OpenCV的cvQueryFrame“非阻塞在OS X上? [英] OpenCV 'cvQueryFrame' non-blocking on OS X?
问题描述
当我在Windows上执行cvQueryFrame,该API阻止,直到图像被交付。在Mac OS X,我在100%的CPU使用率,而只有在查询图像,并在窗口中显示它。我在最新的SVN版本。任何人都可以证实我的经验?难道我做错了什么?是否有变通?
我的循环code是这样的:
而(关键!='Q'){
如果(帧)
cvShowImage(活凸轮,帧);
帧= NULL;
帧= cvQueryFrame(捕捉);
键= cvWaitKey(10);
}
我只是执行的演示应用程序I <一个href=\"http://stackoverflow.com/questions/3907028/opencv-every-frame-processing/3919216#3919216\">$p$psented这里它使用〜22%的CPU,根据活动监视器的。我跑的程序上的MacBook Pro 13,用的OpenCV 2.1( 32位)。
如果你留意了code,你会发现,循环是从你有点不同:
的IplImage *帧= NULL;
字符键= 0;
而(关键!= 27)// ESC
{
帧= cvQueryFrame(捕捉);
如果(!帧)
{
fprintf中(标准错误,!!! cvQueryFrame失败\\ n!);
打破;
} cvShowImage(活凸轮,帧);
键= cvWaitKey(10);
}
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 latest 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);
}
这篇关于OpenCV的cvQueryFrame“非阻塞在OS X上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!