开发者

Does cvQueryFrame have buffer for frames in advance?

If i do:

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()
}

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

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.

I am assuming that c开发者_如何转开发vQuery has some buffer that retrieves the frames.

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

Many thanks


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.

See http://opencv.jp/opencv-1.0.0_org/docs/ref/opencvref_highgui.htm FMI

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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