Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EmguCV在查询高分辨率帧时的性能非常差_C#_Opencv_Emgucv - Fatal编程技术网

C# EmguCV在查询高分辨率帧时的性能非常差

C# EmguCV在查询高分辨率帧时的性能非常差,c#,opencv,emgucv,C#,Opencv,Emgucv,我使用EmguCV从我定义如下的捕获中顺序查询帧: Capture cap; private void Form1_Load(object sender, EventArgs e) { cap = new Capture(); cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280); cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PRO

我使用EmguCV从我定义如下的捕获中顺序查询帧:

Capture cap;
private void Form1_Load(object sender, EventArgs e)
{
    cap = new Capture();
    cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
    cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);
    timer1.Interval = 20;
    timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
    Image<Bgr, byte> img = cap.QueryFrame();
    pictureBox1.Image = img.Bitmap;
}
cap;
私有void Form1\u加载(对象发送方、事件参数e)
{
cap=新捕获();
cap.SetCaptureProperty(Emgu.CV.CvEnum.cap_PROP.CV_cap_PROP_FRAME_WIDTH,1280);
cap.SetCaptureProperty(Emgu.CV.CvEnum.cap_PROP.CV_cap_PROP_FRAME_HEIGHT,720);
时间间隔=20;
timer1.Start();
}
私有无效计时器1_刻度(对象发送方,事件参数e)
{
Image img=cap.QueryFrame();
pictureBox1.Image=img.Bitmap;
}
然后我做了一些像跟踪物体这样的操作,但是它的性能非常差,我是说每200毫秒,当移除设置宽度和高度的5,6行时,我就会得到新的帧,我的性能非常好


我的问题是如何获得良好的性能…

不建议使用计时器从网络摄像头获取图像,因为这会导致性能降低。当你的程序做的很少,也就是说,不处理帧时,获取一个帧要好得多。查看代码示例CameraCaptue以供参考,但您的代码应该是这样的

Capture cap;
private void Form1_Load(object sender, EventArgs e)
{
    cap = new Capture();
    cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
    cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);
    Application.Idle += ProcessFrame;
}
private void ProcessFrame(object sender, EventArgs arg)
{
    Image<Bgr, Byte> frame = _capture.QueryFrame();
    pictureBox1.Image = img.Bitmap;
}
cap;
私有void Form1\u加载(对象发送方、事件参数e)
{
cap=新捕获();
cap.SetCaptureProperty(Emgu.CV.CvEnum.cap_PROP.CV_cap_PROP_FRAME_WIDTH,1280);
cap.SetCaptureProperty(Emgu.CV.CvEnum.cap_PROP.CV_cap_PROP_FRAME_HEIGHT,720);
Application.Idle+=ProcessFrame;
}
私有void ProcessFrame(对象发送方、事件args arg)
{
图像帧=_capture.QueryFrame();
pictureBox1.Image=img.Bitmap;
}
使用这种方法,你不局限于定时器的运行速度,而是你的程序在做什么,以及你的相机以其分辨率获取帧的速度。由于它是一个相当高的分辨率类型(720p),我希望15帧,除非你支付了更高的帧速率类型

希望这有帮助

干杯


克里斯

不建议使用计时器从网络摄像机获取图像,因为这会导致性能降低。当你的程序做的很少,也就是说,不处理帧时,获取一个帧要好得多。查看代码示例CameraCaptue以供参考,但您的代码应该是这样的

Capture cap;
private void Form1_Load(object sender, EventArgs e)
{
    cap = new Capture();
    cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
    cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);
    Application.Idle += ProcessFrame;
}
private void ProcessFrame(object sender, EventArgs arg)
{
    Image<Bgr, Byte> frame = _capture.QueryFrame();
    pictureBox1.Image = img.Bitmap;
}
cap;
私有void Form1\u加载(对象发送方、事件参数e)
{
cap=新捕获();
cap.SetCaptureProperty(Emgu.CV.CvEnum.cap_PROP.CV_cap_PROP_FRAME_WIDTH,1280);
cap.SetCaptureProperty(Emgu.CV.CvEnum.cap_PROP.CV_cap_PROP_FRAME_HEIGHT,720);
Application.Idle+=ProcessFrame;
}
私有void ProcessFrame(对象发送方、事件args arg)
{
图像帧=_capture.QueryFrame();
pictureBox1.Image=img.Bitmap;
}
使用这种方法,你不局限于定时器的运行速度,而是你的程序在做什么,以及你的相机以其分辨率获取帧的速度。由于它是一个相当高的分辨率类型(720p),我希望15帧,除非你支付了更高的帧速率类型

希望这有帮助

干杯

克里斯