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.
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
...
@@ -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 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.
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 main(int argc, char *argv[])
int value = 50;
int value = 50;
...
@@ -56,14 +56,15 @@ The following code is an example used to generate the figure. ::
...
@@ -56,14 +56,15 @@ The following code is an example used to generate the figure. ::
return 0;
return 0;
}
}
.. index:: setWindowProperty
.. _setWindowProperty:
setWindowProperty
setWindowProperty
---------------------
---------------------
Changes parameters of a window dynamically.
.. ocv:function:: void setWindowProperty(const string& name, int prop_id, double prop_value)
.. 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.
:param name: Name of the window.
...
@@ -86,18 +87,18 @@ Changes parameters of a window dynamically.
...
@@ -86,18 +87,18 @@ Changes parameters of a window dynamically.
* **CV_WINDOW_FREERATIO** Make the window resizable without any ratio constraints.
* **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.
The function ``setWindowProperty`` enables changing properties of a window.
.. index:: getWindowProperty
getWindowProperty
getWindowProperty
---------------------
---------------------
Provides parameters of a window.
.. ocv:function:: void getWindowProperty(const string& name, int prop_id)
.. 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.
:param name: Name of the window.
...
@@ -111,45 +112,47 @@ Provides parameters of a window.
...
@@ -111,45 +112,47 @@ Provides parameters of a window.
See
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.
The function ``getWindowProperty`` returns properties of a window.
.. index:: fontQt
.. _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: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 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 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:
: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.
You can also specify a positive integer for better control.
:param style: Font style. The following operation flags are available:
: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.
:param spacing: Spacing between characters. It can be negative or positive.
...
@@ -160,14 +163,13 @@ A basic usage of this function is the following: ::
...
@@ -160,14 +163,13 @@ A basic usage of this function is the following: ::
CvFont font = fontQt(''Times'');
CvFont font = fontQt(''Times'');
addText( img1, ``Hello World !'', Point(50,50), font);
addText( img1, ``Hello World !'', Point(50,50), font);
:param text: Overlay text to write on a window image.
:param text: Overlay text to write on a window image.
...
@@ -204,14 +204,13 @@ displayOverlay
...
@@ -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.
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
displayStatusBar
--------------------
--------------------
Displays a text on the window statusbar during the specified period of time.
:param ext: File extension that defines the output format.
:param ext: File extension that defines the output format.
:param img: Image to be written.
:param img: Image to be written.
:param buf: Output buffer resized to fit the compressed image.
: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.
The function compresses the image and stores it in the memory buffer that is resized to fit the result.
See
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
imread
----------
----------
Loads an image from a file.
.. ocv:function:: Mat imread( const string& filename, int flags=1 )
.. 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:
: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)
* 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)
* Portable image format - ``*.pbm, *.pgm, *.ppm`` (always supported)
* Sun rasters - ``*.sr, *.ras`` (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.
@@ -96,15 +112,19 @@ Saves an image to a specified file.
...
@@ -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.
* 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
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
: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
:ref:`Mat::convertTo` , and
:ocv:func:`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:`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
VideoCapture
------------
------------
.. ocv:class:: VideoCapture
.. ocv:class:: VideoCapture
Class for video capturing from video files or cameras ::
Class for video capturing from video files or cameras. ::
class VideoCapture
class VideoCapture
{
{
...
@@ -152,7 +172,7 @@ Class for video capturing from video files or cameras ::
...
@@ -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 "cv.h"
#include "highgui.h"
#include "highgui.h"
...
@@ -182,30 +202,35 @@ The class provides C++ video capturing API. Here is how the class can be used: :
...
@@ -182,30 +202,35 @@ The class provides C++ video capturing API. Here is how the class can be used: :
:param trackbarname: Name of the created trackbar.
:param trackbarname: Name of the created trackbar.
...
@@ -24,7 +25,7 @@ Creates a trackbar and attaches it to the specified window.
...
@@ -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.
: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]**
**[Qt Backend Only]**
...
@@ -40,14 +41,13 @@ is NULL.
...
@@ -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.
Clicking the label of each trackbar enables editing the trackbar values manually for a more accurate control of it.
:param name: Name of the window in the window caption that may be used as a window identifier.
: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.
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.
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]**
**[Qt Backend Only]**
...
@@ -108,7 +112,7 @@ Qt-specific details:
...
@@ -108,7 +112,7 @@ Qt-specific details:
* **flags** Flags of the window. Currently the supported flags are:
* **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.
* **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.
: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.
:param pos: New position.
...
@@ -171,21 +181,22 @@ Qt-specific details:
...
@@ -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.
* **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
waitKey
-----------
-----------
Waits for a pressed key.
.. ocv:function:: int waitKey(int delay=0)
.. ocv:function:: int waitKey(int delay=0)
.. ocv:cfunction:: int cvWaitKey( int delay=0 )
Waits for a pressed key.
.. ocv:pyoldfunction:: WaitKey(delay=0)-> int
:param delay: Delay in milliseconds. 0 is the special value that means "forever".
:param delay: Delay in milliseconds. 0 is the special value that means "forever".
The function ``waitKey`` waits for a key event infinitely (when
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.
* 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.