cvReleaseFileStorage( &fs );
return 0;
}
+
..
Please note that whatever method of accessing a map you are using, it is
The function finishes the currently written stream and starts the next stream. In the case of XML the file with multiple streams looks like this: ::
-<opencv_storage>
-<!-- stream #1 data -->
-</opencv_storage>
-<opencv_storage>
-<!-- stream #2 data -->
-</opencv_storage>
-...
-
-The a YAML file will look like this:
-%YAML:1.0
-# stream #1 data
-...
----
-# stream #2 data
+ <opencv_storage>
+ <!-- stream #1 data -->
+ </opencv_storage>
+ <opencv_storage>
+ <!-- stream #2 data -->
+ </opencv_storage>
+ ...
+
+The a YAML file will look like this: ::
+
+ %YAML:1.0
+ # stream #1 data
+ ...
+ ---
+ # stream #2 data
This is useful for concatenating files or for resuming the writing process.
:param pptr: Double pointer to the allocated buffer
-The function deallocates the buffer allocated with :ocv:func:`fastMalloc` . If NULL pointer is passed, the function does nothing. C version of the function clears the pointer *pptr to avoid problems with double memory deallocation.
+The function deallocates the buffer allocated with :ocv:func:`fastMalloc` . If NULL pointer is passed, the function does nothing. C version of the function clears the pointer ``*pptr`` to avoid problems with double memory deallocation.
format
The constructor.
-.. ocv:function:: BOWKMeansTrainer::BOWKMeansTrainer( int clusterCount, const TermCriteria& termcrit=TermCriteria(), int attempts=3, int flags=KMEANS_PP_CENTERS );
+.. ocv:function:: BOWKMeansTrainer::BOWKMeansTrainer( int clusterCount, const TermCriteria& termcrit=TermCriteria(), int attempts=3, int flags=KMEANS_PP_CENTERS )
See :ocv:func:`kmeans` function parameters.
break;
case CV_CAP_PROP_FRAME_HEIGHT:
height = cvRound(value);
+ break;
default:
return false;
}
The function ``cvLogPolar`` transforms the source image using the following transformation:
*
- Forward transformation (``CV_WARP_INVERSE_MAP``is not set):
+ Forward transformation (``CV_WARP_INVERSE_MAP`` is not set):
.. math::
:param adaptiveMethod: Adaptive thresholding algorithm to use, ``ADAPTIVE_THRESH_MEAN_C`` or ``ADAPTIVE_THRESH_GAUSSIAN_C`` . See the details below.
:param thresholdType: Thresholding type that must be either ``THRESH_BINARY`` or ``THRESH_BINARY_INV`` .
+
:param blockSize: Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.
:param C: Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.
:param dstCn: Number of channels in the destination image. If the parameter is 0, the number of the channels is derived automatically from ``src`` and ``code`` .
The function converts an input image from one color
-space to another. In case of transformation to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR).
-Note that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue component, the second byte will be Green and the third byte will be Red. The fourth, fifth and sixth bytes would then be the 2nd pixel (Blue then Green then Red) and so on.
+space to another. In case of a transformation to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR).
+Note that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on.
The conventional ranges for R, G, and B channel values are:
In case of linear transformations, the range does not matter.
But in case of a non-linear transformation, an input RGB image should be normalized to the proper value range to get the correct results, for example, for RGB
-:math:`\rightarrow` L*u*v* transformation. For example, if you have a 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will have the 0..255 value range, instead of 0..1 assumed by the function. So, before calling ``cvtColor`` , you need first to scale the image down: ::
+:math:`\rightarrow` L*u*v* transformation. For example, if you have a 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will have the 0..255 value range instead of 0..1 assumed by the function. So, before calling ``cvtColor`` , you need first to scale the image down: ::
img *= 1./255;
cvtColor(img, img, CV_BGR2Luv);
-If you use ``cvtColor`` with 8-bit images then conversion will have lost some information. For many applications this will not be noticeable but it is recommended to use 32-bit images in applications that need the full range of colors or that convert an image before an operation and then convert back.
+If you use ``cvtColor`` with 8-bit images, the conversion will have some information lost. For many applications, this will not be noticeable but it is recommended to use 32-bit images in applications that need the full range of colors or that convert an image before an operation and then convert back.
The function can do the following transformations:
\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}
- in the case of grayscale image and floating range
+ in case of a grayscale image and floating range
*
\texttt{src} ( \texttt{seed} .x, \texttt{seed} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seed} .x, \texttt{seed} .y)+ \texttt{upDiff}
- in the case of grayscale image and fixed range
+ in case of a grayscale image and fixed range
*
\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b
- in the case of color image and floating range
+ in case of a color image and floating range
*
\texttt{src} ( \texttt{seed} .x, \texttt{seed} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seed} .x, \texttt{seed} .y)_b+ \texttt{upDiff} _b
- in the case of color image and fixed range
+ in case of a color image and fixed range
where
:math:`src(x',y')` is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:
*
- Color/brightness of one of its neighbors that already belong to the connected component in case of floating range.
+ Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
*
- Color/brightness of the seed point in case of fixed range.
+ Color/brightness of the seed point in case of a fixed range.
Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on. Various modes of the function are demonstrated in the ``floodfill.cpp`` sample.
:param sum: Integral image as :math:`(W+1)\times (H+1)` , 32-bit integer or floating-point (32f or 64f).
- :param sqsum: Integral image for squared pixel values. It will be :math:`(W+1)\times (H+1)`, double-precision floating-point (64f) array.
+ :param sqsum: Integral image for squared pixel values. It is :math:`(W+1)\times (H+1)`, double-precision floating-point (64f) array.
- :param tilted: Integral for the image rotated by 45 degrees. It will be :math:`(W+1)\times (H+1)` array with the same data type as ``sum``.
+ :param tilted: Integral for the image rotated by 45 degrees. It is :math:`(W+1)\times (H+1)` array with the same data type as ``sum``.
:param sdepth: Desired depth of the integral and the tilted integral images, ``CV_32S``, ``CV_32F``, or ``CV_64F``.
-The functions calculate one or more integral images for the source image as following:
+The functions calculate one or more integral images for the source image as follows:
.. math::
\texttt{tilted} (X,Y) = \sum _{y<Y,abs(x-X+1) \leq Y-y-1} \texttt{image} (x,y)
-Using these integral images, you can calculate sum, mean and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:
+Using these integral images, you can calculate sa um, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example:
.. math::
.. ocv:cfunction:: double cvThreshold( const CvArr* src, CvArr* dst, double threshold, double maxValue, int thresholdType )
.. ocv:pyoldfunction:: cv.Threshold(src, dst, threshold, maxValue, thresholdType)-> None
- :param src: Source array (single-channel, 8-bit of 32-bit floating point)
+ :param src: Source array (single-channel, 8-bit of 32-bit floating point).
:param dst: Destination array of the same size and type as ``src`` .
Also, the special value ``THRESH_OTSU`` may be combined with
one of the above values. In this case, the function determines the optimal threshold
-value using Otsu's algorithm and uses it instead of the specified ``thresh`` .
+value using the Otsu's algorithm and uses it instead of the specified ``thresh`` .
The function returns the computed threshold value.
-Currently, Otsu's method is implemented only for 8-bit images.
+Currently, the Otsu's method is implemented only for 8-bit images.
.. image:: pics/threshold.png
* **GC_INIT_WITH_MASK** The function initializes the state using the provided mask. Note that ``GC_INIT_WITH_RECT`` and ``GC_INIT_WITH_MASK`` can be combined. Then, all the pixels outside of the ROI are automatically initialized with ``GC_BGD`` .
- * **GC_EVAL** The value means that algorithm should just resume.
+ * **GC_EVAL** The value means that the algorithm should just resume.
The function implements the `GrabCut image segmentation algorithm <http://en.wikipedia.org/wiki/GrabCut>`_.
-See the sample grabcut.cpp to learn how to use the function.
+See the sample ``grabcut.cpp`` to learn how to use the function.
-.. [Borgefors86] Borgefors, Gunilla, “Distance transformations in digital images”. Comput. Vision Graph. Image Process. 34 3, pp 344–371 (1986)
+.. [Borgefors86] Borgefors, Gunilla, *Distance transformations in digital images*. Comput. Vision Graph. Image Process. 34 3, pp 344–371 (1986)
-.. [Felzenszwalb04] Felzenszwalb, Pedro F. and Huttenlocher, Daniel P. “Distance Transforms of Sampled Functions”, TR2004-1963, TR2004-1963 (2004)
+.. [Felzenszwalb04] Felzenszwalb, Pedro F. and Huttenlocher, Daniel P. *Distance Transforms of Sampled Functions*, TR2004-1963, TR2004-1963 (2004)
-.. [Meyer92] Meyer, F. “Color image segmentation”, ICIP92, 1992
+.. [Meyer92] Meyer, F. *Color Image Segmentation*, ICIP92, 1992
-.. [Telea04] Alexandru Telea, “An Image Inpainting Technique Based on the Fast Marching Method”. Journal of Graphics, GPU, and Game Tools 9 1, pp 23-34 (2004)
+.. [Telea04] Alexandru Telea, *An Image Inpainting Technique Based on the Fast Marching Method*. Journal of Graphics, GPU, and Game Tools 9 1, pp 23-34 (2004)
The function supports multi-channel images. Each channel is processed independently.
.. seealso::
-:ocv:func:`accumulateSquare`,
-:ocv:func:`accumulateProduct`,
-:ocv:func:`accumulateWeighted`
+
+ :ocv:func:`accumulateSquare`,
+ :ocv:func:`accumulateProduct`,
+ :ocv:func:`accumulateWeighted`
The function supports multi-channel images. Each channel is processed independently.
.. seealso::
-:ocv:func:`accumulate`,
-:ocv:func:`accumulateSquare`,
-:ocv:func:`accumulateWeighted`
+
+ :ocv:func:`accumulate`,
+ :ocv:func:`accumulateSquare`,
+ :ocv:func:`accumulateWeighted`
The function supports multi-channel images. Each channel is processed independently.
.. seealso::
-:ocv:func:`accumulate`,
-:ocv:func:`accumulateSquare`,
-:ocv:func:`accumulateProduct`
\ No newline at end of file
+
+ :ocv:func:`accumulate`,
+ :ocv:func:`accumulateSquare`,
+ :ocv:func:`accumulateProduct`
Planar subdivision is the subdivision of a plane into a set of
non-overlapped regions (facets) that cover the whole plane. The above
-structure describes a subdivision built on a 2d point set, where the points
+structure describes a subdivision built on a 2D point set, where the points
are linked together and form a planar graph, which, together with a few
edges connecting the exterior subdivision points (namely, convex hull points)
with infinity, subdivides a plane into facets by its edges.
-For every subdivision there exists a dual subdivision in which facets and
-points (subdivision vertices) swap their roles, that is, a facet is
+For every subdivision, there is a dual subdivision in which facets and
+points (subdivision vertices) swap their roles. This means that a facet is
treated as a vertex (called a virtual point below) of the dual subdivision and
-the original subdivision vertices become facets. On the picture below
-original subdivision is marked with solid lines and dual subdivision
+the original subdivision vertices become facets. In the figure below, the
+original subdivision is marked with solid lines and dual subdivision -
with dotted lines.
.. image:: pics/subdiv.png
-OpenCV subdivides a plane into triangles using Delaunay's
+OpenCV subdivides a plane into triangles using the Delaunay's
algorithm. Subdivision is built iteratively starting from a dummy
triangle that includes all the subdivision points for sure. In this
-case the dual subdivision is a Voronoi diagram of the input 2d point set. The
-subdivisions can be used for the 3d piece-wise transformation of a plane,
+case, the dual subdivision is a Voronoi diagram of the input 2D point set. The
+subdivisions can be used for the 3D piece-wise transformation of a plane,
morphing, fast location of points on the plane, building special graphs
-(such as NNG,RNG) and so forth.
+(such as NNG,RNG), and so forth.
CvQuadEdge2D
------------
.. ocv:struct:: CvQuadEdge2D
-Quad-edge of planar subdivision.
+Quad-edge of a planar subdivision.
::
..
-Quad-edge is a basic element of subdivision containing four edges (e, eRot, reversed e and reversed eRot):
+Quad-edge is a basic element of a subdivision containing four edges (e, eRot, reversed e, and reversed eRot):
.. image:: pics/quadedge.png
.. ocv:struct:: CvSubdiv2DPoint
-Point of original or dual subdivision.
+Point of an original or dual subdivision.
::
..
* id
- This integer can be used to index auxillary data associated with each vertex of the planar subdivision
+ This integer can be used to index auxillary data associated with each vertex of the planar subdivision.
CalcSubdivVoronoi2D
-------------------
-Calculates the coordinates of Voronoi diagram cells.
+Calculates the coordinates of the Voronoi diagram cells.
.. ocv:cfunction:: void cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv )
.. ocv:pyoldfunction:: cv.CalcSubdivVoronoi2D(subdiv)-> None
- :param subdiv: Delaunay subdivision, in which all the points are already added
+ :param subdiv: Delaunay subdivision, in which all the points are already added.
The function calculates the coordinates
-of virtual points. All virtual points corresponding to some vertex of the
+of virtual points. All virtual points corresponding to a vertex of the
original subdivision form (when connected together) a boundary of the Voronoi
cell at that point.
ClearSubdivVoronoi2D
--------------------
+Removes all virtual points.
.. ocv:cfunction:: void cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv )
.. ocv:pyoldfunction:: cv.ClearSubdivVoronoi2D(subdiv)-> None
- Removes all virtual points.
-
- :param subdiv: Delaunay subdivision
+ :param subdiv: Delaunay subdivision.
The function removes all of the virtual points. It
is called internally in
:ocv:cfunc:`CalcSubdivVoronoi2D`
if the subdivision
-was modified after previous call to the function.
+was modified after the previous call to the function.
CreateSubdivDelaunay2D
----------------------
.. ocv:cfunction:: CvSubdiv2D* cvCreateSubdivDelaunay2D( CvRect rect, CvMemStorage* storage )
.. ocv:pyoldfunction:: cv.CreateSubdivDelaunay2D(rect, storage)-> emptyDelaunayTriangulation
- :param rect: Rectangle that includes all of the 2d points that are to be added to the subdivision
+ :param rect: Rectangle that includes all of the 2D points that are to be added to the subdivision.
- :param storage: Container for subdivision
+ :param storage: Container for the subdivision.
The function creates an empty Delaunay
-subdivision, where 2d points can be added using the function
+subdivision where 2D points can be added using the function
:ocv:cfunc:`SubdivDelaunay2DInsert`
. All of the points to be added must be within
-the specified rectangle, otherwise a runtime error will be raised.
+the specified rectangle, otherwise a runtime error is raised.
Note that the triangulation is a single large triangle that covers the given rectangle. Hence the three vertices of this triangle are outside the rectangle
``rect``
FindNearestPoint2D
------------------
-Finds the closest subdivision vertex to the given point.
+Finds the subdivision vertex closest to the given point.
.. ocv:cfunction:: CvSubdiv2DPoint* cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt )
.. ocv:pyoldfunction:: cv.FindNearestPoint2D(subdiv, pt)-> point
- :param subdiv: Delaunay or another subdivision
+ :param subdiv: Delaunay or another subdivision.
- :param pt: Input point
+ :param pt: Input point.
The function is another function that
locates the input point within the subdivision. It finds the subdivision vertex that
.. ocv:cfunction:: CvSubdiv2DPoint* cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge )
.. ocv:pyoldfunction:: cv.Subdiv2DEdgeDst(edge)-> point
- :param edge: Subdivision edge (not a quad-edge)
+ :param edge: Subdivision edge (not a quad-edge).
The function returns the edge destination. The
-returned pointer may be NULL if the edge is from dual subdivision and
+returned pointer may be NULL if the edge is from a dual subdivision and
the virtual point coordinates are not calculated yet. The virtual points
can be calculated using the function
:ocv:cfunc:`CalcSubdivVoronoi2D`.
.. ocv:cfunction:: CvSubdiv2DEdge cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, CvNextEdgeType type )
.. ocv:pyoldfunction:: cv.Subdiv2DGetEdge(edge, type)-> CvSubdiv2DEdge
- :param edge: Subdivision edge (not a quad-edge)
+ :param edge: Subdivision edge (not a quad-edge).
- :param type: Specifies which of the related edges to return, one of the following:
+ :param type: Parameter specifying which of the related edges to return. The following values are possible:
* **CV_NEXT_AROUND_ORG** next around the edge origin ( ``eOnext`` on the picture below if ``e`` is the input edge)
Subdiv2DNextEdge
----------------
-Returns next edge around the edge origin
+Returns next edge around the edge origin.
.. ocv:cfunction:: CvSubdiv2DEdge cvSubdiv2DNextEdge( CvSubdiv2DEdge edge )
.. ocv:pyoldfunction:: cv.Subdiv2DNextEdge(edge)-> CvSubdiv2DEdge
- :param edge: Subdivision edge (not a quad-edge)
+ :param edge: Subdivision edge (not a quad-edge).
The function returns the next edge around the edge origin:
``eOnext``
on the picture above if
``e``
-is the input edge)
+is the input edge).
Subdiv2DLocate
--------------
.. ocv:cfunction:: CvSubdiv2DPointLocation cvSubdiv2DLocate( CvSubdiv2D* subdiv, CvPoint2D32f pt, CvSubdiv2DEdge* edge, CvSubdiv2DPoint** vertex=NULL )
.. ocv:pyoldfunction:: cv.Subdiv2DLocate(subdiv, pt) -> (loc, where)
- :param subdiv: Delaunay or another subdivision
+ :param subdiv: Delaunay or another subdivision.
- :param pt: The point to locate
+ :param pt: Point to locate.
- :param edge: The output edge the point falls onto or right to
+ :param edge: Output edge the point falls onto or right to.
- :param vertex: Optional output vertex double pointer the input point coinsides with
+ :param vertex: Optional output vertex double pointer the input point coinsides with.
-The function locates the input point within the subdivision. There are 5 cases:
+The function locates the input point within the subdivision. There are five cases:
*
The point falls into some facet. The function returns
.. ocv:cfunction:: CvSubdiv2DEdge cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate )
.. ocv:pyoldfunction:: cv.Subdiv2DRotateEdge(edge, rotate)-> CvSubdiv2DEdge
- :param edge: Subdivision edge (not a quad-edge)
+ :param edge: Subdivision edge (not a quad-edge).
- :param rotate: Specifies which of the edges of the same quad-edge as the input one to return, one of the following:
+ :param rotate: Parameter specifying which of the edges of the same quad-edge as the input one to return. The following values are possible:
* **0** the input edge ( ``e`` on the picture below if ``e`` is the input edge)
.. ocv:cfunction:: CvSubdiv2DPoint* cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt)
.. ocv:pyoldfunction:: cv.SubdivDelaunay2DInsert(subdiv, pt)-> point
- :param subdiv: Delaunay subdivision created by the function :ocv:cfunc:`CreateSubdivDelaunay2D`
+ :param subdiv: Delaunay subdivision created by the function :ocv:cfunc:`CreateSubdivDelaunay2D`.
- :param pt: Inserted point
+ :param pt: Inserted point.
The function inserts a single point into a subdivision and modifies the subdivision topology appropriately. If a point with the same coordinates exists already, no new point is added. The function returns a pointer to the allocated point. No virtual point coordinates are calculated at this stage.
moments
-----------
-Calculates all of the moments up to the third order of a polygon or rasterized shape
+Calculates all of the moments up to the third order of a polygon or rasterized shape.
.. ocv:function:: Moments moments( InputArray array, bool binaryImage=false )
:param binaryImage: If it is true, all non-zero image pixels are treated as 1's. The parameter is used for images only.
- :param moments: The output moments
+ :param moments: Output moments.
-The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The results are returned in a structure ``Moments``, defined as: ::
+The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The results are returned in the structure ``Moments`` defined as: ::
class Moments
{
Moments( const CvMoments& moments );
operator CvMoments() const;
- ..
-
-
In case of a raster image, the spatial moments :math:`\texttt{Moments::m}_{ji}` are computed as:
.. math::
- \texttt{m} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot x^j \cdot y^i \right );
+ \texttt{m} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot x^j \cdot y^i \right )
-the central moments
+The central moments
:math:`\texttt{Moments::mu}_{ji}` are computed as:
.. math::
.. math::
- \bar{x} = \frac{\texttt{m}_{10}}{\texttt{m}_{00}} , \; \bar{y} = \frac{\texttt{m}_{01}}{\texttt{m}_{00}};
+ \bar{x} = \frac{\texttt{m}_{10}}{\texttt{m}_{00}} , \; \bar{y} = \frac{\texttt{m}_{01}}{\texttt{m}_{00}}
-and the normalized central moments
+The normalized central moments
:math:`\texttt{Moments::nu}_{ij}` are computed as:
.. math::
:math:`\texttt{nu}_{00}=1`
:math:`\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0` , hence the values are not stored.
-The moments of a contour are defined in the same way but computed using Green's formula
+The moments of a contour are defined in the same way but computed using the Green's formula
(see
http://en.wikipedia.org/wiki/Green_theorem
). So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour.
HuMoments
-------------
-Calculates the seven Hu invariants.
+Calculates seven Hu invariants.
.. ocv:function:: void HuMoments( const Moments& moments, double* hu )
:param moments: Input moments computed with :ocv:func:`moments` .
:param hu: Output Hu invariants.
-The function calculates the seven Hu invariants (introduced in [Hu62]_; see also
+The function calculates seven Hu invariants (introduced in [Hu62]_; see also
http://en.wikipedia.org/wiki/Image_moment) defined as:
.. math::
The function draws contour outlines in the image if
:math:`\texttt{thickness} \ge 0` or fills the area bounded by the contours if
-:math:`\texttt{thickness}<0` . Here is the example on how to retrieve connected components from the binary image and label them: ::
+:math:`\texttt{thickness}<0` . The example below shows how to retrieve connected components from the binary image and label them: ::
#include "cv.h"
#include "highgui.h"
.. ocv:cfunction:: CvSeq* cvApproxPoly( const void* curve, int headerSize, CvMemStorage* storage, int method, double epsilon, int recursive=0 )
- :param curve: Input vector of 2d point, stored in:
+ :param curve: Input vector of a 2D point stored in:
* ``std::vector`` or ``Mat`` (C++ interface)
- * ``Nx2`` numpy array (Python interface).
+ * ``Nx2`` numpy array (Python interface)
* ``CvSeq`` or `` ``CvMat`` (C interface)
- :param approxCurve: Result of the approximation. The type should match the type of the input curve. In the case of C interface the approximated curve is stored in the memory storage and pointer to it is returned.
+ :param approxCurve: Result of the approximation. The type should match the type of the input curve. In case of C interface the approximated curve is stored in the memory storage and pointer to it is returned.
:param epsilon: Parameter specifying the approximation accuracy. This is the maximum distance between the original curve and its approximation.
:param headerSize: Header size of the approximated curve. Normally, ``sizeof(CvContour)`` is used.
- :param storage: Memory storage where the approximated curve will be stored.
+ :param storage: Memory storage where the approximated curve is stored.
- :param method: The contour approximation algorithm. Only ``CV_POLY_APPROX_DP`` is supported.
+ :param method: Contour approximation algorithm. Only ``CV_POLY_APPROX_DP`` is supported.
- :param recursive: The recursion flag. If it is non-zero and ``curve`` is ``CvSeq*``, the function ``cvApproxPoly`` will approximate all the contours accessible from ``curve`` by ``h_next`` and ``v_next`` links.
+ :param recursive: Recursion flag. If it is non-zero and ``curve`` is ``CvSeq*``, the function ``cvApproxPoly`` approximates all the contours accessible from ``curve`` by ``h_next`` and ``v_next`` links.
-The functions ``approxPolyDP`` approximate a curve or a polygon with another curve/polygon with less vertices, so that the distance between them is less or equal to the specified precision. It uses the Douglas-Peucker algorithm
+The functions ``approxPolyDP`` approximate a curve or a polygon with another curve/polygon with less vertices so that the distance between them is less or equal to the specified precision. It uses the Douglas-Peucker algorithm
http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
-See http://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/contours.cpp on how to use the function.
+See http://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/contours.cpp for the function usage model.
ApproxChains
.. ocv:pyoldfunction:: cv.ApproxChains(chain, storage, method=CV_CHAIN_APPROX_SIMPLE, parameter=0, minimalPerimeter=0, recursive=0)-> contours
- :param chain: Pointer to the approximated Freeman chain that can refer to other chains
+ :param chain: Pointer to the approximated Freeman chain that can refer to other chains.
- :param storage: Storage location for the resulting polylines
+ :param storage: Storage location for the resulting polylines.
- :param method: Approximation method (see the description of the function :ocv:cfunc:`FindContours` )
+ :param method: Approximation method (see the description of the function :ocv:cfunc:`FindContours` ).
- :param parameter: Method parameter (not used now)
+ :param parameter: Method parameter (not used now).
- :param minimalPerimeter: Approximates only those contours whose perimeters are not less than ``minimal_perimeter`` . Other chains are removed from the resulting structure
+ :param minimalPerimeter: Approximates only those contours whose perimeters are not less than ``minimal_perimeter`` . Other chains are removed from the resulting structure.
- :param recursive: Recursion flag. If it is non-zero, the function approximates all chains that can be obtained to from ``chain`` by using the ``h_next`` or ``v_next`` links. Otherwise, the single input chain is approximated.
+ :param recursive: Recursion flag. If it is non-zero, the function approximates all chains that can be obtained from ``chain`` by using the ``h_next`` or ``v_next`` links. Otherwise, the single input chain is approximated.
-This is a stand-alone contour approximation routine, not represented in the new interface. When :ocv:cfunc:`FindContours` retrieves contours as Freeman chains, it calls to the function to get approximated contours, represented as polygons.
+This is a standalone contour approximation routine, not represented in the new interface. When :ocv:cfunc:`FindContours` retrieves contours as Freeman chains, it calls the function to get approximated contours, represented as polygons.
arcLength
.. ocv:cfunction:: double cvContourArea( const CvArr* contour, CvSlice slice=CV_WHOLE_SEQ )
.. ocv:pyoldfunction:: cv.ContourArea(contour, slice=CV_WHOLE_SEQ)-> double
- :param contour: Input vector of 2d points (contour vertices), stored in ``std::vector`` or ``Mat``.
- :param orientation: Oriented area flag. If it is true, the function returns a signed area value, depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can determine orientation of a contour by taking sign of the area. By default the parameter is ``false``, which means that the absolute value is returned.
+ :param contour: Input vector of 2D points (contour vertices), stored in ``std::vector`` or ``Mat``.
+ :param orientation: Oriented area flag. If it is true, the function returns a signed area value, depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can determine orientation of a contour by taking the sign of an area. By default, the parameter is ``false``, which means that the absolute value is returned.
The function computes a contour area. Similarly to
:ocv:func:`moments` , the area is computed using the Green formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using
:ocv:func:`drawContours` or
:ocv:func:`fillPoly` , can be different.
-Here is a short example: ::
+
+Example: ::
vector<Point> contour;
contour.push_back(Point2f(0, 0));
:param points: Input 2D point set, stored in ``std::vector`` or ``Mat``.
- :param hull: Output convex hull. It is either an integer vector of indices or vector of points. In the first case the ``hull`` elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case ``hull`` elements will be the convex hull points themselves.
+ :param hull: Output convex hull. It is either an integer vector of indices or vector of points. In the first case, the ``hull`` elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case, ``hull`` elements aree the convex hull points themselves.
- :param storage: The output memory storage in the old API (``cvConvexHull2`` returns a sequence containing the convex hull points or their indices).
+ :param storage: Output memory storage in the old API (``cvConvexHull2`` returns a sequence containing the convex hull points or their indices).
- :param clockwise: Orientation flag. If true, the output convex hull will be oriented clockwise. Otherwise, it will be oriented counter-clockwise. The usual screen coordinate system is assumed where the origin is at the top-left corner, x axis is oriented to the right, and y axis is oriented downwards.
+ :param clockwise: Orientation flag. If it is true, the output convex hull is oriented clockwise. Otherwise, it is oriented counter-clockwise. The usual screen coordinate system is assumed so that the origin is at the top-left corner, x axis is oriented to the right, and y axis is oriented downwards.
:param orientation: Convex hull orientation parameter in the old API, ``CV_CLOCKWISE`` or ``CV_COUNTERCLOCKWISE``.
- :param returnPoints: Operation flag. In the case of matrix, when the flag is true, the function will return convex hull points, otherwise it will return indices of the convex hull points. When the output array is ``std::vector``, the flag is ignored, and the output depends on the type of the vector - ``std::vector<int>`` implies ``returnPoints=true``, ``std::vector<Point>`` implies ``returnPoints=false``.
+ :param returnPoints: Operation flag. In case of a matrix, when the flag is true, the function returns convex hull points. Otherwise, it returns indices of the convex hull points. When the output array is ``std::vector``, the flag is ignored, and the output depends on the type of the vector: ``std::vector<int>`` implies ``returnPoints=true``, ``std::vector<Point>`` implies ``returnPoints=false``.
The functions find the convex hull of a 2D point set using the Sklansky's algorithm
[Sklansky82]_
.. ocv:pyoldfunction:: cv.ConvexityDefects(contour, convexhull, storage)-> convexityDefects
- :param contour: Input contour
+ :param contour: Input contour.
- :param convexhull: Convex hull obtained using :ocv:cfunc:`ConvexHull2` that should contain pointers or indices to the contour points, not the hull points themselves (the ``returnPoints`` parameter in :ocv:cfunc:`ConvexHull2` should be 0)
+ :param convexhull: Convex hull obtained using :ocv:cfunc:`ConvexHull2` that should contain pointers or indices to the contour points, not the hull points themselves (the ``returnPoints`` parameter in :ocv:cfunc:`ConvexHull2` should be zero).
- :param storage: Container for the output sequence of convexity defects. If it is NULL, the contour or hull (in that order) storage is used
+ :param storage: Container for the output sequence of convexity defects. If it is NULL, the contour or hull (in that order) storage is used.
The function finds all convexity defects of the input contour and returns a sequence of the ``CvConvexityDefect`` structures, where ``CvConvexityDetect`` is defined as: ::
float depth; // distance between the farthest point and the convex hull
};
-Here is the picture displaying convexity defects of a hand contour:
+The figure below displays convexity defects of a hand contour:
.. image:: pics/defects.png
.. ocv:cfunction:: CvBox2D cvFitEllipse2( const CvArr* points )
.. ocv:pyoldfunction:: cv.FitEllipse2(points)-> Box2D
- :param points: The input 2D point set, stored in:
+ :param points: Input 2D point set, stored in:
- * ``std::vector<>`` or ``Mat`` (C++ interface).
+ * ``std::vector<>`` or ``Mat`` (C++ interface)
* ``CvSeq*`` or ``CvMat*`` (C interface)
* Nx2 numpy array (Python interface)
-The function calculates the ellipse that fits (in least-squares sense) a set of 2D points best of all. It returns the rotated rectangle in which the ellipse is inscribed. The algorithm [Fitzgibbon95]_ is used.
+The function calculates the ellipse that fits (in a least-squares sense) a set of 2D points best of all. It returns the rotated rectangle in which the ellipse is inscribed. The algorithm [Fitzgibbon95]_ is used.
fitLine
-----------
:param points: Input vector of 2D or 3D points, stored in ``std::vector<>`` or ``Mat``.
- :param line: Output line parameters. In case of 2D fitting it should be a vector of 4 elements (like ``Vec4f``) - ``(vx, vy, x0, y0)``, where ``(vx, vy)`` is a normalized vector collinear to the line and ``(x0, y0)`` is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like ``Vec6f``) - ``(vx, vy, vz, x0, y0, z0)``, where ``(vx, vy, vz)`` is a normalized vector collinear to the line and ``(x0, y0, z0)`` is a point on the line.
+ :param line: Output line parameters. In case of 2D fitting, it should be a vector of 4 elements (like ``Vec4f``) - ``(vx, vy, x0, y0)``, where ``(vx, vy)`` is a normalized vector collinear to the line and ``(x0, y0)`` is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like ``Vec6f``) - ``(vx, vy, vz, x0, y0, z0)``, where ``(vx, vy, vz)`` is a normalized vector collinear to the line and ``(x0, y0, z0)`` is a point on the line.
- :param distType: Distance used by the M-estimator (see the discussion).
+ :param distType: Distance used by the M-estimator (see the discussion below).
:param param: Numerical parameter ( ``C`` ) for some types of distances. If it is 0, an optimal value is chosen.
:math:`\sum_i \rho(r_i)` where
:math:`r_i` is a distance between the
:math:`i^{th}` point, the line and
-:math:`\rho(r)` is a distance function, one of:
+:math:`\rho(r)` is a distance function, one of the following:
* distType=CV\_DIST\_L2
.. ocv:cfunction:: int cvCheckContourConvexity( const CvArr* contour )
.. ocv:pyoldfunction:: cv.CheckContourConvexity(contour)-> int
- :param contour: The input vector of 2D points, stored in:
+ :param contour: Input vector of 2D points, stored in:
- * ``std::vector<>`` or ``Mat`` (C++ interface).
+ * ``std::vector<>`` or ``Mat`` (C++ interface)
* ``CvSeq*`` or ``CvMat*`` (C interface)
.. ocv:pyoldfunction:: cv.MinAreaRect2(points, storage=None)-> CvBox2D
- :param points: The input vector of 2D points, stored in:
+ :param points: Input vector of 2D points, stored in:
- * ``std::vector<>`` or ``Mat`` (C++ interface).
+ * ``std::vector<>`` or ``Mat`` (C++ interface)
* ``CvSeq*`` or ``CvMat*`` (C interface)
.. ocv:pyoldfunction:: cv.MinEnclosingCircle(points)-> (int, center, radius)
- :param points: The input vector of 2D points, stored in:
+ :param points: Input vector of 2D points, stored in:
- * ``std::vector<>`` or ``Mat`` (C++ interface).
+ * ``std::vector<>`` or ``Mat`` (C++ interface)
* ``CvSeq*`` or ``CvMat*`` (C interface)
.. ocv:cfunction:: double cvMatchShapes( const void* object1, const void* object2, int method, double parameter=0 )
.. ocv:pyoldfunction:: cv.MatchShapes(object1, object2, method, parameter=0)-> None
- :param object1: The first contour or grayscale image.
+ :param object1: First contour or grayscale image.
- :param object2: The second contour or grayscale image.
+ :param object2: Second contour or grayscale image.
:param method: Comparison method: ``CV_CONTOUR_MATCH_I1`` , \ ``CV_CONTOURS_MATCH_I2`` \
or ``CV_CONTOURS_MATCH_I3`` (see the details below).
is a signed distance between the point and the nearest contour
edge.
-Here is a sample output of the function where each image pixel is tested against the contour.
+See below a sample output of the function where each image pixel is tested against the contour.
.. image:: pics/pointpolygon.png
-.. [Fitzgibbon95] Andrew W. Fitzgibbon, R.B.Fisher. A Buyer\92s Guide to Conic Fitting. Proc.5th British Machine Vision Conference, Birmingham, pp. 513-522, 1995.
+.. [Fitzgibbon95] Andrew W. Fitzgibbon, R.B.Fisher. *A Buyer\92s Guide to Conic Fitting*. Proc.5th British Machine Vision Conference, Birmingham, pp. 513-522, 1995.
-.. [Hu62] M. Hu. Visual Pattern Recognition by Moment Invariants, IRE Transactions on Information Theory, 8:2, pp. 179-187, 1962.
+.. [Hu62] M. Hu. *Visual Pattern Recognition by Moment Invariants*, IRE Transactions on Information Theory, 8:2, pp. 179-187, 1962.
-.. [Sklansky82] Sklansky, J., \93Finding the Convex Hull of a Simple Polygon\94. PRL 1 $number, pp 79-83 (1982)
+.. [Sklansky82] Sklansky, J., *Finding the Convex Hull of a Simple Polygon*. PRL 1 $number, pp 79-83 (1982)
-.. [Suzuki85] Suzuki, S. and Abe, K., \93Topological Structural Analysis of Digitized Binary Images by Border Following\94. CVGIP 30 1, pp 32-46 (1985)
+.. [Suzuki85] Suzuki, S. and Abe, K., *Topological Structural Analysis of Digitized Binary Images by Border Following*. CVGIP 30 1, pp 32-46 (1985)
-.. [TehChin89] Teh, C.H. and Chin, R.T., \93On the Detection of Dominant Points on Digital Curve\94. PAMI 11 8, pp 859-872 (1989)
+.. [TehChin89] Teh, C.H. and Chin, R.T., *On the Detection of Dominant Points on Digital Curve*. PAMI 11 8, pp 859-872 (1989)
------------------
Reads the data set from a ``.csv``-like ``filename`` file and stores all read values in a matrix.
-.. ocv:function:: int CvMLData::read_csv(const char* filename);
+.. ocv:function:: int CvMLData::read_csv(const char* filename)
:param filename: The input file name
-----------------------
Returns a pointer to the matrix of response values
-.. ocv:function:: const CvMat* CvMLData::get_responses();
+.. ocv:function:: const CvMat* CvMLData::get_responses()
The method returns a pointer to the matrix of response values or throws an exception if the data has not been loaded from the file yet.
--------------------------
Specifies index of response column in the data matrix
-.. ocv:function:: void CvMLData::set_response_idx( int idx );
+.. ocv:function:: void CvMLData::set_response_idx( int idx )
The method sets the index of a response column in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) or throws an exception if the data has not been loaded from the file yet.
------------------------------
Divides the read data set into two disjoint training and test subsets.
-.. ocv:function:: void CvMLData::set_train_test_split( const CvTrainTestSplit * spl );
+.. ocv:function:: void CvMLData::set_train_test_split( const CvTrainTestSplit * spl )
This method sets parameters for such a split using ``spl`` (see :ocv:class:`CvTrainTestSplit`) or throws an exception if the data has not been loaded from the file yet.
--------------------------------
Mixes the indices of training and test samples
-.. ocv:function:: void CvMLData::mix_train_and_test_idx();
+.. ocv:function:: void CvMLData::mix_train_and_test_idx()
The method shuffles the indices of training and test samples preserving sizes of training and test subsets if the data split is set by :ocv:func:`CvMLData::get_values`. If the data has not been loaded from the file yet, an exception is thrown.
---------------------
Returns the indices of the active variables in the data matrix
-.. ocv:function:: const CvMat* CvMLData::get_var_idx();
+.. ocv:function:: const CvMat* CvMLData::get_var_idx()
The method returns the indices of variables (columns) used in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`).
------------------------
Enables or disables particular variable in the loaded data
-.. ocv:function:: void CvMLData::chahge_var_idx( int vi, bool state );
+.. ocv:function:: void CvMLData::chahge_var_idx( int vi, bool state )
By default, after reading the data set all variables in the ``values`` matrix (see :ocv:func:`CvMLData::get_values`) are used. But you may want to use only a subset of variables and include/exclude (depending on ``state`` value) a variable with the ``vi`` index from the used subset. If the data has not been loaded from the file yet, an exception is thrown.
-----------------------
Returns a matrix of the variable types.
-.. ocv:function:: const CvMat* CvMLData::get_var_types();
+.. ocv:function:: const CvMat* CvMLData::get_var_types()
The function returns a single-row matrix of the type ``CV_8UC1``, where each element is set to either ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``. The number of columns is equal to the number of variables. If data has not been loaded from file yet an exception is thrown.
-----------------------
Sets the variables types in the loaded data.
-.. ocv:function:: void CvMLData::set_var_types( const char* str );
+.. ocv:function:: void CvMLData::set_var_types( const char* str )
In the string, a variable type is followed by a list of variables indices. For example: ``"ord[0-17],cat[18]"``, ``"ord[0,2,4,10-12], cat[1,3,5-9,13,14]"``, ``"cat"`` (all variables are categorical), ``"ord"`` (all variables are ordered).
-------------------------
Changes type of the specified variable
-.. ocv:function:: void CvMLData::change_var_type( int var_idx, int type);
+.. ocv:function:: void CvMLData::change_var_type( int var_idx, int type)
The method changes type of variable with index ``var_idx`` from existing type to ``type`` ( ``CV_VAR_ORDERED`` or ``CV_VAR_CATEGORICAL``).
-----------------------
Sets the delimiter in the file used to separate input numbers
-.. ocv:function:: void CvMLData::set_delimiter( char ch );
+.. ocv:function:: void CvMLData::set_delimiter( char ch )
The method sets the delimiter for variables in a file. For example: ``','`` (default), ``';'``, ``' '`` (space), or other characters. The floating-point separator ``'.'`` is not allowed.
---------------------
Sets the character used to specify missing values
-.. ocv:function:: void CvMLData::set_miss_ch( char ch );
+.. ocv:function:: void CvMLData::set_miss_ch( char ch )
The method sets the character used to specify missing values. For example: ``'?'`` (default), ``'-'``. The floating-point separator ``'.'`` is not allowed.