难道cvQueryFrame有缓冲器,用于提前框架? [英] Does cvQueryFrame have buffer for frames in advance?

查看:553
本文介绍了难道cvQueryFrame有缓冲器,用于提前框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我做的:

while(1) { 
   //retrieve image from the camera
   webCamImage=cvQueryFrame(camera) // where 'camera' is cvCreateCameraCapture(0)

   //do some heavy processing on the image that may take around half a second
   funcA()
}

现在,当我去连续迭代,似乎webCamImage落后!

Now when I go to consecutive iterations, it seems that webCamImage lags !

即使我移动相机,webCamImage需要一段时间来更新,视新的领域很长一段时间,它会持续显示和视摄像头帧的处理previous领域。

Even if i move the camera, webCamImage takes long time to get updated to the new field of view, and it keeps showing and processing previous field of view camera frames.

我假设cvQuery具有一定的缓冲区检索帧。

I am assuming that cvQuery has some buffer that retrieves the frames.

您可以请告诉我如何获得更新的摄像头查看每个迭代?

Can you please advise me on how to get the updated camera view each iteration ?

非常感谢

推荐答案

cvQueryFrame 就是这样调用其他两个函数的包装: cvGrabFrame ,它从相机获取数据非常快, cvRetrieveFrame ,其中uncom presses这些数据,并把它放到一个 IplImage结构。如果您需要捕获的帧的立即的只抓帧,并检索它加工以后。

cvQueryFrame is just a wrapper that calls 2 other functions: cvGrabFrame, which gets data from the camera very quickly, and cvRetrieveFrame, which uncompresses this data and puts it into an IplImage. If you need frames captured immediately, just grab the frame, and retrieve it for processing later.

请参阅 http://opencv.jp/opencv-1.0.0_org /docs/ref/opencvref_highgui.htm FMI

话虽如此,不过,我使用 cvQueryFrame 具有典型的摄像头,和我没有麻烦数十帧每秒。任何的机会,这是滞后的部分实际上是在你的 FuncA的行()打电话?的编辑:从您的code中的评论,我看到 FuncA的行()的确是慢的部分。如果需要半秒来执行,你只能从 cvQUeryFrame 新帧每半秒,就像你描述。无论是尝试让 FuncA的行更快,或把它放在一个单独的线程。

Having said that, though, I use cvQueryFrame with a typical webcam, and I have no trouble getting dozens of frames per second. Any chance that the part that's lagging is actually in your funcA() call? edit: from the comment in your code, I see that funcA() is indeed the slow part. If it takes half a second to execute, you'll only get a new frame from cvQUeryFrame every half second, just as you describe. Try either making funcA faster, or put it in a separate thread.

和作为一个友好的提醒,的IplImage cvQueryFrame / cvRetrieveFrame 不应修改或由用户删除;它是OpenCV中的储存物品的内部系统的一部分,如果你正在做什么有趣的事吧,你应该做一个副本。我不知道,如果你这样做了,但我肯定是没有错的时候我开始了。

and as a friendly reminder, the IplImage returned by cvQueryFrame/cvRetrieveFrame should not be modified or deleted by the user; it's part of OpenCV's internal system for storing things, and if you're doing anything interesting with it, you should make a copy. I don't know if you're doing this already, but I certainly did it wrong when I started out.

这篇关于难道cvQueryFrame有缓冲器,用于提前框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