问题描述
我要过滤视频帧。
for(;;)
{
cap.read( frame);
medianBlur(frame,framedst,5);
imshow("frame",frame);
imshow("framedst",framedst);
if( waitKey (30) >= 0) break;
}
waitKey(30)
是什么意思?因为如果我注释掉 if(waitKey(30)> = 0)break;
这一行,则上面的代码不起作用!
What does the waitKey(30)
mean? Because if I comment out the line if( waitKey (30) >= 0) break;
, the above code doesn't work!
推荐答案
函数 waitKey()
等待键事件发生延迟(此处为30毫秒) )。如所述,HighGui( imshow()
是HighGui的函数)需要定期调用waitKey才能处理其事件循环。
The function waitKey()
waits for a key event for a "delay" (here, 30 milliseconds). As explained in the OpenCV documentation, HighGui (imshow()
is a function of HighGui) need a call of waitKey regularly, in order to process its event loop.
即,如果您不调用waitKey,HighGui将无法处理Windows事件,例如重绘,调整大小,输入事件等。因此,即使有1ms的延迟,也只需调用它即可:)
Ie, if you don't call waitKey, HighGui cannot process windows events like redraw, resizing, input event, etc. So just call it, even with a 1ms delay :)
这篇关于在OpenCV中,waitKey(30)是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!