Expand description
§High-level GUI
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.
It provides easy interface to:
- Create and manipulate windows that can display images and “remember” their content (no need to handle repaint events from OS).
- Add trackbars to the windows, handle simple mouse events as well as keyboard commands.
§Flags related creating and manipulating HighGUI windows and mouse events
§OpenGL support
§Qt New Functions
This figure explains new functionality implemented with Qt* GUI. The new GUI provides a statusbar, a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it. If you cannot see the control panel, press Ctrl+P or right-click any Qt window and select Display properties window.
-
To attach a trackbar, the window name parameter must be NULL.
-
To attach a buttonbar, a button must be created. If the last bar attached to the control panel is a buttonbar, the new button is added to the right of the last button. If the last bar attached to the control panel is a trackbar, or the control panel is empty, a new buttonbar is created. Then, a new button is attached to it.
See below the example used to generate the figure:
@include highgui_qt.cpp
§WinRT support
This figure explains new functionality implemented with WinRT GUI. The new GUI provides an Image control, and a slider panel. Slider panel holds trackbars attached to it.
Sliders are attached below the image control. Every new slider is added below the previous one.
See below the example used to generate the figure:
void sample_app::MainPage::ShowWindow()
{
static cv::String windowName("sample");
cv::winrt_initContainer(this->cvContainer);
cv::namedWindow(windowName); // not required
cv::Mat image = cv::imread("Assets/sample.jpg");
cv::Mat converted = cv::Mat(image.rows, image.cols, CV_8UC4);
cv::cvtColor(image, converted, COLOR_BGR2BGRA);
cv::imshow(windowName, converted); // this will create window if it hasn't been created before
int state = 42;
cv::TrackbarCallback callback = [](int pos, void* userdata)
{
if (pos == 0) {
cv::destroyWindow(windowName);
}
};
cv::TrackbarCallback callbackTwin = [](int pos, void* userdata)
{
if (pos >= 70) {
cv::destroyAllWindows();
}
};
cv::createTrackbar("Sample trackbar", windowName, &state, 100, callback);
cv::createTrackbar("Twin brother", windowName, &state, 100, callbackTwin);
}
Modules§
Structs§
- QtFont
- QtFont available only for Qt. See cv::fontQt
Enums§
- Mouse
Event Flags - Mouse Event Flags see cv::MouseCallback
- Mouse
Event Types - Mouse Events see cv::MouseCallback
- QtButton
Types - Qt “button” type
- QtFont
Styles - Qt font style
- QtFont
Weights - Qt font weight
- Window
Flags - Flags for cv::namedWindow
- Window
Property Flags - Flags for cv::setWindowProperty / cv::getWindowProperty
Constants§
- EVENT_
FLAG_ ALTKEY - indicates that ALT Key is pressed.
- EVENT_
FLAG_ CTRLKEY - indicates that CTRL Key is pressed.
- EVENT_
FLAG_ LBUTTON - indicates that the left mouse button is down.
- EVENT_
FLAG_ MBUTTON - indicates that the middle mouse button is down.
- EVENT_
FLAG_ RBUTTON - indicates that the right mouse button is down.
- EVENT_
FLAG_ SHIFTKEY - indicates that SHIFT Key is pressed.
- EVENT_
LBUTTONDBLCLK - indicates that left mouse button is double clicked.
- EVENT_
LBUTTONDOWN - indicates that the left mouse button is pressed.
- EVENT_
LBUTTONUP - indicates that left mouse button is released.
- EVENT_
MBUTTONDBLCLK - indicates that middle mouse button is double clicked.
- EVENT_
MBUTTONDOWN - indicates that the middle mouse button is pressed.
- EVENT_
MBUTTONUP - indicates that middle mouse button is released.
- EVENT_
MOUSEHWHEEL - positive and negative values mean right and left scrolling, respectively.
- EVENT_
MOUSEMOVE - indicates that the mouse pointer has moved over the window.
- EVENT_
MOUSEWHEEL - positive and negative values mean forward and backward scrolling, respectively.
- EVENT_
RBUTTONDBLCLK - indicates that right mouse button is double clicked.
- EVENT_
RBUTTONDOWN - indicates that the right mouse button is pressed.
- EVENT_
RBUTTONUP - indicates that right mouse button is released.
- QT_
CHECKBOX - Checkbox button.
- QT_
FONT_ BLACK - Weight of 87
- QT_
FONT_ BOLD - Weight of 75
- QT_
FONT_ DEMIBOLD - Weight of 63
- QT_
FONT_ LIGHT - Weight of 25
- QT_
FONT_ NORMAL - Weight of 50
- QT_
NEW_ BUTTONBAR - Button should create a new buttonbar
- QT_
PUSH_ BUTTON - Push button.
- QT_
RADIOBOX - Radiobox button.
- QT_
STYLE_ ITALIC - Italic font.
- QT_
STYLE_ NORMAL - Normal font.
- QT_
STYLE_ OBLIQUE - Oblique font.
- WINDOW_
AUTOSIZE - the user cannot resize the window, the size is constrainted by the image displayed.
- WINDOW_
FREERATIO - the image expends as much as it can (no ratio constraint).
- WINDOW_
FULLSCREEN - change the window to fullscreen.
- WINDOW_
GUI_ EXPANDED - status bar and tool bar
- WINDOW_
GUI_ NORMAL - old fashious way
- WINDOW_
KEEPRATIO - the ratio of the image is respected.
- WINDOW_
NORMAL - the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size.
- WINDOW_
OPENGL - window with opengl support.
- WND_
PROP_ ASPECT_ RATIO - window’s aspect ration (can be set to WINDOW_FREERATIO or WINDOW_KEEPRATIO).
- WND_
PROP_ AUTOSIZE - autosize property (can be WINDOW_NORMAL or WINDOW_AUTOSIZE).
- WND_
PROP_ FULLSCREEN - fullscreen property (can be WINDOW_NORMAL or WINDOW_FULLSCREEN).
- WND_
PROP_ OPENGL - opengl support.
- WND_
PROP_ TOPMOST - property to toggle normal window being topmost or not
- WND_
PROP_ VISIBLE - checks whether the window exists and is visible
- WND_
PROP_ VSYNC - enable or disable VSYNC (in OpenGL mode)
Traits§
- QtFont
Trait - Mutable methods for crate::highgui::QtFont
- QtFont
Trait Const - Constant methods for crate::highgui::QtFont
Functions§
- add_
text - Draws a text on the image.
- add_
text_ with_ font - Draws a text on the image.
- add_
text_ with_ font_ def - Draws a text on the image.
- create_
button - Attaches a button to the control panel.
- create_
button_ def - Attaches a button to the control panel.
- create_
trackbar - Creates a trackbar and attaches it to the specified window.
- current_
ui_ framework - HighGUI backend used.
- destroy_
all_ windows - Destroys all of the HighGUI windows.
- destroy_
window - Destroys the specified window.
- display_
overlay - Displays a text on a window image as an overlay for a specified duration.
- display_
overlay_ def - Displays a text on a window image as an overlay for a specified duration.
- display_
status_ bar - Displays a text on the window statusbar during the specified period of time.
- display_
status_ bar_ def - Displays a text on the window statusbar during the specified period of time.
- font_qt
- Creates the font to draw a text on an image.
- font_
qt_ def - Creates the font to draw a text on an image.
- get_
mouse_ wheel_ delta - Gets the mouse-wheel motion delta, when handling mouse-wheel events cv::EVENT_MOUSEWHEEL and cv::EVENT_MOUSEHWHEEL.
- get_
trackbar_ pos - Returns the trackbar position.
- get_
window_ image_ rect - Provides rectangle of image in the window.
- get_
window_ property - Provides parameters of a window.
- imshow
- Displays an image in the specified window.
- load_
window_ parameters - Loads parameters of the specified window.
- move_
window - Moves the window to the specified position
- named_
window - Creates a window.
- named_
window_ def - Creates a window.
- poll_
key - Polls for a pressed key.
- resize_
window - Resizes the window to the specified size
- resize_
window_ size - Resizes the window to the specified size
- save_
window_ parameters - Saves parameters of the specified window.
- select_
ro_ is - Allows users to select multiple ROIs on the given image.
- select_
ro_ is_ def - Allows users to select multiple ROIs on the given image.
- select_
roi - Allows users to select a ROI on the given image.
- select_
roi_ 1 - Allows users to select a ROI on the given image.
- select_
roi_ 1_ def - @overload
- select_
roi_ def - Allows users to select a ROI on the given image.
- set_
mouse_ callback - @example samples/cpp/create_mask.cpp This program demonstrates using mouse events and how to make and use a mask image (black and white) .
- set_
opengl_ context - Sets the specified window as current OpenGL context.
- set_
opengl_ draw_ callback - Sets a callback function to be called to draw on top of displayed image.
- set_
trackbar_ max - Sets the trackbar maximum position.
- set_
trackbar_ min - Sets the trackbar minimum position.
- set_
trackbar_ pos - Sets the trackbar position.
- set_
window_ property - Changes parameters of a window dynamically.
- set_
window_ title - Updates window title
- start_
loop - start_
window_ thread - stop_
loop - update_
window - Force window to redraw its context and call draw callback ( See cv::setOpenGlDrawCallback ).
- wait_
key - Waits for a pressed key.
- wait_
key_ def - Waits for a pressed key.
- wait_
key_ ex - Similar to #waitKey, but returns full key code.
- wait_
key_ ex_ def - Similar to #waitKey, but returns full key code.
Type Aliases§
- Button
Callback - Callback function for a button created by cv::createButton
- Mouse
Callback - Callback function for mouse events. see cv::setMouseCallback
- Open
GlDraw Callback - Callback function defined to be called every frame. See cv::setOpenGlDrawCallback
- Trackbar
Callback - Callback function for Trackbar see cv::createTrackbar