Possible Duplicate:
OpenCV – cvWaitKey( )
I want to filter the video frame.
for(;;)
{
cap.read( frame);
medianBlur(frame,framedst,5);
imshow("frame",frame);
imshow("framedst",framedst);
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!
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.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 🙂