Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'm agree with @StevenPuttemans. The correct and efficient way depends on GUI you are using: Win32,MFC, QT, wxWidgets, GTK, OpenGL, ... and/or CUDA, OpenCL and so on.

OpenCV provides a memory bank that you have to copy to (or share with) the graphic device and this is done by some user interface library. HighGUI is simplest one.

imshow and waitKey(delay) uses basic functions from platform you are using.On Windows, the Win32 library is used by default.

imshow copy the cv::Mat into a DIB image and Invalidate the Rect related to window on the screen.

Despite of its name, the waitKey function is the only method in HighGUI that can fetch and handle events, so it needs to be called periodically for normal event processing unless HighGUI is used within an environment that takes care of event processing.

This means that waitKey takes care of (executes) all GUI events such as show, refresh a window and so on. In addictions it waits for N millisecs a key press over an OpenCV window. I think it should be considered as UpdateGUI+WaitKey

Sure you will waste N millisecs waiting an usefulness key press but you have to wait also to serve all GUI events.

If you want to use HighGUI from OpenCV, you could write your own UpdateGUI hacking the waitKey code around delay<=0 and choose to serve only message for a specific window (window->hwnd == message.hwnd). Not so easy and maybe not so useful but I think feasible.