+++ /dev/null
-# Calculating and displaying 2D Hue-Saturation histogram of a color image
-
-import sys
-import cv
-
-def hs_histogram(src):
- # Convert to HSV
- hsv = cv.CreateImage(cv.GetSize(src), 8, 3)
- cv.CvtColor(src, hsv, cv.CV_BGR2HSV)
-
- # Extract the H and S planes
- h_plane = cv.CreateMat(src.rows, src.cols, cv.CV_8UC1)
- s_plane = cv.CreateMat(src.rows, src.cols, cv.CV_8UC1)
- cv.Split(hsv, h_plane, s_plane, None, None)
- planes = [h_plane, s_plane]
-
- h_bins = 30
- s_bins = 32
- hist_size = [h_bins, s_bins]
- # hue varies from 0 (~0 deg red) to 180 (~360 deg red again */
- h_ranges = [0, 180]
- # saturation varies from 0 (black-gray-white) to
- # 255 (pure spectrum color)
- s_ranges = [0, 255]
- ranges = [h_ranges, s_ranges]
- scale = 10
- hist = cv.CreateHist([h_bins, s_bins], cv.CV_HIST_ARRAY, ranges, 1)
- cv.CalcHist([cv.GetImage(i) for i in planes], hist)
- (_, max_value, _, _) = cv.GetMinMaxHistValue(hist)
-
- hist_img = cv.CreateImage((h_bins*scale, s_bins*scale), 8, 3)
-
- for h in range(h_bins):
- for s in range(s_bins):
- bin_val = cv.QueryHistValue_2D(hist, h, s)
- intensity = cv.Round(bin_val * 255 / max_value)
- cv.Rectangle(hist_img,
- (h*scale, s*scale),
- ((h+1)*scale - 1, (s+1)*scale - 1),
- cv.RGB(intensity, intensity, intensity),
- cv.CV_FILLED)
- return hist_img
-
-if __name__ == '__main__':
- src = cv.LoadImageM(sys.argv[1])
- cv.NamedWindow("Source", 1)
- cv.ShowImage("Source", src)
-
- cv.NamedWindow("H-S Histogram", 1)
- cv.ShowImage("H-S Histogram", hs_histogram(src))
-
- cv.WaitKey(0)
-
+++ /dev/null
-import sys
-import cv
-
-def findstereocorrespondence(image_left, image_right):
- # image_left and image_right are the input 8-bit single-channel images
- # from the left and the right cameras, respectively
- (r, c) = (image_left.rows, image_left.cols)
- disparity_left = cv.CreateMat(r, c, cv.CV_16S)
- disparity_right = cv.CreateMat(r, c, cv.CV_16S)
- state = cv.CreateStereoGCState(16, 2)
- cv.FindStereoCorrespondenceGC(image_left, image_right, disparity_left, disparity_right, state, 0)
- return (disparity_left, disparity_right)
-
-
-if __name__ == '__main__':
-
- (l, r) = [cv.LoadImageM(f, cv.CV_LOAD_IMAGE_GRAYSCALE) for f in sys.argv[1:]]
-
- (disparity_left, disparity_right) = findstereocorrespondence(l, r)
-
- disparity_left_visual = cv.CreateMat(l.rows, l.cols, cv.CV_8U)
- cv.ConvertScale(disparity_left, disparity_left_visual, -16)
- cv.SaveImage("disparity.pgm", disparity_left_visual)
+++ /dev/null
-import cv
-
-def precornerdetect(image):
- # assume that the image is floating-point
- corners = cv.CloneMat(image)
- cv.PreCornerDetect(image, corners, 3)
-
- dilated_corners = cv.CloneMat(image)
- cv.Dilate(corners, dilated_corners, None, 1)
-
- corner_mask = cv.CreateMat(image.rows, image.cols, cv.CV_8UC1)
- cv.Sub(corners, dilated_corners, corners)
- cv.CmpS(corners, 0, corner_mask, cv.CV_CMP_GE)
- return (corners, corner_mask)
where:
-* :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
: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.
Such an object is called a calibration rig or calibration pattern,
and OpenCV has built-in support for a chessboard as a calibration
rig (see
-:ref:`findChessboardCorners` ). Currently, initialization
+:ocv:func:`findChessboardCorners` ). Currently, initialization
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.
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.
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`
.. ocv:pyfunction:: cv2.calibrationMatrixValues(cameraMatrix, imageSize, apertureWidth, apertureHeight) -> fovx, fovy, focalLength, principalPoint, aspectRatio
- :param cameraMatrix: Input camera matrix that can be estimated by :ref:`calibrateCamera` or :ref:`stereoCalibrate` .
+ :param cameraMatrix: Input camera matrix that can be estimated by :ocv:func:`calibrateCamera` or :ocv:func:`stereoCalibrate` .
:param imageSize: Input image size in pixels.
\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,
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.
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: ::
.. ocv:pyfunction:: cv2.findHomography(srcPoints, dstPoints[, method[, ransacReprojThreshold[, mask]]]) -> retval, mask
-.. ocv:cfunction:: void cvFindHomography( const CvMat* srcPoints, const CvMat* dstPoints, CvMat* H int method=0, double ransacReprojThreshold=3, CvMat* status=NULL)
+.. ocv:cfunction:: void cvFindHomography( const CvMat* srcPoints, const CvMat* dstPoints, CvMat* H, int method=0, double ransacReprojThreshold=3, CvMat* status=NULL)
+
.. ocv:pyoldfunction:: cv.FindHomography(srcPoints, dstPoints, H, method, ransacReprojThreshold=3.0, status=None)-> None
:param srcPoints: Coordinates of the points in the original plane, a matrix of the type ``CV_32FC2`` or ``vector<Point2f>`` .
:math:`h_{33}=1` .
.. seealso::
-:ocv:func:`GetAffineTransform`,
-:ocv:func:`GetPerspectiveTransform`,
-:ocv:func:`EstimateRigidMotion`,
-:ocv:func:`WarpPerspective`,
-:ocv:func:`PerspectiveTransform`
+
+ :ocv:func:`GetAffineTransform`,
+ :ocv:func:`GetPerspectiveTransform`,
+ :ocv:func:`EstimateRigidMotion`,
+ :ocv:func:`WarpPerspective`,
+ :ocv:func:`PerspectiveTransform`
estimateAffine3D
--------------
Filters off small noise blobs (speckles) in the disparity map
-.. ocv:function:: void filterSpeckles( InputOutputArray img, double newVal, int maxSpeckleSize, double maxDiff, InputOutputArray buf=noArray() );
+.. ocv:function:: void filterSpeckles( InputOutputArray img, double newVal, int maxSpeckleSize, double maxDiff, InputOutputArray buf=noArray() )
.. ocv:pyfunction:: cv2.filterSpeckles(img, newVal, maxSpeckleSize, maxDiff[, buf]) -> None
: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`` .
* 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).
: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.
* **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:
: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 Q: Output :math:`4 \times 4` disparity-to-depth mapping matrix (see :ref:`reprojectImageTo3D` ).
+ :param Q: Output :math:`4 \times 4` disparity-to-depth mapping matrix (see :ocv:func:`reprojectImageTo3D` ).
: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.
: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:
.. ocv:cfunction:: void cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2, const CvMat* F, CvSize imageSize, CvMat* H1, CvMat* H2, double threshold=5 )
.. ocv:pyoldfunction:: cv.StereoRectifyUncalibrated(points1, points2, F, imageSize, H1, H2, threshold=5)-> None
- :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.
The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, including ``std::sort()`` .
+.. _MatrixExpressions:
Matrix Expressions
------------------
Mat::Mat
------------
+Various Mat constructors
+
.. ocv:function:: Mat::Mat()
.. ocv:function:: Mat::Mat(int rows, int cols, int type)
.. ocv:function:: Mat::Mat(const Mat& m, const Range* ranges)
- Provides various array constructors.
-
:param ndims: Array dimensionality.
:param rows: Number of rows in a 2D array.
Mat::~Mat
------------
-.. ocv:function:: Mat::~Mat()
+The Mat destructor.
- Provides a matrix destructor.
+.. ocv:function:: Mat::~Mat()
-The matrix destructor calls
-:ocv:func:`Mat::release` .
+The matrix destructor calls :ocv:func:`Mat::release` .
Mat::operator =
-------------------
+Provides matrix assignment operators.
+
.. ocv:function:: Mat& Mat::operator = (const Mat& m)
.. ocv:function:: Mat& Mat::operator = (const MatExpr_Base& expr)
.. ocv:function:: Mat& operator = (const Scalar& s)
- Provides matrix assignment operators.
-
: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.
Mat::operator MatExpr
-------------------------
-.. ocv:function:: Mat::operator MatExpr_<Mat, Mat>() const
+Provides a ``Mat`` -to- ``MatExpr`` cast operator.
- Provides a ``Mat`` -to- ``MatExpr`` cast operator.
+.. ocv:function:: Mat::operator MatExpr_<Mat, Mat>() const
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.
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;
...
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.
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.
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.
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.
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.
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.
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.
Mat::setTo
--------------
-.. ocv:function:: Mat& Mat::setTo(const Scalar& s, InputArray mask=noArray())
+Sets all or some of the array elements to the specified value.
- Sets all or some of the array elements to the specified value.
+.. ocv:function:: Mat& Mat::setTo(const Scalar& s, InputArray mask=noArray())
:param s: Assigned scalar converted to the actual array type.
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.
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: ::
Mat::inv
------------
-.. ocv:function:: MatExpr Mat::inv(int method=DECOMP_LU) const
+Inverses a matrix.
- Inverses a matrix.
+.. ocv:function:: MatExpr Mat::inv(int method=DECOMP_LU) const
:param method: Matrix inversion method. Possible values are the following:
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Mat::push_back
--------------
+Adds elements to the bottom of the matrix.
+
.. ocv:function:: template<typename T> void Mat::push_back(const T& elem)
.. ocv:function:: void Mat::push_back(const Mat& elem)
- Adds elements to the bottom of the matrix.
-
:param elem: Added element(s).
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.
Mat::pop_back
-------------
-.. ocv:function:: template<typename T> void Mat::pop_back(size_t nelems=1)
+Removes elements from the bottom of the matrix.
- Removes elements from the bottom of the matrix.
+.. ocv:function:: template<typename T> void Mat::pop_back(size_t nelems=1)
:param nelems: Number of removed rows. If it is greater than the total number of rows, an exception is thrown.
Mat::locateROI
------------------
-.. ocv:function:: void Mat::locateROI( Size& wholeSize, Point& ofs ) const
+Locates the matrix header within a parent matrix.
- Locates the matrix header within a parent matrix.
+.. ocv:function:: void Mat::locateROI( Size& wholeSize, Point& ofs ) const
:param wholeSize: Output parameter that contains the size of the whole matrix containing ``*this`` is a part.
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.
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()``.
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: ::
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
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:
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.
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`` .
Mat::ptr
------------
+Returns a pointer to the specified matrix row.
+
.. ocv:function:: uchar* Mat::ptr(int i=0)
.. ocv:function:: const uchar* Mat::ptr(int i=0) const
.. ocv:function:: template<typename _Tp> const _Tp* Mat::ptr(int i=0) const
- Returns a pointer to the specified matrix row.
-
:param i: A 0-based row index.
The methods return ``uchar*`` or typed pointer to the specified matrix row. See the sample in
Mat::at
-----------
+Returns a reference to the specified array element.
+
.. ocv:function:: template<typename T> T& Mat::at(int i) const
.. ocv:function:: template<typename T> const T& Mat::at(int i) const
.. ocv:function:: template<typename T> const T& Mat::at(const int* idx) const
- 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.
Mat::begin
--------------
-.. ocv:function:: template<typename _Tp> MatIterator_<_Tp> Mat::begin() template<typename _Tp> MatConstIterator_<_Tp> Mat::begin() const
+Returns the matrix iterator and sets it to the first matrix element.
+
+.. ocv:function:: template<typename _Tp> MatIterator_<_Tp> Mat::begin()
- Returns the matrix iterator and sets it to the first matrix element.
+.. ocv:function:: template<typename _Tp> MatConstIterator_<_Tp> Mat::begin() const
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: ::
Mat::end
------------
+Returns the matrix iterator and sets it to the after-last matrix element.
+
.. ocv:function:: template<typename _Tp> MatIterator_<_Tp> Mat::end()
-.. ocv:function:: template<typename _Tp> MatConstIterator_<_Tp> Mat::end() const
- Returns the matrix iterator and sets it to the after-last matrix element.
+.. ocv:function:: template<typename _Tp> MatConstIterator_<_Tp> Mat::end() const
The methods return the matrix read-only or read-write iterators, set to the point following the last matrix element.
--------
Initializes font structure (OpenCV 1.x API).
-.. c:function:: void cvInitFont( CvFont* font, int fontFace, double hscale, double vscale, double shear=0, int thickness=1, int lineType=8 )
+.. ocv:cfunction:: void cvInitFont( CvFont* font, int fontFace, double hscale, double vscale, double shear=0, int thickness=1, int lineType=8 )
:param font: Pointer to the font structure initialized by the function
:param thickness: Thickness of the text strokes
- :param lineType: Type of the strokes, see :ref:`Line` description
+ :param lineType: Type of the strokes, see :ocv:func:`line` description
The function initializes the font structure that can be passed to text rendering functions.
Ptr<T> ptr = new T(...);
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:
.. 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
* ``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`` .
: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()` .
* **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 ()
: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);
.. ocv:function:: Scalar sum(InputArray arr)
-.. ocv:function:: cv2.sumElems(arr) -> retval
+.. ocv:pyfunction:: cv2.sumElems(arr) -> retval
.. ocv:cfunction:: CvScalar cvSum(const CvArr* arr)
.. ocv:pyoldfunction:: cv.Sum(arr)-> CvScalar
c = src1.channels();
}
- Size sz = getContinuousSize(src1, src2, dst, c);
- func(src1.data, src1.step, src2.data, src2.step, dst.data, dst.step, sz, 0);
- return;
+ Size sz = getContinuousSize(src1, src2, dst);
+ size_t len = sz.width*(size_t)c;
+ if( len == (size_t)(int)len )
+ {
+ sz.width = (int)len;
+ func(src1.data, src1.step, src2.data, src2.step, dst.data, dst.step, sz, 0);
+ return;
+ }
}
if( (kind1 == _InputArray::MATX) + (kind2 == _InputArray::MATX) == 1 ||
NAryMatIterator it(arrays, ptrs);
size_t total = it.size, blocksize = total;
+ if( blocksize*c > INT_MAX )
+ blocksize = INT_MAX/c;
+
if( haveMask )
{
blocksize = std::min(blocksize, blocksize0);
// to handle the copying 1xn matrix => nx1 std vector.
Size sz = size() == dst.size() ?
- getContinuousSize(*this, dst, (int)elemSize()) :
- getContinuousSize(*this, (int)elemSize());
+ getContinuousSize(*this, dst) :
+ getContinuousSize(*this);
+ size_t len = sz.width*elemSize();
for( ; sz.height--; sptr += step, dptr += dst.step )
- memcpy( dptr, sptr, sz.width );
+ memcpy( dptr, sptr, len );
}
return;
}
struct MulOp : public BaseElemWiseOp
{
MulOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
+ void getValueRange(int depth, double& minval, double& maxval)
+ {
+ minval = depth < CV_32S ? cvtest::getMinVal(depth) : depth == CV_32S ? -1000000 : -1000.;
+ maxval = depth < CV_32S ? cvtest::getMaxVal(depth) : depth == CV_32S ? 1000000 : 1000.;
+ minval = std::max(minval, -30000.);
+ maxval = std::min(maxval, 30000.);
+ }
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::multiply(src[0], src[1], dst, alpha);
#if defined _MSC_VER && _MSC_VER >= 1200
-#if !defined(_MT) || defined(_DLL)
+#if !defined(_MT) || defined(_DLL) || defined(_MSC_VER)
extern "C" { __declspec(dllexport) unsigned int __lc_codepage = 0; }
#endif
#ifdef _M_X64
: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.
.. 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`,
: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` .
+.. seealso:: :ocv:func:`createSeparableLinearFilter` .
.. index:: gpu::getLinearColumnFilter_GPU
:param dstType: Destination array type. ``CV_8UC1``, ``CV_8UC4``, ``CV_16SC1``, ``CV_16SC2``, ``CV_32SC1``, ``CV_32FC1`` destination types are supported.
- :param rowKernel, columnKernel: Filter coefficients.
+ :param rowKernel: Horizontal filter coefficients.
+
+ :param columnKernel: Vertical filter coefficients.
: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.
.. seealso:: :ocv:func:`gpu::getLinearRowFilter_GPU`, :ocv:func:`gpu::getLinearColumnFilter_GPU`, :ocv:func:`createSeparableLinearFilter`
:param ddepth: Destination image depth. ``CV_8U``, ``CV_16S``, ``CV_32S``, and ``CV_32F`` are supported.
- :param kernelX, kernelY: Filter coefficients.
+ :param kernelX: Horizontal filter coefficients.
+
+ :param kernelY: Vertical filter coefficients.
:param anchor: Anchor position within the kernel. The default value ``(-1, 1)`` means that the anchor is at the kernel center.
- :param rowBorderType, columnBorderType: Pixel extrapolation method. For details, see :ocv:func:`borderInterpolate`.
+ :param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
+
+ :param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`sepFilter2D`
:param ksize: Aperture size. See :ocv:func:`getDerivKernels` for details.
- :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.
+
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`createDerivFilter`
: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.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`Sobel`
:param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :ocv:func:`getDerivKernels` for details.
- :param rowBorderType, columnBorderType: Pixel extrapolation method. For details, see :ocv:func:`borderInterpolate` and :ocv:func:`Scharr` .
+ :param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
+
+ :param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`Scharr`
:param sigmaY: Gaussian sigma in the vertical direction. If 0, then :math:`\texttt{sigmaY}\leftarrow\texttt{sigmaX}` .
- :param rowBorderType, columnBorderType: Border type to use. 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.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`createGaussianFilter`
: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.
.. seealso:: :ocv:func:`gpu::createGaussianFilter_GPU`, :ocv:func:`GaussianBlur`
.. highlight:: cpp
-.. index:: gpu::meanShiftFiltering
+
gpu::meanShiftFiltering
---------------------------
:param criteria: Termination criteria. See :ocv:class:`TermCriteria`.
-.. index:: gpu::meanShiftProc
+
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
------------------------------
:param criteria: Termination criteria. See :ocv:class:`TermCriteria`.
-.. index:: gpu::integral
+
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
--------------------
:param sqsum: Squared integral image containing 64-bit unsigned integer values packed into ``CV_64FC1`` .
-.. index:: gpu::columnSum
+
gpu::columnSum
------------------
:param sum: Destination image of the ``CV_32FC1`` type.
-.. index:: gpu::cornerHarris
+
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
--------------------------
.. seealso:: :ocv:func:`cornerMinEigenVal`
-.. index:: gpu::mulSpectrums
+
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
-----------------------------
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
------------
*
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
-----------------
:param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
-.. index:: gpu::ConvolveBuf
+
gpu::ConvolveBuf
----------------
};
-.. index:: gpu::ConvolveBuf::ConvolveBuf
+
gpu::ConvolveBuf::ConvolveBuf
---------------------------------
Constructs a buffer for the
:ocv:func:`convolve` function with respective arguments.
-.. index:: gpu::matchTemplate
+
gpu::matchTemplate
----------------------
* ``CV_TM_SQDIFF``
* ``CV_TM_CCORR``
-.. seealso::
- :ocv:func:`matchTemplate`
+.. seealso:: :ocv:func:`matchTemplate`
-.. index:: gpu::remap
gpu::remap
--------------
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
-----------------
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
------------------
:param stream: Stream for the asynchronous version.
-.. seealso::
- :ocv:func:`threshold`
+.. seealso:: :ocv:func:`threshold`
+
-.. index:: gpu::resize
gpu::resize
---------------
.. seealso:: :ocv:func:`resize`
-.. index:: gpu::warpAffine
+
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
------------------------
: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
---------------
: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
-----------------------
: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
-------------------
:param rect: Rectangular window.
-.. index:: gpu::evenLevels
+
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])
+.. ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat* hist, int* histSize, int* lowerLevel, int* upperLevel)
Calculates a histogram with evenly distributed bins.
:param upperLevel: Upper boundary of highest-level bin.
-.. index:: gpu::histRange
-
gpu::histRange
------------------
.. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels)
-.. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4])
+.. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat* hist, const GpuMat* levels)
Calculates a histogram with bins determined by the ``levels`` array.
The output of the function can be used for robust edge or corner detection.
-See Also:
-:ocv:func:`cornerMinEigenVal`,
-:ocv:func:`cornerHarris`,
-:ocv:func:`preCornerDetect`
+.. seealso::
+
+ :ocv:func:`cornerMinEigenVal`,
+ :ocv:func:`cornerHarris`,
+ :ocv:func:`preCornerDetect`
.. ocv:pyfunction:: cv2.goodFeaturesToTrack(image, maxCorners, qualityLevel, minDistance[, corners[, mask[, blockSize[, useHarrisDetector[, k]]]]]) -> corners
-.. ocv:cfunction:: void cvGoodFeaturesToTrack( const CvArr* image CvArr* eigImage, CvArr* tempImage CvPoint2D32f* corners int* cornerCount double qualityLevel double minDistance const CvArr* mask=NULL int blockSize=3 int useHarris=0 double k=0.04 )
+.. ocv:cfunction:: void cvGoodFeaturesToTrack( const CvArr* image, CvArr* eigImage, CvArr* tempImage CvPoint2D32f* corners, int* cornerCount, double qualityLevel, double minDistance, const CvArr* mask=NULL, int blockSize=3, int useHarris=0, double k=0.04 )
+
.. ocv:pyoldfunction:: cv.GoodFeaturesToTrack(image, eigImage, tempImage, cornerCount, qualityLevel, minDistance, mask=None, blockSize=3, useHarris=0, k=0.04)-> corners
:param image: Input 8-bit or floating-point 32-bit, single-channel image.
**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`
**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.
-See Also:
-:ocv:func:`fitEllipse`,
-:ocv:func:`minEnclosingCircle`
+.. seealso::
+ :ocv:func:`fitEllipse`,
+ :ocv:func:`minEnclosingCircle`
HoughLines
: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`,
:ocv:func:`getMorphologyColumnFilter`
-
BaseFilter
----------
.. ocv:class:: BaseFilter
: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`
: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`
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`,
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.
:ocv:func:`copyMakeBorder` to compute tables for quick extrapolation.
.. seealso::
- :ocv:func:`FilterEngine`,
- :ocv:func:`copyMakeBorder`
+
+ :ocv:func:`FilterEngine`,
+ :ocv:func:`copyMakeBorder`
: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`
: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.
.. seealso::
- :ocv:func:`borderInterpolate`
+
+ :ocv:func:`borderInterpolate`
createBoxFilter
:ocv:func:`boxFilter` .
.. seealso::
- :ocv:func:`FilterEngine`,
- :ocv:func:`blur`,
- :ocv:func:`boxFilter`
+
+ :ocv:func:`FilterEngine`,
+ :ocv:func:`blur`,
+ :ocv:func:`boxFilter`
: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`
:ocv:func:`createSeparableFilter` directly.
.. seealso::
- :ocv:func:`createSeparableLinearFilter`,
- :ocv:func:`getGaussianKernel`,
- :ocv:func:`GaussianBlur`
+
+ :ocv:func:`createSeparableLinearFilter`,
+ :ocv:func:`getGaussianKernel`,
+ :ocv:func:`GaussianBlur`
: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.
:ocv:func:`FilterEngine` constructor.
.. seealso::
- :ocv:func:`createSeparableLinearFilter`,
- :ocv:func:`FilterEngine`,
- :ocv:func:`filter2D`
+
+ :ocv:func:`createSeparableLinearFilter`,
+ :ocv:func:`FilterEngine`,
+ :ocv:func:`filter2D`
createMorphologyFilter
: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.
: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
: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.
: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
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
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`
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`
: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`,
:ocv:func:`GaussianBlur`.
.. seealso::
+
:ocv:func:`sepFilter2D`,
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getDerivKernels`,
: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`
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`
\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}
.. seealso::
- :ocv:func:`Sobel`,
- :ocv:func:`Scharr`
+
+ :ocv:func:`Sobel`,
+ :ocv:func:`Scharr`
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`,
: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})`
\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}
.. seealso::
- :ocv:func:`Scharr`,
- :ocv:func:`Lapacian`,
- :ocv:func:`sepFilter2D`,
- :ocv:func:`filter2D`,
- :ocv:func:`GaussianBlur`
+
+ :ocv:func:`Scharr`,
+ :ocv:func:`Lapacian`,
+ :ocv:func:`sepFilter2D`,
+ :ocv:func:`filter2D`,
+ :ocv:func:`GaussianBlur`
:math:`\left<f_x, f_y\right>: \texttt{dst} \rightarrow \texttt{src}` and then use the above formula.
The actual implementations of the geometrical transformations, from the most generic
-:ref:`Remap` and to the simplest and the fastest
-:ref:`Resize` , need to solve two main problems with the above formula:
+:ocv:func:`remap` and to the simplest and the fastest
+:ocv:func:`resize` , need to solve two main problems with the above formula:
*
Extrapolation of non-existing pixels. Similarly to the filtering functions described in the previous section, for some
, where a polynomial function is fit into some neighborhood of the computed pixel
:math:`(f_x(x,y), f_y(x,y))` , and then the value of the polynomial at
:math:`(f_x(x,y), f_y(x,y))` is taken as the interpolated pixel value. In OpenCV, you can choose between several interpolation methods. See
- :ref:`Resize` for details.
+ :ocv:func:`resize` for details.
convertMaps
-----------
*
Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.
-See Also:
-:ocv:func:`remap`,
-:ocv:func:`undisort`,
-:ocv:func:`initUndistortRectifyMap`
+.. seealso::
+
+ :ocv:func:`remap`,
+ :ocv:func:`undisort`,
+ :ocv:func:`initUndistortRectifyMap`
----------------------
Calculates an affine transform from three pairs of the corresponding points.
-.. ocv:function:: Mat getAffineTransform( const Point2f src[], const Point2f dst[] )
+.. ocv:function:: Mat getAffineTransform( const Point2f* src, const Point2f* dst )
.. ocv:pyfunction:: cv2.getAffineTransform(src, dst) -> retval
.. ocv:cfunction:: CvMat* cvGetAffineTransform( const CvPoint2D32f* src, const CvPoint2D32f* dst, CvMat* mapMatrix )
+
.. ocv:pyoldfunction:: cv.GetAffineTransform(src, dst, mapMatrix)-> None
:param src: Coordinates of triangle vertices in the source image.
src(i)=(x_i, y_i),
i=0,1,2
-See Also:
-:ocv:func:`warpAffine`,
-:ocv:func:`transform`
+.. seealso::
+
+ :ocv:func:`warpAffine`,
+ :ocv:func:`transform`
---------------------------
Calculates a perspective transform from four pairs of the corresponding points.
-.. ocv:function:: Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
+.. ocv:function:: Mat getPerspectiveTransform( const Point2f* src, const Point2f* dst )
.. ocv:pyfunction:: cv2.getPerspectiveTransform(src, dst) -> retval
.. ocv:cfunction:: CvMat* cvGetPerspectiveTransform( const CvPoint2D32f* src, const CvPoint2D32f* dst, CvMat* mapMatrix )
+
.. ocv:pyoldfunction:: cv.GetPerspectiveTransform(src, dst, mapMatrix)-> None
:param src: Coordinates of quadrangle vertices in the source image.
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
: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
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`
: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::
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
: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.
: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`
: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::
: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::
: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:
: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.
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.
: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
// camera_matrix=[fx 0 cx; 0 fy cy; 0 0 1]
This is an approximate algorithm of the
:ocv:func:`CAMShift` color object tracker.
-See Also:
-:ocv:func:`calcHist`
-
+.. seealso:: :ocv:func:`calcHist`
.. _compareHist:
compareHist
: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
: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
: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``.
: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
: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.
.. [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.
-http://www.cis.hut.fi/research/IA/paper/publications/bmvc97/bmvc97.html
\ No newline at end of file
+.. [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
\ No newline at end of file
The function can process the image in-place.
-See Also:
-:ocv:func:`threshold`,
-:ocv:func:`blur`,
-:ocv:func:`GaussianBlur`
+.. seealso::
+
+ :ocv:func:`threshold`,
+ :ocv:func:`blur`,
+ :ocv:func:`GaussianBlur`
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`
.. 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
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
: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`` .
The function removes all of the virtual points. It
is called internally in
-:ref:`CalcSubdivVoronoi2D`
+:ocv:cfunc:`CalcSubdivVoronoi2D`
if the subdivision
was modified after previous call to the function.
The function creates an empty Delaunay
subdivision, where 2d points can be added using the function
-:ref:`SubdivDelaunay2DInsert`
+:ocv:cfunc:`SubdivDelaunay2DInsert`
. All of the points to be added must be within
the specified rectangle, otherwise a runtime error will be raised.
locates the input point within the subdivision. It finds the subdivision vertex that
is the closest to the input point. It is not necessarily one of vertices
of the facet containing the input point, though the facet (located using
-:ref:`Subdiv2DLocate`
+:ocv:cfunc:`Subdiv2DLocate`
) is used as a starting
point. The function returns a pointer to the found subdivision vertex.
returned pointer may be NULL if the edge is from dual subdivision and
the virtual point coordinates are not calculated yet. The virtual points
can be calculated using the function
-:ref:`CalcSubdivVoronoi2D`
-.
+:ocv:cfunc:`CalcSubdivVoronoi2D`.
Subdiv2DGetEdge
---------------
.. ocv:cfunction:: CvSubdiv2DPoint* cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt)
.. ocv:pyoldfunction:: cv.SubdivDelaunay2DInsert(subdiv, pt)-> point
- :param subdiv: Delaunay subdivision created by the function :ref:`CreateSubdivDelaunay2D`
+ :param subdiv: Delaunay subdivision created by the function :ocv:cfunc:`CreateSubdivDelaunay2D`
:param pt: Inserted point
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.
-See Also:
-:ocv:func:`contourArea`,
-:ocv:func:`arcLength`
+.. seealso::
+
+ :ocv:func:`contourArea`,
+ :ocv:func:`arcLength`
-------------
Calculates the seven Hu invariants.
-.. ocv:function:: void HuMoments( const Moments& moments, double h[7] )
+.. ocv:function:: void HuMoments( const Moments& moments, double* hu )
.. ocv:pyfunction:: cv2.HuMoments(m) -> hu
.. ocv:pyoldfunction:: cv.GetHuMoments(moments) -> hu
:param moments: Input moments computed with :ocv:func:`moments` .
- :param h: Output Hu invariants.
+ :param hu: Output Hu invariants.
The function calculates the seven Hu invariants (introduced in [Hu62]_; see also
http://en.wikipedia.org/wiki/Image_moment) defined as:
.. math::
- \begin{array}{l} h[0]= \eta _{20}+ \eta _{02} \\ h[1]=( \eta _{20}- \eta _{02})^{2}+4 \eta _{11}^{2} \\ h[2]=( \eta _{30}-3 \eta _{12})^{2}+ (3 \eta _{21}- \eta _{03})^{2} \\ h[3]=( \eta _{30}+ \eta _{12})^{2}+ ( \eta _{21}+ \eta _{03})^{2} \\ h[4]=( \eta _{30}-3 \eta _{12})( \eta _{30}+ \eta _{12})[( \eta _{30}+ \eta _{12})^{2}-3( \eta _{21}+ \eta _{03})^{2}]+(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ h[5]=( \eta _{20}- \eta _{02})[( \eta _{30}+ \eta _{12})^{2}- ( \eta _{21}+ \eta _{03})^{2}]+4 \eta _{11}( \eta _{30}+ \eta _{12})( \eta _{21}+ \eta _{03}) \\ h[6]=(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}]-( \eta _{30}-3 \eta _{12})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ \end{array}
+ \begin{array}{l} hu[0]= \eta _{20}+ \eta _{02} \\ hu[1]=( \eta _{20}- \eta _{02})^{2}+4 \eta _{11}^{2} \\ hu[2]=( \eta _{30}-3 \eta _{12})^{2}+ (3 \eta _{21}- \eta _{03})^{2} \\ hu[3]=( \eta _{30}+ \eta _{12})^{2}+ ( \eta _{21}+ \eta _{03})^{2} \\ hu[4]=( \eta _{30}-3 \eta _{12})( \eta _{30}+ \eta _{12})[( \eta _{30}+ \eta _{12})^{2}-3( \eta _{21}+ \eta _{03})^{2}]+(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ hu[5]=( \eta _{20}- \eta _{02})[( \eta _{30}+ \eta _{12})^{2}- ( \eta _{21}+ \eta _{03})^{2}]+4 \eta _{11}( \eta _{30}+ \eta _{12})( \eta _{21}+ \eta _{03}) \\ hu[6]=(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}]-( \eta _{30}-3 \eta _{12})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ \end{array}
where
:math:`\eta_{ji}` stands for
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
: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)
: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
:math:`\sum_i \rho(r_i)` where
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:
.. 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
Pointer to the parent node.
-.. ocv:mebmer:: CvDTreeNode* left
+.. ocv:member:: CvDTreeNode* left
Pointer to the left child node.
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.
:math:`p_{i,k}` can be provided. Another alternative when
:math:`p_{i,k}` are unknown is to use a simpler clustering algorithm to pre-cluster the input samples and thus obtain initial
:math:`p_{i,k}` . Often (including macnine learning) the
-:ref:`kmeans` algorithm is used for that purpose.
+:ocv:func:`kmeans` algorithm is used for that purpose.
One of the main problems of the EM algorithm is a large number
of parameters to estimate. The majority of the parameters reside in
:math:`\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N` (indices of the most probable mixture component for each sample).
The trained model can be used further for prediction, just like any other classifier. The trained model is similar to the
-:ref:`Bayes classifier`.
+:ocv:class:`CvBayesClassifier`.
For an example of clustering random samples of the multi-Gaussian distribution using EM, see ``em.cpp`` sample in the OpenCV distribution.
Decision trees (:ocv:class:`CvDTree`) usage as base learners allows to process ordered\r
and categorical variables.\r
\r
+.. _Training GBT:\r
\r
Training the GBT model\r
----------------------\r
\delta\cdot\left(|y-f(x)|-\dfrac{\delta}{2}\right) & : |y-f(x)|>\delta\\\r
\dfrac{1}{2}\cdot(y-f(x))^2 & : |y-f(x)|\leq\delta \end{array} \right.`,\r
\r
- where :math:`\delta` is the :math:`\alpha`-quantile estimation of the\r
+ where :math:`\delta` is the :math:`\alpha`-quantile estimation of the\r
:math:`|y-f(x)|`. In the current implementation :math:`\alpha=0.2`.\r
\r
\r
is a regularization parameter from the interval :math:`(0,1]`, futher called\r
*shrinkage*.\r
\r
+.. _Predicting with GBT:\r
\r
Predicting with the GBT Model\r
--------------------------\r
+-----------------------------\r
\r
To get the GBT model prediciton, you need to compute the sum of responses of\r
all the trees in the ensemble. For regression problems, it is the answer.\r
.. ocv:function:: CvGBTreesParams::CvGBTreesParams( int loss_function_type, int weak_count, float shrinkage, float subsample_portion, int max_depth, bool use_surrogates )\r
\r
:param loss_function_type: Type of the loss function used for training\r
- (see :ref:`Training the GBT model`). It must be one of the\r
+ (see :ref:`Training GBT`). It must be one of the\r
following types: ``CvGBTrees::SQUARED_LOSS``, ``CvGBTrees::ABSOLUTE_LOSS``,\r
``CvGBTrees::HUBER_LOSS``, ``CvGBTrees::DEVIANCE_LOSS``. The first three\r
types are used for regression problems, and the last one for\r
count of trees in the GBT model, where ``K`` is the output classes count\r
(equal to one in case of a regression).\r
\r
- :param shrinkage: Regularization parameter (see :ref:`Training the GBT model`).\r
+ :param shrinkage: Regularization parameter (see :ref:`Training GBT`).\r
\r
:param subsample_portion: Portion of the whole training set used for each algorithm iteration.\r
Subset is generated randomly. For more information see\r
only one model.\r
\r
:param k: Number of tree ensembles built in case of the classification problem\r
- (see :ref:`Training the GBT model`). Use this\r
+ (see :ref:`Training GBT`). Use this\r
parameter to change the ouput to sum of the trees' predictions in the\r
``k``-th ensemble only. To get the total GBT model prediction, ``k`` value\r
must be -1. For regression problems, ``k`` is also equal to -1.\r
\r
The method predicts the response corresponding to the given sample\r
-(see :ref:`Predicting with the GBT model`).\r
+(see :ref:`Predicting with GBT`).\r
The result is either the class label or the estimated function value. The\r
:ocv:func:`predict` method enables using the parallel version of the GBT model\r
prediction if the OpenCV is built with the TBB library. In this case, predictions\r
size reaches a limit. Besides, the larger networks are trained much
longer than the smaller ones, so it is reasonable to pre-process the data,
using
-:ocv:func:`PCA::operator ()` or similar technique, and train a smaller network
+:ocv:func:`PCA::operator()` or similar technique, and train a smaller network
on only essential features.
Another MPL feature is an inability to handle categorical
**References:**
-*
- *Machine Learning*, Wald I, July 2002.
+ * *Machine Learning*, Wald I, July 2002. http://stat-www.berkeley.edu/users/breiman/wald2002-1.pdf
- http://stat-www.berkeley.edu/users/breiman/wald2002-1.pdf
+ * *Looking Inside the Black Box*, Wald II, July 2002. http://stat-www.berkeley.edu/users/breiman/wald2002-2.pdf
-*
- *Looking Inside the Black Box*, Wald II, July 2002.
+ * *Software for the Masses*, Wald III, July 2002. http://stat-www.berkeley.edu/users/breiman/wald2002-3.pdf
- http://stat-www.berkeley.edu/users/breiman/wald2002-2.pdf
-
-*
- *Software for the Masses*, Wald III, July 2002.
-
- http://stat-www.berkeley.edu/users/breiman/wald2002-3.pdf
-
-*
- And other articles from the web site
- http://www.stat.berkeley.edu/users/breiman/RandomForests/cc_home.htm
- .
+ * And other articles from the web site http://www.stat.berkeley.edu/users/breiman/RandomForests/cc_home.htm
CvRTParams
----------
self.assert_(li[0] != None)
def test_InPaint(self):
- src = self.get_sample("doc/pics/building.jpg")
+ src = self.get_sample("samples/cpp/building.jpg")
msk = cv.CreateImage(cv.GetSize(src), cv.IPL_DEPTH_8U, 1)
damaged = cv.CloneMat(src)
repaired = cv.CreateImage(cv.GetSize(src), cv.IPL_DEPTH_8U, 3)
def yield_line_image(self):
""" Needed by HoughLines tests """
- src = self.get_sample("doc/pics/building.jpg", 0)
+ src = self.get_sample("samples/cpp/building.jpg", 0)
dst = cv.CreateImage(cv.GetSize(src), 8, 1)
cv.Canny(src, dst, 50, 200, 3)
return dst
""" Test the fragments of code that are included in the documentation """
def setUp(self):
OpenCVTests.setUp(self)
- sys.path.append("../doc/python_fragments")
+ sys.path.append(".")
def test_precornerdetect(self):
from precornerdetect import precornerdetect
def test_findstereocorrespondence(self):
from findstereocorrespondence import findstereocorrespondence
- (l,r) = [self.get_sample("doc/pics/tsukuba_%s.png" % c, cv.CV_LOAD_IMAGE_GRAYSCALE) for c in "lr"]
+ (l,r) = [self.get_sample("samples/cpp/tsukuba_%s.png" % c, cv.CV_LOAD_IMAGE_GRAYSCALE) for c in "lr"]
(disparity_left, disparity_right) = findstereocorrespondence(l, r)
def test_calchist(self):
from calchist import hs_histogram
i1 = self.get_sample("samples/c/lena.jpg")
- i2 = self.get_sample("doc/pics/building.jpg")
+ i2 = self.get_sample("samples/cpp/building.jpg")
i3 = cv.CloneMat(i1)
cv.Flip(i3, i3, 1)
h1 = hs_histogram(i1)
when ``fullAffine=false`` .
.. seealso::
- :ocv:func:`getAffineTransform`,
- :ocv:func:`getPerspectiveTransform`,
- :ocv:func:`findHomography`
+ :ocv:func:`getAffineTransform`,
+ :ocv:func:`getPerspectiveTransform`,
+ :ocv:func:`findHomography`
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.
: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::
.. ocv:pyfunction:: cv2.CamShift(probImage, window, criteria) -> retval, window
.. ocv:cfunction:: int cvCamShift( const CvArr* probImage, CvRect window, CvTermCriteria criteria, CvConnectedComp* comp, CvBox2D* box=NULL )
+
.. ocv:pyoldfunction:: cv.CamShift(probImage, window, criteria)-> (int, comp, box)
:param probImage: Back projection of the object histogram. See :ocv:func:`calcBackProject` .
--------------------------------
Computes a foreground mask.
-.. ocv:function:: virtual void BackgroundSubtractor::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
+.. ocv:function:: void BackgroundSubtractor::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
.. ocv:pyfunction:: cv2.BackgroundSubtractor.apply(image[, fgmask[, learningRate]]) -> fgmask
----------------------------------------
Computes a background image.
-.. ocv:function:: virtual void BackgroundSubtractor::getBackgroundImage(OutputArray backgroundImage) const
+.. ocv:function:: void BackgroundSubtractor::getBackgroundImage(OutputArray backgroundImage) const
:param backgroundImage: The output background image.
-----------------------------------
Updates the background model and returns the foreground mask
-.. ocv:function:: virtual void BackgroundSubtractorMOG::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
+.. ocv:function:: void BackgroundSubtractorMOG::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
Parameters are the same as in ``BackgroundSubtractor::operator()``
------------------------------------
Updates the background model and computes the foreground mask
-.. ocv:function:: virtual void BackgroundSubtractorMOG2::operator()(InputArray image, OutputArray fgmask, double learningRate=-1)
-
- See ``BackgroundSubtractor::operator ()``.
+.. ocv:function:: void BackgroundSubtractorMOG2::operator()(InputArray image, OutputArray fgmask, double learningRate=-1)
+ See :ocv:func:`BackgroundSubtractor::operator()`.
BackgroundSubtractorMOG2::getBackgroundImage
--------------------------------------------
Returns background image
-.. ocv:function:: virtual void BackgroundSubtractorMOG2::getBackgroundImage(OutputArray backgroundImage)
+.. ocv:function:: void BackgroundSubtractorMOG2::getBackgroundImage(OutputArray backgroundImage)
See :ocv:func:`BackgroundSubtractor::getBackgroundImage`.