Skip to main content
The High-Level GUI (highgui) module provides easy-to-use interfaces for creating windows, displaying images, and handling user interaction through keyboard, mouse, and trackbars.

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: waitKey() is essential for window updates:
Without 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.

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