如何提高网络摄像头视频输入的帧速率?恩古简历



我正在使用emgu CV和C#,并在捕获/显示网络摄像头视频时获得低FPS(约8fps)! 到目前为止,这是我尝试过的:我还必须应用一些过滤器,如何使我的代码更有效率?有没有办法使用 GPU 处理这些帧?

    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;
        }
    }

问题是您正在处理 Application.Idle 回调上的帧,该回调仅每隔一段时间调用一次。替换此行

Application.Idle += ProcessFrame

_capture.ImageGrabbed += ProcessFrame

它应该有效。每次帧可用时都会调用此回调。

最新更新