s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1} \begin{bmatrix} r_{11} & r_{12} & r_{13} & t_1 \\ r_{21} & r_{22} & r_{23} & t_2 \\ r_{31} & r_{32} & r_{33} & t_3 \end{bmatrix} \begin{bmatrix} X \\ Y \\ Z \\ 1 \end{bmatrix}
s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}
\begin{bmatrix}
r_{11} & r_{12} & r_{13} & t_1 \\
r_{21} & r_{22} & r_{23} & t_2 \\
r_{31} & r_{32} & r_{33} & t_3
\end{bmatrix}
\begin{bmatrix}
X \\
Y \\
Z \\
1
\end{bmatrix}
Where
:math:`(X, Y, Z)` are the coordinates of a 3D point in the world
...
...
@@ -45,7 +57,13 @@ to the following (when
.. math::
\begin{array}{l} \vecthree{x}{y}{z} = R \vecthree{X}{Y}{Z} + t \\ x' = x/z \\ y' = y/z \\ u = f_x*x' + c_x \\ v = f_y*y' + c_y \end{array}
\begin{array}{l}
\vecthree{x}{y}{z} = R \vecthree{X}{Y}{Z} + t \\
x' = x/z \\
y' = y/z \\
u = f_x*x' + c_x \\
v = f_y*y' + c_y
\end{array}
Real lenses usually have some distortion, mostly
radial distortion and slight tangential distortion. So, the above model
...
...
@@ -207,7 +225,7 @@ cv::composeRT
:param tvec3: The output translation vector of the superposition
:param d??d??: The optional output derivatives of ``rvec3`` or ``tvec3`` w.r.t. ``rvec?`` or ``tvec?``
:param d*d*: The optional output derivatives of ``rvec3`` or ``tvec3`` w.r.t. ``rvec?`` or ``tvec?``
The functions compute:
...
...
@@ -1192,7 +1210,7 @@ The matrices, together with ``R1`` and ``R2`` , can then be passed to
Below is the screenshot from ``stereo_calib.cpp`` sample. Some red horizontal lines, as you can see, pass through the corresponding image regions, i.e. the images are well rectified (which is what most stereo correspondence algorithms rely on). The green rectangles are ``roi1`` and ``roi2`` - indeed, their interior are all valid pixels.
@@ -455,16 +455,14 @@ Template class for short numerical vectors ::
typedef Vec<double, 3> Vec3d;
typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> Vec6d;
.. ``Vec`` is a partial case of ``Matx`` . It is possible to convert ``Vec<T,2>`` to/from ``Point_``,``Vec<T,3>`` to/from ``Point3_`` , and ``Vec<T,4>`` to
:ref:`CvScalar` or
:ref:`Scalar` . The elements of ``Vec`` are accessed using ``operator[]`` . All the expected vector operations are implemented too:
``Vec`` is a partial case of ``Matx`` . It is possible to convert ``Vec<T,2>`` to/from ``Point_``,``Vec<T,3>`` to/from ``Point3_`` , and ``Vec<T,4>`` to :ref:`CvScalar` or :ref:`Scalar`. The elements of ``Vec`` are accessed using ``operator[]``. All the expected vector operations are implemented too:
*
:math:`\texttt{v1} = \texttt{v2} \pm \texttt{v3}`, :math:`\texttt{v1} = \texttt{v2} * \alpha`, :math:`\texttt{v1} = \alpha * \texttt{v2}` (plus the corresponding augmenting operations; note that these operations apply
The class ``Vec`` is commonly used to describe pixel types of multi-channel arrays, see ``Mat_`` description.
...
...
@@ -742,10 +740,7 @@ There are many different ways to create ``Mat`` object. Here are the some popula
..
Thanks to the additional ``datastart`` and ``dataend`` members, it is possible to
compute the relative sub-array position in the main
*"container"*
array using ``locateROI()`` :
Thanks to the additional ``datastart`` and ``dataend`` members, it is possible to compute the relative sub-array position in the main *"container"* array using ``locateROI()``:
::
...
...
@@ -792,17 +787,9 @@ There are many different ways to create ``Mat`` object. Here are the some popula
..
partial yet very common cases of this "user-allocated data" case are conversions
from
:ref:`CvMat` and
:ref:`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 :ref:`CvMat` and :ref:`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`` an ``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`` an ``Mat::operator IplImage()``. The operators do *not* copy the data.
::
...
...
@@ -915,11 +902,11 @@ for a scalar ( ``Scalar`` ),
:math:`A.t() \sim A^t` *
matrix inversion and pseudo-inversion, solving linear systems and least-squares problems:
The result of comparison is 8-bit single channel mask, which elements are set to 255
(if the particular element or pair of elements satisfy the condition) and 0 otherwise.
:math:`A\gtreqqless B,\;A \ne B,\;A \gtreqqless \alpha,\;A \ne \alpha`. The result of comparison is 8-bit single channel mask, which elements are set to 255 (if the particular element or pair of elements satisfy the condition) and 0 otherwise.
*
bitwise logical operations: ``A & B, A & s, A | B, A | s, A textasciicircum B, A textasciicircum s, ~ A`` *
...
...
@@ -935,17 +922,12 @@ for a scalar ( ``Scalar`` ),
matrix constructors and operators that extract sub-matrices (see
:ref:`Mat` description).
matrix initializers ( ``eye(), zeros(), ones()`` ), matrix comma-separated initializers, matrix constructors and operators that extract sub-matrices (see :ref:`Mat` description).
*
verb
"Mat_<destination_type>()" constructors to cast the result to the proper type.
``Mat_<destination_type>()`` constructors to cast the result to the proper type.
Note, however, that comma-separated initializers and probably some other operations may require additional explicit ``Mat()`` or
verb
"Mat_<T>()" constuctor calls to resolve possible ambiguity.
Note, however, that comma-separated initializers and probably some other operations may require additional explicit ``Mat()`` or ``Mat_<T>()`` constuctor calls to resolve possible ambiguity.
Below is the formal description of the ``Mat`` methods.
...
...
@@ -2410,8 +2392,8 @@ Template sparse n-dimensional array class derived from
SparseMatIterator_<_Tp> end();
SparseMatConstIterator_<_Tp> end() const;
};
.. ``SparseMat_`` is a thin wrapper on top of
:ref:`SparseMat` , made in the same way as ``Mat_`` .
``SparseMat_`` is a thin wrapper on top of :ref:`SparseMat` , made in the same way as ``Mat_`` .
It simplifies notation of some operations, and that's it. ::
The array ``frame`` is automatically allocated by ``>>`` operator, since the video frame resolution and bit-depth is known to the video capturing module. The array ``edges`` is automatically allocated by ``cvtColor`` function. It will have the same size and the bit-depth as the input array, and the number of channels will be 1, because we passed the color conversion code ``CV_BGR2GRAY`` (that means color to grayscale conversion). Note that ``frame`` and ``edges`` will be allocated only once during the first execution of the loop body, since all the next video frames will have the same resolution (unless user somehow changes the video resolution, in this case the arrays will be automatically reallocated).
:param src: matrix or matrix expression ``abs`` is a meta-function that is expanded to one of
:func:`absdiff` forms:
:param src: matrix or matrix expression
``abs`` is a meta-function that is expanded to one of :func:`absdiff` forms:
* ``C = abs(A-B)`` is equivalent to ``absdiff(A, B, C)`` and
* ``C = abs(A-B)`` is equivalent to ``absdiff(A, B, C)`` and
* ``C = abs(A)`` is equivalent to ``absdiff(A, Scalar::all(0), C)`` .
* ``C = abs(A)`` is equivalent to ``absdiff(A, Scalar::all(0), C)`` .
* ``C = Mat_<Vec<uchar,n> >(abs(A*alpha + beta))`` is equivalent to ``convertScaleAbs(A, C, alpha, beta)`` The output matrix will have the same size and the same type as the input one
* ``C = Mat_<Vec<uchar,n> >(abs(A*alpha + beta))`` is equivalent to ``convertScaleAbs(A, C, alpha, beta)``.
The output matrix will have the same size and the same type as the input one
(except for the last case, where ``C`` will be ``depth=CV_8U`` ).
See also:
:ref:`Matrix Expressions`,:func:`absdiff`,
See also: :ref:`Matrix Expressions`, :func:`absdiff`
.. index:: absdiff
absdiff
...
...
@@ -38,8 +41,13 @@ absdiff
Computes per-element absolute difference between 2 arrays or between array and a scalar.
:param src1: The first input array
:param src2: The second input array; Must be the same size and same type as ``src1`` :param sc: Scalar; the second input parameter
:param dst: The destination array; it will have the same size and same type as ``src1`` ; see ``Mat::create`` The functions ``absdiff`` compute:
:param src2: The second input array; Must be the same size and same type as ``src1``
:param sc: Scalar; the second input parameter
:param dst: The destination array; it will have the same size and same type as ``src1`` ; see ``Mat::create``
The functions ``absdiff`` compute:
* absolute difference between two arrays:
...
...
@@ -54,7 +62,9 @@ absdiff
where ``I`` is multi-dimensional index of array elements.
in the case of multi-channel arrays each channel is processed independently.
See also: :func:`abs` .. index:: add
See also: :func:`abs`
.. index:: add
add
-------
...
...
@@ -74,10 +84,13 @@ add
:param src1: The first source array
:param src2: The second source array. It must have the same size and same type as ``src1`` :param sc: Scalar; the second input parameter
:param src2: The second source array. It must have the same size and same type as ``src1``
:param sc: Scalar; the second input parameter
:param dst: The destination array; it will have the same size and same type as ``src1`` ; see ``Mat::create`` :param mask: The optional operation mask, 8-bit single channel array;
specifies elements of the destination array to be changed
:param dst: The destination array; it will have the same size and same type as ``src1`` ; see ``Mat::create``
:param mask: The optional operation mask, 8-bit single channel array; specifies elements of the destination array to be changed
The functions ``add`` compute:
...
...
@@ -122,9 +135,13 @@ addWeighted
:param alpha: Weight for the first array elements
:param src2: The second source array; must have the same size and same type as ``src1`` :param beta: Weight for the second array elements
:param src2: The second source array; must have the same size and same type as ``src1``
:param beta: Weight for the second array elements
:param dst: The destination array; it will have the same size and same type as ``src1`` :param gamma: Scalar, added to each sum
:param dst: The destination array; it will have the same size and same type as ``src1``
:param gamma: Scalar, added to each sum
The functions ``addWeighted`` calculate the weighted sum of two arrays as follows:
:param src2: The second source array. It must have the same size and same type as ``src1`` :param sc: Scalar; the second input parameter
:param src2: The second source array. It must have the same size and same type as ``src1``
:param sc: Scalar; the second input parameter
:param dst: The destination array; it will have the same size and same type as ``src1`` ; see ``Mat::create`` :param mask: The optional operation mask, 8-bit single channel array;
specifies elements of the destination array to be changed
:param dst: The destination array; it will have the same size and same type as ``src1`` ; see ``Mat::create``
:param mask: The optional operation mask, 8-bit single channel array; specifies elements of the destination array to be changed
The functions ``bitwise_and`` compute per-element bit-wise logical conjunction:
that is, the covariance matrix will be :math:`\texttt{nsamples} \times \texttt{nsamples}` . Such an unusual covariance matrix is used for fast PCA of a set of very large vectors (see, for example, the EigenFaces technique for face recognition). Eigenvalues of this "scrambled" matrix will match the eigenvalues of the true covariance matrix and the "true" eigenvectors can be easily calculated from the eigenvectors of the "scrambled" covariance matrix.
* **CV_COVAR_NORMAL** The output covariance matrix is calculated as:
that is, ``covar`` will be a square matrix of the same size as the total number of elements in each input vector. One and only one of ``CV_COVAR_SCRAMBLED`` and ``CV_COVAR_NORMAL`` must be specified
* **CV_COVAR_USE_AVG** If the flag is specified, the function does not calculate ``mean`` from the input vectors, but, instead, uses the passed ``mean`` vector. This is useful if ``mean`` has been pre-computed or known a-priori, or if the covariance matrix is calculated by parts - in this case, ``mean`` is not a mean vector of the input sub-set of vectors, but rather the mean vector of the whole set.
...
...
@@ -355,7 +365,9 @@ The functions ``calcCovarMatrix`` calculate the covariance matrix
and, optionally, the mean vector of the set of input vectors.
:param x: The array of x-coordinates; must be single-precision or double-precision floating-point array
:param y: The array of y-coordinates; it must have the same size and same type as ``x`` :param magnitude: The destination array of magnitudes of the same size and same type as ``x`` :param angle: The destination array of angles of the same size and same type as ``x`` .
The angles are measured in radians :math:`(0` to :math:`2 \pi )` or in degrees (0 to 360 degrees).
:param y: The array of y-coordinates; it must have the same size and same type as ``x``
:param magnitude: The destination array of magnitudes of the same size and same type as ``x``
:param angle: The destination array of angles of the same size and same type as ``x``. The angles are measured in radians :math:`(0` to :math:`2 \pi )` or in degrees (0 to 360 degrees).
:param angleInDegrees: The flag indicating whether the angles are measured in radians, which is default mode, or in degrees
...
...
@@ -422,13 +437,27 @@ compare
:param src1: The first source array
:param src2: The second source array; must have the same size and same type as ``src1`` :param value: The scalar value to compare each array element with
:param dst: The destination array; will have the same size as ``src1`` and type= ``CV_8UC1`` :param cmpop: The flag specifying the relation between the elements to be checked
* **CMP_EQ** :math:`\texttt{src1}(I) = \texttt{src2}(I)` or :math:`\texttt{src1}(I) = \texttt{value}` * **CMP_GT** :math:`\texttt{src1}(I) > \texttt{src2}(I)` or :math:`\texttt{src1}(I) > \texttt{value}` * **CMP_GE** :math:`\texttt{src1}(I) \geq \texttt{src2}(I)` or :math:`\texttt{src1}(I) \geq \texttt{value}` * **CMP_LT** :math:`\texttt{src1}(I) < \texttt{src2}(I)` or :math:`\texttt{src1}(I) < \texttt{value}` * **CMP_LE** :math:`\texttt{src1}(I) \leq \texttt{src2}(I)` or :math:`\texttt{src1}(I) \leq \texttt{value}` * **CMP_NE** :math:`\texttt{src1}(I) \ne \texttt{src2}(I)` or :math:`\texttt{src1}(I) \ne \texttt{value}` The functions ``compare`` compare each element of ``src1`` with the corresponding element of ``src2`` or with real scalar ``value`` . When the comparison result is true, the corresponding element of destination array is set to 255, otherwise it is set to 0:
:param src2: The second source array; must have the same size and same type as ``src1``
:param value: The scalar value to compare each array element with
* ``dst(I) = src1(I) cmpop src2(I) ? 255 : 0`` * ``dst(I) = src1(I) cmpop value ? 255 : 0`` The comparison operations can be replaced with the equivalent matrix expressions: ::
:param dst: The destination array; will have the same size as ``src1`` and type= ``CV_8UC1``
:param cmpop: The flag specifying the relation between the elements to be checked
* **CMP_EQ** :math:`\texttt{src1}(I) = \texttt{src2}(I)` or :math:`\texttt{src1}(I) = \texttt{value}`
* **CMP_GT** :math:`\texttt{src1}(I) > \texttt{src2}(I)` or :math:`\texttt{src1}(I) > \texttt{value}`
* **CMP_GE** :math:`\texttt{src1}(I) \geq \texttt{src2}(I)` or :math:`\texttt{src1}(I) \geq \texttt{value}`
* **CMP_LT** :math:`\texttt{src1}(I) < \texttt{src2}(I)` or :math:`\texttt{src1}(I) < \texttt{value}`
* **CMP_LE** :math:`\texttt{src1}(I) \leq \texttt{src2}(I)` or :math:`\texttt{src1}(I) \leq \texttt{value}`
* **CMP_NE** :math:`\texttt{src1}(I) \ne \texttt{src2}(I)` or :math:`\texttt{src1}(I) \ne \texttt{value}`
The functions ``compare`` compare each element of ``src1`` with the corresponding element of ``src2`` or with real scalar ``value`` . When the comparison result is true, the corresponding element of destination array is set to 255, otherwise it is set to 0:
* ``dst(I) = src1(I) cmpop src2(I) ? 255 : 0``
* ``dst(I) = src1(I) cmpop value ? 255 : 0``
The comparison operations can be replaced with the equivalent matrix expressions: ::
The accuracy approaches the maximum possible accuracy for single-precision data.
The function ``cubeRoot`` computes :math:`\sqrt[3]{\texttt{val}}`. Negative arguments are handled correctly, *NaN*
and :math:`\pm\infty` are not handled. The accuracy approaches the maximum possible accuracy for single-precision data.
.. index:: cvarrToMat
...
...
@@ -533,11 +568,11 @@ cvarrToMat
Converts CvMat, IplImage or CvMatND to Mat.
:param src: The source ``CvMat`` , ``IplImage`` or ``CvMatND`` :param copyData: When it is false (default value), no data is copied, only the new header is created.
In this case the original array should not be deallocated while the new matrix header is used. The the parameter is true, all the data is copied, then user may deallocate the original array right after the conversion
:param src: The source ``CvMat`` , ``IplImage`` or ``CvMatND``
:param copyData: When it is false (default value), no data is copied, only the new header is created. In this case the original array should not be deallocated while the new matrix header is used. The the parameter is true, all the data is copied, then user may deallocate the original array right after the conversion
:param allowND: When it is true (default value), then ``CvMatND`` is converted to ``Mat`` if it's possible
(e.g. then the data is contiguous). If it's not possible, or when the parameter is false, the function will report an error
:param allowND: When it is true (default value), then ``CvMatND`` is converted to ``Mat`` if it's possible (e.g. then the data is contiguous). If it's not possible, or when the parameter is false, the function will report an error
:param coiMode: The parameter specifies how the IplImage COI (when set) is handled.
...
...
@@ -588,7 +623,9 @@ The last parameter, ``coiMode`` , specifies how to react on an image with COI se
:param dst: The destination array; will have the same size and same type as ``src`` :param flags: Transformation flags, a combination of the following values
:param dst: The destination array; will have the same size and same type as ``src``
:param flags: Transformation flags, a combination of the following values
* **DCT_INVERSE** do an inverse 1D or 2D transform instead of the default forward transform.
...
...
@@ -672,7 +711,9 @@ Also, the function's performance depends very much, and not monotonically, on th
:param dst: The destination array, which size and type depends on the ``flags`` :param flags: Transformation flags, a combination of the following values
:param dst: The destination array, which size and type depends on the ``flags``
:param flags: Transformation flags, a combination of the following values
* **DFT_INVERSE** do an inverse 1D or 2D transform instead of the default forward transform.
...
...
@@ -806,32 +849,19 @@ Here is the sample on how to compute DFT-based convolution of two 2D real arrays
What can be optimized in the above sample?
*
since we passed
:math:`\texttt{nonzeroRows} \ne 0` to the forward transform calls and
since we copied ``A`` / ``B`` to the top-left corners of ``tempA`` / ``tempB`` , respectively,
it's not necessary to clear the whole ``tempA`` and ``tempB`` ;
it is only necessary to clear the ``tempA.cols - A.cols`` ( ``tempB.cols - B.cols`` )
rightmost columns of the matrices.
since we passed :math:`\texttt{nonzeroRows} \ne 0` to the forward transform calls and since we copied ``A`` / ``B`` to the top-left corners of ``tempA`` / ``tempB`` , respectively, it's not necessary to clear the whole ``tempA`` and ``tempB`` ; it is only necessary to clear the ``tempA.cols - A.cols`` ( ``tempB.cols - B.cols`` ) rightmost columns of the matrices.
*
this DFT-based convolution does not have to be applied to the whole big arrays,
especially if ``B`` is significantly smaller than ``A`` or vice versa.
Instead, we can compute convolution by parts. For that we need to split the destination array ``C`` into multiple tiles and for each tile estimate, which parts of ``A`` and ``B`` are required to compute convolution in this tile. If the tiles in ``C`` are too small,
the speed will decrease a lot, because of repeated work - in the ultimate case, when each tile in ``C`` is a single pixel,
the algorithm becomes equivalent to the naive convolution algorithm.
If the tiles are too big, the temporary arrays ``tempA`` and ``tempB`` become too big
and there is also slowdown because of bad cache locality. So there is optimal tile size somewhere in the middle.
* this DFT-based convolution does not have to be applied to the whole big arrays, especially if ``B`` is significantly smaller than ``A`` or vice versa. Instead, we can compute convolution by parts. For that we need to split the destination array ``C`` into multiple tiles and for each tile estimate, which parts of ``A`` and ``B`` are required to compute convolution in this tile. If the tiles in ``C`` are too small, the speed will decrease a lot, because of repeated work - in the ultimate case, when each tile in ``C`` is a single pixel, the algorithm becomes equivalent to the naive convolution algorithm. If the tiles are too big, the temporary arrays ``tempA`` and ``tempB`` become too big and there is also slowdown because of bad cache locality. So there is optimal tile size somewhere in the middle.
*
if the convolution is done by parts, since different tiles in ``C`` can be computed in parallel, the loop can be threaded.
All of the above improvements have been implemented in
:func:`matchTemplate` and
:func:`filter2D` , therefore, by using them, you can get even better performance than with the above theoretically optimal implementation (though, those two functions actually compute cross-correlation, not convolution, so you will need to "flip" the kernel or the image around the center using
:func:`flip` ).
All of the above improvements have been implemented in :func:`matchTemplate` and :func:`filter2D` , therefore, by using them, you can get even better performance than with the above theoretically optimal implementation (though, those two functions actually compute cross-correlation, not convolution, so you will need to "flip" the kernel or the image around the center using :func:`flip` ).
Computes eigenvalues and eigenvectors of a symmetric matrix.
:param src: The input matrix; must have ``CV_32FC1`` or ``CV_64FC1`` type, square size and be symmetric: :math:`\texttt{src}^T=\texttt{src}` :param eigenvalues: The output vector of eigenvalues of the same type as ``src`` ; The eigenvalues are stored in the descending order.
:param src: The input matrix; must have ``CV_32FC1`` or ``CV_64FC1`` type, square size and be symmetric: :math:`\texttt{src}^T=\texttt{src}`
:param eigenvalues: The output vector of eigenvalues of the same type as ``src`` ; The eigenvalues are stored in the descending order.
:param eigenvectors: The output matrix of eigenvectors; It will have the same size and the same type as ``src`` ; The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues
:param lowindex: Optional index of largest eigenvalue/-vector to calculate.
(See below.)
:param lowindex: Optional index of largest eigenvalue/-vector to calculate. (See below.)
:param highindex: Optional index of smallest eigenvalue/-vector to calculate.
(See below.)
:param highindex: Optional index of smallest eigenvalue/-vector to calculate. (See below.)
The functions ``eigen`` compute just eigenvalues, or eigenvalues and eigenvectors of symmetric matrix ``src`` : ::
...
...
@@ -917,7 +955,9 @@ matrix with eigenvalues. The selected eigenvectors/-values are always in the
:param dst: The destination array; will have the same size and same type as ``src`` The function ``exp`` calculates the exponent of every element of the input array:
:param dst: The destination array; will have the same size and same type as ``src``
The function ``exp`` calculates the exponent of every element of the input array:
.. math::
...
...
@@ -941,7 +983,9 @@ The maximum relative error is about
:param src: The source array. It should be a pointer to :ref:`CvMat` or :ref:`IplImage` :param dst: The destination array; will have single-channel, and the same size and the same depth as ``src`` :param coi: If the parameter is ``>=0`` , it specifies the channel to extract;
If it is ``<0`` , ``src`` must be a pointer to ``IplImage`` with valid COI set - then the selected COI is extracted.
:param src: The source array. It should be a pointer to :ref:`CvMat` or :ref:`IplImage`
:param dst: The destination array; will have single-channel, and the same size and the same depth as ``src``
:param coi: If the parameter is ``>=0`` , it specifies the channel to extract; If it is ``<0`` , ``src`` must be a pointer to ``IplImage`` with valid COI set - then the selected COI is extracted.
The function ``extractImageCOI`` is used to extract image COI from an old-style array and put the result to the new-style C++ matrix. As usual, the destination matrix is reallocated using ``Mat::create`` if needed.
:param dst: The destination array; will have the same size and same type as ``src`` :param flipCode: Specifies how to flip the array:
0 means flipping around the x-axis, positive (e.g., 1) means flipping around y-axis, and negative (e.g., -1) means flipping around both axes. See also the discussion below for the formulas.
:param dst: The destination array; will have the same size and same type as ``src``
:param flipCode: Specifies how to flip the array: 0 means flipping around the x-axis, positive (e.g., 1) means flipping around y-axis, and negative (e.g., -1) means flipping around both axes. See also the discussion below for the formulas.
The function ``flip`` flips the array in one of three different ways (row and column indices are 0-based):
...
...
@@ -1015,8 +1065,9 @@ The example scenarios of function use are:
See also: :func:`transpose`,:func:`repeat`,:func:`completeSymm`
.. index:: gemm
gemm
--------
...
...
@@ -1026,14 +1077,23 @@ gemm
:param src1: The first multiplied input matrix; should have ``CV_32FC1`` , ``CV_64FC1`` , ``CV_32FC2`` or ``CV_64FC2`` type
:param src2: The second multiplied input matrix; should have the same type as ``src1`` :param alpha: The weight of the matrix product
:param src2: The second multiplied input matrix; should have the same type as ``src1``
:param alpha: The weight of the matrix product
:param src3: The third optional delta matrix added to the matrix product; should have the same type as ``src1`` and ``src2`` :param beta: The weight of ``src3`` :param dst: The destination matrix; It will have the proper size and the same type as input matrices
:param src3: The third optional delta matrix added to the matrix product; should have the same type as ``src1`` and ``src2``
:param beta: The weight of ``src3``
:param dst: The destination matrix; It will have the proper size and the same type as input matrices
:param flags: Operation flags:
* **GEMM_1_T** transpose ``src1`` * **GEMM_2_T** transpose ``src2`` * **GEMM_3_T** transpose ``src3`` The function performs generalized matrix multiplication and similar to the corresponding functions ``*gemm`` in BLAS level 3.
For example, ``gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)`` corresponds to
* **GEMM_1_T** transpose ``src1``
* **GEMM_2_T** transpose ``src2``
* **GEMM_3_T** transpose ``src3``
The function performs generalized matrix multiplication and similar to the corresponding functions ``*gemm`` in BLAS level 3. For example, ``gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)`` corresponds to
.. math::
...
...
@@ -1045,7 +1105,9 @@ The function can be replaced with a matrix expression, e.g. the above call can b
The functions ``getConvertElem`` and ``getConvertScaleElem`` return pointers to the functions for converting individual pixels from one type to another. While the main function purpose is to convert single pixels (actually, for converting sparse matrices from one type to another), you can use them to convert the whole row of a dense matrix or the whole matrix at once, by setting ``cn = matrix.cols*matrix.rows*matrix.channels()`` if the matrix data is continuous.
@@ -1099,7 +1163,9 @@ The function returns a negative number if ``vecsize`` is too large (very close t
While the function cannot be used directly to estimate the optimal vector size for DCT transform (since the current DCT implementation supports only even-size vectors), it can be easily computed as ``getOptimalDFTSize((vecsize+1)/2)*2`` .
:param src: The source floating-point single-channel array
:param dst: The destination array. Will have the same size and same type as ``src`` :param flags: The operation flags. ``idct(src, dst, flags)`` is equivalent to ``dct(src, dst, flags | DCT_INVERSE)`` .
See
:func:`dct` for details.
:param dst: The destination array. Will have the same size and same type as ``src``
:param flags: The operation flags.
``idct(src, dst, flags)`` is equivalent to ``dct(src, dst, flags | DCT_INVERSE)``.
See also: :func:`dct`,:func:`dft`,:func:`idft`,:func:`getOptimalDFTSize`
.. index:: idft
idft
--------
.. c:function:: void idft(const Mat\& src, Mat\& dst, int flags=0, int outputRows=0)
.. c:function:: void idft(const Mat& src, Mat& dst, int flags=0, int outputRows=0)
Computes inverse Discrete Fourier Transform of a 1D or 2D array
:param src: The source floating-point real or complex array
:param dst: The destination array, which size and type depends on the ``flags`` :param flags: The operation flags. See :func:`dft` :param nonzeroRows: The number of ``dst`` rows to compute.
The rest of the rows will have undefined content.
See the convolution sample in :func:`dft` description ``idft(src, dst, flags)`` is equivalent to ``dct(src, dst, flags | DFT_INVERSE)`` .
See
:func:`dft` for details.
:param dst: The destination array, which size and type depends on the ``flags``
:param flags: The operation flags. See :func:`dft`
:param nonzeroRows: The number of ``dst`` rows to compute. The rest of the rows will have undefined content. See the convolution sample in :func:`dft` description
``idft(src, dst, flags)`` is equivalent to ``dct(src, dst, flags | DFT_INVERSE)`` .
See :func:`dft` for details.
Note, that none of ``dft`` and ``idft`` scale the result by default.
Thus, you should pass ``DFT_SCALE`` to one of ``dft`` or ``idft`` explicitly to make these transforms mutually inverse.
See also: :func:`dft`,:func:`dct`,:func:`idct`,:func:`mulSpectrums`,:func:`getOptimalDFTSize`
.. index:: inRange
inRange
-----------
...
...
@@ -1149,7 +1223,11 @@ inRange
:param src: The first source array
:param lowerb: The inclusive lower boundary array of the same size and type as ``src`` :param upperb: The exclusive upper boundary array of the same size and type as ``src`` :param dst: The destination array, will have the same size as ``src`` and ``CV_8U`` type
:param lowerb: The inclusive lower boundary array of the same size and type as ``src``
:param upperb: The exclusive upper boundary array of the same size and type as ``src``
:param dst: The destination array, will have the same size as ``src`` and ``CV_8U`` type
The functions ``inRange`` do the range check for every element of the input array:
...
...
@@ -1175,7 +1253,9 @@ invert
:param src: The source floating-point :math:`M \times N` matrix
:param dst: The destination matrix; will have :math:`N \times M` size and the same type as ``src`` :param flags: The inversion method :
:param dst: The destination matrix; will have :math:`N \times M` size and the same type as ``src``
:param flags: The inversion method :
* **DECOMP_LU** Gaussian elimination with optimal pivot element chosen
...
...
@@ -1194,7 +1274,9 @@ In the case of ``DECOMP_SVD`` method, the function returns the inversed conditio
Similarly to ``DECOMP_LU`` , the method ``DECOMP_CHOLESKY`` works only with non-singular square matrices. In this case the function stores the inverted matrix in ``dst`` and returns non-zero, otherwise it returns 0.
See also:
:func:`solve`,:func:`SVD` .. index:: log
:func:`solve`,:func:`SVD`
.. index:: log
log
-------
...
...
@@ -1206,7 +1288,9 @@ log
:param src: The source array
:param dst: The destination array; will have the same size and same type as ``src`` The function ``log`` calculates the natural logarithm of the absolute value of every element of the input array:
:param dst: The destination array; will have the same size and same type as ``src``
The function ``log`` calculates the natural logarithm of the absolute value of every element of the input array:
.. math::
...
...
@@ -1219,7 +1303,9 @@ The maximum relative error is about
:param lut: Look-up table of 256 elements. In the case of multi-channel source array, the table should either have a single channel (in this case the same table is used for all channels) or the same number of channels as in the source array
:param dst: Destination array; will have the same size and the same number of channels as ``src`` , and the same depth as ``lut`` The function ``LUT`` fills the destination array with values from the look-up table. Indices of the entries are taken from the source array. That is, the function processes each element of ``src`` as follows:
:param dst: Destination array; will have the same size and the same number of channels as ``src`` , and the same depth as ``lut``
The function ``LUT`` fills the destination array with values from the look-up table. Indices of the entries are taken from the source array. That is, the function processes each element of ``src`` as follows:
.. math::
...
...
@@ -1244,7 +1332,9 @@ where
d = \fork{0}{if \texttt{src} has depth \texttt{CV\_8U}}{128}{if \texttt{src} has depth \texttt{CV\_8S}}
:param x: The floating-point array of x-coordinates of the vectors
:param y: The floating-point array of y-coordinates of the vectors; must have the same size as ``x`` :param dst: The destination array; will have the same size and same type as ``x`` The function ``magnitude`` calculates magnitude of 2D vectors formed from the corresponding elements of ``x`` and ``y`` arrays:
:param y: The floating-point array of y-coordinates of the vectors; must have the same size as ``x``
:param dst: The destination array; will have the same size and same type as ``x``
The function ``magnitude`` calculates magnitude of 2D vectors formed from the corresponding elements of ``x`` and ``y`` arrays:
:param srcv: The input array or vector of matrices.
All the matrices must have the same size and the same depth
:param nsrc: The number of elements in ``srcv`` :param dstv: The output array or vector of matrices.
All the matrices *must be allocated* , their size and depth must be the same as in ``srcv[0]`` :param ndst: The number of elements in ``dstv`` :param fromTo: The array of index pairs, specifying which channels are copied and where. ``fromTo[k*2]`` is the 0-based index of the input channel in ``srcv`` and ``fromTo[k*2+1]`` is the index of the output channel in ``dstv`` . Here the continuous channel numbering is used, that is,
the first input image channels are indexed from ``0`` to ``srcv[0].channels()-1`` ,
the second input image channels are indexed from ``srcv[0].channels()`` to ``srcv[0].channels() + srcv[1].channels()-1`` etc., and the same scheme is used for the output image channels.
As a special case, when ``fromTo[k*2]`` is negative, the corresponding output channel is filled with zero. ``npairs`` The functions ``mixChannels`` provide an advanced mechanism for shuffling image channels.
:param nsrc: The number of elements in ``srcv``
:param dstv: The output array or vector of matrices. All the matrices *must be allocated* , their size and depth must be the same as in ``srcv[0]``
:param ndst: The number of elements in ``dstv``
:param fromTo: The array of index pairs, specifying which channels are copied and where. ``fromTo[k*2]`` is the 0-based index of the input channel in ``srcv`` and ``fromTo[k*2+1]`` is the index of the output channel in ``dstv`` . Here the continuous channel numbering is used, that is, the first input image channels are indexed from ``0`` to ``srcv[0].channels()-1`` , the second input image channels are indexed from ``srcv[0].channels()`` to ``srcv[0].channels() + srcv[1].channels()-1`` etc., and the same scheme is used for the output image channels. As a special case, when ``fromTo[k*2]`` is negative, the corresponding output channel is filled with zero. ``npairs``
The functions ``mixChannels`` provide an advanced mechanism for shuffling image channels.
:func:`split` and
:func:`merge` and some forms of
:func:`cvtColor` are partial cases of ``mixChannels`` .
...
...
@@ -1545,7 +1664,9 @@ Note that, unlike many other new-style C++ functions in OpenCV (see the introduc
:func:`Mat::create` ), ``mixChannels`` requires the destination arrays be pre-allocated before calling the function.
:param src2: The second source array; must have the same size and the same type as ``src1`` :param dst: The destination array; will have the same size and the same type as ``src1`` :param flags: The same flags as passed to :func:`dft` ; only the flag ``DFT_ROWS`` is checked for
:param src2: The second source array; must have the same size and the same type as ``src1``
:param dst: The destination array; will have the same size and the same type as ``src1``
:param flags: The same flags as passed to :func:`dft` ; only the flag ``DFT_ROWS`` is checked for
:param conj: The optional flag that conjugate the second source array before the multiplication (true) or not (false)
...
...
@@ -1578,7 +1703,11 @@ multiply
:param src1: The first source array
:param src2: The second source array of the same size and the same type as ``src1`` :param dst: The destination array; will have the same size and the same type as ``src1`` :param scale: The optional scale factor
:param src2: The second source array of the same size and the same type as ``src1``
:param dst: The destination array; will have the same size and the same type as ``src1``
:param scale: The optional scale factor
The function ``multiply`` calculates the per-element product of two arrays:
...
...
@@ -1594,7 +1723,9 @@ If you are looking for a matrix product, not per-element product, see
:param scale: The optional scale factor for the matrix product
:param rtype: When it's negative, the destination matrix will have the same type as ``src`` . Otherwise, it will have ``type=CV_MAT_DEPTH(rtype)`` , which should be either ``CV_32F`` or ``CV_64F`` The function ``mulTransposed`` calculates the product of ``src`` and its transposition:
:param rtype: When it's negative, the destination matrix will have the same type as ``src`` . Otherwise, it will have ``type=CV_MAT_DEPTH(rtype)`` , which should be either ``CV_32F`` or ``CV_64F``
The function ``mulTransposed`` calculates the product of ``src`` and its transposition:
.. math::
...
...
@@ -1629,7 +1762,9 @@ otherwise. The function is used to compute covariance matrix and with zero delta
:param src2: The second source array of the same size and the same type as ``src1`` :param normType: Type of the norm; see the discussion below
:param src2: The second source array of the same size and the same type as ``src1``
:param normType: Type of the norm; see the discussion below
:param mask: The optional operation mask
...
...
@@ -1699,13 +1836,17 @@ normalize
:param src: The source array
:param dst: The destination array; will have the same size as ``src`` :param alpha: The norm value to normalize to or the lower range boundary in the case of range normalization
:param dst: The destination array; will have the same size as ``src``
:param alpha: The norm value to normalize to or the lower range boundary in the case of range normalization
:param beta: The upper range boundary in the case of range normalization; not used for norm normalization
:param normType: The normalization type, see the discussion
:param rtype: When the parameter is negative, the destination array will have the same type as ``src`` , otherwise it will have the same number of channels as ``src`` and the depth ``=CV_MAT_DEPTH(rtype)`` :param mask: The optional operation mask
:param rtype: When the parameter is negative, the destination array will have the same type as ``src`` , otherwise it will have the same number of channels as ``src`` and the depth ``=CV_MAT_DEPTH(rtype)``
:param mask: The optional operation mask
The functions ``normalize`` scale and shift the source array elements, so that
...
...
@@ -1730,9 +1871,9 @@ The optional mask specifies the sub-array to be normalize, that is, the norm or
in the case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this, the range transformation for sparse matrices is not allowed, since it can shift the zero level.
:param src: The source two-channel or three-channel floating-point array;
each element is 2D/3D vector to be transformed
:param dst: The destination array; it will have the same size and same type as ``src`` :param mtx: :math:`3\times 3` or :math:`4 \times 4` transformation matrix
:param dst: The destination array; it will have the same size and same type as ``src``
:param mtx: :math:`3\times 3` or :math:`4 \times 4` transformation matrix
The function ``perspectiveTransform`` transforms every element of ``src``,by treating it as 2D or 3D vector, in the following way (here 3D vector transformation is shown; in the case of 2D vector transformation the
:math:`z` component is omitted):
...
...
@@ -1926,7 +2071,9 @@ Note that the function transforms a sparse set of 2D or 3D vectors. If you want
:param x: The source floating-point array of x-coordinates of 2D vectors
:param y: The source array of y-coordinates of 2D vectors; must have the same size and the same type as ``x`` :param angle: The destination array of vector angles; it will have the same size and same type as ``x`` :param angleInDegrees: When it is true, the function will compute angle in degrees, otherwise they will be measured in radians
:param y: The source array of y-coordinates of 2D vectors; must have the same size and the same type as ``x``
:param angle: The destination array of vector angles; it will have the same size and same type as ``x``
:param angleInDegrees: When it is true, the function will compute angle in degrees, otherwise they will be measured in radians
The function ``phase`` computes the rotation angle of each 2D vector that is formed from the corresponding elements of ``x`` and ``y`` :
...
...
@@ -1958,9 +2109,15 @@ polarToCart
Computes x and y coordinates of 2D vectors from their magnitude and angle.
:param magnitude: The source floating-point array of magnitudes of 2D vectors. It can be an empty matrix ( ``=Mat()`` ) - in this case the function assumes that all the magnitudes are =1. If it's not empty, it must have the same size and same type as ``angle`` :param angle: The source floating-point array of angles of the 2D vectors
:param magnitude: The source floating-point array of magnitudes of 2D vectors. It can be an empty matrix ( ``=Mat()`` ) - in this case the function assumes that all the magnitudes are =1. If it's not empty, it must have the same size and same type as ``angle``
:param angle: The source floating-point array of angles of the 2D vectors
:param x: The destination array of x-coordinates of 2D vectors; will have the same size and the same type as ``angle`` :param y: The destination array of y-coordinates of 2D vectors; will have the same size and the same type as ``angle`` :param angleInDegrees: When it is true, the input angles are measured in degrees, otherwise they are measured in radians
:param x: The destination array of x-coordinates of 2D vectors; will have the same size and the same type as ``angle``
:param y: The destination array of y-coordinates of 2D vectors; will have the same size and the same type as ``angle``
:param angleInDegrees: When it is true, the input angles are measured in degrees, otherwise they are measured in radians
The function ``polarToCart`` computes the cartesian coordinates of each 2D vector represented by the corresponding elements of ``magnitude`` and ``angle`` :
...
...
@@ -1972,7 +2129,9 @@ The relative accuracy of the estimated coordinates is
:param dst: The destination array; will have the same size and the same type as ``src`` The function ``pow`` raises every element of the input array to ``p`` :
:param dst: The destination array; will have the same size and the same type as ``src``
The function ``pow`` raises every element of the input array to ``p`` :
.. math::
...
...
@@ -2166,7 +2327,9 @@ RNG::fill
:param mat: 2D or N-dimensional matrix. Currently matrices with more than 4 channels are not supported by the methods. Use :func:`reshape` as a possible workaround.
:param distType: The distribution type, ``RNG::UNIFORM`` or ``RNG::NORMAL`` :param a: The first distribution parameter. In the case of uniform distribution this is inclusive lower boundary. In the case of normal distribution this is mean value.
:param distType: The distribution type, ``RNG::UNIFORM`` or ``RNG::NORMAL``
:param a: The first distribution parameter. In the case of uniform distribution this is inclusive lower boundary. In the case of normal distribution this is mean value.
:param b: The second distribution parameter. In the case of uniform distribution this is non-inclusive upper boundary. In the case of normal distribution this is standard deviation.
...
...
@@ -2220,7 +2383,9 @@ The function ``randn`` fills the matrix ``mtx`` with normally distributed random
is applied to the generated numbers (i.e. the values are clipped)
See also:
:func:`RNG`,:func:`randu` .. index:: randShuffle
:func:`RNG`,:func:`randu`
.. index:: randShuffle
randShuffle
---------------
...
...
@@ -2235,7 +2400,9 @@ randShuffle
:param rng: The optional random number generator used for shuffling. If it is zero, :func:`theRNG` () is used instead
The function ``randShuffle`` shuffles the specified 1D array by randomly choosing pairs of elements and swapping them. The number of such swap operations will be ``mtx.rows*mtx.cols*iterFactor`` See also:
:func:`RNG`,:func:`sort` .. index:: reduce
:func:`RNG`,:func:`sort`
.. index:: reduce
reduce
----------
...
...
@@ -2259,10 +2426,14 @@ reduce
* **CV_REDUCE_MIN** The output is the minimum (column/row-wise) of all of the matrix's rows/columns.
:param dtype: When it is negative, the destination vector will have the same type as the source matrix, otherwise, its type will be ``CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), mtx.channels())`` The function ``reduce`` reduces matrix to a vector by treating the matrix rows/columns as a set of 1D vectors and performing the specified operation on the vectors until a single row/column is obtained. For example, the function can be used to compute horizontal and vertical projections of an raster image. In the case of ``CV_REDUCE_SUM`` and ``CV_REDUCE_AVG`` the output may have a larger element bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction modes.
:param dtype: When it is negative, the destination vector will have the same type as the source matrix, otherwise, its type will be ``CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), mtx.channels())``
The function ``reduce`` reduces matrix to a vector by treating the matrix rows/columns as a set of 1D vectors and performing the specified operation on the vectors until a single row/column is obtained. For example, the function can be used to compute horizontal and vertical projections of an raster image. In the case of ``CV_REDUCE_SUM`` and ``CV_REDUCE_AVG`` the output may have a larger element bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction modes.
See also:
:func:`repeat` .. index:: repeat
:func:`repeat`
.. index:: repeat
repeat
----------
...
...
@@ -2274,7 +2445,9 @@ repeat
:param src: The source array to replicate
:param dst: The destination array; will have the same type as ``src`` :param ny: How many times the ``src`` is repeated along the vertical axis
:param dst: The destination array; will have the same type as ``src``
:param ny: How many times the ``src`` is repeated along the vertical axis
:param nx: How many times the ``src`` is repeated along the horizontal axis
...
...
@@ -2287,9 +2460,9 @@ The functions
The second variant of the function is more convenient to use with
:param src2: The second source array; must have the same size and the same type as ``src1`` :param dst: The destination array; will have the same size and the same type as ``src1`` The function ``cvScaleAdd`` is one of the classical primitive linear algebra operations, known as ``DAXPY`` or ``SAXPY`` in `BLAS <http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms>`_
. It calculates the sum of a scaled array and another array:
:param src2: The second source array; must have the same size and the same type as ``src1``
:param dst: The destination array; will have the same size and the same type as ``src1``
The function ``scaleAdd`` is one of the classical primitive linear algebra operations, known as ``DAXPY`` or ``SAXPY`` in `BLAS <http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms>`_. It calculates the sum of a scaled array and another array:
.. math::
...
...
@@ -2355,7 +2533,9 @@ The function can also be emulated with a matrix expression, for example: ::
* **DECOMP_QR** QR factorization; the system can be over-defined and/or the matrix ``src1`` can be singular
* **DECOMP_NORMAL** While all the previous flags are mutually exclusive, this flag can be used together with any of the previous. It means that the normal equations :math:`\texttt{src1}^T\cdot\texttt{src1}\cdot\texttt{dst}=\texttt{src1}^T\texttt{src2}` are solved instead of the original system :math:`\texttt{src1}\cdot\texttt{dst}=\texttt{src2}` The function ``solve`` solves a linear system or least-squares problem (the latter is possible with SVD or QR methods, or by specifying the flag ``DECOMP_NORMAL`` ):
* **DECOMP_NORMAL** While all the previous flags are mutually exclusive, this flag can be used together with any of the previous. It means that the normal equations :math:`\texttt{src1}^T\cdot\texttt{src1}\cdot\texttt{dst}=\texttt{src1}^T\texttt{src2}` are solved instead of the original system :math:`\texttt{src1}\cdot\texttt{dst}=\texttt{src2}`
The function ``solve`` solves a linear system or least-squares problem (the latter is possible with SVD or QR methods, or by specifying the flag ``DECOMP_NORMAL`` ):
.. math::
...
...
@@ -2422,7 +2604,9 @@ Note that if you want to find unity-norm solution of an under-defined singular s
:param dst: The destination array of the same size and the same type as ``src`` :param flags: The operation flags, a combination of the following values:
:param dst: The destination array of the same size and the same type as ``src``
:param flags: The operation flags, a combination of the following values:
* **CV_SORT_EVERY_ROW** Each matrix row is sorted independently
...
...
@@ -2495,7 +2681,9 @@ sort
The function ``sort`` sorts each matrix row or each matrix column in ascending or descending order. If you want to sort matrix rows or columns lexicographically, you can use STL ``std::sort`` generic function with the proper comparison predicate.
:param dst: The destination array; will have the same size and the same type as ``src`` The functions ``sqrt`` calculate square root of each source array element. in the case of multi-channel arrays each channel is processed independently. The function accuracy is approximately the same as of the built-in ``std::sqrt`` .
:param dst: The destination array; will have the same size and the same type as ``src``
The functions ``sqrt`` calculate square root of each source array element. in the case of multi-channel arrays each channel is processed independently. The accuracy is approximately the same as of the built-in ``std::sqrt`` .
See also:
:func:`pow`,:func:`magnitude` .. index:: subtract
:func:`pow`,:func:`magnitude`
.. index:: subtract
subtract
------------
...
...
@@ -2590,10 +2788,13 @@ subtract
:param src1: The first source array
:param src2: The second source array. It must have the same size and same type as ``src1`` :param sc: Scalar; the first or the second input parameter
:param src2: The second source array. It must have the same size and same type as ``src1``
:param sc: Scalar; the first or the second input parameter
:param dst: The destination array; it will have the same size and same type as ``src1`` ; see ``Mat::create`` :param mask: The optional operation mask, 8-bit single channel array;
specifies elements of the destination array to be changed
:param dst: The destination array; it will have the same size and same type as ``src1`` ; see ``Mat::create``
:param mask: The optional operation mask, 8-bit single channel array; specifies elements of the destination array to be changed
The functions ``subtract`` compute
...
...
@@ -2668,7 +2869,9 @@ The class ``SVD`` is used to compute Singular Value Decomposition of a floating-
For a bit faster operation you can pass ``flags=SVD::MODIFY_A|...`` to modify the decomposed matrix when it is not necessarily to preserve it. If you want to compute condition number of a matrix or absolute value of its determinant - you do not need ``u`` and ``vt`` , so you can pass ``flags=SVD::NO_UV|...`` . Another flag ``FULL_UV`` indicates that full-size ``u`` and ``vt`` must be computed, which is not necessary most of the time.
:param rhs: The right-hand side of a linear system :math:`\texttt{A} \texttt{x} = \texttt{rhs}` being solved, where ``A`` is the matrix passed to :func:`SVD::SVD` or :func:`SVD::operator ()` :param x: The found solution of the system
:param rhs: The right-hand side of a linear system :math:`\texttt{A} \texttt{x} = \texttt{rhs}` being solved, where ``A`` is the matrix passed to :func:`SVD::SVD` or :func:`SVD::operator ()`
:param x: The found solution of the system
The method computes back substitution for the specified right-hand side:
...
...
@@ -2767,7 +2972,9 @@ sum
The functions ``sum`` calculate and return the sum of array elements, independently for each channel.
@@ -2780,7 +2987,9 @@ The function ``theRNG`` returns the default random number generator. For each th
:func:`randn` instead. But if you are going to generate many random numbers inside a loop, it will be much faster to use this function to retrieve the generator and then use ``RNG::operator _Tp()`` .
Performs matrix transformation of every array element.
:param src: The source array; must have as many channels (1 to 4) as ``mtx.cols`` or ``mtx.cols-1`` :param dst: The destination array; will have the same size and depth as ``src`` and as many channels as ``mtx.rows`` :param mtx: The transformation matrix
:param src: The source array; must have as many channels (1 to 4) as ``mtx.cols`` or ``mtx.cols-1``
:param dst: The destination array; will have the same size and depth as ``src`` and as many channels as ``mtx.rows``
:param mtx: The transformation matrix
The function ``transform`` performs matrix transformation of every element of array ``src`` and stores the results in ``dst`` :
...
...
@@ -2833,7 +3046,9 @@ points, arbitrary linear color space transformation (such as various kinds of RG
:math:`\rightarrow` YUV transforms), shuffling the image channels and so forth.
@@ -112,7 +112,6 @@ The macro ``CV_Error_`` can be used to construct the error message on-fly to inc
CV_Error_(CV_StsOutOfRange,
("the matrix element (
i, j, mtx.at<float>(i,j)))
..
.. index:: Exception
...
...
@@ -145,7 +144,6 @@ 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` .
...
...
@@ -241,7 +239,6 @@ That is, the following code computes the execution time in seconds. ::
double t = (double)getTickCount();
// do something ...
t = ((double)getTickCount() - t)/getTickFrequency();
Add descriptors to train descriptor collection. If collection trainDescCollectionis not empty
the new descriptors are added to existing train descriptors.
Add descriptors to train descriptor collection. If collection trainDescCollectionis not empty the new descriptors are added to existing train descriptors.
:param descriptors: Descriptors to add. Each ``descriptors[i]`` is a set of descriptors
from the same (one) train image.
...
...
@@ -119,7 +118,7 @@ the new descriptors are added to existing train descriptors.
Returns constant link to the train descriptor collection (i.e. trainDescCollection).
...
...
@@ -154,23 +153,15 @@ DescriptorMatcher::train
----------------------------
.. c:function:: void DescriptorMatcher::train()
Train descriptor matcher (e.g. train flann index). In all methods to match the method train()
is run every time before matching. Some descriptor matchers (e.g. BruteForceMatcher) have empty
implementation of this method, other matchers realy train their inner structures (e.g. FlannBasedMatcher
trains flann::Index)
Train descriptor matcher (e.g. train flann index). In all methods to match the method train() is run every time before matching. Some descriptor matchers (e.g. BruteForceMatcher) have empty implementation of this method, other matchers realy train their inner structures (e.g. FlannBasedMatcher trains flann::Index)
Find the best match for each descriptor from a query set with train descriptors.
Supposed that the query descriptors are of keypoints detected on the same query image.
In first variant of this method train descriptors are set as input argument and
supposed that they are of keypoints detected on the same train image. In second variant
of the method train descriptors collection that was set using addmethod is used.
Optional mask (or masks) can be set to describe which descriptors can be matched. queryDescriptors[i]can be matched with trainDescriptors[j]only if mask.at<uchar>(i,j)is non-zero.
Find the best match for each descriptor from a query set with train descriptors. Supposed that the query descriptors are of keypoints detected on the same query image. In first variant of this method train descriptors are set as input argument and supposed that they are of keypoints detected on the same train image. In second variant of the method train descriptors collection that was set using addmethod is used. Optional mask (or masks) can be set to describe which descriptors can be matched. queryDescriptors[i] can be matched with trainDescriptors[j] only if mask.at<uchar>(i,j)is non-zero.
Find the k best matches for each descriptor from a query set with train descriptors.
Found k (or less if not possible) matches are returned in distance increasing order.
Details about query and train descriptors see in .
Find the k best matches for each descriptor from a query set with train descriptors. Found k (or less if not possible) matches are returned in distance increasing order. Details about query and train descriptors see in .
Find the best matches for each query descriptor which have distance less than given threshold.
Found matches are returned in distance increasing order. Details about query and train
descriptors see in .
Find the best matches for each query descriptor which have distance less than given threshold. Found matches are returned in distance increasing order. Details about query and train descriptors see in.
Brute-force descriptor matcher. For each descriptor in the first set, this matcher finds the closest
descriptor in the second set by trying each one. This descriptor matcher supports masking
permissible matches between descriptor sets. ::
Brute-force descriptor matcher. For each descriptor in the first set, this matcher finds the closest descriptor in the second set by trying each one. This descriptor matcher supports masking permissible matches between descriptor sets. ::
template<class Distance>
class BruteForceMatcher : public DescriptorMatcher
...
...
@@ -277,10 +261,9 @@ permissible matches between descriptor sets. ::
protected:
...
}
..
For efficiency, BruteForceMatcher is templated on the distance metric.
For float descriptors, a common choice would be ``L2<float>`` . Class of supported distances are: ::
For efficiency, BruteForceMatcher is templated on the distance metric. For float descriptors, a common choice would be ``L2<float>``. Class of supported distances are: ::
template<typename T>
struct Accumulator
...
...
@@ -340,7 +323,7 @@ For float descriptors, a common choice would be ``L2<float>`` . Class of support
int size ) const;
...
};
..
.. index:: FlannBasedMatcher
...
...
@@ -350,14 +333,7 @@ FlannBasedMatcher
-----------------
.. c:type:: FlannBasedMatcher
Flann based descriptor matcher. This matcher trains
:func:`flann::Index` on
train descriptor collection and calls it's nearest search methods to find best matches.
So this matcher may be faster in cases of matching to large train collection than
brute force matcher. ``FlannBasedMatcher`` does not support masking permissible
matches between descriptor sets, because
:func:`flann::Index` does not
support this. ::
Flann based descriptor matcher. This matcher trains :func:`flann::Index` on train descriptor collection and calls it's nearest search methods to find best matches. So this matcher may be faster in cases of matching to large train collection than brute force matcher. ``FlannBasedMatcher`` does not support masking permissible matches between descriptor sets, because :func:`flann::Index` does not support this. ::
class FlannBasedMatcher : public DescriptorMatcher
.. c:function:: DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector( const Ptr<AdjusterAdapter>\& adjaster, int min_features, int max_features, int max_iters )
DynamicAdaptedFeatureDetector constructor.
:param adjaster: An :func:`AdjusterAdapter` that will do the detection and parameter
adjustment
:param min_features: This minimum desired number features.
:param max_features: The maximum desired number of features.
:param max_iters: The maximum number of times to try to adjust the feature detector parameters. For the :func:`FastAdjuster` this number can be high,
but with Star or Surf, many iterations can get time consuming. At each iteration the detector is rerun, so keep this in mind when choosing this value.
.. index:: AdjusterAdapter
AdjusterAdapter
---------------
.. c:type:: AdjusterAdapter
A feature detector parameter adjuster interface, this is used by the :func:`DynamicAdaptedFeatureDetector` and is a wrapper for :func:`FeatureDetecto` r that allow them to be adjusted after a detection. ::
class AdjusterAdapter: public FeatureDetector
{
public:
virtual ~AdjusterAdapter() {}
virtual void tooFew(int min, int n_detected) = 0;
virtual void tooMany(int max, int n_detected) = 0;
virtual bool good() const = 0;
};
See
:func:`FastAdjuster`,:func:`StarAdjuster`,:func:`SurfAdjuster` for concrete implementations.
.. index:: AdjusterAdapter::tooFew
AdjusterAdapter::tooFew
---------------------------
.. c:function:: virtual void tooFew(int min, int n_detected) = 0
Too few features were detected so, adjust the detector parameters accordingly - so that the next detection detects more features.
:param min: This minimum desired number features.
:param n_detected: The actual number detected last run.
An example implementation of this is ::
void FastAdjuster::tooFew(int min, int n_detected)
{
thresh_--;
}
.. index:: AdjusterAdapter::tooMany
AdjusterAdapter::tooMany
----------------------------
.. c:function:: virtual void tooMany(int max, int n_detected) = 0
Too many features were detected so, adjust the detector parameters accordingly - so that the next detection detects less features.
:param max: This maximum desired number features.
:param n_detected: The actual number detected last run.
An example implementation of this is ::
void FastAdjuster::tooMany(int min, int n_detected)
{
thresh_++;
}
.. index:: AdjusterAdapter::good
AdjusterAdapter::good
-------------------------
.. c:function:: virtual bool good() const = 0
Are params maxed out or still valid? Returns false if the parameters can't be adjusted any more. An example implementation of this is ::
bool FastAdjuster::good() const
{
return (thresh_ > 1) && (thresh_ < 200);
}
.. index:: FastAdjuster
FastAdjuster
------------
.. c:type:: FastAdjuster
:func:`AdjusterAdapter` for the :func:`FastFeatureDetector`. This will basically decrement or increment the threshhold by 1 ::
class FastAdjuster FastAdjuster: public AdjusterAdapter
A feature detector parameter adjuster interface, this is used by the
:func:`DynamicAdaptedFeatureDetector` and is a wrapper for
:func:`FeatureDetecto` r that allow them to be adjusted after a detection.
A feature detector parameter adjuster interface, this is used by the :func:`DynamicAdaptedFeatureDetector` and is a wrapper for :func:`FeatureDetecto` r that allow them to be adjusted after a detection. ::
class AdjusterAdapter: public FeatureDetector
{
public:
virtual ~AdjusterAdapter() {}
virtual void tooFew(int min, int n_detected) = 0;
virtual void tooMany(int max, int n_detected) = 0;
virtual bool good() const = 0;
};
See
:func:`FastAdjuster`,:func:`StarAdjuster`,:func:`SurfAdjuster` for concrete implementations. ::
class AdjusterAdapter: public FeatureDetector
{
public:
virtual ~AdjusterAdapter() {}
virtual void tooFew(int min, int n_detected) = 0;
virtual void tooMany(int max, int n_detected) = 0;
virtual bool good() const = 0;
};
..
:func:`FastAdjuster`,:func:`StarAdjuster`,:func:`SurfAdjuster` for concrete implementations.
.. index:: AdjusterAdapter::tooFew
...
...
@@ -489,8 +963,7 @@ AdjusterAdapter::tooFew
---------------------------
.. c:function:: virtual void tooFew(int min, int n_detected) = 0
Too few features were detected so, adjust the detector parameters accordingly - so that the next
detection detects more features.
Too few features were detected so, adjust the detector parameters accordingly - so that the next detection detects more features.
:param min: This minimum desired number features.
...
...
@@ -502,7 +975,7 @@ An example implementation of this is ::
{
thresh_--;
}
..
.. index:: AdjusterAdapter::tooMany
...
...
@@ -510,8 +983,7 @@ AdjusterAdapter::tooMany
----------------------------
.. c:function:: virtual void tooMany(int max, int n_detected) = 0
Too many features were detected so, adjust the detector parameters accordingly - so that the next
detection detects less features.
Too many features were detected so, adjust the detector parameters accordingly - so that the next detection detects less features.
:param max: This maximum desired number features.
...
...
@@ -523,7 +995,7 @@ An example implementation of this is ::
{
thresh_++;
}
..
.. index:: AdjusterAdapter::good
...
...
@@ -531,28 +1003,22 @@ AdjusterAdapter::good
-------------------------
.. c:function:: virtual bool good() const = 0
Are params maxed out or still valid? Returns false if the parameters can't be adjusted any more.
An example implementation of this is ::
Are params maxed out or still valid? Returns false if the parameters can't be adjusted any more. An example implementation of this is ::
bool FastAdjuster::good() const
{
return (thresh_ > 1) && (thresh_ < 200);
}
..
.. index:: FastAdjuster
.. _FastAdjuster:
.. index:: FastAdjuster
FastAdjuster
------------
.. c:type:: FastAdjuster
An
:func:`AdjusterAdapter` for the
:func:`FastFeatureDetector` . This will basically decrement or increment the
threshhold by 1 ::
:func:`AdjusterAdapter` for the :func:`FastFeatureDetector`. This will basically decrement or increment the threshhold by 1 ::
class FastAdjuster FastAdjuster: public AdjusterAdapter
Adds images and keypoints from them to the train collection (descriptors are supposed to be calculated here).
If train collection is not empty new image and keypoints from them will be added to
existing data.
Adds images and keypoints from them to the train collection (descriptors are supposed to be calculated here). If train collection is not empty new image and keypoints from them will be added to existing data.
Classifies query keypoints under keypoints of one train image qiven as input argument
(first version of the method) or train image collection that set using (second version).
Classifies query keypoints under keypoints of one train image qiven as input argument (first version of the method) or train image collection that set using (second version).
Find best match for query keypoints to the training set. In first version of method
one train image and keypoints detected on it - are input arguments. In second version
query keypoints are matched to training collectin that set using . As in the mask can be set.
Find best match for query keypoints to the training set. In first version of method one train image and keypoints detected on it - are input arguments. In second version query keypoints are matched to training collectin that set using . As in the mask can be set.
Find the knn best matches for each keypoint from a query set with train keypoints.
Found knn (or less if not possible) matches are returned in distance increasing order.
Details see in and .
Find the knn best matches for each keypoint from a query set with train keypoints. Found knn (or less if not possible) matches are returned in distance increasing order. Details see in and.
Find the best matches for each query keypoint which have distance less than given threshold.
Found matches are returned in distance increasing order. Details see in and .
Find the best matches for each query keypoint which have distance less than given threshold. Found matches are returned in distance increasing order. Details see in and .
@@ -24,45 +23,43 @@ Match is a line connecting two keypoints (circles).
:param matches: Matches from first image to second one, i.e. ``keypoints1[i]`` has corresponding point ``keypoints2[matches[i]]`` .
:param outImg: Output image. Its content depends on ``flags`` value
what is drawn in output image. See below possible ``flags`` bit values.
:param outImg: Output image. Its content depends on ``flags`` value what is drawn in output image. See below possible ``flags`` bit values.
:param matchColor: Color of matches (lines and connected keypoints).
If ``matchColor==Scalar::all(-1)`` color will be generated randomly.
:param matchColor: Color of matches (lines and connected keypoints). If ``matchColor==Scalar::all(-1)`` color will be generated randomly.
:param singlePointColor: Color of single keypoints (circles), i.e. keypoints not having the matches.
If ``singlePointColor==Scalar::all(-1)`` color will be generated randomly.
:param singlePointColor: Color of single keypoints (circles), i.e. keypoints not having the matches. If ``singlePointColor==Scalar::all(-1)`` color will be generated randomly.
:param matchesMask: Mask determining which matches will be drawn. If mask is empty all matches will be drawn.
:param flags: Each bit of ``flags`` sets some feature of drawing.
Possible ``flags`` bit values is defined by ``DrawMatchesFlags`` , see below. ::
struct DrawMatchesFlags
{
enum{ DEFAULT = 0, // Output image matrix will be created (Mat::create),
// i.e. existing memory of output image may be reused.
// Two source image, matches and single keypoints
// will be drawn.
// For each keypoint only the center point will be
// drawn (without the circle around keypoint with
// keypoint size and orientation).
DRAW_OVER_OUTIMG = 1, // Output image matrix will not be
// created (Mat::create). Matches will be drawn
// on existing content of output image.
NOT_DRAW_SINGLE_POINTS = 2, // Single keypoints will not be drawn.
DRAW_RICH_KEYPOINTS = 4 // For each keypoint the circle around
// keypoint with keypoint size and orientation will
// be drawn.
:param flags: Each bit of ``flags`` sets some feature of drawing. Possible ``flags`` bit values is defined by ``DrawMatchesFlags`` ::
struct DrawMatchesFlags
{
enum{ DEFAULT = 0, // Output image matrix will be created (Mat::create),
// i.e. existing memory of output image may be reused.
// Two source image, matches and single keypoints
// will be drawn.
// For each keypoint only the center point will be
// drawn (without the circle around keypoint with
// keypoint size and orientation).
DRAW_OVER_OUTIMG = 1, // Output image matrix will not be
// created (Mat::create). Matches will be drawn
// on existing content of output image.
NOT_DRAW_SINGLE_POINTS = 2, // Single keypoints will not be drawn.
DRAW_RICH_KEYPOINTS = 4 // For each keypoint the circle around
// keypoint with keypoint size and orientation will
:param outImg: Output image. Its content depends on ``flags`` value
what is drawn in output image. See possible ``flags`` bit values.
:param color: Color of keypoints
:param outImg: Output image. Its content depends on ``flags`` value what is drawn in output image. See possible ``flags`` bit values.
.
:param color: Color of keypoints.
:param flags: Each bit of ``flags`` sets some feature of drawing.
Possible ``flags`` bit values is defined by ``DrawMatchesFlags`` ,
see above in :func:`drawMatches` .
:param flags: Each bit of ``flags`` sets some feature of drawing. Possible ``flags`` bit values is defined by ``DrawMatchesFlags``, see above in :func:`drawMatches` .
Add descriptors to training set. The training set will be clustered using clustermethod to construct vocabulary.
...
...
@@ -70,14 +70,11 @@ BOWTrainer::cluster
-----------------------
.. c:function:: Mat BOWTrainer::cluster() const
Cluster train descriptors. Vocabulary consists from cluster centers. So this method
returns vocabulary. In first method variant the stored in object train descriptors will be
clustered, in second variant -- input descriptors will be clustered.
Cluster train descriptors. Vocabulary consists from cluster centers. So this method returns vocabulary. In first method variant the stored in object train descriptors will be clustered, in second variant -- input descriptors will be clustered.
.. c:function:: Mat BOWTrainer::cluster( const Mat\& descriptors ) const
:param descriptors: Descriptors to cluster. Each row of ``descriptors`` matrix is a one descriptor. Descriptors will not be added
to the inner train descriptor set.
:param descriptors: Descriptors to cluster. Each row of ``descriptors`` matrix is a one descriptor. Descriptors will not be added to the inner train descriptor set.
.. index:: BOWKMeansTrainer
...
...
@@ -103,7 +100,7 @@ BOWKMeansTrainer
protected:
...
};
..
To gain an understanding of constructor parameters see
:func:`kmeans` function
...
...
@@ -117,35 +114,32 @@ BOWImgDescriptorExtractor
-------------------------
.. c:type:: BOWImgDescriptorExtractor
Class to compute image descriptor using ''bad of visual words''. In few,
such computing consists from the following steps:
1. Compute descriptors for given image and it's keypoints set,
\
2. Find nearest visual words from vocabulary for each keypoint descriptor,
\
3. Image descriptor is a normalized histogram of vocabulary words encountered in the image. I.e.
``i`` -bin of the histogram is a frequency of ``i`` -word of vocabulary in the given image. ::
Class to compute image descriptor using ''bad of visual words''. In few, such computing consists from the following steps:
#. Compute descriptors for given image and it's keypoints set
#. Find nearest visual words from vocabulary for each keypoint descriptor,
#. Image descriptor is a normalized histogram of vocabulary words encountered in the image. I.e. ``i`` -bin of the histogram is a frequency of ``i`` -word of vocabulary in the given image. ::
:param imgDescriptor: This is output, i.e. computed image descriptor.
:param pointIdxsOfClusters: Indices of keypoints which belong to the cluster, i.e. ``pointIdxsOfClusters[i]`` is keypoint indices which belong
to the ``i-`` cluster (word of vocabulary) (returned if it is not 0.)
:param pointIdxsOfClusters: Indices of keypoints which belong to the cluster, i.e. ``pointIdxsOfClusters[i]`` is keypoint indices which belong to the ``i-`` cluster (word of vocabulary) (returned if it is not 0.)
:param descriptors: Descriptors of the image keypoints (returned if it is not 0.)
@@ -45,11 +45,11 @@ This class computes the disparity map using block matching algorithm. The class
:math:`>` 0). If ``avergeTexThreshold = 0`` low textureness filtering is disabled, otherwise disparity is set to 0 in each point ``(x, y)`` where for left image
:math:`\sum HorizontalGradiensInWindow(x, y, winSize) < (winSize \cdot winSize) \cdot avergeTexThreshold` i.e. input left image is low textured.
.. c:function:: StereoBeliefPropagation::StereoBeliefPropagation( int ndisp = DEFAULT_NDISP, int iters = DEFAULT_ITERS, int levels = DEFAULT_LEVELS, int msg_type = CV_32F)
This is a simple lightweight class that encapsulate pitched memory on GPU. It is intended to pass to nvcc-compiled code, i.e. CUDA kernels. So it is used internally by OpenCV and by users writes own device code. Its members can be called both from host and from device code. ::
...
...
@@ -21,7 +21,7 @@ This is a simple lightweight class that encapsulate pitched memory on GPU. It is
DevMem2D_(int rows_, int cols_, T *data_, size_t step_);
DevMem2D_(int rows, int cols, T *data, size_t step);
template <typename U>
explicit DevMem2D_(const DevMem2D_<U>& d);
...
...
@@ -37,15 +37,15 @@ This is a simple lightweight class that encapsulate pitched memory on GPU. It is
};
.. index:: gpu::PtrStep_
.. index:: gpu::PtrStep\_
.. _gpu::PtrStep_:
.. gpu::PtrStep\_:
gpu::PtrStep_
-------------
.. c:type:: gpu::PtrStep_
gpu::PtrStep\_
--------------
.. c:type:: gpu::PtrStep\_
This is structure is similar to DevMem2D_but contains only pointer and row step. Width and height fields are excluded due to performance reasons. The structure is for internal use or for users who write own device code. ::
This is structure is similar to DevMem2D\_ but contains only pointer and row step. Width and height fields are excluded due to performance reasons. The structure is for internal use or for users who write own device code. ::
template<typename T> struct PtrStep_
{
...
...
@@ -64,13 +64,13 @@ This is structure is similar to DevMem2D_but contains only pointer and row step.
};
.. index:: gpu::PtrElemStrp_
.. index:: gpu::PtrElemStrp\_
.. _gpu::PtrElemStrp_:
.. gpu::PtrElemStrp\_:
gpu::PtrElemStrp_
-----------------
.. c:type:: gpu::PtrElemStrp_
gpu::PtrElemStrp\_
------------------
.. c:type:: gpu::PtrElemStrp\_
This is structure is similar to DevMem2D_but contains only pointer and row step in elements. Width and height fields are excluded due to performance reasons. This class is can only be constructed if sizeof(T) is a multiple of 256. The structure is for internal use or for users who write own device code. ::
...
...
@@ -84,7 +84,7 @@ This is structure is similar to DevMem2D_but contains only pointer and row step
.. index:: gpu::GpuMat
.. _gpu::GpuMat:
.. gpu::GpuMat:
gpu::GpuMat
-----------
...
...
@@ -136,9 +136,8 @@ Is it a bad practice to leave static or global GpuMat variables allocated, i.e.
See also:
:func:`Mat`
.. index:: gpu::CudaMem
.. _gpu::CudaMem:
.. index:: gpu::CudaMem
gpu::CudaMem
------------
...
...
@@ -187,18 +186,18 @@ Please note that allocation size of such memory types is usually limited. For mo
.. index:: gpu::CudaMem::createMatHeader
cv::gpu::CudaMem::createMatHeader
gpu::CudaMem::createMatHeader
---------------------------------
:func:`Mat`
.. c:function:: Mat CudaMem::createMatHeader() const
.. c:function:: CudaMem::operator Mat() const
.. cpp:function:: Mat CudaMem::createMatHeader() const
.. cpp:function:: CudaMem::operator Mat() const
Creates header without reference counting to CudaMem data.
@@ -168,34 +168,30 @@ Brute-force descriptor matcher. For each descriptor in the first set, this match
};
The class ``BruteForceMatcher_GPU`` has the similar interface to class
. It has two groups of match methods: for matching descriptors of one image with other image or with image set. Also all functions have alternative: save results to GPU memory or to CPU memory.
``Distance`` template parameter is kept for CPU/GPU interfaces similarity. ``BruteForceMatcher_GPU`` supports only ``L1<float>`` and ``L2<float>`` distance types.
The class ``BruteForceMatcher_GPU`` has the similar interface to class. It has two groups of match methods: for matching descriptors of one image with other image or with image set. Also all functions have alternative: save results to GPU memory or to CPU memory. ``Distance`` template parameter is kept for CPU/GPU interfaces similarity. ``BruteForceMatcher_GPU`` supports only ``L1<float>`` and ``L2<float>`` distance types.
:param maskCollection: ``GpuMat`` containing set of masks. It can be obtained from ``std::vector<GpuMat>`` by . Or it can contain user defined mask set. It must be empty matrix or one row matrix, each element is a ``PtrStep`` that points to one mask.
Finds the k best matches for each descriptor from a query set with train descriptors. Found k (or less if not possible) matches are returned in distance increasing order.
Finds the k best matches for each descriptor from a query set with train descriptors. Found k (or less if not possible) matches are returned in distance increasing order. Results will be stored to GPU memory.
Downloads trainIdxand distancematrices obtained via to CPU vector with . If compactResultis true matchesvector will not contain matches for fully masked out query descriptors.
Finds the best matches for each query descriptor which have distance less than given threshold. Found matches are returned in distance increasing order.
Downloads trainIdx, nMatchesand distancematrices obtained via to CPU vector with . If compactResultis true matchesvector will not contain matches for fully masked out query descriptors.
There are two version of algorithm: NPP and OpenCV. NPP calls when ``dstType == CV_8UC1`` or ``dstType == CV_8UC4`` and ``bufType == dstType`` , otherwise calls OpenCV version. NPP supports only ``BORDER_CONSTANT`` border type and doesn't check indices outside image. OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE`` and ``BORDER_CONSTANT`` border types and checks indices outside image.
.. c:function:: Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat\& rowKernel, const Mat\& columnKernel, const Point\& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
.. c:function:: Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel, const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
Creates the separable linear filter engine.
...
...
@@ -546,9 +515,9 @@ See also:,,
.. index:: gpu::sepFilter2D
cv::gpu::sepFilter2D
gpu::sepFilter2D
--------------------
.. c:function:: void sepFilter2D(const GpuMat\& src, GpuMat\& dst, int ddepth, const Mat\& kernelX, const Mat\& kernelY, Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
.. c:function:: void gpu::sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
Applies separable 2D linear filter to the image.
...
...
@@ -566,11 +535,9 @@ cv::gpu::sepFilter2D
See also:,:func:`sepFilter2D` .
.. index:: cv::gpu::createDerivFilter_GPU
.. _cv::gpu::createDerivFilter_GPU:
.. index:: gpu::createDerivFilter_GPU
cv::gpu::createDerivFilter_GPU
gpu::createDerivFilter_GPU
------------------------------
.. c:function:: Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
...
...
@@ -592,9 +559,9 @@ See also:,:func:`createDerivFilter` .
.. index:: gpu::Sobel
cv::gpu::Sobel
gpu::Sobel
--------------
.. c:function:: void Sobel(const GpuMat\& src, GpuMat\& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
.. c:function:: void gpu::Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
Applies generalized Sobel operator to the image.
...
...
@@ -618,9 +585,9 @@ See also:,:func:`Sobel` .
.. index:: gpu::Scharr
cv::gpu::Scharr
gpu::Scharr
---------------
.. c:function:: void Scharr(const GpuMat\& src, GpuMat\& dst, int ddepth, int dx, int dy, double scale = 1, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
.. c:function:: void gpu::Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale = 1, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
Calculates the first x- or y- image derivative using Scharr operator.
...
...
@@ -636,14 +603,11 @@ cv::gpu::Scharr
:param scale: Optional scale factor for the computed derivative values (by default, no scaling is applied, see :func:`getDerivKernels` ).
:param rowBorderType, columnBorderType: Pixel extrapolation method, see :func:`borderInterpolate`
See also:,:func:`Scharr` .
.. index:: cv::gpu::createGaussianFilter_GPU
:param rowBorderType, columnBorderType: Pixel extrapolation method, see :func:`borderInterpolate` See also:,:func:`Scharr` .
Performs a forward or inverse discrete Fourier transform (1D or 2D) of floating point matrix. Can handle real matrices (CV32FC1) and complex matrices in the interleaved format (CV32FC2).
Computes a proximity map for a raster template and an image where the template is searched for.
...
...
@@ -325,8 +325,7 @@ cv::gpu::matchTemplate
:param templ: Template image. Must have the same size and type as ``image`` .
:param result: Map containing comparison results ( ``CV_32FC1`` ). If ``image`` is :math:`W \times H` and
``templ`` is :math:`w \times h` then ``result`` must be :math:`(W-w+1) \times (H-h+1)` .
:param result: Map containing comparison results ( ``CV_32FC1`` ). If ``image`` is :math:`W \times H` and ``templ`` is :math:`w \times h` then ``result`` must be :math:`(W-w+1) \times (H-h+1)` .
:param method: Specifies the way which the template must be compared with the image.
:param src: The source 8-bit or floating-point, 1-channel or 3-channel image
:param dst: The destination image; will have the same size and the same type as ``src``
:param d: The diameter of each pixel neighborhood, that is used during filtering. If it is non-positive, it's computed from ``sigmaSpace``
:param sigmaColor: Filter sigma in the color space. Larger value of the parameter means that farther colors within the pixel neighborhood (see ``sigmaSpace`` ) will be mixed together, resulting in larger areas of semi-equal color
:param sigmaSpace: Filter sigma in the coordinate space. Larger value of the parameter means that farther pixels will influence each other (as long as their colors are close enough; see ``sigmaColor`` ). Then ``d>0`` , it specifies the neighborhood size regardless of ``sigmaSpace`` , otherwise ``d`` is proportional to ``sigmaSpace``
The function applies bilateral filtering to the input image, as described in
:param dst: The destination image; will have the same size and the same type as ``src``
:param ksize: The smoothing kernel size
:param anchor: The anchor point. The default value ``Point(-1,-1)`` means that the anchor is at the kernel center
...
...
@@ -404,9 +408,11 @@ borderInterpolate
Computes source location of extrapolated pixel
:param p: 0-based coordinate of the extrapolated pixel along one of the axes, likely <0 or >= ``len``
:param len: length of the array along the corresponding axis
:param borderType: the border type, one of the ``BORDER_*`` , except for ``BORDER_TRANSPARENT`` and ``BORDER_ISOLATED`` . When ``borderType==BORDER_CONSTANT`` the function always returns -1, regardless of ``p`` and ``len``
The function computes and returns the coordinate of the donor pixel, corresponding to the specified extrapolated pixel when using the specified extrapolation border mode. For example, if we use ``BORDER_WRAP`` mode in the horizontal direction, ``BORDER_REFLECT_101`` in the vertical direction and want to compute value of the "virtual" pixel ``Point(-5, 100)`` in a floating-point image ``img`` , it will be ::
float val = img.at<float>(borderInterpolate(100, img.rows, BORDER_REFLECT_101),
...
...
@@ -419,6 +425,7 @@ Normally, the function is not called directly; it is used inside
See also:
:func:`FilterEngine`,:func:`copyMakeBorder`
.. index:: boxFilter
boxFilter
...
...
@@ -430,6 +437,7 @@ boxFilter
:param src: The source image
:param dst: The destination image; will have the same size and the same type as ``src``
:param ksize: The smoothing kernel size
:param anchor: The anchor point. The default value ``Point(-1,-1)`` means that the anchor is at the kernel center
...
...
@@ -486,10 +494,13 @@ copyMakeBorder
:param src: The source image
:param dst: The destination image; will have the same type as ``src`` and the size ``Size(src.cols+left+right, src.rows+top+bottom)``
:param top, bottom, left, right: Specify how much pixels in each direction from the source image rectangle one needs to extrapolate, e.g. ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built
:param borderType: The border type; see :func:`borderInterpolate`
:param value: The border value if ``borderType==BORDER_CONSTANT``
The function copies the source image into the middle of the destination image. The areas to the left, to the right, above and below the copied source image will be filled with extrapolated pixels. This is not what
:func:`FilterEngine` or based on it filtering functions do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling.
...
...
@@ -527,14 +538,19 @@ createBoxFilter
:param srcType: The source image type
:param sumType: The intermediate horizontal sum type; must have as many channels as ``srcType``
:param dstType: The destination image type; must have as many channels as ``srcType``
:param ksize: The aperture size
:param anchor: The anchor position with the kernel; negative values mean that the anchor is at the kernel center
:param normalize: Whether the sums are normalized or not; see :func:`boxFilter`
:param scale: Another way to specify normalization in lower-level ``getColumnSumFilter``
:param borderType: Which border type to use; see :func:`borderInterpolate`
The function is a convenience function that retrieves horizontal sum primitive filter with
:func:`getRowSumFilter` , vertical sum filter with
:func:`getColumnSumFilter` , constructs new
...
...
@@ -558,14 +574,16 @@ createDerivFilter
:param srcType: The source image type
:param dstType: The destination image type; must have as many channels as ``srcType``
:param dx: The derivative order in respect with x
:param dy: The derivative order in respect with y
:param ksize: The aperture size; see :func:`getDerivKernels`
:param borderType: Which border type to use; see :func:`borderInterpolate`
The function
:func:`createDerivFilter` is a small convenience function that retrieves linear filter coefficients for computing image derivatives using
The function :func:`createDerivFilter` is a small convenience function that retrieves linear filter coefficients for computing image derivatives using
:func:`getDerivKernels` and then creates a separable linear filter with
:func:`createSeparableLinearFilter` . The function is used by
:func:`Sobel` and
...
...
@@ -585,11 +603,14 @@ createGaussianFilter
:param type: The source and the destination image type
:param ksize: The aperture size; see :func:`getGaussianKernel`
:param sigmaX: The Gaussian sigma in the horizontal direction; see :func:`getGaussianKernel`
:param sigmaY: The Gaussian sigma in the vertical direction; if 0, then :math:`\texttt{sigmaY}\leftarrow\texttt{sigmaX}`
:param borderType: Which border type to use; see :func:`borderInterpolate`
The function
:func:`createGaussianFilter` computes Gaussian kernel coefficients and then returns separable linear filter for that kernel. The function is used by
The function :func:`createGaussianFilter` computes Gaussian kernel coefficients and then returns separable linear filter for that kernel. The function is used by
:func:`GaussianBlur` . Note that while the function takes just one data type, both for input and output, you can pass by this limitation by calling
:func:`getGaussianKernel` and then
:func:`createSeparableFilter` directly.
...
...
@@ -610,6 +631,7 @@ createLinearFilter
:param srcType: The source image type
:param dstType: The destination image type; must have as many channels as ``srcType``
:param kernel: The 2D array of filter coefficients
:param anchor: The anchor point within the kernel; special value ``Point(-1,-1)`` means that the anchor is at the kernel center
...
...
@@ -620,6 +642,7 @@ createLinearFilter
the parameter specifies the number of the fractional bits
:param rowBorderType, columnBorderType: The pixel extrapolation methods in the horizontal and the vertical directions; see :func:`borderInterpolate`
:param borderValue: Used in case of constant border
The function returns pointer to 2D linear filter for the specified kernel, the source array type and the destination array type. The function is a higher-level function that calls ``getLinearFilter`` and passes the retrieved 2D filter to
...
...
@@ -644,6 +667,7 @@ createMorphologyFilter
Creates engine for non-separable morphological operations
:param op: The morphology operation id, ``MORPH_ERODE`` or ``MORPH_DILATE``
:param type: The input/output image type
:param element: The 2D 8-bit structuring element for the morphological operation. Non-zero elements indicate the pixels that belong to the element
...
...
@@ -653,6 +677,7 @@ createMorphologyFilter
:param anchor: The anchor position within the structuring element; negative values mean that the anchor is at the center
:param rowBorderType, columnBorderType: The pixel extrapolation methods in the horizontal and the vertical directions; see :func:`borderInterpolate`
:param borderValue: The border value in case of a constant border. The default value, \ ``morphologyDefaultBorderValue`` , has the special meaning. It is transformed :math:`+\inf` for the erosion and to :math:`-\inf` for the dilation, which means that the minimum (maximum) is effectively computed only over the pixels that are inside the image.
The functions construct primitive morphological filtering operations or a filter engine based on them. Normally it's enough to use
...
...
@@ -678,7 +703,9 @@ createSeparableLinearFilter
:param srcType: The source array type
:param dstType: The destination image type; must have as many channels as ``srcType``
:param bufType: The inermediate buffer type; must have as many channels as ``srcType``
:param rowKernel: The coefficients for filtering each row
:param columnKernel: The coefficients for filtering each column
...
...
@@ -691,6 +718,7 @@ createSeparableLinearFilter
the parameter specifies the number of the fractional bits
:param rowBorderType, columnBorderType: The pixel extrapolation methods in the horizontal and the vertical directions; see :func:`borderInterpolate`
:param borderValue: Used in case of a constant border
:param symmetryType: The type of each of the row and column kernel; see :func:`getKernelType` .
...
...
@@ -714,6 +742,7 @@ dilate
:param src: The source image
:param dst: The destination image. It will have the same size and the same type as ``src``
:param element: The structuring element used for dilation. If ``element=Mat()`` , a :math:`3\times 3` rectangular structuring element is used
:param anchor: Position of the anchor within the element. The default value :math:`(-1, -1)` means that the anchor is at the element center
...
...
@@ -721,7 +750,9 @@ dilate
:param iterations: The number of times dilation is applied
:param borderType: The pixel extrapolation method; see :func:`borderInterpolate`
:param borderValue: The border value in case of a constant border. The default value has a special meaning, see :func:`createMorphologyFilter`
The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken:
.. math::
...
...
@@ -743,6 +774,7 @@ erode
:param src: The source image
:param dst: The destination image. It will have the same size and the same type as ``src``
:param element: The structuring element used for dilation. If ``element=Mat()`` , a :math:`3\times 3` rectangular structuring element is used
:param anchor: Position of the anchor within the element. The default value :math:`(-1, -1)` means that the anchor is at the element center
...
...
@@ -750,7 +782,9 @@ erode
:param iterations: The number of times erosion is applied
:param borderType: The pixel extrapolation method; see :func:`borderInterpolate`
:param borderValue: The border value in case of a constant border. The default value has a special meaning, see :func:`createMorphoogyFilter`
The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:
.. math::
...
...
@@ -761,6 +795,7 @@ The function supports the in-place mode. Erosion can be applied several ( ``iter
:param dst: The destination image. It will have the same size and the same number of channels as ``src``
:param ddepth: The desired depth of the destination image. If it is negative, it will be the same as ``src.depth()``
:param kernel: Convolution kernel (or rather a correlation kernel), a single-channel floating point matrix. If you want to apply different kernels to different channels, split the image into separate color planes using :func:`split` and process them individually
:param anchor: The anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor should lie within the kernel. The special default value (-1,-1) means that the anchor is at the kernel center
:param delta: The optional value added to the filtered pixels before storing them in ``dst``
:param borderType: The pixel extrapolation method; see :func:`borderInterpolate`
The function applies an arbitrary linear filter to the image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode.
The function does actually computes correlation, not the convolution:
:param dst: The destination image; will have the same size and the same type as ``src``
:param ksize: The Gaussian kernel size; ``ksize.width`` and ``ksize.height`` can differ, but they both must be positive and odd. Or, they can be zero's, then they are computed from ``sigma*``
:param sigmaX, sigmaY: The Gaussian kernel standard deviations in X and Y direction. If ``sigmaY`` is zero, it is set to be equal to ``sigmaX`` . If they are both zeros, they are computed from ``ksize.width`` and ``ksize.height`` , respectively, see :func:`getGaussianKernel` . To fully control the result regardless of possible future modification of all this semantics, it is recommended to specify all of ``ksize`` , ``sigmaX`` and ``sigmaY``
:param borderType: The pixel extrapolation method; see :func:`borderInterpolate`
The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.
See also:
...
...
@@ -824,7 +868,9 @@ getDerivKernels
Returns filter coefficients for computing spatial image derivatives
:param kx: The output matrix of row filter coefficients; will have type ``ktype``
:param ky: The output matrix of column filter coefficients; will have type ``ktype``
:param dx: The derivative order in respect with x
:param dy: The derivative order in respect with y
...
...
@@ -834,6 +880,7 @@ getDerivKernels
:param normalize: Indicates, whether to normalize (scale down) the filter coefficients or not. In theory the coefficients should have the denominator :math:`=2^{ksize*2-dx-dy-2}` . If you are going to filter floating-point images, you will likely want to use the normalized kernels. But if you compute derivatives of a 8-bit image, store the results in 16-bit image and wish to preserve all the fractional bits, you may want to set ``normalize=false`` .
:param ktype: The type of filter coefficients. It can be ``CV_32f`` or ``CV_64F``
The function computes and returns the filter coefficients for spatial image derivatives. When ``ksize=CV_SCHARR`` , the Scharr
:math:`3 \times 3` kernels are generated, see
:func:`Scharr` . Otherwise, Sobel kernels are generated, see
...
...
@@ -853,6 +900,7 @@ getGaussianKernel
:param sigma: The Gaussian standard deviation. If it is non-positive, it is computed from ``ksize`` as \ ``sigma = 0.3*(ksize/2 - 1) + 0.8``
:param ktype: The type of filter coefficients. It can be ``CV_32f`` or ``CV_64F``
The function computes and returns the
:math:`\texttt{ksize} \times 1` matrix of Gaussian filter coefficients:
...
...
@@ -893,6 +941,7 @@ The function analyzes the kernel coefficients and returns the corresponding kern
* **KERNEL_SMOOTH** All the kernel elements are non-negative and sum to 1. E.g. the Gaussian kernel is both smooth kernel and symmetrical, so the function will return ``KERNEL_SMOOTH | KERNEL_SYMMETRICAL``
* **KERNEL_INTEGER** Al the kernel coefficients are integer numbers. This flag can be combined with ``KERNEL_SYMMETRICAL`` or ``KERNEL_ASYMMETRICAL``
.. index:: getStructuringElement
getStructuringElement
...
...
@@ -903,15 +952,15 @@ getStructuringElement
:param shape: The element shape, one of:
* ``MORPH_RECT`` - rectangular structuring element
* ``MORPH_RECT`` - rectangular structuring element
.. math::
E_{ij}=1
* ``MORPH_ELLIPSE`` - elliptic structuring element, i.e. a filled ellipse inscribed into the rectangle
:param src: The source 1-, 3- or 4-channel image. When ``ksize`` is 3 or 5, the image depth should be ``CV_8U`` , ``CV_16U`` or ``CV_32F`` . For larger aperture sizes it can only be ``CV_8U``
:param dst: The destination array; will have the same size and the same type as ``src``
:param ksize: The aperture linear size. It must be odd and more than 1, i.e. 3, 5, 7 ...
The function smoothes image using the median filter with
...
...
@@ -953,6 +1004,7 @@ morphologyEx
:param src: Source image
:param dst: Destination image. It will have the same size and the same type as ``src``
:param element: Structuring element
:param op: Type of morphological operation, one of the following:
...
...
@@ -970,7 +1022,9 @@ morphologyEx
:param iterations: Number of times erosion and dilation are applied
:param borderType: The pixel extrapolation method; see :func:`borderInterpolate`
:param borderValue: The border value in case of a constant border. The default value has a special meaning, see :func:`createMorphoogyFilter`
The function can perform advanced morphological transformations using erosion and dilation as basic operations.
Opening:
...
...
@@ -1018,6 +1072,7 @@ Laplacian
:param src: Source image
:param dst: Destination image; will have the same size and the same number of channels as ``src``
:param ddepth: The desired depth of the destination image
:param ksize: The aperture size used to compute the second-derivative filters, see :func:`getDerivKernels` . It must be positive and odd
...
...
@@ -1025,7 +1080,9 @@ Laplacian
:param scale: The optional scale factor for the computed Laplacian values (by default, no scaling is applied, see :func:`getDerivKernels` )
:param delta: The optional delta value, added to the results prior to storing them in ``dst``
:param borderType: The pixel extrapolation method, see :func:`borderInterpolate`
The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator:
.. math::
...
...
@@ -1052,6 +1109,7 @@ pyrDown
:param src: The source image
:param dst: The destination image. It will have the specified size and the same type as ``src``
:param dstsize: Size of the destination image. By default it is computed as ``Size((src.cols+1)/2, (src.rows+1)/2)`` . But in any case the following conditions should be satisfied:
.. math::
...
...
@@ -1078,6 +1136,7 @@ pyrUp
:param src: The source image
:param dst: The destination image. It will have the specified size and the same type as ``src``
:param dstsize: Size of the destination image. By default it is computed as ``Size(src.cols*2, (src.rows*2)`` . But in any case the following conditions should be satisfied:
.. math::
...
...
@@ -1099,6 +1158,7 @@ sepFilter2D
:param src: The source image
:param dst: The destination image; will have the same size and the same number of channels as ``src``
:param ddepth: The destination image depth
:param rowKernel: The coefficients for filtering each row
...
...
@@ -1110,6 +1170,7 @@ sepFilter2D
:param delta: The value added to the filtered results before storing them
:param borderType: The pixel extrapolation method; see :func:`borderInterpolate`
The function applies a separable linear filter to the image. That is, first, every row of ``src`` is filtered with 1D kernel ``rowKernel`` . Then, every column of the result is filtered with 1D kernel ``columnKernel`` and the final result shifted by ``delta`` is stored in ``dst`` .
See also:
...
...
@@ -1126,6 +1187,7 @@ Sobel
:param src: The source image
:param dst: The destination image; will have the same size and the same number of channels as ``src``
:param ddepth: The destination image depth
:param xorder: Order of the derivative x
...
...
@@ -1137,7 +1199,9 @@ Sobel
:param scale: The optional scale factor for the computed derivative values (by default, no scaling is applied, see :func:`getDerivKernels` )
:param delta: The optional delta value, added to the results prior to storing them in ``dst``
:param borderType: The pixel extrapolation method, see :func:`borderInterpolate`
In all cases except 1, an
:math:`\texttt{ksize} \times
\texttt{ksize}` separable kernel will be used to calculate the
...
...
@@ -1192,6 +1256,7 @@ Scharr
:param src: The source image
:param dst: The destination image; will have the same size and the same number of channels as ``src``
:param ddepth: The destination image depth
:param xorder: Order of the derivative x
...
...
@@ -1201,7 +1266,9 @@ Scharr
:param scale: The optional scale factor for the computed derivative values (by default, no scaling is applied, see :func:`getDerivKernels` )
:param delta: The optional delta value, added to the results prior to storing them in ``dst``
:param borderType: The pixel extrapolation method, see :func:`borderInterpolate`
The function computes the first x- or y- spatial image derivative using Scharr operator. The call
Other numerous fields of ``CvDTreeNode`` are used internally at the training stage.
...
...
@@ -154,7 +154,7 @@ Decision tree training parameters. ::
bool _use_1se_rule, bool _truncate_pruned_tree,
const float* _priors );
};
..
The structure contains all the decision tree training parameters. There is a default constructor that initializes all the parameters with the default values tuned for standalone classification tree. Any of the parameters can be overridden then, or the structure may be fully initialized using the advanced variant of the constructor.
...
...
@@ -260,7 +260,7 @@ Decision tree training data and shared data for tree ensembles. ::
CvRNG rng;
};
..
This structure is mostly used internally for storing both standalone trees and tree ensembles efficiently. Basically, it contains 3 types of information:
@@ -124,7 +124,7 @@ Parameters of the EM algorithm. ::
const CvMat** covs;
CvTermCriteria term_crit;
};
..
The structure has 2 constructors, the default one represents a rough rule-of-thumb, with another one it is possible to override a variety of parameters, from a single number of mixtures (the only essential problem-dependent parameter), to the initial values for the mixture parameters.
...
...
@@ -186,7 +186,7 @@ EM model. ::
CvMat* inv_eigen_values;
CvMat** cov_rotate_mats;
};
..
.. index:: CvEM::train
...
...
@@ -311,5 +311,5 @@ Example: Clustering random samples of multi-Gaussian distribution using EM ::
The structure has default constructor that initializes parameters for ``RPROP`` algorithm. There is also more advanced constructor to customize the parameters and/or choose backpropagation algorithm. Finally, the individual parameters can be adjusted after the structure is created.
...
...
@@ -212,7 +212,7 @@ MLP model. ::
CvRNG rng;
};
..
Unlike many other models in ML that are constructed and trained at once, in the MLP model these steps are separated. First, a network with the specified topology is created using the non-default constructor or the method ``create`` . All the weights are set to zeros. Then the network is trained using the set of input and output vectors. The training procedure can be repeated more than once, i.e. the weights can be adjusted based on the new training data.
@@ -76,7 +76,7 @@ Training Parameters of Random Trees. ::
int _nactive_vars, int max_tree_count,
float forest_accuracy, int termcrit_type );
};
..
The set of training parameters for the forest is the superset of the training parameters for a single tree. However, Random trees do not need all the functionality/features of decision trees, most noticeably, the trees are not pruned, so the cross-validation parameters are not used.
...
...
@@ -128,7 +128,7 @@ Random Trees. ::
int nclasses;
...
};
..
.. index:: CvRTrees::train
...
...
@@ -295,5 +295,5 @@ Example: Prediction of mushroom goodness using random trees classifier ::
* **OPTFLOW_USE_INITIAL_FLOW** use initial estimations stored in ``nextPts`` . If the flag is not set, then initially :math:`\texttt{nextPts}\leftarrow\texttt{prevPts}`
The function implements the sparse iterative version of the Lucas-Kanade optical flow in pyramids, see
Bouguet00
.
...
...
@@ -86,6 +87,7 @@ updateMotionHistory
:param timestamp: Current time in milliseconds or other units
:param duration: Maximal duration of the motion track in the same units as ``timestamp``
The function updates the motion history image as following:
.. math::
...
...
@@ -145,11 +147,15 @@ calcGlobalOrientation
Calculates the global motion orientation in some selected region.
:param orientation: Motion gradient orientation image, calculated by the function :func:`calcMotionGradient`
:param mask: Mask image. It may be a conjunction of a valid gradient mask, also calculated by :func:`calcMotionGradient` , and the mask of the region, whose direction needs to be calculated
:param mhi: The motion history image, calculated by :func:`updateMotionHistory`
:param timestamp: The timestamp passed to :func:`updateMotionHistory`
:param duration: Maximal duration of motion track in milliseconds, passed to :func:`updateMotionHistory`
The function calculates the average
motion direction in the selected region and returns the angle between
0 degrees and 360 degrees. The average direction is computed from
...
...
@@ -165,9 +171,11 @@ CamShift
Finds the object center, size, and orientation
:param probImage: Back projection of the object histogram; see :func:`calcBackProject`
:param window: Initial search window
:param criteria: Stop criteria for the underlying :func:`meanShift`
The function implements the CAMSHIFT object tracking algrorithm