* :math:`(X, Y, Z)` are the coordinates of a 3D point in the world coordinate space
* :math:`(u, v)` are the coordinates of the projection point in pixels
* :math:`A` is a camera matrix, or a matrix of intrinsic parameters
* :math:`(cx, cy)` is a principal point that is usually at the image center
* :math:`fx, fy` are the focal lengths expressed in pixel-related units
* :math:`(X, Y, Z)` are the coordinates of a 3D point in the world coordinate space
* :math:`(u, v)` are the coordinates of the projection point in pixels
* :math:`A` is a camera matrix, or a matrix of intrinsic parameters
* :math:`(cx, cy)` is a principal point that is usually at the image center
* :math:`fx, fy` are the focal lengths expressed in pixel-related units
Thus, if an image from the camera is
scaled by a factor, all of these parameters should
@ -140,7 +141,7 @@ Finds the camera intrinsic and extrinsic parameters from several views of a cali
:param flags:Different flags that may be zero or a combination of the following values:
* **CV_CALIB_USE_INTRINSIC_GUESS** ``cameraMatrix`` contains valid initial values of ``fx, fy, cx, cy`` that are optimized further. Otherwise, ``(cx, cy)`` is initially set to the image center ( ``imageSize`` is used), and focal distances are computed in a least-squares fashion. Note, that if intrinsic parameters are known, there is no need to use this function just to estimate extrinsic parameters. Use :ref:`solvePnP` instead.
* **CV_CALIB_USE_INTRINSIC_GUESS** ``cameraMatrix`` contains valid initial values of ``fx, fy, cx, cy`` that are optimized further. Otherwise, ``(cx, cy)`` is initially set to the image center ( ``imageSize`` is used), and focal distances are computed in a least-squares fashion. Note, that if intrinsic parameters are known, there is no need to use this function just to estimate extrinsic parameters. Use :ocv:func:`solvePnP` instead.
* **CV_CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global optimization. It stays at the center or at a different location specified when ``CV_CALIB_USE_INTRINSIC_GUESS`` is set too.
@ -159,7 +160,7 @@ object with a known geometry and easily detectable feature points.
Such an object is called a calibration rig or calibration pattern,
and OpenCV has built-in support for a chessboard as a calibration
of intrinsic parameters (when ``CV_CALIB_USE_INTRINSIC_GUESS`` is not set) is only implemented for planar calibration patterns
(where Z-coordinates of the object points must be all zeros). 3D
calibration rigs can also be used as long as initial ``cameraMatrix`` is provided.
@ -173,7 +174,7 @@ The algorithm performs the following steps:
Estimate the initial camera pose as if the intrinsic parameters have been already known. This is done using
:ocv:func:`solvePnP` .
#.
Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points ``imagePoints`` and the projected (using the current estimates for camera parameters and the poses) object points ``objectPoints``. See :ref:`projectPoints` for details.
Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points ``imagePoints`` and the projected (using the current estimates for camera parameters and the poses) object points ``objectPoints``. See :ocv:func:`projectPoints` for details.
The function returns the final re-projection error.
@ -182,11 +183,12 @@ The function returns the final re-projection error.
If you use a non-square (=non-NxN) grid and :ocv:func:`findChessboardCorners` for calibration, and ``calibrateCamera`` returns bad values (zero distortion coefficients, an image center very far from ``(w/2-0.5,h/2-0.5)``, and/or large differences between :math:`f_x` and :math:`f_y` (ratios of 10:1 or more)), then you have probably used ``patternSize=cvSize(rows,cols)`` instead of using ``patternSize=cvSize(cols,rows)`` in :ocv:func:`findChessboardCorners` .
..seealso::
:ocv:func:`FindChessboardCorners`,
:ocv:func:`solvePnP`,
:ocv:func:`initCameraMatrix2D`,
:ocv:func:`stereoCalibrate`,
:ocv:func:`undistort`
:ocv:func:`FindChessboardCorners`,
:ocv:func:`solvePnP`,
:ocv:func:`initCameraMatrix2D`,
:ocv:func:`stereoCalibrate`,
:ocv:func:`undistort`
@ -198,7 +200,7 @@ Computes useful camera characteristics from the camera matrix.
where :math:`\mathrm{rodrigues}` denotes a rotation vector to a rotation matrix transformation, and
:math:`\mathrm{rodrigues}^{-1}` denotes the inverse transformation. See :ref:`Rodrigues` for details.
:math:`\mathrm{rodrigues}^{-1}` denotes the inverse transformation. See :ocv:func:`Rodrigues` for details.
Also, the functions can compute the derivatives of the output vectors with regards to the input vectors (see :ocv:func:`matMulDeriv` ).
The functions are used inside :ocv:func:`stereoCalibrate` but can also be used in your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a function that contains a matrix multiplication.
@ -447,7 +449,7 @@ in a certain order (row by row, left to right in every row). Otherwise, if the f
them, it returns 0. For example, a regular chessboard has 8 x 8
squares and 7 x 7 internal corners, that is, points where the black squares touch each other.
The detected coordinates are approximate, and to determine their positions more accurately, the function calls :ocv:func:`cornerSubPix`.
You also may use the function :ref:`cornerSubPix` with different parameters if returned coordinates are not accurate enough.
You also may use the function :ocv:func:`cornerSubPix` with different parameters if returned coordinates are not accurate enough.
Sample usage of detecting and drawing chessboard corners: ::
@ -655,7 +657,8 @@ Finds a perspective transformation between two planes.
@ -789,8 +793,8 @@ Returns the new camera matrix based on the free scaling parameter.
:param imageSize:Original image size.
:param alpha:Free scaling parameter between 0 (when all the pixels in the undistorted image are valid) and 1 (when all the source image pixels are retained in the undistorted image). See :ref:`StereoRectify` for details.
:param alpha:Free scaling parameter between 0 (when all the pixels in the undistorted image are valid) and 1 (when all the source image pixels are retained in the undistorted image). See :ocv:func:`stereoRectify` for details.
:param newCameraMatrix:Output new camera matrix.
:param newImageSize:Image size after rectification. By default,it is set to ``imageSize`` .
@ -1130,7 +1134,7 @@ The class implements the modified H. Hirschmuller algorithm HH08 that differs fr
* Mutual information cost function is not implemented. Instead, a simpler Birchfield-Tomasi sub-pixel metric from BT96 is used. Though, the color images are supported as well.
* Some pre- and post- processing steps from K. Konolige algorithm :ocv:func:`StereoBM::operator()` are included, for example: pre-filtering (``CV_STEREO_BM_XSOBEL`` type) and post-filtering (uniqueness check, quadratic interpolation and speckle filtering).
* Some pre- and post- processing steps from K. Konolige algorithm :ocv:func:`StereoBM::operator()` are included, for example: pre-filtering (``CV_STEREO_BM_XSOBEL`` type) and post-filtering (uniqueness check, quadratic interpolation and speckle filtering).
@ -1150,7 +1154,9 @@ StereoSGBM::StereoSGBM
:param SADWindowSize:Matched block size. It must be an odd number ``>=1`` . Normally, it should be somewhere in the ``3..11`` range.
:param P1, P2:Parameters that control disparity smoothness. The larger the values are, the smoother the disparity is. ``P1`` is the penalty on the disparity change by plus or minus 1 between neighbor pixels. ``P2`` is the penalty on the disparity change by more than 1 between neighbor pixels. The algorithm requires ``P2 > P1`` . See ``stereo_match.cpp`` sample where some reasonably good ``P1`` and ``P2`` values are shown (like ``8*number_of_image_channels*SADWindowSize*SADWindowSize`` and ``32*number_of_image_channels*SADWindowSize*SADWindowSize`` , respectively).
:param P1:The first parameter controlling the disparity smoothness. See below.
:param P2:The second parameter controlling the disparity smoothness. The larger the values are, the smoother the disparity is. ``P1`` is the penalty on the disparity change by plus or minus 1 between neighbor pixels. ``P2`` is the penalty on the disparity change by more than 1 between neighbor pixels. The algorithm requires ``P2 > P1`` . See ``stereo_match.cpp`` sample where some reasonably good ``P1`` and ``P2`` values are shown (like ``8*number_of_image_channels*SADWindowSize*SADWindowSize`` and ``32*number_of_image_channels*SADWindowSize*SADWindowSize`` , respectively).
:param disp12MaxDiff:Maximum allowed difference (in integer pixel units) in the left-right disparity check. Set it to a non-positive value to disable the check.
@ -1247,7 +1253,7 @@ stereoCalibrate
* **CV_CALIB_RATIONAL_MODEL** Enable coefficients k4, k5, and k6. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the rational model and return 8 coefficients. If the flag is not set, the function computes and returns only 5 distortion coefficients.
The function estimates transformation between two cameras making a stereo pair. If you have a stereo camera where the relative position and orientation of two cameras is fixed, and if you computed poses of an object relative to the first camera and to the second camera, (R1, T1) and (R2, T2), respectively (this can be done with
:ref:`solvePnP` ), then those poses definitely relate to each other. This means that, given (
:ocv:func:`solvePnP` ), then those poses definitely relate to each other. This means that, given (
:math:`R_1`,:math:`T_1` ), it should be possible to compute (
:math:`R_2`,:math:`T_2` ). You only need to know the position and orientation of the second camera relative to the first camera. This is what the described function does. It computes (
:math:`R`,:math:`T` ) so that:
@ -1303,11 +1309,15 @@ stereoRectify
:param T:Translation vector between coordinate systems of the cameras.
:param R1, R2:Output :math:`3 \times 3` rectification transforms (rotation matrices) for the first and the second cameras, respectively.
:param R1:Output 3x3 rectification transform (rotation matrix) for the first camera.
:param R2:Output 3x3 rectification transform (rotation matrix) for the second camera.
:param P1, P2:Output :math:`3 \times 4` projection matrices in the new (rectified) coordinate systems.
:param P1:Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
:param P2:Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
:param flags:Operation flags that may be zero or ``CV_CALIB_ZERO_DISPARITY`` . If the flag is set, the function makes the principal points of each camera have the same pixel coordinates in the rectified views. And if the flag is not set, the function may still shift the images in the horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the useful image area.
@ -1315,7 +1325,9 @@ stereoRectify
:param newImageSize:New image resolution after rectification. The same size should be passed to :ocv:func:`initUndistortRectifyMap` (see the ``stereo_calib.cpp`` sample in OpenCV samples directory). When (0,0) is passed (default), it is set to the original ``imageSize`` . Setting it to larger value can help you preserve details in the original image, especially when there is a big radial distortion.
:param roi1, roi2:Optional output rectangles inside the rectified images where all the pixels are valid. If ``alpha=0`` , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below).
:param roi1:
:param roi2:Optional output rectangles inside the rectified images where all the pixels are valid. If ``alpha=0`` , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below).
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by
:ocv:func:`stereoCalibrate` as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
:param points1, points2:Two arrays of corresponding 2D points. The same formats as in :ref:`findFundamentalMat` are supported.
:param points1:Array of feature points in the first image.
:param points2:The corresponding points in the second image. The same formats as in :ocv:func:`findFundamentalMat` are supported.
:param F:Input fundamental matrix. It can be computed from the same set of point pairs using :ref:`findFundamentalMat` .
:param F:Input fundamental matrix. It can be computed from the same set of point pairs using :ocv:func:`findFundamentalMat` .
:param imageSize:Size of the image.
:param H1, H2:Output rectification homography matrices for the first and for the second images.
:param H1:Output rectification homography matrix for the first image.
:param H2:Output rectification homography matrix for the second image.
:param threshold:Optional threshold used to filter out the outliers. If the parameter is greater than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points for which :math:`|\texttt{points2[i]}^T*\texttt{F}*\texttt{points1[i]}|>\texttt{threshold}` ) are rejected prior to computing the homographies. Otherwise,all the points are considered inliers.
:param m:Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that no data is copied but the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is de-referenced via :ocv:func:`Mat::release` .
:param expr:Assigned matrix expression object. As opposite to the first form of the assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, ``C=A+B`` is expanded to ``add(A, B, C)`` , and :func:`add` takes care of automatic ``C`` reallocation.
@ -815,18 +815,18 @@ These are available assignment operators. Since they all are very different, mak
The cast operator should not be called explicitly. It is used internally by the
:ref:`MatrixExpressions` engine.
Mat::row
------------
..ocv:function:: Mat Mat::row(int i) const
Creates a matrix header for the specified matrix row.
Creates a matrix header for the specified matrix row.
..ocv:function:: Mat Mat::row(int i) const
:param i:A 0-based row index.
@ -847,8 +847,7 @@ The method makes a new header for the specified matrix row and returns it. This
A.row(i) = A.row(j); // will not work
This happens because ``A.row(i)`` forms a temporary header that is further assigned to another header. Remember that each of these operations is O(1), that is, no data is copied. Thus, the above assignment is not true if you may have expected the j-th row to be copied to the i-th row. To achieve that, you should either turn this simple assignment into an expression or use the
:ocv:func:`Mat::copyTo` method:::
This happens because ``A.row(i)`` forms a temporary header that is further assigned to another header. Remember that each of these operations is O(1), that is, no data is copied. Thus, the above assignment is not true if you may have expected the j-th row to be copied to the i-th row. To achieve that, you should either turn this simple assignment into an expression or use the :ocv:func:`Mat::copyTo` method: ::
Mat A;
...
@ -860,9 +859,9 @@ The method makes a new header for the specified matrix row and returns it. This
Mat::col
------------
..ocv:function:: Mat Mat::col(int j) const
Creates a matrix header for the specified matrix column.
Creates a matrix header for the specified matrix column.
..ocv:function:: Mat Mat::col(int j) const
:param j:A 0-based column index.
@ -872,12 +871,12 @@ The method makes a new header for the specified matrix column and returns it. Th
Mat::rowRange
-----------------
Creates a matrix header for the specified row span.
..ocv:function:: Mat Mat::rowRange(int startrow, int endrow) const
..ocv:function:: Mat Mat::rowRange(const Range& r) const
Creates a matrix header for the specified row span.
:param startrow:A 0-based start index of the row span.
:param endrow:A 0-based ending index of the row span.
@ -890,12 +889,12 @@ The method makes a new header for the specified row span of the matrix. Similarl
Mat::colRange
-----------------
Creates a matrix header for the specified row span.
..ocv:function:: Mat Mat::colRange(int startcol, int endcol) const
..ocv:function:: Mat Mat::colRange(const Range& r) const
Creates a matrix header for the specified row span.
:param startcol:A 0-based start index of the column span.
:param endcol:A 0-based ending index of the column span.
@ -908,12 +907,12 @@ The method makes a new header for the specified column span of the matrix. Simil
Mat::diag
-------------
Extracts a diagonal from a matrix, or creates a diagonal matrix.
..ocv:function:: Mat Mat::diag(int d) const
..ocv:function:: static Mat Mat::diag(const Mat& matD)
Extracts a diagonal from a matrix, or creates a diagonal matrix.
:param d:Index of the diagonal, with the following values:
* **d=0** is the main diagonal.
@ -930,20 +929,20 @@ The method makes a new header for the specified matrix diagonal. The new matrix
Mat::clone
--------------
..ocv:function:: Mat Mat::clone() const
Creates a full copy of the array and the underlying data.
Creates a full copy of the array and the underlying data.
..ocv:function:: Mat Mat::clone() const
The method creates a full copy of the array. The original ``step[]`` is not taken into account. So, the array copy is a continuous array occupying ``total()*elemSize()`` bytes.
Mat::copyTo
---------------
Copies the matrix to another one.
..ocv:function:: void Mat::copyTo( OutputArray m ) const
..ocv:function:: void Mat::copyTo( OutputArray m, InputArray mask ) const
Copies the matrix to another one.
:param m:Destination matrix. If it does not have a proper size or type before the operation, it is reallocated.
:param mask:Operation mask. Its non-zero elements indicate which matrix elements need to be copied.
@ -961,9 +960,9 @@ When the operation mask is specified, and the ``Mat::create`` call shown above r
Mat::convertTo
------------------
..ocv:function:: void Mat::convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const
Converts an array to another datatype with optional scaling.
Converts an array to another datatype with optional scaling.
..ocv:function:: void Mat::convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const
:param m:Destination matrix. If it does not have a proper size or type before the operation, it is reallocated.
@ -982,9 +981,9 @@ The method converts source pixel values to the target datatype. ``saturate_cast<
Mat::assignTo
-----------------
..ocv:function:: void Mat::assignTo( Mat& m, int type=-1 ) const
Provides a functional form of ``convertTo``.
Provides a functional form of ``convertTo``.
..ocv:function:: void Mat::assignTo( Mat& m, int type=-1 ) const
:param m:Destination array.
@ -995,9 +994,9 @@ This is an internally used method called by the
:param s:Assigned scalar converted to the actual array type.
@ -1006,9 +1005,9 @@ Mat::setTo
Mat::reshape
----------------
..ocv:function:: Mat Mat::reshape(int cn, int rows=0) const
Changes the shape and/or the number of channels of a 2D matrix without copying the data.
Changes the shape and/or the number of channels of a 2D matrix without copying the data.
..ocv:function:: Mat Mat::reshape(int cn, int rows=0) const
:param cn:New number of channels. If the parameter is 0, the number of channels remains the same.
@ -1039,9 +1038,9 @@ For example, if there is a set of 3D points stored as an STL vector, and you wan
Mat::t
----------
..ocv:function:: MatExpr Mat::t() const
Transposes a matrix.
Transposes a matrix.
..ocv:function:: MatExpr Mat::t() const
The method performs matrix transposition by means of matrix expressions. It does not perform the actual transposition but returns a temporary matrix transposition object that can be further used as a part of more complex matrix expressions or can be assigned to a matrix: ::
@ -1051,9 +1050,9 @@ The method performs matrix transposition by means of matrix expressions. It does
:param method:Matrix inversion method. Possible values are the following:
@ -1068,9 +1067,9 @@ The method performs a matrix inversion by means of matrix expressions. This mean
Mat::mul
------------
..ocv:function:: MatExpr Mat::mul(InputArray m, double scale=1) const
Performs an element-wise multiplication or division of the two matrices.
Performs an element-wise multiplication or division of the two matrices.
..ocv:function:: MatExpr Mat::mul(InputArray m, double scale=1) const
:param m:Another array of the same type and the same size as ``*this``, or a matrix expression.
@ -1085,9 +1084,9 @@ Example: ::
Mat::cross
--------------
..ocv:function:: Mat Mat::cross(InputArray m) const
Computes a cross-product of two 3-element vectors.
Computes a cross-product of two 3-element vectors.
..ocv:function:: Mat Mat::cross(InputArray m) const
:param m:Another cross-product operand.
@ -1096,9 +1095,9 @@ The method computes a cross-product of two 3-element vectors. The vectors must b
Mat::dot
------------
..ocv:function:: double Mat::dot(InputArray m) const
Computes a dot-product of two vectors.
Computes a dot-product of two vectors.
..ocv:function:: double Mat::dot(InputArray m) const
:param m:Another dot-product operand.
@ -1107,12 +1106,12 @@ The method computes a dot-product of two matrices. If the matrices are not singl
Mat::zeros
--------------
Returns a zero array of the specified size and type.
..ocv:function:: static MatExpr Mat::zeros(int rows, int cols, int type)
..ocv:function:: static MatExpr Mat::zeros(Size size, int type)
..ocv:function:: static MatExpr Mat::zeros(int ndims, const int* sizes, int type)
Returns a zero array of the specified size and type.
:param ndims:Array dimensionality.
:param rows:Number of rows.
@ -1136,12 +1135,12 @@ In the example above, a new matrix is allocated only if ``A`` is not a 3x3 float
Mat::ones
-------------
Returns an array of all 1's of the specified size and type.
..ocv:function:: static MatExpr Mat::ones(int rows, int cols, int type)
..ocv:function:: static MatExpr Mat::ones(Size size, int type)
..ocv:function:: static MatExpr Mat::ones(int ndims, const int* sizes, int type)
Returns an array of all 1's of the specified size and type.
:param ndims:Array dimensionality.
:param rows:Number of rows.
@ -1165,11 +1164,11 @@ The above operation does not form a 100x100 matrix of 1's and then multiply it b
Mat::eye
------------
Returns an identity matrix of the specified size and type.
..ocv:function:: static MatExpr Mat::eye(int rows, int cols, int type)
..ocv:function:: static MatExpr Mat::eye(Size size, int type)
Returns an identity matrix of the specified size and type.
:param rows:Number of rows.
:param cols:Number of columns.
@ -1188,12 +1187,12 @@ The method returns a Matlab-style identity matrix initializer, similarly to
Mat::create
---------------
Allocates new array data if needed.
..ocv:function:: void Mat::create(int rows, int cols, int type)
..ocv:function:: void Mat::create(Size size, int type)
..ocv:function:: void Mat::create(int ndims, const int* sizes, int type)
Allocates new array data if needed.
:param ndims:New array dimensionality.
:param rows:New number of rows.
@ -1242,9 +1241,9 @@ because ``cvtColor`` , as well as the most of OpenCV functions, calls ``Mat::cre
Mat::addref
---------------
..ocv:function:: void Mat::addref()
Increments the reference counter.
Increments the reference counter.
..ocv:function:: void Mat::addref()
The method increments the reference counter associated with the matrix data. If the matrix header points to an external data set (see
:ocv:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It is called implicitly by the matrix assignment operator. The reference counter increment is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
@ -1252,9 +1251,9 @@ The method increments the reference counter associated with the matrix data. If
Mat::release
----------------
..ocv:function:: void Mat::release()
Decrements the reference counter and deallocates the matrix if needed.
Decrements the reference counter and deallocates the matrix if needed.
..ocv:function:: void Mat::release()
The method decrements the reference counter associated with the matrix data. When the reference counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers are set to NULL's. If the matrix header points to an external data set (see
:ocv:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case.
@ -1263,11 +1262,11 @@ This method can be called manually to force the matrix data deallocation. But si
Mat::resize
---------------
Changes the number of matrix rows.
..ocv:function:: void Mat::resize( size_t sz )
..ocv:function:: void Mat::resize( size_t sz, const Scalar& s )
Changes the number of matrix rows.
:param sz:New number of rows.
:param s:Value assigned to the newly added elements.
@ -1276,9 +1275,9 @@ The methods change the number of matrix rows. If the matrix is reallocated, the
Mat::reserve
---------------
..ocv:function:: void Mat::reserve( size_t sz )
Reserves space for the certain number of rows.
Reserves space for the certain number of rows.
..ocv:function:: void Mat::reserve( size_t sz )
:param sz:Number of rows.
@ -1286,20 +1285,20 @@ The method reserves space for ``sz`` rows. If the matrix already has enough spac
The methods add one or more elements to the bottom of the matrix. They emulate the corresponding method of the STL vector class. When ``elem`` is ``Mat`` , its type and the number of columns must be the same as in the container matrix.
:param wholeSize:Output parameter that contains the size of the whole matrix containing ``*this`` is a part.
@ -1325,9 +1324,9 @@ After you extracted a submatrix from a matrix using
Mat::adjustROI
------------------
..ocv:function:: Mat& Mat::adjustROI( int dtop, int dbottom, int dleft, int dright )
Adjusts a submatrix size and position within the parent matrix.
Adjusts a submatrix size and position within the parent matrix.
..ocv:function:: Mat& Mat::adjustROI( int dtop, int dbottom, int dleft, int dright )
:param dtop:Shift of the top submatrix boundary upwards.
@ -1350,19 +1349,19 @@ It is your responsibility to make sure ``adjustROI`` does not cross the parent m
The function is used internally by the OpenCV filtering functions, like
:ocv:func:`filter2D` , morphological operations, and so on.
See Also:
:ocv:func:`copyMakeBorder`
..seealso:::ocv:func:`copyMakeBorder`
Mat::operator()
-------------------
Extracts a rectangular submatrix.
..ocv:function:: Mat Mat::operator()( Range rowRange, Range colRange ) const
..ocv:function:: Mat Mat::operator()( const Rect& roi ) const
..ocv:function:: Mat Mat::operator()( const Ranges* ranges ) const
Extracts a rectangular submatrix.
:param rowRange:Start and end row of the extracted submatrix. The upper boundary is not included. To select all the rows, use ``Range::all()``.
@ -1381,9 +1380,10 @@ The operators make a new header for the specified sub-array of ``*this`` . They
Mat::operator CvMat
-----------------------
Creates the ``CvMat`` header for the matrix.
..ocv:function:: Mat::operator CvMat() const
Creates the ``CvMat`` header for the matrix.
The operator creates the ``CvMat`` header for the matrix without copying the underlying data. The reference counter is not taken into account by this operation. Thus, you should make sure than the original matrix is not deallocated while the ``CvMat`` header is used. The operator is useful for intermixing the new and the old OpenCV API's, for example: ::
@ -1399,25 +1399,25 @@ where ``mycvOldFunc`` is a function written to work with OpenCV 1.x data structu
Mat::operator IplImage
--------------------------
..ocv:function:: Mat::operator IplImage() const
Creates the ``IplImage`` header for the matrix.
Creates the ``IplImage`` header for the matrix.
..ocv:function:: Mat::operator IplImage() const
The operator creates the ``IplImage`` header for the matrix without copying the underlying data. You should make sure than the original matrix is not deallocated while the ``IplImage`` header is used. Similarly to ``Mat::operator CvMat`` , the operator is useful for intermixing the new and the old OpenCV API's.
Mat::total
--------------
..ocv:function:: size_t Mat::total() const
Returns the total number of array elements.
Returns the total number of array elements.
..ocv:function:: size_t Mat::total() const
The method returns the number of array elements (a number of pixels if the array represents an image).
Mat::isContinuous
---------------------
..ocv:function:: bool Mat::isContinuous() const
Reports whether the matrix is continuous or not.
Reports whether the matrix is continuous or not.
..ocv:function:: bool Mat::isContinuous() const
The method returns ``true`` if the matrix elements are stored continuously without gaps at the end of each row. Otherwise, it returns ``false``. Obviously, ``1x1`` or ``1xN`` matrices are always continuous. Matrices created with
:ocv:func:`Mat::create` are always continuous. But if you extract a part of the matrix using
@ -1486,36 +1486,36 @@ Another OpenCV idiom in this function, a call of
Mat::elemSize
-----------------
..ocv:function:: size_t Mat::elemSize(void) const
Returns the matrix element size in bytes.
Returns the matrix element size in bytes.
..ocv:function:: size_t Mat::elemSize(void) const
The method returns the matrix element size in bytes. For example, if the matrix type is ``CV_16SC3`` , the method returns ``3*sizeof(short)`` or 6.
Mat::elemSize1
------------------
..ocv:function:: size_t Mat::elemSize() const
Returns the size of each matrix element channel in bytes.
Returns the size of each matrix element channel in bytes.
..ocv:function:: size_t Mat::elemSize() const
The method returns the matrix element channel size in bytes, that is, it ignores the number of channels. For example, if the matrix type is ``CV_16SC3`` , the method returns ``sizeof(short)`` or 2.
Mat::type
-------------
..ocv:function:: int Mat::type() const
Returns the type of a matrix element.
Returns the type of a matrix element.
..ocv:function:: int Mat::type() const
The method returns a matrix element type. This is an identifier compatible with the ``CvMat`` type system, like ``CV_16SC3`` or 16-bit signed 3-channel array, and so on.
Mat::depth
--------------
..ocv:function:: int Mat::depth() const
Returns the depth of a matrix element.
Returns the depth of a matrix element.
..ocv:function:: int Mat::depth() const
The method returns the identifier of the matrix element depth (the type of each individual channel). For example, for a 16-bit signed 3-channel array, the method returns ``CV_16S`` . A complete list of matrix types contains the following values:
@ -1536,18 +1536,18 @@ The method returns the identifier of the matrix element depth (the type of each
Mat::channels
-----------------
..ocv:function:: int Mat::channels() const
Returns the number of matrix channels.
Returns the number of matrix channels.
..ocv:function:: int Mat::channels() const
The method returns the number of matrix channels.
Mat::step1
--------------
..ocv:function:: size_t Mat::step1() const
Returns a normalized step.
Returns a normalized step.
..ocv:function:: size_t Mat::step1() const
The method returns a matrix step divided by
:ocv:func:`Mat::elemSize1()` . It can be useful to quickly access an arbitrary matrix element.
@ -1555,24 +1555,26 @@ The method returns a matrix step divided by
Mat::size
-------------
..ocv:function:: Size Mat::size() const
Returns a matrix size.
Returns a matrix size.
..ocv:function:: Size Mat::size() const
The method returns a matrix size: ``Size(cols, rows)`` .
The method returns a matrix size: ``Size(cols, rows)`` . When the matrix is more than 2-dimensional, the returned size is (-1, -1).
Mat::empty
--------------
..ocv:function:: bool Mat::empty() const
Returns ``true`` if the array has no elemens.
Returns ``true`` if the array has no elemens.
..ocv:function:: bool Mat::empty() const
The method returns ``true`` if ``Mat::total()`` is 0 or if ``Mat::data`` is NULL. Because of ``pop_back()`` and ``resize()`` methods ``M.total() == 0`` does not imply that ``M.data == NULL`` .
Returns a reference to the specified array element.
:param i, j, k:Indices along the dimensions 0, 1, and 2, respectively.
:param i:Index along the dimension 0
:param j:Index along the dimension 1
:param k:Index along the dimension 2
:param pt:Element position specified as ``Point(j,i)`` .
:param idx:Array of ``Mat::dims`` indices.
The template methods return a reference to the specified array element. For the sake of higher performance, the index range checks are only performed in the Debug configuration.
@ -1634,9 +1636,11 @@ The example below initializes a Hilbert matrix: ::
The methods return the matrix read-only or read-write iterators. The use of matrix iterators is very similar to the use of bi-directional STL iterators. In the example below, the alpha blending function is rewritten using the matrix iterators: ::
@ -1673,10 +1677,11 @@ The methods return the matrix read-only or read-write iterators. The use of matr
Mat::end
------------
Returns the matrix iterator and sets it to the after-last matrix element.
That is, ``Ptr<T> ptr`` incapsulates a pointer to a ``T`` instance and a reference counter associated with the pointer. See the
:ref:`Ptr`
:ocv:class:`Ptr`
description for details.
.._AutomaticAllocation:
@ -176,7 +176,7 @@ Multi-channel (``n``-channel) types can be specified using the following options
..note::``CV_32FC1 == CV_32F``, ``CV_32FC2 == CV_32FC(2) == CV_MAKETYPE(CV_32F, 2)``, and ``CV_MAKETYPE(depth, n) == ((x&7)<<3) + (n-1)``. This means that the constant type is formed from the ``depth``, taking the lowest 3 bits, and the number of channels minus 1, taking the next ``log2(CV_CN_MAX)`` bits.
Examples::
Examples: ::
Mat mtx(3, 3, CV_32F); // make a 3x3 floating-point matrix
Mat cmtx(10, 1, CV_64FC2); // make a 10x1 2-channel floating-point
@ -18,7 +18,7 @@ Computes an absolute value of each matrix element.
* ``C = abs(A)`` is equivalent to ``absdiff(A, Scalar::all(0), C)``
* ``C = Mat_<Vec<uchar,n> >(abs(A*alpha + beta))`` is equivalent to :ocv:funcx:`convertScaleAbs`(A, C, alpha, beta)`
* ``C = Mat_<Vec<uchar,n> >(abs(A*alpha + beta))`` is equivalent to :ocv:funcx:`convertScaleAbs`(A, C, alpha, beta)
The output matrix has the same size and the same type as the input one except for the last case, where ``C`` is ``depth=CV_8U`` .
@ -2172,7 +2172,7 @@ PCA constructors
:param maxComponents:Maximum number of components that PCA should retain. By default, all the components are retained.
The default constructor initializes an empty PCA structure. The second constructor initializes the structure and calls
:ocv:func:`PCA::operator()` .
:ocv:func:`PCA::operator()` .
@ -3114,7 +3114,7 @@ The constructors.
* **SVD::FULL_UV** When the matrix is not square, by default the algorithm produces ``u`` and ``vt`` matrices of sufficiently large size for the further ``A`` reconstruction. If, however, ``FULL_UV`` flag is specified, ``u`` and ``vt`` will be full-size square orthogonal matrices.
The first constructor initializes an empty ``SVD`` structure. The second constructor initializes an empty ``SVD`` structure and then calls
:ocv:func:`SVD::operator()` .
:ocv:func:`SVD::operator()` .
SVD::operator ()
@ -3163,7 +3163,7 @@ Performs SVD of a matrix
:param flags:Opertion flags - see :ocv:func:`SVD::SVD`.
The methods/functions perform SVD of matrix. Unlike ``SVD::SVD`` constructor and ``SVD::operator()``, they store the results to the user-provided matrices. ::
The methods/functions perform SVD of matrix. Unlike ``SVD::SVD`` constructor and ``SVD::operator()``, they store the results to the user-provided matrices. ::
Mat A, w, u, vt;
SVD::compute(A, w, u, vt);
@ -3231,7 +3231,7 @@ Calculates the sum of array elements.
:param xyzw:Output 4-channel floating-point image of the same size as ``disp`` . Each element of ``xyzw(x,y)`` contains 3D coordinates ``(x,y,z,1)`` of the point ``(x,y)`` , computed from the disparity map.
:param Q::math:`4 \times 4` perspective transformation matrix that can be obtained via :ref:`StereoRectify` .
:param Q::math:`4 \times 4` perspective transformation matrix that can be obtained via :ocv:func:`stereoRectify` .
:param stream:Stream for the asynchronous version.
@ -115,6 +115,7 @@ By using ``FilterEngine_GPU`` instead of functions you can avoid unnecessary mem
..note:: The GPU filters do not support the in-place mode.
..seealso::
:ocv:class:`gpu::BaseRowFilter_GPU`,
:ocv:class:`gpu::BaseColumnFilter_GPU`,
:ocv:class:`gpu::BaseFilter_GPU`,
@ -454,11 +455,13 @@ gpu::getLinearRowFilter_GPU
:param borderType:Pixel extrapolation method. For details, see :ocv:func:`borderInterpolate`. For details on limitations, see below.
There are two versions of the algorithm: NPP and OpenCV.
* NPP version is called when ``srcType == CV_8UC1`` or ``srcType == CV_8UC4`` and ``bufType == srcType`` . Otherwise, the OpenCV version is called. NPP supports only ``BORDER_CONSTANT`` border type and does not check indices outside the image.
* OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE``, and ``BORDER_CONSTANT`` border types. It checks indices outside the image.
There are two versions of the algorithm: NPP and OpenCV.
* NPP version is called when ``srcType == CV_8UC1`` or ``srcType == CV_8UC4`` and ``bufType == srcType`` . Otherwise, the OpenCV version is called. NPP supports only ``BORDER_CONSTANT`` border type and does not check indices outside the image.
* OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE``, and ``BORDER_CONSTANT`` border types. It checks indices outside the image.
See Also:,:ocv:func:`createSeparableLinearFilter` .
:param anchor:Anchor position within the kernel. Negative values mean that anchor is positioned at the aperture center.
:param rowBorderType, columnBorderType:Pixel extrapolation method in the horizontal and vertical directions For details, see :ocv:func:`borderInterpolate`. For details on limitations, see :ocv:func:`gpu::getLinearRowFilter_GPU`, cpp:ocv:func:`gpu::getLinearColumnFilter_GPU`.
:param rowBorderType:Pixel extrapolation method in the vertical direction For details, see :ocv:func:`borderInterpolate`. For details on limitations, see :ocv:func:`gpu::getLinearRowFilter_GPU`, cpp:ocv:func:`gpu::getLinearColumnFilter_GPU`.
:param columnBorderType:Pixel extrapolation method in the horizontal direction.
:param scale:Optional scale factor for the computed derivative values. By default, no scaling is applied. For details, see :ocv:func:`getDerivKernels` .
:param rowBorderType, columnBorderType:Pixel extrapolation method. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType:Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType:Pixel extrapolation method in the horizontal direction.
:param ksize:Gaussian kernel size. ``ksize.width`` and ``ksize.height`` can differ but they both must be positive and odd. If they are zeros, they are computed from ``sigmaX`` and ``sigmaY`` .
:param sigmaX, sigmaY: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 :ocv:func:`getGaussianKernel` for details. To fully control the result regardless of possible future modification of all this semantics, you are recommended to specify all of ``ksize``, ``sigmaX``, and ``sigmaY`` .
:param sigmaX:Gaussian kernel standard deviation in X direction.
:param sigmaY:Gaussian kernel standard deviation in 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 :ocv:func:`getGaussianKernel` for details. To fully control the result regardless of possible future modification of all this semantics, you are recommended to specify all of ``ksize``, ``sigmaX``, and ``sigmaY`` .
:param rowBorderType, columnBorderType:Pixel extrapolation method. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType:Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType:Pixel extrapolation method in the horizontal direction.
:param criteria:Termination criteria. See :ocv:class:`TermCriteria`.
..index:: gpu::meanShiftProc
gpu::meanShiftProc
----------------------
@ -41,10 +41,8 @@ gpu::meanShiftProc
:param criteria:Termination criteria. See :ocv:class:`TermCriteria`.
..seealso::
:ocv:func:`gpu::meanShiftFiltering`
..seealso:::ocv:func:`gpu::meanShiftFiltering`
..index:: gpu::meanShiftSegmentation
gpu::meanShiftSegmentation
------------------------------
@ -64,7 +62,7 @@ gpu::meanShiftSegmentation
:param criteria:Termination criteria. See :ocv:class:`TermCriteria`.
..index:: gpu::integral
gpu::integral
-----------------
@ -80,10 +78,9 @@ gpu::integral
:param sqsum:Squared integral image of the ``CV_32FC1`` type.
..seealso::
:ocv:func:`integral`
..seealso:::ocv:func:`integral`
..index:: gpu::sqrIntegral
gpu::sqrIntegral
--------------------
@ -95,7 +92,7 @@ gpu::sqrIntegral
:param sqsum:Squared integral image containing 64-bit unsigned integer values packed into ``CV_64FC1`` .
..index:: gpu::columnSum
gpu::columnSum
------------------
@ -107,7 +104,7 @@ gpu::columnSum
:param sum:Destination image of the ``CV_32FC1`` type.
..index:: gpu::cornerHarris
gpu::cornerHarris
---------------------
@ -127,10 +124,8 @@ gpu::cornerHarris
:param borderType:Pixel extrapolation method. Only ``BORDER_REFLECT101`` and ``BORDER_REPLICATE`` are supported for now.
..seealso::
:ocv:func:`cornerHarris`
..seealso:::ocv:func:`cornerHarris`
..index:: gpu::cornerMinEigenVal
gpu::cornerMinEigenVal
--------------------------
@ -152,7 +147,7 @@ gpu::cornerMinEigenVal
..seealso:::ocv:func:`cornerMinEigenVal`
..index:: gpu::mulSpectrums
gpu::mulSpectrums
---------------------
@ -172,10 +167,8 @@ gpu::mulSpectrums
Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
..seealso::
:ocv:func:`mulSpectrums`
..seealso:::ocv:func:`mulSpectrums`
..index:: gpu::mulAndScaleSpectrums
gpu::mulAndScaleSpectrums
-----------------------------
@ -197,10 +190,9 @@ gpu::mulAndScaleSpectrums
Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
..seealso::
:ocv:func:`mulSpectrums`
..seealso:::ocv:func:`mulSpectrums`
..index:: gpu::dft
gpu::dft
------------
@ -236,10 +228,9 @@ gpu::dft
*
If the source matrix is real (its type is ``CV_32FC1`` ), forward DFT is performed. The result of the DFT is packed into complex ( ``CV_32FC2`` ) matrix. So, the width of the destination matrix is ``dft_size.width / 2 + 1`` . But if the source is a single column, the height is reduced instead of the width.
..seealso::
:ocv:func:`dft`
..seealso:::ocv:func:`dft`
..index:: gpu::convolve
gpu::convolve
-----------------
@ -259,7 +250,7 @@ gpu::convolve
:param buf:Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
..index:: gpu::ConvolveBuf
gpu::ConvolveBuf
----------------
@ -280,7 +271,7 @@ Class providing a memory buffer for the :ocv:func:`gpu::convolve` function.
};
..index:: gpu::ConvolveBuf::ConvolveBuf
gpu::ConvolveBuf::ConvolveBuf
---------------------------------
@ -294,7 +285,7 @@ gpu::ConvolveBuf::ConvolveBuf
Constructs a buffer for the
:ocv:func:`convolve` function with respective arguments.
..index:: gpu::matchTemplate
gpu::matchTemplate
----------------------
@ -324,10 +315,8 @@ gpu::matchTemplate
* ``CV_TM_SQDIFF``
* ``CV_TM_CCORR``
..seealso::
:ocv:func:`matchTemplate`
..seealso:::ocv:func:`matchTemplate`
..index:: gpu::remap
gpu::remap
--------------
@ -351,10 +340,8 @@ The function transforms the source image using the specified map:
Values of pixels with non-integer coordinates are computed using the bilinear interpolation.
..seealso::
:ocv:func:`remap`
..seealso:::ocv:func:`remap`
..index:: gpu::cvtColor
gpu::cvtColor
-----------------
@ -376,10 +363,9 @@ gpu::cvtColor
3-channel color spaces (like ``HSV``, ``XYZ``, and so on) can be stored in a 4-channel image for better perfomance.
..seealso::
:ocv:func:`cvtColor`
..seealso:::ocv:func:`cvtColor`
..index:: gpu::threshold
gpu::threshold
------------------
@ -401,10 +387,9 @@ gpu::threshold
:param stream:Stream for the asynchronous version.
..seealso::
:ocv:func:`threshold`
..seealso:::ocv:func:`threshold`
..index:: gpu::resize
gpu::resize
---------------
@ -439,7 +424,7 @@ gpu::resize
..seealso:::ocv:func:`resize`
..index:: gpu::warpAffine
gpu::warpAffine
-------------------
@ -457,10 +442,9 @@ gpu::warpAffine
:param flags:Combination of interpolation methods (see :ocv:func:`resize`) and the optional flag ``WARP_INVERSE_MAP`` specifying that ``M`` is an inverse transformation (``dst=>src``). Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` interpolation methods are supported.
..seealso::
:ocv:func:`warpAffine`
..seealso:::ocv:func:`warpAffine`
..index:: gpu::warpPerspective
gpu::warpPerspective
------------------------
@ -478,10 +462,9 @@ gpu::warpPerspective
:param flags:Combination of interpolation methods (see :ocv:func:`resize` ) and the optional flag ``WARP_INVERSE_MAP`` specifying that ``M`` is the inverse transformation (``dst => src``). Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` interpolation methods are supported.
..seealso::
:ocv:func:`warpPerspective`
..seealso:::ocv:func:`warpPerspective`
..index:: gpu::rotate
gpu::rotate
---------------
@ -503,10 +486,9 @@ gpu::rotate
:param interpolation:Interpolation method. Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` are supported.
..seealso::
:ocv:func:`gpu::warpAffine`
..seealso:::ocv:func:`gpu::warpAffine`
..index:: gpu::copyMakeBorder
gpu::copyMakeBorder
-----------------------
@ -518,14 +500,18 @@ gpu::copyMakeBorder
:param dst:Destination image with the same type as ``src``. The size is ``Size(src.cols+left+right, src.rows+top+bottom)`` .
:param top, bottom, left, right:Number of pixels in each direction from the source image rectangle to extrapolate. For example: ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param top:
:param bottom:
:param left:
:param right:Number of pixels in each direction from the source image rectangle to extrapolate. For example: ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param value:Border value.
..seealso::
:ocv:func:`copyMakeBorder`
..seealso:::ocv:func:`copyMakeBorder`
..index:: gpu::rectStdDev
gpu::rectStdDev
-------------------
@ -541,7 +527,7 @@ gpu::rectStdDev
:param rect:Rectangular window.
..index:: gpu::evenLevels
gpu::evenLevels
-------------------
@ -557,13 +543,11 @@ gpu::evenLevels
:param upperLevel:Upper boundary value of the greatest level.
..index:: gpu::histEven
gpu::histEven
-----------------
..ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel)
..ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4])
:param image:Input 8-bit or floating-point 32-bit, single-channel image.
@ -266,12 +268,14 @@ The function can be used to initialize a point-based tracker of an object.
**Note**: If the function is called with different values ``A`` and ``B`` of the parameter ``qualityLevel`` , and ``A`` > {B}, the vector of returned corners with ``qualityLevel=A`` will be the prefix of the output vector with ``qualityLevel=B`` .
See Also: :ocv:func:`cornerMinEigenVal`,
:ocv:func:`cornerHarris`,
:ocv:func:`calcOpticalFlowPyrLK`,
:ocv:func:`estimateRigidMotion`,
:ocv:func:`PlanarObjectDetector`,
:ocv:func:`OneWayDescriptor`
..seealso::
:ocv:func:`cornerMinEigenVal`,
:ocv:func:`cornerHarris`,
:ocv:func:`calcOpticalFlowPyrLK`,
:ocv:func:`estimateRigidMotion`,
:ocv:func:`PlanarObjectDetector`,
:ocv:func:`OneWayDescriptor`
@ -336,10 +340,10 @@ The function finds circles in a grayscale image using a modification of the Houg
**Note**: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( ``minRadius`` and ``maxRadius`` ) if you know it. Or, you may ignore the returned radius, use only the center, and find the correct radius using an additional procedure.
:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
..seealso::
:ocv:func:`BaseRowFilter`,
:ocv:func:`BaseFilter`,
:ocv:func:`FilterEngine`,
@ -62,7 +63,6 @@ where
:ocv:func:`getMorphologyColumnFilter`
BaseFilter
----------
..ocv:class:: BaseFilter
@ -104,11 +104,12 @@ where
:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
..seealso::
:ocv:func:`BaseColumnFilter`,
:ocv:func:`BaseRowFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getLinearFilter`,
:ocv:func:`getMorphologyFilter`
:ocv:func:`BaseColumnFilter`,
:ocv:func:`BaseRowFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getLinearFilter`,
:ocv:func:`getMorphologyFilter`
@ -145,12 +146,13 @@ where
:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
..seealso::
:ocv:func:`BaseColumnFilter`,
:ocv:func:`Filter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getLinearRowFilter`,
:ocv:func:`getMorphologyRowFilter`,
:ocv:func:`getRowSumFilter`
:ocv:func:`BaseColumnFilter`,
:ocv:func:`Filter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getLinearRowFilter`,
:ocv:func:`getMorphologyRowFilter`,
:ocv:func:`getRowSumFilter`
@ -356,6 +358,7 @@ Explore the data types. As it was mentioned in the
In case of non-separable filtering, ``bufType`` must be the same as ``srcType`` . The source data is copied to the temporary buffer, if needed, and then just passed to ``FilterEngine::filter2D`` . That is, the input type for ``filter2D`` is ``srcType`` (= ``bufType`` ) and the output type is ``dstType`` .
..seealso::
:ocv:func:`BaseColumnFilter`,
:ocv:func:`BaseFilter`,
:ocv:func:`BaseRowFilter`,
@ -426,13 +429,13 @@ The function smoothes an image using the kernel:
The call ``blur(src, dst, ksize, anchor, borderType)`` is equivalent to ``boxFilter(src, dst, src.type(), anchor, true, borderType)`` .
..seealso::
:ocv:func:`boxFilter`,
:ocv:func:`bilateralFilter`,
:ocv:func:`GaussianBlur`,
:ocv:func:`medianBlur`
borderInterpolate
---------------------
Computes the source location of an extrapolated pixel.
@ -458,8 +461,9 @@ Normally, the function is not called directly. It is used inside
:ocv:func:`copyMakeBorder` to compute tables for quick extrapolation.
..seealso::
:ocv:func:`FilterEngine`,
:ocv:func:`copyMakeBorder`
:ocv:func:`FilterEngine`,
:ocv:func:`copyMakeBorder`
@ -500,11 +504,12 @@ and so on). If you need to compute pixel sums over variable-size windows, use
:ocv:func:`integral` .
..seealso::
:ocv:func:`boxFilter`,
:ocv:func:`bilateralFilter`,
:ocv:func:`GaussianBlur`,
:ocv:func:`medianBlur`,
:ocv:func:`integral`
:ocv:func:`boxFilter`,
:ocv:func:`bilateralFilter`,
:ocv:func:`GaussianBlur`,
:ocv:func:`medianBlur`,
:ocv:func:`integral`
@ -540,7 +545,13 @@ Forms a border around an image.
:param dst:Destination image of the same type as ``src`` and the size ``Size(src.cols+left+right, src.rows+top+bottom)`` .
:param top, bottom, left, right:Parameter specifying how many pixels in each direction from the source image rectangle to extrapolate. For example, ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param top:
:param bottom:
:param left:
:param right:Parameter specifying how many pixels in each direction from the source image rectangle to extrapolate. For example, ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param borderType:Border type. See :ocv:func:`borderInterpolate` for details.
@ -567,7 +578,8 @@ The function supports the mode when ``src`` is already in the middle of ``dst``
..seealso::
:ocv:func:`borderInterpolate`
:ocv:func:`borderInterpolate`
createBoxFilter
@ -606,9 +618,10 @@ The function itself is used by
:ocv:func:`boxFilter` .
..seealso::
:ocv:func:`FilterEngine`,
:ocv:func:`blur`,
:ocv:func:`boxFilter`
:ocv:func:`FilterEngine`,
:ocv:func:`blur`,
:ocv:func:`boxFilter`
@ -637,10 +650,11 @@ The function :ocv:func:`createDerivFilter` is a small convenience function that
:ocv:func:`Scharr` .
..seealso::
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getDerivKernels`,
:ocv:func:`Scharr`,
:ocv:func:`Sobel`
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getDerivKernels`,
:ocv:func:`Scharr`,
:ocv:func:`Sobel`
@ -666,9 +680,10 @@ The function :ocv:func:`createGaussianFilter` computes Gaussian kernel coefficie
:ocv:func:`createSeparableFilter` directly.
..seealso::
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getGaussianKernel`,
:ocv:func:`GaussianBlur`
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getGaussianKernel`,
:ocv:func:`GaussianBlur`
@ -692,7 +707,9 @@ Creates a non-separable linear filter engine.
:param bits:Number of the fractional bits. the parameter is used when the kernel is an integer matrix representing fixed-point filter coefficients.
:param rowBorderType, columnBorderType:Pixel extrapolation methods in the horizontal and vertical directions. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType:Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType:Pixel extrapolation method in the horizontal direction.
:param borderValue:Border vaule used in case of a constant border.
@ -700,9 +717,10 @@ The function returns a pointer to a 2D linear filter for the specified kernel, t
:ocv:func:`FilterEngine` constructor.
..seealso::
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`filter2D`
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`filter2D`
createMorphologyFilter
@ -729,7 +747,9 @@ Creates an engine for non-separable morphological operations.
:param anchor:Anchor position within the structuring element. Negative values mean that the anchor is at the kernel center.
:param rowBorderType, columnBorderType:Pixel extrapolation methods in the horizontal and vertical directions. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType:Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType:Pixel extrapolation method in the horizontal direction.
:param borderValue:Border value in case of a constant border. The default value, \ ``morphologyDefaultBorderValue`` , has a 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.
@ -742,10 +762,11 @@ Note that
:ocv:func:`createMorphologyFilter` analyzes the structuring element shape and builds a separable morphological filter engine when the structuring element is square.
..seealso::
:ocv:func:`erode`,
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`FilterEngine`
:ocv:func:`erode`,
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`FilterEngine`
createSeparableLinearFilter
@ -774,7 +795,9 @@ Creates an engine for a separable linear filter.
:param bits:Number of the fractional bits. The parameter is used when the kernel is an integer matrix representing fixed-point filter coefficients.
:param rowBorderType, columnBorderType:Pixel extrapolation methods in the horizontal and vertical directions. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType:Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType:Pixel extrapolation method in the horizontal direction.
:param borderValue:Border value used in case of a constant border.
@ -787,10 +810,11 @@ The functions construct primitive separable linear filtering operations or a fil
:ocv:func:`FilterEngine` constructor.
..seealso::
:ocv:func:`sepFilter2D`,
:ocv:func:`createLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getKernelType`
:ocv:func:`sepFilter2D`,
:ocv:func:`createLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getKernelType`
dilate
@ -827,9 +851,10 @@ The function dilates the source image using the specified structuring element th
The function supports the in-place mode. Dilation can be applied several ( ``iterations`` ) times. In case of multi-channel images, each channel is processed independently.
..seealso::
:ocv:func:`erode`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
:ocv:func:`erode`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
erode
@ -866,9 +891,10 @@ The function erodes the source image using the specified structuring element tha
The function supports the in-place mode. Erosion can be applied several ( ``iterations`` ) times. In case of multi-channel images, each channel is processed independently.
..seealso::
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
@ -911,10 +937,11 @@ That is, the kernel is not mirrored around the anchor point. If you need a real
The function uses the DFT-based algorithm in case of sufficiently large kernels (~``11 x 11`` or larger) and the direct algorithm (that uses the engine retrieved by :ocv:func:`createLinearFilter` ) for small kernels.
..seealso::
:ocv:func:`sepFilter2D`,
:ocv:func:`createLinearFilter`,
:ocv:func:`dft`,
:ocv:func:`matchTemplate`
:ocv:func:`sepFilter2D`,
:ocv:func:`createLinearFilter`,
:ocv:func:`dft`,
:ocv:func:`matchTemplate`
@ -932,13 +959,16 @@ Smoothes an image using a Gaussian filter.
:param ksize:Gaussian kernel size. ``ksize.width`` and ``ksize.height`` can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from ``sigma*`` .
:param sigmaX, sigmaY: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 :ocv:func:`getGaussianKernel` for details. To fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ``ksize`` , ``sigmaX`` , and ``sigmaY`` .
:param sigmaX:Gaussian kernel standard deviation in X direction.
:param sigmaY:Gaussian kernel standard deviation in Y direction. If ``sigmaY`` is zero, it is set to be equal to ``sigmaX`` . If both sigmas are zeros, they are computed from ``ksize.width`` and ``ksize.height`` , respectively. See :ocv:func:`getGaussianKernel` for details. To fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ``ksize`` , ``sigmaX`` , and ``sigmaY`` .
:param borderType:Pixel extrapolation method. See :ocv:func:`borderInterpolate` for details.
The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.
..seealso::
:ocv:func:`sepFilter2D`,
:ocv:func:`filter2D`,
:ocv:func:`blur`,
@ -1009,6 +1039,7 @@ Two of such generated kernels can be passed to
:ocv:func:`GaussianBlur`.
..seealso::
:ocv:func:`sepFilter2D`,
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getDerivKernels`,
@ -1111,10 +1142,11 @@ The function smoothes an image using the median filter with the
:math:`\texttt{ksize} \times \texttt{ksize}` aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported.
..seealso::
:ocv:func:`bilateralFilter`,
:ocv:func:`blur`,
:ocv:func:`boxFilter`,
:ocv:func:`GaussianBlur`
:ocv:func:`bilateralFilter`,
:ocv:func:`blur`,
:ocv:func:`boxFilter`,
:ocv:func:`GaussianBlur`
@ -1188,9 +1220,10 @@ Morphological gradient:
Any of the operations can be done in-place.
..seealso::
:ocv:func:`dilate`,
:ocv:func:`erode`,
:ocv:func:`createMorphologyFilter`
:ocv:func:`dilate`,
:ocv:func:`erode`,
:ocv:func:`createMorphologyFilter`
@ -1234,8 +1267,9 @@ This is done when ``ksize > 1`` . When ``ksize == 1`` , the Laplacian is compute
\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}
..seealso::
:ocv:func:`Sobel`,
:ocv:func:`Scharr`
:ocv:func:`Sobel`,
:ocv:func:`Scharr`
@ -1370,6 +1404,7 @@ Applies a separable linear filter to an image.
The function applies a separable linear filter to the image. That is, first, every row of ``src`` is filtered with the 1D kernel ``rowKernel`` . Then, every column of the result is filtered with the 1D kernel ``columnKernel`` . The final result shifted by ``delta`` is stored in ``dst`` .
..seealso::
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`filter2D`,
:ocv:func:`Sobel`,
@ -1392,7 +1427,7 @@ Smooths the image in one of several ways.
:param smoothtype:Type of the smoothing:
* **CV_BLUR_NO_SCALE** linear convolution with :math:`\texttt{param1}\times\texttt{param2}` box kernel (all 1's). If you want to smooth different pixels with different-size box kernels, you can use the integral image that is computed using :ref:`Integral`
* **CV_BLUR_NO_SCALE** linear convolution with :math:`\texttt{param1}\times\texttt{param2}` box kernel (all 1's). If you want to smooth different pixels with different-size box kernels, you can use the integral image that is computed using :ocv:func:`integral`
* **CV_BLUR** linear convolution with :math:`\texttt{param1}\times\texttt{param2}` box kernel (all 1's) with subsequent scaling by :math:`1/(\texttt{param1}\cdot\texttt{param2})`
@ -1500,11 +1535,12 @@ The second case corresponds to a kernel of:
:param src:Coordinates of quadrangle vertices in the source image.
@ -138,10 +142,11 @@ where
src(i)=(x_i, y_i),
i=0,1,2,3
See Also:
:ocv:func:`findHomography`,
:ocv:func:`warpPerspective`,
:ocv:func:`perspectiveTransform`
..seealso::
:ocv:func:`findHomography`,
:ocv:func:`warpPerspective`,
:ocv:func:`perspectiveTransform`
getRectSubPix
@ -179,9 +184,10 @@ outside. In this case, the replication border mode (see
:ocv:func:`borderInterpolate` ) is used to extrapolate
the pixel values outside of the image.
See Also:
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`
..seealso::
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`
getRotationMatrix2D
@ -218,12 +224,11 @@ where
The transformation maps the rotation center to itself. If this is not the target, adjust the shift.
See Also:
:ocv:func:`getAffineTransform`,
:ocv:func:`warpAffine`,
:ocv:func:`transform`
..seealso::
:ocv:func:`getAffineTransform`,
:ocv:func:`warpAffine`,
:ocv:func:`transform`
@ -269,21 +274,22 @@ Remaps an image to log-polar space.
:param flags:A combination of interpolation methods and the following optional flags:
* **CV_WARP_FILL_OUTLIERS** fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero
* **CV_WARP_FILL_OUTLIERS** fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero
* **CV_WARP_INVERSE_MAP** See below
* **CV_WARP_INVERSE_MAP** See below
The function ``cvLogPolar`` transforms the source image using the following transformation:
* Forward transformation (``CV_WARP_INVERSE_MAP``is not set):
*
Forward transformation (``CV_WARP_INVERSE_MAP``is not set):
..math::
dst( \phi , \rho ) = src(x,y)
* Inverse transformation (``CV_WARP_INVERSE_MAP`` is set):
*
Inverse transformation (``CV_WARP_INVERSE_MAP`` is set):
..math::
@ -409,12 +415,11 @@ If you want to decimate the image by factor of 2 in each direction, you can call
To shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK).
See Also:
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`,
:ocv:func:`remap`
..seealso::
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`,
:ocv:func:`remap`
warpAffine
@ -455,12 +460,13 @@ when the flag ``WARP_INVERSE_MAP`` is set. Otherwise, the transformation is firs
:ocv:func:`invertAffineTransform` and then put in the formula above instead of ``M`` .
The function cannot operate in-place.
See Also:
:ocv:func:`warpPerspective`,
:ocv:func:`resize`,
:ocv:func:`remap`,
:ocv:func:`getRectSubPix`,
:ocv:func:`transform`
..seealso::
:ocv:func:`warpPerspective`,
:ocv:func:`resize`,
:ocv:func:`remap`,
:ocv:func:`getRectSubPix`,
:ocv:func:`transform`
..note::``cvGetQuadrangleSubPix`` is similar to ``cvWarpAffine``, but the outliers are extrapolated using replication border mode.
@ -501,12 +507,13 @@ when the flag ``WARP_INVERSE_MAP`` is set. Otherwise, the transformation is firs
:ocv:func:`invert` and then put in the formula above instead of ``M`` .
The function cannot operate in-place.
See Also:
:ocv:func:`warpAffine`,
:ocv:func:`resize`,
:ocv:func:`remap`,
:ocv:func:`getRectSubPix`,
:ocv:func:`perspectiveTransform`
..seealso::
:ocv:func:`warpAffine`,
:ocv:func:`resize`,
:ocv:func:`remap`,
:ocv:func:`getRectSubPix`,
:ocv:func:`perspectiveTransform`
@ -529,27 +536,27 @@ Computes the undistortion and rectification transformation map.
:param distCoeffs:Input vector of distortion coefficients :math:`(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])` of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
:param R:Optional rectification transformation in the object space (3x3 matrix). ``R1`` or ``R2`` , computed by :ref:`StereoRectify` can be passed here. If the matrix is empty, the identity transformation is assumed. In ``cvInitUndistortMap`` R assumed to be an identity matrix.
:param R:Optional rectification transformation in the object space (3x3 matrix). ``R1`` or ``R2`` , computed by :ocv:func:`stereoRectify` can be passed here. If the matrix is empty, the identity transformation is assumed. In ``cvInitUndistortMap`` R assumed to be an identity matrix.
:param newCameraMatrix:New camera matrix :math:`A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}` .
:param size:Undistorted image size.
:param m1type:Type of the first output map that can be ``CV_32FC1`` or ``CV_16SC2`` . See :ref:`convertMaps` for details.
:param m1type:Type of the first output map that can be ``CV_32FC1`` or ``CV_16SC2`` . See :ocv:func:`convertMaps` for details.
:param map1:The first output map.
:param map2:The second output map.
The function computes the joint undistortion and rectification transformation and represents the result in the form of maps for
:ref:`Remap` . The undistorted image looks like original, as if it is captured with a camera using the camera matrix ``=newCameraMatrix`` and zero distortion. In case of a monocular camera, ``newCameraMatrix`` is usually equal to ``cameraMatrix`` , or it can be computed by
:ref:`GetOptimalNewCameraMatrix` for a better control over scaling. In case of a stereo camera, ``newCameraMatrix`` is normally set to ``P1`` or ``P2`` computed by
:ref:`StereoRectify` .
:ocv:func:`remap` . The undistorted image looks like original, as if it is captured with a camera using the camera matrix ``=newCameraMatrix`` and zero distortion. In case of a monocular camera, ``newCameraMatrix`` is usually equal to ``cameraMatrix`` , or it can be computed by
:ocv:func:`getOptimalNewCameraMatrix` for a better control over scaling. In case of a stereo camera, ``newCameraMatrix`` is normally set to ``P1`` or ``P2`` computed by
:ocv:func:`stereoRectify` .
Also, this new camera is oriented differently in the coordinate space, according to ``R`` . That, for example, helps to align two heads of a stereo camera so that the epipolar lines on both images become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).
The function actually builds the maps for the inverse mapping algorithm that is used by
:ref:`Remap` . That is, for each pixel
:ocv:func:`remap` . That is, for each pixel
:math:`(u, v)` in the destination (corrected and rectified) image, the function computes the corresponding coordinates in the source image (that is, in the original image from camera). The following process is applied:
..math::
@ -560,9 +567,9 @@ where
:math:`(k_1, k_2, p_1, p_2[, k_3])` are the distortion coefficients.
In case of a stereo camera, this function is called twice: once for each camera head, after
:ref:`StereoRectify` , which in its turn is called after
:ref:`StereoCalibrate` . But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from the fundamental matrix using
:ref:`StereoRectifyUncalibrated` . For each camera, the function computes homography ``H`` as the rectification transformation in a pixel domain, not a rotation matrix ``R`` in 3D space. ``R`` can be computed from ``H`` as
:ocv:func:`stereoRectify` , which in its turn is called after
:ocv:func:`stereoCalibrate` . But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from the fundamental matrix using
:ocv:func:`stereoRectifyUncalibrated` . For each camera, the function computes homography ``H`` as the rectification transformation in a pixel domain, not a rotation matrix ``R`` in 3D space. ``R`` can be computed from ``H`` as
..math::
@ -587,7 +594,7 @@ Returns the default new camera matrix.
:param centerPrincipalPoint:Location of the principal point in the new camera matrix. The parameter indicates whether this location should be at the image center or not.
The function returns the camera matrix that is either an exact copy of the input ``cameraMatrix`` (when ``centerPrinicipalPoint=false`` ), or the modified one (when ``centerPrincipalPoint`` =true).
The function returns the camera matrix that is either an exact copy of the input ``cameraMatrix`` (when ``centerPrinicipalPoint=false`` ), or the modified one (when ``centerPrincipalPoint=true``).
In the latter case, the new camera matrix will be:
@ -602,8 +609,8 @@ where
:math:`(1,1)` elements of ``cameraMatrix`` , respectively.
By default, the undistortion functions in OpenCV (see
:ref:`initUndistortRectifyMap`,
:ref:`undistort`) do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.
:ocv:func:`initUndistortRectifyMap`,
:ocv:func:`undistort`) do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.
@ -639,10 +646,10 @@ The function is simply a combination of
Those pixels in the destination image, for which there is no correspondent pixels in the source image, are filled with zeros (black color).
A particular subset of the source image that will be visible in the corrected image can be regulated by ``newCameraMatrix`` . You can use
:ref:`GetOptimalNewCameraMatrix` to compute the appropriate ``newCameraMatrix`` depending on your requirements.
:ocv:func:`getOptimalNewCameraMatrix` to compute the appropriate ``newCameraMatrix`` depending on your requirements.
The camera matrix and the distortion parameters can be determined using
:ref:`calibrateCamera` . If the resolution of images is different from the resolution used at the calibration stage,
:ocv:func:`calibrateCamera` . If the resolution of images is different from the resolution used at the calibration stage,
:math:`f_x, f_y, c_x` and
:math:`c_y` need to be scaled accordingly, while the distortion coefficients remain the same.
@ -666,14 +673,14 @@ Computes the ideal point coordinates from the observed point coordinates.
:param distCoeffs:Input vector of distortion coefficients :math:`(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])` of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
:param R:Rectification transformation in the object space (3x3 matrix). ``R1`` or ``R2`` computed by :ref:`StereoRectify` can be passed here. If the matrix is empty, the identity transformation is used.
:param R:Rectification transformation in the object space (3x3 matrix). ``R1`` or ``R2`` computed by :ocv:func:`stereoRectify` can be passed here. If the matrix is empty, the identity transformation is used.
:param P:New camera matrix (3x3) or new projection matrix (3x4). ``P1`` or ``P2`` computed by :ref:`StereoRectify` can be passed here. If the matrix is empty, the identity new camera matrix is used.
:param P:New camera matrix (3x3) or new projection matrix (3x4). ``P1`` or ``P2`` computed by :ocv:func:`stereoRectify` can be passed here. If the matrix is empty, the identity new camera matrix is used.
The function is similar to
:ref:`undistort` and
:ref:`initUndistortRectifyMap` but it operates on a sparse set of points instead of a raster image. Also the function performs a reverse transformation to
:ref:`projectPoints` . In case of a 3D object, it does not reconstruct its 3D coordinates, but for a planar object, it does, up to a translation vector, if the proper ``R`` is specified. ::
:ocv:func:`undistort` and
:ocv:func:`initUndistortRectifyMap` but it operates on a sparse set of points instead of a raster image. Also the function performs a reverse transformation to
:ocv:func:`projectPoints` . In case of a 3D object, it does not reconstruct its 3D coordinates, but for a planar object, it does, up to a translation vector, if the proper ``R`` is specified. ::
// (u,v) is the input point, (u', v') is the output point
@ -145,9 +145,7 @@ The functions ``calcBackProject`` calculate the back project of the histogram. T
This is an approximate algorithm of the
:ocv:func:`CAMShift` color object tracker.
See Also:
:ocv:func:`calcHist`
..seealso:::ocv:func:`calcHist`
.._compareHist:
compareHist
@ -312,7 +310,7 @@ Locates a template within an image by using a histogram comparison.
:param hist:Histogram
:param method:Comparison method, passed to :ref:`CompareHist` (see description of that function)
:param method:Comparison method, passed to :ocv:cfunc:`CompareHist` (see description of that function)
:param factor:Normalization factor for histograms, will affect the normalization scale of the destination image, pass 1 if unsure
@ -420,7 +418,11 @@ Returns a pointer to the histogram bin.
:param hist:Histogram
:param idx0, idx1, idx2, idx3:Indices of the bin
:param idx0:0-th index
:param idx1:1-st index
:param idx2:2-nd index
:param idx:Array of indices
@ -475,9 +477,9 @@ Makes a histogram out of an array.
:param data:Array that will be used to store histogram bins
:param ranges:Histogram bin ranges, see :ref:`CreateHist`
:param ranges:Histogram bin ranges, see :ocv:cfunc:`CreateHist`
:param uniform:Uniformity flag, see :ref:`CreateHist`
:param uniform:Uniformity flag, see :ocv:cfunc:`CreateHist`
The function initializes the histogram, whose header and bins are allocated by the user. :ocv:cfunc:`ReleaseHist` does not need to be called afterwards. Only dense histograms can be initialized this way. The function returns ``hist``.
@ -511,7 +513,11 @@ Queries the value of the histogram bin.
:param hist:Histogram
:param idx0, idx1, idx2, idx3:Indices of the bin
:param idx0:0-th index
:param idx1:1-st index
:param idx2:2-nd index
:param idx:Array of indices
@ -536,9 +542,9 @@ Sets the bounds of the histogram bins.
:param hist:Histogram
:param ranges:Array of bin ranges arrays, see :ref:`CreateHist`
:param ranges:Array of bin ranges arrays, see :ocv:cfunc:`CreateHist`
:param uniform:Uniformity flag, see :ref:`CreateHist`
:param uniform:Uniformity flag, see :ocv:cfunc:`CreateHist`
The function is a stand-alone function for setting bin ranges in the histogram. For a more detailed description of the parameters ``ranges`` and ``uniform`` see the :ocv:cfunc:`CalcHist` function, that can initialize the ranges as well. Ranges for the histogram bins must be set before the histogram is calculated or the backproject of the histogram is calculated.
@ -581,5 +587,4 @@ between the calculated minimum and maximum distances are incremented
..[RubnerSept98] Y. Rubner. C. Tomasi, L.J. Guibas. The Earth Mover’s Distance as a Metric for Image Retrieval. Technical Report STAN-CS-TN-98-86, Department of Computer Science, Stanford University, September 1998.
..[Iivarinen97] Jukka Iivarinen, Markus Peura, Jaakko Srel, and Ari Visa. Comparison of Combined Shape Descriptors for Irregular Objects, 8th British Machine Vision Conference, BMVC'97.
..[Iivarinen97] Jukka Iivarinen, Markus Peura, Jaakko Srel, and Ari Visa. Comparison of Combined Shape Descriptors for Irregular Objects, 8th British Machine Vision Conference, BMVC'97. http://www.cis.hut.fi/research/IA/paper/publications/bmvc97/bmvc97.html
Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on. Various modes of the function are demonstrated in the ``floodfill.cpp`` sample.
See Also:
:ocv:func:`findContours`
..seealso:::ocv:func:`findContours`
@ -743,13 +741,13 @@ Currently, Otsu's method is implemented only for 8-bit images.
..image:: pics/threshold.png
See Also:
:ocv:func:`adaptiveThreshold`,
:ocv:func:`findContours`,
:ocv:func:`compare`,
:ocv:func:`min`,
:ocv:func:`max`
..seealso::
:ocv:func:`adaptiveThreshold`,
:ocv:func:`findContours`,
:ocv:func:`compare`,
:ocv:func:`min`,
:ocv:func:`max`
watershed
@ -787,9 +785,7 @@ example, when such tangent components exist in the initial
marker image. Visual demonstration and usage example of the function
can be found in the OpenCV samples directory (see the ``watershed.cpp`` demo).
See Also:
:ocv:func:`findContours`
..seealso:::ocv:func:`findContours`
grabCut
@ -814,7 +810,9 @@ Runs the GrabCut algorithm.
:param rect:ROI containing a segmented object. The pixels outside of the ROI are marked as "obvious background". The parameter is only used when ``mode==GC_INIT_WITH_RECT`` .
:param bgdModel, fgdModel:Temporary arrays used for segmentation. Do not modify them while you are processing the same image.
:param bgdModel:Temporary array for the background model. Do not modify it while you are processing the same image.
:param fgdModel:Temporary arrays for the foreground model. Do not modify it while you are processing the same image.
:param iterCount:Number of iterations the algorithm should make before returning the result. Note that the result can be refined with further calls with ``mode==GC_INIT_WITH_MASK`` or ``mode==GC_EVAL`` .
@ -71,9 +71,10 @@ The moments of a contour are defined in the same way but computed using Green's
http://en.wikipedia.org/wiki/Green_theorem
). So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour.
These values are proved to be invariants to the image scale, rotation, and reflection except the seventh one, whose sign is changed by reflection. This invariance is proved with the assumption of infinite image resolution. In case of raster images, the computed Hu invariants for the original and transformed images are a bit different.
See Also:
:ocv:func:`matchShapes`
..seealso:::ocv:func:`matchShapes`
findContours
@ -280,7 +280,7 @@ Approximates Freeman chain(s) with a polygonal curve.
:param storage:Storage location for the resulting polylines
:param method:Approximation method (see the description of the function :ref:`FindContours` )
:param method:Approximation method (see the description of the function :ocv:cfunc:`FindContours` )
:param parameter:Method parameter (not used now)
@ -463,7 +463,9 @@ Fits a line to a 2D or 3D point set.
:param param:Numerical parameter ( ``C`` ) for some types of distances. If it is 0, an optimal value is chosen.
:param reps, aeps:Sufficient accuracy for the radius (distance between the coordinate origin and the line) and angle, respectively. 0.01 would be a good default value for both.
:param reps:Sufficient accuracy for the radius (distance between the coordinate origin and the line).
:param aeps:Sufficient accuracy for the angle. 0.01 would be a good default value for ``reps`` and ``aeps``.
The function ``fitLine`` fits a line to a 2D or 3D point set by minimizing
@ -78,7 +78,7 @@ The structure represents a possible decision tree node split. It has public memb
Pointer to the next split in the node list of splits.
..ocv:member:: int subset[2]
..ocv:member:: int[] subset
Bit array indicating the value subset in case of split on a categorical variable. The rule is:
@ -90,13 +90,11 @@ The structure represents a possible decision tree node split. It has public memb
..ocv:member:: float ord.c
The threshold value in case of split on an ordered variable. The rule is:
The threshold value in case of split on an ordered variable. The rule is: ::
::
if var_value < c
then next_node<-left
else next_node<-right
if var_value < c
then next_node<-left
else next_node<-right
..ocv:member:: int ord.split_point
@ -125,7 +123,7 @@ The structure represents a node in a decision tree. It has public members:
Pointer to the parent node.
..ocv:mebmer:: CvDTreeNode* left
..ocv:member:: CvDTreeNode* left
Pointer to the left child node.
@ -137,7 +135,7 @@ The structure represents a node in a decision tree. It has public members:
Pointer to the first (primary) split in the node list of splits.
..ocv:mebmer:: int sample_count
..ocv:member:: int sample_count
The number of samples that fall into the node at the training stage. It is used to resolve the difficult cases - when the variable for the primary split is missing and all the variables for other surrogate splits are missing too. In this case the sample is directed to the left if ``left->sample_count > right->sample_count`` and to the right otherwise.
..ocv:function:: CvGBTreesParams::CvGBTreesParams( int loss_function_type, int weak_count, float shrinkage, float subsample_portion, int max_depth, bool use_surrogates )
:param loss_function_type:Type of the loss function used for training
(see :ref:`Training the GBT model`). It must be one of the
(see :ref:`Training GBT`). It must be one of the
following types: ``CvGBTrees::SQUARED_LOSS``, ``CvGBTrees::ABSOLUTE_LOSS``,
``CvGBTrees::HUBER_LOSS``, ``CvGBTrees::DEVIANCE_LOSS``. The first three
types are used for regression problems, and the last one for
@ -205,10 +205,10 @@ In case of point sets, the problem is formulated as follows: you need to find a
when ``fullAffine=false`` .
..seealso::
:ocv:func:`getAffineTransform`,
:ocv:func:`getPerspectiveTransform`,
:ocv:func:`findHomography`
:ocv:func:`getAffineTransform`,
:ocv:func:`getPerspectiveTransform`,
:ocv:func:`findHomography`
@ -242,14 +242,10 @@ That is, MHI pixels where the motion occurs are set to the current ``timestamp``
The function, together with
:ocv:func:`calcMotionGradient` and
:ocv:func:`calcGlobalOrientation` , implements a motion templates technique described in
[Davis97]_
and
[Bradski00]_
.
[Davis97]_ and [Bradski00]_.
See also the OpenCV sample ``motempl.c`` that demonstrates the use of all the motion template functions.
calcMotionGradient
----------------------
Calculates a gradient orientation of a motion history image.
@ -267,7 +263,9 @@ Calculates a gradient orientation of a motion history image.
:param orientation:Output motion gradient orientation image that has the same type and the same size as ``mhi`` . Each pixel of the image is a motion orientation, from 0 to 360 degrees.
:param delta1, delta2:Minimum and maximum allowed difference between ``mhi`` values within a pixel neighorhood. That is, the function finds the minimum ( :math:`m(x,y)` ) and maximum ( :math:`M(x,y)` ) ``mhi`` values over :math:`3 \times 3` neighborhood of each pixel and marks the motion orientation at :math:`(x, y)` as valid only if
:param delta1:Minimal (or maximal) allowed difference between ``mhi`` values within a pixel neighorhood.
:param delta2:Maximal (or minimal) allowed difference between ``mhi`` values within a pixel neighorhood. That is, the function finds the minimum ( :math:`m(x,y)` ) and maximum ( :math:`M(x,y)` ) ``mhi`` values over :math:`3 \times 3` neighborhood of each pixel and marks the motion orientation at :math:`(x, y)` as valid only if
..math::
@ -354,6 +352,7 @@ Finds an object center, size, and orientation.