The other important role of this function is to fetch and handle events in HighGUI calling. For example, in a loop, if you create a window (using namedWindow) and the display on the screen using imshow(). In this scenario, nothing is shown on the screen until waitKey is called, since HighGUI does not give any time for imshow to process the drawing events.
/* Assuming this is a while loop -> e.g. video stream where img is obtained from say web camera.*/
cvShowImage("Window",img);
/* A small interval of 10 milliseconds. This may be necessary to display the image correctly */
cvWaitKey(10);
/* to wait until user feeds keyboard input replace with cvWaitKey(0); */
No comments:
Post a Comment