Commit ea520d13 authored by Elena Fedotova's avatar Elena Fedotova

Purpose: 2nd review cycle.

parent 1c41a747
Qt New Functions
Qt* New Functions
================
.. highlight:: cpp
.. image:: pics/qtgui.png
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 can't see the control panel then press Ctrl+P or right-click on any Qt-window and select "Display properties window".
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.
......@@ -14,7 +14,7 @@ This figure explains new functionality implemented with Qt* GUI. The new GUI pro
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.
The following code is an example used to generate the figure. ::
See below the example used to generate the figure: ::
int main(int argc, char *argv[])
int value = 50;
......@@ -56,14 +56,15 @@ The following code is an example used to generate the figure. ::
return 0;
}
.. index:: setWindowProperty
.. _setWindowProperty:
setWindowProperty
---------------------
Changes parameters of a window dynamically.
.. ocv:function:: void setWindowProperty(const string& name, int prop_id, double prop_value)
.. ocv:cfunction:: void cvSetWindowProperty(const char* name, int propId, double propValue)
Changes parameters of a window dynamically.
:param name: Name of the window.
......@@ -86,18 +87,18 @@ Changes parameters of a window dynamically.
* **CV_WINDOW_FREERATIO** Make the window resizable without any ratio constraints.
* **CV_WINDOW_KEEPRATIO** Make the window resizable, but preserve the proportions of the displayed image.
* **CV_WINDOW_KEEPRATIO** Make the window resizable but preserve the proportions of the displayed image.
The function ``setWindowProperty`` enables changing properties of a window.
.. index:: getWindowProperty
getWindowProperty
---------------------
Provides parameters of a window.
.. ocv:function:: void getWindowProperty(const string& name, int prop_id)
.. ocv:cfunction:: void cvGetWindowProperty(const char* name, int propId)
Provides parameters of a window.
:param name: Name of the window.
......@@ -111,45 +112,47 @@ Provides parameters of a window.
See
:ref:`setWindowProperty` to know the meaning of the returned values.
:ocv:func:`setWindowProperty` to know the meaning of the returned values.
The function ``getWindowProperty`` returns properties of a window.
.. index:: fontQt
.. _fontQt:
fontQt
----------
Creates the font to draw a text on an image.
.. ocv:function:: CvFont fontQt(const string& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), int weight = CV_FONT_NORMAL, int style = CV_STYLE_NORMAL, int spacing = 0)
.. ocv:cfunction:: CvFont cvFontQt(const char* nameFont, int pointSize=-1, CvScalar color=cvScalarAll(0), int weight=CV_FONT_NORMAL, int style=CV_STYLE_NORMAL, int spacing=0)
Creates the font to draw a text on an image.
:param nameFont: Name 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.
:param pointSize: Size 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.
:param color: Color of the font in BGRA -- A = 255 is fully transparent. Use the macro ``CV _ RGB`` for simplicity.
:param color: Color of the font in BGRA where A = 255 is fully transparent. Use the macro ``CV _ RGB`` for simplicity.
:param weight: Font weight. The following operation flags are available:
* **CV_FONT_LIGHT** Weight of 25
* **CV_FONT_LIGHT** Weight of 25
* **CV_FONT_NORMAL** Weight of 50
* **CV_FONT_NORMAL** Weight of 50
* **CV_FONT_DEMIBOLD** Weight of 63
* **CV_FONT_DEMIBOLD** Weight of 63
* **CV_FONT_BOLD** Weight of 75
* **CV_FONT_BOLD** Weight of 75
* **CV_FONT_BLACK** Weight of 87
* **CV_FONT_BLACK** Weight of 87
You can also specify a positive integer for better control.
:param style: Font style. The following operation flags are available:
* **CV_STYLE_NORMAL** Normal font
* **CV_STYLE_NORMAL** Normal font
* **CV_STYLE_ITALIC** Italic font
* **CV_STYLE_ITALIC** Italic font
* **CV_STYLE_OBLIQUE** Oblique font
* **CV_STYLE_OBLIQUE** Oblique font
:param spacing: Spacing between characters. It can be negative or positive.
......@@ -160,14 +163,13 @@ A basic usage of this function is the following: ::
CvFont font = fontQt(''Times'');
addText( img1, ``Hello World !'', Point(50,50), font);
.. index:: addText
addText
-----------
Creates the font to draw a text on an image.
.. ocv:function:: void addText(const Mat& img, const string& text, Point location, CvFont *font)
.. ocv:cfunction:: void cvAddText(const CvArr* img, const char* text, CvPoint location, CvFont *font)
Creates the font to draw a text on an image.
:param img: 8-bit 3-channel image where the text should be drawn.
......@@ -184,7 +186,7 @@ on an image
using a specific font
*font*
(see example
:ref:`fontQt` )
:ocv:func:`fontQt` )
.. index:: displayOverlay
......@@ -194,8 +196,6 @@ displayOverlay
Displays a text on a window image as an overlay for a specified duration.
.. ocv:cfunction:: void cvDisplayOverlay(const char* name, const char* text, int delay)
:param name: Name of the window.
:param text: Overlay text to write on a window image.
......@@ -204,14 +204,13 @@ displayOverlay
The function ``displayOverlay`` displays useful information/tips on top of the window for a certain amount of time *delay*. 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.
.. index:: displayStatusBar
displayStatusBar
--------------------
Displays a text on the window statusbar during the specified period of time.
.. ocv:function:: void displayStatusBar(const string& name, const string& text, int delay)
.. ocv:cfunction:: void cvDisplayStatusBar(const char* name, const char* text, int delayms)
Displays a text on the window statusbar during the specified period of time.
:param name: Name of the window.
......@@ -223,13 +222,14 @@ The function ``displayOverlay`` displays useful information/tips on top of the w
*delay*
. This information is displayed on the window statubar (the window must be created with the ``CV_GUI_EXPANDED`` flags).
.. index:: createOpenGLCallback
createOpenGLCallback
------------------------
Creates a callback function called to draw OpenGL on top the the image display by ``windowname``.
.. ocv:function:: void createOpenGLCallback( const string& window_name, OpenGLCallback callbackOpenGL, void* userdata CV_DEFAULT(NULL), double angle CV_DEFAULT(-1), double zmin CV_DEFAULT(-1), double zmax CV_DEFAULT(-1)
.. ocv:cfunction:: void cvCreateOpenGLCallback( const char* windowName, CvOpenGLCallback callbackOpenGL, void* userdata=NULL, double angle=-1, double zmin=-1, double zmax=-1
Creates a callback function called to draw OpenGL on top the the image display by ``windowname``.
:param window_name: Name of the window.
......@@ -237,13 +237,13 @@ Creates a callback function called to draw OpenGL on top the the image display b
:param userdata: Pointer passed to the callback function. *(Optional)*
:param angle: Parameter specifying the field of view angle, in degrees, in the y direction. Default value is 45 degrees. *(Optional)*
:param angle: Parameter specifying the field of a view angle, in degrees, in the y direction. Default value is 45 degrees. *(Optional)*
:param zmin: Parameter specifying the distance from the viewer to the near clipping plane (always positive). Default value is 0.01. *(Optional)*
:param zmax: Parameter specifying the distance from the viewer to the far clipping plane (always positive). Default value is 1000. *(Optional)*
The function ``createOpenGLCallback`` can be used to draw 3D data on the window. An example of callback could be: ::
The function ``createOpenGLCallback`` can be used to draw 3D data on the window. See the callback example below: ::
void on_opengl(void* param)
{
......@@ -274,40 +274,42 @@ The function ``createOpenGLCallback`` can be used to draw 3D data on the window.
}
}
.. index:: saveWindowParameters
saveWindowParameters
------------------------
Saves parameters of the specified window.
.. ocv:function:: void saveWindowParameters(const string& name)
.. ocv:cfunction:: void cvSaveWindowParameters(const char* name)
Saves parameters of the window ``windowname`` .
:param name: Name of the window.
The function ``saveWindowParameters`` saves size, location, flags, trackbars value, zoom and panning location of the window
``window_name`` .
.. index:: loadWindowParameters
loadWindowParameters
------------------------
Loads parameters of the specified window.
.. ocv:function:: void loadWindowParameters(const string& name)
.. ocv:cfunction:: void cvLoadWindowParameters(const char* name)
Loads parameters of the window ``windowname`` .
:param name: Name of the window.
The function ``loadWindowParameters`` loads size, location, flags, trackbars value, zoom and panning location of the window
The function ``loadWindowParameters`` loads size, location, flags, trackbars value, zoom, and panning location of the window
``window_name`` .
.. index:: createButton
createButton
----------------
Attaches a button to the control panel.
.. ocv:function:: createButton( const string& button_name CV_DEFAULT(NULL),ButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL), int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0))
.. ocv:cfunction:: cvCreateButton( const char* buttonName=NULL, CvButtonCallback onChange=NULL, void* userdata=NULL, int buttonType=CV_PUSH_BUTTON, int initialButtonState=0
Attaches a button to the control panel.
:param button_name: Name of the button.
......@@ -315,20 +317,20 @@ Attaches a button to the control panel.
:param userdata: Pointer passed to the callback function.
:param button_type: The optional type of the button.
:param button_type: Optional type of the button.
* **CV_PUSH_BUTTON** Push button
* **CV_PUSH_BUTTON** Push button
* **CV_CHECKBOX** Checkbox button
* **CV_CHECKBOX** Checkbox button
* **CV_RADIOBOX** Radiobox button. The radiobox on the same buttonbar (same line) are exclusive, that is only one can be selected at a time.
* **CV_RADIOBOX** Radiobox button. The radiobox on the same buttonbar (same line) are exclusive, that is, only one can be selected at a time.
:param initial_button_state: Default state of the button. Use for checkbox and radiobox. Its value could be 0 or 1. *(Optional)*
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.
Here are various examples of the ``createButton`` function call: ::
See below various examples of the ``createButton`` function call: ::
createButton(NULL,callbackButton);//create a push button "button 0", that will call callbackButton.
createButton("button2",callbackButton,NULL,CV_CHECKBOX,0);
......
......@@ -3,86 +3,102 @@ Reading and Writing Images and Video
.. highlight:: cpp
.. index:: imdecode
.. _imdecode:
imdecode
------------
Reads an image from a buffer in memory.
.. ocv:function:: Mat imdecode( InputArray buf, int flags )
:param buf: Input array of vector of bytes.
Reads an image from a buffer in the memory.
:param buf: Input array of a vector of bytes.
:param flags: The same flags as in :ref:`imread` .
:param flags: The same flags as in :ocv:func:`imread` .
The function reads an image from the specified buffer in memory.
The function reads an image from the specified buffer in the memory.
If the buffer is too short or contains invalid data, the empty matrix is returned.
See
:ref:`imread` for the list of supported formats and flags description.
:ocv:func:`imread` for the list of supported formats and flags description.
.. index:: imencode
.. _imencode:
imencode
------------
Encode an image into a memory buffer.
.. ocv:function:: bool imencode( const string& ext, InputArray img, vector<uchar>& buf, const vector<int>& params=vector<int>())
Encodes an image into a memory buffer.
:param ext: File extension that defines the output format.
:param img: Image to be written.
:param buf: Output buffer resized to fit the compressed image.
:param params: Format-specific parameters. See :ref:`imwrite` .
:param params: Format-specific parameters. See :ocv:func:`imwrite` .
The function compresses the image and stores it in the memory buffer that is resized to fit the result.
See
:ref:`imwrite` for the list of supported formats and flags description.
:ocv:func:`imwrite` for the list of supported formats and flags description.
.. index:: imread
.. _imread:
imread
----------
Loads an image from a file.
.. ocv:function:: Mat imread( const string& filename, int flags=1 )
:param filename: Name of file to be loaded.
Loads an image from a file.
:param filename: Name of a file to be loaded.
:param flags: Flags specifying the color type of a loaded image:
* **>0** a 3-channel color image
* **>0** Load a 3-channel color image.
* **=0** a grayscale image
* **=0** Load a grayscale image.
* **<0** The image is loaded as is. Note that in the current implementation the alpha channel, if any, is stripped from the output image. For example, a 4-channel RGBA image is loaded as RGB if :math:`flags\ge0` .
* **<0** Load the image as is. Note that in the current implementation the alpha channel, if any, is stripped from the output image. For example, a 4-channel RGBA image is loaded as RGB if :math:`flags\ge0` .
The function ``imread`` loads an image from the specified file and returns it. If the image cannot be read (because of missing file, improper permissions, unsupported or invalid format), the function returns an empty matrix ( ``Mat::data==NULL`` ). Currently, the following file formats are supported:
The function ``imread`` loads an image from the specified file and returns it. If the image cannot be read (because of a missing file, improper permissions, unsupported or invalid format), the function returns an empty matrix ( ``Mat::data==NULL`` ). Currently, the following file formats are supported:
* Windows bitmaps - ``*.bmp, *.dib`` (always supported)
* JPEG files - ``*.jpeg, *.jpg, *.jpe`` (see the *Notes* section)
* JPEG files - ``*.jpeg, *.jpg, *.jpe`` (see the *Notes* below)
* JPEG 2000 files - ``*.jp2`` (see the *Notes* section)
* JPEG 2000 files - ``*.jp2`` (see the *Notes* below)
* Portable Network Graphics - ``*.png`` (see the *Notes* section)
* Portable Network Graphics - ``*.png`` (see the *Notes* below)
* Portable image format - ``*.pbm, *.pgm, *.ppm`` (always supported)
* Sun rasters - ``*.sr, *.ras`` (always supported)
* TIFF files - ``*.tiff, *.tif`` (see the *Notes* section)
* TIFF files - ``*.tiff, *.tif`` (see the *Notes* below)
**Notes**:
.. note::
* The function determines the type of an image by the content, not by the file extension.
* The function determines the type of an image by the content, not by the file extension.
* On Microsoft Windows* OS and MacOSX*, the codecs shipped with an OpenCV image (libjpeg, libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware that currently these native image loaders give images with different pixel values because of the color management embedded into MacOSX.
* On Microsoft Windows* OS and MacOSX*, the codecs shipped with an OpenCV image ( ``libjpeg``, ``libpng``, ``libtiff``, and ``libjasper``) are used by default. So, OpenCV can always read JPEGs, PNGs, and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware that currently these native image loaders give images with different pixel values because of the color management embedded into MacOSX.
* On Linux*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for codecs supplied with an OS image. Install the relevant packages (do not forget the development files, for example, "libjpeg-dev", in Debian* and Ubuntu*) to get the codec support or turn on the ``OPENCV_BUILD_3RDPARTY_LIBS`` flag in CMake.
* On Linux*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for codecs supplied with an OS image. Install the relevant packages (do not forget the development files, for example, ``libjpeg-dev``, in Debian* and Ubuntu*) to get the codec support or turn on the ``OPENCV_BUILD_3RDPARTY_LIBS`` flag in CMake.
.. index:: imwrite
.. _imwrite:
imwrite
-----------
Saves an image to a specified file.
.. ocv:function:: bool imwrite( const string& filename, InputArray img, const vector<int>& params=vector<int>())
Saves an image to a specified file.
:param filename: Name of the file.
:param img: Image to be saved.
......@@ -96,15 +112,19 @@ Saves an image to a specified file.
* For PPM, PGM, or PBM, it can be a binary format flag ( ``CV_IMWRITE_PXM_BINARY`` ), 0 or 1. Default value is 1.
The function ``imwrite`` saves the image to the specified file. The image format is chosen based on the ``filename`` extension (see
:ref:`imread` for the list of extensions). Only 8-bit (or 16-bit in case of PNG, JPEG 2000, and TIFF) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use
:ref:`Mat::convertTo` , and
:ref:`cvtColor` to convert it before saving. Or, use the universal XML I/O functions to save the image to XML or YAML format.
:ocv:func:`imread` for the list of extensions). Only 8-bit (or 16-bit in case of PNG, JPEG 2000, and TIFF) single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use
:ocv:func:`Mat::convertTo` , and
:ocv:func:`cvtColor` to convert it before saving. Or, use the universal XML I/O functions to save the image to XML or YAML format.
.. index:: VideoCapture
.. _VideoCapture:
VideoCapture
------------
.. ocv:class:: VideoCapture
Class for video capturing from video files or cameras ::
Class for video capturing from video files or cameras. ::
class VideoCapture
{
......@@ -152,7 +172,7 @@ Class for video capturing from video files or cameras ::
};
The class provides C++ video capturing API. Here is how the class can be used: ::
The class provides C++ video capturing API. Use the class as follows: ::
#include "cv.h"
#include "highgui.h"
......@@ -182,30 +202,35 @@ The class provides C++ video capturing API. Here is how the class can be used: :
}
.. index:: VideoCapture::VideoCapture
.. _VideoCapture::VideoCapture:
VideoCapture::VideoCapture
------------------------------
VideoCapture constructors.
.. ocv:function:: VideoCapture::VideoCapture()
.. ocv:function:: VideoCapture::VideoCapture(const string& filename)
.. ocv:function:: VideoCapture::VideoCapture(int device)
:param filename: name of the opened video file
Provides VideoCapture constructors.
:param filename: Name of an opened video file.
:param device: id of the opened video capturing device (i.e. a camera index).
:param device: ID of an opened video capturing device (a camera index).
.. index:: VideoCapture::get
.. _VideoCapture::get:
VideoCapture::get
---------------------
Returns the specified ``VideoCapture`` property
.. ocv:function:: double VideoCapture::get(int property_id)
:param property_id: Property identifier. It can be one of the following:
* **CV_CAP_PROP_POS_MSEC** Film current position in milliseconds or video capture timestamp.
* **CV_CAP_PROP_POS_MSEC** Current position of the film in milliseconds or video capture timestamp.
* **CV_CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next.
......@@ -239,22 +264,26 @@ Returns the specified ``VideoCapture`` property
* **CV_CAP_PROP_CONVERT_RGB** Boolean flags indicating whether images should be converted to RGB.
* **CV_CAP_PROP_WHITE_BALANCE** Currently unsupported
* **CV_CAP_PROP_WHITE_BALANCE** Currently not supported.
* **CV_CAP_PROP_RECTIFICATION** TOWRITE (note: only supported by DC1394 v 2.x backend currently)
* **CV_CAP_PROP_RECTIFICATION** TOWRITE (Note: only supported by DC1394 v 2.x backend currently)
**Note**: When querying a property that is not supported by the backend used by the ``VideoCapture`` class, value 0 is returned.
.. note:: When querying a property that is not supported by the backend used by the ``VideoCapture`` class, value 0 is returned.
.. index:: VideoCapture::set
.. _VideoCapture::set:
VideoCapture::set
---------------------
Sets a property in the ``VideoCapture``.
.. ocv:function:: bool VideoCapture::set(int property_id, double value)
Sets a property in the VideoCapture backend.
:param property_id: Property identifier. It can be one of the following:
* **CV_CAP_PROP_POS_MSEC** Film current position in milliseconds or video capture timestamp.
* **CV_CAP_PROP_POS_MSEC** Current position of the film in milliseconds or video capture timestamp.
* **CV_CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next.
......@@ -288,17 +317,23 @@ Sets a property in the ``VideoCapture``.
* **CV_CAP_PROP_CONVERT_RGB** Boolean flags indicating whether images should be converted to RGB.
* **CV_CAP_PROP_WHITE_BALANCE** Currently unsupported
* **CV_CAP_PROP_WHITE_BALANCE** Currently not supported
* **CV_CAP_PROP_RECTIFICATION** TOWRITE (note: only supported by DC1394 v 2.x backend currently)
* **CV_CAP_PROP_RECTIFICATION** TOWRITE (Note: only supported by DC1394 v 2.x backend currently)
:param value: Value of the property.
.. index:: VideoWriter
.. _VideoWriter:
VideoWriter
-----------
.. ocv:class:: VideoWriter
Video writer class ::
Video writer class. ::
class VideoWriter
{
......@@ -331,6 +366,5 @@ Video writer class ::
...
};
For more detailed description see http://opencv.willowgarage.com/wiki/documentation/cpp/highgui/VideoWriter
..
......@@ -3,14 +3,15 @@ User Interface
.. highlight:: cpp
.. index:: createTrackbar
.. _createTrackbar:
createTrackbar
------------------
Creates a trackbar and attaches it to the specified window.
.. ocv:function:: int createTrackbar( const string& trackbarname, const string& winname, int* value, int count, TrackbarCallback onChange=0, void* userdata=0)
.. ocv:cfunction:: int cvCreateTrackbar( const char* trackbarName, const char* windowName, int* value, int count, CvTrackbarCallback onChange )
.. ocv:pyoldfunction:: CreateTrackbar(trackbarName, windowName, value, count, onChange) -> None
Creates a trackbar and attaches it to the specified window.
:param trackbarname: Name of the created trackbar.
......@@ -24,7 +25,7 @@ Creates a trackbar and attaches it to the specified window.
:param userdata: User data that is passed as is to the callback. It can be used to handle trackbar events without using global variables.
The function ``createTrackbar`` creates a trackbar (a.k.a. slider or range control) with the specified name and range, assigns a variable ``value`` to be syncronized with the trackbar position and specifies the callback function ``onChange`` to be called on the trackbar position change. The created trackbar is displayed on top of the given window.
The function ``createTrackbar`` creates a trackbar (a slider or range control) with the specified name and range, assigns a variable ``value`` to be a position syncronized with the trackbar and specifies the callback function ``onChange`` to be called on the trackbar position change. The created trackbar is displayed on top of the given window.
**[Qt Backend Only]**
......@@ -40,14 +41,13 @@ is NULL.
Clicking the label of each trackbar enables editing the trackbar values manually for a more accurate control of it.
.. index:: getTrackbarPos
getTrackbarPos
------------------
Returns the trackbar position.
.. ocv:function:: int getTrackbarPos( const string& trackbarname, const string& winname )
.. ocv:cfunction:: int cvGetTrackbarPos( const char* trackbarName, const char* windowName )
.. ocv:pyoldfunction:: GetTrackbarPos(trackbarName, windowName)-> None
Returns the trackbar position.
:param trackbarname: Name of the trackbar.
......@@ -61,12 +61,16 @@ Qt-specific details:
* **winname** Name of the window that is the parent of the trackbar. It can be NULL if the trackbar is attached to the control panel.
.. index:: imshow
.. _imshow:
imshow
----------
Displays an image in the specified window.
.. ocv:function:: void imshow( const string& winname, InputArray image )
Displays an image in the specified window.
:param winname: Name of the window.
:param image: Image to be shown.
......@@ -82,25 +86,25 @@ The function ``imshow`` displays an image in the specified window. If the window
*
If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].
.. index:: namedWindow
.. _namedWindow:
namedWindow
---------------
Creates a window.
.. ocv:function:: void namedWindow( const string& winname, int flags )
.. ocv:cfunction:: int cvNamedWindow( const char* name, int flags )
.. ocv:pyoldfunction:: NamedWindow(name, flags=CV_WINDOW_AUTOSIZE)-> None
Creates a window.
:param name: Name of the window in the window caption that may be used as a window identifier.
:param flags: Flags of the window. Currently the only supported flag is ``CV_WINDOW_AUTOSIZE`` . If this is set, the window size is automatically adjusted to fit the displayed image (see :ref:`imshow` ), and you cannot change the window size manually.
:param flags: Flags of the window. Currently the only supported flag is ``CV_WINDOW_AUTOSIZE`` . If it is set, the window size is automatically adjusted to fit the displayed image (see :ocv:func:`imshow` ), and you cannot change the window size manually.
The function ``namedWindow`` creates a window that can be used as a placeholder for images and trackbars. Created windows are referred to by their names.
If a window with the same name already exists, the function does nothing.
You can call :cpp:func:`destroyWindow` or :cpp:func:`destroyAllWindows` to close the window and de-allocate any associated memory usage. For a simple program, you do not really have to call these functions because all the resources and windows of the application are closed automatically by the operating system upon exit.
You can call :ocv:func:`destroyWindow` or :ocv:func:`destroyAllWindows` to close the window and de-allocate any associated memory usage. For a simple program, you do not really have to call these functions because all the resources and windows of the application are closed automatically by the operating system upon exit.
**[Qt Backend Only]**
......@@ -108,7 +112,7 @@ Qt-specific details:
* **flags** Flags of the window. Currently the supported flags are:
* **CV_WINDOW_NORMAL or CV_WINDOW_AUTOSIZE:** ``CV_WINDOW_NORMAL`` enables you to resize the window, whereas ``CV_WINDOW_AUTOSIZE`` adjusts automatically the window size to fit the displayed image (see :ref:`imshow` ), and you cannot change the window size manually.
* **CV_WINDOW_NORMAL or CV_WINDOW_AUTOSIZE:** ``CV_WINDOW_NORMAL`` enables you to resize the window, whereas ``CV_WINDOW_AUTOSIZE`` adjusts automatically the window size to fit the displayed image (see :ocv:func:`imshow` ), and you cannot change the window size manually.
* **CV_WINDOW_FREERATIO or CV_WINDOW_KEEPRATIO:** ``CV_WINDOW_FREERATIO`` adjusts the image with no respect to its ratio, whereas ``CV_WINDOW_KEEPRATIO`` keeps the image ratio.
......@@ -120,46 +124,52 @@ Qt-specific details:
::
namedWindow( "myWindow", CV_WINDOW_NORMAL | CV_GUI_NORMAL );
namedWindow( ``myWindow'', ``CV_WINDOW_NORMAL`` textbar ``CV_GUI_NORMAL`` );
..
.. index:: destroyWindow
.. _destroyWindow:
destroyWindow
-------------
Destroys a window.
.. ocv:function:: void destroyWindow( const string &winname )
.. ocv:cfunction:: void cvDestroyWindow( const char* name )
.. ocv:pyoldfunction:: DestroyWindow(name)-> None
Destroys a window.
:param winname: Name of the window to be destroyed.
The function ``destroyWindow`` destroys the window with the given name.
.. index:: destroyAllWindows
.. _destroyAllWindows:
destroyAllWindows
-----------------
Destroys all of the HighGUI windows.
.. ocv:function:: void destroyAllWindows()
Destroys all of the HighGUI windows.
The function ``destroyAllWindows`` destroys all of the opened HighGUI windows.
.. index:: setTrackbarPos
.. _setTrackbarPos:
setTrackbarPos
------------------
Sets the trackbar position.
.. ocv:function:: void setTrackbarPos( const string& trackbarname, const string& winname, int pos )
.. ocv:cfunction:: void cvSetTrackbarPos( const char* trackbarName, const char* windowName, int pos )
.. ocv:pyoldfunction:: SetTrackbarPos(trackbarName, windowName, pos)-> None
Sets the trackbar position.
:param trackbarname: Name of the trackbar.
:param winname: Name of the window that is the parent of trackbar.
:param winname: Name of the window that is the parent of the trackbar.
:param pos: New position.
......@@ -171,21 +181,22 @@ Qt-specific details:
* **winname** Name of the window that is the parent of the trackbar. It can be NULL if the trackbar is attached to the control panel.
.. index:: waitKey
.. _waitKey:
waitKey
-----------
Waits for a pressed key.
.. ocv:function:: int waitKey(int delay=0)
.. ocv:cfunction:: int cvWaitKey( int delay=0 )
.. ocv:pyoldfunction:: WaitKey(delay=0)-> int
Waits for a pressed key.
:param delay: Delay in milliseconds. 0 is the special value that means "forever".
The function ``waitKey`` waits for a key event infinitely (when
:math:`\texttt{delay}\leq 0` ) or for ``delay`` milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the function will not wait exactly ``delay`` ms, it will wait at least ``delay`` ms, depending on what else is running on your computer at that time. It returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed.
:math:`\texttt{delay}\leq 0` ) or for ``delay`` milliseconds, when it is positive. It returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed.
**Notes:**
.. note::
* This function is the only method in HighGUI that can fetch and handle events, so it needs to be called periodically for normal event processing unless HighGUI is used within an environment that takes care of event processing.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment