started work on API & doc synchronization (in particular, Mat& => Input/OutputArray in the descriptions)
This commit is contained in:
@@ -10,6 +10,8 @@ Basic Structures
|
||||
DataType
|
||||
--------
|
||||
|
||||
.. cpp:class:: DataType
|
||||
|
||||
Template "trait" class for other OpenCV primitive data types ::
|
||||
|
||||
template<typename _Tp> class DataType
|
||||
@@ -36,7 +38,7 @@ Template "trait" class for other OpenCV primitive data types ::
|
||||
};
|
||||
};
|
||||
|
||||
The template class ``DataType`` is a descriptive class for OpenCV primitive data types and other types that comply with the following definition. A primitive OpenCV data type is one of ``unsigned char``, ``bool``, ``signed char``, ``unsigned short``, ``signed short``, ``int``, ``float``, ``double`` or a tuple of values of one of these types, where all the values in the tuple have the same type. Any primitive type from the list can be defined by an identifier in the form ``CV_<bit-depth>{U|S|F}C<number_of_channels>``, for example: ``uchar`` ~ ``CV_8UC1``, 3-element floating-point tuple ~ ``CV_32FC3``, and so on. A universal OpenCV structure that is able to store a single instance of such a primitive data type is
|
||||
The template class ``DataType`` is a descriptive class for OpenCV primitive data types and other types that comply with the following definition. A primitive OpenCV data type is one of ``unsigned char``, ``bool``, ``signed char``, ``unsigned short``, ``signed short``, ``int``, ``float``, ``double`` or a tuple of values of one of these types, where all the values in the tuple have the same type. Any primitive type from the list can be defined by an identifier in the form ``CV_<bit-depth>{U|S|F}C(<number_of_channels>)``, for example: ``uchar`` ~ ``CV_8UC1``, 3-element floating-point tuple ~ ``CV_32FC3``, and so on. A universal OpenCV structure that is able to store a single instance of such a primitive data type is
|
||||
:ref:`Vec`. Multiple instances of such a type can be stored in a ``std::vector``, ``Mat``, ``Mat_``, ``SparseMat``, ``SparseMat_``, or any other container that is able to store ``Vec`` instances.
|
||||
|
||||
The ``DataType`` class is basically used to provide a description of such primitive data types without adding any fields or methods to the corresponding classes (and it is actually impossible to add anything to primitive C/C++ data types). This technique is known in C++ as class traits. It is not ``DataType`` itself that is used but its specialized versions, such as: ::
|
||||
@@ -78,6 +80,8 @@ So, such traits are used to tell OpenCV which data type you are working with, ev
|
||||
Point\_
|
||||
-------
|
||||
|
||||
.. cpp:class:: Point_
|
||||
|
||||
Template class for 2D points ::
|
||||
|
||||
template<typename _Tp> class Point_
|
||||
@@ -143,6 +147,8 @@ Example: ::
|
||||
Point3\_
|
||||
--------
|
||||
|
||||
.. cpp:class:: Point3_
|
||||
|
||||
Template class for 3D points ::
|
||||
|
||||
template<typename _Tp> class Point3_
|
||||
@@ -174,7 +180,7 @@ The class represents a 3D point specified by its coordinates
|
||||
:math:`z` .
|
||||
An instance of the class is interchangeable with the C structure ``CvPoint2D32f`` . Similarly to ``Point_`` , the coordinates of 3D points can be converted to another type. The vector arithmetic and comparison operations are also supported.
|
||||
|
||||
The following types of?? aliases are available: ::
|
||||
The following ``Point3_<>`` aliases are available: ::
|
||||
|
||||
typedef Point3_<int> Point3i;
|
||||
typedef Point3_<float> Point3f;
|
||||
@@ -185,6 +191,8 @@ The following types of?? aliases are available: ::
|
||||
Size\_
|
||||
------
|
||||
|
||||
.. cpp:class:: Size_
|
||||
|
||||
Template class for specfying an image or rectangle size ::
|
||||
|
||||
template<typename _Tp> class Size_
|
||||
@@ -214,7 +222,7 @@ Template class for specfying an image or rectangle size ::
|
||||
The class ``Size_`` is similar to ``Point_`` except that the two members are called ``width`` and ``height`` instead of ``x`` and ``y`` . The structure can be converted to and from the old OpenCV structures
|
||||
``CvSize`` and ``CvSize2D32f`` . The same set of arithmetic and comparison operations as for ``Point_`` is available.
|
||||
|
||||
OpenCV defines the following types of?? aliases: ::
|
||||
OpenCV defines the following ``Size_<>`` aliases: ::
|
||||
|
||||
typedef Size_<int> Size2i;
|
||||
typedef Size2i Size;
|
||||
@@ -225,6 +233,8 @@ OpenCV defines the following types of?? aliases: ::
|
||||
Rect\_
|
||||
------
|
||||
|
||||
.. cpp:class:: Rect_
|
||||
|
||||
Template class for 2D rectangles ::
|
||||
|
||||
template<typename _Tp> class Rect_
|
||||
@@ -314,17 +324,19 @@ This is an example how the partial ordering on rectangles can be established (re
|
||||
}
|
||||
|
||||
|
||||
For your convenience, the following type of aliases?? is available: ::
|
||||
For your convenience, the ``Rect_<>`` alias is available: ::
|
||||
|
||||
typedef Rect_<int> Rect;
|
||||
|
||||
.. index:: _RotatedRect
|
||||
|
||||
|
||||
.. _RotatedRect:
|
||||
|
||||
RotatedRect
|
||||
-----------
|
||||
|
||||
.. cpp:class:: RotatedRect
|
||||
|
||||
Template class for rotated rectangles ::
|
||||
|
||||
class RotatedRect
|
||||
@@ -356,7 +368,7 @@ The class ``RotatedRect`` replaces the old ``CvBox2D`` and is fully compatible w
|
||||
TermCriteria
|
||||
------------
|
||||
|
||||
.. c:type:: TermCriteria
|
||||
.. cpp:class:: TermCriteria
|
||||
|
||||
Template class defining termination criteria for iterative algorithms ::
|
||||
|
||||
@@ -393,6 +405,8 @@ The class ``TermCriteria`` replaces the old ``CvTermCriteria`` and is fully comp
|
||||
Matx
|
||||
----
|
||||
|
||||
.. cpp:class:: Matx
|
||||
|
||||
Template class for small matrices ::
|
||||
|
||||
template<typename T, int m, int n> class Matx
|
||||
@@ -428,9 +442,9 @@ Template class for small matrices ::
|
||||
|
||||
|
||||
The class represents small matrices whose type and size are known at compilation time. If you need a more flexible type, use
|
||||
:ref:`Mat` . The elements of the matrix ``M`` are accessible using the ``M(i,j)`` notation. Most of the common matrix operations (see also
|
||||
:cpp:class:`Mat` . The elements of the matrix ``M`` are accessible using the ``M(i,j)`` notation. Most of the common matrix operations (see also
|
||||
:ref:`MatrixExpressions` ) are available. To do an operation on ``Matx`` that is not implemented, you can easily convert the matrix to
|
||||
:ref:`Mat` and backwards. ::
|
||||
:cpp:class:`Mat` and backwards. ::
|
||||
|
||||
Matx33f m(1, 2, 3,
|
||||
4, 5, 6,
|
||||
@@ -438,12 +452,14 @@ The class represents small matrices whose type and size are known at compilation
|
||||
cout << sum(Mat(m*m.t())) << endl;
|
||||
|
||||
.. index:: Vec
|
||||
|
||||
|
||||
.. _Vec:
|
||||
|
||||
Vec
|
||||
---
|
||||
|
||||
.. cpp:class:: Vec
|
||||
|
||||
Template class for short numerical vectors ::
|
||||
|
||||
template<typename T, int cn> class Vec : public Matx<T, cn, 1>
|
||||
@@ -487,7 +503,7 @@ Template class for short numerical vectors ::
|
||||
* ``v1 == v2, v1 != v2`` * ``norm(v1)`` (:math:`L_2`-norm)
|
||||
|
||||
The ``Vec`` class is commonly used to describe pixel types of multi-channel arrays. See
|
||||
:ref:`Mat_`?? for details.
|
||||
:ref:`Mat_` for details.
|
||||
|
||||
.. index:: Scalar
|
||||
|
||||
@@ -496,6 +512,8 @@ The ``Vec`` class is commonly used to describe pixel types of multi-channel arra
|
||||
Scalar\_
|
||||
--------
|
||||
|
||||
.. cpp:class:: Scalar_
|
||||
|
||||
Template class for a 4-element vector ::
|
||||
|
||||
template<typename _Tp> class Scalar_ : public Vec<_Tp, 4>
|
||||
@@ -527,6 +545,8 @@ The template class ``Scalar_`` and its double-precision instantiation ``Scalar``
|
||||
Range
|
||||
-----
|
||||
|
||||
.. cpp:class:: Range
|
||||
|
||||
Template class specifying a continuous subsequence (slice) of a sequence ::
|
||||
|
||||
class Range
|
||||
@@ -568,6 +588,8 @@ The static method ``Range::all()`` returns a special variable that means "the wh
|
||||
Ptr
|
||||
---
|
||||
|
||||
.. cpp:class:: Ptr
|
||||
|
||||
Template class for smart reference-counting pointers ::
|
||||
|
||||
template<typename _Tp> class Ptr
|
||||
@@ -623,7 +645,7 @@ This class provides the following options:
|
||||
Default constructor, copy constructor, and assignment operator for an arbitrary C++ class or a C structure. For some objects, like files, windows, mutexes, sockets, and others, a copy constructor or an assignment operator are difficult to define. For some other objects, like complex classifiers in OpenCV, copy constructors are absent and not easy to implement. Finally, some of complex OpenCV and your own data structures may be written in C. However, copy constructors and default constructors can simplify programming a lot. Besides, they are often required (for example, by STL containers). By wrapping a pointer to such a complex object ``TObj`` to ``Ptr<TObj>`` , you automatically get all of the necessary constructors and the assignment operator.
|
||||
|
||||
*
|
||||
Speed-up for the above-mentioned operations regardless of the data size, similar to "O(1)" operations.?? Indeed, while some structures, like ``std::vector`` , provide a copy constructor and an assignment operator, the operations may take a considerable amount of time if the data structures are large. But if the structures are put into ``Ptr<>`` , the overhead is small and independent of the data size.
|
||||
*O(1)* complexity of the above-mentioned operations. Indeed, while some structures, like ``std::vector``, provide a copy constructor and an assignment operator, the operations may take a considerable amount of time if the data structures are large. But if the structures are put into ``Ptr<>`` , the overhead is small and independent of the data size.
|
||||
|
||||
*
|
||||
Automatic destruction, even for C structures. See the example below with ``FILE*`` .
|
||||
@@ -654,12 +676,10 @@ However, if the object is deallocated in a different way, the specialized method
|
||||
|
||||
.. index:: Mat
|
||||
|
||||
.. _Mat:
|
||||
|
||||
Mat
|
||||
---
|
||||
|
||||
.. c:type:: Mat
|
||||
.. cpp:class:: Mat
|
||||
|
||||
OpenCV C++ n-dimensional dense array class ::
|
||||
|
||||
@@ -818,9 +838,9 @@ There are many different ways to create a ``Mat`` object. The most popular optio
|
||||
|
||||
..
|
||||
|
||||
??is the indent required here? does it apply to step 2 but not to the whole bulleted item??Partial yet very common cases of this *user-allocated data* case are conversions from ``CvMat`` and ``IplImage`` to ``Mat``. For this purpose, there are special constructors taking pointers to ``CvMat`` or ``IplImage`` and the optional flag indicating whether to copy the data or not.
|
||||
Partial yet very common cases of this *user-allocated data* case are conversions from ``CvMat`` and ``IplImage`` to ``Mat``. For this purpose, there are special constructors taking pointers to ``CvMat`` or ``IplImage`` and the optional flag indicating whether to copy the data or not.
|
||||
|
||||
Backward conversion from ``Mat`` to ``CvMat`` or ``IplImage`` is provided via cast operators ``Mat::operator CvMat() const`` and ``Mat::operator IplImage()``. The operators do NOT copy the data.
|
||||
Backward conversion from ``Mat`` to ``CvMat`` or ``IplImage`` is provided via cast operators ``Mat::operator CvMat() const`` and ``Mat::operator IplImage()``. The operators do NOT copy the data.
|
||||
|
||||
::
|
||||
|
||||
@@ -967,8 +987,6 @@ Below is the formal description of the ``Mat`` methods.
|
||||
|
||||
.. index:: Mat::Mat
|
||||
|
||||
.. _Mat::Mat:
|
||||
|
||||
Mat::Mat
|
||||
------------
|
||||
.. cpp:function:: Mat::Mat()
|
||||
@@ -1078,7 +1096,7 @@ Mat::operator =
|
||||
|
||||
:param m: The assigned, right-hand-side matrix. Matrix assignment is O(1) operation, that is, no data is copied. Instead, the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is de-referenced via :ref:`Mat::release` .
|
||||
|
||||
:param expr: The assigned matrix expression object. As opposite to the first form of assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, ``C=A+B`` is expanded to ``add(A, B, C)`` , and :func:`add` takes care of automatic ``C`` reallocation.
|
||||
:param expr: The assigned matrix expression object. As opposite to the first form of assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, ``C=A+B`` is expanded to ``add(A, B, C)`` , and :cpp:func:`add` takes care of automatic ``C`` reallocation.
|
||||
|
||||
:param s: The scalar assigned to each matrix element. The matrix size or type is not changed.
|
||||
|
||||
@@ -1097,8 +1115,6 @@ The cast operator should not be called explicitly. It is used internally by the
|
||||
|
||||
.. index:: Mat::row
|
||||
|
||||
.. _Mat::row:
|
||||
|
||||
Mat::row
|
||||
------------
|
||||
.. cpp:function:: Mat Mat::row(int i) const
|
||||
@@ -1138,8 +1154,6 @@ This is because ``A.row(i)`` forms a temporary header, which is further assigned
|
||||
|
||||
.. index:: Mat::col
|
||||
|
||||
.. _Mat::col:
|
||||
|
||||
Mat::col
|
||||
------------
|
||||
.. cpp:function:: Mat Mat::col(int j) const
|
||||
@@ -1153,8 +1167,6 @@ The method makes a new header for the specified matrix column and returns it. Th
|
||||
|
||||
.. index:: Mat::rowRange
|
||||
|
||||
.. _Mat::rowRange:
|
||||
|
||||
Mat::rowRange
|
||||
-----------------
|
||||
.. cpp:function:: Mat Mat::rowRange(int startrow, int endrow) const
|
||||
@@ -1167,16 +1179,14 @@ Mat::rowRange
|
||||
|
||||
:param endrow: A 0-based ending index of the row span.
|
||||
|
||||
:param r: The :func:`Range` structure containing both the start and the end indices.
|
||||
:param r: The :cpp:func:`Range` structure containing both the start and the end indices.
|
||||
|
||||
The method makes a new header for the specified row span of the matrix. Similarly to
|
||||
:func:`Mat::row` and
|
||||
:func:`Mat::col` , this is an O(1) operation.
|
||||
:cpp:func:`Mat::row` and
|
||||
:cpp:func:`Mat::col` , this is an O(1) operation.
|
||||
|
||||
.. index:: Mat::colRange
|
||||
|
||||
.. _Mat::colRange:
|
||||
|
||||
Mat::colRange
|
||||
-----------------
|
||||
.. cpp:function:: Mat Mat::colRange(int startcol, int endcol) const
|
||||
@@ -1189,16 +1199,14 @@ Mat::colRange
|
||||
|
||||
:param endcol: A 0-based ending index of the column span.
|
||||
|
||||
:param r: The :func:`Range` structure containing both the start and the end indices.
|
||||
:param r: The :cpp:func:`Range` structure containing both the start and the end indices.
|
||||
|
||||
The method makes a new header for the specified column span of the matrix. Similarly to
|
||||
:func:`Mat::row` and
|
||||
:func:`Mat::col` , this is an O(1) operation.
|
||||
:cpp:func:`Mat::row` and
|
||||
:cpp:func:`Mat::col` , this is an O(1) operation.
|
||||
|
||||
.. index:: Mat::diag
|
||||
|
||||
.. _Mat::diag:
|
||||
|
||||
Mat::diag
|
||||
-------------
|
||||
.. cpp:function:: Mat Mat::diag(int d) const
|
||||
@@ -1218,13 +1226,11 @@ Mat::diag
|
||||
:param matD: A single-column matrix that forms the diagonal matrix.
|
||||
|
||||
The method makes a new header for the specified matrix diagonal. The new matrix is represented as a single-column matrix. Similarly to
|
||||
:func:`Mat::row` and
|
||||
:func:`Mat::col` , this is an O(1) operation.
|
||||
:cpp:func:`Mat::row` and
|
||||
:cpp:func:`Mat::col` , this is an O(1) operation.
|
||||
|
||||
.. index:: Mat::clone
|
||||
|
||||
.. _Mat::clone:
|
||||
|
||||
Mat::clone
|
||||
--------------
|
||||
.. cpp:function:: Mat Mat::clone() const
|
||||
@@ -1259,8 +1265,6 @@ When the operation mask is specified, and the ``Mat::create`` call shown above r
|
||||
|
||||
.. index:: Mat::convertTo
|
||||
|
||||
.. _Mat::convertTo:
|
||||
|
||||
Mat::convertTo
|
||||
------------------
|
||||
.. cpp:function:: void Mat::convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const
|
||||
@@ -1300,7 +1304,7 @@ This is an internally used method called by the
|
||||
|
||||
Mat::setTo
|
||||
--------------
|
||||
.. c:function:: Mat& Mat::setTo(const Scalar& s, const Mat& mask=Mat())
|
||||
.. cpp:function:: Mat& Mat::setTo(const Scalar& s, const Mat& mask=Mat())
|
||||
|
||||
Sets all or some of the array elements to the specified value.
|
||||
|
||||
@@ -1327,7 +1331,7 @@ The method makes a new matrix header for ``*this`` elements. The new matrix may
|
||||
|
||||
*
|
||||
No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of rows, or the operation changes the indices of elements' row in some other way, the matrix must be continuous. See
|
||||
:func:`Mat::isContinuous` .
|
||||
:cpp:func:`Mat::isContinuous` .
|
||||
|
||||
For example, if there is a set of 3D points stored as an STL vector, and you want to represent the points as a ``3xN`` matrix, do the following: ::
|
||||
|
||||
@@ -1471,7 +1475,7 @@ Mat::ones
|
||||
:param type: Created matrix type.
|
||||
|
||||
The method returns a Matlab-style 1's array initializer, similarly to
|
||||
:func:`Mat::zeros` . Note that using this method you can initialize an array with an arbitrary value, using the following Matlab idiom: ::
|
||||
:cpp:func:`Mat::zeros` . Note that using this method you can initialize an array with an arbitrary value, using the following Matlab idiom: ::
|
||||
|
||||
Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3.
|
||||
|
||||
@@ -1496,7 +1500,7 @@ Mat::eye
|
||||
:param type: Created matrix type.
|
||||
|
||||
The method returns a Matlab-style identity matrix initializer, similarly to
|
||||
:func:`Mat::zeros` . Similarly to ``Mat::ones`` , you can use a scale operation to create a scaled identity matrix efficiently: ::
|
||||
:cpp:func:`Mat::zeros` . Similarly to ``Mat::ones`` , you can use a scale operation to create a scaled identity matrix efficiently: ::
|
||||
|
||||
// make a 4x4 diagonal matrix with 0.1's on the diagonal.
|
||||
Mat A = Mat::eye(4, 4, CV_32F)*0.1;
|
||||
@@ -1535,7 +1539,7 @@ This is one of the key ``Mat`` methods. Most new-style OpenCV functions and meth
|
||||
|
||||
#.
|
||||
Otherwise, de-reference the previous data by calling
|
||||
:func:`Mat::release` #.
|
||||
:cpp:func:`Mat::release` #.
|
||||
initialize the new header
|
||||
|
||||
#.
|
||||
@@ -1564,8 +1568,6 @@ because ``cvtColor`` , as well as the most of OpenCV functions, calls ``Mat::cre
|
||||
|
||||
.. index:: Mat::addref
|
||||
|
||||
.. _Mat::addref:
|
||||
|
||||
Mat::addref
|
||||
---------------
|
||||
.. cpp:function:: void Mat::addref()
|
||||
@@ -1573,12 +1575,10 @@ Mat::addref
|
||||
Increments the reference counter.
|
||||
|
||||
The method increments the reference counter associated with the matrix data. If the matrix header points to an external data set (see
|
||||
:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It is called implicitly by the matrix assignment operator. The reference counter increment is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
|
||||
:cpp:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It is called implicitly by the matrix assignment operator. The reference counter increment is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
|
||||
|
||||
.. index:: Mat::release
|
||||
|
||||
.. _Mat::release:
|
||||
|
||||
Mat::release
|
||||
----------------
|
||||
.. cpp:function:: void Mat::release()
|
||||
@@ -1586,14 +1586,12 @@ Mat::release
|
||||
Decrements the reference counter and deallocates the matrix if needed.
|
||||
|
||||
The method decrements the reference counter associated with the matrix data. When the reference counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers are set to NULL's. If the matrix header points to an external data set (see
|
||||
:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case.
|
||||
:cpp:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case.
|
||||
|
||||
This method can be called manually to force the matrix data deallocation. But since this method is automatically called in the destructor, or by any other method that changes the data pointer, it is usually not needed. The reference counter decrement and check for 0 is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
|
||||
|
||||
.. index:: Mat::resize
|
||||
|
||||
.. _Mat::resize:
|
||||
|
||||
Mat::resize
|
||||
---------------
|
||||
.. cpp:function:: void Mat::resize( size_t sz ) const
|
||||
@@ -1606,12 +1604,10 @@ The method changes the number of matrix rows. If the matrix is reallocated, the
|
||||
|
||||
.. index:: Mat::push_back
|
||||
|
||||
.. _Mat::push_back:
|
||||
|
||||
Mat::push_back
|
||||
--------------
|
||||
.. c:function:: template<typename T> void Mat::push_back(const T& elem)
|
||||
.. c:function:: template<typename T> void Mat::push_back(const Mat_<T>& elem)
|
||||
.. cpp:function:: template<typename T> void Mat::push_back(const T& elem)
|
||||
.. cpp:function:: template<typename T> void Mat::push_back(const Mat_<T>& elem)
|
||||
|
||||
Adds elements to the bottom of the matrix.
|
||||
|
||||
@@ -1625,7 +1621,7 @@ The methods add one or more elements to the bottom of the matrix. They emulate t
|
||||
|
||||
Mat::pop_back
|
||||
-------------
|
||||
.. c:function:: template<typename T> void Mat::pop_back(size_t nelems=1)
|
||||
.. cpp:function:: template<typename T> void Mat::pop_back(size_t nelems=1)
|
||||
|
||||
Removes elements from the bottom of the matrix.
|
||||
|
||||
@@ -1648,7 +1644,7 @@ Mat::locateROI
|
||||
:param ofs: An output parameter that contains an offset of ``*this`` inside the whole matrix.
|
||||
|
||||
After you extracted a submatrix from a matrix using
|
||||
:func:`Mat::row`,:func:`Mat::col`,:func:`Mat::rowRange`,:func:`Mat::colRange` , and others, the resultant submatrix will point just to the part of the original big matrix. However, each submatrix contains some information (represented by ``datastart`` and ``dataend`` fields) that helps reconstruct the original matrix size and the position of the extracted submatrix within the original matrix. The method ``locateROI`` does exactly that.
|
||||
:cpp:func:`Mat::row`,:cpp:func:`Mat::col`,:cpp:func:`Mat::rowRange`,:cpp:func:`Mat::colRange` , and others, the resultant submatrix will point just to the part of the original big matrix. However, each submatrix contains some information (represented by ``datastart`` and ``dataend`` fields) that helps reconstruct the original matrix size and the position of the extracted submatrix within the original matrix. The method ``locateROI`` does exactly that.
|
||||
|
||||
.. index:: Mat::adjustROI
|
||||
|
||||
@@ -1669,7 +1665,7 @@ Mat::adjustROI
|
||||
:param dright: The shift of the right submatrix boundary to the right.
|
||||
|
||||
The method is complimentary to
|
||||
:func:`Mat::locateROI` . Indeed, the typical use of these functions is to determine the submatrix position within the parent matrix and then shift the position somehow. Typically, it can be required for filtering operations when pixels outside of the ROI should be taken into account. When all the method parameters are positive, the ROI needs to grow in all directions by the specified amount, for example: ::
|
||||
:cpp:func:`Mat::locateROI` . Indeed, the typical use of these functions is to determine the submatrix position within the parent matrix and then shift the position somehow. Typically, it can be required for filtering operations when pixels outside of the ROI should be taken into account. When all the method parameters are positive, the ROI needs to grow in all directions by the specified amount, for example: ::
|
||||
|
||||
A.adjustROI(2, 2, 2, 2);
|
||||
|
||||
@@ -1679,10 +1675,10 @@ In this example, the matrix size is increased by 4 elements in each direction. T
|
||||
It is your responsibility to make sure ``adjustROI`` does not cross the parent matrix boundary. If it does, the function signals an error.
|
||||
|
||||
The function is used internally by the OpenCV filtering functions, like
|
||||
:func:`filter2D` , morphological operations, and so on.
|
||||
:cpp:func:`filter2D` , morphological operations, and so on.
|
||||
|
||||
See Also
|
||||
:func:`copyMakeBorder`
|
||||
:cpp:func:`copyMakeBorder`
|
||||
|
||||
.. index:: Mat::operator()
|
||||
|
||||
@@ -1707,14 +1703,14 @@ Mat::operator()
|
||||
:param ranges: The array of selected ranges along each array dimension.
|
||||
|
||||
The operators make a new header for the specified sub-array of ``*this`` . They are the most generalized forms of
|
||||
:func:`Mat::row`,:func:`Mat::col`,:func:`Mat::rowRange`, and
|
||||
:func:`Mat::colRange` . For example, ``A(Range(0, 10), Range::all())`` is equivalent to ``A.rowRange(0, 10)`` . Similarly to all of the above, the operators are O(1) operations, that is, no matrix data is copied.
|
||||
:cpp:func:`Mat::row`,:cpp:func:`Mat::col`,:cpp:func:`Mat::rowRange`, and
|
||||
:cpp:func:`Mat::colRange` . For example, ``A(Range(0, 10), Range::all())`` is equivalent to ``A.rowRange(0, 10)`` . Similarly to all of the above, the operators are O(1) operations, that is, no matrix data is copied.
|
||||
|
||||
.. index:: Mat::operator CvMat
|
||||
|
||||
Mat::operator CvMat
|
||||
-----------------------
|
||||
.. cpp:function:: Mat::operator CvMat(void) const
|
||||
.. cpp:function:: Mat::operator CvMat() const
|
||||
|
||||
Creates the ``CvMat`` header for the matrix.
|
||||
|
||||
@@ -1733,7 +1729,7 @@ where ``mycvOldFunc`` is a function written to work with OpenCV 1.x data structu
|
||||
|
||||
Mat::operator IplImage
|
||||
--------------------------
|
||||
.. cpp:function:: Mat::operator IplImage(void) const
|
||||
.. cpp:function:: Mat::operator IplImage() const
|
||||
|
||||
Creates the ``IplImage`` header for the matrix.
|
||||
|
||||
@@ -1745,7 +1741,7 @@ The operator creates the ``IplImage`` header for the matrix without copying the
|
||||
|
||||
Mat::total
|
||||
--------------
|
||||
.. cpp:function:: size_t Mat::total(void) const
|
||||
.. cpp:function:: size_t Mat::total() const
|
||||
|
||||
Returns the total number of array elements.
|
||||
|
||||
@@ -1757,13 +1753,13 @@ The method returns the number of array elements (a number of pixels if the array
|
||||
|
||||
Mat::isContinuous
|
||||
---------------------
|
||||
.. cpp:function:: bool Mat::isContinuous(void) const
|
||||
.. cpp:function:: bool Mat::isContinuous() const
|
||||
|
||||
Reports whether the matrix is continuous or not.
|
||||
|
||||
The method returns ``true`` if the matrix elements are stored continuously - without gaps in the end of each row. Otherwise, it returns ``false``. Obviously, ``1x1`` or ``1xN`` matrices are always continuous. Matrices created with
|
||||
:func:`Mat::create` are always continuous. But if you extract a part of the matrix using
|
||||
:func:`Mat::col`,:func:`Mat::diag` , and so on, or constructed a matrix header for externally allocated data, such matrices may no longer have this property.
|
||||
:cpp:func:`Mat::create` are always continuous. But if you extract a part of the matrix using
|
||||
:cpp:func:`Mat::col`,:cpp:func:`Mat::diag` , and so on, or constructed a matrix header for externally allocated data, such matrices may no longer have this property.
|
||||
|
||||
The continuity flag is stored as a bit in the ``Mat::flags`` field and is computed automatically when you construct a matrix header. Thus, the continuity check is a very fast operation, though it could be, in theory, done as following: ::
|
||||
|
||||
@@ -1822,8 +1818,8 @@ The method is used in quite a few of OpenCV functions. The point is that element
|
||||
This trick, while being very simple, can boost performance of a simple element-operation by 10-20 percents, especially if the image is rather small and the operation is quite simple.
|
||||
|
||||
Also, note that there is another OpenCV idiom in this function: a call of
|
||||
:func:`Mat::create` for the destination array instead of checking that it already has the proper size and type. And while the newly allocated arrays are always continuous, we still check the destination array, because
|
||||
:func:`create` does not always allocate a new matrix.
|
||||
:cpp:func:`Mat::create` for the destination array instead of checking that it already has the proper size and type. And while the newly allocated arrays are always continuous, we still check the destination array, because
|
||||
:cpp:func:`create` does not always allocate a new matrix.
|
||||
|
||||
.. index:: Mat::elemSize
|
||||
|
||||
@@ -1831,7 +1827,7 @@ Also, note that there is another OpenCV idiom in this function: a call of
|
||||
|
||||
Mat::elemSize
|
||||
-----------------
|
||||
.. cpp:function:: size_t Mat::elemSize(void) const
|
||||
.. cpp:function:: size_t Mat::elemSize() const
|
||||
|
||||
Returns the matrix element size in bytes.
|
||||
|
||||
@@ -1843,7 +1839,7 @@ The method returns the matrix element size in bytes. For example, if the matrix
|
||||
|
||||
Mat::elemSize1
|
||||
------------------
|
||||
.. cpp:function:: size_t Mat::elemSize1(void) const
|
||||
.. cpp:function:: size_t Mat::elemSize1() const
|
||||
|
||||
Returns the size of each matrix element channel in bytes.
|
||||
|
||||
@@ -1855,7 +1851,7 @@ The method returns the matrix element channel size in bytes, that is, it ignores
|
||||
|
||||
Mat::type
|
||||
-------------
|
||||
.. cpp:function:: int Mat::type(void) const
|
||||
.. cpp:function:: int Mat::type() const
|
||||
|
||||
Returns a matrix element type.
|
||||
|
||||
@@ -1867,7 +1863,7 @@ The method returns a matrix element type. This is an id, compatible with the ``C
|
||||
|
||||
Mat::depth
|
||||
--------------
|
||||
.. cpp:function:: int Mat::depth(void) const
|
||||
.. cpp:function:: int Mat::depth() const
|
||||
|
||||
Returns the matrix element depth.
|
||||
|
||||
@@ -1893,7 +1889,7 @@ The method returns the matrix element depth id (the type of each individual chan
|
||||
|
||||
Mat::channels
|
||||
-----------------
|
||||
.. cpp:function:: int Mat::channels(void) const
|
||||
.. cpp:function:: int Mat::channels() const
|
||||
|
||||
Returns the number of matrix channels.
|
||||
|
||||
@@ -1905,20 +1901,18 @@ The method returns the number of matrix channels.
|
||||
|
||||
Mat::step1
|
||||
--------------
|
||||
.. cpp:function:: size_t Mat::step1(void) const
|
||||
.. cpp:function:: size_t Mat::step1() const
|
||||
|
||||
Returns a normalized step.
|
||||
|
||||
The method returns a matrix step divided by
|
||||
:func:`Mat::elemSize1()` . It can be useful to quickly access an arbitrary matrix element.
|
||||
:cpp:func:`Mat::elemSize1()` . It can be useful to quickly access an arbitrary matrix element.
|
||||
|
||||
.. index:: Mat::size
|
||||
|
||||
.. _Mat::size:
|
||||
|
||||
Mat::size
|
||||
-------------
|
||||
.. cpp:function:: Size Mat::size(void) const
|
||||
.. cpp:function:: Size Mat::size() const
|
||||
|
||||
Returns a matrix size.
|
||||
|
||||
@@ -1930,7 +1924,7 @@ The method returns a matrix size: ``Size(cols, rows)`` .
|
||||
|
||||
Mat::empty
|
||||
--------------
|
||||
.. cpp:function:: bool Mat::empty(void) const
|
||||
.. cpp:function:: bool Mat::empty() const
|
||||
|
||||
Returns ``true`` if the array has no elemens.
|
||||
|
||||
@@ -1942,20 +1936,20 @@ The method returns ``true`` if ``Mat::total()`` is 0 or if ``Mat::data`` is NULL
|
||||
|
||||
Mat::ptr
|
||||
------------
|
||||
.. c:function:: uchar* Mat::ptr(int i=0)
|
||||
.. cpp:function:: uchar* Mat::ptr(int i=0)
|
||||
|
||||
.. c:function:: const uchar* Mat::ptr(int i=0) const
|
||||
.. cpp:function:: const uchar* Mat::ptr(int i=0) const
|
||||
|
||||
.. c:function:: template<typename _Tp> _Tp* Mat::ptr(int i=0)
|
||||
.. cpp:function:: template<typename _Tp> _Tp* Mat::ptr(int i=0)
|
||||
|
||||
.. c:function:: template<typename _Tp> const _Tp* Mat::ptr(int i=0) const
|
||||
.. cpp:function:: template<typename _Tp> const _Tp* Mat::ptr(int i=0) const
|
||||
|
||||
Returns a pointer to the specified matrix row.
|
||||
|
||||
:param i: A 0-based row index.
|
||||
|
||||
The methods return ``uchar*`` or typed pointer to the specified matrix row. See the sample in
|
||||
:func:`Mat::isContinuous` () to know how to use these methods.
|
||||
:cpp:func:`Mat::isContinuous` () to know how to use these methods.
|
||||
|
||||
.. index:: Mat::at
|
||||
|
||||
@@ -1963,25 +1957,25 @@ The methods return ``uchar*`` or typed pointer to the specified matrix row. See
|
||||
|
||||
Mat::at
|
||||
-----------
|
||||
.. c:function:: template<typename T> T& Mat::at(int i) const
|
||||
.. cpp:function:: template<typename T> T& Mat::at(int i) const
|
||||
|
||||
.. c:function:: template<typename T> const T& Mat::at(int i) const
|
||||
.. cpp:function:: template<typename T> const T& Mat::at(int i) const
|
||||
|
||||
.. c:function:: template<typename T> T& Mat::at(int i, int j)
|
||||
.. cpp:function:: template<typename T> T& Mat::at(int i, int j)
|
||||
|
||||
.. c:function:: template<typename T> const T& Mat::at(int i, int j) const
|
||||
.. cpp:function:: template<typename T> const T& Mat::at(int i, int j) const
|
||||
|
||||
.. c:function:: template<typename T> T& Mat::at(Point pt)
|
||||
.. cpp:function:: template<typename T> T& Mat::at(Point pt)
|
||||
|
||||
.. c:function:: template<typename T> const T& Mat::at(Point pt) const
|
||||
.. cpp:function:: template<typename T> const T& Mat::at(Point pt) const
|
||||
|
||||
.. c:function:: template<typename T> T& Mat::at(int i, int j, int k)
|
||||
.. cpp:function:: template<typename T> T& Mat::at(int i, int j, int k)
|
||||
|
||||
.. c:function:: template<typename T> const T& Mat::at(int i, int j, int k) const
|
||||
.. cpp:function:: template<typename T> const T& Mat::at(int i, int j, int k) const
|
||||
|
||||
.. c:function:: template<typename T> T& Mat::at(const int* idx)
|
||||
.. cpp:function:: template<typename T> T& Mat::at(const int* idx)
|
||||
|
||||
.. c:function:: template<typename T> const T& Mat::at(const int* idx) const
|
||||
.. cpp:function:: template<typename T> const T& Mat::at(const int* idx) const
|
||||
|
||||
Returns a reference to the specified array element.
|
||||
|
||||
@@ -2009,7 +2003,7 @@ Here is an example of initialization of a Hilbert matrix: ::
|
||||
|
||||
Mat::begin
|
||||
--------------
|
||||
.. c:function:: template<typename _Tp> MatIterator_<_Tp> Mat::begin() template<typename _Tp> MatConstIterator_<_Tp> Mat::begin() const
|
||||
.. cpp:function:: template<typename _Tp> MatIterator_<_Tp> Mat::begin() template<typename _Tp> MatConstIterator_<_Tp> Mat::begin() const
|
||||
|
||||
Returns the matrix iterator and sets it to the first matrix element..
|
||||
|
||||
@@ -2051,7 +2045,8 @@ The methods return the matrix read-only or read-write iterators. The use of matr
|
||||
|
||||
Mat::end
|
||||
------------
|
||||
.. c:function:: template<typename _Tp> MatIterator_<_Tp> Mat::end() template<typename _Tp> MatConstIterator_<_Tp> Mat::end() const
|
||||
.. cpp:function:: template<typename _Tp> MatIterator_<_Tp> Mat::end()
|
||||
.. cpp:function:: template<typename _Tp> MatConstIterator_<_Tp> Mat::end() const
|
||||
|
||||
Returns the matrix iterator and sets it to the after-last matrix element.
|
||||
|
||||
@@ -2178,11 +2173,13 @@ Here is an example of how you can compute a normalized and thresholded 3D color
|
||||
}
|
||||
|
||||
|
||||
.. _SparseMat:
|
||||
.. index:: SparseMat
|
||||
|
||||
SparseMat
|
||||
---------
|
||||
|
||||
.. cpp:class:: SparseMat
|
||||
|
||||
Sparse n-dimensional array. ::
|
||||
|
||||
class SparseMat
|
||||
@@ -2459,9 +2456,13 @@ The class ``SparseMat`` represents multi-dimensional sparse numerical arrays. Su
|
||||
|
||||
..
|
||||
|
||||
.. index:: SparseMat\_
|
||||
|
||||
SparseMat\_
|
||||
-----------
|
||||
|
||||
.. cpp:class:: SparseMat
|
||||
|
||||
Template sparse n-dimensional array class derived from
|
||||
:ref:`SparseMat` ::
|
||||
|
||||
|
@@ -10,7 +10,7 @@ Clustering
|
||||
kmeans
|
||||
------
|
||||
|
||||
.. c:function:: double kmeans( const Mat& samples, int clusterCount, Mat& labels, TermCriteria termcrit, int attempts, int flags, Mat* centers )
|
||||
.. cpp:function:: double kmeans( InputArray samples, int clusterCount, InputOutputArray labels, TermCriteria termcrit, int attempts, int flags, OutputArray centers=None() )
|
||||
|
||||
Finds centers of clusters and groups input samples around the clusters.
|
||||
|
||||
@@ -57,9 +57,9 @@ attempts to 1, initialize labels each time using a custom algorithm, pass them w
|
||||
|
||||
partition
|
||||
-------------
|
||||
.. c:function:: template<typename _Tp, class _EqPredicate> int
|
||||
.. cpp:function:: template<typename _Tp, class _EqPredicate> int
|
||||
|
||||
.. c:function:: partition( const vector<_Tp>& vec, vector<int>& labels, _EqPredicate predicate=_EqPredicate())
|
||||
.. cpp:function:: partition( const vector<_Tp>& vec, vector<int>& labels, _EqPredicate predicate=_EqPredicate())
|
||||
|
||||
Splits an element set into equivalency classes.
|
||||
|
||||
|
@@ -10,7 +10,7 @@ with ``CV_RGB`` or the :ref:`Scalar` constructor
|
||||
) for color
|
||||
images and brightness for grayscale images. For color images, the channel ordering
|
||||
is normally *Blue, Green, Red*.
|
||||
This is what :func:`imshow`, :func:`imread`, and :func:`imwrite` expect.
|
||||
This is what :cpp:func:`imshow`, :cpp:func:`imread`, and :cpp:func:`imwrite` expect.
|
||||
So, if you form a color using the
|
||||
:ref:`Scalar` constructor, it should look like:
|
||||
|
||||
@@ -19,7 +19,7 @@ So, if you form a color using the
|
||||
\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 used color space. The whole image can be converted from BGR to RGB or to a different color space using
|
||||
:func:`cvtColor` .
|
||||
:cpp: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. This means that 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 when rendering antialiased shapes.
|
||||
@@ -32,7 +32,7 @@ The functions do not support alpha-transparency when the target image is 4-chann
|
||||
|
||||
circle
|
||||
----------
|
||||
.. c:function:: void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
|
||||
.. cpp:function:: void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
|
||||
|
||||
Draws a circle.
|
||||
|
||||
@@ -46,7 +46,7 @@ circle
|
||||
|
||||
: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 lineType: Type of the circle boundary. See :cpp:func:`line` description.
|
||||
|
||||
:param shift: Number of fractional bits in the center's coordinates and in the radius value.
|
||||
|
||||
@@ -56,9 +56,9 @@ The function ``circle`` draws a simple or filled circle with a given center and
|
||||
|
||||
clipLine
|
||||
------------
|
||||
.. c:function:: bool clipLine(Size imgSize, Point& pt1, Point& pt2)
|
||||
.. cpp:function:: bool clipLine(Size imgSize, Point& pt1, Point& pt2)
|
||||
|
||||
.. c:function:: bool clipLine(Rect imgRect, Point& pt1, Point& pt2)
|
||||
.. cpp:function:: bool clipLine(Rect imgRect, Point& pt1, Point& pt2)
|
||||
|
||||
Clips the line against the image rectangle.
|
||||
|
||||
@@ -77,9 +77,9 @@ They return ``false`` if the line segment is completely outside the rectangle. O
|
||||
|
||||
ellipse
|
||||
-----------
|
||||
.. c:function:: 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)
|
||||
.. cpp:function:: 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)
|
||||
|
||||
.. c:function:: void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, int thickness=1, int lineType=8)
|
||||
.. cpp:function:: void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, int thickness=1, int lineType=8)
|
||||
|
||||
Draws a simple or thick elliptic arc or fills an ellipse sector.
|
||||
|
||||
@@ -101,15 +101,15 @@ ellipse
|
||||
|
||||
: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 lineType: Type of the ellipse boundary. See :cpp:func:`line` description.
|
||||
|
||||
:param shift: Number of fractional bits in the center's 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.
|
||||
:cpp:func:`ellipse2Poly` and then render it with
|
||||
:cpp:func:`polylines` or fill it with
|
||||
:cpp: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.
|
||||
|
||||
**Figure 1. Parameters of Elliptic Arc**
|
||||
|
||||
@@ -119,15 +119,15 @@ A piecewise-linear curve is used to approximate the elliptic arc boundary. If yo
|
||||
|
||||
ellipse2Poly
|
||||
----------------
|
||||
.. c:function:: void ellipse2Poly( Point center, Size axes, int angle, int startAngle, int endAngle, int delta, vector<Point>& pts )
|
||||
.. cpp:function:: 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` for details.
|
||||
:param axes: Half-sizes of the arc. See :cpp:func:`ellipse` for details.
|
||||
|
||||
:param angle: Rotation angle of the ellipse in degrees. See :func:`ellipse` for details.
|
||||
:param angle: Rotation angle of the ellipse in degrees. See :cpp:func:`ellipse` for details.
|
||||
|
||||
:param startAngle: Starting angle of the elliptic arc in degrees.
|
||||
|
||||
@@ -138,13 +138,13 @@ ellipse2Poly
|
||||
:param pts: 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` .
|
||||
:cpp:func:`ellipse` .
|
||||
|
||||
.. index:: fillConvexPoly
|
||||
|
||||
fillConvexPoly
|
||||
------------------
|
||||
.. c:function:: void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0)
|
||||
.. cpp:function:: void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0)
|
||||
|
||||
Fills a convex polygon.
|
||||
|
||||
@@ -156,7 +156,7 @@ fillConvexPoly
|
||||
|
||||
:param color: Polygon color.
|
||||
|
||||
:param lineType: Type of the polygon boundaries. See :func:`line` description.
|
||||
:param lineType: Type of the polygon boundaries. See :cpp:func:`line` description.
|
||||
|
||||
:param shift: Number of fractional bits in the vertex coordinates.
|
||||
|
||||
@@ -168,7 +168,7 @@ that is, a polygon whose contour intersects every horizontal line (scan line) tw
|
||||
|
||||
fillPoly
|
||||
------------
|
||||
.. c:function:: void fillPoly(Mat& img, const Point** pts, const int* npts, int ncontours, const Scalar& color, int lineType=8, int shift=0, Point offset=Point() )
|
||||
.. cpp:function:: 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.
|
||||
|
||||
@@ -182,7 +182,7 @@ fillPoly
|
||||
|
||||
:param color: Polygon color.
|
||||
|
||||
:param lineType: Type of the polygon boundaries. See :func:`line` description.
|
||||
:param lineType: Type of the polygon boundaries. See :cpp:func:`line` description.
|
||||
|
||||
:param shift: Number of fractional bits in the vertex coordinates.
|
||||
|
||||
@@ -193,17 +193,17 @@ areas with holes, contours with self-intersections (some of thier parts), and so
|
||||
|
||||
getTextSize
|
||||
---------------
|
||||
.. c:function:: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine)
|
||||
.. cpp:function:: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine)
|
||||
|
||||
Calculates the width and height of a text string.
|
||||
|
||||
:param text: Input text string.
|
||||
|
||||
:param fontFace: Font to use. See :func:`putText` for details.
|
||||
:param fontFace: Font to use. See :cpp:func:`putText` for details.
|
||||
|
||||
:param fontScale: Font scale. See :func:`putText` for details.
|
||||
:param fontScale: Font scale. See :cpp:func:`putText` for details.
|
||||
|
||||
:param thickness: Thickness of lines used to render the text. See :func:`putText` for details.
|
||||
:param thickness: Thickness of lines used to render the text. See :cpp:func:`putText` for details.
|
||||
|
||||
:param baseLine: Output parameter - y-coordinate of the baseline relative to the bottom-most text point.
|
||||
|
||||
@@ -244,7 +244,7 @@ That is, the following code renders some text, the tight box surrounding it, and
|
||||
|
||||
line
|
||||
--------
|
||||
.. c:function:: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
|
||||
.. cpp:function:: 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.
|
||||
|
||||
@@ -321,7 +321,9 @@ The number of pixels along the line is stored in ``LineIterator::count`` . ::
|
||||
|
||||
rectangle
|
||||
-------------
|
||||
.. c:function:: void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
|
||||
.. cpp:function:: void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
|
||||
|
||||
.. cpp:function:: void rectangle(Mat& img, Rect r, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
|
||||
|
||||
Draws a simple, thick, or filled up-right rectangle.
|
||||
|
||||
@@ -330,22 +332,24 @@ rectangle
|
||||
:param pt1: One of the rectangle's vertices.
|
||||
|
||||
:param pt2: Opposite to ``pt1`` rectangle vertex.
|
||||
|
||||
:param r: Alternative specification of the drawn rectangle
|
||||
|
||||
:param color: Rectangle color or brightness (grayscale image).
|
||||
|
||||
:param thickness: Thickness of lines that make up the rectangle. Negative values, like ``CV_FILLED`` , mean that the function has to draw a filled rectangle.
|
||||
|
||||
:param lineType: Type of the line. See :func:`line` description.
|
||||
:param lineType: Type of the line. See :cpp:func:`line` description.
|
||||
|
||||
:param shift: Number of fractional bits in the point coordinates.
|
||||
|
||||
The function ``rectangle`` draws a rectangle outline or a filled rectangle whose two opposite corners are ``pt1`` and ``pt2`` .
|
||||
The function ``rectangle`` draws a rectangle outline or a filled rectangle whose two opposite corners are ``pt1`` and ``pt2``, or ``r.tl()`` and ``r.br()-Point(1,1)``.
|
||||
|
||||
.. index:: polylines
|
||||
|
||||
polylines
|
||||
-------------
|
||||
.. c:function:: 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 )
|
||||
.. cpp:function:: 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.
|
||||
|
||||
@@ -363,7 +367,7 @@ polylines
|
||||
|
||||
:param thickness: Thickness of the polyline edges.
|
||||
|
||||
:param lineType: Type of the line segments. See :func:`line` description.
|
||||
:param lineType: Type of the line segments. See :cpp:func:`line` description.
|
||||
|
||||
:param shift: Number of fractional bits in the vertex coordinates.
|
||||
|
||||
@@ -373,7 +377,7 @@ The function ``polylines`` draws one or more polygonal curves.
|
||||
|
||||
putText
|
||||
-----------
|
||||
.. c:function:: void putText( Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
|
||||
.. cpp:function:: 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.
|
||||
|
||||
@@ -399,5 +403,5 @@ putText
|
||||
The function ``putText`` renders the specified text string in the image.
|
||||
Symbols that cannot be rendered using the specified font are
|
||||
replaced by question marks. See
|
||||
:func:`getTextSize` for a text rendering code example.
|
||||
:cpp:func:`getTextSize` for a text rendering code example.
|
||||
|
||||
|
@@ -9,12 +9,12 @@ OpenCV (Open Source Computer Vision Library: http://opencv.willowgarage.com/wiki
|
||||
OpenCV has a modular structure, which means that the package includes several shared or static libraries. The following modules are available:
|
||||
|
||||
* **core** - a compact module defining basic data structures, including the dense multi-dimensional array ``Mat`` and basic functions used by all other modules.
|
||||
* **imgproc** - an image processing module that includes linear and non-linear image filtering, geometrical image transformations (resize, affine and perspective wraping, generic table-based remapping), color space conversion, histograms, and so on.
|
||||
* **imgproc** - an image processing module that includes linear and non-linear image filtering, geometrical image transformations (resize, affine and perspective warping, generic table-based remapping), color space conversion, histograms, and so on.
|
||||
* **video** - a video analysis module that includes motion estimation, background subtraction, and object tracking algorithms.
|
||||
* **calib3d** - basic multiple-view geometry algorithms, single and stereo camera calibration, object pose estimation, stereo correspondence algorithms, and elements of 3D reconstruction.
|
||||
* **features2d** - salient feature detectors, descriptors, and descriptor matchers.
|
||||
* **objdetect** - detection of objects and instances of the predefined classes (for example, faces, eyes, mugs, people, cars, and so on).
|
||||
* **highgui** - an easy-to-use interface to video capturing, image and video codecs APIs, as well as simple UI capabilities.
|
||||
* **highgui** - an easy-to-use interface to video capturing, image and video codecs, as well as simple UI capabilities.
|
||||
* **gpu** - GPU-accelerated algorithms from different OpenCV modules.
|
||||
* ... some other helper modules, such as FLANN and Google test wrappers, Python bindings, and others.
|
||||
|
||||
@@ -56,7 +56,7 @@ Automatic Memory Management
|
||||
|
||||
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. This means that the destructors do not always deallocate the buffers as in case of ``Mat``. They take into account possible data sharing. A destructor decrements the reference counter associated with the matrix data buffer. 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 a ``Mat`` instance is copied, no actual data is really copied. Instead, the counter associated with its reference is incremented to memorize that there is another owner of the same data. There is also the ``Mat::clone`` method that creates a full copy of the matrix data. See the example below: ::
|
||||
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. This means that the destructors do not always deallocate the buffers as in case of ``Mat``. They take into account possible data sharing. A destructor decrements the reference counter associated with the matrix data buffer. 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 a ``Mat`` instance is copied, no actual data is really copied. Instead, the reference counter is incremented to memorize that there is another owner of the same data. There is also the ``Mat::clone`` method that creates a full copy of the matrix data. See the example below: ::
|
||||
|
||||
// create a big 8Mb matrix
|
||||
Mat A(1000, 1000, CV_64F);
|
||||
@@ -100,7 +100,7 @@ description for details.
|
||||
Automatic Allocation of the Output Data
|
||||
---------------------------------------
|
||||
|
||||
OpenCV deallocates the memory automatically, as well as automatically allocates the memory for output function parameters most of the time. So, if a function has one or more input arrays (``cv::Mat`` instances) and some output arrays, the output arrays are automatically allocated or reallocated. The size and type of the output arrays are determined from the size and type of input arrays. If needed, the functions take extra parameters that help to figure out the output array properties.
|
||||
OpenCV deallocates the memory automatically, as well as automatically allocates the memory for output function parameters most of the time. So, if a function has one or more input arrays (``cv::Mat`` instances) and some output arrays, the output arrays are automatically allocated or reallocated. The size and type of the output arrays are determined from the size and type of input arrays. If needed, the functions take extra parameters that help to figure out the output array properties.
|
||||
|
||||
Example: ::
|
||||
|
||||
@@ -152,9 +152,9 @@ where ``cv::uchar`` is an OpenCV 8-bit unsigned integer type. In the optimized S
|
||||
Fixed Pixel Types. Limited Use of Templates
|
||||
-------------------------------------------
|
||||
|
||||
Templates is a great feature of C++ that enables implementation of very powerful, efficient and yet safe data structures and algorithms. However, the extensive use of templates may dramatically increase compilation time and code size. Besides, it is difficult to separate an interface and implementation when templates are used exclusively. This could be fine for basic algorithms but not good for computer vision libraries where a single algorithm may span a thousand lines of code. Because of this and also to simplify development of bindings for other languages, like Python*, Java*, Matlab* that do not have templates at all or have limited template capabilities, the current OpenCV implementation is based on polymorphism and runtime dispatching over templates. In those places where runtime dispatching would be too slow (like pixel access operators), impossible (generic ``Ptr<>`` implementation), or just very inconvenient (``saturate_cast<>()``) the current implementation introduces small template classes, methods, and functions. Anywhere else in this implementation templates are not used.
|
||||
Templates is a great feature of C++ that enables implementation of very powerful, efficient and yet safe data structures and algorithms. However, the extensive use of templates may dramatically increase compilation time and code size. Besides, it is difficult to separate an interface and implementation when templates are used exclusively. This could be fine for basic algorithms but not good for computer vision libraries where a single algorithm may span thousands lines of code. Because of this and also to simplify development of bindings for other languages, like Python, Java, Matlab that do not have templates at all or have limited template capabilities, the current OpenCV implementation is based on polymorphism and runtime dispatching over templates. In those places where runtime dispatching would be too slow (like pixel access operators), impossible (generic ``Ptr<>`` implementation), or just very inconvenient (``saturate_cast<>()``) the current implementation introduces small template classes, methods, and functions. Anywhere else in the current OpenCV version the use of templates is limited.
|
||||
|
||||
There is a limited fixed set of primitive data types the library can operate on. That is, array elements should have one of the following types:
|
||||
Consequently, there is a limited fixed set of primitive data types the library can operate on. That is, array elements should have one of the following types:
|
||||
|
||||
* 8-bit unsigned integer (uchar)
|
||||
* 8-bit signed integer (schar)
|
||||
@@ -163,7 +163,7 @@ There is a limited fixed set of primitive data types the library can operate on.
|
||||
* 32-bit signed integer (int)
|
||||
* 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). An array whose elements are such tuples, are called multi-channel arrays, as opposite to the single-channel arrays, whose elements are scalar values. The maximum possible number of channels is defined by the ``CV_CN_MAX`` constant, which is not smaller than 32.
|
||||
* a tuple of several elements where all elements have the same type (one of the above). An array whose elements are such tuples, are called multi-channel arrays, as opposite to the single-channel arrays, whose elements are scalar values. The maximum possible number of channels is defined by the ``CV_CN_MAX`` constant, which is currently set to 512.
|
||||
|
||||
For these basic types, the following enumeration is applied::
|
||||
|
||||
@@ -190,12 +190,17 @@ Arrays with more complex elements cannot be constructed or processed using OpenC
|
||||
|
||||
* The face detection algorithm only works with 8-bit grayscale or color images.
|
||||
* Linear algebra functions and most of the machine learning algorithms work with floating-point arrays only.
|
||||
* Basic functions, such as ``cv::add``, support all types, except for ``CV_8SC(n)``.
|
||||
* Basic functions, such as ``cv::add``, support all types.
|
||||
* Color space conversion functions support 8-bit unsigned, 16-bit unsigned, and 32-bit floating-point types.
|
||||
|
||||
The subset of supported types for each functions has been defined from practical needs. All this information about supported types can be put together into a special table. In different implementations of the standard, the tables may look differently. For example, on embedded platforms the double-precision floating-point type (``CV_64F``) may be unavailable.
|
||||
The subset of supported types for each function has been defined from practical needs and could be extended in future based on user requests.
|
||||
|
||||
|
||||
InputArray and OutputArray
|
||||
--------------------------
|
||||
|
||||
Many OpenCV functions process dense 2-dimensional or multi-dimensional numerical arrays. Usually, such functions take cpp:class:`Mat` as parameters, but in some cases it's more convenient to use ``std::vector<>`` (for a point set, for example) or ``Matx<>`` (for 3x3 homography matrix and such). To avoid many duplicates in the API, special "proxy" classes have been introduced. The base "proxy" class is ``InputArray``. It is used for passing read-only arrays on a function input. The derived from ``InputArray`` class ``OutputArray`` is used to specify an output array for a function. Normally, you should not care of those intermediate types (and you should not declare variables of those types explicitly) - it will all just work automatically. You can assume that instead of ``InputArray``/``OutputArray`` you can always use ``Mat``, ``std::vector<>``, ``Matx<>``, ``Vec<>`` or ``Scalar``. When a function has an optional input or output array, and you do not have or do not want one, pass ``cv::None()``.
|
||||
|
||||
Error Handling
|
||||
--------------
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ Utility and System Functions and Macros
|
||||
|
||||
alignPtr
|
||||
------------
|
||||
.. c:function:: template<typename _Tp> _Tp* alignPtr(_Tp* ptr, int n=sizeof(_Tp))
|
||||
.. cpp:function:: template<typename _Tp> _Tp* alignPtr(_Tp* ptr, int n=sizeof(_Tp))
|
||||
|
||||
Aligns a pointer to the specified number of bytes.
|
||||
|
||||
@@ -25,7 +25,7 @@ The function returns the aligned pointer of the same type as the input pointer:
|
||||
|
||||
alignSize
|
||||
-------------
|
||||
.. c:function:: size_t alignSize(size_t sz, int n)
|
||||
.. cpp:function:: size_t alignSize(size_t sz, int n)
|
||||
|
||||
Aligns a buffer size to the specified number of bytes.
|
||||
|
||||
@@ -43,7 +43,7 @@ The function returns the minimum number that is greater or equal to ``sz`` and i
|
||||
|
||||
allocate
|
||||
------------
|
||||
.. c:function:: template<typename _Tp> _Tp* allocate(size_t n)
|
||||
.. cpp:function:: template<typename _Tp> _Tp* allocate(size_t n)
|
||||
|
||||
Allocates an array of elements.
|
||||
|
||||
@@ -55,7 +55,7 @@ The generic function ``allocate`` allocates a buffer for the specified number of
|
||||
|
||||
deallocate
|
||||
--------------
|
||||
.. c:function:: template<typename _Tp> void deallocate(_Tp* ptr, size_t n)
|
||||
.. cpp:function:: template<typename _Tp> void deallocate(_Tp* ptr, size_t n)
|
||||
|
||||
Deallocates an array of elements.
|
||||
|
||||
@@ -64,8 +64,8 @@ deallocate
|
||||
:param n: 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` .
|
||||
:cpp:func:`allocate` . The number of elements must match the number passed to
|
||||
:cpp:func:`allocate` .
|
||||
|
||||
.. index:: CV_Assert
|
||||
|
||||
@@ -73,7 +73,7 @@ The generic function ``deallocate`` deallocates the buffer allocated with
|
||||
|
||||
CV_Assert
|
||||
---------
|
||||
.. c:function:: CV_Assert(expr)
|
||||
.. cpp:function:: CV_Assert(expr)
|
||||
|
||||
Checks a condition at runtime. ::
|
||||
|
||||
@@ -84,17 +84,17 @@ CV_Assert
|
||||
:param expr: Expression to check.
|
||||
|
||||
The macros ``CV_Assert`` and ``CV_DbgAssert`` evaluate the specified expression. 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.
|
||||
:cpp: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
|
||||
|
||||
error
|
||||
---------
|
||||
.. c:function:: void error( const Exception\& exc )
|
||||
.. cpp:function:: void error( const Exception\& exc )
|
||||
|
||||
.. c:function:: \#define CV_Error( code, msg ) <...>
|
||||
.. cpp:function:: \#define CV_Error( code, msg ) <...>
|
||||
|
||||
.. c:function:: \#define CV_Error_( code, args ) <...>
|
||||
.. cpp:function:: \#define CV_Error_( code, args ) <...>
|
||||
|
||||
Signals an error and raises an exception.
|
||||
|
||||
@@ -148,13 +148,13 @@ Exception class passed to 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` .
|
||||
:cpp:func:`error` .
|
||||
|
||||
.. index:: fastMalloc
|
||||
|
||||
fastMalloc
|
||||
--------------
|
||||
.. c:function:: void* fastMalloc(size_t size)
|
||||
.. cpp:function:: void* fastMalloc(size_t size)
|
||||
|
||||
Allocates an aligned memory buffer.
|
||||
|
||||
@@ -166,74 +166,74 @@ The function allocates the buffer of the specified size and returns it. When the
|
||||
|
||||
fastFree
|
||||
------------
|
||||
.. c:function:: void fastFree(void* ptr)
|
||||
.. cpp:function:: void fastFree(void* ptr)
|
||||
|
||||
Deallocates a memory buffer.
|
||||
|
||||
:param ptr: Pointer to the allocated buffer.
|
||||
|
||||
The function deallocates the buffer allocated with
|
||||
:func:`fastMalloc` .
|
||||
:cpp:func:`fastMalloc` .
|
||||
If NULL pointer is passed, the function does nothing.
|
||||
|
||||
.. index:: format
|
||||
|
||||
format
|
||||
----------
|
||||
.. c:function:: string format( const char* fmt, ... )
|
||||
.. cpp:function:: string format( const char* fmt, ... )
|
||||
|
||||
Returns a text string formatted using the ``printf`` -like expression.
|
||||
|
||||
:param fmt: ``printf`` -compatible formatting specifiers.
|
||||
|
||||
The function acts like ``sprintf`` but forms and returns an STL string. It can be used to form an error message in the
|
||||
:func:`Exception` constructor.
|
||||
:cpp:func:`Exception` constructor.
|
||||
|
||||
.. index:: getNumThreads
|
||||
|
||||
getNumThreads
|
||||
-----------------
|
||||
.. c:function:: int getNumThreads()
|
||||
.. cpp:function:: 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`
|
||||
:cpp:func:`setNumThreads`,
|
||||
:cpp:func:`getThreadNum`
|
||||
|
||||
.. index:: getThreadNum
|
||||
|
||||
getThreadNum
|
||||
----------------
|
||||
.. c:function:: int getThreadNum()
|
||||
.. cpp:function:: int getThreadNum()
|
||||
|
||||
Returns the index of the currently executed thread.
|
||||
|
||||
The function returns a 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` .
|
||||
:cpp:func:`setNumThreads`,
|
||||
:cpp:func:`getNumThreads` .
|
||||
|
||||
.. index:: getTickCount
|
||||
|
||||
getTickCount
|
||||
----------------
|
||||
.. c:function:: int64 getTickCount()
|
||||
.. cpp:function:: int64 getTickCount()
|
||||
|
||||
Returns the number of ticks.
|
||||
|
||||
The function returns the number of ticks after the certain event (for example, 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.
|
||||
:cpp: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
|
||||
|
||||
getTickFrequency
|
||||
--------------------
|
||||
.. c:function:: double getTickFrequency()
|
||||
.. cpp:function:: double getTickFrequency()
|
||||
|
||||
Returns the number of ticks per second.
|
||||
|
||||
@@ -248,7 +248,7 @@ That is, the following code computes the execution time in seconds: ::
|
||||
|
||||
setNumThreads
|
||||
-----------------
|
||||
.. c:function:: void setNumThreads(int nthreads)
|
||||
.. cpp:function:: void setNumThreads(int nthreads)
|
||||
|
||||
Sets the number of threads used by OpenCV.
|
||||
|
||||
@@ -257,5 +257,5 @@ setNumThreads
|
||||
The function sets the number of threads used by OpenCV in parallel OpenMP regions. If ``nthreads=0`` , the function uses the default number of threads that is usually equal to the number of the processing cores.
|
||||
|
||||
See Also:
|
||||
:func:`getNumThreads`,
|
||||
:func:`getThreadNum`
|
||||
:cpp:func:`getNumThreads`,
|
||||
:cpp:func:`getThreadNum`
|
Reference in New Issue
Block a user