opencv on mbed

Dependencies:   mbed

Committer:
joeverbout
Date:
Thu Mar 31 21:16:38 2016 +0000
Revision:
0:ea44dc9ed014
OpenCV on mbed attempt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeverbout 0:ea44dc9ed014 1 /*M///////////////////////////////////////////////////////////////////////////////////////
joeverbout 0:ea44dc9ed014 2 //
joeverbout 0:ea44dc9ed014 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
joeverbout 0:ea44dc9ed014 4 //
joeverbout 0:ea44dc9ed014 5 // By downloading, copying, installing or using the software you agree to this license.
joeverbout 0:ea44dc9ed014 6 // If you do not agree to this license, do not download, install,
joeverbout 0:ea44dc9ed014 7 // copy or use the software.
joeverbout 0:ea44dc9ed014 8 //
joeverbout 0:ea44dc9ed014 9 //
joeverbout 0:ea44dc9ed014 10 // License Agreement
joeverbout 0:ea44dc9ed014 11 // For Open Source Computer Vision Library
joeverbout 0:ea44dc9ed014 12 //
joeverbout 0:ea44dc9ed014 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
joeverbout 0:ea44dc9ed014 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
joeverbout 0:ea44dc9ed014 15 // Third party copyrights are property of their respective owners.
joeverbout 0:ea44dc9ed014 16 //
joeverbout 0:ea44dc9ed014 17 // Redistribution and use in source and binary forms, with or without modification,
joeverbout 0:ea44dc9ed014 18 // are permitted provided that the following conditions are met:
joeverbout 0:ea44dc9ed014 19 //
joeverbout 0:ea44dc9ed014 20 // * Redistribution's of source code must retain the above copyright notice,
joeverbout 0:ea44dc9ed014 21 // this list of conditions and the following disclaimer.
joeverbout 0:ea44dc9ed014 22 //
joeverbout 0:ea44dc9ed014 23 // * Redistribution's in binary form must reproduce the above copyright notice,
joeverbout 0:ea44dc9ed014 24 // this list of conditions and the following disclaimer in the documentation
joeverbout 0:ea44dc9ed014 25 // and/or other materials provided with the distribution.
joeverbout 0:ea44dc9ed014 26 //
joeverbout 0:ea44dc9ed014 27 // * The name of the copyright holders may not be used to endorse or promote products
joeverbout 0:ea44dc9ed014 28 // derived from this software without specific prior written permission.
joeverbout 0:ea44dc9ed014 29 //
joeverbout 0:ea44dc9ed014 30 // This software is provided by the copyright holders and contributors "as is" and
joeverbout 0:ea44dc9ed014 31 // any express or implied warranties, including, but not limited to, the implied
joeverbout 0:ea44dc9ed014 32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
joeverbout 0:ea44dc9ed014 33 // In no event shall the Intel Corporation or contributors be liable for any direct,
joeverbout 0:ea44dc9ed014 34 // indirect, incidental, special, exemplary, or consequential damages
joeverbout 0:ea44dc9ed014 35 // (including, but not limited to, procurement of substitute goods or services;
joeverbout 0:ea44dc9ed014 36 // loss of use, data, or profits; or business interruption) however caused
joeverbout 0:ea44dc9ed014 37 // and on any theory of liability, whether in contract, strict liability,
joeverbout 0:ea44dc9ed014 38 // or tort (including negligence or otherwise) arising in any way out of
joeverbout 0:ea44dc9ed014 39 // the use of this software, even if advised of the possibility of such damage.
joeverbout 0:ea44dc9ed014 40 //
joeverbout 0:ea44dc9ed014 41 //M*/
joeverbout 0:ea44dc9ed014 42
joeverbout 0:ea44dc9ed014 43 #ifndef __OPENCV_HIGHGUI_HPP__
joeverbout 0:ea44dc9ed014 44 #define __OPENCV_HIGHGUI_HPP__
joeverbout 0:ea44dc9ed014 45
joeverbout 0:ea44dc9ed014 46 #include "opencv2/core.hpp"
joeverbout 0:ea44dc9ed014 47 #include "opencv2/imgcodecs.hpp"
joeverbout 0:ea44dc9ed014 48 #include "opencv2/videoio.hpp"
joeverbout 0:ea44dc9ed014 49
joeverbout 0:ea44dc9ed014 50 /**
joeverbout 0:ea44dc9ed014 51 @defgroup highgui High-level GUI
joeverbout 0:ea44dc9ed014 52
joeverbout 0:ea44dc9ed014 53 While OpenCV was designed for use in full-scale applications and can be used within functionally
joeverbout 0:ea44dc9ed014 54 rich UI frameworks (such as Qt\*, WinForms\*, or Cocoa\*) or without any UI at all, sometimes there
joeverbout 0:ea44dc9ed014 55 it is required to try functionality quickly and visualize the results. This is what the HighGUI
joeverbout 0:ea44dc9ed014 56 module has been designed for.
joeverbout 0:ea44dc9ed014 57
joeverbout 0:ea44dc9ed014 58 It provides easy interface to:
joeverbout 0:ea44dc9ed014 59
joeverbout 0:ea44dc9ed014 60 - Create and manipulate windows that can display images and "remember" their content (no need to
joeverbout 0:ea44dc9ed014 61 handle repaint events from OS).
joeverbout 0:ea44dc9ed014 62 - Add trackbars to the windows, handle simple mouse events as well as keyboard commands.
joeverbout 0:ea44dc9ed014 63
joeverbout 0:ea44dc9ed014 64 @{
joeverbout 0:ea44dc9ed014 65 @defgroup highgui_opengl OpenGL support
joeverbout 0:ea44dc9ed014 66 @defgroup highgui_qt Qt New Functions
joeverbout 0:ea44dc9ed014 67
joeverbout 0:ea44dc9ed014 68 ![image](pics/qtgui.png)
joeverbout 0:ea44dc9ed014 69
joeverbout 0:ea44dc9ed014 70 This figure explains new functionality implemented with Qt\* GUI. The new GUI provides a statusbar,
joeverbout 0:ea44dc9ed014 71 a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it.
joeverbout 0:ea44dc9ed014 72 If you cannot see the control panel, press Ctrl+P or right-click any Qt window and select **Display
joeverbout 0:ea44dc9ed014 73 properties window**.
joeverbout 0:ea44dc9ed014 74
joeverbout 0:ea44dc9ed014 75 - To attach a trackbar, the window name parameter must be NULL.
joeverbout 0:ea44dc9ed014 76
joeverbout 0:ea44dc9ed014 77 - To attach a buttonbar, a button must be created. If the last bar attached to the control panel
joeverbout 0:ea44dc9ed014 78 is a buttonbar, the new button is added to the right of the last button. If the last bar
joeverbout 0:ea44dc9ed014 79 attached to the control panel is a trackbar, or the control panel is empty, a new buttonbar is
joeverbout 0:ea44dc9ed014 80 created. Then, a new button is attached to it.
joeverbout 0:ea44dc9ed014 81
joeverbout 0:ea44dc9ed014 82 See below the example used to generate the figure:
joeverbout 0:ea44dc9ed014 83 @code
joeverbout 0:ea44dc9ed014 84 int main(int argc, char *argv[])
joeverbout 0:ea44dc9ed014 85 {
joeverbout 0:ea44dc9ed014 86
joeverbout 0:ea44dc9ed014 87 int value = 50;
joeverbout 0:ea44dc9ed014 88 int value2 = 0;
joeverbout 0:ea44dc9ed014 89
joeverbout 0:ea44dc9ed014 90
joeverbout 0:ea44dc9ed014 91 namedWindow("main1",WINDOW_NORMAL);
joeverbout 0:ea44dc9ed014 92 namedWindow("main2",WINDOW_AUTOSIZE | CV_GUI_NORMAL);
joeverbout 0:ea44dc9ed014 93 createTrackbar( "track1", "main1", &value, 255, NULL);
joeverbout 0:ea44dc9ed014 94
joeverbout 0:ea44dc9ed014 95 String nameb1 = "button1";
joeverbout 0:ea44dc9ed014 96 String nameb2 = "button2";
joeverbout 0:ea44dc9ed014 97
joeverbout 0:ea44dc9ed014 98 createButton(nameb1,callbackButton,&nameb1,QT_CHECKBOX,1);
joeverbout 0:ea44dc9ed014 99 createButton(nameb2,callbackButton,NULL,QT_CHECKBOX,0);
joeverbout 0:ea44dc9ed014 100 createTrackbar( "track2", NULL, &value2, 255, NULL);
joeverbout 0:ea44dc9ed014 101 createButton("button5",callbackButton1,NULL,QT_RADIOBOX,0);
joeverbout 0:ea44dc9ed014 102 createButton("button6",callbackButton2,NULL,QT_RADIOBOX,1);
joeverbout 0:ea44dc9ed014 103
joeverbout 0:ea44dc9ed014 104 setMouseCallback( "main2",on_mouse,NULL );
joeverbout 0:ea44dc9ed014 105
joeverbout 0:ea44dc9ed014 106 Mat img1 = imread("files/flower.jpg");
joeverbout 0:ea44dc9ed014 107 VideoCapture video;
joeverbout 0:ea44dc9ed014 108 video.open("files/hockey.avi");
joeverbout 0:ea44dc9ed014 109
joeverbout 0:ea44dc9ed014 110 Mat img2,img3;
joeverbout 0:ea44dc9ed014 111
joeverbout 0:ea44dc9ed014 112 while( waitKey(33) != 27 )
joeverbout 0:ea44dc9ed014 113 {
joeverbout 0:ea44dc9ed014 114 img1.convertTo(img2,-1,1,value);
joeverbout 0:ea44dc9ed014 115 video >> img3;
joeverbout 0:ea44dc9ed014 116
joeverbout 0:ea44dc9ed014 117 imshow("main1",img2);
joeverbout 0:ea44dc9ed014 118 imshow("main2",img3);
joeverbout 0:ea44dc9ed014 119 }
joeverbout 0:ea44dc9ed014 120
joeverbout 0:ea44dc9ed014 121 destroyAllWindows();
joeverbout 0:ea44dc9ed014 122
joeverbout 0:ea44dc9ed014 123 return 0;
joeverbout 0:ea44dc9ed014 124 }
joeverbout 0:ea44dc9ed014 125 @endcode
joeverbout 0:ea44dc9ed014 126
joeverbout 0:ea44dc9ed014 127
joeverbout 0:ea44dc9ed014 128 @defgroup highgui_winrt WinRT support
joeverbout 0:ea44dc9ed014 129
joeverbout 0:ea44dc9ed014 130 This figure explains new functionality implemented with WinRT GUI. The new GUI provides an Image control,
joeverbout 0:ea44dc9ed014 131 and a slider panel. Slider panel holds trackbars attached to it.
joeverbout 0:ea44dc9ed014 132
joeverbout 0:ea44dc9ed014 133 Sliders are attached below the image control. Every new slider is added below the previous one.
joeverbout 0:ea44dc9ed014 134
joeverbout 0:ea44dc9ed014 135 See below the example used to generate the figure:
joeverbout 0:ea44dc9ed014 136 @code
joeverbout 0:ea44dc9ed014 137 void sample_app::MainPage::ShowWindow()
joeverbout 0:ea44dc9ed014 138 {
joeverbout 0:ea44dc9ed014 139 static cv::String windowName("sample");
joeverbout 0:ea44dc9ed014 140 cv::winrt_initContainer(this->cvContainer);
joeverbout 0:ea44dc9ed014 141 cv::namedWindow(windowName); // not required
joeverbout 0:ea44dc9ed014 142
joeverbout 0:ea44dc9ed014 143 cv::Mat image = cv::imread("Assets/sample.jpg");
joeverbout 0:ea44dc9ed014 144 cv::Mat converted = cv::Mat(image.rows, image.cols, CV_8UC4);
joeverbout 0:ea44dc9ed014 145 cv::cvtColor(image, converted, COLOR_BGR2BGRA);
joeverbout 0:ea44dc9ed014 146 cv::imshow(windowName, converted); // this will create window if it hasn't been created before
joeverbout 0:ea44dc9ed014 147
joeverbout 0:ea44dc9ed014 148 int state = 42;
joeverbout 0:ea44dc9ed014 149 cv::TrackbarCallback callback = [](int pos, void* userdata)
joeverbout 0:ea44dc9ed014 150 {
joeverbout 0:ea44dc9ed014 151 if (pos == 0) {
joeverbout 0:ea44dc9ed014 152 cv::destroyWindow(windowName);
joeverbout 0:ea44dc9ed014 153 }
joeverbout 0:ea44dc9ed014 154 };
joeverbout 0:ea44dc9ed014 155 cv::TrackbarCallback callbackTwin = [](int pos, void* userdata)
joeverbout 0:ea44dc9ed014 156 {
joeverbout 0:ea44dc9ed014 157 if (pos >= 70) {
joeverbout 0:ea44dc9ed014 158 cv::destroyAllWindows();
joeverbout 0:ea44dc9ed014 159 }
joeverbout 0:ea44dc9ed014 160 };
joeverbout 0:ea44dc9ed014 161 cv::createTrackbar("Sample trackbar", windowName, &state, 100, callback);
joeverbout 0:ea44dc9ed014 162 cv::createTrackbar("Twin brother", windowName, &state, 100, callbackTwin);
joeverbout 0:ea44dc9ed014 163 }
joeverbout 0:ea44dc9ed014 164 @endcode
joeverbout 0:ea44dc9ed014 165
joeverbout 0:ea44dc9ed014 166 @defgroup highgui_c C API
joeverbout 0:ea44dc9ed014 167 @}
joeverbout 0:ea44dc9ed014 168 */
joeverbout 0:ea44dc9ed014 169
joeverbout 0:ea44dc9ed014 170 ///////////////////////// graphical user interface //////////////////////////
joeverbout 0:ea44dc9ed014 171 namespace cv
joeverbout 0:ea44dc9ed014 172 {
joeverbout 0:ea44dc9ed014 173
joeverbout 0:ea44dc9ed014 174 //! @addtogroup highgui
joeverbout 0:ea44dc9ed014 175 //! @{
joeverbout 0:ea44dc9ed014 176
joeverbout 0:ea44dc9ed014 177 //! Flags for cv::namedWindow
joeverbout 0:ea44dc9ed014 178 enum WindowFlags {
joeverbout 0:ea44dc9ed014 179 WINDOW_NORMAL = 0x00000000, //!< the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size.
joeverbout 0:ea44dc9ed014 180 WINDOW_AUTOSIZE = 0x00000001, //!< the user cannot resize the window, the size is constrainted by the image displayed.
joeverbout 0:ea44dc9ed014 181 WINDOW_OPENGL = 0x00001000, //!< window with opengl support.
joeverbout 0:ea44dc9ed014 182
joeverbout 0:ea44dc9ed014 183 WINDOW_FULLSCREEN = 1, //!< change the window to fullscreen.
joeverbout 0:ea44dc9ed014 184 WINDOW_FREERATIO = 0x00000100, //!< the image expends as much as it can (no ratio constraint).
joeverbout 0:ea44dc9ed014 185 WINDOW_KEEPRATIO = 0x00000000 //!< the ratio of the image is respected.
joeverbout 0:ea44dc9ed014 186 };
joeverbout 0:ea44dc9ed014 187
joeverbout 0:ea44dc9ed014 188 //! Flags for cv::setWindowProperty / cv::getWindowProperty
joeverbout 0:ea44dc9ed014 189 enum WindowPropertyFlags {
joeverbout 0:ea44dc9ed014 190 WND_PROP_FULLSCREEN = 0, //!< fullscreen property (can be WINDOW_NORMAL or WINDOW_FULLSCREEN).
joeverbout 0:ea44dc9ed014 191 WND_PROP_AUTOSIZE = 1, //!< autosize property (can be WINDOW_NORMAL or WINDOW_AUTOSIZE).
joeverbout 0:ea44dc9ed014 192 WND_PROP_ASPECT_RATIO = 2, //!< window's aspect ration (can be set to WINDOW_FREERATIO or WINDOW_KEEPRATIO).
joeverbout 0:ea44dc9ed014 193 WND_PROP_OPENGL = 3 //!< opengl support.
joeverbout 0:ea44dc9ed014 194 };
joeverbout 0:ea44dc9ed014 195
joeverbout 0:ea44dc9ed014 196 //! Mouse Events see cv::MouseCallback
joeverbout 0:ea44dc9ed014 197 enum MouseEventTypes {
joeverbout 0:ea44dc9ed014 198 EVENT_MOUSEMOVE = 0, //!< indicates that the mouse pointer has moved over the window.
joeverbout 0:ea44dc9ed014 199 EVENT_LBUTTONDOWN = 1, //!< indicates that the left mouse button is pressed.
joeverbout 0:ea44dc9ed014 200 EVENT_RBUTTONDOWN = 2, //!< indicates that the right mouse button is pressed.
joeverbout 0:ea44dc9ed014 201 EVENT_MBUTTONDOWN = 3, //!< indicates that the middle mouse button is pressed.
joeverbout 0:ea44dc9ed014 202 EVENT_LBUTTONUP = 4, //!< indicates that left mouse button is released.
joeverbout 0:ea44dc9ed014 203 EVENT_RBUTTONUP = 5, //!< indicates that right mouse button is released.
joeverbout 0:ea44dc9ed014 204 EVENT_MBUTTONUP = 6, //!< indicates that middle mouse button is released.
joeverbout 0:ea44dc9ed014 205 EVENT_LBUTTONDBLCLK = 7, //!< indicates that left mouse button is double clicked.
joeverbout 0:ea44dc9ed014 206 EVENT_RBUTTONDBLCLK = 8, //!< indicates that right mouse button is double clicked.
joeverbout 0:ea44dc9ed014 207 EVENT_MBUTTONDBLCLK = 9, //!< indicates that middle mouse button is double clicked.
joeverbout 0:ea44dc9ed014 208 EVENT_MOUSEWHEEL = 10,//!< positive and negative values mean forward and backward scrolling, respectively.
joeverbout 0:ea44dc9ed014 209 EVENT_MOUSEHWHEEL = 11 //!< positive and negative values mean right and left scrolling, respectively.
joeverbout 0:ea44dc9ed014 210 };
joeverbout 0:ea44dc9ed014 211
joeverbout 0:ea44dc9ed014 212 //! Mouse Event Flags see cv::MouseCallback
joeverbout 0:ea44dc9ed014 213 enum MouseEventFlags {
joeverbout 0:ea44dc9ed014 214 EVENT_FLAG_LBUTTON = 1, //!< indicates that the left mouse button is down.
joeverbout 0:ea44dc9ed014 215 EVENT_FLAG_RBUTTON = 2, //!< indicates that the right mouse button is down.
joeverbout 0:ea44dc9ed014 216 EVENT_FLAG_MBUTTON = 4, //!< indicates that the middle mouse button is down.
joeverbout 0:ea44dc9ed014 217 EVENT_FLAG_CTRLKEY = 8, //!< indicates that CTRL Key is pressed.
joeverbout 0:ea44dc9ed014 218 EVENT_FLAG_SHIFTKEY = 16,//!< indicates that SHIFT Key is pressed.
joeverbout 0:ea44dc9ed014 219 EVENT_FLAG_ALTKEY = 32 //!< indicates that ALT Key is pressed.
joeverbout 0:ea44dc9ed014 220 };
joeverbout 0:ea44dc9ed014 221
joeverbout 0:ea44dc9ed014 222 //! Qt font weight
joeverbout 0:ea44dc9ed014 223 enum QtFontWeights {
joeverbout 0:ea44dc9ed014 224 QT_FONT_LIGHT = 25, //!< Weight of 25
joeverbout 0:ea44dc9ed014 225 QT_FONT_NORMAL = 50, //!< Weight of 50
joeverbout 0:ea44dc9ed014 226 QT_FONT_DEMIBOLD = 63, //!< Weight of 63
joeverbout 0:ea44dc9ed014 227 QT_FONT_BOLD = 75, //!< Weight of 75
joeverbout 0:ea44dc9ed014 228 QT_FONT_BLACK = 87 //!< Weight of 87
joeverbout 0:ea44dc9ed014 229 };
joeverbout 0:ea44dc9ed014 230
joeverbout 0:ea44dc9ed014 231 //! Qt font style
joeverbout 0:ea44dc9ed014 232 enum QtFontStyles {
joeverbout 0:ea44dc9ed014 233 QT_STYLE_NORMAL = 0, //!< Normal font.
joeverbout 0:ea44dc9ed014 234 QT_STYLE_ITALIC = 1, //!< Italic font.
joeverbout 0:ea44dc9ed014 235 QT_STYLE_OBLIQUE = 2 //!< Oblique font.
joeverbout 0:ea44dc9ed014 236 };
joeverbout 0:ea44dc9ed014 237
joeverbout 0:ea44dc9ed014 238 //! Qt "button" type
joeverbout 0:ea44dc9ed014 239 enum QtButtonTypes {
joeverbout 0:ea44dc9ed014 240 QT_PUSH_BUTTON = 0, //!< Push button.
joeverbout 0:ea44dc9ed014 241 QT_CHECKBOX = 1, //!< Checkbox button.
joeverbout 0:ea44dc9ed014 242 QT_RADIOBOX = 2 //!< Radiobox button.
joeverbout 0:ea44dc9ed014 243 };
joeverbout 0:ea44dc9ed014 244
joeverbout 0:ea44dc9ed014 245 /** @brief Callback function for mouse events. see cv::setMouseCallback
joeverbout 0:ea44dc9ed014 246 @param event one of the cv::MouseEventTypes constants.
joeverbout 0:ea44dc9ed014 247 @param x The x-coordinate of the mouse event.
joeverbout 0:ea44dc9ed014 248 @param y The y-coordinate of the mouse event.
joeverbout 0:ea44dc9ed014 249 @param flags one of the cv::MouseEventFlags constants.
joeverbout 0:ea44dc9ed014 250 @param userdata The optional parameter.
joeverbout 0:ea44dc9ed014 251 */
joeverbout 0:ea44dc9ed014 252 typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata);
joeverbout 0:ea44dc9ed014 253
joeverbout 0:ea44dc9ed014 254 /** @brief Callback function for Trackbar see cv::createTrackbar
joeverbout 0:ea44dc9ed014 255 @param pos current position of the specified trackbar.
joeverbout 0:ea44dc9ed014 256 @param userdata The optional parameter.
joeverbout 0:ea44dc9ed014 257 */
joeverbout 0:ea44dc9ed014 258 typedef void (*TrackbarCallback)(int pos, void* userdata);
joeverbout 0:ea44dc9ed014 259
joeverbout 0:ea44dc9ed014 260 /** @brief Callback function defined to be called every frame. See cv::setOpenGlDrawCallback
joeverbout 0:ea44dc9ed014 261 @param userdata The optional parameter.
joeverbout 0:ea44dc9ed014 262 */
joeverbout 0:ea44dc9ed014 263 typedef void (*OpenGlDrawCallback)(void* userdata);
joeverbout 0:ea44dc9ed014 264
joeverbout 0:ea44dc9ed014 265 /** @brief Callback function for a button created by cv::createButton
joeverbout 0:ea44dc9ed014 266 @param state current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
joeverbout 0:ea44dc9ed014 267 @param userdata The optional parameter.
joeverbout 0:ea44dc9ed014 268 */
joeverbout 0:ea44dc9ed014 269 typedef void (*ButtonCallback)(int state, void* userdata);
joeverbout 0:ea44dc9ed014 270
joeverbout 0:ea44dc9ed014 271 /** @brief Creates a window.
joeverbout 0:ea44dc9ed014 272
joeverbout 0:ea44dc9ed014 273 The function namedWindow creates a window that can be used as a placeholder for images and
joeverbout 0:ea44dc9ed014 274 trackbars. Created windows are referred to by their names.
joeverbout 0:ea44dc9ed014 275
joeverbout 0:ea44dc9ed014 276 If a window with the same name already exists, the function does nothing.
joeverbout 0:ea44dc9ed014 277
joeverbout 0:ea44dc9ed014 278 You can call cv::destroyWindow or cv::destroyAllWindows to close the window and de-allocate any associated
joeverbout 0:ea44dc9ed014 279 memory usage. For a simple program, you do not really have to call these functions because all the
joeverbout 0:ea44dc9ed014 280 resources and windows of the application are closed automatically by the operating system upon exit.
joeverbout 0:ea44dc9ed014 281
joeverbout 0:ea44dc9ed014 282 @note
joeverbout 0:ea44dc9ed014 283
joeverbout 0:ea44dc9ed014 284 Qt backend supports additional flags:
joeverbout 0:ea44dc9ed014 285 - **WINDOW_NORMAL or WINDOW_AUTOSIZE:** WINDOW_NORMAL enables you to resize the
joeverbout 0:ea44dc9ed014 286 window, whereas WINDOW_AUTOSIZE adjusts automatically the window size to fit the
joeverbout 0:ea44dc9ed014 287 displayed image (see imshow ), and you cannot change the window size manually.
joeverbout 0:ea44dc9ed014 288 - **WINDOW_FREERATIO or WINDOW_KEEPRATIO:** WINDOW_FREERATIO adjusts the image
joeverbout 0:ea44dc9ed014 289 with no respect to its ratio, whereas WINDOW_KEEPRATIO keeps the image ratio.
joeverbout 0:ea44dc9ed014 290 - **CV_GUI_NORMAL or CV_GUI_EXPANDED:** CV_GUI_NORMAL is the old way to draw the window
joeverbout 0:ea44dc9ed014 291 without statusbar and toolbar, whereas CV_GUI_EXPANDED is a new enhanced GUI.
joeverbout 0:ea44dc9ed014 292 By default, flags == WINDOW_AUTOSIZE | WINDOW_KEEPRATIO | CV_GUI_EXPANDED
joeverbout 0:ea44dc9ed014 293
joeverbout 0:ea44dc9ed014 294 @param winname Name of the window in the window caption that may be used as a window identifier.
joeverbout 0:ea44dc9ed014 295 @param flags Flags of the window. The supported flags are: (cv::WindowFlags)
joeverbout 0:ea44dc9ed014 296 */
joeverbout 0:ea44dc9ed014 297 CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE);
joeverbout 0:ea44dc9ed014 298
joeverbout 0:ea44dc9ed014 299 /** @brief Destroys the specified window.
joeverbout 0:ea44dc9ed014 300
joeverbout 0:ea44dc9ed014 301 The function destroyWindow destroys the window with the given name.
joeverbout 0:ea44dc9ed014 302
joeverbout 0:ea44dc9ed014 303 @param winname Name of the window to be destroyed.
joeverbout 0:ea44dc9ed014 304 */
joeverbout 0:ea44dc9ed014 305 CV_EXPORTS_W void destroyWindow(const String& winname);
joeverbout 0:ea44dc9ed014 306
joeverbout 0:ea44dc9ed014 307 /** @brief Destroys all of the HighGUI windows.
joeverbout 0:ea44dc9ed014 308
joeverbout 0:ea44dc9ed014 309 The function destroyAllWindows destroys all of the opened HighGUI windows.
joeverbout 0:ea44dc9ed014 310 */
joeverbout 0:ea44dc9ed014 311 CV_EXPORTS_W void destroyAllWindows();
joeverbout 0:ea44dc9ed014 312
joeverbout 0:ea44dc9ed014 313 CV_EXPORTS_W int startWindowThread();
joeverbout 0:ea44dc9ed014 314
joeverbout 0:ea44dc9ed014 315 /** @brief Waits for a pressed key.
joeverbout 0:ea44dc9ed014 316
joeverbout 0:ea44dc9ed014 317 The function waitKey waits for a key event infinitely (when \f$\texttt{delay}\leq 0\f$ ) or for delay
joeverbout 0:ea44dc9ed014 318 milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the
joeverbout 0:ea44dc9ed014 319 function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is
joeverbout 0:ea44dc9ed014 320 running on your computer at that time. It returns the code of the pressed key or -1 if no key was
joeverbout 0:ea44dc9ed014 321 pressed before the specified time had elapsed.
joeverbout 0:ea44dc9ed014 322
joeverbout 0:ea44dc9ed014 323 @note
joeverbout 0:ea44dc9ed014 324
joeverbout 0:ea44dc9ed014 325 This function is the only method in HighGUI that can fetch and handle events, so it needs to be
joeverbout 0:ea44dc9ed014 326 called periodically for normal event processing unless HighGUI is used within an environment that
joeverbout 0:ea44dc9ed014 327 takes care of event processing.
joeverbout 0:ea44dc9ed014 328
joeverbout 0:ea44dc9ed014 329 @note
joeverbout 0:ea44dc9ed014 330
joeverbout 0:ea44dc9ed014 331 The function only works if there is at least one HighGUI window created and the window is active.
joeverbout 0:ea44dc9ed014 332 If there are several HighGUI windows, any of them can be active.
joeverbout 0:ea44dc9ed014 333
joeverbout 0:ea44dc9ed014 334 @param delay Delay in milliseconds. 0 is the special value that means "forever".
joeverbout 0:ea44dc9ed014 335 */
joeverbout 0:ea44dc9ed014 336 CV_EXPORTS_W int waitKey(int delay = 0);
joeverbout 0:ea44dc9ed014 337
joeverbout 0:ea44dc9ed014 338 /** @brief Displays an image in the specified window.
joeverbout 0:ea44dc9ed014 339
joeverbout 0:ea44dc9ed014 340 The function imshow displays an image in the specified window. If the window was created with the
joeverbout 0:ea44dc9ed014 341 cv::WINDOW_AUTOSIZE flag, the image is shown with its original size, however it is still limited by the screen resolution.
joeverbout 0:ea44dc9ed014 342 Otherwise, the image is scaled to fit the window. The function may scale the image, depending on its depth:
joeverbout 0:ea44dc9ed014 343
joeverbout 0:ea44dc9ed014 344 - If the image is 8-bit unsigned, it is displayed as is.
joeverbout 0:ea44dc9ed014 345 - If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the
joeverbout 0:ea44dc9ed014 346 value range [0,255\*256] is mapped to [0,255].
joeverbout 0:ea44dc9ed014 347 - If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the
joeverbout 0:ea44dc9ed014 348 value range [0,1] is mapped to [0,255].
joeverbout 0:ea44dc9ed014 349
joeverbout 0:ea44dc9ed014 350 If window was created with OpenGL support, cv::imshow also support ogl::Buffer , ogl::Texture2D and
joeverbout 0:ea44dc9ed014 351 cuda::GpuMat as input.
joeverbout 0:ea44dc9ed014 352
joeverbout 0:ea44dc9ed014 353 If the window was not created before this function, it is assumed creating a window with cv::WINDOW_AUTOSIZE.
joeverbout 0:ea44dc9ed014 354
joeverbout 0:ea44dc9ed014 355 If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow.
joeverbout 0:ea44dc9ed014 356
joeverbout 0:ea44dc9ed014 357 @note This function should be followed by cv::waitKey function which displays the image for specified
joeverbout 0:ea44dc9ed014 358 milliseconds. Otherwise, it won't display the image. For example, **waitKey(0)** will display the window
joeverbout 0:ea44dc9ed014 359 infinitely until any keypress (it is suitable for image display). **waitKey(25)** will display a frame
joeverbout 0:ea44dc9ed014 360 for 25 ms, after which display will be automatically closed. (If you put it in a loop to read
joeverbout 0:ea44dc9ed014 361 videos, it will display the video frame-by-frame)
joeverbout 0:ea44dc9ed014 362
joeverbout 0:ea44dc9ed014 363 @note
joeverbout 0:ea44dc9ed014 364
joeverbout 0:ea44dc9ed014 365 [__Windows Backend Only__] Pressing Ctrl+C will copy the image to the clipboard.
joeverbout 0:ea44dc9ed014 366
joeverbout 0:ea44dc9ed014 367 [__Windows Backend Only__] Pressing Ctrl+S will show a dialog to save the image.
joeverbout 0:ea44dc9ed014 368
joeverbout 0:ea44dc9ed014 369 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 370 @param mat Image to be shown.
joeverbout 0:ea44dc9ed014 371 */
joeverbout 0:ea44dc9ed014 372 CV_EXPORTS_W void imshow(const String& winname, InputArray mat);
joeverbout 0:ea44dc9ed014 373
joeverbout 0:ea44dc9ed014 374 /** @brief Resizes window to the specified size
joeverbout 0:ea44dc9ed014 375
joeverbout 0:ea44dc9ed014 376 @note
joeverbout 0:ea44dc9ed014 377
joeverbout 0:ea44dc9ed014 378 - The specified window size is for the image area. Toolbars are not counted.
joeverbout 0:ea44dc9ed014 379 - Only windows created without cv::WINDOW_AUTOSIZE flag can be resized.
joeverbout 0:ea44dc9ed014 380
joeverbout 0:ea44dc9ed014 381 @param winname Window name.
joeverbout 0:ea44dc9ed014 382 @param width The new window width.
joeverbout 0:ea44dc9ed014 383 @param height The new window height.
joeverbout 0:ea44dc9ed014 384 */
joeverbout 0:ea44dc9ed014 385 CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height);
joeverbout 0:ea44dc9ed014 386
joeverbout 0:ea44dc9ed014 387 /** @brief Moves window to the specified position
joeverbout 0:ea44dc9ed014 388
joeverbout 0:ea44dc9ed014 389 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 390 @param x The new x-coordinate of the window.
joeverbout 0:ea44dc9ed014 391 @param y The new y-coordinate of the window.
joeverbout 0:ea44dc9ed014 392 */
joeverbout 0:ea44dc9ed014 393 CV_EXPORTS_W void moveWindow(const String& winname, int x, int y);
joeverbout 0:ea44dc9ed014 394
joeverbout 0:ea44dc9ed014 395 /** @brief Changes parameters of a window dynamically.
joeverbout 0:ea44dc9ed014 396
joeverbout 0:ea44dc9ed014 397 The function setWindowProperty enables changing properties of a window.
joeverbout 0:ea44dc9ed014 398
joeverbout 0:ea44dc9ed014 399 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 400 @param prop_id Window property to edit. The supported operation flags are: (cv::WindowPropertyFlags)
joeverbout 0:ea44dc9ed014 401 @param prop_value New value of the window property. The supported flags are: (cv::WindowFlags)
joeverbout 0:ea44dc9ed014 402 */
joeverbout 0:ea44dc9ed014 403 CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value);
joeverbout 0:ea44dc9ed014 404
joeverbout 0:ea44dc9ed014 405 /** @brief Updates window title
joeverbout 0:ea44dc9ed014 406 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 407 @param title New title.
joeverbout 0:ea44dc9ed014 408 */
joeverbout 0:ea44dc9ed014 409 CV_EXPORTS_W void setWindowTitle(const String& winname, const String& title);
joeverbout 0:ea44dc9ed014 410
joeverbout 0:ea44dc9ed014 411 /** @brief Provides parameters of a window.
joeverbout 0:ea44dc9ed014 412
joeverbout 0:ea44dc9ed014 413 The function getWindowProperty returns properties of a window.
joeverbout 0:ea44dc9ed014 414
joeverbout 0:ea44dc9ed014 415 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 416 @param prop_id Window property to retrieve. The following operation flags are available: (cv::WindowPropertyFlags)
joeverbout 0:ea44dc9ed014 417
joeverbout 0:ea44dc9ed014 418 @sa setWindowProperty
joeverbout 0:ea44dc9ed014 419 */
joeverbout 0:ea44dc9ed014 420 CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id);
joeverbout 0:ea44dc9ed014 421
joeverbout 0:ea44dc9ed014 422 /** @brief Sets mouse handler for the specified window
joeverbout 0:ea44dc9ed014 423
joeverbout 0:ea44dc9ed014 424 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 425 @param onMouse Mouse callback. See OpenCV samples, such as
joeverbout 0:ea44dc9ed014 426 <https://github.com/Itseez/opencv/tree/master/samples/cpp/ffilldemo.cpp>, on how to specify and
joeverbout 0:ea44dc9ed014 427 use the callback.
joeverbout 0:ea44dc9ed014 428 @param userdata The optional parameter passed to the callback.
joeverbout 0:ea44dc9ed014 429 */
joeverbout 0:ea44dc9ed014 430 CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0);
joeverbout 0:ea44dc9ed014 431
joeverbout 0:ea44dc9ed014 432 /** @brief Gets the mouse-wheel motion delta, when handling mouse-wheel events cv::EVENT_MOUSEWHEEL and
joeverbout 0:ea44dc9ed014 433 cv::EVENT_MOUSEHWHEEL.
joeverbout 0:ea44dc9ed014 434
joeverbout 0:ea44dc9ed014 435 For regular mice with a scroll-wheel, delta will be a multiple of 120. The value 120 corresponds to
joeverbout 0:ea44dc9ed014 436 a one notch rotation of the wheel or the threshold for action to be taken and one such action should
joeverbout 0:ea44dc9ed014 437 occur for each delta. Some high-precision mice with higher-resolution freely-rotating wheels may
joeverbout 0:ea44dc9ed014 438 generate smaller values.
joeverbout 0:ea44dc9ed014 439
joeverbout 0:ea44dc9ed014 440 For cv::EVENT_MOUSEWHEEL positive and negative values mean forward and backward scrolling,
joeverbout 0:ea44dc9ed014 441 respectively. For cv::EVENT_MOUSEHWHEEL, where available, positive and negative values mean right and
joeverbout 0:ea44dc9ed014 442 left scrolling, respectively.
joeverbout 0:ea44dc9ed014 443
joeverbout 0:ea44dc9ed014 444 With the C API, the macro CV_GET_WHEEL_DELTA(flags) can be used alternatively.
joeverbout 0:ea44dc9ed014 445
joeverbout 0:ea44dc9ed014 446 @note
joeverbout 0:ea44dc9ed014 447
joeverbout 0:ea44dc9ed014 448 Mouse-wheel events are currently supported only on Windows.
joeverbout 0:ea44dc9ed014 449
joeverbout 0:ea44dc9ed014 450 @param flags The mouse callback flags parameter.
joeverbout 0:ea44dc9ed014 451 */
joeverbout 0:ea44dc9ed014 452 CV_EXPORTS int getMouseWheelDelta(int flags);
joeverbout 0:ea44dc9ed014 453
joeverbout 0:ea44dc9ed014 454 /** @brief Creates a trackbar and attaches it to the specified window.
joeverbout 0:ea44dc9ed014 455
joeverbout 0:ea44dc9ed014 456 The function createTrackbar creates a trackbar (a slider or range control) with the specified name
joeverbout 0:ea44dc9ed014 457 and range, assigns a variable value to be a position synchronized with the trackbar and specifies
joeverbout 0:ea44dc9ed014 458 the callback function onChange to be called on the trackbar position change. The created trackbar is
joeverbout 0:ea44dc9ed014 459 displayed in the specified window winname.
joeverbout 0:ea44dc9ed014 460
joeverbout 0:ea44dc9ed014 461 @note
joeverbout 0:ea44dc9ed014 462
joeverbout 0:ea44dc9ed014 463 [__Qt Backend Only__] winname can be empty (or NULL) if the trackbar should be attached to the
joeverbout 0:ea44dc9ed014 464 control panel.
joeverbout 0:ea44dc9ed014 465
joeverbout 0:ea44dc9ed014 466 Clicking the label of each trackbar enables editing the trackbar values manually.
joeverbout 0:ea44dc9ed014 467
joeverbout 0:ea44dc9ed014 468 @param trackbarname Name of the created trackbar.
joeverbout 0:ea44dc9ed014 469 @param winname Name of the window that will be used as a parent of the created trackbar.
joeverbout 0:ea44dc9ed014 470 @param value Optional pointer to an integer variable whose value reflects the position of the
joeverbout 0:ea44dc9ed014 471 slider. Upon creation, the slider position is defined by this variable.
joeverbout 0:ea44dc9ed014 472 @param count Maximal position of the slider. The minimal position is always 0.
joeverbout 0:ea44dc9ed014 473 @param onChange Pointer to the function to be called every time the slider changes position. This
joeverbout 0:ea44dc9ed014 474 function should be prototyped as void Foo(int,void\*); , where the first parameter is the trackbar
joeverbout 0:ea44dc9ed014 475 position and the second parameter is the user data (see the next parameter). If the callback is
joeverbout 0:ea44dc9ed014 476 the NULL pointer, no callbacks are called, but only value is updated.
joeverbout 0:ea44dc9ed014 477 @param userdata User data that is passed as is to the callback. It can be used to handle trackbar
joeverbout 0:ea44dc9ed014 478 events without using global variables.
joeverbout 0:ea44dc9ed014 479 */
joeverbout 0:ea44dc9ed014 480 CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname,
joeverbout 0:ea44dc9ed014 481 int* value, int count,
joeverbout 0:ea44dc9ed014 482 TrackbarCallback onChange = 0,
joeverbout 0:ea44dc9ed014 483 void* userdata = 0);
joeverbout 0:ea44dc9ed014 484
joeverbout 0:ea44dc9ed014 485 /** @brief Returns the trackbar position.
joeverbout 0:ea44dc9ed014 486
joeverbout 0:ea44dc9ed014 487 The function returns the current position of the specified trackbar.
joeverbout 0:ea44dc9ed014 488
joeverbout 0:ea44dc9ed014 489 @note
joeverbout 0:ea44dc9ed014 490
joeverbout 0:ea44dc9ed014 491 [__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
joeverbout 0:ea44dc9ed014 492 panel.
joeverbout 0:ea44dc9ed014 493
joeverbout 0:ea44dc9ed014 494 @param trackbarname Name of the trackbar.
joeverbout 0:ea44dc9ed014 495 @param winname Name of the window that is the parent of the trackbar.
joeverbout 0:ea44dc9ed014 496 */
joeverbout 0:ea44dc9ed014 497 CV_EXPORTS_W int getTrackbarPos(const String& trackbarname, const String& winname);
joeverbout 0:ea44dc9ed014 498
joeverbout 0:ea44dc9ed014 499 /** @brief Sets the trackbar position.
joeverbout 0:ea44dc9ed014 500
joeverbout 0:ea44dc9ed014 501 The function sets the position of the specified trackbar in the specified window.
joeverbout 0:ea44dc9ed014 502
joeverbout 0:ea44dc9ed014 503 @note
joeverbout 0:ea44dc9ed014 504
joeverbout 0:ea44dc9ed014 505 [__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
joeverbout 0:ea44dc9ed014 506 panel.
joeverbout 0:ea44dc9ed014 507
joeverbout 0:ea44dc9ed014 508 @param trackbarname Name of the trackbar.
joeverbout 0:ea44dc9ed014 509 @param winname Name of the window that is the parent of trackbar.
joeverbout 0:ea44dc9ed014 510 @param pos New position.
joeverbout 0:ea44dc9ed014 511 */
joeverbout 0:ea44dc9ed014 512 CV_EXPORTS_W void setTrackbarPos(const String& trackbarname, const String& winname, int pos);
joeverbout 0:ea44dc9ed014 513
joeverbout 0:ea44dc9ed014 514 /** @brief Sets the trackbar maximum position.
joeverbout 0:ea44dc9ed014 515
joeverbout 0:ea44dc9ed014 516 The function sets the maximum position of the specified trackbar in the specified window.
joeverbout 0:ea44dc9ed014 517
joeverbout 0:ea44dc9ed014 518 @note
joeverbout 0:ea44dc9ed014 519
joeverbout 0:ea44dc9ed014 520 [__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
joeverbout 0:ea44dc9ed014 521 panel.
joeverbout 0:ea44dc9ed014 522
joeverbout 0:ea44dc9ed014 523 @param trackbarname Name of the trackbar.
joeverbout 0:ea44dc9ed014 524 @param winname Name of the window that is the parent of trackbar.
joeverbout 0:ea44dc9ed014 525 @param maxval New maximum position.
joeverbout 0:ea44dc9ed014 526 */
joeverbout 0:ea44dc9ed014 527 CV_EXPORTS_W void setTrackbarMax(const String& trackbarname, const String& winname, int maxval);
joeverbout 0:ea44dc9ed014 528
joeverbout 0:ea44dc9ed014 529 /** @brief Sets the trackbar minimum position.
joeverbout 0:ea44dc9ed014 530
joeverbout 0:ea44dc9ed014 531 The function sets the minimum position of the specified trackbar in the specified window.
joeverbout 0:ea44dc9ed014 532
joeverbout 0:ea44dc9ed014 533 @note
joeverbout 0:ea44dc9ed014 534
joeverbout 0:ea44dc9ed014 535 [__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
joeverbout 0:ea44dc9ed014 536 panel.
joeverbout 0:ea44dc9ed014 537
joeverbout 0:ea44dc9ed014 538 @param trackbarname Name of the trackbar.
joeverbout 0:ea44dc9ed014 539 @param winname Name of the window that is the parent of trackbar.
joeverbout 0:ea44dc9ed014 540 @param minval New maximum position.
joeverbout 0:ea44dc9ed014 541 */
joeverbout 0:ea44dc9ed014 542 CV_EXPORTS_W void setTrackbarMin(const String& trackbarname, const String& winname, int minval);
joeverbout 0:ea44dc9ed014 543
joeverbout 0:ea44dc9ed014 544 //! @addtogroup highgui_opengl OpenGL support
joeverbout 0:ea44dc9ed014 545 //! @{
joeverbout 0:ea44dc9ed014 546
joeverbout 0:ea44dc9ed014 547 /** @brief Displays OpenGL 2D texture in the specified window.
joeverbout 0:ea44dc9ed014 548
joeverbout 0:ea44dc9ed014 549 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 550 @param tex OpenGL 2D texture data.
joeverbout 0:ea44dc9ed014 551 */
joeverbout 0:ea44dc9ed014 552 CV_EXPORTS void imshow(const String& winname, const ogl::Texture2D& tex);
joeverbout 0:ea44dc9ed014 553
joeverbout 0:ea44dc9ed014 554 /** @brief Sets a callback function to be called to draw on top of displayed image.
joeverbout 0:ea44dc9ed014 555
joeverbout 0:ea44dc9ed014 556 The function setOpenGlDrawCallback can be used to draw 3D data on the window. See the example of
joeverbout 0:ea44dc9ed014 557 callback function below:
joeverbout 0:ea44dc9ed014 558 @code
joeverbout 0:ea44dc9ed014 559 void on_opengl(void* param)
joeverbout 0:ea44dc9ed014 560 {
joeverbout 0:ea44dc9ed014 561 glLoadIdentity();
joeverbout 0:ea44dc9ed014 562
joeverbout 0:ea44dc9ed014 563 glTranslated(0.0, 0.0, -1.0);
joeverbout 0:ea44dc9ed014 564
joeverbout 0:ea44dc9ed014 565 glRotatef( 55, 1, 0, 0 );
joeverbout 0:ea44dc9ed014 566 glRotatef( 45, 0, 1, 0 );
joeverbout 0:ea44dc9ed014 567 glRotatef( 0, 0, 0, 1 );
joeverbout 0:ea44dc9ed014 568
joeverbout 0:ea44dc9ed014 569 static const int coords[6][4][3] = {
joeverbout 0:ea44dc9ed014 570 { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } },
joeverbout 0:ea44dc9ed014 571 { { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } },
joeverbout 0:ea44dc9ed014 572 { { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } },
joeverbout 0:ea44dc9ed014 573 { { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } },
joeverbout 0:ea44dc9ed014 574 { { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } },
joeverbout 0:ea44dc9ed014 575 { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } }
joeverbout 0:ea44dc9ed014 576 };
joeverbout 0:ea44dc9ed014 577
joeverbout 0:ea44dc9ed014 578 for (int i = 0; i < 6; ++i) {
joeverbout 0:ea44dc9ed014 579 glColor3ub( i*20, 100+i*10, i*42 );
joeverbout 0:ea44dc9ed014 580 glBegin(GL_QUADS);
joeverbout 0:ea44dc9ed014 581 for (int j = 0; j < 4; ++j) {
joeverbout 0:ea44dc9ed014 582 glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2]);
joeverbout 0:ea44dc9ed014 583 }
joeverbout 0:ea44dc9ed014 584 glEnd();
joeverbout 0:ea44dc9ed014 585 }
joeverbout 0:ea44dc9ed014 586 }
joeverbout 0:ea44dc9ed014 587 @endcode
joeverbout 0:ea44dc9ed014 588
joeverbout 0:ea44dc9ed014 589 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 590 @param onOpenGlDraw Pointer to the function to be called every frame. This function should be
joeverbout 0:ea44dc9ed014 591 prototyped as void Foo(void\*) .
joeverbout 0:ea44dc9ed014 592 @param userdata Pointer passed to the callback function.(__Optional__)
joeverbout 0:ea44dc9ed014 593 */
joeverbout 0:ea44dc9ed014 594 CV_EXPORTS void setOpenGlDrawCallback(const String& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
joeverbout 0:ea44dc9ed014 595
joeverbout 0:ea44dc9ed014 596 /** @brief Sets the specified window as current OpenGL context.
joeverbout 0:ea44dc9ed014 597
joeverbout 0:ea44dc9ed014 598 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 599 */
joeverbout 0:ea44dc9ed014 600 CV_EXPORTS void setOpenGlContext(const String& winname);
joeverbout 0:ea44dc9ed014 601
joeverbout 0:ea44dc9ed014 602 /** @brief Force window to redraw its context and call draw callback ( See cv::setOpenGlDrawCallback ).
joeverbout 0:ea44dc9ed014 603
joeverbout 0:ea44dc9ed014 604 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 605 */
joeverbout 0:ea44dc9ed014 606 CV_EXPORTS void updateWindow(const String& winname);
joeverbout 0:ea44dc9ed014 607
joeverbout 0:ea44dc9ed014 608 //! @} highgui_opengl
joeverbout 0:ea44dc9ed014 609
joeverbout 0:ea44dc9ed014 610 //! @addtogroup highgui_qt
joeverbout 0:ea44dc9ed014 611 //! @{
joeverbout 0:ea44dc9ed014 612
joeverbout 0:ea44dc9ed014 613 /** @brief QtFont available only for Qt. See cv::fontQt
joeverbout 0:ea44dc9ed014 614 */
joeverbout 0:ea44dc9ed014 615 struct QtFont
joeverbout 0:ea44dc9ed014 616 {
joeverbout 0:ea44dc9ed014 617 const char* nameFont; //!< Name of the font
joeverbout 0:ea44dc9ed014 618 Scalar color; //!< Color of the font. Scalar(blue_component, green_component, red_component[, alpha_component])
joeverbout 0:ea44dc9ed014 619 int font_face; //!< See cv::QtFontStyles
joeverbout 0:ea44dc9ed014 620 const int* ascii; //!< font data and metrics
joeverbout 0:ea44dc9ed014 621 const int* greek;
joeverbout 0:ea44dc9ed014 622 const int* cyrillic;
joeverbout 0:ea44dc9ed014 623 float hscale, vscale;
joeverbout 0:ea44dc9ed014 624 float shear; //!< slope coefficient: 0 - normal, >0 - italic
joeverbout 0:ea44dc9ed014 625 int thickness; //!< See cv::QtFontWeights
joeverbout 0:ea44dc9ed014 626 float dx; //!< horizontal interval between letters
joeverbout 0:ea44dc9ed014 627 int line_type; //!< PointSize
joeverbout 0:ea44dc9ed014 628 };
joeverbout 0:ea44dc9ed014 629
joeverbout 0:ea44dc9ed014 630 /** @brief Creates the font to draw a text on an image.
joeverbout 0:ea44dc9ed014 631
joeverbout 0:ea44dc9ed014 632 The function fontQt creates a cv::QtFont object. This cv::QtFont is not compatible with putText .
joeverbout 0:ea44dc9ed014 633
joeverbout 0:ea44dc9ed014 634 A basic usage of this function is the following: :
joeverbout 0:ea44dc9ed014 635 @code
joeverbout 0:ea44dc9ed014 636 QtFont font = fontQt("Times");
joeverbout 0:ea44dc9ed014 637 addText( img1, "Hello World !", Point(50,50), font);
joeverbout 0:ea44dc9ed014 638 @endcode
joeverbout 0:ea44dc9ed014 639
joeverbout 0:ea44dc9ed014 640 @param nameFont Name of the font. The name should match the name of a system font (such as
joeverbout 0:ea44dc9ed014 641 *Times*). If the font is not found, a default one is used.
joeverbout 0:ea44dc9ed014 642 @param pointSize Size of the font. If not specified, equal zero or negative, the point size of the
joeverbout 0:ea44dc9ed014 643 font is set to a system-dependent default value. Generally, this is 12 points.
joeverbout 0:ea44dc9ed014 644 @param color Color of the font in BGRA where A = 255 is fully transparent. Use the macro CV_RGB
joeverbout 0:ea44dc9ed014 645 for simplicity.
joeverbout 0:ea44dc9ed014 646 @param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.
joeverbout 0:ea44dc9ed014 647 @param style Font style. Available operation flags are : cv::QtFontStyles
joeverbout 0:ea44dc9ed014 648 @param spacing Spacing between characters. It can be negative or positive.
joeverbout 0:ea44dc9ed014 649 */
joeverbout 0:ea44dc9ed014 650 CV_EXPORTS QtFont fontQt(const String& nameFont, int pointSize = -1,
joeverbout 0:ea44dc9ed014 651 Scalar color = Scalar::all(0), int weight = QT_FONT_NORMAL,
joeverbout 0:ea44dc9ed014 652 int style = QT_STYLE_NORMAL, int spacing = 0);
joeverbout 0:ea44dc9ed014 653
joeverbout 0:ea44dc9ed014 654 /** @brief Draws a text on the image.
joeverbout 0:ea44dc9ed014 655
joeverbout 0:ea44dc9ed014 656 The function addText draws *text* on the image *img* using a specific font *font* (see example cv::fontQt
joeverbout 0:ea44dc9ed014 657 )
joeverbout 0:ea44dc9ed014 658
joeverbout 0:ea44dc9ed014 659 @param img 8-bit 3-channel image where the text should be drawn.
joeverbout 0:ea44dc9ed014 660 @param text Text to write on an image.
joeverbout 0:ea44dc9ed014 661 @param org Point(x,y) where the text should start on an image.
joeverbout 0:ea44dc9ed014 662 @param font Font to use to draw a text.
joeverbout 0:ea44dc9ed014 663 */
joeverbout 0:ea44dc9ed014 664 CV_EXPORTS void addText( const Mat& img, const String& text, Point org, const QtFont& font);
joeverbout 0:ea44dc9ed014 665
joeverbout 0:ea44dc9ed014 666 /** @brief Displays a text on a window image as an overlay for a specified duration.
joeverbout 0:ea44dc9ed014 667
joeverbout 0:ea44dc9ed014 668 The function displayOverlay displays useful information/tips on top of the window for a certain
joeverbout 0:ea44dc9ed014 669 amount of time *delayms*. The function does not modify the image, displayed in the window, that is,
joeverbout 0:ea44dc9ed014 670 after the specified delay the original content of the window is restored.
joeverbout 0:ea44dc9ed014 671
joeverbout 0:ea44dc9ed014 672 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 673 @param text Overlay text to write on a window image.
joeverbout 0:ea44dc9ed014 674 @param delayms The period (in milliseconds), during which the overlay text is displayed. If this
joeverbout 0:ea44dc9ed014 675 function is called before the previous overlay text timed out, the timer is restarted and the text
joeverbout 0:ea44dc9ed014 676 is updated. If this value is zero, the text never disappears.
joeverbout 0:ea44dc9ed014 677 */
joeverbout 0:ea44dc9ed014 678 CV_EXPORTS void displayOverlay(const String& winname, const String& text, int delayms = 0);
joeverbout 0:ea44dc9ed014 679
joeverbout 0:ea44dc9ed014 680 /** @brief Displays a text on the window statusbar during the specified period of time.
joeverbout 0:ea44dc9ed014 681
joeverbout 0:ea44dc9ed014 682 The function displayStatusBar displays useful information/tips on top of the window for a certain
joeverbout 0:ea44dc9ed014 683 amount of time *delayms* . This information is displayed on the window statusbar (the window must be
joeverbout 0:ea44dc9ed014 684 created with the CV_GUI_EXPANDED flags).
joeverbout 0:ea44dc9ed014 685
joeverbout 0:ea44dc9ed014 686 @param winname Name of the window.
joeverbout 0:ea44dc9ed014 687 @param text Text to write on the window statusbar.
joeverbout 0:ea44dc9ed014 688 @param delayms Duration (in milliseconds) to display the text. If this function is called before
joeverbout 0:ea44dc9ed014 689 the previous text timed out, the timer is restarted and the text is updated. If this value is
joeverbout 0:ea44dc9ed014 690 zero, the text never disappears.
joeverbout 0:ea44dc9ed014 691 */
joeverbout 0:ea44dc9ed014 692 CV_EXPORTS void displayStatusBar(const String& winname, const String& text, int delayms = 0);
joeverbout 0:ea44dc9ed014 693
joeverbout 0:ea44dc9ed014 694 /** @brief Saves parameters of the specified window.
joeverbout 0:ea44dc9ed014 695
joeverbout 0:ea44dc9ed014 696 The function saveWindowParameters saves size, location, flags, trackbars value, zoom and panning
joeverbout 0:ea44dc9ed014 697 location of the window windowName.
joeverbout 0:ea44dc9ed014 698
joeverbout 0:ea44dc9ed014 699 @param windowName Name of the window.
joeverbout 0:ea44dc9ed014 700 */
joeverbout 0:ea44dc9ed014 701 CV_EXPORTS void saveWindowParameters(const String& windowName);
joeverbout 0:ea44dc9ed014 702
joeverbout 0:ea44dc9ed014 703 /** @brief Loads parameters of the specified window.
joeverbout 0:ea44dc9ed014 704
joeverbout 0:ea44dc9ed014 705 The function loadWindowParameters loads size, location, flags, trackbars value, zoom and panning
joeverbout 0:ea44dc9ed014 706 location of the window windowName.
joeverbout 0:ea44dc9ed014 707
joeverbout 0:ea44dc9ed014 708 @param windowName Name of the window.
joeverbout 0:ea44dc9ed014 709 */
joeverbout 0:ea44dc9ed014 710 CV_EXPORTS void loadWindowParameters(const String& windowName);
joeverbout 0:ea44dc9ed014 711
joeverbout 0:ea44dc9ed014 712 CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
joeverbout 0:ea44dc9ed014 713
joeverbout 0:ea44dc9ed014 714 CV_EXPORTS void stopLoop();
joeverbout 0:ea44dc9ed014 715
joeverbout 0:ea44dc9ed014 716 /** @brief Attaches a button to the control panel.
joeverbout 0:ea44dc9ed014 717
joeverbout 0:ea44dc9ed014 718 The function createButton attaches a button to the control panel. Each button is added to a
joeverbout 0:ea44dc9ed014 719 buttonbar to the right of the last button. A new buttonbar is created if nothing was attached to the
joeverbout 0:ea44dc9ed014 720 control panel before, or if the last element attached to the control panel was a trackbar.
joeverbout 0:ea44dc9ed014 721
joeverbout 0:ea44dc9ed014 722 See below various examples of the cv::createButton function call: :
joeverbout 0:ea44dc9ed014 723 @code
joeverbout 0:ea44dc9ed014 724 createButton(NULL,callbackButton);//create a push button "button 0", that will call callbackButton.
joeverbout 0:ea44dc9ed014 725 createButton("button2",callbackButton,NULL,QT_CHECKBOX,0);
joeverbout 0:ea44dc9ed014 726 createButton("button3",callbackButton,&value);
joeverbout 0:ea44dc9ed014 727 createButton("button5",callbackButton1,NULL,QT_RADIOBOX);
joeverbout 0:ea44dc9ed014 728 createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON,1);
joeverbout 0:ea44dc9ed014 729 @endcode
joeverbout 0:ea44dc9ed014 730
joeverbout 0:ea44dc9ed014 731 @param bar_name Name of the button.
joeverbout 0:ea44dc9ed014 732 @param on_change Pointer to the function to be called every time the button changes its state.
joeverbout 0:ea44dc9ed014 733 This function should be prototyped as void Foo(int state,\*void); . *state* is the current state
joeverbout 0:ea44dc9ed014 734 of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
joeverbout 0:ea44dc9ed014 735 @param userdata Pointer passed to the callback function.
joeverbout 0:ea44dc9ed014 736 @param type Optional type of the button. Available types are: (cv::QtButtonTypes)
joeverbout 0:ea44dc9ed014 737 @param initial_button_state Default state of the button. Use for checkbox and radiobox. Its
joeverbout 0:ea44dc9ed014 738 value could be 0 or 1. (__Optional__)
joeverbout 0:ea44dc9ed014 739 */
joeverbout 0:ea44dc9ed014 740 CV_EXPORTS int createButton( const String& bar_name, ButtonCallback on_change,
joeverbout 0:ea44dc9ed014 741 void* userdata = 0, int type = QT_PUSH_BUTTON,
joeverbout 0:ea44dc9ed014 742 bool initial_button_state = false);
joeverbout 0:ea44dc9ed014 743
joeverbout 0:ea44dc9ed014 744 //! @} highgui_qt
joeverbout 0:ea44dc9ed014 745
joeverbout 0:ea44dc9ed014 746 //! @} highgui
joeverbout 0:ea44dc9ed014 747
joeverbout 0:ea44dc9ed014 748 } // cv
joeverbout 0:ea44dc9ed014 749
joeverbout 0:ea44dc9ed014 750 #ifndef DISABLE_OPENCV_24_COMPATIBILITY
joeverbout 0:ea44dc9ed014 751 #include "opencv2/highgui/highgui_c.h"
joeverbout 0:ea44dc9ed014 752 #endif
joeverbout 0:ea44dc9ed014 753
joeverbout 0:ea44dc9ed014 754 #endif
joeverbout 0:ea44dc9ed014 755