Loading...
Searching...
No Matches

Classes

struct  cv::QtFont
 QtFont available only for Qt. See cv::fontQt. More...
 

Enumerations

enum  cv::QtButtonTypes {
  cv::QT_PUSH_BUTTON = 0 ,
  cv::QT_CHECKBOX = 1 ,
  cv::QT_RADIOBOX = 2 ,
  cv::QT_NEW_BUTTONBAR = 1024
}
 Qt "button" type. More...
 
enum  cv::QtFontStyles {
  cv::QT_STYLE_NORMAL = 0 ,
  cv::QT_STYLE_ITALIC = 1 ,
  cv::QT_STYLE_OBLIQUE = 2
}
 Qt font style. More...
 
enum  cv::QtFontWeights {
  cv::QT_FONT_LIGHT = 25 ,
  cv::QT_FONT_NORMAL = 50 ,
  cv::QT_FONT_DEMIBOLD = 63 ,
  cv::QT_FONT_BOLD = 75 ,
  cv::QT_FONT_BLACK = 87
}
 Qt font weight. More...
 

Functions

void cv::addText (const Mat &img, const String &text, Point org, const QtFont &font)
 Draws a text on the image.
 
void cv::addText (const Mat &img, const String &text, Point org, const String &nameFont, int pointSize=-1, Scalar color=Scalar::all(0), int weight=QT_FONT_NORMAL, int style=QT_STYLE_NORMAL, int spacing=0)
 Draws a text on the image.
 
int cv::createButton (const String &bar_name, ButtonCallback on_change, void *userdata=0, int type=QT_PUSH_BUTTON, bool initial_button_state=false)
 Attaches a button to the control panel.
 
void cv::displayOverlay (const String &winname, const String &text, int delayms=0)
 Displays a text on a window image as an overlay for a specified duration.
 
void cv::displayStatusBar (const String &winname, const String &text, int delayms=0)
 Displays a text on the window statusbar during the specified period of time.
 
QtFont cv::fontQt (const String &nameFont, int pointSize=-1, Scalar color=Scalar::all(0), int weight=QT_FONT_NORMAL, int style=QT_STYLE_NORMAL, int spacing=0)
 Creates the font to draw a text on an image.
 
void cv::loadWindowParameters (const String &windowName)
 Loads parameters of the specified window.
 
void cv::saveWindowParameters (const String &windowName)
 Saves parameters of the specified window.
 
int cv::startLoop (int(*pt2Func)(int argc, char *argv[]), int argc, char *argv[])
 
void cv::stopLoop ()
 

Detailed Description

image

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:

int main(int argc, char *argv[])
{
int value = 50;
int value2 = 0;
createTrackbar( "track1", "main1", &value, 255, NULL);
String nameb1 = "button1";
String nameb2 = "button2";
createButton(nameb1,callbackButton,&nameb1,QT_CHECKBOX,1);
createButton(nameb2,callbackButton,NULL,QT_CHECKBOX,0);
createTrackbar( "track2", NULL, &value2, 255, NULL);
createButton("button5",callbackButton1,NULL,QT_RADIOBOX,0);
createButton("button6",callbackButton2,NULL,QT_RADIOBOX,1);
setMouseCallback( "main2",on_mouse,NULL );
Mat img1 = imread("files/flower.jpg");
VideoCapture video;
video.open("files/hockey.avi");
Mat img2,img3;
while( waitKey(33) != 27 )
{
img1.convertTo(img2,-1,1,value);
video >> img3;
imshow("main1",img2);
imshow("main2",img3);
}
return 0;
}
std::string String
Definition: cvstd.hpp:152
int createButton(const String &bar_name, ButtonCallback on_change, void *userdata=0, int type=QT_PUSH_BUTTON, bool initial_button_state=false)
Attaches a button to the control panel.
@ QT_CHECKBOX
Checkbox button.
Definition: highgui.hpp:259
@ QT_RADIOBOX
Radiobox button.
Definition: highgui.hpp:260
@ WINDOW_NORMAL
the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal s...
Definition: highgui.hpp:187
@ WINDOW_GUI_NORMAL
old fashious way
Definition: highgui.hpp:195
@ WINDOW_AUTOSIZE
the user cannot resize the window, the size is constrainted by the image displayed.
Definition: highgui.hpp:188
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
void destroyAllWindows()
Destroys all of the HighGUI windows.
void setMouseCallback(const String &winname, MouseCallback onMouse, void *userdata=0)
Sets mouse handler for the specified window.
int createTrackbar(const String &trackbarname, const String &winname, int *value, int count, TrackbarCallback onChange=0, void *userdata=0)
Creates a trackbar and attaches it to the specified window.
CV_EXPORTS_W Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
@defgroup highgui_winrt 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:
@code
    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);
    }
