我正在使用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;
}
}
答案 0 :(得分:1)
问题是你正在处理Application.Idle回调上的帧,它只是经常被调用。替换此行
Application.Idle += ProcessFrame
带
_capture.ImageGrabbed += ProcessFrame
它应该有效。每当帧可用时,都会调用此回调。