提交 a766f9b4 编写于 作者: E Elena Fedotova

Purpose: updated the highgui chapter

上级 2f81eb22
Qt new functions
Qt New Functions
================
.. highlight:: cpp
.. image:: pics/qtgui.png
This figure explains the new functionalities implemented with Qt GUI. As we can see, the new GUI provides a statusbar, a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it.
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.
*
To attach a trackbar, the window name parameter must be NULL.
*
To attach a buttonbar, a button must be created.
If the last bar attached to the control panel is a buttonbar, the new button is added on 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 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. ::
......@@ -63,33 +64,33 @@ setWindowProperty
---------------------
.. c:function:: void setWindowProperty(const string& name, int prop_id, double prop_value)
Change the parameters of the window dynamically.
Changes parameters of a window dynamically.
:param name: Name of the window.
:param prop_id: Window's property to edit. The operation flags:
:param prop_id: Window property to edit. The following operation flags are available:
* **CV_WND_PROP_FULLSCREEN** Change if the window is fullscreen ( ``CV_WINDOW_NORMAL`` or ``CV_WINDOW_FULLSCREEN`` ).
* **CV_WND_PROP_AUTOSIZE** Change if the user can resize the window (texttt {CV\_WINDOW\_NORMAL} or ``CV_WINDOW_AUTOSIZE`` ).
* **CV_WND_PROP_AUTOSIZE** Change if the window is resizable (texttt {CV\_WINDOW\_NORMAL} or ``CV_WINDOW_AUTOSIZE`` ).
* **CV_WND_PROP_ASPECTRATIO** Change if the image's aspect ratio is preserved (texttt {CV\_WINDOW\_FREERATIO} or ``CV_WINDOW_KEEPRATIO`` ).
* **CV_WND_PROP_ASPECTRATIO** Change if the aspect ratio of the image is preserved (texttt {CV\_WINDOW\_FREERATIO} or ``CV_WINDOW_KEEPRATIO`` ).
:param prop_value: New value of the Window's property. The operation flags:
:param prop_value: New value of the window property. The following operation flags are available:
* **CV_WINDOW_NORMAL** Change the window in normal size, or allows the user to resize the window.
* **CV_WINDOW_NORMAL** Change the window to normal size or make the window resizable.
* **CV_WINDOW_AUTOSIZE** The user cannot resize the window, the size is constrainted by the image displayed.
* **CV_WINDOW_AUTOSIZE** Constrain the size by the displayed image. The window is not resizable.
* **CV_WINDOW_FULLSCREEN** Change the window to fullscreen.
* **CV_WINDOW_FREERATIO** The image expends as much as it can (no ratio constraint)
* **CV_WINDOW_FREERATIO** Make the image extendable (no ratio constraint).??
* **CV_WINDOW_KEEPRATIO** The ration image is respected.
* **CV_WINDOW_KEEPRATIO** Maintain the image ratio.??
The function `` setWindowProperty`` allows to change the window's properties.
The function ``setWindowProperty`` enables changing properties of a window.
.. index:: getWindowProperty
......@@ -97,23 +98,23 @@ getWindowProperty
---------------------
.. c:function:: void getWindowProperty(const char* name, int prop_id)
Get the parameters of the window.
Provides parameters of a window.
:param name: Name of the window.
:param prop_id: Window's property to retrive. The operation flags:
:param prop_id: Window property to retrive. The following operation flags are available:
* **CV_WND_PROP_FULLSCREEN** Change if the window is fullscreen ( ``CV_WINDOW_NORMAL`` or ``CV_WINDOW_FULLSCREEN`` ).
* **CV_WND_PROP_AUTOSIZE** Change if the user can resize the window (texttt {CV\_WINDOW\_NORMAL} or ``CV_WINDOW_AUTOSIZE`` ).
* **CV_WND_PROP_AUTOSIZE** Change if the window is resizable (texttt {CV\_WINDOW\_NORMAL} or ``CV_WINDOW_AUTOSIZE`` ).
* **CV_WND_PROP_ASPECTRATIO** Change if the image's aspect ratio is preserved (texttt {CV\_WINDOW\_FREERATIO} or ``CV_WINDOW_KEEPRATIO`` ).
* **CV_WND_PROP_ASPECTRATIO** Change if the aspect ratio of the image is preserved (texttt {CV\_WINDOW\_FREERATIO} or ``CV_WINDOW_KEEPRATIO`` ).
See
:ref:`setWindowProperty` to know the meaning of the returned values.
The function `` getWindowProperty`` return window's properties.
The function ``getWindowProperty`` returns properties of a window.
.. index:: fontQt
......@@ -123,15 +124,15 @@ fontQt
----------
.. c: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)
Create the font to be used to draw text on an image.
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 will be 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 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 -- A = 255 is fully transparent. Use the macro ``CV _ RGB`` for simplicity.
:param weight: The operation flags:
:param weight: Font weight. The following operation flags are available:
* **CV_FONT_LIGHT** Weight of 25
......@@ -143,21 +144,21 @@ fontQt
* **CV_FONT_BLACK** Weight of 87
You can also specify a positive integer for more control.
You can also specify a positive integer for better control.
:param style: The operation flags:
:param style: Font style. The following operation flags are available:
* **CV_STYLE_NORMAL** Font is normal
* **CV_STYLE_NORMAL** Normal font
* **CV_STYLE_ITALIC** Font is in italic
* **CV_STYLE_ITALIC** Italic font
* **CV_STYLE_OBLIQUE** Font is oblique
* **CV_STYLE_OBLIQUE** Oblique font
:param spacing: Spacing between characters. Can be negative or positive
:param spacing: Spacing between characters. It can be negative or positive.
The function ``fontQt`` creates a CvFont object. This CvFont is not compatible with putText.
The function ``fontQt`` creates a ``CvFont`` object. This ``CvFont`` is not compatible with ``putText`` .
A basic usage of this function is: ::
A basic usage of this function is the following: ::
CvFont font = fontQt(''Times'');
addText( img1, ``Hello World !'', Point(50,50), font);
......@@ -168,19 +169,19 @@ addText
-----------
.. c:function:: void addText(const Mat& img, const string& text, Point location, CvFont *font)
Create the font to be used to draw text on an image
Creates the font to draw a text on an image.
:param img: Image where the text should be drawn
:param img: Image where the text should be drawn.
:param text: Text to write on the image
:param text: Text to write on an image.
:param location: Point(x,y) where the text should start on the image
:param location: Point(x,y) where the text should start on an image.
:param font: Font to use to draw the text
:param font: Font to use to draw a text.
The function ``addText`` draw
The function ``addText`` draws
*text*
on the image
on an image
*img*
using a specific font
*font*
......@@ -193,17 +194,17 @@ displayOverlay
------------------
.. c:function:: void displayOverlay(const string& name, const string& text, int delay)
Display text on the window's image as an overlay for delay milliseconds. This is not editing the image's data. The text is display on the top of the image.
Displays a text on a window image as an overlay for a specified duration.
:param name: Name of the window
:param name: Name of the window.
:param text: Overlay text to write on the window's image
:param text: Overlay text to write on a window image.
:param delay: Delay to display the overlay text. If this function is called before the previous overlay text time out, the timer is restarted and the text updated. . If this value is zero, the text never disapers.
:param delay: Duration (in milliseconds)? to display the overlay text. If this function is called before the previous overlay text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.
The function ``displayOverlay`` aims at displaying useful information/tips on the window for a certain amount of time
The function ``displayOverlay`` displays useful information/tips on top of the window for a certain amount of time
*delay*
. This information is display on the top of the window.
. This does not affect the image data.??
.. index:: displayStatusBar
......@@ -211,17 +212,17 @@ displayStatusBar
--------------------
.. c:function:: void displayStatusBar(const string& name, const string& text, int delayms)
Display text on the window's statusbar as for delay milliseconds.
Displays a text on the window statusbar for a specified duration.??
:param name: Name of the window
:param name: Name of the window.
:param text: Text to write on the window's statusbar
:param text: Text to write on the window statusbar.
:param delay: Delay to display the text. If this function is called before the previous text time out, the timer is restarted and the text updated. If this value is zero, the text never disapers.
:param delay: Duration (in milliseconds) to display the text. If this function is called before the previous text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.
The function ``displayOverlay`` aims at displaying useful information/tips on the window for a certain amount of time
The function ``displayOverlay`` displays useful information/tips on top of the window for a certain amount of time
*delay*
. This information is displayed on the window's statubar (the window must be created with ``CV_GUI_EXPANDED`` flags).
. This information is displayed on the window statubar (the window must be created with the ``CV_GUI_EXPANDED`` flags).
.. index:: createOpenGLCallback
......@@ -230,21 +231,19 @@ createOpenGLCallback
.. c: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)
Create a callback function called to draw OpenGL on top the the image display by windowname.
Creates a callback function called to draw OpenGL on top the the image display by ``windowname`` .
:param window_name: Name of the window
:param window_name: Name of the window.
:param callbackOpenGL:
Pointer to the function to be called every frame.
This function should be prototyped as ``void Foo(*void);`` .
:param callbackOpenGL: Pointer to the function to be called every frame. This function should be prototyped as ``void Foo(*void);`` .
:param userdata: pointer passed to the callback function. *(Optional)*
:param userdata: Pointer passed to the callback function. *(Optional)*
:param angle: Specifies the field of view angle, in degrees, in the y direction.. *(Optional - Default 45 degree)*
:param angle: Parameter specifying the field of view angle, in degrees, in the y direction. Default value is 45 degrees. *(Optional)*
:param zmin: Specifies the distance from the viewer to the near clipping plane (always positive). *(Optional - Default 0.01)*
:param zmin: Parameter specifying the distance from the viewer to the near clipping plane (always positive). Default value is 0.01. *(Optional)*
:param zmax: Specifies the distance from the viewer to the far clipping plane (always positive). *(Optional - Default 1000)*
: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: ::
......@@ -284,12 +283,12 @@ saveWindowParameters
.. c:function:: void saveWindowParameters(const string& name)
Save parameters of the window windowname.
Saves parameters of the window ``windowname`` .
:param name: Name of the window
:param name: Name of the window.
The function ``saveWindowParameters`` saves size, location, flags, trackbars' value, zoom and panning location of the window
*window_name*
The function ``saveWindowParameters`` saves size, location, flags, trackbars value, zoom and panning location of the window
``window_name`` .
.. index:: loadWindowParameters
......@@ -298,12 +297,12 @@ loadWindowParameters
.. c:function:: void loadWindowParameters(const string& name)
Load parameters of the window windowname.
Loads parameters of the window ``windowname`` .
:param name: Name of the window
:param name: Name of the window.
The function ``loadWindowParameters`` load size, location, flags, trackbars' value, zoom and panning location of the window
*window_name*
The function ``loadWindowParameters`` loads size, location, flags, trackbars value, zoom and panning location of the window
``window_name`` .
.. index:: createButton
......@@ -312,31 +311,29 @@ createButton
.. c: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))
Create a callback function called to draw OpenGL on top the the image display by windowname.
Creates a callback function called to draw OpenGL on top of the image display by ``windowname`` .
:param button_name: Name of the button *( if NULL, the name will be "button <number of boutton>")*
:param button_name: Name of the button. If NULL, the name is ``button <number of buttons>`` .??
:param on_change:
Pointer to the function to be called every time the button changed its state.
This function should be prototyped as ``void Foo(int state,*void);`` . *state* is the current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
:param on_change: Pointer to the function to be called every time the button changes its state. This function should be prototyped as ``void Foo(int state,*void);`` . *state* is the current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button.
:param userdata: pointer passed to the callback function. *(Optional)*
:param userdata: Pointer passed to the callback function. *(Optional)*
The ``button_type`` parameter can be :
* (Optional -- Will be a push button by default.)
The ``button_type`` parameter can be any of the following:
* (Optional -- Will be a push button by default.)??
* **CV_PUSH_BUTTON** The button will be a push button.
* **CV_PUSH_BUTTON** Push button
* **CV_CHECKBOX** The button will be a checkbox button.
* **CV_CHECKBOX** Checkbox button
* **CV_RADIOBOX** The button will be a radiobox button. The radiobox on the same buttonbar (same line) are exclusive; one on can be select at the 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.
* **initial_button_state** Default state of the button. Use for checkbox and radiobox, its value could be 0 or 1. *(Optional)*
* **initial_button_state** Default state of the button. Use for checkbox and radiobox. Its value could be 0 or 1. *(Optional)*
The function ``createButton`` attach a button to the control panel. Each button is added to a buttonbar on the right of the last button.
A new buttonbar is create if nothing was attached to the control panel before, or if the last element attached to the control panel was a trackbar.
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 example of ``createButton`` function call: ::
Here are 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);
......
......@@ -13,15 +13,15 @@ imdecode
Reads an image from a buffer in memory.
:param buf: The input array of vector of bytes
:param buf: Input array of vector of bytes.
:param flags: The same flags as in :ref:`imread`
:param flags: The same flags as in :ref:`imread` .
The function reads image from the specified buffer in memory.
If the buffer is too short or contains invalid data, the empty matrix will be returned.
The function reads an image from the specified buffer in 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 the flags description.
:ref:`imread` for the list of supported formats and flags description.
.. index:: imencode
......@@ -33,17 +33,17 @@ imencode
Encode an image into a memory buffer.
:param ext: The file extension that defines the output format
:param ext: File extension that defines the output format.
:param img: The image to be written
:param img: Image to be written.
:param buf: The output buffer; resized to fit the compressed image
:param buf: Output buffer resized to fit the compressed image.
:param params: The format-specific parameters; see :ref:`imwrite`
:param params: Format-specific parameters. See :ref:`imwrite` .
The function compresses the image and stores it in the memory buffer, which 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
:ref:`imwrite` for the list of supported formats and the flags description.
:ref:`imwrite` for the list of supported formats and flags description.
.. index:: imread
......@@ -57,37 +57,37 @@ imread
:param filename: Name of file to be loaded.
:param flags: Specifies color type of the loaded image:
:param flags: Flags specifying the color type of a loaded image:
* **>0** the loaded image is forced to be a 3-channel color image
* **>0** a 3-channel color image
* **=0** the loaded image is forced to be grayscale
* **=0** a grayscale image
* **<0** the loaded image will be loaded as-is (note that in the current implementation the alpha channel, if any, is stripped from the output image, e.g. 4-channel RGBA image will be loaded as RGB if :math:`flags\ge0` ).
* **<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` .
The function ``imread`` loads an image from the specified file and returns it. If the image can not be read (because of missing file, improper permissions, unsupported or invalid format), the function returns 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 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 **Note2**)
* JPEG files - ``*.jpeg, *.jpg, *.jpe`` (see the *Notes* section)
* JPEG 2000 files - ``*.jp2`` (see **Note2**)
* JPEG 2000 files - ``*.jp2`` (see the *Notes* section)
* Portable Network Graphics - ``*.png`` (see **Note2**)
* Portable Network Graphics - ``*.png`` (see the *Notes* section)
* Portable image format - ``*.pbm, *.pgm, *.ppm`` (always supported)
* Sun rasters - ``*.sr, *.ras`` (always supported)
* TIFF files - ``*.tiff, *.tif`` (see **Note2**)
* TIFF files - ``*.tiff, *.tif`` (see the *Notes* section)
**Note1**
: The function determines type of the image by the content, not by the file extension.
**Notes**:
**Note2**
: On Windows and MacOSX the shipped with OpenCV image codecs (libjpeg, libpng, libtiff and libjasper) are used by default; so OpenCV can always read JPEGs, PNGs and TIFFs. On MacOSX there is also the option to use native MacOSX image readers. But beware that currently these native image loaders give images with somewhat different pixel values, because of the embedded into MacOSX color management.
* The function determines the type of an image by the content, not by the file extension.
On Linux, BSD flavors and other Unix-like open-source operating systems OpenCV looks for the supplied with OS image codecs. Please, install the relevant packages (do not forget the development files, e.g. "libjpeg-dev" etc. in Debian and Ubuntu) in order to get the codec support, or turn on ``OPENCV_BUILD_3RDPARTY_LIBS`` flag in CMake.
* 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.
.. index:: imwrite
......@@ -101,20 +101,20 @@ imwrite
:param filename: Name of the file.
:param img: The image to be saved.
:param img: Image to be saved.
:param params: The format-specific save parameters, encoded as pairs ``paramId_1, paramValue_1, paramId_2, paramValue_2, ...`` . The following parameters are currently supported:
:param params: Format-specific save parameters encoded as pairs ``paramId_1, paramValue_1, paramId_2, paramValue_2, ...`` . The following parameters are currently supported:
* In the case of JPEG it can be a quality ( ``CV_IMWRITE_JPEG_QUALITY`` ), from 0 to 100 (the higher is the better), 95 by default.
* For JPEG, it can be a quality ( ``CV_IMWRITE_JPEG_QUALITY`` ) from 0 to 100 (the higher is the better). Default value is 95.
* In the case of PNG it can be the compression level ( ``CV_IMWRITE_PNG_COMPRESSION`` ), from 0 to 9 (the higher value means smaller size and longer compression time), 3 by default.
* For PNG, it can be the compression level ( ``CV_IMWRITE_PNG_COMPRESSION`` ) from 0 to 9. A higher value means a smaller size and longer compression time. Default value is 3.
* In the case of PPM, PGM or PBM it can a binary format flag ( ``CV_IMWRITE_PXM_BINARY`` ), 0 or 1, 1 by default.
* 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 the 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
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.
:ref:`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
......@@ -214,11 +214,13 @@ VideoCapture::VideoCapture
.. c:function:: VideoCapture::VideoCapture(int device)
VideoCapture constructors.?? No desc here and further??
:param filename: TOWRITE
:param device: TOWRITE
VideoCapture constructors.
.. index:: VideoCapture::get
......@@ -228,47 +230,48 @@ VideoCapture::get
---------------------
.. c:function:: double VideoCapture::get(int property_id)
:param property_id: Property identifier. Can be one of the following:
: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** Film current position in milliseconds or video capture timestamp.
* **CV_CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next
* **CV_CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next.
* **CV_CAP_PROP_POS_AVI_RATIO** Relative position of the video file (0 - start of the film, 1 - end of the film)
* **CV_CAP_PROP_POS_AVI_RATIO** Relative position of the video file: 0 - start of the film, 1 - end of the film.
* **CV_CAP_PROP_FRAME_WIDTH** Width of the frames in the video stream
* **CV_CAP_PROP_FRAME_WIDTH** Width of the frames in the video stream.
* **CV_CAP_PROP_FRAME_HEIGHT** Height of the frames in the video stream
* **CV_CAP_PROP_FRAME_HEIGHT** Height of the frames in the video stream.
* **CV_CAP_PROP_FPS** Frame rate
* **CV_CAP_PROP_FPS** Frame rate.
* **CV_CAP_PROP_FOURCC** 4-character code of codec
* **CV_CAP_PROP_FOURCC** 4-character code of codec.
* **CV_CAP_PROP_FRAME_COUNT** Number of frames in the video file
* **CV_CAP_PROP_FRAME_COUNT** Number of frames in the video file.
* **CV_CAP_PROP_FORMAT** The format of the Mat objects returned by retrieve()
* **CV_CAP_PROP_FORMAT** Format of the Mat objects returned by ``retrieve()`` .
* **CV_CAP_PROP_MODE** A backend-specific value indicating the current capture mode
* **CV_CAP_PROP_MODE** Backend-specific value indicating the current capture mode.
* **CV_CAP_PROP_BRIGHTNESS** Brightness of the image (only for cameras)
* **CV_CAP_PROP_BRIGHTNESS** Brightness of the image (only for cameras).
* **CV_CAP_PROP_CONTRAST** Contrast of the image (only for cameras)
* **CV_CAP_PROP_CONTRAST** Contrast of the image (only for cameras).
* **CV_CAP_PROP_SATURATION** Saturation of the image (only for cameras)
* **CV_CAP_PROP_SATURATION** Saturation of the image (only for cameras).
* **CV_CAP_PROP_HUE** Hue of the image (only for cameras)
* **CV_CAP_PROP_HUE** Hue of the image (only for cameras).
* **CV_CAP_PROP_GAIN** Gain of the image (only for cameras)
* **CV_CAP_PROP_GAIN** Gain of the image (only for cameras).
* **CV_CAP_PROP_EXPOSURE** Exposure (only for cameras)
* **CV_CAP_PROP_EXPOSURE** Exposure (only for cameras).
* **CV_CAP_PROP_CONVERT_RGB** Boolean flags indicating whether images should be converted to RGB
* **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_RECTIFICATION** TOWRITE (note: only supported by DC1394 v 2.x backend currently)
Note that when querying a property which is unsupported by the backend used by the VideoCapture class, the 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
......@@ -278,49 +281,51 @@ VideoCapture::set
---------------------
.. c:function:: bool VideoCapture::set(int property_id, double value)
:param property_id: Property identifier. Can be one of the following:
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** Film current position in milliseconds or video capture timestamp.
* **CV_CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next
* **CV_CAP_PROP_POS_FRAMES** 0-based index of the frame to be decoded/captured next.
* **CV_CAP_PROP_POS_AVI_RATIO** Relative position of the video file (0 - start of the film, 1 - end of the film)
* **CV_CAP_PROP_POS_AVI_RATIO** Relative position of the video file: 0 - start of the film, 1 - end of the film.
* **CV_CAP_PROP_FRAME_WIDTH** Width of the frames in the video stream
* **CV_CAP_PROP_FRAME_WIDTH** Width of the frames in the video stream.
* **CV_CAP_PROP_FRAME_HEIGHT** Height of the frames in the video stream
* **CV_CAP_PROP_FRAME_HEIGHT** Height of the frames in the video stream.
* **CV_CAP_PROP_FPS** Frame rate
* **CV_CAP_PROP_FPS** Frame rate.
* **CV_CAP_PROP_FOURCC** 4-character code of codec
* **CV_CAP_PROP_FOURCC** 4-character code of codec.
* **CV_CAP_PROP_FRAME_COUNT** Number of frames in the video file
* **CV_CAP_PROP_FRAME_COUNT** Number of frames in the video file.
* **CV_CAP_PROP_FORMAT** The format of the Mat objects returned by retrieve()
* **CV_CAP_PROP_FORMAT** Format of the Mat objects returned by ``retrieve()`` .
* **CV_CAP_PROP_MODE** A backend-specific value indicating the current capture mode
* **CV_CAP_PROP_MODE** Backend-specific value indicating the current capture mode.
* **CV_CAP_PROP_BRIGHTNESS** Brightness of the image (only for cameras)
* **CV_CAP_PROP_BRIGHTNESS** Brightness of the image (only for cameras).
* **CV_CAP_PROP_CONTRAST** Contrast of the image (only for cameras)
* **CV_CAP_PROP_CONTRAST** Contrast of the image (only for cameras).
* **CV_CAP_PROP_SATURATION** Saturation of the image (only for cameras)
* **CV_CAP_PROP_SATURATION** Saturation of the image (only for cameras).
* **CV_CAP_PROP_HUE** Hue of the image (only for cameras)
* **CV_CAP_PROP_HUE** Hue of the image (only for cameras).
* **CV_CAP_PROP_GAIN** Gain of the image (only for cameras)
* **CV_CAP_PROP_GAIN** Gain of the image (only for cameras).
* **CV_CAP_PROP_EXPOSURE** Exposure (only for cameras)
* **CV_CAP_PROP_EXPOSURE** Exposure (only for cameras).
* **CV_CAP_PROP_CONVERT_RGB** Boolean flags indicating whether images should be converted to RGB
* **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_RECTIFICATION** TOWRITE (note: only supported by DC1394 v 2.x backend currently)
:param value: value of the property.
:param value: Value of the property.
Sets a property in the VideoCapture backend.
.. index:: VideoWriter
......
......@@ -11,27 +11,27 @@ createTrackbar
------------------
.. c:function:: int createTrackbar( const string& trackbarname, const string& winname, int* value, int count, TrackbarCallback onChange CV_DEFAULT(0), void* userdata CV_DEFAULT(0))
Creates a trackbar and attaches it to the specified window
Creates a trackbar and attaches it to the specified window.
:param trackbarname: Name of the created trackbar.
:param winname: Name of the window which will be used as a parent of the created trackbar.
:param winname: Name of the window that will be used as a parent of the created trackbar.
:param value: The optional pointer to an integer variable, whose value will reflect the position of the slider. Upon creation, the slider position is defined by this variable.
:param value: Optional pointer to an integer variable whose value reflects the position of the slider. Upon creation, the slider position is defined by this variable.
:param count: The maximal position of the slider. The minimal position is always 0.
:param count: Maximal position of the slider. The minimal position is always 0.
:param onChange: Pointer to the function to be called every time the slider changes position. This function should be prototyped as ``void Foo(int,void*);`` , where the first parameter is the trackbar position and the second parameter is the user data (see the next parameter). If the callback is NULL pointer, then no callbacks is called, but only ``value`` is updated
:param onChange: Pointer to the function to be called every time the slider changes position. This function should be prototyped as ``void Foo(int,void*);`` , where the first parameter is the trackbar position and the second parameter is the user data (see the next parameter). If the callback is the NULL pointer, no callbacks are called, but only ``value`` is updated.
: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.
:param userdata: The 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 trackbar position and specifies a callback function ``onChange`` to be called on the trackbar position change. The created trackbar is displayed on the top of the given window.
\
\
**[Qt Backend Only]**
qt-specific details:
Qt-specific details:
* **winname** Name of the window which will be used as a parent for created trackbar. Can be NULL if the trackbar should be attached to the control panel.
* **winname** Name of the window that will be used as a parent for created trackbar. It can be NULL if the trackbar should be attached to the control panel.
The created trackbar is displayed at the bottom of the given window if
*winname*
......@@ -39,7 +39,7 @@ is correctly provided, or displayed on the control panel if
*winname*
is NULL.
By clicking on the label of each trackbar, it is possible to edit the trackbar's value 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.
.. index:: getTrackbarPos
......@@ -51,15 +51,15 @@ getTrackbarPos
:param trackbarname: Name of the trackbar.
:param winname: Name of the window which is the parent of the trackbar.
:param winname: Name of the window that is the parent of the trackbar.
The function returns the current position of the specified trackbar.
\
\
**[Qt Backend Only]**
qt-specific details:
Qt-specific details:
* **winname** Name of the window which is the parent of the trackbar. 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:: imshow
......@@ -69,13 +69,13 @@ imshow
----------
.. c:function:: void imshow( const string& winname, const Mat& image )
Displays the image in the specified window
Displays an image in the specified window.
:param winname: Name of the window.
:param image: Image to be shown.
The function ``imshow`` displays the image in the specified window. If the window was created with the ``CV_WINDOW_AUTOSIZE`` flag then the image is shown with its original size, otherwise the image is scaled to fit in the window. The function may scale the image, depending on its depth:
The function ``imshow`` displays an image in the specified window. If the window was created with the ``CV_WINDOW_AUTOSIZE`` flag, the image is shown with its original size. Otherwise, the image is scaled to fit the window. The function may scale the image, depending on its depth:
*
If the image is 8-bit unsigned, it is displayed as is.
......@@ -98,27 +98,27 @@ namedWindow
: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 the user can not change the window size manually.
: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.
The function ``namedWindow`` creates a window which 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.
\
\
**[Qt Backend Only]**
qt-specific details:
Qt-specific details:
* **flags** Flags of the window. Currently the supported flags are:
* **CV_WINDOW_NORMAL or CV_WINDOW_AUTOSIZE:** ``CV_WINDOW_NORMAL`` let the user resize the window, whereas ``CV_WINDOW_AUTOSIZE`` adjusts automatically the window's size to fit the displayed image (see :ref:`imshow` ), and the user can not 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 :ref:`imshow` ), and you cannot change the window size manually.
* **CV_WINDOW_FREERATIO or CV_WINDOW_KEEPRATIO:** ``CV_WINDOW_FREERATIO`` adjust the image without respect the its ration, whereas ``CV_WINDOW_KEEPRATIO`` keep the image's 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.
* **CV_GUI_NORMAL or CV_GUI_EXPANDED:** ``CV_GUI_NORMAL`` is the old way to draw the window without statusbar and toolbar, whereas ``CV_GUI_EXPANDED`` is the new enhance GUI.
* **CV_GUI_NORMAL or CV_GUI_EXPANDED:** ``CV_GUI_NORMAL`` is the old way to draw the window without statusbar and toolbar, whereas ``CV_GUI_EXPANDED`` is a new enhanced GUI.
This parameter is optional. The default flags set for a new window are ``CV_WINDOW_AUTOSIZE`` , ``CV_WINDOW_KEEPRATIO`` , and ``CV_GUI_EXPANDED`` .
However, if you want to modify the flags, you can combine them using OR operator, ie:
However, if you want to modify the flags, you can combine them using the OR operator, that is:
::
......@@ -138,17 +138,17 @@ setTrackbarPos
:param trackbarname: Name of the trackbar.
:param winname: Name of the window which is the parent of trackbar.
:param winname: Name of the window that is the parent of trackbar.
:param pos: The new position.
:param pos: New position.
The function sets the position of the specified trackbar in the specified window.
\
\
**[Qt Backend Only]**
qt-specific details:
Qt-specific details:
* **winname** Name of the window which is the parent of trackbar. 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
......@@ -160,14 +160,14 @@ waitKey
Waits for a pressed key.
: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
: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.
The function ``waitKey`` waits for key event infinitely (when
:math:`\texttt{delay}\leq 0` ) or for ``delay`` milliseconds, when it's positive. 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 some 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.
**Note 2:**
The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active.
* The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册