Overview
From opencv2/highgui.hpp:55-66:While OpenCV was designed for use in full-scale applications and can be used within functionally rich UI frameworks (such as Qt, WinForms, or Cocoa) or without any UI at all, sometimes there it is required to try functionality quickly and visualize the results. This is what the HighGUI module has been designed for.
Windows
Create and manage display windows
Image Display
Show images with imshow() function
User Input
Handle keyboard and mouse events
Trackbars
Interactive parameter adjustment
Window Management
Creating Windows
From highgui.hpp:142-152:Window Flags
Window Operations
Displaying Images
Basic Image Display
Multiple Images
Updating Display
Keyboard Input
waitKey Function
Interactive Key Handling
From samples/cpp/edge.cpp:Mouse Events
From highgui.hpp:166-189:Mouse Callback
Implementing Mouse Callback
Interactive Drawing
Trackbars
Example from samples/cpp/edge.cpp:Creating Trackbars
Multiple Trackbars
Getting Trackbar Position
Practical Examples
Image Viewer with Controls
ROI Selector
Color Picker
Best Practices
Window Lifecycle:
Always destroy windows when done:
Event Loop:
Without
waitKey() is essential for window updates:waitKey(), windows won’t refresh or respond to events.Trackbar Callbacks:
Trackbar callbacks can be nullptr if you handle updates elsewhere:
Platform-Specific Features
Qt Backend
When built with Qt support, additional features are available:Limitations
Simple GUI Only:
HighGUI is designed for quick visualization and simple interaction. For production applications with complex UI requirements, use:
- Qt
- wxWidgets
- GTK
- Platform-native frameworks
Thread Safety:
HighGUI functions should be called from the main thread. For multi-threaded applications, handle GUI updates carefully.
Related Modules
- Image I/O - Load images to display
- Video I/O - Display video streams
- Image Processing - Process images before display
Source Reference
Main header:~/workspace/source/modules/highgui/include/opencv2/highgui.hpp
Examples:
samples/cpp/edge.cpp- Trackbar usage- Various tutorial samples demonstrate GUI features
