What happens during the execution of cvWaitKey()
? What are some typical use cases? I saw it in OpenCV reference but the documentation isn't clear on its exact purpose.
相关问题
- Sorting 3 numbers without branching [closed]
- Multiple sockets for clients to connect to
- How to get the background from multiple images by
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
cvWaitKey(0)
stops your program until you press a button.cvWaitKey(10)
doesn't stop your program but wake up and alert to end your program when you press a button. Its used into loops becausecvWaitkey
doesn't stop loop.Normal use
with
k
you can see what key was pressed.. argument of
0
is interpreted asinfinite
. in order to drag the highGUI windows, you need to continually call the
cv::waitKey()
function. eg for static images:cv::imshow("winname", img);
while(cv::waitKey(1) != 27); // 27 = ascii value of ESC
Plain simply,
cvWaitKey()
sleeps for X miliseconds, waiting for any key to be pressed.If a key is pressed, this function returns the ASCII code of key. Or returns -1 if no keys were pressed during that time.