when I perform a cvQueryFrame on Windows, the API blocks until an image is delivered. On Mac OS X, I am at 100% CPU utilization, while only querying for an image and displaying it in a window. I am at the la开发者_JAVA百科test SVN version. Can anyone confirm my experience? Am I doing something wrong? Is there a work-around?
My loop code looks like this:
while(key != 'q') {
if (frame)
cvShowImage("Live Cam", frame);
frame = NULL;
frame = cvQueryFrame(capture);
key = cvWaitKey(10);
}
I just executed a demo application I presented here and it uses ~22% CPU, according to Activity Monitor. I ran the program on a Macbook Pro 13", with OpenCV 2.1 (32bits).
If you pay attention to that code you'll notice that the loop is a little bit different from yours:
IplImage* frame = NULL;
char key = 0;
while (key != 27) // ESC
{
frame = cvQueryFrame(capture);
if(!frame)
{
fprintf( stderr, "!!! cvQueryFrame failed!\n" );
break;
}
cvShowImage("Live Cam", frame );
key = cvWaitKey(10);
}
精彩评论