[英]Is Emgu CV QueryFrame method asynchronous?
I am currently using the EmguCV QueryFrame
method to capture frames. 我目前正在使用EmguCV QueryFrame
方法捕获帧。 The code is something like this, inside my processFrame
method: 代码在我的processFrame
方法中是这样的:
using(Image<Bgr, Byte> imgOriginal = _capture.QueryFrame()){
if(imgOriginal == null) return;
using(Image<Gray, Byte> grayImg = imgOriginal.Convert<Gray, Byte>()){
//some stuff with grayImg
}
}
The problem I'm facing is that I keep getting an OutOfMemory
exception. 我面临的问题是我不断收到OutOfMemory
异常。 Upon further inspection with MemProfiler
, I find that a Byte[,,]
object of namespace System
uses up exponentially more memory than anything else. 通过对MemProfiler
进一步检查,我发现名称空间System
的Byte[,,]
对象使用的内存成倍增加。 The only Byte[,,]
I can think of is the Bgr
frame imgOriginal
that is captured. 我能想到的唯一的Byte[,,]
是捕获的Bgr
帧imgOriginal
。
This leads me to believe that the Capture
object keeps on querying new frames even if the code within the using block has not finished executing. 这使我相信,即使using块中的代码尚未完成执行, Capture
对象仍会继续查询新帧。 Is this true? 这是真的? Or is there some other reason? 还是还有其他原因? Is there any way to solve this? 有什么办法解决这个问题?
Any help would be appreciated. 任何帮助,将不胜感激。 Thank you. 谢谢。
What version of EMGU are you using? 您正在使用哪个版本的EMGU?
Try this: 尝试这个:
Mat frame = new Mat();
_capture.Retrieve(frame, 0);
For converting to grayscale: 转换为灰度:
Mat grayFrame = new Mat();
CvInvoke.CvtColor(frame, grayFrame, ColorConversion.Bgr2Gray);
Also, you can try to check how it works in the examples section of EMGU. 另外,您可以尝试在EMGU的示例部分中检查其工作方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.