@endcode

@defgroup highgui_c C API

Enumeration Type Documentation

◆ QtButtonTypes

#include <opencv2/highgui.hpp>

Qt "button" type.

Enumerator
QT_PUSH_BUTTON 

Push button.

QT_CHECKBOX 

Checkbox button.

QT_RADIOBOX 

Radiobox button.

QT_NEW_BUTTONBAR 

Button should create a new buttonbar.

◆ QtFontStyles

#include <opencv2/highgui.hpp>

Qt font style.

Enumerator
QT_STYLE_NORMAL 

Normal font.

QT_STYLE_ITALIC 

Italic font.

QT_STYLE_OBLIQUE 

Oblique font.

◆ QtFontWeights

#include <opencv2/highgui.hpp>

Qt font weight.

Enumerator
QT_FONT_LIGHT 

Weight of 25.

QT_FONT_NORMAL 

Weight of 50.

QT_FONT_DEMIBOLD 

Weight of 63.

QT_FONT_BOLD 

Weight of 75.

QT_FONT_BLACK 

Weight of 87.

Function Documentation

◆ addText() [1/2]

void cv::addText ( const Mat img,
const String text,
Point  org,
const QtFont font 
)

#include <opencv2/highgui.hpp>

Draws a text on the image.

The function addText draws text on the image img using a specific font font (see example cv::fontQt )

Parameters
img8-bit 3-channel image where the text should be drawn.
textText to write on an image.
orgPoint(x,y) where the text should start on an image.
fontFont to use to draw a text.

◆ addText() [2/2]

void cv::addText ( const Mat img,
const String text,
Point  org,
const String nameFont,
int  pointSize = -1,
Scalar  color = Scalar::all(0),
int  weight = QT_FONT_NORMAL,
int  style = QT_STYLE_NORMAL,
int  spacing = 0 
)

#include <opencv2/highgui.hpp>

Draws a text on the image.

Parameters
img8-bit 3-channel image where the text should be drawn.
textText to write on an image.
orgPoint(x,y) where the text should start on an image.
nameFontName of the font. The name should match the name of a system font (such as Times*). If the font is not found, a default one is used.
pointSizeSize of the font. If not specified, equal zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.
colorColor of the font in BGRA where A = 255 is fully transparent.
weightFont weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.
styleFont style. Available operation flags are : cv::QtFontStyles
spacingSpacing between characters. It can be negative or positive.

◆ createButton()

int cv::createButton ( const String bar_name,
ButtonCallback  on_change,
void *  userdata = 0,
int  type = QT_PUSH_BUTTON,
bool  initial_button_state = false 
)

#include <opencv2/highgui.hpp>

Attaches a button to the control panel.

The function createButton attaches a button to the control panel. Each button is added to a buttonbar to the right of the last button. A new buttonbar is created if nothing was attached to the control panel before, or if the last element attached to the control panel was a trackbar or if the QT_NEW_BUTTONBAR flag is added to the type.

See below various examples of the cv::createButton function call: :

