Tuesday, June 9, 2009

with opencv, dont forget cvWaitKey() when grabbing your frames

Currently I program an application in C++ with openCV and brought it together with the QT library. Transforming an example was easy, at least to get it compiled. But the capturing process was not running in its own loop, an update was triggerd regularly by a timer. The result was that I recieved only the first initial frame.

Solution was to reinsert the waiting for key function cvWaitKey with a small value which I removed because it seemed without any use. Now I get all frames...

For instance like this:
...
IplImage* image =cvQueryFrame( capture );
cvShowImage( "Window", image);
cvWaitKey(1);

...

2 comments: