2012-12-16 131 views
3

我正在使用emgu CV & C#,并在捕获/显示网络摄像头视频时获得低FPS(约8fps)!到目前为止,这是我所尝试的: 我必须应用一些过滤器,我怎样才能让我的代码更有效率? 有什么办法来使用GPU来处理这些帧?如何提高摄像头视频输入的帧速率? Emgu CV

private Capture _capture; 
    private bool _captureInProgress; 
    private Image<Bgr, Byte> frame; 
    private void ProcessFrame(object sender, EventArgs arg) 
    { 
     frame = _capture.QueryFrame(); 
     captureImageBox.Image = frame; 

    } 

    private void startToolStripMenuItem_Click(object sender, EventArgs e) 
    { 
     #region if capture is not created, create it now 
     if (_capture == null) 
     { 
      try 
      { 
       _capture = new Capture(); 
      } 
      catch (NullReferenceException excpt) 
      { 
       MessageBox.Show(excpt.Message); 
      } 
     } 
     #endregion 

     Application.Idle += ProcessFrame; 

     if (_capture != null) 
     { 
      if (_captureInProgress) 
      { 
       //stop the capture 

       startToolStripMenuItem.Text = "Start"; 
       Application.Idle -= ProcessFrame; 
      } 
      else 
      { 
       //start the capture 
       startToolStripMenuItem.Text = "Stop"; 
       Application.Idle += ProcessFrame; 
      } 

      _captureInProgress = !_captureInProgress; 
     } 
    } 
+0

您是否检查过此网址:http://www.emgu.com/forum/viewtopic.php?f=7&t=2602? –

+0

是的!但它不起作用! :/ – SparkWerk

+0

@Umair是否仍然是一个问题?您发布的代码似乎什么都不做,只是从网络摄像头获取帧而不做任何进一步处理。你能发布更多的代码和你的摄像头的类型? – codingadventures

回答

1

问题是你正在处理Application.Idle回调中的帧,它只是经常被调用。替换该行

Application.Idle += ProcessFrame

_capture.ImageGrabbed += ProcessFrame

,它应该工作。每当有帧可用时,都会调用此回调。

+1

不应该是_capture.ImageGrabbed + = ProcessFrame? – gonzobrains

+0

这不适合我。 ProcessFrame从未被调用过,我的程序只是坐在那里。 –