createButton("",callbackButton);//create a push button "button 0", that will call callbackButton.
createButton("button2",callbackButton,NULL,QT_CHECKBOX,0);
createButton("button3",callbackButton,&value);
createButton("button5",callbackButton1,NULL,QT_RADIOBOX);
createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON,1);
createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON|QT_NEW_BUTTONBAR);// create a push button in a new row
@ QT_PUSH_BUTTON
Push button.
Definition: highgui.hpp:258
@ QT_NEW_BUTTONBAR
Button should create a new buttonbar.
Definition: highgui.hpp:261
Parameters
bar_nameName of the button.
on_changePointer to the function to be called every time the button changes its state. This function should be prototyped as void Foo(int state,*void); . state is the current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
userdataPointer passed to the callback function.
typeOptional type of the button. Available types are: (cv::QtButtonTypes)
initial_button_stateDefault state of the button. Use for checkbox and radiobox. Its value could be 0 or 1. (Optional)

◆ displayOverlay()

void cv::displayOverlay ( const String winname,
const String text,
int  delayms = 0 
)

#include <opencv2/highgui.hpp>

Displays a text on a window image as an overlay for a specified duration.

The function displayOverlay displays useful information/tips on top of the window for a certain amount of time delayms. The function does not modify the image, displayed in the window, that is, after the specified delay the original content of the window is restored.

Parameters
winnameName of the window.
textOverlay text to write on a window image.
delaymsThe period (in milliseconds), during which the overlay text is displayed. If this function is called before the previous overlay text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.

◆ displayStatusBar()

void cv::displayStatusBar ( const String winname,
const String text,
int  delayms = 0 
)

#include <opencv2/highgui.hpp>

Displays a text on the window statusbar during the specified period of time.

The function displayStatusBar displays useful information/tips on top of the window for a certain amount of time delayms . This information is displayed on the window statusbar (the window must be created with the CV_GUI_EXPANDED flags).

Parameters
winnameName of the window.
textText to write on the window statusbar.
delaymsDuration (in milliseconds) to display the text. If this function is called before the previous text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.

◆ fontQt()

QtFont cv::fontQt ( const String nameFont,
int  pointSize = -1,
Scalar  color = Scalar::all(0),
int  weight = QT_FONT_NORMAL,
int  style = QT_STYLE_NORMAL,
int  spacing = 0 
)

#include <opencv2/highgui.hpp>

Creates the font to draw a text on an image.

The function fontQt creates a cv::QtFont object. This cv::QtFont is not compatible with putText .

A basic usage of this function is the following: :

QtFont font = fontQt("Times");
addText( img1, "Hello World !", Point(50,50), font);
Point2i Point
Definition: types.hpp:209
void addText(const Mat &img, const String &text, Point org, const QtFont &font)
Draws a text on the image.
QtFont fontQt(const String &nameFont, int pointSize=-1, Scalar color=Scalar::all(0), int weight=QT_FONT_NORMAL, int style=QT_STYLE_NORMAL, int spacing=0)
Creates the font to draw a text on an image.
QtFont available only for Qt. See cv::fontQt.
Definition: highgui.hpp:717
Parameters
nameFontName of the font. The name should match the name of a system font (such as Times*). If the font is not found, a default one is used.
pointSizeSize of the font. If not specified, equal zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.
colorColor of the font in BGRA where A = 255 is fully transparent. Use the macro CV_RGB for simplicity.
weightFont weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.
styleFont style. Available operation flags are : cv::QtFontStyles
spacingSpacing between characters. It can be negative or positive.

◆ loadWindowParameters()

void cv::loadWindowParameters ( const String windowName)

#include <opencv2/highgui.hpp>

Loads parameters of the specified window.

The function loadWindowParameters loads size, location, flags, trackbars value, zoom and panning location of the window windowName.

Parameters
windowNameName of the window.

◆ saveWindowParameters()

void cv::saveWindowParameters ( const String windowName)

#include <opencv2/highgui.hpp>

Saves parameters of the specified window.

The function saveWindowParameters saves size, location, flags, trackbars value, zoom and panning location of the window windowName.

Parameters
windowNameName of the window.

◆ startLoop()

int cv::startLoop ( int(*)(int argc, char *argv[])  pt2Func,
int  argc,
char *  argv[] 
)

#include <opencv2/highgui.hpp>

◆ stopLoop()

void cv::stopLoop ( )

#include <opencv2/highgui.hpp>