cleaned RST formatting a bit
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3,136 +3,73 @@ Clustering
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
|
||||
.. index:: kmeans
|
||||
|
||||
|
||||
cv::kmeans
|
||||
----------
|
||||
|
||||
`id=0.0672046481842 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/kmeans>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: double kmeans( const Mat\& samples, int clusterCount, Mat\& labels, TermCriteria termcrit, int attempts, int flags, Mat* centers )
|
||||
|
||||
Finds the centers of clusters and groups the input samples around the clusters.
|
||||
|
||||
:param samples: Floating-point matrix of input samples, one row per sample
|
||||
|
||||
:param clusterCount: The number of clusters to split the set by
|
||||
|
||||
:param labels: The input/output integer array that will store the cluster indices for every sample
|
||||
|
||||
:param termcrit: Specifies maximum number of iterations and/or accuracy (distance the centers can move by between subsequent iterations)
|
||||
|
||||
:param attempts: How many times the algorithm is executed using different initial labelings. The algorithm returns the labels that yield the best compactness (see the last function parameter)
|
||||
|
||||
:param flags: It can take the following values:
|
||||
|
||||
* **KMEANS_RANDOM_CENTERS** Random initial centers are selected in each attempt
|
||||
|
||||
* **KMEANS_PP_CENTERS** Use kmeans++ center initialization by Arthur and Vassilvitskii
|
||||
|
||||
|
||||
:param samples: Floating-point matrix of input samples, one row per sample
|
||||
|
||||
|
||||
:param clusterCount: The number of clusters to split the set by
|
||||
|
||||
|
||||
:param labels: The input/output integer array that will store the cluster indices for every sample
|
||||
|
||||
|
||||
:param termcrit: Specifies maximum number of iterations and/or accuracy (distance the centers can move by between subsequent iterations)
|
||||
|
||||
|
||||
:param attempts: How many times the algorithm is executed using different initial labelings. The algorithm returns the labels that yield the best compactness (see the last function parameter)
|
||||
|
||||
|
||||
:param flags: It can take the following values:
|
||||
|
||||
* **KMEANS_RANDOM_CENTERS** Random initial centers are selected in each attempt
|
||||
|
||||
* **KMEANS_PP_CENTERS** Use kmeans++ center initialization by Arthur and Vassilvitskii
|
||||
|
||||
* **KMEANS_USE_INITIAL_LABELS** During the first (and possibly the only) attempt, the
|
||||
function uses the user-supplied labels instaed of computing them from the initial centers. For the second and further attempts, the function will use the random or semi-random centers (use one of ``KMEANS_*_CENTERS`` flag to specify the exact method)
|
||||
|
||||
|
||||
|
||||
|
||||
:param centers: The output matrix of the cluster centers, one row per each cluster center
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``kmeans``
|
||||
implements a k-means algorithm that finds the
|
||||
centers of
|
||||
``clusterCount``
|
||||
clusters and groups the input samples
|
||||
around the clusters. On output,
|
||||
:math:`\texttt{labels}_i`
|
||||
contains a 0-based cluster index for
|
||||
the sample stored in the
|
||||
:math:`i^{th}`
|
||||
row of the
|
||||
``samples``
|
||||
matrix.
|
||||
function uses the user-supplied labels instaed of computing them from the initial centers. For the second and further attempts, the function will use the random or semi-random centers (use one of ``KMEANS_*_CENTERS`` flag to specify the exact method)
|
||||
|
||||
:param centers: The output matrix of the cluster centers, one row per each cluster center
|
||||
|
||||
The function ``kmeans`` implements a k-means algorithm that finds the
|
||||
centers of ``clusterCount`` clusters and groups the input samples
|
||||
around the clusters. On output,
|
||||
:math:`\texttt{labels}_i` contains a 0-based cluster index for
|
||||
the sample stored in the
|
||||
:math:`i^{th}` row of the ``samples`` matrix.
|
||||
|
||||
The function returns the compactness measure, which is computed as
|
||||
|
||||
|
||||
.. math::
|
||||
|
||||
\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2
|
||||
|
||||
\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2
|
||||
|
||||
after every attempt; the best (minimum) value is chosen and the
|
||||
corresponding labels and the compactness value are returned by the function.
|
||||
Basically, the user can use only the core of the function, set the number of
|
||||
attempts to 1, initialize labels each time using some custom algorithm and pass them with
|
||||
(
|
||||
``flags``
|
||||
=
|
||||
``KMEANS_USE_INITIAL_LABELS``
|
||||
) flag, and then choose the best (most-compact) clustering.
|
||||
|
||||
( ``flags`` = ``KMEANS_USE_INITIAL_LABELS`` ) flag, and then choose the best (most-compact) clustering.
|
||||
|
||||
.. index:: partition
|
||||
|
||||
|
||||
cv::partition
|
||||
-------------
|
||||
|
||||
`id=0.0923567235062 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/partition>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: template<typename _Tp, class _EqPredicate> int
|
||||
|
||||
|
||||
|
||||
.. cfunction:: partition( const vector<_Tp>\& vec, vector<int>\& labels, _EqPredicate predicate=_EqPredicate())
|
||||
|
||||
Splits an element set into equivalency classes.
|
||||
|
||||
:param vec: The set of elements stored as a vector
|
||||
|
||||
:param labels: The output vector of labels; will contain as many elements as ``vec`` . Each label ``labels[i]`` is 0-based cluster index of ``vec[i]`` :param predicate: The equivalence predicate (i.e. pointer to a boolean function of two arguments or an instance of the class that has the method ``bool operator()(const _Tp& a, const _Tp& b)`` . The predicate returns true when the elements are certainly if the same class, and false if they may or may not be in the same class
|
||||
|
||||
|
||||
|
||||
|
||||
:param vec: The set of elements stored as a vector
|
||||
|
||||
|
||||
:param labels: The output vector of labels; will contain as many elements as ``vec`` . Each label ``labels[i]`` is 0-based cluster index of ``vec[i]``
|
||||
|
||||
|
||||
:param predicate: The equivalence predicate (i.e. pointer to a boolean function of two arguments or an instance of the class that has the method ``bool operator()(const _Tp& a, const _Tp& b)`` . The predicate returns true when the elements are certainly if the same class, and false if they may or may not be in the same class
|
||||
|
||||
|
||||
|
||||
The generic function
|
||||
``partition``
|
||||
implements an
|
||||
:math:`O(N^2)`
|
||||
algorithm for
|
||||
splitting a set of
|
||||
:math:`N`
|
||||
elements into one or more equivalency classes, as described in
|
||||
The generic function ``partition`` implements an
|
||||
:math:`O(N^2)` algorithm for
|
||||
splitting a set of
|
||||
:math:`N` elements into one or more equivalency classes, as described in
|
||||
http://en.wikipedia.org/wiki/Disjoint-set_data_structure
|
||||
. The function
|
||||
returns the number of equivalency classes.
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
******************
|
||||
Core Functionality
|
||||
******************
|
||||
****************************
|
||||
core. The Core Functionality
|
||||
****************************
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
@@ -3,442 +3,225 @@ Drawing Functions
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
Drawing functions work with matrices/images of arbitrary depth.
|
||||
The boundaries of the shapes can be rendered with antialiasing (implemented only for 8-bit images for now).
|
||||
All the functions include the parameter color that uses a rgb value (that may be constructed
|
||||
with
|
||||
``CV_RGB``
|
||||
or the :ref:`Scalar` constructor
|
||||
with ``CV_RGB`` or the :ref:`Scalar` constructor
|
||||
) for color
|
||||
images and brightness for grayscale images. For color images the order channel
|
||||
is normally
|
||||
is normally
|
||||
*Blue, Green, Red*
|
||||
, this is what
|
||||
:func:`imshow`
|
||||
,
|
||||
:func:`imread`
|
||||
and
|
||||
:func:`imwrite`
|
||||
expect
|
||||
, so if you form a color using
|
||||
:ref:`Scalar`
|
||||
constructor, it should look like:
|
||||
|
||||
, this is what
|
||||
:func:`imshow`,:func:`imread` and
|
||||
:func:`imwrite` expect
|
||||
, so if you form a color using
|
||||
:ref:`Scalar` constructor, it should look like:
|
||||
|
||||
.. math::
|
||||
|
||||
\texttt{Scalar} (blue \_ component, green \_ component, red \_ component[, alpha \_ component])
|
||||
\texttt{Scalar} (blue \_ component, green \_ component, red \_ component[, alpha \_ component])
|
||||
|
||||
If you are using your own image rendering and I/O functions, you can use any channel ordering, the drawing functions process each channel independently and do not depend on the channel order or even on the color space used. The whole image can be converted from BGR to RGB or to a different color space using
|
||||
:func:`cvtColor` .
|
||||
|
||||
If you are using your own image rendering and I/O functions, you can use any channel ordering, the drawing functions process each channel independently and do not depend on the channel order or even on the color space used. The whole image can be converted from BGR to RGB or to a different color space using
|
||||
:func:`cvtColor`
|
||||
.
|
||||
|
||||
If a drawn figure is partially or completely outside the image, the drawing functions clip it. Also, many drawing functions can handle pixel coordinates specified with sub-pixel accuracy, that is, the coordinates can be passed as fixed-point numbers, encoded as integers. The number of fractional bits is specified by the
|
||||
``shift``
|
||||
parameter and the real point coordinates are calculated as
|
||||
:math:`\texttt{Point}(x,y)\rightarrow\texttt{Point2f}(x*2^{-shift},y*2^{-shift})`
|
||||
. This feature is especially effective wehn rendering antialiased shapes.
|
||||
|
||||
Also, note that the functions do not support alpha-transparency - when the target image is 4-channnel, then the
|
||||
``color[3]``
|
||||
is simply copied to the repainted pixels. Thus, if you want to paint semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main image.
|
||||
If a drawn figure is partially or completely outside the image, the drawing functions clip it. Also, many drawing functions can handle pixel coordinates specified with sub-pixel accuracy, that is, the coordinates can be passed as fixed-point numbers, encoded as integers. The number of fractional bits is specified by the ``shift`` parameter and the real point coordinates are calculated as
|
||||
:math:`\texttt{Point}(x,y)\rightarrow\texttt{Point2f}(x*2^{-shift},y*2^{-shift})` . This feature is especially effective wehn rendering antialiased shapes.
|
||||
|
||||
Also, note that the functions do not support alpha-transparency - when the target image is 4-channnel, then the ``color[3]`` is simply copied to the repainted pixels. Thus, if you want to paint semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main image.
|
||||
|
||||
.. index:: circle
|
||||
|
||||
|
||||
cv::circle
|
||||
----------
|
||||
|
||||
`id=0.143685141364 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/circle>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void circle(Mat\& img, Point center, int radius, const Scalar\& color, int thickness=1, int lineType=8, int shift=0)
|
||||
|
||||
Draws a circle
|
||||
|
||||
:param img: Image where the circle is drawn
|
||||
|
||||
:param center: Center of the circle
|
||||
|
||||
:param radius: Radius of the circle
|
||||
|
||||
:param color: Circle color
|
||||
|
||||
|
||||
:param img: Image where the circle is drawn
|
||||
|
||||
|
||||
:param center: Center of the circle
|
||||
|
||||
|
||||
:param radius: Radius of the circle
|
||||
|
||||
|
||||
:param color: Circle color
|
||||
|
||||
|
||||
:param thickness: Thickness of the circle outline if positive; negative thickness means that a filled circle is to be drawn
|
||||
|
||||
|
||||
:param lineType: Type of the circle boundary, see :func:`line` description
|
||||
|
||||
|
||||
:param shift: Number of fractional bits in the center coordinates and radius value
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``circle``
|
||||
draws a simple or filled circle with a
|
||||
:param thickness: Thickness of the circle outline if positive; negative thickness means that a filled circle is to be drawn
|
||||
|
||||
:param lineType: Type of the circle boundary, see :func:`line` description
|
||||
|
||||
:param shift: Number of fractional bits in the center coordinates and radius value
|
||||
|
||||
The function ``circle`` draws a simple or filled circle with a
|
||||
given center and radius.
|
||||
|
||||
|
||||
.. index:: clipLine
|
||||
|
||||
|
||||
cv::clipLine
|
||||
------------
|
||||
|
||||
`id=0.715949286846 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/clipLine>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: bool clipLine(Size imgSize, Point\& pt1, Point\& pt2)
|
||||
|
||||
|
||||
|
||||
.. cfunction:: bool clipLine(Rect imgRect, Point\& pt1, Point\& pt2)
|
||||
|
||||
Clips the line against the image rectangle
|
||||
|
||||
:param imgSize: The image size; the image rectangle will be ``Rect(0, 0, imgSize.width, imgSize.height)`` :param imgSize: The image rectangle
|
||||
|
||||
:param pt1: The first line point
|
||||
|
||||
:param pt2: The second line point
|
||||
|
||||
|
||||
|
||||
:param imgSize: The image size; the image rectangle will be ``Rect(0, 0, imgSize.width, imgSize.height)``
|
||||
|
||||
|
||||
:param imgSize: The image rectangle
|
||||
|
||||
|
||||
:param pt1: The first line point
|
||||
|
||||
|
||||
:param pt2: The second line point
|
||||
|
||||
|
||||
|
||||
The functions
|
||||
``clipLine``
|
||||
calculate a part of the line
|
||||
The functions ``clipLine`` calculate a part of the line
|
||||
segment which is entirely within the specified rectangle.
|
||||
They return
|
||||
``false``
|
||||
if the line segment is completely outside the rectangle and
|
||||
``true``
|
||||
otherwise.
|
||||
|
||||
|
||||
They return ``false`` if the line segment is completely outside the rectangle and ``true`` otherwise.
|
||||
|
||||
.. index:: ellipse
|
||||
|
||||
|
||||
cv::ellipse
|
||||
-----------
|
||||
|
||||
`id=0.0631091216884 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/ellipse>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void ellipse(Mat\& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar\& color, int thickness=1, int lineType=8, int shift=0)
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void ellipse(Mat\& img, const RotatedRect\& box, const Scalar\& color, int thickness=1, int lineType=8)
|
||||
|
||||
Draws a simple or thick elliptic arc or an fills ellipse sector.
|
||||
|
||||
:param img: The image
|
||||
|
||||
:param center: Center of the ellipse
|
||||
|
||||
:param axes: Length of the ellipse axes
|
||||
|
||||
:param angle: The ellipse rotation angle in degrees
|
||||
|
||||
|
||||
:param img: The image
|
||||
|
||||
|
||||
:param center: Center of the ellipse
|
||||
|
||||
|
||||
:param axes: Length of the ellipse axes
|
||||
|
||||
|
||||
:param angle: The ellipse rotation angle in degrees
|
||||
|
||||
|
||||
:param startAngle: Starting angle of the elliptic arc in degrees
|
||||
|
||||
|
||||
:param endAngle: Ending angle of the elliptic arc in degrees
|
||||
|
||||
|
||||
:param box: Alternative ellipse representation via a :ref:`RotatedRect` , i.e. the function draws an ellipse inscribed in the rotated rectangle
|
||||
|
||||
|
||||
:param color: Ellipse color
|
||||
|
||||
|
||||
:param thickness: Thickness of the ellipse arc outline if positive, otherwise this indicates that a filled ellipse sector is to be drawn
|
||||
|
||||
|
||||
:param lineType: Type of the ellipse boundary, see :func:`line` description
|
||||
|
||||
|
||||
:param shift: Number of fractional bits in the center coordinates and axes' values
|
||||
|
||||
|
||||
|
||||
The functions
|
||||
``ellipse``
|
||||
with less parameters draw an ellipse outline, a filled ellipse, an elliptic
|
||||
arc or a filled ellipse sector.
|
||||
A piecewise-linear curve is used to approximate the elliptic arc boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
|
||||
:func:`ellipse2Poly`
|
||||
and then render it with
|
||||
:func:`polylines`
|
||||
or fill it with
|
||||
:func:`fillPoly`
|
||||
. If you use the first variant of the function and want to draw the whole ellipse, not an arc, pass
|
||||
``startAngle=0``
|
||||
and
|
||||
``endAngle=360``
|
||||
. The picture below
|
||||
:param startAngle: Starting angle of the elliptic arc in degrees
|
||||
|
||||
:param endAngle: Ending angle of the elliptic arc in degrees
|
||||
|
||||
:param box: Alternative ellipse representation via a :ref:`RotatedRect` , i.e. the function draws an ellipse inscribed in the rotated rectangle
|
||||
|
||||
:param color: Ellipse color
|
||||
|
||||
:param thickness: Thickness of the ellipse arc outline if positive, otherwise this indicates that a filled ellipse sector is to be drawn
|
||||
|
||||
:param lineType: Type of the ellipse boundary, see :func:`line` description
|
||||
|
||||
:param shift: Number of fractional bits in the center coordinates and axes' values
|
||||
|
||||
The functions ``ellipse`` with less parameters draw an ellipse outline, a filled ellipse, an elliptic
|
||||
arc or a filled ellipse sector.
|
||||
A piecewise-linear curve is used to approximate the elliptic arc boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
|
||||
:func:`ellipse2Poly` and then render it with
|
||||
:func:`polylines` or fill it with
|
||||
:func:`fillPoly` . If you use the first variant of the function and want to draw the whole ellipse, not an arc, pass ``startAngle=0`` and ``endAngle=360`` . The picture below
|
||||
explains the meaning of the parameters.
|
||||
|
||||
Parameters of Elliptic Arc
|
||||
|
||||
|
||||
|
||||
.. image:: ../../pics/ellipse.png
|
||||
|
||||
|
||||
|
||||
|
||||
.. index:: ellipse2Poly
|
||||
|
||||
|
||||
cv::ellipse2Poly
|
||||
----------------
|
||||
|
||||
`id=0.644340648167 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/ellipse2Poly>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void ellipse2Poly( Point center, Size axes, int angle, int startAngle, int endAngle, int delta, vector<Point>\& pts )
|
||||
|
||||
Approximates an elliptic arc with a polyline
|
||||
|
||||
:param center: Center of the arc
|
||||
|
||||
:param axes: Half-sizes of the arc. See :func:`ellipse` :param angle: Rotation angle of the ellipse in degrees. See :func:`ellipse` :param startAngle: Starting angle of the elliptic arc in degrees
|
||||
|
||||
:param endAngle: Ending angle of the elliptic arc in degrees
|
||||
|
||||
:param delta: Angle between the subsequent polyline vertices. It defines the approximation accuracy.
|
||||
|
||||
|
||||
:param center: Center of the arc
|
||||
|
||||
|
||||
:param axes: Half-sizes of the arc. See :func:`ellipse`
|
||||
|
||||
|
||||
:param angle: Rotation angle of the ellipse in degrees. See :func:`ellipse`
|
||||
|
||||
|
||||
:param startAngle: Starting angle of the elliptic arc in degrees
|
||||
|
||||
|
||||
:param endAngle: Ending angle of the elliptic arc in degrees
|
||||
|
||||
|
||||
:param delta: Angle between the subsequent polyline vertices. It defines the approximation accuracy.
|
||||
|
||||
|
||||
:param pts: The output vector of polyline vertices
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``ellipse2Poly``
|
||||
computes the vertices of a polyline that approximates the specified elliptic arc. It is used by
|
||||
:func:`ellipse`
|
||||
.
|
||||
:param pts: The output vector of polyline vertices
|
||||
|
||||
The function ``ellipse2Poly`` computes the vertices of a polyline that approximates the specified elliptic arc. It is used by
|
||||
:func:`ellipse` .
|
||||
|
||||
.. index:: fillConvexPoly
|
||||
|
||||
|
||||
cv::fillConvexPoly
|
||||
------------------
|
||||
|
||||
`id=0.345453533071 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/fillConvexPoly>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void fillConvexPoly(Mat\& img, const Point* pts, int npts, const Scalar\& color, int lineType=8, int shift=0)
|
||||
|
||||
Fills a convex polygon.
|
||||
|
||||
:param img: Image
|
||||
|
||||
:param pts: The polygon vertices
|
||||
|
||||
:param npts: The number of polygon vertices
|
||||
|
||||
:param color: Polygon color
|
||||
|
||||
|
||||
:param img: Image
|
||||
|
||||
|
||||
:param pts: The polygon vertices
|
||||
|
||||
|
||||
:param npts: The number of polygon vertices
|
||||
|
||||
|
||||
:param color: Polygon color
|
||||
|
||||
|
||||
:param lineType: Type of the polygon boundaries, see :func:`line` description
|
||||
|
||||
|
||||
:param shift: The number of fractional bits in the vertex coordinates
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``fillConvexPoly``
|
||||
draws a filled convex polygon.
|
||||
This function is much faster than the function
|
||||
``fillPoly``
|
||||
and can fill not only convex polygons but any monotonic polygon without self-intersections,
|
||||
:param lineType: Type of the polygon boundaries, see :func:`line` description
|
||||
|
||||
:param shift: The number of fractional bits in the vertex coordinates
|
||||
|
||||
The function ``fillConvexPoly`` draws a filled convex polygon.
|
||||
This function is much faster than the function ``fillPoly`` and can fill not only convex polygons but any monotonic polygon without self-intersections,
|
||||
i.e., a polygon whose contour intersects every horizontal line (scan
|
||||
line) twice at the most (though, its top-most and/or the bottom edge could be horizontal).
|
||||
|
||||
|
||||
.. index:: fillPoly
|
||||
|
||||
|
||||
cv::fillPoly
|
||||
------------
|
||||
|
||||
`id=0.00272984452496 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/fillPoly>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void fillPoly(Mat\& img, const Point** pts, const int* npts, int ncontours, const Scalar\& color, int lineType=8, int shift=0, Point offset=Point() )
|
||||
|
||||
Fills the area bounded by one or more polygons
|
||||
|
||||
:param img: Image
|
||||
|
||||
:param pts: Array of polygons, each represented as an array of points
|
||||
|
||||
:param npts: The array of polygon vertex counters
|
||||
|
||||
:param ncontours: The number of contours that bind the filled region
|
||||
|
||||
|
||||
:param img: Image
|
||||
|
||||
|
||||
:param pts: Array of polygons, each represented as an array of points
|
||||
|
||||
|
||||
:param npts: The array of polygon vertex counters
|
||||
|
||||
|
||||
:param ncontours: The number of contours that bind the filled region
|
||||
|
||||
|
||||
:param color: Polygon color
|
||||
|
||||
|
||||
:param lineType: Type of the polygon boundaries, see :func:`line` description
|
||||
|
||||
|
||||
:param shift: The number of fractional bits in the vertex coordinates
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``fillPoly``
|
||||
fills an area bounded by several
|
||||
:param color: Polygon color
|
||||
|
||||
:param lineType: Type of the polygon boundaries, see :func:`line` description
|
||||
|
||||
:param shift: The number of fractional bits in the vertex coordinates
|
||||
|
||||
The function ``fillPoly`` fills an area bounded by several
|
||||
polygonal contours. The function can fills complex areas, for example,
|
||||
areas with holes, contours with self-intersections (some of thier parts), and so forth.
|
||||
|
||||
|
||||
.. index:: getTextSize
|
||||
|
||||
|
||||
cv::getTextSize
|
||||
---------------
|
||||
|
||||
`id=0.364618843078 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/getTextSize>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: Size getTextSize(const string\& text, int fontFace, double fontScale, int thickness, int* baseLine)
|
||||
|
||||
Calculates the width and height of a text string.
|
||||
|
||||
:param text: The input text string
|
||||
|
||||
:param fontFace: The font to use; see :func:`putText` :param fontScale: The font scale; see :func:`putText` :param thickness: The thickness of lines used to render the text; see :func:`putText` :param baseLine: The output parameter - y-coordinate of the baseline relative to the bottom-most text point
|
||||
|
||||
The function ``getTextSize`` calculates and returns size of the box that contain the specified text.
|
||||
That is, the following code will render some text, the tight box surrounding it and the baseline: ::
|
||||
|
||||
|
||||
|
||||
:param text: The input text string
|
||||
|
||||
|
||||
:param fontFace: The font to use; see :func:`putText`
|
||||
|
||||
|
||||
:param fontScale: The font scale; see :func:`putText`
|
||||
|
||||
|
||||
:param thickness: The thickness of lines used to render the text; see :func:`putText`
|
||||
|
||||
|
||||
:param baseLine: The output parameter - y-coordinate of the baseline relative to the bottom-most text point
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``getTextSize``
|
||||
calculates and returns size of the box that contain the specified text.
|
||||
That is, the following code will render some text, the tight box surrounding it and the baseline:
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
// Use "y" to show that the baseLine is about
|
||||
string text = "Funny text inside the box";
|
||||
int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX;
|
||||
double fontScale = 2;
|
||||
int thickness = 3;
|
||||
|
||||
|
||||
Mat img(600, 800, CV_8UC3, Scalar::all(0));
|
||||
|
||||
|
||||
int baseline=0;
|
||||
Size textSize = getTextSize(text, fontFace,
|
||||
fontScale, thickness, &baseline);
|
||||
baseline += thickness;
|
||||
|
||||
|
||||
// center the text
|
||||
Point textOrg((img.cols - textSize.width)/2,
|
||||
(img.rows + textSize.height)/2);
|
||||
|
||||
|
||||
// draw the box
|
||||
rectangle(img, textOrg + Point(0, baseline),
|
||||
textOrg + Point(textSize.width, -textSize.height),
|
||||
@@ -447,86 +230,46 @@ That is, the following code will render some text, the tight box surrounding it
|
||||
line(img, textOrg + Point(0, thickness),
|
||||
textOrg + Point(textSize.width, thickness),
|
||||
Scalar(0, 0, 255));
|
||||
|
||||
|
||||
// then put the text itself
|
||||
putText(img, text, textOrg, fontFace, fontScale,
|
||||
Scalar::all(255), thickness, 8);
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
.. index:: line
|
||||
|
||||
|
||||
cv::line
|
||||
--------
|
||||
|
||||
`id=0.645160739861 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/line>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void line(Mat\& img, Point pt1, Point pt2, const Scalar\& color, int thickness=1, int lineType=8, int shift=0)
|
||||
|
||||
Draws a line segment connecting two points
|
||||
|
||||
:param img: The image
|
||||
|
||||
:param pt1: First point of the line segment
|
||||
|
||||
:param pt2: Second point of the line segment
|
||||
|
||||
:param color: Line color
|
||||
|
||||
:param thickness: Line thickness
|
||||
|
||||
|
||||
:param img: The image
|
||||
|
||||
|
||||
:param pt1: First point of the line segment
|
||||
|
||||
|
||||
:param pt2: Second point of the line segment
|
||||
|
||||
|
||||
:param color: Line color
|
||||
|
||||
|
||||
:param thickness: Line thickness
|
||||
|
||||
|
||||
:param lineType: Type of the line:
|
||||
|
||||
|
||||
|
||||
* **8** (or omitted) 8-connected line.
|
||||
|
||||
|
||||
* **4** 4-connected line.
|
||||
|
||||
|
||||
* **CV_AA** antialiased line.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:param shift: Number of fractional bits in the point coordinates
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``line``
|
||||
draws the line segment between
|
||||
``pt1``
|
||||
and
|
||||
``pt2``
|
||||
points in the image. The line is
|
||||
|
||||
* **8** (or omitted) 8-connected line.
|
||||
|
||||
* **4** 4-connected line.
|
||||
|
||||
* **CV_AA** antialiased line.
|
||||
|
||||
:param shift: Number of fractional bits in the point coordinates
|
||||
|
||||
The function ``line`` draws the line segment between ``pt1`` and ``pt2`` points in the image. The line is
|
||||
clipped by the image boundaries. For non-antialiased lines
|
||||
with integer coordinates the 8-connected or 4-connected Bresenham
|
||||
algorithm is used. Thick lines are drawn with rounding endings.
|
||||
Antialiased lines are drawn using Gaussian filtering. To specify
|
||||
the line color, the user may use the macro
|
||||
``CV_RGB(r, g, b)``
|
||||
.
|
||||
|
||||
|
||||
the line color, the user may use the macro ``CV_RGB(r, g, b)`` .
|
||||
|
||||
.. index:: LineIterator
|
||||
|
||||
@@ -534,22 +277,10 @@ the line color, the user may use the macro
|
||||
|
||||
LineIterator
|
||||
------------
|
||||
|
||||
`id=0.913176469223 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/LineIterator>`__
|
||||
|
||||
.. ctype:: LineIterator
|
||||
|
||||
Class for iterating pixels on a raster line ::
|
||||
|
||||
|
||||
Class for iterating pixels on a raster line
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
class LineIterator
|
||||
{
|
||||
public:
|
||||
@@ -566,205 +297,109 @@ Class for iterating pixels on a raster line
|
||||
// move the iterator to the next pixel
|
||||
LineIterator& operator ++();
|
||||
LineIterator operator ++(int);
|
||||
|
||||
|
||||
// internal state of the iterator
|
||||
uchar* ptr;
|
||||
int err, count;
|
||||
int minusDelta, plusDelta;
|
||||
int minusStep, plusStep;
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
The class
|
||||
``LineIterator``
|
||||
is used to get each pixel of a raster line. It can be treated as versatile implementation of the Bresenham algorithm, where you can stop at each pixel and do some extra processing, for example, grab pixel values along the line, or draw a line with some effect (e.g. with XOR operation).
|
||||
The class ``LineIterator`` is used to get each pixel of a raster line. It can be treated as versatile implementation of the Bresenham algorithm, where you can stop at each pixel and do some extra processing, for example, grab pixel values along the line, or draw a line with some effect (e.g. with XOR operation).
|
||||
|
||||
The number of pixels along the line is store in
|
||||
``LineIterator::count``
|
||||
.
|
||||
The number of pixels along the line is store in ``LineIterator::count`` . ::
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
// grabs pixels along the line (pt1, pt2)
|
||||
// from 8-bit 3-channel image to the buffer
|
||||
LineIterator it(img, pt1, pt2, 8);
|
||||
vector<Vec3b> buf(it.count);
|
||||
|
||||
|
||||
for(int i = 0; i < it.count; i++, ++it)
|
||||
buf[i] = *(const Vec3b)*it;
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
.. index:: rectangle
|
||||
|
||||
|
||||
cv::rectangle
|
||||
-------------
|
||||
|
||||
`id=0.494030339931 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/rectangle>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void rectangle(Mat\& img, Point pt1, Point pt2, const Scalar\& color, int thickness=1, int lineType=8, int shift=0)
|
||||
|
||||
Draws a simple, thick, or filled up-right rectangle.
|
||||
|
||||
:param img: Image
|
||||
|
||||
:param pt1: One of the rectangle's vertices
|
||||
|
||||
:param pt2: Opposite to ``pt1`` rectangle vertex
|
||||
|
||||
:param color: Rectangle color or brightness (grayscale image)
|
||||
|
||||
|
||||
:param img: Image
|
||||
|
||||
|
||||
:param pt1: One of the rectangle's vertices
|
||||
|
||||
|
||||
:param pt2: Opposite to ``pt1`` rectangle vertex
|
||||
|
||||
|
||||
:param color: Rectangle color or brightness (grayscale image)
|
||||
|
||||
|
||||
:param thickness: Thickness of lines that make up the rectangle. Negative values, e.g. ``CV_FILLED`` , mean that the function has to draw a filled rectangle.
|
||||
|
||||
|
||||
:param lineType: Type of the line, see :func:`line` description
|
||||
|
||||
|
||||
:param shift: Number of fractional bits in the point coordinates
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``rectangle``
|
||||
draws a rectangle outline or a filled rectangle, which two opposite corners are
|
||||
``pt1``
|
||||
and
|
||||
``pt2``
|
||||
.
|
||||
|
||||
:param thickness: Thickness of lines that make up the rectangle. Negative values, e.g. ``CV_FILLED`` , mean that the function has to draw a filled rectangle.
|
||||
|
||||
:param lineType: Type of the line, see :func:`line` description
|
||||
|
||||
:param shift: Number of fractional bits in the point coordinates
|
||||
|
||||
The function ``rectangle`` draws a rectangle outline or a filled rectangle, which two opposite corners are ``pt1`` and ``pt2`` .
|
||||
|
||||
.. index:: polylines
|
||||
|
||||
|
||||
cv::polylines
|
||||
-------------
|
||||
|
||||
`id=0.550422277453 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/polylines>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void polylines(Mat\& img, const Point** pts, const int* npts, int ncontours, bool isClosed, const Scalar\& color, int thickness=1, int lineType=8, int shift=0 )
|
||||
|
||||
Draws several polygonal curves
|
||||
|
||||
:param img: The image
|
||||
|
||||
:param pts: Array of polygonal curves
|
||||
|
||||
:param npts: Array of polygon vertex counters
|
||||
|
||||
:param ncontours: The number of curves
|
||||
|
||||
|
||||
:param img: The image
|
||||
|
||||
|
||||
:param pts: Array of polygonal curves
|
||||
|
||||
|
||||
:param npts: Array of polygon vertex counters
|
||||
|
||||
|
||||
:param ncontours: The number of curves
|
||||
|
||||
|
||||
:param isClosed: Indicates whether the drawn polylines are closed or not. If they are closed, the function draws the line from the last vertex of each curve to its first vertex
|
||||
|
||||
|
||||
:param color: Polyline color
|
||||
|
||||
|
||||
:param thickness: Thickness of the polyline edges
|
||||
|
||||
|
||||
:param lineType: Type of the line segments, see :func:`line` description
|
||||
|
||||
|
||||
:param shift: The number of fractional bits in the vertex coordinates
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``polylines``
|
||||
draws one or more polygonal curves.
|
||||
:param isClosed: Indicates whether the drawn polylines are closed or not. If they are closed, the function draws the line from the last vertex of each curve to its first vertex
|
||||
|
||||
:param color: Polyline color
|
||||
|
||||
:param thickness: Thickness of the polyline edges
|
||||
|
||||
:param lineType: Type of the line segments, see :func:`line` description
|
||||
|
||||
:param shift: The number of fractional bits in the vertex coordinates
|
||||
|
||||
The function ``polylines`` draws one or more polygonal curves.
|
||||
|
||||
.. index:: putText
|
||||
|
||||
|
||||
cv::putText
|
||||
-----------
|
||||
|
||||
`id=0.164290316532 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/putText>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void putText( Mat\& img, const string\& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
|
||||
|
||||
Draws a text string
|
||||
|
||||
:param img: The image
|
||||
|
||||
:param text: The text string to be drawn
|
||||
|
||||
:param org: The bottom-left corner of the text string in the image
|
||||
|
||||
:param fontFace: The font type, one of ``FONT_HERSHEY_SIMPLEX`` , ``FONT_HERSHEY_PLAIN`` , ``FONT_HERSHEY_DUPLEX`` , ``FONT_HERSHEY_COMPLEX`` , ``FONT_HERSHEY_TRIPLEX`` , ``FONT_HERSHEY_COMPLEX_SMALL`` , ``FONT_HERSHEY_SCRIPT_SIMPLEX`` or ``FONT_HERSHEY_SCRIPT_COMPLEX`` ,
|
||||
where each of the font id's can be combined with ``FONT_HERSHEY_ITALIC`` to get the slanted letters.
|
||||
|
||||
|
||||
:param img: The image
|
||||
|
||||
|
||||
:param text: The text string to be drawn
|
||||
|
||||
|
||||
:param org: The bottom-left corner of the text string in the image
|
||||
|
||||
|
||||
:param fontFace: The font type, one of ``FONT_HERSHEY_SIMPLEX`` , ``FONT_HERSHEY_PLAIN`` ,
|
||||
``FONT_HERSHEY_DUPLEX`` , ``FONT_HERSHEY_COMPLEX`` , ``FONT_HERSHEY_TRIPLEX`` ,
|
||||
``FONT_HERSHEY_COMPLEX_SMALL`` , ``FONT_HERSHEY_SCRIPT_SIMPLEX`` or ``FONT_HERSHEY_SCRIPT_COMPLEX`` ,
|
||||
where each of the font id's can be combined with ``FONT_HERSHEY_ITALIC`` to get the slanted letters.
|
||||
|
||||
|
||||
:param fontScale: The font scale factor that is multiplied by the font-specific base size
|
||||
|
||||
|
||||
:param color: The text color
|
||||
|
||||
|
||||
:param thickness: Thickness of the lines used to draw the text
|
||||
|
||||
|
||||
:param lineType: The line type; see ``line`` for details
|
||||
|
||||
|
||||
:param bottomLeftOrigin: When true, the image data origin is at the bottom-left corner, otherwise it's at the top-left corner
|
||||
|
||||
|
||||
|
||||
The function
|
||||
``putText``
|
||||
renders the specified text string in the image.
|
||||
:param fontScale: The font scale factor that is multiplied by the font-specific base size
|
||||
|
||||
:param color: The text color
|
||||
|
||||
:param thickness: Thickness of the lines used to draw the text
|
||||
|
||||
:param lineType: The line type; see ``line`` for details
|
||||
|
||||
:param bottomLeftOrigin: When true, the image data origin is at the bottom-left corner, otherwise it's at the top-left corner
|
||||
|
||||
The function ``putText`` renders the specified text string in the image.
|
||||
Symbols that can not be rendered using the specified font are
|
||||
replaced by question marks. See
|
||||
:func:`getTextSize`
|
||||
for a text rendering code example.
|
||||
replaced by question marks. See
|
||||
:func:`getTextSize` for a text rendering code example.
|
||||
|
||||
|
@@ -3,4 +3,3 @@ Dynamic Structures
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
|
@@ -30,20 +30,17 @@ The API Concepts
|
||||
*"cv"* namespace
|
||||
----------------
|
||||
|
||||
All the OpenCV classes and functions are placed into *"cv"* namespace. Therefore, to access this functionality from your code, use
|
||||
``cv::`` specifier or ``using namespace cv;`` directive:
|
||||
All the OpenCV classes and functions are placed into *"cv"* namespace. Therefore, to access this functionality from your code, use ``cv::`` specifier or ``using namespace cv;`` directive:
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
...
|
||||
cv::Mat H = cv::findHomography(points1, points2, CV_RANSAC, 5);
|
||||
...
|
||||
|
||||
or
|
||||
or ::
|
||||
|
||||
::
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
using namespace cv;
|
||||
...
|
||||
@@ -51,16 +48,13 @@ or
|
||||
...
|
||||
|
||||
It is probable that some of the current or future OpenCV external names conflict with STL
|
||||
or other libraries, in this case use explicit namespace specifiers to resolve the name conflicts:
|
||||
or other libraries, in this case use explicit namespace specifiers to resolve the name conflicts: ::
|
||||
|
||||
::
|
||||
|
||||
Mat a(100, 100, CV_32F);
|
||||
randu(a, Scalar::all(1), Scalar::all(std::rand()));
|
||||
cv::log(a, a);
|
||||
a /= std::log(2.);
|
||||
|
||||
|
||||
Automatic Memory Management
|
||||
---------------------------
|
||||
|
||||
@@ -68,13 +62,11 @@ OpenCV handles all the memory automatically.
|
||||
|
||||
First of all, ``std::vector``, ``Mat`` and other data structures used by the functions and methods have destructors that deallocate the underlying memory buffers when needed.
|
||||
|
||||
Secondly, in the case of ``Mat`` this *when needed* means that the destructors do not always deallocate the buffers, they take into account possible data sharing. That is, destructor decrements the reference counter, associated with the matrix data buffer, and the buffer is deallocated if and only if the reference counter reaches zero, that is, when no other structures refer to the same buffer. Similarly, when ``Mat`` instance is copied, not actual data is really copied; instead, the associated with it reference counter is incremented to memorize that there is another owner of the same data. There is also ``Mat::clone`` method that creates a full copy of the matrix data. Here is the example
|
||||
Secondly, in the case of ``Mat`` this *when needed* means that the destructors do not always deallocate the buffers, they take into account possible data sharing. That is, destructor decrements the reference counter, associated with the matrix data buffer, and the buffer is deallocated if and only if the reference counter reaches zero, that is, when no other structures refer to the same buffer. Similarly, when ``Mat`` instance is copied, not actual data is really copied; instead, the associated with it reference counter is incremented to memorize that there is another owner of the same data. There is also ``Mat::clone`` method that creates a full copy of the matrix data. Here is the example ::
|
||||
|
||||
::
|
||||
|
||||
// create a big 8Mb matrix
|
||||
Mat A(1000, 1000, CV_64F);
|
||||
|
||||
|
||||
// create another header for the same matrix;
|
||||
// this is instant operation, regardless of the matrix size.
|
||||
Mat B = A;
|
||||
@@ -82,7 +74,7 @@ Secondly, in the case of ``Mat`` this *when needed* means that the destructors d
|
||||
Mat C = B.row(3);
|
||||
// now create a separate copy of the matrix
|
||||
Mat D = B.clone();
|
||||
// copy the 5-th row of B to C, that is, copy the 5-th row of A
|
||||
// copy the 5-th row of B to C, that is, copy the 5-th row of A
|
||||
// to the 3-rd row of A.
|
||||
B.row(5).copyTo(C);
|
||||
// now let A and D share the data; after that the modified version
|
||||
@@ -91,8 +83,8 @@ Secondly, in the case of ``Mat`` this *when needed* means that the destructors d
|
||||
// now make B an empty matrix (which references no memory buffers),
|
||||
// but the modified version of A will still be referenced by C,
|
||||
// despite that C is just a single row of the original A
|
||||
B.release();
|
||||
|
||||
B.release();
|
||||
|
||||
// finally, make a full copy of C. In result, the big modified
|
||||
// matrix will be deallocated, since it's not referenced by anyone
|
||||
C = C.clone();
|
||||
@@ -107,7 +99,6 @@ one can use::
|
||||
|
||||
That is, ``Ptr<T> ptr`` incapsulates a pointer to ``T`` instance and a reference counter associated with the pointer. See ``Ptr`` description for details.
|
||||
|
||||
|
||||
.. todo::
|
||||
|
||||
Should we replace Ptr<> with the semi-standard shared_ptr<>?
|
||||
@@ -118,17 +109,17 @@ Automatic Allocation of the Output Data
|
||||
OpenCV does not only deallocate the memory automatically, it can also allocate memory for the output function parameters automatically most of the time. That is, if a function has one or more input arrays (``cv::Mat`` instances) and some output arrays, the output arrays automatically allocated or reallocated. The size and type of the output arrays are determined from the input arrays' size and type. If needed, the functions take extra parameters that help to figure out the output array properties.
|
||||
|
||||
Here is the example: ::
|
||||
|
||||
|
||||
#include "cv.h"
|
||||
#include "highgui.h"
|
||||
|
||||
|
||||
using namespace cv;
|
||||
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
VideoCapture cap(0);
|
||||
if(!cap.isOpened()) return -1;
|
||||
|
||||
|
||||
Mat frame, edges;
|
||||
namedWindow("edges",1);
|
||||
for(;;)
|
||||
@@ -150,15 +141,14 @@ The key component of this technology is the method ``Mat::create``. It takes the
|
||||
|
||||
Some notable exceptions from this scheme are ``cv::mixChannels``, ``cv::RNG::fill`` and a few others functions and methods. They are not able to allocate the output array, so the user has to do that in advance.
|
||||
|
||||
|
||||
Saturation Arithmetics
|
||||
----------------------
|
||||
|
||||
As computer vision library, OpenCV deals a lot with image pixels that are often encoded in a compact 8- or 16-bit per channel form and thus have a limited value range. Furthermore, certain operations on images, like color space conversions, brightness/contrast adjustments, sharpening, complex interpolation (bi-cubic, Lanczos) can produce values out of the available range. If we just store the lowest 8 (16) bit of the result, that will result in some visual artifacts and may affect the further image analysis. To solve this problem, we use so-called *saturation* arithmetics, e.g. to store ``r``, a result of some operation, to 8-bit image, we find the nearest value within 0..255 range:
|
||||
As computer vision library, OpenCV deals a lot with image pixels that are often encoded in a compact 8- or 16-bit per channel form and thus have a limited value range. Furthermore, certain operations on images, like color space conversions, brightness/contrast adjustments, sharpening, complex interpolation (bi-cubic, Lanczos) can produce values out of the available range. If we just store the lowest 8 (16) bit of the result, that will result in some visual artifacts and may affect the further image analysis. To solve this problem, we use so-called *saturation* arithmetics, e.g. to store ``r``, a result of some operation, to 8-bit image, we find the nearest value within 0..255 range:
|
||||
|
||||
.. math::
|
||||
|
||||
I(x,y)= \min ( \max (\textrm{round}(r), 0), 255)
|
||||
I(x,y)= \min ( \max (\textrm{round}(r), 0), 255)
|
||||
|
||||
The similar rules are applied to 8-bit signed and 16-bit signed and unsigned types. This semantics is used everywhere in the library. In C++ code it is done using ``saturate_cast<>`` functions that resembler the standard C++ cast operations. Here is the implementation of the above formula::
|
||||
|
||||
@@ -166,7 +156,6 @@ The similar rules are applied to 8-bit signed and 16-bit signed and unsigned typ
|
||||
|
||||
where ``cv::uchar`` is OpenCV's 8-bit unsigned integer type. In optimized SIMD code we use specialized instructions, like SSE2' ``paddusb``, ``packuswb`` etc. to achieve exactly the same behavior as in C++ code.
|
||||
|
||||
|
||||
Fixed Pixel Types. Limited Use of Templates
|
||||
-------------------------------------------
|
||||
|
||||
@@ -182,18 +171,17 @@ Because of this, there is a limited fixed set of primitive data types that the l
|
||||
* 32-bit floating-point number (float)
|
||||
* 64-bit floating-point number (double)
|
||||
* a tuple of several elements, where all elements have the same type (one of the above). Array, which elements are such tuples, are called multi-channel arrays, as opposite to the single-channel arrays, which elements are scalar values. The maximum possible number of channels is defined by ``CV_CN_MAX`` constant (which is not smaller than 32).
|
||||
|
||||
|
||||
.. todo::
|
||||
Need we extend the above list? Shouldn't we throw away 8-bit signed (schar)?
|
||||
|
||||
|
||||
For these basic types there is enumeration::
|
||||
|
||||
enum { CV_8U=0, CV_8S=1, CV_16U=2, CV_16S=3, CV_32S=4, CV_32F=5, CV_64F=6 };
|
||||
|
||||
|
||||
Multi-channel (``n``-channel) types can be specified using ``CV_8UC1`` ... ``CV_64FC4`` constants (for number of channels from 1 to 4), or using ``CV_8UC(n)`` ... ``CV_64FC(n)`` or ``CV_MAKETYPE(CV_8U, n)`` ... ``CV_MAKETYPE(CV_64F, n)`` macros when the number of channels is more than 4 or unknown at compile time.
|
||||
|
||||
.. note::
|
||||
``CV_32FC1 == CV_32F``, ``CV_32FC2 == CV_32FC(2) == CV_MAKETYPE(CV_32F, 2)`` and ``CV_MAKETYPE(depth, n) == ((x&7)<<3) + (n-1)``, that is, the type constant is formed from the ``depth``, taking the lowest 3 bits, and the number of channels minus 1, taking the next ``log2(CV_CN_MAX)`` bits.
|
||||
.. note:: ``CV_32FC1 == CV_32F``, ``CV_32FC2 == CV_32FC(2) == CV_MAKETYPE(CV_32F, 2)`` and ``CV_MAKETYPE(depth, n) == ((x&7)<<3) + (n-1)``, that is, the type constant is formed from the ``depth``, taking the lowest 3 bits, and the number of channels minus 1, taking the next ``log2(CV_CN_MAX)`` bits.
|
||||
|
||||
Here are some examples::
|
||||
|
||||
@@ -219,7 +207,6 @@ The subset of supported types for each functions has been defined from practical
|
||||
Should we include such a table into the standard?
|
||||
Should we specify minimum "must-have" set of supported formats for each functions?
|
||||
|
||||
|
||||
Error handling
|
||||
--------------
|
||||
|
||||
@@ -227,10 +214,8 @@ OpenCV uses exceptions to signal about the critical errors. When the input data
|
||||
|
||||
The exceptions can be instances of ``cv::Exception`` class or its derivatives. In its turn, ``cv::Exception`` is a derivative of std::exception, so it can be gracefully handled in the code using other standard C++ library components.
|
||||
|
||||
The exception is typically thrown using ``CV_Error(errcode, description)`` macro, or its printf-like ``CV_Error_(errcode, printf-spec, (printf-args))`` variant, or using ``CV_Assert(condition)`` macro that checks the condition and throws exception when it is not satisfied. For performance-critical code there is ``CV_DbgAssert(condition)`` that is only retained in Debug configuration. Thanks to the automatic memory management, all the intermediate buffers are automatically deallocated in the case of sudden error; user only needs to put a try statement to catch the exceptions, if needed:
|
||||
The exception is typically thrown using ``CV_Error(errcode, description)`` macro, or its printf-like ``CV_Error_(errcode, printf-spec, (printf-args))`` variant, or using ``CV_Assert(condition)`` macro that checks the condition and throws exception when it is not satisfied. For performance-critical code there is ``CV_DbgAssert(condition)`` that is only retained in Debug configuration. Thanks to the automatic memory management, all the intermediate buffers are automatically deallocated in the case of sudden error; user only needs to put a try statement to catch the exceptions, if needed: ::
|
||||
|
||||
::
|
||||
|
||||
try
|
||||
{
|
||||
... // call OpenCV
|
||||
@@ -241,7 +226,6 @@ The exception is typically thrown using ``CV_Error(errcode, description)`` macro
|
||||
std::cout << "exception caught: " << err_msg << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Multi-threading and reenterability
|
||||
----------------------------------
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -3,149 +3,69 @@ Utility and System Functions and Macros
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
|
||||
.. index:: alignPtr
|
||||
|
||||
|
||||
cv::alignPtr
|
||||
------------
|
||||
|
||||
`id=0.732441674276 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/alignPtr>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: template<typename _Tp> _Tp* alignPtr(_Tp* ptr, int n=sizeof(_Tp))
|
||||
|
||||
Aligns pointer to the specified number of bytes
|
||||
|
||||
:param ptr: The aligned pointer
|
||||
|
||||
:param n: The alignment size; must be a power of two
|
||||
|
||||
|
||||
|
||||
|
||||
:param ptr: The aligned pointer
|
||||
|
||||
|
||||
:param n: The alignment size; must be a power of two
|
||||
|
||||
|
||||
|
||||
The function returns the aligned pointer of the same type as the input pointer:
|
||||
|
||||
|
||||
.. math::
|
||||
|
||||
\texttt{(\_Tp*)(((size\_t)ptr + n-1) \& -n)}
|
||||
|
||||
|
||||
\texttt{(\_Tp*)(((size\_t)ptr + n-1) \& -n)}
|
||||
|
||||
.. index:: alignSize
|
||||
|
||||
|
||||
cv::alignSize
|
||||
-------------
|
||||
|
||||
`id=0.0293178300141 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/alignSize>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: size_t alignSize(size_t sz, int n)
|
||||
|
||||
Aligns a buffer size to the specified number of bytes
|
||||
|
||||
:param sz: The buffer size to align
|
||||
|
||||
:param n: The alignment size; must be a power of two
|
||||
|
||||
|
||||
|
||||
|
||||
:param sz: The buffer size to align
|
||||
|
||||
|
||||
:param n: The alignment size; must be a power of two
|
||||
|
||||
|
||||
|
||||
The function returns the minimum number that is greater or equal to
|
||||
``sz``
|
||||
and is divisble by
|
||||
``n``
|
||||
:
|
||||
|
||||
The function returns the minimum number that is greater or equal to ``sz`` and is divisble by ``n`` :
|
||||
|
||||
.. math::
|
||||
|
||||
\texttt{(sz + n-1) \& -n}
|
||||
|
||||
|
||||
\texttt{(sz + n-1) \& -n}
|
||||
|
||||
.. index:: allocate
|
||||
|
||||
|
||||
cv::allocate
|
||||
------------
|
||||
|
||||
`id=0.672857293821 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/allocate>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: template<typename _Tp> _Tp* allocate(size_t n)
|
||||
|
||||
Allocates an array of elements
|
||||
|
||||
:param n: The number of elements to allocate
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:param n: The number of elements to allocate
|
||||
|
||||
|
||||
|
||||
The generic function
|
||||
``allocate``
|
||||
allocates buffer for the specified number of elements. For each element the default constructor is called.
|
||||
|
||||
|
||||
The generic function ``allocate`` allocates buffer for the specified number of elements. For each element the default constructor is called.
|
||||
|
||||
.. index:: deallocate
|
||||
|
||||
|
||||
cv::deallocate
|
||||
--------------
|
||||
|
||||
`id=0.907199792708 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/deallocate>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: template<typename _Tp> void deallocate(_Tp* ptr, size_t n)
|
||||
|
||||
Allocates an array of elements
|
||||
|
||||
:param ptr: Pointer to the deallocated buffer
|
||||
|
||||
:param n: The number of elements in the buffer
|
||||
|
||||
|
||||
|
||||
|
||||
:param ptr: Pointer to the deallocated buffer
|
||||
|
||||
|
||||
:param n: The number of elements in the buffer
|
||||
|
||||
|
||||
|
||||
The generic function
|
||||
``deallocate``
|
||||
deallocates the buffer allocated with
|
||||
:func:`allocate`
|
||||
. The number of elements must match the number passed to
|
||||
:func:`allocate`
|
||||
.
|
||||
|
||||
The generic function ``deallocate`` deallocates the buffer allocated with
|
||||
:func:`allocate` . The number of elements must match the number passed to
|
||||
:func:`allocate` .
|
||||
|
||||
.. index:: CV_Assert
|
||||
|
||||
@@ -153,152 +73,57 @@ deallocates the buffer allocated with
|
||||
|
||||
CV_Assert
|
||||
---------
|
||||
|
||||
`id=0.132247699783 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/CV_Assert>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: CV_Assert(expr)
|
||||
|
||||
Checks a condition at runtime.
|
||||
Checks a condition at runtime. ::
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
#define CV_Assert( expr ) ...
|
||||
#define CV_DbgAssert(expr) ...
|
||||
|
||||
|
||||
..
|
||||
|
||||
:param expr: The checked expression
|
||||
|
||||
|
||||
|
||||
:param expr: The checked expression
|
||||
|
||||
|
||||
|
||||
The macros
|
||||
``CV_Assert``
|
||||
and
|
||||
``CV_DbgAssert``
|
||||
evaluate the specified expression and if it is 0, the macros raise an error (see
|
||||
:func:`error`
|
||||
). The macro
|
||||
``CV_Assert``
|
||||
checks the condition in both Debug and Release configurations, while
|
||||
``CV_DbgAssert``
|
||||
is only retained in the Debug configuration.
|
||||
|
||||
The macros ``CV_Assert`` and ``CV_DbgAssert`` evaluate the specified expression and if it is 0, the macros raise an error (see
|
||||
:func:`error` ). The macro ``CV_Assert`` checks the condition in both Debug and Release configurations, while ``CV_DbgAssert`` is only retained in the Debug configuration.
|
||||
|
||||
.. index:: error
|
||||
|
||||
|
||||
cv::error
|
||||
---------
|
||||
|
||||
`id=0.274198769781 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/error>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void error( const Exception\& exc )
|
||||
|
||||
|
||||
|
||||
.. cfunction:: \#define CV_Error( code, msg ) <...>
|
||||
|
||||
|
||||
|
||||
.. cfunction:: \#define CV_Error_( code, args ) <...>
|
||||
|
||||
Signals an error and raises the exception
|
||||
|
||||
:param exc: The exception to throw
|
||||
|
||||
:param code: The error code, normally, a negative value. The list of pre-defined error codes can be found in ``cxerror.h`` :param msg: Text of the error message
|
||||
|
||||
:param args: printf-like formatted error message in parantheses
|
||||
|
||||
The function and the helper macros ``CV_Error`` and ``CV_Error_`` call the error handler. Currently, the error handler prints the error code ( ``exc.code`` ), the context ( ``exc.file``,``exc.line`` and the error message ``exc.err`` to the standard error stream ``stderr`` . In Debug configuration it then provokes memory access violation, so that the execution stack and all the parameters can be analyzed in debugger. In Release configuration the exception ``exc`` is thrown.
|
||||
|
||||
|
||||
:param exc: The exception to throw
|
||||
|
||||
|
||||
:param code: The error code, normally, a negative value. The list of pre-defined error codes can be found in ``cxerror.h``
|
||||
|
||||
|
||||
:param msg: Text of the error message
|
||||
|
||||
|
||||
:param args: printf-like formatted error message in parantheses
|
||||
|
||||
|
||||
|
||||
The function and the helper macros
|
||||
``CV_Error``
|
||||
and
|
||||
``CV_Error_``
|
||||
call the error handler. Currently, the error handler prints the error code (
|
||||
``exc.code``
|
||||
), the context (
|
||||
``exc.file``
|
||||
,
|
||||
``exc.line``
|
||||
and the error message
|
||||
``exc.err``
|
||||
to the standard error stream
|
||||
``stderr``
|
||||
. In Debug configuration it then provokes memory access violation, so that the execution stack and all the parameters can be analyzed in debugger. In Release configuration the exception
|
||||
``exc``
|
||||
is thrown.
|
||||
The macro ``CV_Error_`` can be used to construct the error message on-fly to include some dynamic information, for example: ::
|
||||
|
||||
The macro
|
||||
``CV_Error_``
|
||||
can be used to construct the error message on-fly to include some dynamic information, for example:
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
// note the extra parentheses around the formatted text message
|
||||
CV_Error_(CV_StsOutOfRange,
|
||||
("the matrix element (
|
||||
i, j, mtx.at<float>(i,j)))
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
.. index:: Exception
|
||||
|
||||
.. _Exception:
|
||||
|
||||
Exception
|
||||
---------
|
||||
|
||||
`id=0.792198322059 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/Exception>`__
|
||||
|
||||
.. ctype:: Exception
|
||||
|
||||
The exception class passed to error ::
|
||||
|
||||
|
||||
The exception class passed to error
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
class Exception
|
||||
{
|
||||
public:
|
||||
@@ -308,7 +133,7 @@ The exception class passed to error
|
||||
const string& _func, const string& _file, int _line);
|
||||
Exception(const Exception& exc);
|
||||
Exception& operator = (const Exception& exc);
|
||||
|
||||
|
||||
// the error code
|
||||
int code;
|
||||
// the error text message
|
||||
@@ -320,249 +145,115 @@ The exception class passed to error
|
||||
// the source file line where the error happened
|
||||
int line;
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
The class
|
||||
``Exception``
|
||||
encapsulates all or almost all the necessary information about the error happened in the program. The exception is usually constructed and thrown implicitly, via
|
||||
``CV_Error``
|
||||
and
|
||||
``CV_Error_``
|
||||
macros, see
|
||||
:func:`error`
|
||||
.
|
||||
|
||||
|
||||
The class ``Exception`` encapsulates all or almost all the necessary information about the error happened in the program. The exception is usually constructed and thrown implicitly, via ``CV_Error`` and ``CV_Error_`` macros, see
|
||||
:func:`error` .
|
||||
|
||||
.. index:: fastMalloc
|
||||
|
||||
|
||||
cv::fastMalloc
|
||||
--------------
|
||||
|
||||
`id=0.913748026438 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/fastMalloc>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void* fastMalloc(size_t size)
|
||||
|
||||
Allocates aligned memory buffer
|
||||
|
||||
:param size: The allocated buffer size
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:param size: The allocated buffer size
|
||||
|
||||
|
||||
|
||||
The function allocates buffer of the specified size and returns it. When the buffer size is 16 bytes or more, the returned buffer is aligned on 16 bytes.
|
||||
|
||||
|
||||
.. index:: fastFree
|
||||
|
||||
|
||||
cv::fastFree
|
||||
------------
|
||||
|
||||
`id=0.486348253472 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/fastFree>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void fastFree(void* ptr)
|
||||
|
||||
Deallocates memory buffer
|
||||
|
||||
:param ptr: Pointer to the allocated buffer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:param ptr: Pointer to the allocated buffer
|
||||
|
||||
|
||||
|
||||
The function deallocates the buffer, allocated with
|
||||
:func:`fastMalloc`
|
||||
.
|
||||
The function deallocates the buffer, allocated with
|
||||
:func:`fastMalloc` .
|
||||
If NULL pointer is passed, the function does nothing.
|
||||
|
||||
|
||||
.. index:: format
|
||||
|
||||
|
||||
cv::format
|
||||
----------
|
||||
|
||||
`id=0.359045522761 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/format>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: string format( const char* fmt, ... )
|
||||
|
||||
Returns a text string formatted using printf-like expression
|
||||
|
||||
:param fmt: The printf-compatible formatting specifiers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:param fmt: The printf-compatible formatting specifiers
|
||||
|
||||
|
||||
|
||||
The function acts like
|
||||
``sprintf``
|
||||
, but forms and returns STL string. It can be used for form the error message in
|
||||
:func:`Exception`
|
||||
constructor.
|
||||
|
||||
The function acts like ``sprintf`` , but forms and returns STL string. It can be used for form the error message in
|
||||
:func:`Exception` constructor.
|
||||
|
||||
.. index:: getNumThreads
|
||||
|
||||
|
||||
cv::getNumThreads
|
||||
-----------------
|
||||
|
||||
`id=0.665594834701 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/getNumThreads>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: int getNumThreads()
|
||||
|
||||
Returns the number of threads used by OpenCV
|
||||
|
||||
|
||||
|
||||
The function returns the number of threads that is used by OpenCV.
|
||||
|
||||
See also:
|
||||
:func:`setNumThreads`
|
||||
,
|
||||
:func:`getThreadNum`
|
||||
.
|
||||
|
||||
|
||||
See also:
|
||||
:func:`setNumThreads`,:func:`getThreadNum` .
|
||||
|
||||
.. index:: getThreadNum
|
||||
|
||||
|
||||
cv::getThreadNum
|
||||
----------------
|
||||
|
||||
`id=0.835208450402 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/getThreadNum>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: int getThreadNum()
|
||||
|
||||
Returns index of the currently executed thread
|
||||
|
||||
|
||||
|
||||
The function returns 0-based index of the currently executed thread. The function is only valid inside a parallel OpenMP region. When OpenCV is built without OpenMP support, the function always returns 0.
|
||||
|
||||
See also:
|
||||
:func:`setNumThreads`
|
||||
,
|
||||
:func:`getNumThreads`
|
||||
.
|
||||
|
||||
See also:
|
||||
:func:`setNumThreads`,:func:`getNumThreads` .
|
||||
|
||||
.. index:: getTickCount
|
||||
|
||||
|
||||
cv::getTickCount
|
||||
----------------
|
||||
|
||||
`id=0.682548115061 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/getTickCount>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: int64 getTickCount()
|
||||
|
||||
Returns the number of ticks
|
||||
|
||||
|
||||
|
||||
The function returns the number of ticks since the certain event (e.g. when the machine was turned on).
|
||||
It can be used to initialize
|
||||
:func:`RNG`
|
||||
or to measure a function execution time by reading the tick count before and after the function call. See also the tick frequency.
|
||||
|
||||
It can be used to initialize
|
||||
:func:`RNG` or to measure a function execution time by reading the tick count before and after the function call. See also the tick frequency.
|
||||
|
||||
.. index:: getTickFrequency
|
||||
|
||||
|
||||
cv::getTickFrequency
|
||||
--------------------
|
||||
|
||||
`id=0.85013360741 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/getTickFrequency>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: double getTickFrequency()
|
||||
|
||||
Returns the number of ticks per second
|
||||
|
||||
|
||||
|
||||
The function returns the number of ticks per second.
|
||||
That is, the following code computes the execution time in seconds.
|
||||
That is, the following code computes the execution time in seconds. ::
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
double t = (double)getTickCount();
|
||||
// do something ...
|
||||
t = ((double)getTickCount() - t)/getTickFrequency();
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
.. index:: setNumThreads
|
||||
|
||||
|
||||
cv::setNumThreads
|
||||
-----------------
|
||||
|
||||
`id=0.215563071229 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/setNumThreads>`__
|
||||
|
||||
|
||||
|
||||
|
||||
.. cfunction:: void setNumThreads(int nthreads)
|
||||
|
||||
Sets the number of threads used by OpenCV
|
||||
|
||||
:param nthreads: The number of threads used by OpenCV
|
||||
|
||||
The function sets the number of threads used by OpenCV in parallel OpenMP regions. If ``nthreads=0`` , the function will use the default number of threads, which is usually equal to the number of the processing cores.
|
||||
|
||||
|
||||
|
||||
|
||||
:param nthreads: The number of threads used by OpenCV
|
||||
|
||||
|
||||
|
||||
The function sets the number of threads used by OpenCV in parallel OpenMP regions. If
|
||||
``nthreads=0``
|
||||
, the function will use the default number of threads, which is usually equal to the number of the processing cores.
|
||||
|
||||
See also:
|
||||
:func:`getNumThreads`
|
||||
,
|
||||
:func:`getThreadNum`
|
||||
See also:
|
||||
:func:`getNumThreads`,:func:`getThreadNum`
|
@@ -3,30 +3,16 @@ XML/YAML Persistence
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
|
||||
.. index:: FileStorage
|
||||
|
||||
.. _FileStorage:
|
||||
|
||||
FileStorage
|
||||
-----------
|
||||
|
||||
`id=0.36488878292 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/FileStorage>`__
|
||||
|
||||
.. ctype:: FileStorage
|
||||
|
||||
The XML/YAML file storage class ::
|
||||
|
||||
|
||||
The XML/YAML file storage class
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
class FileStorage
|
||||
{
|
||||
public:
|
||||
@@ -41,7 +27,7 @@ The XML/YAML file storage class
|
||||
FileStorage(CvFileStorage* fs);
|
||||
// the destructor; closes the file if needed
|
||||
virtual ~FileStorage();
|
||||
|
||||
|
||||
// opens the specified file for reading (flags=FileStorage::READ)
|
||||
// or writing (flags=FileStorage::WRITE)
|
||||
virtual bool open(const string& filename, int flags);
|
||||
@@ -49,7 +35,7 @@ The XML/YAML file storage class
|
||||
virtual bool isOpened() const;
|
||||
// closes the file
|
||||
virtual void release();
|
||||
|
||||
|
||||
// returns the first top-level node
|
||||
FileNode getFirstTopLevelNode() const;
|
||||
// returns the root file node
|
||||
@@ -58,54 +44,39 @@ The XML/YAML file storage class
|
||||
// returns the top-level node by name
|
||||
FileNode operator[](const string& nodename) const;
|
||||
FileNode operator[](const char* nodename) const;
|
||||
|
||||
|
||||
// returns the underlying CvFileStorage*
|
||||
CvFileStorage* operator *() { return fs; }
|
||||
const CvFileStorage* operator *() const { return fs; }
|
||||
|
||||
|
||||
// writes the certain number of elements of the specified format
|
||||
// (see DataType) without any headers
|
||||
void writeRaw( const string& fmt, const uchar* vec, size_t len );
|
||||
|
||||
|
||||
// writes an old-style object (CvMat, CvMatND etc.)
|
||||
void writeObj( const string& name, const void* obj );
|
||||
|
||||
|
||||
// returns the default object name from the filename
|
||||
// (used by cvSave() with the default object name etc.)
|
||||
static string getDefaultObjectName(const string& filename);
|
||||
|
||||
|
||||
Ptr<CvFileStorage> fs;
|
||||
string elname;
|
||||
vector<char> structs;
|
||||
int state;
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
.. index:: FileNode
|
||||
|
||||
.. _FileNode:
|
||||
|
||||
FileNode
|
||||
--------
|
||||
|
||||
`id=0.228849909258 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/FileNode>`__
|
||||
|
||||
.. ctype:: FileNode
|
||||
|
||||
The XML/YAML file node class ::
|
||||
|
||||
|
||||
The XML/YAML file node class
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
class CV_EXPORTS FileNode
|
||||
{
|
||||
public:
|
||||
@@ -134,44 +105,29 @@ The XML/YAML file node class
|
||||
operator float() const;
|
||||
operator double() const;
|
||||
operator string() const;
|
||||
|
||||
|
||||
FileNodeIterator begin() const;
|
||||
FileNodeIterator end() const;
|
||||
|
||||
|
||||
void readRaw( const string& fmt, uchar* vec, size_t len ) const;
|
||||
void* readObj() const;
|
||||
|
||||
|
||||
// do not use wrapper pointer classes for better efficiency
|
||||
const CvFileStorage* fs;
|
||||
const CvFileNode* node;
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
.. index:: FileNodeIterator
|
||||
|
||||
.. _FileNodeIterator:
|
||||
|
||||
FileNodeIterator
|
||||
----------------
|
||||
|
||||
`id=0.575104633905 Comments from the Wiki <http://opencv.willowgarage.com/wiki/documentation/cpp/core/FileNodeIterator>`__
|
||||
|
||||
.. ctype:: FileNodeIterator
|
||||
|
||||
The XML/YAML file node iterator class ::
|
||||
|
||||
|
||||
The XML/YAML file node iterator class
|
||||
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
|
||||
class CV_EXPORTS FileNodeIterator
|
||||
{
|
||||
public:
|
||||
@@ -181,23 +137,21 @@ The XML/YAML file node iterator class
|
||||
FileNodeIterator(const FileNodeIterator& it);
|
||||
FileNode operator *() const;
|
||||
FileNode operator ->() const;
|
||||
|
||||
|
||||
FileNodeIterator& operator ++();
|
||||
FileNodeIterator operator ++(int);
|
||||
FileNodeIterator& operator --();
|
||||
FileNodeIterator operator --(int);
|
||||
FileNodeIterator& operator += (int);
|
||||
FileNodeIterator& operator -= (int);
|
||||
|
||||
|
||||
FileNodeIterator& readRaw( const string& fmt, uchar* vec,
|
||||
size_t maxCount=(size_t)INT_MAX );
|
||||
|
||||
|
||||
const CvFileStorage* fs;
|
||||
const CvFileNode* container;
|
||||
CvSeqReader reader;
|
||||
size_t remaining;
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
Reference in New Issue
Block a user