waitKey
is the function that execute the rendering in HighGUI.
It’s a well documented but no intuitive function. When you use imshow
in a loop, you should call waitKey
even if you don’t want to wait for anything.
waitKey
does three things:
- waits for a keypress
- optionally, waits for a period of time at most, so it can be used as a convenient alternative to sleep()
- renders windows (like pending imshow) before waiting
The waiting is doing by a gui function in GTK, QT or whatever library is used. It is expected to pause the thread with a mutex or equivalent.