]
opencv_module_list = [
-"core",
-"imgproc",
-"calib3d",
-"features2d",
-"video",
-"objdetect",
-"highgui",
+#"core",
+#"imgproc",
+#"calib3d",
+#"features2d",
+#"video",
+#"objdetect",
+#"highgui",
"ml"
]
fdecl = ""
balance = 0
lineno = 0
-
+
for l in df.readlines():
lineno += 1
ll = l.strip()
if balance > 0:
continue
rst_decl = self.parser.parse_func_decl_no_wrap(fdecl)
+
hdr_decls = self.fmap.get(rst_decl[0], [])
if not hdr_decls:
print "Documented function %s (%s) in %s:%d is not in the headers" % (fdecl, rst_decl[0], docname, lineno)
self.fmap[rst_decl[0]] = hdr_decls[:decl_idx] + hdr_decls[decl_idx+1:]
continue
print "Documented function %s in %s:%d does not have a match" % (fdecl, docname, lineno)
+ df.close()
def check_module_docs(self, name):
self.parser = hp.CppHeaderParser()
self.process_rst(d)
print "\n\n########## The list of undocumented functions: ###########\n\n"
+ misscount = 0
fkeys = sorted(self.fmap.keys())
for f in fkeys:
decls = self.fmap[f]
for d in decls:
+ misscount += 1
print "%s %s(%s)" % (d[1], d[0], ", ".join([a[0] + " " + a[1] for a in d[3]]))
+ print "\n\n\nundocumented functions in %s: %d" % (name, misscount)
p = RSTParser()
for m in opencv_module_list:
The function returns the final re-projection error.
Note: if you're using a non-square (=non-NxN) grid and
-:func:`findChessboardCorners`
+:cpp:func:`findChessboardCorners`
for calibration, and
``calibrateCamera``
returns
,
:ref:`FindExtrinsicCameraParams2`
,
-:func:`initCameraMatrix2D`
+:cpp:func:`initCameraMatrix2D`
,
:ref:`StereoCalibrate`
,
:param P1, P2: The output :math:`3 \times 4` projection matrices in the new (rectified) coordinate systems.
- :param Q: The output :math:`4 \times 4` disparity-to-depth mapping matrix, see :func:`reprojectImageTo3D` .
+ :param Q: The output :math:`4 \times 4` disparity-to-depth mapping matrix, see :cpp:func:`reprojectImageTo3D` .
:param flags: The operation flags; may be 0 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 horizontal or vertical direction (depending on the orientation of epipolar lines) in order to maximize the useful image area.
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, that makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. On input the function takes the matrices computed by
-:func:`stereoCalibrate`
+:cpp:func:`stereoCalibrate`
and on output it gives 2 rotation matrices and also 2 projection matrices in the new coordinates. The 2 cases are distinguished by the function are:
:param distCoeffs: The 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: The rectification transformation in object space (3x3 matrix). ``R1`` or ``R2`` , computed by :func:`StereoRectify` can be passed here. If the matrix is empty, the identity transformation is used
+ :param R: The rectification transformation in object space (3x3 matrix). ``R1`` or ``R2`` , computed by :cpp:func:`StereoRectify` can be passed here. If the matrix is empty, the identity transformation is used
- :param P: The new camera matrix (3x3) or the new projection matrix (3x4). ``P1`` or ``P2`` , computed by :func:`StereoRectify` can be passed here. If the matrix is empty, the identity new camera matrix is used
+ :param P: The new camera matrix (3x3) or the new projection matrix (3x4). ``P1`` or ``P2`` , computed by :cpp:func:`StereoRectify` can be passed here. If the matrix is empty, the identity new camera matrix is used
All the functions include the parameter color that uses a rgb value (that may be constructed
with
``CV_RGB``
-macro or the :func:`cvScalar` function
+macro or the :cpp:func:`cvScalar` function
) for color
images and brightness for grayscale images. For color images the order channel
is normally
*Blue, Green, Red*
, this is what
-:func:`imshow`
+:cpp:func:`imshow`
,
-:func:`imread`
+:cpp:func:`imread`
and
-:func:`imwrite`
+:cpp:func:`imwrite`
expect
, so if you form a color using
-:func:`cvScalar`
+:cpp:func:`cvScalar`
, it should look like:
If you are using your own image rendering and I/O functions, you can use any channel ordering, the drawing functions process each channel independently and do not depend on the channel order or even on the color space used. The whole image can be converted from BGR to RGB or to a different color space using
-:func:`cvtColor`
+:cpp:func:`cvtColor`
.
If a drawn figure is partially or completely outside the image, the drawing functions clip it. Also, many drawing functions can handle pixel coordinates specified with sub-pixel accuracy, that is, the coordinates can be passed as fixed-point numbers, encoded as integers. The number of fractional bits is specified by the
Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images (represented as
-:func:`Mat`
+:cpp:func:`Mat`
's), that is, for each pixel location
:math:`(x,y)`
in the source image some its (normally rectangular) neighborhood is considered and used to compute the response. In case of a linear filter it is a weighted sum of pixel values, in case of morphological operations it is the minimum or maximum etc. The computed response is stored to the destination image at the same location
Note: if you're using a non-square (=non-NxN) grid and
-:func:`findChessboardCorners`
+:cpp:func:`findChessboardCorners`
for calibration, and
``calibrateCamera``
returns
,
:ref:`FindExtrinsicCameraParams2`
,
-:func:`initCameraMatrix2D`
+:cpp:func:`initCameraMatrix2D`
,
:ref:`StereoCalibrate`
,
:param P1, P2: The output :math:`3 \times 4` projection matrices in the new (rectified) coordinate systems.
- :param Q: The output :math:`4 \times 4` disparity-to-depth mapping matrix, see :func:`reprojectImageTo3D` .
+ :param Q: The output :math:`4 \times 4` disparity-to-depth mapping matrix, see :cpp:func:`reprojectImageTo3D` .
:type Q: :class:`CvMat`
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, that makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. On input the function takes the matrices computed by
-:func:`stereoCalibrate`
+:cpp:func:`stereoCalibrate`
and on output it gives 2 rotation matrices and also 2 projection matrices in the new coordinates. The 2 cases are distinguished by the function are:
:type distCoeffs: :class:`CvMat`
- :param R: The rectification transformation in object space (3x3 matrix). ``R1`` or ``R2`` , computed by :func:`StereoRectify` can be passed here. If the matrix is empty, the identity transformation is used
+ :param R: The rectification transformation in object space (3x3 matrix). ``R1`` or ``R2`` , computed by :cpp:func:`StereoRectify` can be passed here. If the matrix is empty, the identity transformation is used
:type R: :class:`CvMat`
- :param P: The new camera matrix (3x3) or the new projection matrix (3x4). ``P1`` or ``P2`` , computed by :func:`StereoRectify` can be passed here. If the matrix is empty, the identity new camera matrix is used
+ :param P: The new camera matrix (3x3) or the new projection matrix (3x4). ``P1`` or ``P2`` , computed by :cpp:func:`StereoRectify` can be passed here. If the matrix is empty, the identity new camera matrix is used
:type P: :class:`CvMat`
is normally
*Blue, Green, Red*
, this is what
-:func:`imshow`
+:cpp:func:`imshow`
,
-:func:`imread`
+:cpp:func:`imread`
and
-:func:`imwrite`
+:cpp:func:`imwrite`
expect
If you are using your own image rendering and I/O functions, you can use any channel ordering, the drawing functions process each channel independently and do not depend on the channel order or even on the color space used. The whole image can be converted from BGR to RGB or to a different color space using
-:func:`cvtColor`
+:cpp:func:`cvtColor`
.
If a drawn figure is partially or completely outside the image, the drawing functions clip it. Also, many drawing functions can handle pixel coordinates specified with sub-pixel accuracy, that is, the coordinates can be passed as fixed-point numbers, encoded as integers. The number of fractional bits is specified by the
Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images (represented as
-:func:`Mat`
+:cpp:func:`Mat`
's), that is, for each pixel location
:math:`(x,y)`
in the source image some its (normally rectangular) neighborhood is considered and used to compute the response. In case of a linear filter it is a weighted sum of pixel values, in case of morphological operations it is the minimum or maximum etc. The computed response is stored to the destination image at the same location
calibrateCamera
---------------
-.. c:function:: double calibrateCamera( const vector<vector<Point3f> >& objectPoints, const vector<vector<Point2f> >& imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector<Mat>& rvecs, vector<Mat>& tvecs, int flags=0 )
+.. cpp:function:: double calibrateCamera( InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, OutputArray rvecs, OutputArray tvecs, int flags=0 )
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
calibrationMatrixValues
-----------------------
-.. c:function:: void calibrationMatrixValues( const Mat& cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double& fovx, double& fovy, double& focalLength, Point2d& principalPoint, double& aspectRatio )
+.. cpp:function:: void calibrationMatrixValues( InputArray cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double& fovx, double& fovy, double& focalLength, Point2d& principalPoint, double& aspectRatio )
Computes useful camera characteristics from the camera matrix.
composeRT
-------------
-.. c:function:: void composeRT( const Mat& rvec1, const Mat& tvec1, const Mat& rvec2, const Mat& tvec2, Mat& rvec3, Mat& tvec3 )
-.. c:function:: void composeRT( const Mat& rvec1, const Mat& tvec1, const Mat& rvec2, const Mat& tvec2, Mat& rvec3, Mat& tvec3, Mat& dr3dr1, Mat& dr3dt1, Mat& dr3dr2, Mat& dr3dt2, Mat& dt3dr1, Mat& dt3dt1, Mat& dt3dr2, Mat& dt3dt2 )
+.. cpp:function:: void composeRT( InputArray rvec1, InputArray tvec1, InputArray rvec2, InputArray tvec2, OutputArray rvec3, OutputArray tvec3, OutputArray dr3dr1=None(), OutputArray dr3dt1=None(), OutputArray dr3dr2=None(), OutputArray dr3dt2=None(), OutputArray dt3dr1=None(), OutputArray dt3dt1=None(), OutputArray dt3dr2=None(), OutputArray dt3dt2=None() )
Combines two rotation-and-shift transformations.
computeCorrespondEpilines
-----------------------------
-.. c:function:: void computeCorrespondEpilines( const Mat& points, int whichImage, const Mat& F, vector<Vec3f>& lines )
+.. cpp:function:: void computeCorrespondEpilines( InputArray points, int whichImage, InputArray F, OutputArray lines )
For points in an image of a stereo pair, computes the corresponding epilines in the other image.
convertPointsHomogeneous
------------------------
-.. c:function:: void convertPointsHomogeneous( const Mat& src, vector<Point3f>& dst )
-
-.. c:function:: void convertPointsHomogeneous( const Mat& src, vector<Point2f>& dst )
+.. cpp:function:: void convertPointsHomogeneous( InputArray src, OutputArray dst )
Converts points to/from homogeneous coordinates.
decomposeProjectionMatrix
-----------------------------
-.. c:function:: void decomposeProjectionMatrix( const Mat& projMatrix, Mat& cameraMatrix, Mat& rotMatrix, Mat& transVect )
+.. cpp:function:: void decomposeProjectionMatrix( InputArray projMatrix, OutputArray cameraMatrix, OutputArray rotMatrix, OutputArray transVect )
-.. c:function:: void decomposeProjectionMatrix( const Mat& projMatrix, Mat& cameraMatrix, Mat& rotMatrix, Mat& transVect, Mat& rotMatrixX, Mat& rotMatrixY, Mat& rotMatrixZ, Vec3d& eulerAngles )
+.. cpp:function:: void decomposeProjectionMatrix( InputArray projMatrix, OutputArray cameraMatrix, OutputArray rotMatrix, OutputArray transVect, OutputArray rotMatrixX, OutputArray rotMatrixY, OutputArray rotMatrixZ, Vec3d& eulerAngles )
Decomposes a projection matrix into a rotation matrix and a camera matrix.
drawChessboardCorners
-------------------------
-.. c:function:: void drawChessboardCorners( Mat& image, Size patternSize, const Mat& corners, bool patternWasFound )
+.. cpp:function:: void drawChessboardCorners( InputOutputArray image, Size patternSize, InputArray corners, bool patternWasFound )
Renders the detected chessboard corners.
findChessboardCorners
-------------------------
-.. c:function:: bool findChessboardCorners( const Mat& image, Size patternSize, vector<Point2f>& corners, int flags=CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE )
+.. cpp:function:: bool findChessboardCorners( InputArray image, Size patternSize, OutputArray corners, int flags=CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE )
Finds the positions of internal corners of the chessboard.
findCirclesGrid
-------------------
-.. c:function:: bool findCirclesGrid( const Mat& image, Size patternSize, vector<Point2f>& centers, int flags=CALIB_CB_SYMMETRIC_GRID )
+.. cpp:function:: bool findCirclesGrid( InputArray image, Size patternSize, vector<Point2f>& centers, int flags=CALIB_CB_SYMMETRIC_GRID )
Finds the centers in the grid of circles.
solvePnP
------------
-.. c:function:: void solvePnP( const Mat& objectPoints, const Mat& imagePoints, const Mat& cameraMatrix, const Mat& distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess=false )
+.. cpp:function:: void solvePnP( InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess=false )
Finds an object pose from 3D-2D point correspondences.
solvePnPRansac
------------------
-.. c:function:: void solvePnPRansac( const Mat& objectPoints, const Mat& imagePoints, const Mat& cameraMatrix, const Mat& distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess=false, int iterationsCount = 100, float reprojectionError = 8.0, int minInliersCount = 100, vector<int>* inliers = NULL )
+.. cpp:function:: void solvePnPRansac( InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess=false, int iterationsCount = 100, float reprojectionError = 8.0, int minInliersCount = 100, OutputArray inliers = None() )
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
findFundamentalMat
----------------------
-.. c:function:: Mat findFundamentalMat( const Mat& points1, const Mat& points2, vector<uchar>& status, int method=FM_RANSAC, double param1=3., double param2=0.99 )
-
-.. c:function:: Mat findFundamentalMat( const Mat& points1, const Mat& points2, int method=FM_RANSAC, double param1=3., double param2=0.99 )
+.. cpp:function:: Mat findFundamentalMat( InputArray points1, InputArray points2, int method=FM_RANSAC, double param1=3., double param2=0.99, OutputArray mask=None() )
Calculates a fundamental matrix from the corresponding points in two images.
findHomography
------------------
-.. c:function:: Mat findHomography( const Mat& srcPoints, const Mat& dstPoints, Mat& status, int method=0, double ransacReprojThreshold=3 )
-
-.. c:function:: Mat findHomography( const Mat& srcPoints, const Mat& dstPoints, vector<uchar>& status, int method=0, double ransacReprojThreshold=3 )
-
-.. c:function:: Mat findHomography( const Mat& srcPoints, const Mat& dstPoints, int method=0, double ransacReprojThreshold=3 )
+.. cpp:function:: Mat findHomography( InputArray srcPoints, InputArray dstPoints, int method=0, double ransacReprojThreshold=3, OutputArray mask=None() )
Finds a perspective transformation between two planes.
:ref:`WarpPerspective`,
:ref:`PerspectiveTransform`
-.. index:: getDefaultNewCameraMatrix
-
-.. index:: getDefaultNewCameraMatrix
-
-.. _getDefaultNewCameraMatrix:
-
-getDefaultNewCameraMatrix
------------------------------
-.. c:function:: Mat getDefaultNewCameraMatrix( const Mat& cameraMatrix, Size imgSize=Size(), bool centerPrincipalPoint=false )
-
- Returns the default new camera matrix.
-
- :param cameraMatrix: Input camera matrix.
-
- :param imageSize: Camera view image size in pixels.
-
- :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).
-
-In the latter case, the new camera matrix will be:
-
-.. math::
-
- \begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,
-
-where
-:math:`f_x` and
-:math:`f_y` are
-:math:`(0,0)` and
-: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.
.. index:: getOptimalNewCameraMatrix
getOptimalNewCameraMatrix
-----------------------------
-.. c:function:: Mat getOptimalNewCameraMatrix( const Mat& cameraMatrix, const Mat& distCoeffs, Size imageSize, double alpha, Size newImageSize=Size(), Rect* validPixROI=0)
+.. cpp:function:: Mat getOptimalNewCameraMatrix( InputArray cameraMatrix, InputArray distCoeffs, Size imageSize, double alpha, Size newImageSize=Size(), Rect* validPixROI=0)
Returns the new camera matrix based on the free scaling parameter.
initCameraMatrix2D
----------------------
-.. c:function:: Mat initCameraMatrix2D( const vector<vector<Point3f> >& objectPoints, const vector<vector<Point2f> >& imagePoints, Size imageSize, double aspectRatio=1.)
+.. cpp:function:: Mat initCameraMatrix2D( InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size imageSize, double aspectRatio=1.)
Finds an initial camera matrix from 3D-2D point correspondences.
The function estimates and returns an initial camera matrix for the camera calibration process.
Currently, the function only supports planar calibration patterns, which are patterns where each object point has z-coordinate =0.
-.. index:: initUndistortRectifyMap
-
-.. _initUndistortRectifyMap:
-
-initUndistortRectifyMap
----------------------------
-
-.. c:function:: void initUndistortRectifyMap( const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& R, const Mat& newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2 )
-
- Computes the undistortion and rectification transformation map.
-
- :param cameraMatrix: Input camera matrix :math:`A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}` .
-
- :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.
-
- :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 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` .
-
-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
-: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::
-
- \begin{array}{l} x \leftarrow (u - {c'}_x)/{f'}_x \\ y \leftarrow (v - {c'}_y)/{f'}_y \\{[X\,Y\,W]} ^T \leftarrow R^{-1}*[x \, y \, 1]^T \\ x' \leftarrow X/W \\ y' \leftarrow Y/W \\ x" \leftarrow x' (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + 2p_1 x' y' + p_2(r^2 + 2 x'^2) \\ y" \leftarrow y' (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' \\ map_x(u,v) \leftarrow x" f_x + c_x \\ map_y(u,v) \leftarrow y" f_y + c_y \end{array}
-
-where
-:math:`(k_1, k_2, p_1, p_2[, k_3])` are the distortion coefficients.
-
-In case of a stereo camera, this function is called twice: once for each camera head, after
-:ref:`StereoRectify` , which in its turn is called after
-:ref:`StereoCalibrate` . But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from the fundamental matrix using
-:ref:`StereoRectifyUncalibrated` . For each camera, the function computes homography ``H`` as the rectification transformation in a pixel domain, not a rotation matrix ``R`` in 3D space. ``R`` can be computed from ``H`` as
-
-.. math::
-
- \texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}
-
-where ``cameraMatrix`` can be chosen arbitrarily.
-
.. index:: matMulDeriv
.. _matMulDeriv:
matMulDeriv
---------------
-.. c:function:: void matMulDeriv( const Mat& A, const Mat& B, Mat& dABdA, Mat& dABdB )
+.. cpp:function:: void matMulDeriv( InputArray A, InputArray B, OutputArray dABdA, OutputArray dABdB )
Computes partial derivatives of the matrix product for each multiplied matrix.
projectPoints
-----------------
-.. c:function:: void projectPoints( const Mat& objectPoints, const Mat& rvec, const Mat& tvec, const Mat& cameraMatrix, const Mat& distCoeffs, vector<Point2f>& imagePoints )
-
-.. c:function:: void projectPoints( const Mat& objectPoints, const Mat& rvec, const Mat& tvec, const Mat& cameraMatrix, const Mat& distCoeffs, vector<Point2f>& imagePoints, Mat& dpdrot, Mat& dpdt, Mat& dpdf, Mat& dpdc, Mat& dpddist, double aspectRatio=0 )
+.. cpp:function:: void projectPoints( InputArray objectPoints, InputArray rvec, InputArray tvec, InputArray cameraMatrix, InputArray distCoeffs, OutputArray imagePoints, OutputArray dpdrot=None(), OutputArray dpdt=None(), OutputArray dpdf=None(), OutputArray dpdc=None(), OutputArray dpddist=None(), double aspectRatio=0 )
Projects 3D points to an image plane.
reprojectImageTo3D
----------------------
-.. c:function:: void reprojectImageTo3D( const Mat& disparity, Mat& _3dImage, const Mat& Q, bool handleMissingValues=false )
+.. cpp:function:: void reprojectImageTo3D( InputArray disparity, OutputArray _3dImage, InputArray Q, bool handleMissingValues=false )
Reprojects a disparity image to 3D space.
RQDecomp3x3
---------------
-.. c:function:: void RQDecomp3x3( const Mat& M, Mat& R, Mat& Q )
+.. cpp:function:: void RQDecomp3x3( InputArray M, OutputArray R, OutputArray Q )
-.. c:function:: Vec3d RQDecomp3x3( const Mat& M, Mat& R, Mat& Q, Mat& Qx, Mat& Qy, Mat& Qz )
+.. cpp:function:: Vec3d RQDecomp3x3( InputArray M, OutputArray R, OutputArray Q, OutputArray Qx, OutputArray Qy, OutputArray Qz )
Computes an RQ decomposition of 3x3 matrices.
Rodrigues
-------------
-.. c:function:: void Rodrigues(const Mat& src, Mat& dst)
-
-.. c:function:: void Rodrigues(const Mat& src, Mat& dst, Mat& jacobian)
+.. cpp:function:: void Rodrigues(InputArray src, OutputArray dst, OutputArray jacobian=None())
Converts a rotation matrix to a rotation vector or vice versa.
void init(int preset, int ndisparities=0, int SADWindowSize=21);
// computes the disparity for the two rectified 8-bit single-channel images.
// the disparity will be 16-bit signed (fixed-point) or 32-bit floating-point image of the same size as left.
- void operator()( const Mat& left, const Mat& right, Mat& disparity, int disptype=CV_16S );
+ void operator()( InputArray left, InputArray right, OutputArray disparity, int disptype=CV_16S );
Ptr<CvStereoBMState> state;
};
StereoBM::operator ()
-----------------------
-.. c:function:: void StereoBM::operator()(const Mat& left, const Mat& right, Mat& disp, int disptype=CV_16S )
+.. cpp:function:: void StereoBM::operator()(InputArray left, InputArray right, OutputArray disp, int disptype=CV_16S )
Computes disparity using the BM algorithm for a rectified stereo pair.
bool fullDP=false);
virtual ~StereoSGBM();
- virtual void operator()(const Mat& left, const Mat& right, Mat& disp);
+ virtual void operator()(InputArray left, InputArray right, OutputArray disp);
int minDisparity;
int numberOfDisparities;
StereoSGBM::StereoSGBM
--------------------------
-.. c:function:: StereoSGBM::StereoSGBM()
+.. cpp:function:: StereoSGBM::StereoSGBM()
-.. c:function:: StereoSGBM::StereoSGBM( int minDisparity, int numDisparities, int SADWindowSize, int P1=0, int P2=0, int disp12MaxDiff=0, int preFilterCap=0, int uniquenessRatio=0, int speckleWindowSize=0, int speckleRange=0, bool fullDP=false)
+.. cpp:function:: StereoSGBM::StereoSGBM( int minDisparity, int numDisparities, int SADWindowSize, int P1=0, int P2=0, int disp12MaxDiff=0, int preFilterCap=0, int uniquenessRatio=0, int speckleWindowSize=0, int speckleRange=0, bool fullDP=false)
The constructor.
StereoSGBM::operator ()
-----------------------
-.. c:function:: void StereoSGBM::operator()(const Mat& left, const Mat& right, Mat& disp)
+.. cpp:function:: void StereoSGBM::operator()(InputArray left, InputArray right, OutputArray disp)
Computes disparity using the SGBM algorithm for a rectified stereo pair.
stereoCalibrate
-------------------
-.. c:function:: double stereoCalibrate( const vector<vector<Point3f> >& objectPoints, const vector<vector<Point2f> >& imagePoints1, const vector<vector<Point2f> >& imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, TermCriteria term_crit = TermCriteria(TermCriteria::COUNT+ TermCriteria::EPS, 30, 1e-6), int flags=CALIB_FIX_INTRINSIC )
+.. cpp:function:: double stereoCalibrate( InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, Size imageSize, OutputArray R, OutputArray T, OutputArray E, OutputArray F, TermCriteria term_crit = TermCriteria(TermCriteria::COUNT+ TermCriteria::EPS, 30, 1e-6), int flags=CALIB_FIX_INTRINSIC )
Calibrates the stereo camera.
.. index:: stereoRectify
-.. _stereoRectify:
-
stereoRectify
-----------------
-.. c:function:: void stereoRectify( const Mat& cameraMatrix1, const Mat& distCoeffs1, const Mat& cameraMatrix2, const Mat& distCoeffs2, Size imageSize, const Mat& R, const Mat& T, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags=CALIB_ZERO_DISPARITY )
-.. c:function:: void stereoRectify( const Mat& cameraMatrix1, const Mat& distCoeffs1, const Mat& cameraMatrix2, const Mat& distCoeffs2, Size imageSize, const Mat& R, const Mat& T, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, double alpha, Size newImageSize=Size(), Rect* roi1=0, Rect* roi2=0, int flags=CALIB_ZERO_DISPARITY )
+.. cpp:function:: void stereoRectify( InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags=CALIB_ZERO_DISPARITY, double alpha, Size newImageSize=Size(), Rect* roi1=0, Rect* roi2=0 )
Computes rectification transforms for each head of a calibrated stereo camera.
stereoRectifyUncalibrated
-----------------------------
-.. c:function:: bool stereoRectifyUncalibrated( const Mat& points1, const Mat& points2, const Mat& F, Size imgSize, Mat& H1, Mat& H2, double threshold=5 )
+.. cpp:function:: bool stereoRectifyUncalibrated( InputArray points1, InputArray points2, InputArray F, Size imgSize, OutputArray H1, OutputArray H2, double threshold=5 )
Computes a rectification transform for an uncalibrated stereo camera.
:ref:`calibrateCamera` . Then, the images can be corrected using
:ref:`undistort` , or just the point coordinates can be corrected with
:ref:`undistortPoints` .
-
-.. index:: undistort
-
-.. _undistort:
-
-undistort
--------------
-.. c:function:: void undistort( const Mat& src, Mat& dst, const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& newCameraMatrix=Mat() )
-
- Transforms an image to compensate for lens distortion.
-
- :param src: Input (distorted) image.
-
- :param dst: Output (corrected) image that has the same size and type as ``src`` .
-
- :param cameraMatrix: Input camera matrix :math:`A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}` .
-
- :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 newCameraMatrix: Camera matrix of the distorted image. By default, it is the same as ``cameraMatrix`` but you may additionally scale and shift the result by using a different matrix.
-
-The function transforms an image to compensate radial and tangential lens distortion.
-
-The function is simply a combination of
-:ref:`InitUndistortRectifyMap` (with unity ``R`` ) and
-:ref:`Remap` (with bilinear interpolation). See the former function for details of the transformation being performed.
-
-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.
-
-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,
-:math:`f_x, f_y, c_x` and
-:math:`c_y` need to be scaled accordingly, while the distortion coefficients remain the same.
-
-.. index:: undistortPoints
-
-.. _undistortPoints:
-
-undistortPoints
--------------------
-.. c:function:: void undistortPoints( const Mat& src, vector<Point2f>& dst, const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& R=Mat(), const Mat& P=Mat())
-
-.. c:function:: void undistortPoints( const Mat& src, Mat& dst, const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& R=Mat(), const Mat& P=Mat())
-
- Computes the ideal point coordinates from the observed point coordinates.
-
- :param src: Observed point coordinates, 1xN or Nx1 2-channel (CV _ 32FC2 or CV _ 64FC2).
-
- :param dst: Output ideal point coordinates after undistortion and reverse perspective transformation.
-
- :param cameraMatrix: Camera matrix :math:`\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}` .
-
- :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 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.
-
-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. ::
-
- // (u,v) is the input point, (u', v') is the output point
- // camera_matrix=[fx 0 cx; 0 fy cy; 0 0 1]
- // P=[fx' 0 cx' tx; 0 fy' cy' ty; 0 0 1 tz]
- x" = (u - cx)/fx
- y" = (v - cy)/fy
- (x',y') = undistort(x",y",dist_coeffs)
- [X,Y,W]T = R*[x' y' 1]T
- x = X/W, y = Y/W
- u' = x*fx' + cx'
- v' = y*fy' + cy',
-
-where ``undistort()`` is an approximate iterative algorithm that estimates the normalized original point coordinates out of the normalized distorted point coordinates ("normalized" means that the coordinates do not depend on the camera matrix).
-
-The function can be used for both a stereo camera head or a monocular camera (when R is
-empty
-).
DataType
--------
+.. cpp:class:: DataType
+
Template "trait" class for other OpenCV primitive data types ::
template<typename _Tp> class DataType
};
};
-The template class ``DataType`` is a descriptive class for OpenCV primitive data types and other types that comply with the following definition. A primitive OpenCV data type is one of ``unsigned char``, ``bool``, ``signed char``, ``unsigned short``, ``signed short``, ``int``, ``float``, ``double`` or a tuple of values of one of these types, where all the values in the tuple have the same type. Any primitive type from the list can be defined by an identifier in the form ``CV_<bit-depth>{U|S|F}C<number_of_channels>``, for example: ``uchar`` ~ ``CV_8UC1``, 3-element floating-point tuple ~ ``CV_32FC3``, and so on. A universal OpenCV structure that is able to store a single instance of such a primitive data type is
+The template class ``DataType`` is a descriptive class for OpenCV primitive data types and other types that comply with the following definition. A primitive OpenCV data type is one of ``unsigned char``, ``bool``, ``signed char``, ``unsigned short``, ``signed short``, ``int``, ``float``, ``double`` or a tuple of values of one of these types, where all the values in the tuple have the same type. Any primitive type from the list can be defined by an identifier in the form ``CV_<bit-depth>{U|S|F}C(<number_of_channels>)``, for example: ``uchar`` ~ ``CV_8UC1``, 3-element floating-point tuple ~ ``CV_32FC3``, and so on. A universal OpenCV structure that is able to store a single instance of such a primitive data type is
:ref:`Vec`. Multiple instances of such a type can be stored in a ``std::vector``, ``Mat``, ``Mat_``, ``SparseMat``, ``SparseMat_``, or any other container that is able to store ``Vec`` instances.
The ``DataType`` class is basically used to provide a description of such primitive data types without adding any fields or methods to the corresponding classes (and it is actually impossible to add anything to primitive C/C++ data types). This technique is known in C++ as class traits. It is not ``DataType`` itself that is used but its specialized versions, such as: ::
Point\_
-------
+.. cpp:class:: Point_
+
Template class for 2D points ::
template<typename _Tp> class Point_
Point3\_
--------
+.. cpp:class:: Point3_
+
Template class for 3D points ::
template<typename _Tp> class Point3_
:math:`z` .
An instance of the class is interchangeable with the C structure ``CvPoint2D32f`` . Similarly to ``Point_`` , the coordinates of 3D points can be converted to another type. The vector arithmetic and comparison operations are also supported.
-The following types of?? aliases are available: ::
+The following ``Point3_<>`` aliases are available: ::
typedef Point3_<int> Point3i;
typedef Point3_<float> Point3f;
Size\_
------
+.. cpp:class:: Size_
+
Template class for specfying an image or rectangle size ::
template<typename _Tp> class Size_
The class ``Size_`` is similar to ``Point_`` except that the two members are called ``width`` and ``height`` instead of ``x`` and ``y`` . The structure can be converted to and from the old OpenCV structures
``CvSize`` and ``CvSize2D32f`` . The same set of arithmetic and comparison operations as for ``Point_`` is available.
-OpenCV defines the following types of?? aliases: ::
+OpenCV defines the following ``Size_<>`` aliases: ::
typedef Size_<int> Size2i;
typedef Size2i Size;
Rect\_
------
+.. cpp:class:: Rect_
+
Template class for 2D rectangles ::
template<typename _Tp> class Rect_
}
-For your convenience, the following type of aliases?? is available: ::
+For your convenience, the ``Rect_<>`` alias is available: ::
typedef Rect_<int> Rect;
.. index:: _RotatedRect
-
+
.. _RotatedRect:
RotatedRect
-----------
+.. cpp:class:: RotatedRect
+
Template class for rotated rectangles ::
class RotatedRect
TermCriteria
------------
-.. c:type:: TermCriteria
+.. cpp:class:: TermCriteria
Template class defining termination criteria for iterative algorithms ::
Matx
----
+.. cpp:class:: Matx
+
Template class for small matrices ::
template<typename T, int m, int n> class Matx
The class represents small matrices whose type and size are known at compilation time. If you need a more flexible type, use
-:ref:`Mat` . The elements of the matrix ``M`` are accessible using the ``M(i,j)`` notation. Most of the common matrix operations (see also
+:cpp:class:`Mat` . The elements of the matrix ``M`` are accessible using the ``M(i,j)`` notation. Most of the common matrix operations (see also
:ref:`MatrixExpressions` ) are available. To do an operation on ``Matx`` that is not implemented, you can easily convert the matrix to
-:ref:`Mat` and backwards. ::
+:cpp:class:`Mat` and backwards. ::
Matx33f m(1, 2, 3,
4, 5, 6,
cout << sum(Mat(m*m.t())) << endl;
.. index:: Vec
-
+
.. _Vec:
Vec
---
+.. cpp:class:: Vec
+
Template class for short numerical vectors ::
template<typename T, int cn> class Vec : public Matx<T, cn, 1>
* ``v1 == v2, v1 != v2`` * ``norm(v1)`` (:math:`L_2`-norm)
The ``Vec`` class is commonly used to describe pixel types of multi-channel arrays. See
-:ref:`Mat_`?? for details.
+:ref:`Mat_` for details.
.. index:: Scalar
Scalar\_
--------
+.. cpp:class:: Scalar_
+
Template class for a 4-element vector ::
template<typename _Tp> class Scalar_ : public Vec<_Tp, 4>
Range
-----
+.. cpp:class:: Range
+
Template class specifying a continuous subsequence (slice) of a sequence ::
class Range
Ptr
---
+.. cpp:class:: Ptr
+
Template class for smart reference-counting pointers ::
template<typename _Tp> class Ptr
Default constructor, copy constructor, and assignment operator for an arbitrary C++ class or a C structure. For some objects, like files, windows, mutexes, sockets, and others, a copy constructor or an assignment operator are difficult to define. For some other objects, like complex classifiers in OpenCV, copy constructors are absent and not easy to implement. Finally, some of complex OpenCV and your own data structures may be written in C. However, copy constructors and default constructors can simplify programming a lot. Besides, they are often required (for example, by STL containers). By wrapping a pointer to such a complex object ``TObj`` to ``Ptr<TObj>`` , you automatically get all of the necessary constructors and the assignment operator.
*
- Speed-up for the above-mentioned operations regardless of the data size, similar to "O(1)" operations.?? Indeed, while some structures, like ``std::vector`` , provide a copy constructor and an assignment operator, the operations may take a considerable amount of time if the data structures are large. But if the structures are put into ``Ptr<>`` , the overhead is small and independent of the data size.
+ *O(1)* complexity of the above-mentioned operations. Indeed, while some structures, like ``std::vector``, provide a copy constructor and an assignment operator, the operations may take a considerable amount of time if the data structures are large. But if the structures are put into ``Ptr<>`` , the overhead is small and independent of the data size.
*
Automatic destruction, even for C structures. See the example below with ``FILE*`` .
.. index:: Mat
-.. _Mat:
-
Mat
---
-.. c:type:: Mat
+.. cpp:class:: Mat
OpenCV C++ n-dimensional dense array class ::
..
- ??is the indent required here? does it apply to step 2 but not to the whole bulleted item??Partial yet very common cases of this *user-allocated data* case are conversions from ``CvMat`` and ``IplImage`` to ``Mat``. For this purpose, there are special constructors taking pointers to ``CvMat`` or ``IplImage`` and the optional flag indicating whether to copy the data or not.
+ Partial yet very common cases of this *user-allocated data* case are conversions from ``CvMat`` and ``IplImage`` to ``Mat``. For this purpose, there are special constructors taking pointers to ``CvMat`` or ``IplImage`` and the optional flag indicating whether to copy the data or not.
- Backward conversion from ``Mat`` to ``CvMat`` or ``IplImage`` is provided via cast operators ``Mat::operator CvMat() const`` and ``Mat::operator IplImage()``. The operators do NOT copy the data.
+ Backward conversion from ``Mat`` to ``CvMat`` or ``IplImage`` is provided via cast operators ``Mat::operator CvMat() const`` and ``Mat::operator IplImage()``. The operators do NOT copy the data.
::
.. index:: Mat::Mat
-.. _Mat::Mat:
-
Mat::Mat
------------
.. cpp:function:: Mat::Mat()
:param m: The assigned, right-hand-side matrix. Matrix assignment is O(1) operation, that is, no data is copied. Instead, the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is de-referenced via :ref:`Mat::release` .
- :param expr: The assigned matrix expression object. As opposite to the first form of assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, ``C=A+B`` is expanded to ``add(A, B, C)`` , and :func:`add` takes care of automatic ``C`` reallocation.
+ :param expr: The assigned matrix expression object. As opposite to the first form of assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, ``C=A+B`` is expanded to ``add(A, B, C)`` , and :cpp:func:`add` takes care of automatic ``C`` reallocation.
:param s: The scalar assigned to each matrix element. The matrix size or type is not changed.
.. index:: Mat::row
-.. _Mat::row:
-
Mat::row
------------
.. cpp:function:: Mat Mat::row(int i) const
.. index:: Mat::col
-.. _Mat::col:
-
Mat::col
------------
.. cpp:function:: Mat Mat::col(int j) const
.. index:: Mat::rowRange
-.. _Mat::rowRange:
-
Mat::rowRange
-----------------
.. cpp:function:: Mat Mat::rowRange(int startrow, int endrow) const
:param endrow: A 0-based ending index of the row span.
- :param r: The :func:`Range` structure containing both the start and the end indices.
+ :param r: The :cpp:func:`Range` structure containing both the start and the end indices.
The method makes a new header for the specified row span of the matrix. Similarly to
-:func:`Mat::row` and
-:func:`Mat::col` , this is an O(1) operation.
+:cpp:func:`Mat::row` and
+:cpp:func:`Mat::col` , this is an O(1) operation.
.. index:: Mat::colRange
-.. _Mat::colRange:
-
Mat::colRange
-----------------
.. cpp:function:: Mat Mat::colRange(int startcol, int endcol) const
:param endcol: A 0-based ending index of the column span.
- :param r: The :func:`Range` structure containing both the start and the end indices.
+ :param r: The :cpp:func:`Range` structure containing both the start and the end indices.
The method makes a new header for the specified column span of the matrix. Similarly to
-:func:`Mat::row` and
-:func:`Mat::col` , this is an O(1) operation.
+:cpp:func:`Mat::row` and
+:cpp:func:`Mat::col` , this is an O(1) operation.
.. index:: Mat::diag
-.. _Mat::diag:
-
Mat::diag
-------------
.. cpp:function:: Mat Mat::diag(int d) const
:param matD: A single-column matrix that forms the diagonal matrix.
The method makes a new header for the specified matrix diagonal. The new matrix is represented as a single-column matrix. Similarly to
-:func:`Mat::row` and
-:func:`Mat::col` , this is an O(1) operation.
+:cpp:func:`Mat::row` and
+:cpp:func:`Mat::col` , this is an O(1) operation.
.. index:: Mat::clone
-.. _Mat::clone:
-
Mat::clone
--------------
.. cpp:function:: Mat Mat::clone() const
.. index:: Mat::convertTo
-.. _Mat::convertTo:
-
Mat::convertTo
------------------
.. cpp:function:: void Mat::convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const
Mat::setTo
--------------
-.. c:function:: Mat& Mat::setTo(const Scalar& s, const Mat& mask=Mat())
+.. cpp:function:: Mat& Mat::setTo(const Scalar& s, const Mat& mask=Mat())
Sets all or some of the array elements to the specified value.
*
No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of rows, or the operation changes the indices of elements' row in some other way, the matrix must be continuous. See
- :func:`Mat::isContinuous` .
+ :cpp:func:`Mat::isContinuous` .
For example, if there is a set of 3D points stored as an STL vector, and you want to represent the points as a ``3xN`` matrix, do the following: ::
:param type: Created matrix type.
The method returns a Matlab-style 1's array initializer, similarly to
-:func:`Mat::zeros` . Note that using this method you can initialize an array with an arbitrary value, using the following Matlab idiom: ::
+:cpp:func:`Mat::zeros` . Note that using this method you can initialize an array with an arbitrary value, using the following Matlab idiom: ::
Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3.
:param type: Created matrix type.
The method returns a Matlab-style identity matrix initializer, similarly to
-:func:`Mat::zeros` . Similarly to ``Mat::ones`` , you can use a scale operation to create a scaled identity matrix efficiently: ::
+:cpp:func:`Mat::zeros` . Similarly to ``Mat::ones`` , you can use a scale operation to create a scaled identity matrix efficiently: ::
// make a 4x4 diagonal matrix with 0.1's on the diagonal.
Mat A = Mat::eye(4, 4, CV_32F)*0.1;
#.
Otherwise, de-reference the previous data by calling
- :func:`Mat::release` #.
+ :cpp:func:`Mat::release` #.
initialize the new header
#.
.. index:: Mat::addref
-.. _Mat::addref:
-
Mat::addref
---------------
.. cpp:function:: void Mat::addref()
Increments the reference counter.
The method increments the reference counter associated with the matrix data. If the matrix header points to an external data set (see
-:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It is called implicitly by the matrix assignment operator. The reference counter increment is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
+:cpp:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It is called implicitly by the matrix assignment operator. The reference counter increment is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
.. index:: Mat::release
-.. _Mat::release:
-
Mat::release
----------------
.. cpp:function:: void Mat::release()
Decrements the reference counter and deallocates the matrix if needed.
The method decrements the reference counter associated with the matrix data. When the reference counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers are set to NULL's. If the matrix header points to an external data set (see
-:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case.
+:cpp:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case.
This method can be called manually to force the matrix data deallocation. But since this method is automatically called in the destructor, or by any other method that changes the data pointer, it is usually not needed. The reference counter decrement and check for 0 is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
.. index:: Mat::resize
-.. _Mat::resize:
-
Mat::resize
---------------
.. cpp:function:: void Mat::resize( size_t sz ) const
.. index:: Mat::push_back
-.. _Mat::push_back:
-
Mat::push_back
--------------
-.. c:function:: template<typename T> void Mat::push_back(const T& elem)
-.. c:function:: template<typename T> void Mat::push_back(const Mat_<T>& elem)
+.. cpp:function:: template<typename T> void Mat::push_back(const T& elem)
+.. cpp:function:: template<typename T> void Mat::push_back(const Mat_<T>& elem)
Adds elements to the bottom of the matrix.
Mat::pop_back
-------------
-.. c:function:: template<typename T> void Mat::pop_back(size_t nelems=1)
+.. cpp:function:: template<typename T> void Mat::pop_back(size_t nelems=1)
Removes elements from the bottom of the matrix.
:param ofs: An output parameter that contains an offset of ``*this`` inside the whole matrix.
After you extracted a submatrix from a matrix using
-:func:`Mat::row`,:func:`Mat::col`,:func:`Mat::rowRange`,:func:`Mat::colRange` , and others, the resultant submatrix will point just to the part of the original big matrix. However, each submatrix contains some information (represented by ``datastart`` and ``dataend`` fields) that helps reconstruct the original matrix size and the position of the extracted submatrix within the original matrix. The method ``locateROI`` does exactly that.
+:cpp:func:`Mat::row`,:cpp:func:`Mat::col`,:cpp:func:`Mat::rowRange`,:cpp:func:`Mat::colRange` , and others, the resultant submatrix will point just to the part of the original big matrix. However, each submatrix contains some information (represented by ``datastart`` and ``dataend`` fields) that helps reconstruct the original matrix size and the position of the extracted submatrix within the original matrix. The method ``locateROI`` does exactly that.
.. index:: Mat::adjustROI
:param dright: The shift of the right submatrix boundary to the right.
The method is complimentary to
-:func:`Mat::locateROI` . Indeed, the typical use of these functions is to determine the submatrix position within the parent matrix and then shift the position somehow. Typically, it can be required for filtering operations when pixels outside of the ROI should be taken into account. When all the method parameters are positive, the ROI needs to grow in all directions by the specified amount, for example: ::
+:cpp:func:`Mat::locateROI` . Indeed, the typical use of these functions is to determine the submatrix position within the parent matrix and then shift the position somehow. Typically, it can be required for filtering operations when pixels outside of the ROI should be taken into account. When all the method parameters are positive, the ROI needs to grow in all directions by the specified amount, for example: ::
A.adjustROI(2, 2, 2, 2);
It is your responsibility to make sure ``adjustROI`` does not cross the parent matrix boundary. If it does, the function signals an error.
The function is used internally by the OpenCV filtering functions, like
-:func:`filter2D` , morphological operations, and so on.
+:cpp:func:`filter2D` , morphological operations, and so on.
See Also
-:func:`copyMakeBorder`
+:cpp:func:`copyMakeBorder`
.. index:: Mat::operator()
:param ranges: The array of selected ranges along each array dimension.
The operators make a new header for the specified sub-array of ``*this`` . They are the most generalized forms of
-:func:`Mat::row`,:func:`Mat::col`,:func:`Mat::rowRange`, and
-:func:`Mat::colRange` . For example, ``A(Range(0, 10), Range::all())`` is equivalent to ``A.rowRange(0, 10)`` . Similarly to all of the above, the operators are O(1) operations, that is, no matrix data is copied.
+:cpp:func:`Mat::row`,:cpp:func:`Mat::col`,:cpp:func:`Mat::rowRange`, and
+:cpp:func:`Mat::colRange` . For example, ``A(Range(0, 10), Range::all())`` is equivalent to ``A.rowRange(0, 10)`` . Similarly to all of the above, the operators are O(1) operations, that is, no matrix data is copied.
.. index:: Mat::operator CvMat
Mat::operator CvMat
-----------------------
-.. cpp:function:: Mat::operator CvMat(void) const
+.. cpp:function:: Mat::operator CvMat() const
Creates the ``CvMat`` header for the matrix.
Mat::operator IplImage
--------------------------
-.. cpp:function:: Mat::operator IplImage(void) const
+.. cpp:function:: Mat::operator IplImage() const
Creates the ``IplImage`` header for the matrix.
Mat::total
--------------
-.. cpp:function:: size_t Mat::total(void) const
+.. cpp:function:: size_t Mat::total() const
Returns the total number of array elements.
Mat::isContinuous
---------------------
-.. cpp:function:: bool Mat::isContinuous(void) const
+.. cpp:function:: bool Mat::isContinuous() const
Reports whether the matrix is continuous or not.
The method returns ``true`` if the matrix elements are stored continuously - without gaps in the end of each row. Otherwise, it returns ``false``. Obviously, ``1x1`` or ``1xN`` matrices are always continuous. Matrices created with
-:func:`Mat::create` are always continuous. But if you extract a part of the matrix using
-:func:`Mat::col`,:func:`Mat::diag` , and so on, or constructed a matrix header for externally allocated data, such matrices may no longer have this property.
+:cpp:func:`Mat::create` are always continuous. But if you extract a part of the matrix using
+:cpp:func:`Mat::col`,:cpp:func:`Mat::diag` , and so on, or constructed a matrix header for externally allocated data, such matrices may no longer have this property.
The continuity flag is stored as a bit in the ``Mat::flags`` field and is computed automatically when you construct a matrix header. Thus, the continuity check is a very fast operation, though it could be, in theory, done as following: ::
This trick, while being very simple, can boost performance of a simple element-operation by 10-20 percents, especially if the image is rather small and the operation is quite simple.
Also, note that there is another OpenCV idiom in this function: a call of
-:func:`Mat::create` for the destination array instead of checking that it already has the proper size and type. And while the newly allocated arrays are always continuous, we still check the destination array, because
-:func:`create` does not always allocate a new matrix.
+:cpp:func:`Mat::create` for the destination array instead of checking that it already has the proper size and type. And while the newly allocated arrays are always continuous, we still check the destination array, because
+:cpp:func:`create` does not always allocate a new matrix.
.. index:: Mat::elemSize
Mat::elemSize
-----------------
-.. cpp:function:: size_t Mat::elemSize(void) const
+.. cpp:function:: size_t Mat::elemSize() const
Returns the matrix element size in bytes.
Mat::elemSize1
------------------
-.. cpp:function:: size_t Mat::elemSize1(void) const
+.. cpp:function:: size_t Mat::elemSize1() const
Returns the size of each matrix element channel in bytes.
Mat::type
-------------
-.. cpp:function:: int Mat::type(void) const
+.. cpp:function:: int Mat::type() const
Returns a matrix element type.
Mat::depth
--------------
-.. cpp:function:: int Mat::depth(void) const
+.. cpp:function:: int Mat::depth() const
Returns the matrix element depth.
Mat::channels
-----------------
-.. cpp:function:: int Mat::channels(void) const
+.. cpp:function:: int Mat::channels() const
Returns the number of matrix channels.
Mat::step1
--------------
-.. cpp:function:: size_t Mat::step1(void) const
+.. cpp:function:: size_t Mat::step1() const
Returns a normalized step.
The method returns a matrix step divided by
-:func:`Mat::elemSize1()` . It can be useful to quickly access an arbitrary matrix element.
+:cpp:func:`Mat::elemSize1()` . It can be useful to quickly access an arbitrary matrix element.
.. index:: Mat::size
-.. _Mat::size:
-
Mat::size
-------------
-.. cpp:function:: Size Mat::size(void) const
+.. cpp:function:: Size Mat::size() const
Returns a matrix size.
Mat::empty
--------------
-.. cpp:function:: bool Mat::empty(void) const
+.. cpp:function:: bool Mat::empty() const
Returns ``true`` if the array has no elemens.
Mat::ptr
------------
-.. c:function:: uchar* Mat::ptr(int i=0)
+.. cpp:function:: uchar* Mat::ptr(int i=0)
-.. c:function:: const uchar* Mat::ptr(int i=0) const
+.. cpp:function:: const uchar* Mat::ptr(int i=0) const
-.. c:function:: template<typename _Tp> _Tp* Mat::ptr(int i=0)
+.. cpp:function:: template<typename _Tp> _Tp* Mat::ptr(int i=0)
-.. c:function:: template<typename _Tp> const _Tp* Mat::ptr(int i=0) const
+.. cpp:function:: template<typename _Tp> const _Tp* Mat::ptr(int i=0) const
Returns a pointer to the specified matrix row.
:param i: A 0-based row index.
The methods return ``uchar*`` or typed pointer to the specified matrix row. See the sample in
-:func:`Mat::isContinuous` () to know how to use these methods.
+:cpp:func:`Mat::isContinuous` () to know how to use these methods.
.. index:: Mat::at
Mat::at
-----------
-.. c:function:: template<typename T> T& Mat::at(int i) const
+.. cpp:function:: template<typename T> T& Mat::at(int i) const
-.. c:function:: template<typename T> const T& Mat::at(int i) const
+.. cpp:function:: template<typename T> const T& Mat::at(int i) const
-.. c:function:: template<typename T> T& Mat::at(int i, int j)
+.. cpp:function:: template<typename T> T& Mat::at(int i, int j)
-.. c:function:: template<typename T> const T& Mat::at(int i, int j) const
+.. cpp:function:: template<typename T> const T& Mat::at(int i, int j) const
-.. c:function:: template<typename T> T& Mat::at(Point pt)
+.. cpp:function:: template<typename T> T& Mat::at(Point pt)
-.. c:function:: template<typename T> const T& Mat::at(Point pt) const
+.. cpp:function:: template<typename T> const T& Mat::at(Point pt) const
-.. c:function:: template<typename T> T& Mat::at(int i, int j, int k)
+.. cpp:function:: template<typename T> T& Mat::at(int i, int j, int k)
-.. c:function:: template<typename T> const T& Mat::at(int i, int j, int k) const
+.. cpp:function:: template<typename T> const T& Mat::at(int i, int j, int k) const
-.. c:function:: template<typename T> T& Mat::at(const int* idx)
+.. cpp:function:: template<typename T> T& Mat::at(const int* idx)
-.. c:function:: template<typename T> const T& Mat::at(const int* idx) const
+.. cpp:function:: template<typename T> const T& Mat::at(const int* idx) const
Returns a reference to the specified array element.
Mat::begin
--------------
-.. c:function:: template<typename _Tp> MatIterator_<_Tp> Mat::begin() template<typename _Tp> MatConstIterator_<_Tp> Mat::begin() const
+.. cpp:function:: template<typename _Tp> MatIterator_<_Tp> Mat::begin() template<typename _Tp> MatConstIterator_<_Tp> Mat::begin() const
Returns the matrix iterator and sets it to the first matrix element..
Mat::end
------------
-.. c:function:: template<typename _Tp> MatIterator_<_Tp> Mat::end() template<typename _Tp> MatConstIterator_<_Tp> Mat::end() const
+.. cpp:function:: template<typename _Tp> MatIterator_<_Tp> Mat::end()
+.. cpp:function:: template<typename _Tp> MatConstIterator_<_Tp> Mat::end() const
Returns the matrix iterator and sets it to the after-last matrix element.
}
-.. _SparseMat:
+.. index:: SparseMat
SparseMat
---------
+.. cpp:class:: SparseMat
+
Sparse n-dimensional array. ::
class SparseMat
..
+.. index:: SparseMat\_
+
SparseMat\_
-----------
+.. cpp:class:: SparseMat
+
Template sparse n-dimensional array class derived from
:ref:`SparseMat` ::
kmeans
------
-.. c:function:: double kmeans( const Mat& samples, int clusterCount, Mat& labels, TermCriteria termcrit, int attempts, int flags, Mat* centers )
+.. cpp:function:: double kmeans( InputArray samples, int clusterCount, InputOutputArray labels, TermCriteria termcrit, int attempts, int flags, OutputArray centers=None() )
Finds centers of clusters and groups input samples around the clusters.
partition
-------------
-.. c:function:: template<typename _Tp, class _EqPredicate> int
+.. cpp:function:: template<typename _Tp, class _EqPredicate> int
-.. c:function:: partition( const vector<_Tp>& vec, vector<int>& labels, _EqPredicate predicate=_EqPredicate())
+.. cpp:function:: partition( const vector<_Tp>& vec, vector<int>& labels, _EqPredicate predicate=_EqPredicate())
Splits an element set into equivalency classes.
) for color
images and brightness for grayscale images. For color images, the channel ordering
is normally *Blue, Green, Red*.
-This is what :func:`imshow`, :func:`imread`, and :func:`imwrite` expect.
+This is what :cpp:func:`imshow`, :cpp:func:`imread`, and :cpp:func:`imwrite` expect.
So, if you form a color using the
:ref:`Scalar` constructor, it should look like:
\texttt{Scalar} (blue \_ component, green \_ component, red \_ component[, alpha \_ component])
If you are using your own image rendering and I/O functions, you can use any channel ordering. The drawing functions process each channel independently and do not depend on the channel order or even on the used color space. The whole image can be converted from BGR to RGB or to a different color space using
-:func:`cvtColor` .
+:cpp:func:`cvtColor` .
If a drawn figure is partially or completely outside the image, the drawing functions clip it. Also, many drawing functions can handle pixel coordinates specified with sub-pixel accuracy. This means that the coordinates can be passed as fixed-point numbers encoded as integers. The number of fractional bits is specified by the ``shift`` parameter and the real point coordinates are calculated as
:math:`\texttt{Point}(x,y)\rightarrow\texttt{Point2f}(x*2^{-shift},y*2^{-shift})` . This feature is especially effective when rendering antialiased shapes.
circle
----------
-.. c:function:: void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
+.. cpp:function:: void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Draws a circle.
:param thickness: Thickness of the circle outline if positive. Negative thickness means that a filled circle is to be drawn.
- :param lineType: Type of the circle boundary. See :func:`line` description.
+ :param lineType: Type of the circle boundary. See :cpp:func:`line` description.
:param shift: Number of fractional bits in the center's coordinates and in the radius value.
clipLine
------------
-.. c:function:: bool clipLine(Size imgSize, Point& pt1, Point& pt2)
+.. cpp:function:: bool clipLine(Size imgSize, Point& pt1, Point& pt2)
-.. c:function:: bool clipLine(Rect imgRect, Point& pt1, Point& pt2)
+.. cpp:function:: bool clipLine(Rect imgRect, Point& pt1, Point& pt2)
Clips the line against the image rectangle.
ellipse
-----------
-.. c:function:: void ellipse(Mat& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
+.. cpp:function:: void ellipse(Mat& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
-.. c:function:: void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, int thickness=1, int lineType=8)
+.. cpp:function:: void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, int thickness=1, int lineType=8)
Draws a simple or thick elliptic arc or fills an ellipse sector.
:param thickness: Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn.
- :param lineType: Type of the ellipse boundary. See :func:`line` description.
+ :param lineType: Type of the ellipse boundary. See :cpp:func:`line` description.
:param shift: Number of fractional bits in the center's coordinates and axes' values.
The functions ``ellipse`` with less parameters draw an ellipse outline, a filled ellipse, an elliptic arc, or a filled ellipse sector.
A piecewise-linear curve is used to approximate the elliptic arc boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
-:func:`ellipse2Poly` and then render it with
-:func:`polylines` or fill it with
-:func:`fillPoly` . If you use the first variant of the function and want to draw the whole ellipse, not an arc, pass ``startAngle=0`` and ``endAngle=360`` . The picture below explains the meaning of the parameters.
+:cpp:func:`ellipse2Poly` and then render it with
+:cpp:func:`polylines` or fill it with
+:cpp:func:`fillPoly` . If you use the first variant of the function and want to draw the whole ellipse, not an arc, pass ``startAngle=0`` and ``endAngle=360`` . The picture below explains the meaning of the parameters.
**Figure 1. Parameters of Elliptic Arc**
ellipse2Poly
----------------
-.. c:function:: void ellipse2Poly( Point center, Size axes, int angle, int startAngle, int endAngle, int delta, vector<Point>& pts )
+.. cpp:function:: void ellipse2Poly( Point center, Size axes, int angle, int startAngle, int endAngle, int delta, vector<Point>& pts )
Approximates an elliptic arc with a polyline.
:param center: Center of the arc.
- :param axes: Half-sizes of the arc. See :func:`ellipse` for details.
+ :param axes: Half-sizes of the arc. See :cpp:func:`ellipse` for details.
- :param angle: Rotation angle of the ellipse in degrees. See :func:`ellipse` for details.
+ :param angle: Rotation angle of the ellipse in degrees. See :cpp:func:`ellipse` for details.
:param startAngle: Starting angle of the elliptic arc in degrees.
:param pts: Output vector of polyline vertices.
The function ``ellipse2Poly`` computes the vertices of a polyline that approximates the specified elliptic arc. It is used by
-:func:`ellipse` .
+:cpp:func:`ellipse` .
.. index:: fillConvexPoly
fillConvexPoly
------------------
-.. c:function:: void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0)
+.. cpp:function:: void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0)
Fills a convex polygon.
:param color: Polygon color.
- :param lineType: Type of the polygon boundaries. See :func:`line` description.
+ :param lineType: Type of the polygon boundaries. See :cpp:func:`line` description.
:param shift: Number of fractional bits in the vertex coordinates.
fillPoly
------------
-.. c:function:: void fillPoly(Mat& img, const Point** pts, const int* npts, int ncontours, const Scalar& color, int lineType=8, int shift=0, Point offset=Point() )
+.. cpp:function:: void fillPoly(Mat& img, const Point** pts, const int* npts, int ncontours, const Scalar& color, int lineType=8, int shift=0, Point offset=Point() )
Fills the area bounded by one or more polygons.
:param color: Polygon color.
- :param lineType: Type of the polygon boundaries. See :func:`line` description.
+ :param lineType: Type of the polygon boundaries. See :cpp:func:`line` description.
:param shift: Number of fractional bits in the vertex coordinates.
getTextSize
---------------
-.. c:function:: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine)
+.. cpp:function:: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine)
Calculates the width and height of a text string.
:param text: Input text string.
- :param fontFace: Font to use. See :func:`putText` for details.
+ :param fontFace: Font to use. See :cpp:func:`putText` for details.
- :param fontScale: Font scale. See :func:`putText` for details.
+ :param fontScale: Font scale. See :cpp:func:`putText` for details.
- :param thickness: Thickness of lines used to render the text. See :func:`putText` for details.
+ :param thickness: Thickness of lines used to render the text. See :cpp:func:`putText` for details.
:param baseLine: Output parameter - y-coordinate of the baseline relative to the bottom-most text point.
line
--------
-.. c:function:: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
+.. cpp:function:: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Draws a line segment connecting two points.
rectangle
-------------
-.. c:function:: void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
+.. cpp:function:: void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
+
+.. cpp:function:: void rectangle(Mat& img, Rect r, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Draws a simple, thick, or filled up-right rectangle.
:param pt1: One of the rectangle's vertices.
:param pt2: Opposite to ``pt1`` rectangle vertex.
+
+ :param r: Alternative specification of the drawn rectangle
:param color: Rectangle color or brightness (grayscale image).
:param thickness: Thickness of lines that make up the rectangle. Negative values, like ``CV_FILLED`` , mean that the function has to draw a filled rectangle.
- :param lineType: Type of the line. See :func:`line` description.
+ :param lineType: Type of the line. See :cpp:func:`line` description.
:param shift: Number of fractional bits in the point coordinates.
-The function ``rectangle`` draws a rectangle outline or a filled rectangle whose two opposite corners are ``pt1`` and ``pt2`` .
+The function ``rectangle`` draws a rectangle outline or a filled rectangle whose two opposite corners are ``pt1`` and ``pt2``, or ``r.tl()`` and ``r.br()-Point(1,1)``.
.. index:: polylines
polylines
-------------
-.. c:function:: void polylines(Mat& img, const Point** pts, const int* npts, int ncontours, bool isClosed, const Scalar& color, int thickness=1, int lineType=8, int shift=0 )
+.. cpp:function:: void polylines(Mat& img, const Point** pts, const int* npts, int ncontours, bool isClosed, const Scalar& color, int thickness=1, int lineType=8, int shift=0 )
Draws several polygonal curves.
:param thickness: Thickness of the polyline edges.
- :param lineType: Type of the line segments. See :func:`line` description.
+ :param lineType: Type of the line segments. See :cpp:func:`line` description.
:param shift: Number of fractional bits in the vertex coordinates.
putText
-----------
-.. c:function:: void putText( Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
+.. cpp:function:: void putText( Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
Draws a text string.
The function ``putText`` renders the specified text string in the image.
Symbols that cannot be rendered using the specified font are
replaced by question marks. See
-:func:`getTextSize` for a text rendering code example.
+:cpp:func:`getTextSize` for a text rendering code example.
OpenCV has a modular structure, which means that the package includes several shared or static libraries. The following modules are available:
* **core** - a compact module defining basic data structures, including the dense multi-dimensional array ``Mat`` and basic functions used by all other modules.
- * **imgproc** - an image processing module that includes linear and non-linear image filtering, geometrical image transformations (resize, affine and perspective wraping, generic table-based remapping), color space conversion, histograms, and so on.
+ * **imgproc** - an image processing module that includes linear and non-linear image filtering, geometrical image transformations (resize, affine and perspective warping, generic table-based remapping), color space conversion, histograms, and so on.
* **video** - a video analysis module that includes motion estimation, background subtraction, and object tracking algorithms.
* **calib3d** - basic multiple-view geometry algorithms, single and stereo camera calibration, object pose estimation, stereo correspondence algorithms, and elements of 3D reconstruction.
* **features2d** - salient feature detectors, descriptors, and descriptor matchers.
* **objdetect** - detection of objects and instances of the predefined classes (for example, faces, eyes, mugs, people, cars, and so on).
- * **highgui** - an easy-to-use interface to video capturing, image and video codecs APIs, as well as simple UI capabilities.
+ * **highgui** - an easy-to-use interface to video capturing, image and video codecs, as well as simple UI capabilities.
* **gpu** - GPU-accelerated algorithms from different OpenCV modules.
* ... some other helper modules, such as FLANN and Google test wrappers, Python bindings, and others.
OpenCV handles all the memory automatically.
-First of all, ``std::vector``, ``Mat``, and other data structures used by the functions and methods have destructors that deallocate the underlying memory buffers when needed. This means that the destructors do not always deallocate the buffers as in case of ``Mat``. They take into account possible data sharing. A destructor decrements the reference counter associated with the matrix data buffer. The buffer is deallocated if and only if the reference counter reaches zero, that is, when no other structures refer to the same buffer. Similarly, when a ``Mat`` instance is copied, no actual data is really copied. Instead, the counter associated with its reference is incremented to memorize that there is another owner of the same data. There is also the ``Mat::clone`` method that creates a full copy of the matrix data. See the example below: ::
+First of all, ``std::vector``, ``Mat``, and other data structures used by the functions and methods have destructors that deallocate the underlying memory buffers when needed. This means that the destructors do not always deallocate the buffers as in case of ``Mat``. They take into account possible data sharing. A destructor decrements the reference counter associated with the matrix data buffer. The buffer is deallocated if and only if the reference counter reaches zero, that is, when no other structures refer to the same buffer. Similarly, when a ``Mat`` instance is copied, no actual data is really copied. Instead, the reference counter is incremented to memorize that there is another owner of the same data. There is also the ``Mat::clone`` method that creates a full copy of the matrix data. See the example below: ::
// create a big 8Mb matrix
Mat A(1000, 1000, CV_64F);
Automatic Allocation of the Output Data
---------------------------------------
-OpenCV deallocates the memory automatically, as well as automatically allocates the memory for output function parameters most of the time. So, if a function has one or more input arrays (``cv::Mat`` instances) and some output arrays, the output arrays are automatically allocated or reallocated. The size and type of the output arrays are determined from the size and type of input arrays. If needed, the functions take extra parameters that help to figure out the output array properties.
+OpenCV deallocates the memory automatically, as well as automatically allocates the memory for output function parameters most of the time. So, if a function has one or more input arrays (``cv::Mat`` instances) and some output arrays, the output arrays are automatically allocated or reallocated. The size and type of the output arrays are determined from the size and type of input arrays. If needed, the functions take extra parameters that help to figure out the output array properties.
Example: ::
Fixed Pixel Types. Limited Use of Templates
-------------------------------------------
-Templates is a great feature of C++ that enables implementation of very powerful, efficient and yet safe data structures and algorithms. However, the extensive use of templates may dramatically increase compilation time and code size. Besides, it is difficult to separate an interface and implementation when templates are used exclusively. This could be fine for basic algorithms but not good for computer vision libraries where a single algorithm may span a thousand lines of code. Because of this and also to simplify development of bindings for other languages, like Python*, Java*, Matlab* that do not have templates at all or have limited template capabilities, the current OpenCV implementation is based on polymorphism and runtime dispatching over templates. In those places where runtime dispatching would be too slow (like pixel access operators), impossible (generic ``Ptr<>`` implementation), or just very inconvenient (``saturate_cast<>()``) the current implementation introduces small template classes, methods, and functions. Anywhere else in this implementation templates are not used.
+Templates is a great feature of C++ that enables implementation of very powerful, efficient and yet safe data structures and algorithms. However, the extensive use of templates may dramatically increase compilation time and code size. Besides, it is difficult to separate an interface and implementation when templates are used exclusively. This could be fine for basic algorithms but not good for computer vision libraries where a single algorithm may span thousands lines of code. Because of this and also to simplify development of bindings for other languages, like Python, Java, Matlab that do not have templates at all or have limited template capabilities, the current OpenCV implementation is based on polymorphism and runtime dispatching over templates. In those places where runtime dispatching would be too slow (like pixel access operators), impossible (generic ``Ptr<>`` implementation), or just very inconvenient (``saturate_cast<>()``) the current implementation introduces small template classes, methods, and functions. Anywhere else in the current OpenCV version the use of templates is limited.
-There is a limited fixed set of primitive data types the library can operate on. That is, array elements should have one of the following types:
+Consequently, there is a limited fixed set of primitive data types the library can operate on. That is, array elements should have one of the following types:
* 8-bit unsigned integer (uchar)
* 8-bit signed integer (schar)
* 32-bit signed integer (int)
* 32-bit floating-point number (float)
* 64-bit floating-point number (double)
- * a tuple of several elements where all elements have the same type (one of the above). An array whose elements are such tuples, are called multi-channel arrays, as opposite to the single-channel arrays, whose elements are scalar values. The maximum possible number of channels is defined by the ``CV_CN_MAX`` constant, which is not smaller than 32.
+ * a tuple of several elements where all elements have the same type (one of the above). An array whose elements are such tuples, are called multi-channel arrays, as opposite to the single-channel arrays, whose elements are scalar values. The maximum possible number of channels is defined by the ``CV_CN_MAX`` constant, which is currently set to 512.
For these basic types, the following enumeration is applied::
* The face detection algorithm only works with 8-bit grayscale or color images.
* Linear algebra functions and most of the machine learning algorithms work with floating-point arrays only.
- * Basic functions, such as ``cv::add``, support all types, except for ``CV_8SC(n)``.
+ * Basic functions, such as ``cv::add``, support all types.
* Color space conversion functions support 8-bit unsigned, 16-bit unsigned, and 32-bit floating-point types.
-The subset of supported types for each functions has been defined from practical needs. All this information about supported types can be put together into a special table. In different implementations of the standard, the tables may look differently. For example, on embedded platforms the double-precision floating-point type (``CV_64F``) may be unavailable.
+The subset of supported types for each function has been defined from practical needs and could be extended in future based on user requests.
+InputArray and OutputArray
+--------------------------
+
+Many OpenCV functions process dense 2-dimensional or multi-dimensional numerical arrays. Usually, such functions take cpp:class:`Mat` as parameters, but in some cases it's more convenient to use ``std::vector<>`` (for a point set, for example) or ``Matx<>`` (for 3x3 homography matrix and such). To avoid many duplicates in the API, special "proxy" classes have been introduced. The base "proxy" class is ``InputArray``. It is used for passing read-only arrays on a function input. The derived from ``InputArray`` class ``OutputArray`` is used to specify an output array for a function. Normally, you should not care of those intermediate types (and you should not declare variables of those types explicitly) - it will all just work automatically. You can assume that instead of ``InputArray``/``OutputArray`` you can always use ``Mat``, ``std::vector<>``, ``Matx<>``, ``Vec<>`` or ``Scalar``. When a function has an optional input or output array, and you do not have or do not want one, pass ``cv::None()``.
+
Error Handling
--------------
.. index:: abs
-.. _abs:
-
abs
--------
-.. c:function:: MatExpr<...> abs(const Mat& src)
-
-.. c:function:: MatExpr<...> abs(const MatExpr<...>& src)
+---
+.. cpp:function:: MatExpr abs(const Mat& src)
+.. cpp:function:: MatExpr abs(const MatExpr& src)
Computes an absolute value of each matrix element.
:param src: Matrix or matrix expression.
-``abs`` is a meta-function that is expanded to one of :func:`absdiff` forms:
+``abs`` is a meta-function that is expanded to one of :cpp:func:`absdiff` forms:
* ``C = abs(A-B)`` is equivalent to ``absdiff(A, B, C)``
The output matrix has the same size and the same type as the input one (except for the last case, where ``C`` will be ``depth=CV_8U`` ).
See Also: :ref:`MatrixExpressions`,
-:func:`absdiff`
+:cpp:func:`absdiff`
.. index:: absdiff
-.. _absdiff:
-
absdiff
-----------
-.. c:function:: void absdiff(const Mat& src1, const Mat& src2, Mat& dst)
-.. c:function:: void absdiff(const Mat& src1, const Scalar& sc, Mat& dst)
+.. cpp:function:: void absdiff(InputArray src1, InputArray src2, OutputArray dst)
Computes the per-element absolute difference between 2 arrays or between an array and a scalar.
- :param src1: The first input array.
- :param src2: The second input array of the same size and type as ``src1`` .
-
- :param sc: A scalar. This is the second input parameter.
+ :param src1: The first input array or a scalar.
+ :param src2: The second input array or a scalar.
+ :param dst: The destination array. It will have the same size and type as ``src1`` (or ``src2``).
- :param dst: The destination array of the same size and type as ``src1`` . See ``Mat::create`` .
-
-The functions ``absdiff`` compute:
+The function ``absdiff`` computes:
- * absolute difference between two arrays:
+ #. absolute difference between two arrays when they have the same size and type:
.. math::
- \texttt{dst} (I) = \texttt{saturate} (| \texttt{src1} (I) - \texttt{src2} (I)|)
+ \texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)
- * absolute difference between an array and a scalar:
+ #. absolute difference between an array and a scalar, when the second array is constructed from ``Scalar`` or has as many elements as the number of channels in ``src1``:
.. math::
- \texttt{dst} (I) = \texttt{saturate} (| \texttt{src1} (I) - \texttt{sc} |)
+ \texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2} |)
+
+ #. or absolute difference between a scalar and an array, when the first array is constructed from ``Scalar`` or has as many elements as the number of channels in ``src2``:
+
+ .. math::
+ \texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I) |)
+
where ``I`` is a multi-dimensional index of array elements.
In case of multi-channel arrays, each channel is processed independently.
-See Also: :func:`abs`
+See Also: :cpp:func:`abs`
.. index:: add
-.. _add:
-
add
-------
-.. c:function:: void add(const Mat& src1, const Mat& src2, Mat& dst)
-
-.. c:function:: void add(const Mat& src1, const Mat& src2, Mat& dst, const Mat& mask)
-
-.. c:function:: void add(const Mat& src1, const Scalar& sc, Mat& dst, const Mat& mask=Mat())
+.. cpp:function:: void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=None(), int dtype=-1)
Computes the per-element sum of two arrays or an array and a scalar.
- :param src1: The first source array.
+ :param src1: The first source array or a scalar.
- :param src2: The second source array of the same size and type as ``src1`` .
+ :param src2: The second source array or a scalar.
- :param sc: Scalar. This is the second input parameter.
-
- :param dst: Destination array of the same size and type as ``src1`` . See ``Mat::create`` .
+ :param dst: Destination array. It will have the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``src1``/``src2``.
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
+
+ :param dtype: Optional depth of the output array. See the discussion below.
-The functions ``add`` compute:
+The function ``add`` computes:
-*
- the sum of two arrays:
+ #.
+ the sum of two arrays, when both input arrays have the same size and the same number of channels:
.. math::
- \texttt{dst} (I) = \texttt{saturate} ( \texttt{src1} (I) + \texttt{src2} (I)) \quad \texttt{if mask} (I) \ne0
+ \texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0
-*
- the sum of an array and a scalar:
+ #.
+ the sum of an array and a scalar, when ``src2`` is constructed from ``Scalar`` or has the same number of elements as ``src1.channels()``:
+
+ .. math::
+
+ \texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0
+
+ #.
+ or the sum of a scalar and an array, when ``src1`` is constructed from ``Scalar`` or has the same number of elements as ``src2.channels()``:
.. math::
- \texttt{dst} (I) = \texttt{saturate} ( \texttt{src1} (I) + \texttt{sc} ) \quad \texttt{if mask} (I) \ne0
+ \texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0
-where ``I`` is a multi-dimensional index of array elements.
+where ``I`` is a multi-dimensional index of array elements. In case of multi-channel arrays, each channel is processed independently.
The first function in the list above can be replaced with matrix expressions: ::
dst = src1 + src2;
dst += src1; // equivalent to add(dst, src1, dst);
-
-In case of multi-channel arrays, each channel is processed independently.
+The input arrays and the destination array can all have the same or different depths. For example, you can add 16-bit unsigned array to 8-bit signed array and store the sum as 32-bit floating-point array. Depth of the output array is determined by ``dtype`` parameter. In the 2nd and 3rd cases above, as well as in the first case, when ``src1.depth() == src2.depth()``, ``dtype`` can be set to the default ``-1``. In this case the output array will have the same depth as the input array, be it ``src1``, ``src2`` or both.
See Also:
-:func:`subtract`,
-:func:`addWeighted`,
-:func:`scaleAdd`,
-:func:`convertScale`,
+:cpp:func:`subtract`,
+:cpp:func:`addWeighted`,
+:cpp:func:`scaleAdd`,
+:cpp:func:`convertScale`,
:ref:`MatrixExpressions`
.. index:: addWeighted
-.. _addWeighted:
-
addWeighted
---------------
-.. c:function:: void addWeighted(const Mat& src1, double alpha, const Mat& src2, double beta, double gamma, Mat& dst)
+.. cpp:function:: void addWeighted(InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, int dtype=-1)
Computes the weighted sum of two arrays.
:param alpha: Weight for the first array elements.
- :param src2: The second source array of the same size and type as ``src1`` .
+ :param src2: The second source array of the same size and channel number as ``src1`` .
:param beta: Weight for the second array elements.
- :param dst: Destination array of the same size and type as ``src1`` .
+ :param dst: Destination array. It will have the same size and number of channels as the input arrays.
:param gamma: Scalar added to each sum.
+
+ :param dtype: Optional depth of the destination array. When both input arrays have the same depth, ``dtype`` can be set to ``-1``, which will be equivalent to ``src1.depth()``.
The functions ``addWeighted`` calculate the weighted sum of two arrays as follows:
\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )
-where ``I`` is a multi-dimensional index of array elements.
+where ``I`` is a multi-dimensional index of array elements. In case of multi-channel arrays, each channel is processed independently.
-The first function can be replaced with a matrix expression: ::
+The function can be replaced with a matrix expression: ::
dst = src1*alpha + src2*beta + gamma;
-In case of multi-channel arrays, each channel is processed independently.
-
See Also:
-:func:`add`,
-:func:`subtract`,
-:func:`scaleAdd`,
-:func:`convertScale`,
+:cpp:func:`add`,
+:cpp:func:`subtract`,
+:cpp:func:`scaleAdd`,
+:cpp:func:`convertScale`,
:ref:`MatrixExpressions`
.. index:: bitwise_and
-.. _bitwise_and_:
-
bitwise_and
-----------
-.. c:function:: void bitwise_and(const Mat& src1, const Mat& src2, Mat& dst, const Mat& mask=Mat())
-
-.. c:function:: void bitwise_and(const Mat& src1, const Scalar& sc, Mat& dst, const Mat& mask=Mat())
+.. cpp:function:: void bitwise_and(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=None())
Calculates the per-element bit-wise conjunction of two arrays or an array and a scalar.
- :param src1: The first source array.
+ :param src1: The first source array or a scalar.
- :param src2: The second source array of the same size and type as ``src1`` .
-
- :param sc: Scalar. This is the second input parameter.
+ :param src2: The second source array or a scalar.
- :param dst: Destination array of the same size and type as ``src1`` . See ``Mat::create`` .
+ :param dst: Destination array. It will have the same size and type as the input array(s).
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
-The functions ``bitwise_and`` compute the per-element bit-wise logical conjunction:
+The function computes the per-element bit-wise logical conjunction:
-*
- of two arrays
+ #.
+ of two arrays, when ``src1`` and ``src2`` have the same size:
.. math::
\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
-*
- an array and a scalar:
+ #.
+ an array and a scalar, when ``src2`` is constructed from ``Scalar`` or has the same number of elements as ``src1.channels()``:
.. math::
- \texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{sc} \quad \texttt{if mask} (I) \ne0
+ \texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0
-In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently.
+ #.
+ or a scalar and an array, when ``src1`` is constructed from ``Scalar`` or has the same number of elements as ``src2.channels()``:
+
+ .. math::
+
+ \texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
-.. index:: bitwise_not
-.. _bitwise_not_:
+In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the 2nd and 3rd cases above, the scalar is first converted to the array type.
+
+.. index:: bitwise_not
bitwise_not
-----------
-.. c:function:: void bitwise_not(const Mat& src, Mat& dst)
+.. cpp:function:: void bitwise_not(InputArray src, OutputArray dst, InputArray mask=None())
Inverts every bit of an array.
- :param src1: Source array.
+ :param src: Source array.
- :param dst: Destination array. It is reallocated to be of the same size and type as ``src`` . See ``Mat::create`` .
+ :param dst: Destination array. It will have the same size and type as the input array.
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
-The functions ``bitwise_not`` compute per-element bit-wise inversion of the source array:
+The function computes per-element bit-wise inversion of the source array:
.. math::
.. index:: bitwise_or
-.. _bitwise_or_:
-
bitwise_or
----------
-.. c:function:: void bitwise_or(const Mat& src1, const Mat& src2, Mat& dst, const Mat& mask=Mat())
-
-.. c:function:: void bitwise_or(const Mat& src1, const Scalar& sc, Mat& dst, const Mat& mask=Mat())
+.. cpp:function:: void bitwise_or(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=None())
Calculates the per-element bit-wise disjunction of two arrays or an array and a scalar.
- :param src1: The first source array.
+ :param src1: The first source array or a scalar.
- :param src2: The second source array of the same size and type as ``src1`` .
-
- :param sc: Scalar. This is the second input parameter.
+ :param src2: The second source array or a scalar.
+
+ :param dst: Destination array. It will have the same size and type as the input array(s).
- :param dst: Destination array. It is reallocated to be of the same size and type as ``src1`` . See ``Mat::create`` .
-
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
-The functions ``bitwise_or`` compute the per-element bit-wise logical disjunction:
+The function computes the per-element bit-wise logical disjunction:
-*
- of two arrays
+ #.
+ of two arrays, when ``src1`` and ``src2`` have the same size:
- .. math::
+ .. math::
- \texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
+ \texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
-*
- an array and a scalar:
+ #.
+ an array and a scalar, when ``src2`` is constructed from ``Scalar`` or has the same number of elements as ``src1.channels()``:
- .. math::
+ .. math::
- \texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{sc} \quad \texttt{if mask} (I) \ne0
+ \texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0
-In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently.
+ #.
+ or a scalar and an array, when ``src1`` is constructed from ``Scalar`` or has the same number of elements as ``src2.channels()``:
-.. index:: bitwise_xor
+ .. math::
-.. _bitwise_xor_:
+ \texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
+
+
+ In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the 2nd and 3rd cases above, the scalar is first converted to the array type.
+
+
+.. index:: bitwise_xor
bitwise_xor
-----------
-.. c:function:: void bitwise_xor(const Mat& src1, const Mat& src2, Mat& dst, const Mat& mask=Mat())
-
-.. c:function:: void bitwise_xor(const Mat& src1, const Scalar& sc, Mat& dst, const Mat& mask=Mat())
+.. cpp:function:: void bitwise_xor(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=None())
Calculates the per-element bit-wise "exclusive or" operation on two arrays or an array and a scalar.
- :param src1: The first source array.
+ :param src1: The first source array or a scalar.
- :param src2: The second source array of the same size and type as ``src1`` .
-
- :param sc: Scalar. This is the second input parameter.
+ :param src2: The second source array or a scalar.
+
+ :param dst: Destination array. It will have the same size and type as the input array(s).
- :param dst: Destination array. It is reallocated to be of the same size and type as ``src1`` . See ``Mat::create`` .
-
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
-The functions ``bitwise_xor`` compute the per-element bit-wise logical "exclusive or" operation:
+The function computes the per-element bit-wise logical "exclusive-or" operation:
- * on two arrays
+ #.
+ on two arrays, when ``src1`` and ``src2`` have the same size:
- .. math::
+ .. math::
- \texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
+ \texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
- * an array and a scalar:
+ #.
+ an array and a scalar, when ``src2`` is constructed from ``Scalar`` or has the same number of elements as ``src1.channels()``:
- .. math::
+ .. math::
- \texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{sc} \quad \texttt{if mask} (I) \ne0
+ \texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0
-In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently.
+ #.
+ or a scalar and an array, when ``src1`` is constructed from ``Scalar`` or has the same number of elements as ``src2.channels()``:
-.. index:: calcCovarMatrix
+ .. math::
+
+ \texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0
+
+
+ In case of floating-point arrays, their machine-specific bit representations (usually IEEE754-compliant) are used for the operation. In case of multi-channel arrays, each channel is processed independently. In the 2nd and 3rd cases above, the scalar is first converted to the array type.
+
-.. _calcCovarMatrix:
+.. index:: calcCovarMatrix
calcCovarMatrix
---------------
-.. c:function:: void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, int ctype=CV_64F)
+.. cpp:function:: void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, int flags, int ctype=CV_64F)
-.. c:function:: void calcCovarMatrix( const Mat& samples, Mat& covar, Mat& mean, int flags, int ctype=CV_64F)
+.. cpp:function:: void calcCovarMatrix( InputArray samples, OutputArray covar, OutputArray mean, int flags, int ctype=CV_64F)
Calculates the covariance matrix of a set of vectors.
:param nsamples: The number of samples when they are stored separately.
- :param covar: The output covariance matrix of the type= ``ctype`` and square size.
+ :param covar: The output covariance matrix of the type ``ctype`` and square size.
- :param mean: The input or output (depending on the flags) array - the mean (average) vector of the input vectors.
+ :param mean: The input or output (depending on the flags) array - the average of the input vectors.
:param flags: Operation flags, a combination of the following values:
The functions ``calcCovarMatrix`` calculate the covariance matrix and, optionally, the mean vector of the set of input vectors.
See Also:
-:func:`PCA`,
-:func:`mulTransposed`,
-:func:`Mahalanobis`
+:cpp:func:`PCA`,
+:cpp:func:`mulTransposed`,
+:cpp:func:`Mahalanobis`
.. index:: cartToPolar
-.. _cartToPolar:
-
cartToPolar
-----------
-.. c:function:: void cartToPolar(const Mat& x, const Mat& y, Mat& magnitude, Mat& angle, bool angleInDegrees=false)
+.. cpp:function:: void cartToPolar(InputArray x, InputArray y, OutputArray magnitude, OutputArray angle, bool angleInDegrees=false)
Calculates the magnitude and angle of 2D vectors.
.. index:: checkRange
-.. _checkRange:
-
checkRange
----------
-.. c:function:: bool checkRange(const Mat& src, bool quiet=true, Point* pos=0, double minVal=-DBL_MAX, double maxVal=DBL_MAX)
+.. cpp:function:: bool checkRange(InputArray src, bool quiet=true, Point* pos=0, double minVal=-DBL_MAX, double maxVal=DBL_MAX)
Checks every element of an input array for invalid values.
.. index:: compare
-.. _compare:
-
compare
-------
-.. c:function:: void compare(const Mat& src1, const Mat& src2, Mat& dst, int cmpop)
-
-.. c:function:: void compare(const Mat& src1, double value, Mat& dst, int cmpop)
+.. cpp:function:: void compare(InputArray src1, InputArray src2, OutputArray dst, int cmpop)
Performs the per-element comparison of two arrays or an array and scalar value.
- :param src1: The first source array.
+ :param src1: The first source array or a scalar.
- :param src2: The second source array of the same size and type as ``src1`` .
+ :param src2: The second source array or a scalar.
- :param value: Scalar value to compare each array element with.
-
- :param dst: Destination array of the same size as ``src1`` and type= ``CV_8UC1`` .
+ :param dst: Destination array. It will have the same size as the input array(s) and type= ``CV_8UC1`` .
:param cmpop: Flag specifying the relation between the elements to be checked.
- * **CMP_EQ** :math:`\texttt{src1}(I) = \texttt{src2}(I)` or :math:`\texttt{src1}(I) = \texttt{value}`
- * **CMP_GT** :math:`\texttt{src1}(I) > \texttt{src2}(I)` or :math:`\texttt{src1}(I) > \texttt{value}`
- * **CMP_GE** :math:`\texttt{src1}(I) \geq \texttt{src2}(I)` or :math:`\texttt{src1}(I) \geq \texttt{value}`
- * **CMP_LT** :math:`\texttt{src1}(I) < \texttt{src2}(I)` or :math:`\texttt{src1}(I) < \texttt{value}`
- * **CMP_LE** :math:`\texttt{src1}(I) \leq \texttt{src2}(I)` or :math:`\texttt{src1}(I) \leq \texttt{value}`
- * **CMP_NE** :math:`\texttt{src1}(I) \ne \texttt{src2}(I)` or :math:`\texttt{src1}(I) \ne \texttt{value}`
+ * **CMP_EQ** ``src1`` equal to ``src2``.
+ * **CMP_GT** ``src1`` greater than ``src2``.
+ * **CMP_GE** ``src1`` greater than or equal to ``src2``.
+ * **CMP_LT** ``src1`` less than ``src2``.
+ * **CMP_LE** ``src1`` less than or equal to ``src2``.
+ * **CMP_NE** ``src1`` not equal to ``src2``.
-The functions ``compare`` compare each element of ``src1`` with the corresponding element of ``src2`` or with the real scalar ``value`` . When the comparison result is true, the corresponding element of destination array is set to 255. Otherwise, it is set to 0:
+The function compares:
- * ``dst(I) = src1(I) cmpop src2(I) ? 255 : 0``
- * ``dst(I) = src1(I) cmpop value ? 255 : 0``
-
+
+ #.
+ elements of two arrays, when ``src1`` and ``src2`` have the same size:
+
+ .. math::
+
+ \texttt{dst} (I) = \texttt{src1} (I) \,cmpop\, \texttt{src2} (I)
+
+ #.
+ elements of ``src1`` with a scalar ``src2`, when ``src2`` is constructed from ``Scalar`` or has a single element:
+
+ .. math::
+
+ \texttt{dst} (I) = \texttt{src1}(I) \,cmpop\, \texttt{src2}
+
+ #.
+ or ``src1`` with elements of ``src2``, when ``src1`` is constructed from ``Scalar`` or has a single element:
+
+ .. math::
+
+ \texttt{dst} (I) = \texttt{src1} \,cmpop\, \texttt{src2} (I)
+
+
+When the comparison result is true, the corresponding element of destination array is set to 255.
The comparison operations can be replaced with the equivalent matrix expressions: ::
Mat dst1 = src1 >= src2;
See Also:
-:func:`checkRange`,
-:func:`min`,
-:func:`max`,
-:func:`threshold`,
+:cpp:func:`checkRange`,
+:cpp:func:`min`,
+:cpp:func:`max`,
+:cpp:func:`threshold`,
:ref:`MatrixExpressions`
.. index:: completeSymm
-.. _completeSymm:
-
completeSymm
------------
-.. c:function:: void completeSymm(Mat& mtx, bool lowerToUpper=false)
+.. cpp:function:: void completeSymm(InputOutputArray mtx, bool lowerToUpper=false)
Copies the lower or the upper half of a square matrix to another half.
:param mtx: Input-output floating-point square matrix.
- :param lowerToUpper: If true, the lower half is copied to the upper half. Otherwise, the upper half is copied to the lower half.
+ :param lowerToUpper: The operation flag. If it is true, the lower half is copied to the upper half. Otherwise, the upper half is copied to the lower half.
The function ``completeSymm`` copies the lower half of a square matrix to its another half. The matrix diagonal remains unchanged:
-*
+ *
:math:`\texttt{mtx}_{ij}=\texttt{mtx}_{ji}` for
:math:`i > j` if ``lowerToUpper=false``
-*
+ *
:math:`\texttt{mtx}_{ij}=\texttt{mtx}_{ji}` for
:math:`i < j` if ``lowerToUpper=true``
-See Also: :func:`flip`,
-:func:`transpose`
+See Also: :cpp:func:`flip`,
+:cpp:func:`transpose`
.. index:: convertScaleAbs
-.. _convertScaleAbs:
-
convertScaleAbs
---------------
-.. c:function:: void convertScaleAbs(const Mat& src, Mat& dst, double alpha=1, double beta=0)
+.. cpp:function:: void convertScaleAbs(InputArray src, OutputArray dst, double alpha=1, double beta=0)
Scales, computes absolute values, and converts the result to 8-bit.
On each element of the input array, the function ``convertScaleAbs`` performs three operations sequentially: scaling, taking an absolute value, conversion to an unsigned 8-bit type:
+
.. math::
\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)
See Also:
-:func:`Mat::convertTo`,
-:func:`abs`
+:cpp:func:`Mat::convertTo`,
+:cpp:func:`abs`
.. index:: countNonZero
-.. _countNonZero:
-
countNonZero
------------
-.. c:function:: int countNonZero( const Mat& mtx )
+.. cpp:function:: int countNonZero( InputArray mtx )
Counts non-zero array elements.
:param mtx: Single-channel array.
-The function ``cvCountNonZero`` returns the number of non-zero elements in ``mtx`` :
+The function returns the number of non-zero elements in ``mtx`` :
.. math::
\sum _{I: \; \texttt{mtx} (I) \ne0 } 1
See Also:
-:func:`mean`,
-:func:`meanStdDev`,
-:func:`norm`,
-:func:`minMaxLoc`,
-:func:`calcCovarMatrix`
+:cpp:func:`mean`,
+:cpp:func:`meanStdDev`,
+:cpp:func:`norm`,
+:cpp:func:`minMaxLoc`,
+:cpp:func:`calcCovarMatrix`
.. index:: cubeRoot
-.. _cubeRoot:
-
cubeRoot
--------
-.. c:function:: float cubeRoot(float val)
+.. cpp:function:: float cubeRoot(float val)
Computes the cube root of an argument.
.. index:: cvarrToMat
-.. _cvarrToMat:
-
cvarrToMat
----------
-.. c:function:: Mat cvarrToMat(const CvArr* src, bool copyData=false, bool allowND=true, int coiMode=0)
+.. cpp:function:: Mat cvarrToMat(const CvArr* src, bool copyData=false, bool allowND=true, int coiMode=0)
Converts ``CvMat``, ``IplImage`` , or ``CvMatND`` to ``Mat``.
:param copyData: When it is false (default value), no data is copied and only the new header is created. In this case, the original array should not be deallocated while the new matrix header is used. If the parameter is true, all the data is copied and you may deallocate the original array right after the conversion.
- :param allowND: When it is true (default value), ``CvMatND`` is converted to ``Mat`` , if it is possible (for example, when the data is contiguous). If it is not possible, or when the parameter is false, the function will report an error.
+ :param allowND: When it is true (default value), ``CvMatND`` is converted to 2-dimensional ``Mat``, if it is possible (see the discussion below). If it is not possible, or when the parameter is false, the function will report an error.
:param coiMode: The parameter specifies how the IplImage COI (when set) is handled.
* If ``coiMode=0`` , the function reports an error if COI is set.
- * If ``coiMode=1`` , the function never reports an error. Instead, it returns the header to the whole original image and you will have to check and process COI manually. See :func:`extractImageCOI` .
+ * If ``coiMode=1`` , the function never reports an error. Instead, it returns the header to the whole original image and you will have to check and process COI manually. See :cpp:func:`extractImageCOI` .
The function ``cvarrToMat`` converts ``CvMat``, ``IplImage`` , or ``CvMatND`` header to
-:func:`Mat` header, and optionally duplicates the underlying data. The constructed header is returned by the function.
+:cpp:func:`Mat` header, and optionally duplicates the underlying data. The constructed header is returned by the function.
-When ``copyData=false`` , the conversion is done really fast (in O(1) time) and the newly created matrix header will have ``refcount=0`` , which means that no reference counting is done for the matrix data. In this case, you have to preserve the data until the new header is destructed. Otherwise, when ``copyData=true`` , the new buffer is allocated and managed as if you created a new matrix from scratch and copied the data there. That is, ``cvarrToMat(src, true) :math:`\sim` cvarrToMat(src, false).clone()`` (assuming that COI is not set). The function provides a uniform way of supporting
+When ``copyData=false`` , the conversion is done really fast (in O(1) time) and the newly created matrix header will have ``refcount=0`` , which means that no reference counting is done for the matrix data. In this case, you have to preserve the data until the new header is destructed. Otherwise, when ``copyData=true`` , the new buffer is allocated and managed as if you created a new matrix from scratch and copied the data there. That is, ``cvarrToMat(src, true)`` is equivalent to ``cvarrToMat(src, false).clone()`` (assuming that COI is not set). The function provides a uniform way of supporting
``CvArr`` paradigm in the code that is migrated to use new-style data structures internally. The reverse transformation, from
-:func:`Mat` to
+:cpp:func:`Mat` to
``CvMat`` or
``IplImage`` can be done by a simple assignment: ::
// for the same 10x10 floating-point array.
// note that you will need to use "&"
// to pass C & C1 to OpenCV functions, for example:
- printf("
-
+ printf("%g\n", cvNorm(&C1, 0, CV_L2));
Normally, the function is used to convert an old-style 2D array (
``CvMat`` or
``IplImage`` ) to ``Mat`` . However, the function can also take
``CvMatND`` as an input and create
-:func:`Mat` for it, if it is possible. And, for ``CvMatND A`` , it is possible if and only if ``A.dim[i].size*A.dim.step[i] == A.dim.step[i-1]`` for all or for all but one ``i, 0 < i < A.dims`` . That is, the matrix data should be continuous or it should be representable as a sequence of continuous matrices. By using this function in this way, you can process
-``CvMatND`` using an arbitrary element-wise function. But for more complex operations, such as filtering functions, it will not work, and you need to convert
-``CvMatND`` to
-:func:`MatND` using the corresponding constructor of the latter.
+:cpp:func:`Mat` for it, if it is possible. And, for ``CvMatND A`` , it is possible if and only if ``A.dim[i].size*A.dim.step[i] == A.dim.step[i-1]`` for all or for all but one ``i, 0 < i < A.dims`` . That is, the matrix data should be continuous or it should be representable as a sequence of continuous matrices. By using this function in this way, you can process
+``CvMatND`` using an arbitrary element-wise function.
The last parameter, ``coiMode`` , specifies how to deal with an image with COI set. By default, it is 0 and the function reports an error when an image with COI comes in. And ``coiMode=1`` means that no error is signalled. You have to check COI presence and handle it manually. The modern structures, such as
-:func:`Mat` and
-:func:`MatND` do not support COI natively. To process an individual channel of a new-style array, you need either to organize a loop over the array (for example, using matrix iterators) where the channel of interest will be processed, or extract the COI using
-:func:`mixChannels` (for new-style arrays) or
-:func:`extractImageCOI` (for old-style arrays), process this individual channel, and insert it back to the destination array if needed (using
-:func:`mixChannel` or
-:func:`insertImageCOI` , respectively).
+:cpp:func:`Mat` and
+:cpp:func:`MatND` do not support COI natively. To process an individual channel of a new-style array, you need either to organize a loop over the array (for example, using matrix iterators) where the channel of interest will be processed, or extract the COI using
+:cpp:func:`mixChannels` (for new-style arrays) or
+:cpp:func:`extractImageCOI` (for old-style arrays), process this individual channel, and insert it back to the destination array if needed (using
+:cpp:func:`mixChannel` or
+:cpp:func:`insertImageCOI` , respectively).
See Also:
-:func:`cvGetImage`,
-:func:`cvGetMat`,
-:func:`cvGetMatND`,
-:func:`extractImageCOI`,
-:func:`insertImageCOI`,
-:func:`mixChannels`
+:c:func:`cvGetImage`,
+:c:func:`cvGetMat`,
+:c:func:`cvGetMatND`,
+:cpp:func:`extractImageCOI`,
+:cpp:func:`insertImageCOI`,
+:cpp:func:`mixChannels`
.. index:: dct
-.. _dct:
-
dct
-------
-.. c:function:: void dct(const Mat& src, Mat& dst, int flags=0)
+.. cpp:function:: void dct(InputArray src, OutputArray dst, int flags=0)
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
Currently ``dct`` supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you can pad the array when necessary.
Also, the function performance depends very much, and not monotonically, on the array size (see
-:func:`getOptimalDFTSize` ). In the current implementation DCT of a vector of size ``N`` is computed via DFT of a vector of size ``N/2`` . Thus, the optimal DCT size
+:cpp:func:`getOptimalDFTSize` ). In the current implementation DCT of a vector of size ``N`` is computed via DFT of a vector of size ``N/2`` . Thus, the optimal DCT size
:math:`\texttt{N}^*\geq\texttt{N}` can be computed as: ::
size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
See Also:
-:func:`dft`,
-:func:`getOptimalDFTSize`,
-:func:`idct`
+:cpp:func:`dft`,
+:cpp:func:`getOptimalDFTSize`,
+:cpp:func:`idct`
.. index:: dft
-.. _dft:
-
dft
---
-.. c:function:: void dft(const Mat& src, Mat& dst, int flags=0, int nonzeroRows=0)
+.. cpp:function:: void dft(InputArray src, OutputArray dst, int flags=0, int nonzeroRows=0)
Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
If ``DFT_SCALE`` is set, the scaling is done after the transformation.
Unlike
-:func:`dct` , the function supports arrays of arbitrary size. But only those arrays are processed efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the current implementation). Such an efficient DFT size can be computed using the
-:func:`getOptimalDFTSize` method.
+:cpp:func:`dct` , the function supports arrays of arbitrary size. But only those arrays are processed efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the current implementation). Such an efficient DFT size can be computed using the
+:cpp:func:`getOptimalDFTSize` method.
Here is a sample illustrating how to compute a DFT-based convolution of two 2D real arrays: ::
- void convolveDFT(const Mat& A, const Mat& B, Mat& C)
+ void convolveDFT(InputArray A, InputArray B, OutputArray C)
{
// reallocate the output array if needed
C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
*
If different tiles in ``C`` can be computed in parallel and, thus, the convolution is done by parts, the loop can be threaded.
-All of the above improvements have been implemented in :func:`matchTemplate` and :func:`filter2D` . Therefore, by using them, you can get the performance even better than with the above theoretically optimal implementation. Though, those two functions actually compute cross-correlation, not convolution, so you need to "flip" the kernel or the image around the center using :func:`flip` .
+All of the above improvements have been implemented in :cpp:func:`matchTemplate` and :cpp:func:`filter2D` . Therefore, by using them, you can get the performance even better than with the above theoretically optimal implementation. Though, those two functions actually compute cross-correlation, not convolution, so you need to "flip" the kernel or the image around the center using :cpp:func:`flip` .
See Also:
-:func:`dct`,
-:func:`getOptimalDFTSize`,
-:func:`mulSpectrums`,
-:func:`filter2D`,
-:func:`matchTemplate`,
-:func:`flip`,
-:func:`cartToPolar`,
-:func:`magnitude`,
-:func:`phase`
+:cpp:func:`dct`,
+:cpp:func:`getOptimalDFTSize`,
+:cpp:func:`mulSpectrums`,
+:cpp:func:`filter2D`,
+:cpp:func:`matchTemplate`,
+:cpp:func:`flip`,
+:cpp:func:`cartToPolar`,
+:cpp:func:`magnitude`,
+:cpp:func:`phase`
.. index:: divide
-.. _divide:
-
divide
----------
-.. c:function:: void divide(const Mat& src1, const Mat& src2, Mat& dst, double scale=1)
-
-.. c:function:: void divide(double scale, const Mat& src2, Mat& dst)
-
-.. c:function:: void divide(const MatND& src1, const MatND& src2, MatND& dst, double scale=1)
+.. cpp:function:: void divide(InputArray src1, InputArray src2, OutputArray dst, double scale=1, int dtype=-1)
-.. c:function:: void divide(double scale, const MatND& src2, MatND& dst)
+.. cpp:function:: void divide(double scale, InputArray src2, OutputArray dst, int dtype=-1)
Performs per-element division of two arrays or a scalar by an array.
:param dst: The destination array of the same size and type as ``src2`` .
+ :param dtype: Optional depth of the destination array. If it is ``-1``, ``dst`` will have depth ``src2.depth()``. In the case of array by array division, you can only pass ``-1`` when ``src1.depth()==src2.depth()``.
+
The functions ``divide`` divide one array by another:
.. math::
\texttt{dst(I) = saturate(scale/src2(I))}
-The result has the same type as ``src1`` . When ``src2(I)=0``,``dst(I)=0`` too.
+When ``src2(I)`` is zero, ``dst(I)`` will also be zero. Different channels of multi-channel arrays are processed independently.
See Also:
-:func:`multiply`,
-:func:`add`,
-:func:`subtract`,
+:cpp:func:`multiply`,
+:cpp:func:`add`,
+:cpp:func:`subtract`,
:ref:`MatrixExpressions`
.. index:: determinant
-.. _determinant:
-
determinant
-----------
-.. c:function:: double determinant(const Mat& mtx)
+.. cpp:function:: double determinant(InputArray mtx)
Returns the determinant of a square floating-point matrix.
:param mtx: The input matrix that must have ``CV_32FC1`` or ``CV_64FC1`` type and square size.
The function ``determinant`` computes and returns the determinant of the specified matrix. For small matrices ( ``mtx.cols=mtx.rows<=3`` ),
-the direct method is used. For larger matrices, the function uses LU factorization.
+the direct method is used. For larger matrices, the function uses LU factorization with partial pivoting.
-For symmetric positively-determined matrices, it is also possible to compute
-:func:`SVD` :
-:math:`\texttt{mtx}=U \cdot W \cdot V^T` and then calculate the determinant as a product of the diagonal elements of
-:math:`W` .
+For symmetric positively-determined matrices, it is also possible to use :cpp:func:`eigen` decomposition to compute the determinant.
See Also:
-:func:`SVD`,
-:func:`trace`,
-:func:`invert`,
-:func:`solve`,
+:cpp:func:`trace`,
+:cpp:func:`invert`,
+:cpp:func:`solve`,
+:cpp:func:`eigen`,
:ref:`MatrixExpressions`
.. index:: eigen
-.. _eigen:
-
eigen
-----
-.. c:function:: bool eigen(const Mat& src, Mat& eigenvalues, int lowindex=-1, int highindex=-1)
+.. cpp:function:: bool eigen(InputArray src, OutputArray eigenvalues, int lowindex=-1, int highindex=-1)
-.. c:function:: bool eigen(const Mat& src, Mat& eigenvalues, Mat& eigenvectors, int lowindex=-1,int highindex=-1)
+.. cpp:function:: bool eigen(InputArray src, OutputArray eigenvalues, OutputArray eigenvectors, int lowindex=-1,int highindex=-1)
Computes eigenvalues and eigenvectors of a symmetric matrix.
:param eigenvectors: The output matrix of eigenvectors. It has the same size and type as ``src`` . The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues.
- :param lowindex: Optional index of largest eigenvalue/-vector to calculate. See below for more details.
+ :param lowindex: Optional index of largest eigenvalue/-vector to calculate. Ignored in the current implementation.
- :param highindex: Optional index of smallest eigenvalue/-vector to calculate. See below for more details.
+ :param highindex: Optional index of smallest eigenvalue/-vector to calculate. Ignored in the current implementation.
The functions ``eigen`` compute just eigenvalues, or eigenvalues and eigenvectors of the symmetric matrix ``src`` : ::
- src*eigenvectors(i,:)' = eigenvalues(i)*eigenvectors(i,:)' (in MATLAB notation)
-
-
-If either ``low-`` or ``highindex`` is supplied, the other one is required, too.
-Indexing is 0-based. For example, to calculate the largest eigenvector/-value set,
-``lowindex = highindex = 0`` .
-For legacy reasons, this function always returns a square matrix of the same size as the source matrix with eigenvectors and a vector of the length of the source matrix with eigenvalues. The selected eigenvectors/-values are always in the first ``highindex`` - ``lowindex`` + 1 rows.
+ src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
See Also:
-:func:`SVD`,
-:func:`completeSymm`,
-:func:`PCA`
+:cpp:func:`completeSymm`,
+:cpp:func:`PCA`
.. index:: exp
-.. _exp:
-
exp
---
-.. c:function:: void exp(const InputArray& src, OutputArray dst)
+.. cpp:function:: void exp(InputArray src, OutputArray dst)
Calculates the exponent of every array element.
:math:`\pm \infty` ) are not handled.
See Also:
-:func:`log`,
-:func:`cartToPolar`,
-:func:`polarToCart`,
-:func:`phase`,
-:func:`pow`,
-:func:`sqrt`,
-:func:`magnitude`
+:cpp:func:`log`,
+:cpp:func:`cartToPolar`,
+:cpp:func:`polarToCart`,
+:cpp:func:`phase`,
+:cpp:func:`pow`,
+:cpp:func:`sqrt`,
+:cpp:func:`magnitude`
.. index:: extractImageCOI
-.. _extractImageCOI:
-
extractImageCOI
---------------
-.. c:function:: void extractImageCOI(const CvArr* src, Mat& dst, int coi=-1)
+.. cpp:function:: void extractImageCOI(const CvArr* src, OutputArray dst, int coi=-1)
Extracts the selected image channel.
The function ``extractImageCOI`` is used to extract an image COI from an old-style array and put the result to the new-style C++ matrix. As usual, the destination matrix is reallocated using ``Mat::create`` if needed.
To extract a channel from a new-style matrix, use
-:func:`mixChannels` or
-:func:`split` .
+:cpp:func:`mixChannels` or
+:cpp:func:`split` .
See Also:
-:func:`mixChannels`,
-:func:`split`,
-:func:`merge`,
-:func:`cvarrToMat`,
-:func:`cvSetImageCOI`,
-:func:`cvGetImageCOI`
+:cpp:func:`mixChannels`,
+:cpp:func:`split`,
+:cpp:func:`merge`,
+:cpp:func:`cvarrToMat`,
+:c:func:`cvSetImageCOI`,
+:c:func:`cvGetImageCOI`
.. index:: fastAtan2
-.. _fastAtan2:
-
fastAtan2
---------
-.. c:function:: float fastAtan2(float y, float x)
+.. cpp:function:: float fastAtan2(float y, float x)
Calculates the angle of a 2D vector in degrees.
flip
--------
-.. c:function:: void flip(const Mat& src, Mat& dst, int flipCode)
+.. cpp:function:: void flip(InputArray src, OutputArray dst, int flipCode)
Flips a 2D array around vertical, horizontal, or both axes.
The example scenarios of using the function are the following:
-*
+ *
Vertical flipping of the image (
:math:`\texttt{flipCode} = 0` ) to switch between top-left and bottom-left image origin. This is a typical operation in video processing on Microsoft Windows* OS.
-*
+ *
Horizontal flipping of the image with the subsequent horizontal shift and absolute difference calculation to check for a vertical-axis symmetry (
:math:`\texttt{flipCode} > 0` ).
-*
+ *
Simultaneous horizontal and vertical flipping of the image with the subsequent shift and absolute difference calculation to check for a central symmetry (
:math:`\texttt{flipCode} < 0` ).
-*
+ *
Reversing the order of 1D point arrays (
:math:`\texttt{flipCode} > 0` or
:math:`\texttt{flipCode} = 0` ).
-See Also: :func:`transpose`,
-:func:`repeat`,
-:func:`completeSymm`
+See Also: :cpp:func:`transpose`,
+:cpp:func:`repeat`,
+:cpp:func:`completeSymm`
.. index:: gemm
-.. _gemm:
-
gemm
----
-.. c:function:: void gemm(const Mat& src1, const Mat& src2, double alpha, const Mat& src3, double beta, Mat& dst, int flags=0)
+.. cpp:function:: void gemm(InputArray src1, InputArray src2, double alpha, InputArray src3, double beta, OutputArray dst, int flags=0)
Performs generalized matrix multiplication.
See Also:
-:func:`mulTransposed`,
-:func:`transform`,
+:cpp:func:`mulTransposed`,
+:cpp:func:`transform`,
:ref:`MatrixExpressions`
.. index:: getConvertElem
-.. _getConvertItem:
-
getConvertElem
--------------
-.. c:function:: ConvertData getConvertElem(int fromType, int toType)
+.. cpp:function:: ConvertData getConvertElem(int fromType, int toType)
-.. c:function:: ConvertScaleData getConvertScaleElem(int fromType, int toType)
+.. cpp:function:: ConvertScaleData getConvertScaleElem(int fromType, int toType)
-.. c:function:: typedef void (*ConvertData)(const void* from, void* to, int cn)
+.. cpp:function:: typedef void (*ConvertData)(const void* from, void* to, int cn)
-.. c:function:: typedef void (*ConvertScaleData)(const void* from, void* to, int cn, double alpha, double beta)
+.. cpp:function:: typedef void (*ConvertScaleData)(const void* from, void* to, int cn, double alpha, double beta)
Returns a conversion function for a single pixel.
The functions ``getConvertElem`` and ``getConvertScaleElem`` return pointers to the functions for converting individual pixels from one type to another. While the main function purpose is to convert single pixels (actually, for converting sparse matrices from one type to another), you can use them to convert the whole row of a dense matrix or the whole matrix at once, by setting ``cn = matrix.cols*matrix.rows*matrix.channels()`` if the matrix data is continuous.
See Also:
-:func:`Mat::convertTo`,
-:func:`MatND::convertTo`,
-:func:`SparseMat::convertTo`
+:cpp:func:`Mat::convertTo`,
+:cpp:func:`SparseMat::convertTo`
.. index:: getOptimalDFTSize
-.. _getOptimalDFTSize:
-
getOptimalDFTSize
-----------------
-.. c:function:: int getOptimalDFTSize(int vecsize)
+.. cpp:function:: int getOptimalDFTSize(int vecsize)
Returns the optimal DFT size for a given vector size.
While the function cannot be used directly to estimate the optimal vector size for DCT transform (since the current DCT implementation supports only even-size vectors), it can be easily computed as ``getOptimalDFTSize((vecsize+1)/2)*2`` .
See Also:
-:func:`dft`,
-:func:`dct`,
-:func:`idft`,
-:func:`idct`,
-:func:`mulSpectrums`
+:cpp:func:`dft`,
+:cpp:func:`dct`,
+:cpp:func:`idft`,
+:cpp:func:`idct`,
+:cpp:func:`mulSpectrums`
.. index:: idct
-.. _idct:
-
idct
----
-.. c:function:: void idct(const Mat& src, Mat& dst, int flags=0)
+.. cpp:function:: void idct(InputArray src, OutputArray dst, int flags=0)
Computes the inverse Discrete Cosine Transform of a 1D or 2D array.
``idct(src, dst, flags)`` is equivalent to ``dct(src, dst, flags | DCT_INVERSE)``.
-See Also: :func:`dct`,
-:func:`dft`,
-:func:`idft`,
-:func:`getOptimalDFTSize`
+See Also: :cpp:func:`dct`,
+:cpp:func:`dft`,
+:cpp:func:`idft`,
+:cpp:func:`getOptimalDFTSize`
.. index:: idft
-.. _idft:
-
idft
----
-.. c:function:: void idft(const Mat& src, Mat& dst, int flags=0, int outputRows=0)
+.. cpp:function:: void idft(InputArray src, OutputArray dst, int flags=0, int outputRows=0)
Computes the inverse Discrete Fourier Transform of a 1D or 2D array.
:param dst: The destination array whose size and type depend on the ``flags`` .
- :param flags: The operation flags. See :func:`dft` .
+ :param flags: The operation flags. See :cpp:func:`dft` .
- :param nonzeroRows: The number of ``dst`` rows to compute. The rest of the rows have undefined content. See the convolution sample in :func:`dft` description.
+ :param nonzeroRows: The number of ``dst`` rows to compute. The rest of the rows have undefined content. See the convolution sample in :cpp:func:`dft` description.
``idft(src, dst, flags)`` is equivalent to ``dct(src, dst, flags | DFT_INVERSE)`` .
-See :func:`dft` for details.
+See :cpp:func:`dft` for details.
**Note**:
None of ``dft`` and ``idft`` scale the result by default.
Thus, you should pass ``DFT_SCALE`` to one of ``dft`` or ``idft`` explicitly to make these transforms mutually inverse.
-See Also: :func:`dft`,
-:func:`dct`,
-:func:`idct`,
-:func:`mulSpectrums`,
-:func:`getOptimalDFTSize`
+See Also: :cpp:func:`dft`,
+:cpp:func:`dct`,
+:cpp:func:`idct`,
+:cpp:func:`mulSpectrums`,
+:cpp:func:`getOptimalDFTSize`
.. index:: inRange
-.. _inRange:
-
inRange
-------
-.. c:function:: void inRange(const Mat& src, const Mat& lowerb, const Mat& upperb, Mat& dst)
-
-.. c:function:: void inRange(const Mat& src, const Scalar& lowerb, const Scalar& upperb, Mat& dst)
-
-.. c:function:: void inRange(const MatND& src, const MatND& lowerb, const MatND& upperb, MatND& dst)
-
-.. c:function:: void inRange(const MatND& src, const Scalar& lowerb, const Scalar& upperb, MatND& dst)
+.. cpp:function:: void inRange(InputArray src, InputArray lowerb, InputArray upperb, OutputArray dst)
Checks if array elements lie between the elements of two other arrays.
:param src: The first source array.
- :param lowerb: Inclusive lower boundary array of the same size and type as ``src`` .
+ :param lowerb: Inclusive lower boundary array or a scalar.
- :param upperb: Exclusive upper boundary array of the same size and type as ``src`` .
+ :param upperb: Inclusive upper boundary array or a scalar.
:param dst: Destination array of the same size as ``src`` and ``CV_8U`` type.
-The functions ``inRange`` check the range as follows:
+The function checks the range as follows:
-* for every element of the input array:
+ * for every element of the input array:
-.. math::
+ .. math::
- \texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 < \texttt{upperb} (I)_0
+ \texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 < \texttt{upperb} (I)_0
-* for single-channel arrays:
+ * for single-channel arrays:
-.. math::
+ .. math::
- \texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 < \texttt{upperb} (I)_0 \land \texttt{lowerb} (I)_1 \leq \texttt{src} (I)_1 < \texttt{upperb} (I)_1
+ \texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 < \texttt{upperb} (I)_0 \land \texttt{lowerb} (I)_1 \leq \texttt{src} (I)_1 < \texttt{upperb} (I)_1
-* for two-channel arrays and so forth.
+ for two-channel arrays and so forth.
``dst`` (I) is set to 255 (all ``1`` -bits) if ``src`` (I) is within the specified range and 0 otherwise.
-.. index:: invert
+When the lower and/or upper bounary parameters are scalars, the indexes ``(I)`` at ``lowerb`` and ``upperb`` in the above formulas should be omitted.
-.. _invert:
+.. index:: invert
invert
------
-.. c:function:: double invert(const Mat& src, Mat& dst, int method=DECOMP_LU)
+.. cpp:function:: double invert(InputArray src, OutputArray dst, int method=DECOMP_LU)
Finds the inverse or pseudo-inverse of a matrix.
- :param src: The source floating-point :math:`M \times N` matrix.
+ :param src: The source floating-point ``M x N`` matrix.
- :param dst: The destination matrix of :math:`N \times M` size and the same type as ``src`` .
+ :param dst: The destination matrix of ``N x M`` size and the same type as ``src`` .
:param flags: The inversion method :
In case of the ``DECOMP_SVD`` method, the function returns the inverse condition number of ``src`` (the ratio of the smallest singular value to the largest singular value) and 0 if ``src`` is singular. The SVD method calculates a pseudo-inverse matrix if ``src`` is singular.
-Similarly to ``DECOMP_LU`` , the method ``DECOMP_CHOLESKY`` works only with non-singular square matrices. In this case, the function stores the inverted matrix in ``dst`` and returns non-zero. Otherwise, it returns 0.
+Similarly to ``DECOMP_LU`` , the method ``DECOMP_CHOLESKY`` works only with non-singular square matrices that should also be symmetrical and positively defined. In this case, the function stores the inverted matrix in ``dst`` and returns non-zero. Otherwise, it returns 0.
See Also:
-:func:`solve`,
-:func:`SVD`
+:cpp:func:`solve`,
+:cpp:class:`SVD`
.. index:: log
-.. _log:
-
log
---
-.. c:function:: void log(const Mat& src, Mat& dst)
-
-.. c:function:: void log(const MatND& src, MatND& dst)
+.. cpp:function:: void log(InputArray src, OutputArray dst)
Calculates the natural logarithm of every array element.
:math:`\pm \infty` ) are not handled.
See Also:
-:func:`exp`,
-:func:`cartToPolar`,
-:func:`polarToCart`,
-:func:`phase`,
-:func:`pow`,
-:func:`sqrt`,
-:func:`magnitude`
+:cpp:func:`exp`,
+:cpp:func:`cartToPolar`,
+:cpp:func:`polarToCart`,
+:cpp:func:`phase`,
+:cpp:func:`pow`,
+:cpp:func:`sqrt`,
+:cpp:func:`magnitude`
.. index:: LUT
-.. _LUT:
-
LUT
---
-.. c:function:: void LUT(const Mat& src, const Mat& lut, Mat& dst)
+.. cpp:function:: void LUT(InputArray src, InputArray lut, OutputArray dst)
Performs a look-up table transform of an array.
d = \fork{0}{if \texttt{src} has depth \texttt{CV\_8U}}{128}{if \texttt{src} has depth \texttt{CV\_8S}}
See Also:
-:func:`convertScaleAbs`,``Mat::convertTo``
+:cpp:func:`convertScaleAbs`,
+:cpp:func:`Mat::convertTo`
.. index:: magnitude
-.. _magnitude:
-
magnitude
---------
-.. c:function:: void magnitude(const Mat& x, const Mat& y, Mat& magnitude)
+.. cpp:function:: void magnitude(InputArray x, InputArray y, OutputArray magnitude)
Calculates the magnitude of 2D vectors.
\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}
See Also:
-:func:`cartToPolar`,
-:func:`polarToCart`,
-:func:`phase`,
-:func:`sqrt`
+:cpp:func:`cartToPolar`,
+:cpp:func:`polarToCart`,
+:cpp:func:`phase`,
+:cpp:func:`sqrt`
.. index:: Mahalanobis
-.. _Mahalanobis:
-
Mahalanobis
-----------
-.. c:function:: double Mahalanobis(const Mat& vec1, const Mat& vec2, const Mat& icovar)
+.. cpp:function:: double Mahalanobis(InputArray vec1, InputArray vec2, InputArray icovar)
Calculates the Mahalanobis distance between two vectors.
:param icovar: Inverse covariance matrix.
-The function ``cvMahalonobis`` calculates and returns the weighted distance between two vectors:
+The function ``Mahalonobis`` calculates and returns the weighted distance between two vectors:
.. math::
d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }
The covariance matrix may be calculated using the
-:func:`calcCovarMatrix` function and then inverted using the
-:func:`invert` function (preferably using the ``DECOMP_SVD`` method, as the most accurate).
+:cpp:func:`calcCovarMatrix` function and then inverted using the
+:cpp:func:`invert` function (preferably using the ``DECOMP_SVD`` method, as the most accurate).
.. index:: max
-.. _max:
-
max
---
-.. c:function:: Mat_Expr<...> max(const Mat& src1, const Mat& src2)
+.. cpp:function:: MatExpr max(const Mat& src1, const Mat& src2)
-.. c:function:: Mat_Expr<...> max(const Mat& src1, double value)
+.. cpp:function:: MatExpr max(const Mat& src1, double value)
-.. c:function:: Mat_Expr<...> max(double value, const Mat& src1)
+.. cpp:function:: MatExpr max(double value, const Mat& src1)
-.. c:function:: void max(const Mat& src1, const Mat& src2, Mat& dst)
+.. cpp:function:: void max(InputArray src1, InputArray src2, OutputArray dst)
-.. c:function:: void max(const Mat& src1, double value, Mat& dst)
+.. cpp:function:: void max(const Mat& src1, const Mat& src2, Mat& dst)
-.. c:function:: void max(const MatND& src1, const MatND& src2, MatND& dst)
-
-.. c:function:: void max(const MatND& src1, double value, MatND& dst)
+.. cpp:function:: void max(const Mat& src1, double value, Mat& dst)
Calculates per-element maximum of two arrays or array and a scalar.
:ref:`MatrixExpressions` . They return an expression object that can be further either transformed/ assigned to a matrix, or passed to a function, and so on.
See Also:
-:func:`min`,
-:func:`compare`,
-:func:`inRange`,
-:func:`minMaxLoc`,
+:cpp:func:`min`,
+:cpp:func:`compare`,
+:cpp:func:`inRange`,
+:cpp:func:`minMaxLoc`,
:ref:`MatrixExpressions`
.. index:: mean
-.. _mean:
-
mean
----
-.. c:function:: Scalar mean(const Mat& mtx)
-
-.. c:function:: Scalar mean(const Mat& mtx, const Mat& mask)
-
-.. c:function:: Scalar mean(const MatND& mtx)
-
-.. c:function:: Scalar mean(const MatND& mtx, const MatND& mask)
+.. cpp:function:: Scalar mean(InputArray mtx, InputArray mask=None())
Calculates an average (mean) of array elements.
- :param mtx: Source array that should have from 1 to 4 channels so that the result can be stored in :func:`Scalar` .
+ :param mtx: Source array that should have from 1 to 4 channels so that the result can be stored in :cpp:func:`Scalar` .
:param mask: Optional operation mask.
When all the mask elements are 0's, the functions return ``Scalar::all(0)`` .
See Also:
-:func:`countNonZero`,
-:func:`meanStdDev`,
-:func:`norm`,
-:func:`minMaxLoc`
+:cpp:func:`countNonZero`,
+:cpp:func:`meanStdDev`,
+:cpp:func:`norm`,
+:cpp:func:`minMaxLoc`
.. index:: meanStdDev
-.. _meanStdDev:
-
meanStdDev
----------
-.. c:function:: void meanStdDev(const Mat& mtx, Scalar& mean, Scalar& stddev, const Mat& mask=Mat())
-
-.. c:function:: void meanStdDev(const MatND& mtx, Scalar& mean, Scalar& stddev, const MatND& mask=MatND())
+.. cpp:function:: void meanStdDev(InputArray mtx, OutputArray mean, OutputArray stddev, InputArray mask=None())
Calculates mean and standard deviation of array elements.
- :param mtx: Source array that should have from 1 to 4 channels so that the results can be stored in :func:`Scalar` 's.
+ :param mtx: Source array that should have from 1 to 4 channels so that the results can be stored in :cpp:func:`Scalar` 's.
:param mean: Output parameter: computed mean value.
The computed standard deviation is only the diagonal of the complete normalized covariance matrix. If the full matrix is needed, you can reshape the multi-channel array
:math:`M \times N` to the single-channel array
:math:`M*N \times \texttt{mtx.channels}()` (only possible when the matrix is continuous) and then pass the matrix to
-:func:`calcCovarMatrix` .
+:cpp:func:`calcCovarMatrix` .
See Also:
-:func:`countNonZero`,
-:func:`mean`,
-:func:`norm`,
-:func:`minMaxLoc`,
-:func:`calcCovarMatrix`
+:cpp:func:`countNonZero`,
+:cpp:func:`mean`,
+:cpp:func:`norm`,
+:cpp:func:`minMaxLoc`,
+:cpp:func:`calcCovarMatrix`
.. index:: merge
-.. _merge:
-
merge
-----
-.. c:function:: void merge(const Mat* mv, size_t count, Mat& dst)
-
-.. c:function:: void merge(const vector<Mat>& mv, Mat& dst)
+.. cpp:function:: void merge(const Mat* mv, size_t count, OutputArray dst)
-.. c:function:: void merge(const MatND* mv, size_t count, MatND& dst)
-
-.. c:function:: void merge(const vector<MatND>& mv, MatND& dst)
+.. cpp:function:: void merge(const vector<Mat>& mv, OutputArray dst)
Composes a multi-channel array from several single-channel arrays.
- :param mv: Source array or vector of the single-channel matrices to be merged. All the matrices in ``mv`` must have the same size and the same type.
+ :param mv: Source array or vector of matrices to be merged. All the matrices in ``mv`` must have the same size and the same depth.
:param count: Number of source matrices when ``mv`` is a plain C array. It must be greater than zero.
- :param dst: Destination array of the same size and the same depth as ``mv[0]`` . The number of channels matches the number of source matrices.
-
-The functions ``merge`` merge several single-channel arrays (or rather interleave their elements) to make a single multi-channel array.
-
-.. math::
+ :param dst: Destination array of the same size and the same depth as ``mv[0]`` . The number of channels will be the total number of channels in the matrix array.
- \texttt{dst} (I)_c = \texttt{mv} [c](I)
+The functions ``merge`` merge several arrays to make a single multi-channel array. That is, each element of the output array will be a concatenation of the elements of the input arrays, where elements of i-th input array are treated as ``mv[i].channels()``-element vectors.
The function
-:func:`split` does the reverse operatio. If you need to merge several multi-channel images or shuffle channels in some other advanced way, use
-:func:`mixChannels` .
+:cpp:func:`split` does the reverse operation. If you need to shuffle channels in some other advanced way, use
+:cpp:func:`mixChannels` .
See Also:
-:func:`mixChannels`,
-:func:`split`,
-:func:`reshape`
+:cpp:func:`mixChannels`,
+:cpp:func:`split`,
+:cpp:func:`reshape`
.. index:: min
-.. _min:
-
min
---
-.. c:function:: Mat_Expr<...> min(const Mat& src1, const Mat& src2)
-
-.. c:function:: Mat_Expr<...> min(const Mat& src1, double value)
+.. cpp:function:: MatExpr min(const Mat& src1, const Mat& src2)
-.. c:function:: Mat_Expr<...> min(double value, const Mat& src1)
+.. cpp:function:: MatExpr min(const Mat& src1, double value)
-.. c:function:: void min(const Mat& src1, const Mat& src2, Mat& dst)
+.. cpp:function:: MatExpr min(double value, const Mat& src1)
-.. c:function:: void min(const Mat& src1, double value, Mat& dst)
+.. cpp:function:: void min(InputArray src1, InputArray src2, OutputArray dst)
-.. c:function:: void min(const MatND& src1, const MatND& src2, MatND& dst)
+.. cpp:function:: void min(const Mat& src1, const Mat& src2, Mat& dst)
-.. c:function:: void min(const MatND& src1, double value, MatND& dst)
+.. cpp:function:: void min(const Mat& src1, double value, Mat& dst)
Calculates per-element minimum of two arrays or array and a scalar.
:ref:`MatrixExpressions` . They return the expression object that can be further either transformed/assigned to a matrix, or passed to a function, and so on.
See Also:
-:func:`max`,
-:func:`compare`,
-:func:`inRange`,
-:func:`minMaxLoc`,
+:cpp:func:`max`,
+:cpp:func:`compare`,
+:cpp:func:`inRange`,
+:cpp:func:`minMaxLoc`,
:ref:`MatrixExpressions`
.. index:: minMaxLoc
-.. _minMaxLoc:
-
minMaxLoc
---------
-.. c:function:: void minMaxLoc(const Mat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, const Mat& mask=Mat())
-
-.. c:function:: void minMaxLoc(const MatND& src, double* minVal, double* maxVal, int* minIdx=0, int* maxIdx=0, const MatND& mask=MatND())
+.. cpp:function:: void minMaxLoc(InputArray src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=None())
-.. c:function:: void minMaxLoc(const SparseMat& src, double* minVal, double* maxVal, int* minIdx=0, int* maxIdx=0)
+.. cpp:function:: void minMaxLoc(const SparseMat& src, double* minVal, double* maxVal, int* minIdx=0, int* maxIdx=0)
Finds the global minimum and maximum in a whole array or sub-array.
if ``mask`` is not an empty array, in the specified array region.
The functions do not work with multi-channel arrays. If you need to find minimum or maximum elements across all the channels, use
-:func:`reshape` first to reinterpret the array as single-channel. Or you may extract the particular channel using either
-:func:`extractImageCOI` , or
-:func:`mixChannels` , or
-:func:`split` .
+:cpp:func:`reshape` first to reinterpret the array as single-channel. Or you may extract the particular channel using either
+:cpp:func:`extractImageCOI` , or
+:cpp:func:`mixChannels` , or
+:cpp:func:`split` .
In case of a sparse matrix, the minimum is found among non-zero elements only.
See Also:
-:func:`max`,
-:func:`min`,
-:func:`compare`,
-:func:`inRange`,
-:func:`extractImageCOI`,
-:func:`mixChannels`,
-:func:`split`,
-:func:`reshape`
+:cpp:func:`max`,
+:cpp:func:`min`,
+:cpp:func:`compare`,
+:cpp:func:`inRange`,
+:cpp:func:`extractImageCOI`,
+:cpp:func:`mixChannels`,
+:cpp:func:`split`,
+:cpp:func:`reshape`
.. index:: mixChannels
-.. _mixChannels:
-
mixChannels
-----------
-.. c:function:: void mixChannels(const Mat* srcv, int nsrc, Mat* dstv, int ndst, const int* fromTo, size_t npairs)
-
-.. c:function:: void mixChannels(const MatND* srcv, int nsrc, MatND* dstv, int ndst, const int* fromTo, size_t npairs)
+.. cpp:function:: void mixChannels(const Mat* srcv, int nsrc, Mat* dstv, int ndst, const int* fromTo, size_t npairs)
-.. c:function:: void mixChannels(const vector<Mat>& srcv, vector<Mat>& dstv, const int* fromTo, int npairs)
-
-.. c:function:: void mixChannels(const vector<MatND>& srcv, vector<MatND>& dstv, const int* fromTo, int npairs)
+.. cpp:function:: void mixChannels(const vector<Mat>& srcv, vector<Mat>& dstv, const int* fromTo, int npairs)
Copies specified channels from input arrays to the specified channels of output arrays.
The functions ``mixChannels`` provide an advanced mechanism for shuffling image channels.
-:func:`split` and
-:func:`merge` and some forms of
-:func:`cvtColor` are partial cases of ``mixChannels`` .
+:cpp:func:`split` and
+:cpp:func:`merge` and some forms of
+:cpp:func:`cvtColor` are partial cases of ``mixChannels`` .
As an example, this code splits a 4-channel RGBA image into a 3-channel BGR (with R and B channels swapped) and separate alpha channel image: ::
**Note**
Unlike many other new-style C++ functions in OpenCV (see the introduction section and
-:func:`Mat::create` ), ``mixChannels`` requires the destination arrays to be pre-allocated before calling the function.
+:cpp:func:`Mat::create` ), ``mixChannels`` requires the destination arrays to be pre-allocated before calling the function.
See Also:
-:func:`split`,
-:func:`merge`,
-:func:`cvtColor`
+:cpp:func:`split`,
+:cpp:func:`merge`,
+:cpp:func:`cvtColor`
.. index:: mulSpectrums
-.. _mulSpectrums:
-
mulSpectrums
------------
-.. c:function:: void mulSpectrums(const Mat& src1, const Mat& src2, Mat& dst, int flags, bool conj=false)
+.. cpp:function:: void mulSpectrums(InputArray src1, InputArray src2, OutputArray dst, int flags, bool conj=false)
Performs the per-element multiplication of two Fourier spectrums.
The function ``mulSpectrums`` performs the per-element multiplication of the two CCS-packed or complex matrices that are results of a real or complex Fourier transform.
The function, together with
-:func:`dft` and
-:func:`idft` , may be used to calculate convolution (pass ``conj=false`` ) or correlation (pass ``conj=false`` ) of two arrays rapidly. When the arrays are complex, they are simply multiplied (per element) with an optional conjugation of the second-array elements. When the arrays are real, they are assumed to be CCS-packed (see
-:func:`dft` for details).
+:cpp:func:`dft` and
+:cpp:func:`idft` , may be used to calculate convolution (pass ``conj=false`` ) or correlation (pass ``conj=false`` ) of two arrays rapidly. When the arrays are complex, they are simply multiplied (per element) with an optional conjugation of the second-array elements. When the arrays are real, they are assumed to be CCS-packed (see
+:cpp:func:`dft` for details).
.. index:: multiply
-.. _multiply:
-
multiply
--------
-.. c:function:: void multiply(const Mat& src1, const Mat& src2, Mat& dst, double scale=1)
-
-.. c:function:: void multiply(const MatND& src1, const MatND& src2, MatND& dst, double scale=1)
+.. cpp:function:: void multiply(InputArray src1, InputArray src2, OutputArray dst, double scale=1)
Calculates the per-element scaled product of two arrays.
There is also
:ref:`MatrixExpressions` -friendly variant of the first function. See
-:func:`Mat::mul` .
+:cpp:func:`Mat::mul` .
For a not-per-element matrix product, see
-:func:`gemm` .
+:cpp:func:`gemm` .
See Also:
-:func:`add`,
-:func:`substract`,
-:func:`divide`,
+:cpp:func:`add`,
+:cpp:func:`substract`,
+:cpp:func:`divide`,
:ref:`MatrixExpressions`,
-:func:`scaleAdd`,
-:func:`addWeighted`,
-:func:`accumulate`,
-:func:`accumulateProduct`,
-:func:`accumulateSquare`,
-:func:`Mat::convertTo`
+:cpp:func:`scaleAdd`,
+:cpp:func:`addWeighted`,
+:cpp:func:`accumulate`,
+:cpp:func:`accumulateProduct`,
+:cpp:func:`accumulateSquare`,
+:cpp:func:`Mat::convertTo`
.. index:: mulTransposed
-.. mulTransposed:
-
mulTransposed
-------------
-.. c:function:: void mulTransposed( const Mat& src, Mat& dst, bool aTa, const Mat& delta=Mat(), double scale=1, int rtype=-1 )
+.. cpp:function:: void mulTransposed(InputArray src, OutputArray dst, bool aTa, InputArray delta=None(), double scale=1, int rtype=-1)
Calculates the product of a matrix and its transposition.
- :param src: Source matrix.
+ :param src: Source single-channel matrix. Note that unlike :cpp:func:`gemm`, the function can multiply not only floating-point matrices.
:param dst: Destination square matrix.
:param aTa: Flag specifying the multiplication ordering. See the description below.
- :param delta: Optional delta matrix subtracted from ``src`` before the multiplication. When the matrix is empty ( ``delta=Mat()`` ), it is assumed to be zero, that is, nothing is subtracted. If it has the same size as ``src`` , it is simply subtracted. Otherwise, it is "repeated" (see :func:`repeat` ) to cover the full ``src`` and then subtracted. Type of the delta matrix, when it is not empty, must be the same as the type of created destination matrix. See the ``rtype`` description.
+ :param delta: Optional delta matrix subtracted from ``src`` before the multiplication. When the matrix is empty ( ``delta=None()`` ), it is assumed to be zero, that is, nothing is subtracted. If it has the same size as ``src`` , it is simply subtracted. Otherwise, it is "repeated" (see :cpp:func:`repeat` ) to cover the full ``src`` and then subtracted. Type of the delta matrix, when it is not empty, must be the same as the type of created destination matrix. See the ``rtype`` description.
:param scale: Optional scale factor for the matrix product.
- :param rtype: When it is negative, the destination matrix has the same type as ``src`` . Otherwise, it has ``type=CV_MAT_DEPTH(rtype)`` that should be either ``CV_32F`` or ``CV_64F`` .
+ :param rtype: Optional type of the destination matrix. When it is negative, the destination matrix will have the same type as ``src`` . Otherwise, it will be ``type=CV_MAT_DEPTH(rtype)`` that should be either ``CV_32F`` or ``CV_64F`` .
The function ``mulTransposed`` calculates the product of ``src`` and its transposition:
:math:`B=A^T` .
See Also:
-:func:`calcCovarMatrix`,
-:func:`gemm`,
-:func:`repeat`,
-:func:`reduce`
+:cpp:func:`calcCovarMatrix`,
+:cpp:func:`gemm`,
+:cpp:func:`repeat`,
+:cpp:func:`reduce`
.. index:: norm
-.. _norm:
-
norm
----
-.. c:function:: double norm(const Mat& src1, int normType=NORM_L2)
-
-.. c:function:: double norm(const Mat& src1, const Mat& src2, int normType=NORM_L2)
-
-.. c:function:: double norm(const Mat& src1, int normType, const Mat& mask)
-
-.. c:function:: double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask)
+.. cpp:function:: double norm(InputArray src1, int normType=NORM_L2, InputArray mask=None())
-.. c:function:: double norm(const MatND& src1, int normType=NORM_L2, const MatND& mask=MatND())
+.. cpp:function:: double norm(InputArray src1, InputArray src2, int normType, InputArray mask=None())
-.. c:function:: double norm(const MatND& src1, const MatND& src2, int normType=NORM_L2, const MatND& mask=MatND())
-
-.. c:function:: double norm( const SparseMat& src, int normType )
+.. cpp:function:: double norm( const SparseMat& src, int normType )
Calculates an absolute array norm, an absolute difference norm, or a relative difference norm.
:param normType: Type of the norm. See the details below.
- :param mask: Optional operation mask.
+ :param mask: Optional operation mask. It must have the same size as ``src1`` and ``CV_8UC1`` type.
The functions ``norm`` calculate an absolute norm of ``src1`` (when there is no ``src2`` ):
The functions ``norm`` return the calculated norm.
-When the ``mask`` parameter is used and it is not empty (has the type ``CV_8U`` and the same size as ``src1`` ), the norm is computed only over the region specified by the mask.
+When the ``mask`` parameter is specified and it is not empty, the norm is computed only over the region specified by the mask.
A multi-channel source arrays are treated as a single-channel, that is, the results for all channels are combined.
.. index:: normalize
-.. _normalize:
-
normalize
---------
-.. c:function:: void normalize( const Mat& src, Mat& dst, double alpha=1, double beta=0, int normType=NORM_L2, int rtype=-1, const Mat& mask=Mat())
+.. cpp:function:: void normalize(const InputArray src, OutputArray dst, double alpha=1, double beta=0, int normType=NORM_L2, int rtype=-1, InputArray mask=None())
-.. c:function:: void normalize( const MatND& src, MatND& dst, double alpha=1, double beta=0, int normType=NORM_L2, int rtype=-1, const MatND& mask=MatND())
+.. cpp:function:: void normalize(const SparseMat& src, SparseMat& dst, double alpha, int normType)
-.. c:function:: void normalize( const SparseMat& src, SparseMat& dst, double alpha, int normType )
-
- Normalizes an array norm or a range.
+ Normalizes norm or value range of an array
:param src: Source array.
when ``normType=NORM_MINMAX`` (for dense arrays only).
The optional mask specifies a sub-array to be normalized. This means that the norm or min-n-max are computed over the sub-array, and then this sub-array is modified to be normalized. If you want to only use the mask to compute the norm or min-max but modify the whole array, you can use
-:func:`norm` and
-:func:`Mat::convertScale` /
-:func:`MatND::convertScale` /cross{SparseMat::convertScale} separately.
+:cpp:func:`norm` and
+:cpp:func:`Mat::convertScale` /
In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this, the range transformation for sparse matrices is not allowed, since it can shift the zero level.
See Also:
-:func:`norm`,
-:func:`Mat::convertScale`,
-:func:`MatND::convertScale`,
-:func:`SparseMat::convertScale`
+:cpp:func:`norm`,
+:cpp:func:`Mat::convertScale`,
+:cpp:func:`SparseMat::convertScale`
.. index:: PCA
-.. _PCA:
-
PCA
---
-.. c:type:: PCA
+.. cpp:class:: PCA
Class for Principal Component Analysis ::
// default constructor
PCA();
// computes PCA for a set of vectors stored as data rows or columns.
- PCA(const Mat& data, const Mat& mean, int flags, int maxComponents=0);
+ PCA(InputArray data, InputArray mean, int flags, int maxComponents=0);
// computes PCA for a set of vectors stored as data rows or columns
- PCA& operator()(const Mat& data, const Mat& mean, int flags, int maxComponents=0);
+ PCA& operator()(InputArray data, InputArray mean, int flags, int maxComponents=0);
// projects vector into the principal components space
- Mat project(const Mat& vec) const;
- void project(const Mat& vec, Mat& result) const;
+ Mat project(InputArray vec) const;
+ void project(InputArray vec, OutputArray result) const;
// reconstructs the vector from its PC projection
- Mat backProject(const Mat& vec) const;
- void backProject(const Mat& vec, Mat& result) const;
+ Mat backProject(InputArray vec) const;
+ void backProject(InputArray vec, OutputArray result) const;
// eigenvectors of the PC space, stored as the matrix rows
Mat eigenvectors;
http://en.wikipedia.org/wiki/Principal\_component\_analysis
The sample below is the function that takes two matrices. The first one stores the set of vectors (a row per vector) that is used to compute PCA. The second one stores another "test" set of vectors (a row per vector) that are first compressed with PCA, then reconstructed back, and then the reconstruction error norm is computed and printed for each vector. ::
- PCA compressPCA(const Mat& pcaset, int maxComponents,
- const Mat& testset, Mat& compressed)
+ PCA compressPCA(InputArray pcaset, int maxComponents,
+ const Mat& testset, OutputArray compressed)
{
PCA pca(pcaset, // pass the data
Mat(), // there is no pre-computed mean vector,
See Also:
-:func:`calcCovarMatrix`,
-:func:`mulTransposed`,
-:func:`SVD`,
-:func:`dft`,
-:func:`dct`
+:cpp:func:`calcCovarMatrix`,
+:cpp:func:`mulTransposed`,
+:cpp:class:`SVD`,
+:cpp:func:`dft`,
+:cpp:func:`dct`
.. index:: PCA::PCA
-.. _PCA::PCA:
-
PCA::PCA
------------
-.. c:function:: PCA::PCA()
+.. cpp:function:: PCA::PCA()
-.. c:function:: PCA::PCA(const Mat& data, const Mat& mean, int flags, int maxComponents=0)
+.. cpp:function:: PCA::PCA(InputArray data, InputArray mean, int flags, int maxComponents=0)
PCA constructors
:param maxComponents: Maximum number of components that PCA should retain. By default, all the components are retained.
The default constructor initializes empty PCA structure. The second constructor initializes the structure and calls
-:func:`PCA::operator ()` .
+:cpp:func:`PCA::operator ()` .
.. index:: PCA::operator ()
-.. _PCA::operator ():
-
PCA::operator ()
----------------
-.. c:function:: PCA& PCA::operator()(const Mat& data, const Mat& mean, int flags, int maxComponents=0)
+.. cpp:function:: PCA& PCA::operator()(InputArray data, InputArray mean, int flags, int maxComponents=0)
Performs Principal Component Analysis of the supplied dataset.
.. index:: PCA::project
-.. _PCA::project:
-
PCA::project
------------
-.. c:function:: Mat PCA::project(const Mat& vec) const
+.. cpp:function:: Mat PCA::project(InputArray vec) const
-.. c:function:: void PCA::project(const Mat& vec, Mat& result) const
+.. cpp:function:: void PCA::project(InputArray vec, OutputArray result) const
Projects vector(s) to the principal component subspace.
.. index:: PCA::backProject
-.. _PCA::backProject:
-
PCA::backProject
----------------
-.. c:function:: Mat PCA::backProject(const Mat& vec) const
+.. cpp:function:: Mat PCA::backProject(InputArray vec) const
-.. c:function:: void PCA::backProject(const Mat& vec, Mat& result) const
+.. cpp:function:: void PCA::backProject(InputArray vec, OutputArray result) const
Reconstructs vectors from their PC projections.
:param result: Reconstructed vectors. The layout and size are the same as of ``PCA::project`` input vectors.
The methods are inverse operations to
-:func:`PCA::project` . They take PC coordinates of projected vectors and reconstruct the original vectors. Of course, unless all the principal components have been retained, the reconstructed vectors are different from the originals. But typically, the difference is small if the number of components is large enough (but still much smaller than the original vector dimensionality). As a result, PCA is used.
+:cpp:func:`PCA::project` . They take PC coordinates of projected vectors and reconstruct the original vectors. Of course, unless all the principal components have been retained, the reconstructed vectors are different from the originals. But typically, the difference is small if the number of components is large enough (but still much smaller than the original vector dimensionality). As a result, PCA is used.
.. index:: perspectiveTransform
-.. _perspectiveTransform:
-
perspectiveTransform
--------------------
-.. c:function:: void perspectiveTransform(const Mat& src, Mat& dst, const Mat& mtx )
+.. cpp:function:: void perspectiveTransform(InputArray src, OutputArray dst, InputArray mtx)
Performs the perspective matrix transformation of vectors.
**Note**:
The function transforms a sparse set of 2D or 3D vectors. If you want to transform an image using perspective transformation, use
-:func:`warpPerspective` . If you have an inverse task, that is, you want to compute the most probable perspective transformation out of several pairs of corresponding points, you can use
-:func:`getPerspectiveTransform` or
-:func:`findHomography` .
+:cpp:func:`warpPerspective` . If you have an inverse task, that is, you want to compute the most probable perspective transformation out of several pairs of corresponding points, you can use
+:cpp:func:`getPerspectiveTransform` or
+:cpp:func:`findHomography` .
See Also:
-:func:`transform`,
-:func:`warpPerspective`,
-:func:`getPerspectiveTransform`,
-:func:`findHomography`
+:cpp:func:`transform`,
+:cpp:func:`warpPerspective`,
+:cpp:func:`getPerspectiveTransform`,
+:cpp:func:`findHomography`
.. index:: phase
-.. _phase:
-
phase
-----
-.. c:function:: void phase(const Mat& x, const Mat& y, Mat& angle, bool angleInDegrees=false)
+.. cpp:function:: void phase(InputArray x, InputArray y, OutputArray angle, bool angleInDegrees=false)
Calculates the rotation angle of 2d vectors.
.. index:: polarToCart
-.. _polarToCart:
-
polarToCart
-----------
-.. c:function:: void polarToCart(const Mat& magnitude, const Mat& angle, Mat& x, Mat& y, bool angleInDegrees=false)
+.. cpp:function:: void polarToCart(InputArray magnitude, InputArray angle, OutputArray x, OutputArray y, bool angleInDegrees=false)
Computes x and y coordinates of 2D vectors from their magnitude and angle.
:math:`\sim\,10^{-6}` .
See Also:
-:func:`cartToPolar`,
-:func:`magnitude`,
-:func:`phase`,
-:func:`exp`,
-:func:`log`,
-:func:`pow`,
-:func:`sqrt`
+:cpp:func:`cartToPolar`,
+:cpp:func:`magnitude`,
+:cpp:func:`phase`,
+:cpp:func:`exp`,
+:cpp:func:`log`,
+:cpp:func:`pow`,
+:cpp:func:`sqrt`
.. index:: pow
-.. _pow:
-
pow
---
-.. c:function:: void pow(const Mat& src, double p, Mat& dst)
-
-.. c:function:: void pow(const MatND& src, double p, MatND& dst)
+.. cpp:function:: void pow(InputArray src, double p, OutputArray dst)
Raises every array element to a power.
For some values of ``p`` , such as integer values, 0.5 and -0.5, specialized faster algorithms are used.
See Also:
-:func:`sqrt`,
-:func:`exp`,
-:func:`log`,
-:func:`cartToPolar`,
-:func:`polarToCart`
+:cpp:func:`sqrt`,
+:cpp:func:`exp`,
+:cpp:func:`log`,
+:cpp:func:`cartToPolar`,
+:cpp:func:`polarToCart`
.. index:: RNG
-.. _RNG:
-
RNG
---
+.. cpp:class: RNG
+
Random number generator class ::
class CV_EXPORTS RNG
// fills thec array with random numbers sampled from the specified distribution
void fill( Mat& mat, int distType, const Scalar& a, const Scalar& b );
- void fill( MatND& mat, int distType, const Scalar& a, const Scalar& b );
// internal state of the RNG (could change in the future)
uint64 state;
.. index:: RNG::RNG
-.. _RNG::RNG:
-
RNG::RNG
------------
-.. c:function:: RNG::RNG()
+.. cpp:function:: RNG::RNG()
-.. c:function:: RNG::RNG(uint64 state)
+.. cpp:function:: RNG::RNG(uint64 state)
RNG constructors
.. index:: RNG::next
-.. _RNG::next:
-
RNG::next
-------------
-.. c:function:: unsigned RNG::next()
+.. cpp:function:: unsigned RNG::next()
Returns the next random number.
.. index:: RNG::operator T
-.. _RNG::operator T:
-
RNG::operator T
---------------
.. index:: RNG::operator ()
-.. _RNG::operator ():
-
RNG::operator ()
--------------------
-.. c:function:: unsigned RNG::operator ()()
+.. cpp:function:: unsigned RNG::operator ()()
-.. c:function:: unsigned RNG::operator ()(unsigned N)
+.. cpp:function:: unsigned RNG::operator ()(unsigned N)
Returns the next random number.
:param N: Upper non-inclusive boundary of the returned random number.
The methods transform the state using the MWC algorithm and return the next random number. The first form is equivalent to
-:func:`RNG::next` . The second form returns the random number modulo ``N`` , which means that the result is in the range ``[0, N)`` .
+:cpp:func:`RNG::next` . The second form returns the random number modulo ``N`` , which means that the result is in the range ``[0, N)`` .
.. index:: RNG::uniform
-.. _RNG::uniform:
-
RNG::uniform
----------------
-.. c:function:: int RNG::uniform(int a, int b)
+.. cpp:function:: int RNG::uniform(int a, int b)
-.. c:function:: float RNG::uniform(float a, float b)
+.. cpp:function:: float RNG::uniform(float a, float b)
-.. c:function:: double RNG::uniform(double a, double b)
+.. cpp:function:: double RNG::uniform(double a, double b)
Returns the next random number sampled from the uniform distribution.
.. index:: RNG::gaussian
-.. _RNG::gaussian:
-
RNG::gaussian
-----------------
-.. c:function:: double RNG::gaussian(double sigma)
+.. cpp:function:: double RNG::gaussian(double sigma)
Returns the next random number sampled from the Gaussian distribution.
.. index:: RNG::fill
-.. _RNG::fill:
-
RNG::fill
-------------
-.. c:function:: void RNG::fill( Mat& mat, int distType, const Scalar& a, const Scalar& b )
-
-.. c:function:: void RNG::fill( MatND& mat, int distType, const Scalar& a, const Scalar& b )
+.. cpp:function:: void RNG::fill( InputOutputArray mat, int distType, InputArray a, InputArray b )
Fills arrays with random numbers.
- :param mat: 2D or N-dimensional matrix. Currently matrices with more than 4 channels are not supported by the methods. Use :func:`reshape` as a possible workaround.
+ :param mat: 2D or N-dimensional matrix. Currently matrices with more than 4 channels are not supported by the methods. Use :cpp:func:`reshape` as a possible workaround.
:param distType: Distribution type, ``RNG::UNIFORM`` or ``RNG::NORMAL`` .
:param a: The first distribution parameter. In case of the uniform distribution, this is an inclusive lower boundary. In case of the normal distribution, this is a mean value.
- :param b: The second distribution parameter. In case of the uniform distribution, this is a non-inclusive upper boundary. In case of the normal distribution, this is a standard deviation.
+ :param b: The second distribution parameter. In case of the uniform distribution, this is a non-inclusive upper boundary. In case of the normal distribution, this is a standard deviation (diagonal of the standard deviation matrix or the full standard deviation matrix).
Each of the methods fills the matrix with the random values from the specified distribution. As the new numbers are generated, the RNG state is updated accordingly. In case of multiple-channel images, every channel is filled independently, which means that RNG cannot generate samples from the multi-dimensional Gaussian distribution with non-diagonal covariation matrix directly. To do that, first, generate matrix from the distribution
:math:`N(0, I_n)` (Gaussian distribution with zero mean and identity covariation matrix) and then transform it using
-:func:`transform` and the specific covariation matrix.
+:cpp:func:`transform` and the specific covariation matrix.
.. index:: randu
-.. _randu:
-
randu
-----
-.. c:function:: template<typename _Tp> _Tp randu()
+.. cpp:function:: template<typename _Tp> _Tp randu()
-.. c:function:: void randu(Mat& mtx, const Scalar& low, const Scalar& high)
+.. cpp:function:: void randu(InputOutputArray mtx, InputArray low, InputArray high)
Generates a single uniformly-distributed random number or an array of random numbers.
- :param mtx: Output array of random numbers. The array must be pre-allocated and have 1 to 4 channels.
+ :param mtx: Output array of random numbers. The array must be pre-allocated.
:param low: Inclusive lower boundary of the generated random numbers.
:param high: Exclusive upper boundary of the generated random numbers.
The template functions ``randu`` generate and return the next uniformly-distributed random value of the specified type. ``randu<int>()`` is an equivalent to ``(int)theRNG();`` , and so on. See
-:func:`RNG` description.
+:cpp:func:`RNG` description.
The second non-template variant of the function fills the matrix ``mtx`` with uniformly-distributed random numbers from the specified range:
\texttt{low} _c \leq \texttt{mtx} (I)_c < \texttt{high} _c
See Also:
-:func:`RNG`,
-:func:`randn`,
-:func:`theRNG`
+:cpp:func:`RNG`,
+:cpp:func:`randn`,
+:cpp:func:`theRNG`
.. index:: randn
-.. _randn:
-
randn
-----
-.. c:function:: void randn(Mat& mtx, const Scalar& mean, const Scalar& stddev)
+.. cpp:function:: void randn(InputOutputArray mtx, InputArray mean, InputArray stddev)
Fills the array with normally distributed random numbers.
:param mean: Mean value (expectation) of the generated random numbers.
- :param stddev: Standard deviation of the generated random numbers.
+ :param stddev: Standard deviation of the generated random numbers. It can be either a vector (in which case a diagonal standard deviation matrix is assumed) or a square matrix.
-The function ``randn`` fills the matrix ``mtx`` with normally distributed random numbers with the specified mean and standard deviation. The generated random numbers are clipped to fit the value range of the destination array data type.
+The function ``randn`` fills the matrix ``mtx`` with normally distributed random numbers with the specified mean vector and the standard deviation matrix. The generated random numbers are clipped to fit the value range of the destination array data type.
See Also:
-:func:`RNG`,
-:func:`randu`
+:cpp:func:`RNG`,
+:cpp:func:`randu`
.. index:: randShuffle
-.. randShuffle:
-
randShuffle
-----------
-.. c:function:: void randShuffle(Mat& mtx, double iterFactor=1., RNG* rng=0)
+.. cpp:function:: void randShuffle(InputOutputArray mtx, double iterFactor=1., RNG* rng=0)
Shuffles the array elements randomly.
:param iterFactor: Scale factor that determines the number of random swap operations. See the details below.
- :param rng: Optional random number generator used for shuffling. If it is zero, :func:`theRNG` () is used instead.
+ :param rng: Optional random number generator used for shuffling. If it is zero, :cpp:func:`theRNG` () is used instead.
The function ``randShuffle`` shuffles the specified 1D array by randomly choosing pairs of elements and swapping them. The number of such swap operations will be ``mtx.rows*mtx.cols*iterFactor`` .
See Also:
-:func:`RNG`,
-:func:`sort`
+:cpp:func:`RNG`,
+:cpp:func:`sort`
.. index:: reduce
-.. _reduce:
-
reduce
------
-.. c:function:: void reduce(const Mat& mtx, Mat& vec, int dim, int reduceOp, int dtype=-1)
+.. cpp:function:: void reduce(InputArray mtx, OutputArray vec, int dim, int reduceOp, int dtype=-1)
Reduces a matrix to a vector.
The function ``reduce`` reduces the matrix to a vector by treating the matrix rows/columns as a set of 1D vectors and performing the specified operation on the vectors until a single row/column is obtained. For example, the function can be used to compute horizontal and vertical projections of a raster image. In case of ``CV_REDUCE_SUM`` and ``CV_REDUCE_AVG`` , the output may have a larger element bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction modes.
-See Also: :func:`repeat`
+See Also: :cpp:func:`repeat`
.. index:: repeat
-.. _repeat:
-
repeat
------
-.. c:function:: void repeat(const Mat& src, int ny, int nx, Mat& dst)
+.. cpp:function:: void repeat(InputArray src, int ny, int nx, OutputArray dst)
-.. c:function:: Mat repeat(const Mat& src, int ny, int nx)
+.. cpp:function:: Mat repeat(InputArray src, int ny, int nx)
Fills the destination array with repeated copies of the source array.
:param nx: Flag to specify how many times the ``src`` is repeated along the horizontal axis.
The functions
-:func:`repeat` duplicate the source array one or more times along each of the two axes:
+:cpp:func:`repeat` duplicate the source array one or more times along each of the two axes:
.. math::
:ref:`MatrixExpressions` .
See Also:
-:func:`reduce`,
+:cpp:func:`reduce`,
:ref:`MatrixExpressions`
.. index:: saturate_cast
-.. _saturate_cast_:
-
saturate_cast
-------------
-.. c:function:: template<typename _Tp> inline _Tp saturate_cast(unsigned char v)
+.. cpp:function:: template<typename _Tp> inline _Tp saturate_cast(unsigned char v)
-.. c:function:: template<typename _Tp> inline _Tp saturate_cast(signed char v)
+.. cpp:function:: template<typename _Tp> inline _Tp saturate_cast(signed char v)
-.. c:function:: template<typename _Tp> inline _Tp saturate_cast(unsigned short v)
+.. cpp:function:: template<typename _Tp> inline _Tp saturate_cast(unsigned short v)
-.. c:function:: template<typename _Tp> inline _Tp saturate_cast(signed short v)
+.. cpp:function:: template<typename _Tp> inline _Tp saturate_cast(signed short v)
-.. c:function:: template<typename _Tp> inline _Tp saturate_cast(int v)
+.. cpp:function:: template<typename _Tp> inline _Tp saturate_cast(int v)
-.. c:function:: template<typename _Tp> inline _Tp saturate_cast(unsigned int v)
+.. cpp:function:: template<typename _Tp> inline _Tp saturate_cast(unsigned int v)
-.. c:function:: template<typename _Tp> inline _Tp saturate_cast(float v)
+.. cpp:function:: template<typename _Tp> inline _Tp saturate_cast(float v)
-.. c:function:: template<typename _Tp> inline _Tp saturate_cast(double v)
+.. cpp:function:: template<typename _Tp> inline _Tp saturate_cast(double v)
Template function for accurate conversion from one primitive type to another.
This operation is used in the simplest or most complex image processing functions in OpenCV.
See Also:
-:func:`add`,
-:func:`subtract`,
-:func:`multiply`,
-:func:`divide`,
-:func:`Mat::convertTo`
+:cpp:func:`add`,
+:cpp:func:`subtract`,
+:cpp:func:`multiply`,
+:cpp:func:`divide`,
+:cpp:func:`Mat::convertTo`
.. index:: scaleAdd
-.. _scaleAdd:
-
scaleAdd
--------
-.. c:function:: void scaleAdd(const Mat& src1, double scale, const Mat& src2, Mat& dst)
-
-.. c:function:: void scaleAdd(const MatND& src1, double scale, const MatND& src2, MatND& dst)
+.. cpp:function:: void scaleAdd(InputArray src1, double scale, InputArray src2, OutputArray dst)
Calculates the sum of a scaled array and another array.
See Also:
-:func:`add`,
-:func:`addWeighted`,
-:func:`subtract`,
-:func:`Mat::dot`,
-:func:`Mat::convertTo`,
+:cpp:func:`add`,
+:cpp:func:`addWeighted`,
+:cpp:func:`subtract`,
+:cpp:func:`Mat::dot`,
+:cpp:func:`Mat::convertTo`,
:ref:`MatrixExpressions`
.. index:: setIdentity
-.. _setIdentity:
-
setIdentity
-----------
-.. c:function:: void setIdentity(Mat& dst, const Scalar& value=Scalar(1))
+.. cpp:function:: void setIdentity(InputOutputArray dst, const Scalar& value=Scalar(1))
Initializes a scaled identity matrix.
:param value: Value to assign to diagonal elements.
The function
-:func:`setIdentity` initializes a scaled identity matrix:
+:cpp:func:`setIdentity` initializes a scaled identity matrix:
.. math::
See Also:
-:func:`Mat::zeros`,
-:func:`Mat::ones`,
+:cpp:func:`Mat::zeros`,
+:cpp:func:`Mat::ones`,
:ref:`MatrixExpressions`,
-:func:`Mat::setTo`,
-:func:`Mat::operator=`
+:cpp:func:`Mat::setTo`,
+:cpp:func:`Mat::operator=`
.. index:: solve
-.. _solve:
-
solve
-----
-.. c:function:: bool solve(const Mat& src1, const Mat& src2, Mat& dst, int flags=DECOMP_LU)
+.. cpp:function:: bool solve(InputArray src1, InputArray src2, OutputArray dst, int flags=DECOMP_LU)
Solves one or more linear systems or least-squares problems.
If you want to find a unity-norm solution of an under-defined singular system
:math:`\texttt{src1}\cdot\texttt{dst}=0` , the function ``solve`` will not do the work. Use
-:func:`SVD::solveZ` instead.
+:cpp:func:`SVD::solveZ` instead.
See Also:
-:func:`invert`,
-:func:`SVD`,
-:func:`eigen`
+:cpp:func:`invert`,
+:cpp:class:`SVD`,
+:cpp:func:`eigen`
.. index:: solveCubic
-.. _solveCubic:
-
solveCubic
--------------
-.. c:function:: void solveCubic(const Mat& coeffs, Mat& roots)
+.. cpp:function:: void solveCubic(InputArray coeffs, OutputArray roots)
Finds the real roots of a cubic equation.
.. index:: solvePoly
-.. _solvePoly:
-
solvePoly
---------
-.. c:function:: void solvePoly(const Mat& coeffs, Mat& roots, int maxIters=20, int fig=100)
+.. cpp:function:: void solvePoly(InputArray coeffs, OutputArray roots, int maxIters=20, int fig=100)
Finds the real or complex roots of a polynomial equation.
.. index:: sort
-.. _sort:
-
sort
----
-.. c:function:: void sort(const Mat& src, Mat& dst, int flags)
+.. cpp:function:: void sort(InputArray src, OutputArray dst, int flags)
Sorts each row or each column of a matrix.
The function ``sort`` sorts each matrix row or each matrix column in ascending or descending order. So you should pass two operation flags to get desirable behaviour. If you want to sort matrix rows or columns lexicographically, you can use STL ``std::sort`` generic function with the proper comparison predicate.
See Also:
-:func:`sortIdx`,
-:func:`randShuffle`
+:cpp:func:`sortIdx`,
+:cpp:func:`randShuffle`
.. index:: sortIdx
-.. _sortIdx:
-
sortIdx
-------
-.. c:function:: void sortIdx(const Mat& src, Mat& dst, int flags)
+.. cpp:function:: void sortIdx(InputArray src, OutputArray dst, int flags)
Sorts each row or each column of a matrix.
See Also:
-:func:`sort`,
-:func:`randShuffle`
+:cpp:func:`sort`,
+:cpp:func:`randShuffle`
.. index:: split
-.. _split:
-
split
-----
-.. c:function:: void split(const Mat& mtx, Mat* mv)
+.. cpp:function:: void split(const Mat& mtx, Mat* mv)
-.. c:function:: void split(const Mat& mtx, vector<Mat>& mv)
-
-.. c:function:: void split(const MatND& mtx, MatND* mv)
-
-.. c:function:: void split(const MatND& mtx, vector<MatND>& mv)
+.. cpp:function:: void split(const Mat& mtx, vector<Mat>& mv)
Divides a multi-channel array into several single-channel arrays.
:param mtx: Source multi-channel array.
- :param mv: Destination array or vector of arrays. The number of arrays must match ``mtx.channels()`` . The arrays themselves are reallocated, if needed.
+ :param mv: Destination array or vector of arrays. In the first variant of the function the number of arrays must match ``mtx.channels()`` . The arrays themselves are reallocated, if needed.
The functions ``split`` split a multi-channel array into separate single-channel arrays:
\texttt{mv} [c](I) = \texttt{mtx} (I)_c
If you need to extract a single channel or do some other sophisticated channel permutation, use
-:func:`mixChannels` .
+:cpp:func:`mixChannels` .
See Also:
-:func:`merge`,
-:func:`mixChannels`,
-:func:`cvtColor`
+:cpp:func:`merge`,
+:cpp:func:`mixChannels`,
+:cpp:func:`cvtColor`
.. index:: sqrt
-.. _sqrt:
-
sqrt
----
-.. c:function:: void sqrt(const Mat& src, Mat& dst)
-
-.. c:function:: void sqrt(const MatND& src, MatND& dst)
+.. cpp:function:: void sqrt(InputArray src, OutputArray dst)
Calculates a quare root of array elements.
The functions ``sqrt`` calculate a square root of each source array element. In case of multi-channel arrays, each channel is processed independently. The accuracy is approximately the same as of the built-in ``std::sqrt`` .
See Also:
-:func:`pow`,
-:func:`magnitude`
+:cpp:func:`pow`,
+:cpp:func:`magnitude`
.. index:: subtract
-.. _subtract:
-
subtract
--------
-.. c:function:: void subtract(const Mat& src1, const Mat& src2, Mat& dst)
-
-.. c:function:: void subtract(const Mat& src1, const Mat& src2, Mat& dst, const Mat& mask)
-
-.. c:function:: void subtract(const Mat& src1, const Scalar& sc, Mat& dst, const Mat& mask=Mat())
-
-.. c:function:: void subtract(const Scalar& sc, const Mat& src2, Mat& dst, const Mat& mask=Mat())
-
-.. c:function:: void subtract(const MatND& src1, const MatND& src2, MatND& dst)
-
-.. c:function:: void subtract(const MatND& src1, const MatND& src2, MatND& dst, const MatND& mask)
-
-.. c:function:: void subtract(const MatND& src1, const Scalar& sc, MatND& dst, const MatND& mask=MatND())
-
-.. c:function:: void subtract(const Scalar& sc, const MatND& src2, MatND& dst, const MatND& mask=MatND())
+.. cpp:function:: void subtract(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=None(), int dtype=-1)
Calculates the per-element difference between two arrays or array and a scalar.
- :param src1: The first source array.
+ :param src1: The first source array or a scalar.
- :param src2: The second source array. It must have the same size and same type as ``src1`` .
+ :param src2: The second source array or a scalar.
- :param sc: Scalar that could be the first or the second input parameter.
-
- :param dst: Destination array of the same size and type as ``src1`` . See ``Mat::create`` .
+ :param dst: Destination array of the same size and the same number of channels as the input array.
:param mask: Optional operation mask. This is an 8-bit single channel array that specifies elements of the destination array to be changed.
+
+ :param dtype: Optional depth of the output array. See the discussion below.
-The functions ``subtract`` compute the following values:
+The function ``subtract`` computes:
-*
- Difference between two arrays
+ #.
+ the difference between two arrays, when both input arrays have the same size and the same number of channels:
.. math::
- \texttt{dst} (I) = \texttt{saturate} ( \texttt{src1} (I) - \texttt{src2} (I)) \quad \texttt{if mask} (I) \ne0
+ \texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0
-*
- Difference between an array and a scalar:
+ #.
+ the difference between an array and a scalar, when ``src2`` is constructed from ``Scalar`` or has the same number of elements as ``src1.channels()``:
.. math::
- \texttt{dst} (I) = \texttt{saturate} ( \texttt{src1} (I) - \texttt{sc} ) \quad \texttt{if mask} (I) \ne0
+ \texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0
-*
- Difference between a scalar and an array:
+ #.
+ or the difference between a scalar and an array, when ``src1`` is constructed from ``Scalar`` or has the same number of elements as ``src2.channels()``:
.. math::
- \texttt{dst} (I) = \texttt{saturate} ( \texttt{sc} - \texttt{src2} (I)) \quad \texttt{if mask} (I) \ne0
+ \texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0
-where ``I`` is a multi-dimensional index of the array elements.
+where ``I`` is a multi-dimensional index of array elements. In case of multi-channel arrays, each channel is processed independently.
-The first function in the above list can be replaced with matrix expressions: ::
+The first function in the list above can be replaced with matrix expressions: ::
dst = src1 - src2;
- dst -= src2; // equivalent to subtract(dst, src2, dst);
+ dst -= src1; // equivalent to subtract(dst, src1, dst);
+The input arrays and the destination array can all have the same or different depths. For example, you can subtract to 8-bit unsigned arrays and store the difference in 16-bit signed array. Depth of the output array is determined by ``dtype`` parameter. In the 2nd and 3rd cases above, as well as in the first case, when ``src1.depth() == src2.depth()``, ``dtype`` can be set to the default ``-1``. In this case the output array will have the same depth as the input array, be it ``src1``, ``src2`` or both.
See Also:
-:func:`add`,
-:func:`addWeighted`,
-:func:`scaleAdd`,
-:func:`convertScale`,
+:cpp:func:`add`,
+:cpp:func:`addWeighted`,
+:cpp:func:`scaleAdd`,
+:cpp:func:`convertScale`,
:ref:`MatrixExpressions`
.. index:: SVD
-.. _SVD:
-
SVD
---
-.. c:type:: SVD
+.. cpp:class:: SVD
Class for computing Singular Value Decomposition ::
// finds vector x, norm(x)=1, so that A*x = 0,
// where A is a singular matrix
- static void solveZ( const Mat& A, Mat& x );
+ static void solveZ( const Mat& A, OutputArray x );
// does back-subsitution:
// x = vt.t()*inv(w)*u.t()*rhs ~ inv(A)*rhs
- void backSubst( const Mat& rhs, Mat& x ) const;
+ void backSubst( const Mat& rhs, OutputArray x ) const;
Mat u; // the left orthogonal matrix
Mat w; // vector of singular values
For a bit faster operation, you can pass ``flags=SVD::MODIFY_A|...`` to modify the decomposed matrix when it is not necessary to preserve it. If you want to compute a condition number of a matrix or an absolute value of its determinant, you do not need ``u`` and ``vt`` . You can pass ``flags=SVD::NO_UV|...`` . Another flag ``FULL_UV`` indicates that full-size ``u`` and ``vt`` must be computed, which is not necessary most of the time.
See Also:
-:func:`invert`,
-:func:`solve`,
-:func:`eigen`,
-:func:`determinant`
+:cpp:func:`invert`,
+:cpp:func:`solve`,
+:cpp:func:`eigen`,
+:cpp:func:`determinant`
.. index:: SVD::SVD
-.. _SVD::SVD:
-
SVD::SVD
--------
-.. c:function:: SVD::SVD()
+.. cpp:function:: SVD::SVD()
-.. c:function:: SVD::SVD( const Mat& A, int flags=0 )
+.. cpp:function:: SVD::SVD( InputArray A, int flags=0 )
SVD constructors
* **SVD::FULL_UV** When the matrix is not square, by default the algorithm produces ``u`` and ``vt`` matrices of sufficiently large size for the further ``A`` reconstruction. If, however, ``FULL_UV`` flag is specified, ``u`` and ``vt`` will be full-size square orthogonal matrices.
The first constructor initializes an empty ``SVD`` structure. The second constructor initializes an empty ``SVD`` structure and then calls
-:func:`SVD::operator ()` .
+:cpp:func:`SVD::operator ()` .
.. index:: SVD::operator ()
-.. _SVD::operator ():
-
SVD::operator ()
----------------
-.. c:function:: SVD& SVD::operator ()( const Mat& A, int flags=0 )
+.. cpp:function:: SVD& SVD::operator ()( InputArray A, int flags=0 )
Performs SVD of a matrix.
* **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, the ``FULL_UV`` flag is specified, ``u`` and ``vt`` are full-size square orthogonal matrices.
The operator performs the singular value decomposition of the supplied matrix. The ``u``,``vt`` , and the vector of singular values ``w`` are stored in the structure. The same ``SVD`` structure can be reused many times with different matrices. Each time, if needed, the previous ``u``,``vt`` , and ``w`` are reclaimed and the new matrices are created, which is all handled by
-:func:`Mat::create` .
+:cpp:func:`Mat::create` .
.. index:: SVD::solveZ
-.. _SVD::solveZ:
-
SVD::solveZ
-----------
-.. c:function:: static void SVD::solveZ( const Mat& A, Mat& x )
+.. cpp:function:: static void SVD::solveZ( InputArray A, OutputArray x )
Solves an under-determined singular linear system.
.. index:: SVD::backSubst
-.. _SVD::backSubst:
-
SVD::backSubst
--------------
-.. c:function:: void SVD::backSubst( const Mat& rhs, Mat& x ) const
+.. cpp:function:: void SVD::backSubst( InputArray rhs, OutputArray x ) const
Performs a singular value back substitution.
- :param rhs: Right-hand side of a linear system :math:`\texttt{A} \texttt{x} = \texttt{rhs}` to be solved, where ``A`` is the matrix passed to :func:`SVD::SVD` or :func:`SVD::operator ()` .
+ :param rhs: Right-hand side of a linear system :math:`\texttt{A} \texttt{x} = \texttt{rhs}` to be solved, where ``A`` is the matrix passed to :cpp:func:`SVD::SVD` or :cpp:func:`SVD::operator ()` .
:param x: Found solution of the system.
**Note**
Explicit SVD with the further back substitution only makes sense if you need to solve many linear systems with the same left-hand side (for example, ``A`` ). If all you need is to solve a single system (possibly with multiple ``rhs`` immediately available), simply call
-:func:`solve` add pass ``DECOMP_SVD`` there. It does absolutely the same thing.
+:cpp:func:`solve` add pass ``DECOMP_SVD`` there. It does absolutely the same thing.
.. index:: sum
-.. _sum:
-
sum
---
-.. c:function:: Scalar sum(const Mat& mtx)
-
-.. c:function:: Scalar sum(const MatND& mtx)
+.. cpp:function:: Scalar sum(InputArray mtx)
Calculates the sum of array elements.
The functions ``sum`` calculate and return the sum of array elements, independently for each channel.
See Also:
-:func:`countNonZero`,
-:func:`mean`,
-:func:`meanStdDev`,
-:func:`norm`,
-:func:`minMaxLoc`,
-:func:`reduce`
+:cpp:func:`countNonZero`,
+:cpp:func:`mean`,
+:cpp:func:`meanStdDev`,
+:cpp:func:`norm`,
+:cpp:func:`minMaxLoc`,
+:cpp:func:`reduce`
.. index:: theRNG
theRNG
------
-.. c:function:: RNG& theRNG()
+.. cpp:function:: RNG& theRNG()
Returns the default random number generator.
The function ``theRNG`` returns the default random number generator. For each thread, there is a separate random number generator, so you can use the function safely in multi-thread environments. If you just need to get a single random number using this generator or initialize an array, you can use
-:func:`randu` or
-:func:`randn` instead. But if you are going to generate many random numbers inside a loop, it is much faster to use this function to retrieve the generator and then use ``RNG::operator _Tp()`` .
+:cpp:func:`randu` or
+:cpp:func:`randn` instead. But if you are going to generate many random numbers inside a loop, it is much faster to use this function to retrieve the generator and then use ``RNG::operator _Tp()`` .
See Also:
-:func:`RNG`,
-:func:`randu`,
-:func:`randn`
+:cpp:func:`RNG`,
+:cpp:func:`randu`,
+:cpp:func:`randn`
.. index:: trace
-.. _trace:
-
trace
-----
-.. c:function:: Scalar trace(const Mat& mtx)
+.. cpp:function:: Scalar trace(InputArray mtx)
Returns the trace of a matrix.
.. index:: transform
-.. _transform:
-
transform
---------
-.. c:function:: void transform(const Mat& src, Mat& dst, const Mat& mtx )
+.. cpp:function:: void transform(InputArray src, OutputArray dst, InputArray mtx )
Performs the matrix transformation of every array element.
:math:`\rightarrow` YUV transforms), shuffling the image channels, and so forth.
See Also:
-:func:`perspectiveTransform`,
-:func:`getAffineTransform`,
-:func:`estimateRigidTransform`,
-:func:`warpAffine`,
-:func:`warpPerspective`
+:cpp:func:`perspectiveTransform`,
+:cpp:func:`getAffineTransform`,
+:cpp:func:`estimateRigidTransform`,
+:cpp:func:`warpAffine`,
+:cpp:func:`warpPerspective`
.. index:: transpose
-.. _transpose:
-
transpose
---------
-.. c:function:: void transpose(const Mat& src, Mat& dst)
+.. cpp:function:: void transpose(InputArray src, OutputArray dst)
Transposes a matrix.
:param dst: Destination array of the same type as ``src`` .
-The function :func:`transpose` transposes the matrix ``src`` :
+The function :cpp:func:`transpose` transposes the matrix ``src`` :
.. math::
alignPtr
------------
-.. c:function:: template<typename _Tp> _Tp* alignPtr(_Tp* ptr, int n=sizeof(_Tp))
+.. cpp:function:: template<typename _Tp> _Tp* alignPtr(_Tp* ptr, int n=sizeof(_Tp))
Aligns a pointer to the specified number of bytes.
alignSize
-------------
-.. c:function:: size_t alignSize(size_t sz, int n)
+.. cpp:function:: size_t alignSize(size_t sz, int n)
Aligns a buffer size to the specified number of bytes.
allocate
------------
-.. c:function:: template<typename _Tp> _Tp* allocate(size_t n)
+.. cpp:function:: template<typename _Tp> _Tp* allocate(size_t n)
Allocates an array of elements.
deallocate
--------------
-.. c:function:: template<typename _Tp> void deallocate(_Tp* ptr, size_t n)
+.. cpp:function:: template<typename _Tp> void deallocate(_Tp* ptr, size_t n)
Deallocates an array of elements.
:param n: Number of elements in the buffer.
The generic function ``deallocate`` deallocates the buffer allocated with
-:func:`allocate` . The number of elements must match the number passed to
-:func:`allocate` .
+:cpp:func:`allocate` . The number of elements must match the number passed to
+:cpp:func:`allocate` .
.. index:: CV_Assert
CV_Assert
---------
-.. c:function:: CV_Assert(expr)
+.. cpp:function:: CV_Assert(expr)
Checks a condition at runtime. ::
:param expr: Expression to check.
The macros ``CV_Assert`` and ``CV_DbgAssert`` evaluate the specified expression. If it is 0, the macros raise an error (see
-:func:`error` ). The macro ``CV_Assert`` checks the condition in both Debug and Release configurations, while ``CV_DbgAssert`` is only retained in the Debug configuration.
+:cpp:func:`error` ). The macro ``CV_Assert`` checks the condition in both Debug and Release configurations, while ``CV_DbgAssert`` is only retained in the Debug configuration.
.. index:: error
error
---------
-.. c:function:: void error( const Exception\& exc )
+.. cpp:function:: void error( const Exception\& exc )
-.. c:function:: \#define CV_Error( code, msg ) <...>
+.. cpp:function:: \#define CV_Error( code, msg ) <...>
-.. c:function:: \#define CV_Error_( code, args ) <...>
+.. cpp:function:: \#define CV_Error_( code, args ) <...>
Signals an error and raises an exception.
};
The class ``Exception`` encapsulates all or almost all the necessary information about the error happened in the program. The exception is usually constructed and thrown implicitly via ``CV_Error`` and ``CV_Error_`` macros. See
-:func:`error` .
+:cpp:func:`error` .
.. index:: fastMalloc
fastMalloc
--------------
-.. c:function:: void* fastMalloc(size_t size)
+.. cpp:function:: void* fastMalloc(size_t size)
Allocates an aligned memory buffer.
fastFree
------------
-.. c:function:: void fastFree(void* ptr)
+.. cpp:function:: void fastFree(void* ptr)
Deallocates a memory buffer.
:param ptr: Pointer to the allocated buffer.
The function deallocates the buffer allocated with
-:func:`fastMalloc` .
+:cpp:func:`fastMalloc` .
If NULL pointer is passed, the function does nothing.
.. index:: format
format
----------
-.. c:function:: string format( const char* fmt, ... )
+.. cpp:function:: string format( const char* fmt, ... )
Returns a text string formatted using the ``printf`` -like expression.
:param fmt: ``printf`` -compatible formatting specifiers.
The function acts like ``sprintf`` but forms and returns an STL string. It can be used to form an error message in the
-:func:`Exception` constructor.
+:cpp:func:`Exception` constructor.
.. index:: getNumThreads
getNumThreads
-----------------
-.. c:function:: int getNumThreads()
+.. cpp:function:: int getNumThreads()
Returns the number of threads used by OpenCV.
The function returns the number of threads that is used by OpenCV.
See Also:
-:func:`setNumThreads`,
-:func:`getThreadNum`
+:cpp:func:`setNumThreads`,
+:cpp:func:`getThreadNum`
.. index:: getThreadNum
getThreadNum
----------------
-.. c:function:: int getThreadNum()
+.. cpp:function:: int getThreadNum()
Returns the index of the currently executed thread.
The function returns a 0-based index of the currently executed thread. The function is only valid inside a parallel OpenMP region. When OpenCV is built without OpenMP support, the function always returns 0.
See Also:
-:func:`setNumThreads`,
-:func:`getNumThreads` .
+:cpp:func:`setNumThreads`,
+:cpp:func:`getNumThreads` .
.. index:: getTickCount
getTickCount
----------------
-.. c:function:: int64 getTickCount()
+.. cpp:function:: int64 getTickCount()
Returns the number of ticks.
The function returns the number of ticks after the certain event (for example, when the machine was turned on).
It can be used to initialize
-:func:`RNG` or to measure a function execution time by reading the tick count before and after the function call. See also the tick frequency.
+:cpp:func:`RNG` or to measure a function execution time by reading the tick count before and after the function call. See also the tick frequency.
.. index:: getTickFrequency
getTickFrequency
--------------------
-.. c:function:: double getTickFrequency()
+.. cpp:function:: double getTickFrequency()
Returns the number of ticks per second.
setNumThreads
-----------------
-.. c:function:: void setNumThreads(int nthreads)
+.. cpp:function:: void setNumThreads(int nthreads)
Sets the number of threads used by OpenCV.
The function sets the number of threads used by OpenCV in parallel OpenMP regions. If ``nthreads=0`` , the function uses the default number of threads that is usually equal to the number of the processing cores.
See Also:
-:func:`getNumThreads`,
-:func:`getThreadNum`
\ No newline at end of file
+:cpp:func:`getNumThreads`,
+:cpp:func:`getThreadNum`
\ No newline at end of file
template<typename _Tp> static inline _Tp randu() { return (_Tp)theRNG(); }
//! fills array with uniformly-distributed random numbers from the range [low, high)
-CV_EXPORTS_W void randu(CV_IN_OUT OutputArray dst, InputArray low, InputArray high);
+CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high);
//! fills array with normally-distributed random numbers with the specified mean and the standard deviation
-CV_EXPORTS_W void randn(CV_IN_OUT OutputArray dst, InputArray mean, InputArray stddev);
+CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev);
//! shuffles the input array elements
CV_EXPORTS void randShuffle(InputOutputArray dst, double iterFactor=1., RNG* rng=0);
DescriptorExtractor::compute
--------------------------------
-.. c:function:: void DescriptorExtractor::compute( const Mat\& image, vector<KeyPoint>\& keypoints, Mat\& descriptors ) const
+.. cpp:function:: void DescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const
Computes the descriptors for a set of keypoints detected in an image (first variant) or image set (second variant).
:param descriptors: Descriptors. Row i is the descriptor for keypoint i.
-.. c:function:: void DescriptorExtractor::compute( const vector<Mat>\& images, vector<vector<KeyPoint> >\& keypoints, vector<Mat>\& descriptors ) const
+.. cpp:function:: void DescriptorExtractor::compute( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints, vector<Mat>& descriptors ) const
:param images: Image set.
DescriptorExtractor::read
-----------------------------
-.. c:function:: void DescriptorExtractor::read( const FileNode\& fn )
+.. cpp:function:: void DescriptorExtractor::read( const FileNode& fn )
Reads the object of a descriptor extractor from a file node.
DescriptorExtractor::write
------------------------------
-.. c:function:: void DescriptorExtractor::write( FileStorage\& fs ) const
+.. cpp:function:: void DescriptorExtractor::write( FileStorage& fs ) const
Writes the object of a descriptor extractor to a file storage.
DescriptorExtractor::create
-------------------------------
-.. c:function:: Ptr<DescriptorExtractor> DescriptorExtractor::create( const string& descriptorExtractorType )
+.. cpp:function:: Ptr<DescriptorExtractor> DescriptorExtractor::create( const string& descriptorExtractorType )
Creates a descriptor extractor by name.
FAST
--------
-.. c:function:: void FAST( const Mat& image, vector<KeyPoint>& keypoints, int threshold, bool nonmaxSupression=true )
+.. cpp:function:: void FAST( const Mat& image, vector<KeyPoint>& keypoints, int threshold, bool nonmaxSupression=true )
Detects corners using the FAST algorithm by E. Rosten (*Machine learning for high-speed corner detection*, 2006).
RandomizedTree::train
-------------------------
-.. c:function:: void train(std::vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits)
+.. cpp:function:: void train(std::vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits)
Trains a randomized tree using an input set of keypoints.
-.. c:function:: void train(std::vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits)
+.. cpp:function:: void train(std::vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits)
:param base_set: Vector of the ``BaseKeypoint`` type. It contains image keypoints used for training.
RandomizedTree::read
------------------------
-.. c:function:: read(const char* file_name, int num_quant_bits)
+.. cpp:function:: read(const char* file_name, int num_quant_bits)
-.. c:function:: read(std::istream &is, int num_quant_bits)
+.. cpp:function:: read(std::istream &is, int num_quant_bits)
Reads a pre-saved randomized tree from a file or stream.
RandomizedTree::write
-------------------------
-.. c:function:: void write(const char* file_name) const
+.. cpp:function:: void write(const char* file_name) const
Writes the current randomized tree to a file or stream.
-.. c:function:: void write(std::ostream \&os) const
+.. cpp:function:: void write(std::ostream \&os) const
:param file_name: Name of the file where randomized tree data is stored.
RandomizedTree::applyQuantization
-------------------------------------
-.. c:function:: void applyQuantization(int num_quant_bits)
+.. cpp:function:: void applyQuantization(int num_quant_bits)
Applies quantization to the current randomized tree.
RTreeClassifier::train
--------------------------
-.. c:function:: void train(vector<BaseKeypoint> const& base_set, RNG& rng, int num_trees = RTreeClassifier::DEFAULT_TREES, int depth = DEFAULT_DEPTH, int views = DEFAULT_VIEWS, size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM, int num_quant_bits = DEFAULT_NUM_QUANT_BITS, bool print_status = true)
+.. cpp:function:: void train(vector<BaseKeypoint> const& base_set, RNG& rng, int num_trees = RTreeClassifier::DEFAULT_TREES, int depth = DEFAULT_DEPTH, int views = DEFAULT_VIEWS, size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM, int num_quant_bits = DEFAULT_NUM_QUANT_BITS, bool print_status = true)
Trains a randomized tree classifier using an input set of keypoints.
-.. c:function:: void train(vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int num_trees = RTreeClassifier::DEFAULT_TREES, int depth = DEFAULT_DEPTH, int views = DEFAULT_VIEWS, size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM, int num_quant_bits = DEFAULT_NUM_QUANT_BITS, bool print_status = true)
+.. cpp:function:: void train(vector<BaseKeypoint> const& base_set, RNG& rng, PatchGenerator& make_patch, int num_trees = RTreeClassifier::DEFAULT_TREES, int depth = DEFAULT_DEPTH, int views = DEFAULT_VIEWS, size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM, int num_quant_bits = DEFAULT_NUM_QUANT_BITS, bool print_status = true)
:param base_set: Vector of the ``BaseKeypoint`` type. It contains image keypoints used for training.
RTreeClassifier::getSignature
---------------------------------
-.. c:function:: void getSignature(IplImage *patch, uchar *sig)
+.. cpp:function:: void getSignature(IplImage *patch, uchar *sig)
Returns a signature for an image patch.
-.. c:function:: void getSignature(IplImage *patch, float *sig)
+.. cpp:function:: void getSignature(IplImage *patch, float *sig)
:param patch: Image patch to calculate the signature for.
:param sig: Output signature (array dimension is ``reduced_num_dim)`` .
RTreeClassifier::getSparseSignature
---------------------------------------
-.. c:function:: void getSparseSignature(IplImage *patch, float *sig, float thresh)
+.. cpp:function:: void getSparseSignature(IplImage *patch, float *sig, float thresh)
Returns a signature for an image patch similarly to ``getSignature`` but uses a threshold for removing all signature elements below the threshold so that the signature is compressed.
RTreeClassifier::countNonZeroElements
-----------------------------------------
-.. c:function:: static int countNonZeroElements(float *vec, int n, double tol=1e-10)
+.. cpp:function:: static int countNonZeroElements(float *vec, int n, double tol=1e-10)
Returns the number of non-zero elements in an input array.
RTreeClassifier::read
-------------------------
-.. c:function:: read(const char* file_name)
+.. cpp:function:: read(const char* file_name)
Reads a pre-saved ``RTreeClassifier`` from a file or stream.
-.. c:function:: read(std::istream& is)
+.. cpp:function:: read(std::istream& is)
:param file_name: Name of the file that contains randomized tree data.
RTreeClassifier::write
--------------------------
-.. c:function:: void write(const char* file_name) const
+.. cpp:function:: void write(const char* file_name) const
Writes the current ``RTreeClassifier`` to a file or stream.
-.. c:function:: void write(std::ostream &os) const
+.. cpp:function:: void write(std::ostream &os) const
:param file_name: Name of the file where randomized tree data is stored.
RTreeClassifier::setQuantization
------------------------------------
-.. c:function:: void setQuantization(int num_quant_bits)
+.. cpp:function:: void setQuantization(int num_quant_bits)
Applies quantization to the current randomized tree.
BOWTrainer::add
-------------------
-.. c:function:: void BOWTrainer::add( const Mat& descriptors )
+.. cpp:function:: void BOWTrainer::add( const Mat& descriptors )
Adds descriptors to a training set. The training set is clustered using ``clustermethod`` to construct the vocabulary.
BOWTrainer::getDescriptors
------------------------------
-.. c:function:: const vector<Mat>& BOWTrainer::getDescriptors() const
+.. cpp:function:: const vector<Mat>& BOWTrainer::getDescriptors() const
Returns a training set of descriptors.
BOWTrainer::descripotorsCount
---------------------------------
-.. c:function:: const vector<Mat>& BOWTrainer::descripotorsCount() const
+.. cpp:function:: const vector<Mat>& BOWTrainer::descripotorsCount() const
Returns the count of all descriptors stored in the training set.
BOWTrainer::cluster
-----------------------
-.. c:function:: Mat BOWTrainer::cluster() const
+.. cpp:function:: Mat BOWTrainer::cluster() const
Clusters train descriptors. The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first variant of the method, train descriptors stored in the object are clustered. In the second variant, input descriptors are clustered.
-.. c:function:: Mat BOWTrainer::cluster( const Mat& descriptors ) const
+.. cpp:function:: Mat BOWTrainer::cluster( const Mat& descriptors ) const
:param descriptors: Descriptors to cluster. Each row of the ``descriptors`` matrix is a descriptor. Descriptors are not added to the inner train descriptor set.
BOWImgDescriptorExtractor::BOWImgDescriptorExtractor
--------------------------------------------------------
-.. c:function:: BOWImgDescriptorExtractor::BOWImgDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor, const Ptr<DescriptorMatcher>& dmatcher )
+.. cpp:function:: BOWImgDescriptorExtractor::BOWImgDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor, const Ptr<DescriptorMatcher>& dmatcher )
The class constructor.
BOWImgDescriptorExtractor::setVocabulary
--------------------------------------------
-.. c:function:: void BOWImgDescriptorExtractor::setVocabulary( const Mat& vocabulary )
+.. cpp:function:: void BOWImgDescriptorExtractor::setVocabulary( const Mat& vocabulary )
Sets a visual vocabulary.
BOWImgDescriptorExtractor::getVocabulary
--------------------------------------------
-.. c:function:: const Mat& BOWImgDescriptorExtractor::getVocabulary() const
+.. cpp:function:: const Mat& BOWImgDescriptorExtractor::getVocabulary() const
Returns the set vocabulary.
BOWImgDescriptorExtractor::compute
--------------------------------------
-.. c:function:: void BOWImgDescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor, vector<vector<int> >* pointIdxsOfClusters=0, Mat* descriptors=0 )
+.. cpp:function:: void BOWImgDescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor, vector<vector<int> >* pointIdxsOfClusters=0, Mat* descriptors=0 )
Computes an image descriptor using the set visual vocabulary.
BOWImgDescriptorExtractor::descriptorSize
---------------------------------------------
-.. c:function:: int BOWImgDescriptorExtractor::descriptorSize() const
+.. cpp:function:: int BOWImgDescriptorExtractor::descriptorSize() const
Returns an image discriptor size if the vocabulary is set. Otherwise, it returns 0.
BOWImgDescriptorExtractor::descriptorType
---------------------------------------------
-.. c:function:: int BOWImgDescriptorExtractor::descriptorType() const
+.. cpp:function:: int BOWImgDescriptorExtractor::descriptorType() const
Returns an image descriptor type.
:param stream: Stream for the asynchronous version.
-See Also: :c:func:`reprojectImageTo3D` .
+See Also: :c:cpp:func:`reprojectImageTo3D` .
.. index:: gpu::solvePnPRansac
:param camera_mat: 3x3 matrix of intrinsic camera parameters.
- :param dist_coef: Distortion coefficients. See :c:func:`undistortPoints` for details.
+ :param dist_coef: Distortion coefficients. See :c:cpp:func:`undistortPoints` for details.
:param rvec: Output 3D rotation vector.
:param inliers: Output vector of inlier indices.
-See Also :c:func:`solvePnPRansac`.
+See Also :c:cpp:func:`solvePnPRansac`.
\ No newline at end of file
You are not recommended to leave static or global ``GpuMat`` variables allocated, that is to rely on its destructor. The destruction order of such variables and CUDA context is undefined. GPU memory release function returns error if the CUDA context has been destroyed before.
See Also:
-:func:`Mat`
+:cpp:func:`Mat`
.. index:: gpu::CudaMem
.. cpp:class:: gpu::CudaMem
This class with reference counting wraps special memory type allocation functions from CUDA. Its interface is also
-:func:`Mat`-like but with additional memory type parameters.
+:cpp:func:`Mat`-like but with additional memory type parameters.
*
``ALLOC_PAGE_LOCKED``: Sets a page locked memory type, used commonly for fast and asynchronous uploading/downloading data from/to GPU.
Finds the best match for each descriptor from a query set with train descriptors.
See Also:
-:c:func:`DescriptorMatcher::match`
+:c:cpp:func:`DescriptorMatcher::match`
.. index:: gpu::BruteForceMatcher_GPU::matchSingle
Finds the k best matches for each descriptor from a query set with train descriptors. The function returns detected k (or less if not possible) matches in the increasing order by distance.
-.. c:function:: void knnMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >&matches, int k, const std::vector<GpuMat>&masks = std::vector<GpuMat>(), bool compactResult = false )
+.. cpp:function:: void knnMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >&matches, int k, const std::vector<GpuMat>&masks = std::vector<GpuMat>(), bool compactResult = false )
See Also:
-:func:`DescriptorMatcher::knnMatch`
+:cpp:func:`DescriptorMatcher::knnMatch`
.. index:: gpu::BruteForceMatcher_GPU::knnMatch
This function works only on devices with the compute capability :math:`>=` 1.1.
See Also:
-:func:`DescriptorMatcher::radiusMatch`
+:cpp:func:`DescriptorMatcher::radiusMatch`
.. index:: gpu::BruteForceMatcher_GPU::radiusMatch
The class can be used to apply an arbitrary filtering operation to an image. It contains all the necessary intermediate buffers. Pointers to the initialized ``FilterEngine_GPU`` instances are returned by various ``create*Filter_GPU`` functions (see below), and they are used inside high-level functions such as
-:func:`gpu::filter2D`, :func:`gpu::erode`, :func:`gpu::Sobel` , and others.
+:cpp:func:`gpu::filter2D`, :cpp:func:`gpu::erode`, :cpp:func:`gpu::Sobel` , and others.
By using ``FilterEngine_GPU`` instead of functions you can avoid unnecessary memory allocation for intermediate buffers and get much better performance:
::
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`boxFilter`
+See Also: :c:cpp:func:`boxFilter`
.. index:: gpu::boxFilter
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`boxFilter`
+See Also: :c:cpp:func:`boxFilter`
.. index:: gpu::blur
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`blur`, :cpp:func:`gpu::boxFilter`
+See Also: :c:cpp:func:`blur`, :cpp:func:`gpu::boxFilter`
.. index:: gpu::createMorphologyFilter_GPU
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`createMorphologyFilter`
+See Also: :c:cpp:func:`createMorphologyFilter`
.. index:: gpu::erode
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`erode`
+See Also: :c:cpp:func:`erode`
.. index:: gpu::dilate
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`dilate`
+See Also: :c:cpp:func:`dilate`
.. index:: gpu::morphologyEx
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`morphologyEx`
+See Also: :c:cpp:func:`morphologyEx`
.. index:: gpu::createLinearFilter_GPU
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`createLinearFilter`
+See Also: :c:cpp:func:`createLinearFilter`
.. index:: gpu::filter2D
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`filter2D`
+See Also: :c:cpp:func:`filter2D`
.. index:: gpu::Laplacian
:param ddepth: Desired depth of the destination image. It supports only the same depth as the source image depth.
- :param ksize: Aperture size used to compute the second-derivative filters (see :c:func:`getDerivKernels`). It must be positive and odd. Only ``ksize`` = 1 and ``ksize`` = 3 are supported.
+ :param ksize: Aperture size used to compute the second-derivative filters (see :c:cpp:func:`getDerivKernels`). It must be positive and odd. Only ``ksize`` = 1 and ``ksize`` = 3 are supported.
- :param scale: Optional scale factor for the computed Laplacian values. By default, no scaling is applied (see :c:func:`getDerivKernels` ).
+ :param scale: Optional scale factor for the computed Laplacian values. By default, no scaling is applied (see :c:cpp:func:`getDerivKernels` ).
**Note:**
This filter does not check out-of-border accesses, so only a proper sub-matrix of a bigger matrix has to be passed to it.
-See Also: :c:func:`Laplacian`,:func:`gpu::filter2D` .
+See Also: :c:cpp:func:`Laplacian`,:cpp:func:`gpu::filter2D` .
.. index:: gpu::getLinearRowFilter_GPU
:param anchor: Anchor position within the kernel. Negative values mean that the anchor is positioned at the aperture center.
- :param borderType: Pixel extrapolation method. For details, see :c:func:`borderInterpolate`. For details on limitations, see below.
+ :param borderType: Pixel extrapolation method. For details, see :c:cpp: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.
-See Also:,:func:`createSeparableLinearFilter` .
+See Also:,:cpp:func:`createSeparableLinearFilter` .
.. index:: gpu::getLinearColumnFilter_GPU
:param anchor: Anchor position within the kernel. Negative values mean that the anchor is positioned at the aperture center.
- :param borderType: Pixel extrapolation method. For details, see :c:func:`borderInterpolate` . For details on limitations, see below.
+ :param borderType: Pixel extrapolation method. For details, see :c:cpp:func:`borderInterpolate` . For details on limitations, see below.
There are two versions of the algorithm: NPP and OpenCV.
* NPP version is called when ``dstType == CV_8UC1`` or ``dstType == CV_8UC4`` and ``bufType == dstType`` . 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 image.
-See Also: :cpp:func:`gpu::getLinearRowFilter_GPU`, :c:func:`createSeparableLinearFilter`
+See Also: :cpp:func:`gpu::getLinearRowFilter_GPU`, :c:cpp:func:`createSeparableLinearFilter`
.. index:: gpu::createSeparableLinearFilter_GPU
: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 :c:func:`borderInterpolate`. For details on limitations, see :cpp:func:`gpu::getLinearRowFilter_GPU`, cpp:func:`gpu::getLinearColumnFilter_GPU`.
+ :param rowBorderType, columnBorderType: Pixel extrapolation method in the horizontal and vertical directions For details, see :c:cpp:func:`borderInterpolate`. For details on limitations, see :cpp:func:`gpu::getLinearRowFilter_GPU`, cpp:cpp:func:`gpu::getLinearColumnFilter_GPU`.
-See Also: :cpp:func:`gpu::getLinearRowFilter_GPU`, :cpp:func:`gpu::getLinearColumnFilter_GPU`, :c:func:`createSeparableLinearFilter`
+See Also: :cpp:func:`gpu::getLinearRowFilter_GPU`, :cpp:func:`gpu::getLinearColumnFilter_GPU`, :c:cpp:func:`createSeparableLinearFilter`
.. index:: gpu::sepFilter2D
: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 :c:func:`borderInterpolate`.
+ :param rowBorderType, columnBorderType: Pixel extrapolation method. For details, see :c:cpp:func:`borderInterpolate`.
-See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:func:`sepFilter2D`
+See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:cpp:func:`sepFilter2D`
.. index:: gpu::createDerivFilter_GPU
:param dy: Derivative order in respect of y.
- :param ksize: Aperture size. See :c:func:`getDerivKernels` for details.
+ :param ksize: Aperture size. See :c:cpp:func:`getDerivKernels` for details.
- :param rowBorderType, columnBorderType: Pixel extrapolation method. See :c:func:`borderInterpolate` for details.
+ :param rowBorderType, columnBorderType: Pixel extrapolation method. See :c:cpp:func:`borderInterpolate` for details.
-See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:func:`createDerivFilter`
+See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:cpp:func:`createDerivFilter`
.. index:: gpu::Sobel
:param ksize: Size of the extended Sobel kernel. Possible valies are 1, 3, 5 or 7.
- :param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. For details, see :c:func:`getDerivKernels` .
+ :param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. For details, see :c:cpp:func:`getDerivKernels` .
- :param rowBorderType, columnBorderType: Pixel extrapolation method. See :c:func:`borderInterpolate` for details.
+ :param rowBorderType, columnBorderType: Pixel extrapolation method. See :c:cpp:func:`borderInterpolate` for details.
-See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:func:`Sobel`
+See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:cpp:func:`Sobel`
.. index:: gpu::Scharr
:param yorder: Order of the derivative y.
- :param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :c:func:`getDerivKernels` for details.
+ :param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :c:cpp:func:`getDerivKernels` for details.
- :param rowBorderType, columnBorderType: Pixel extrapolation method. For details, see :c:func:`borderInterpolate` and :c:func:`Scharr` .
+ :param rowBorderType, columnBorderType: Pixel extrapolation method. For details, see :c:cpp:func:`borderInterpolate` and :c:cpp:func:`Scharr` .
-See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:func:`Scharr`
+See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:cpp:func:`Scharr`
.. index:: gpu::createGaussianFilter_GPU
:param type: Source and destination image type. ``CV_8UC1``, ``CV_8UC4``, ``CV_16SC1``, ``CV_16SC2``, ``CV_32SC1``, ``CV_32FC1`` are supported.
- :param ksize: Aperture size. See :c:func:`getGaussianKernel` for details.
+ :param ksize: Aperture size. See :c:cpp:func:`getGaussianKernel` for details.
- :param sigmaX: Gaussian sigma in the horizontal direction. See :c:func:`getGaussianKernel` for details.
+ :param sigmaX: Gaussian sigma in the horizontal direction. See :c:cpp:func:`getGaussianKernel` for details.
: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 :c:func:`borderInterpolate` for details.
+ :param rowBorderType, columnBorderType: Border type to use. See :c:cpp:func:`borderInterpolate` for details.
-See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:func:`createGaussianFilter`
+See Also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:cpp:func:`createGaussianFilter`
.. index:: gpu::GaussianBlur
: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 :c: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, 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 :c:cpp: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 :c:func:`borderInterpolate` for details.
+ :param rowBorderType, columnBorderType: Pixel extrapolation method. See :c:cpp:func:`borderInterpolate` for details.
-See Also: :cpp:func:`gpu::createGaussianFilter_GPU`, :c:func:`GaussianBlur`
+See Also: :cpp:func:`gpu::createGaussianFilter_GPU`, :c:cpp:func:`GaussianBlur`
.. index:: gpu::getMaxFilter_GPU
:param criteria: Termination criteria. See :cpp:class:`TermCriteria`.
See Also:
-:c:func:`gpu::meanShiftFiltering`
+:c:cpp:func:`gpu::meanShiftFiltering`
.. index:: gpu::meanShiftSegmentation
:param sqsum: Squared integral image of the ``CV_32FC1`` type.
See Also:
-:c:func:`integral`
+:c:cpp:func:`integral`
.. index:: gpu::sqrIntegral
:param borderType: Pixel extrapolation method. Only ``BORDER_REFLECT101`` and ``BORDER_REPLICATE`` are supported for now.
See Also:
-:c:func:`cornerHarris`
+:c:cpp:func:`cornerHarris`
.. index:: gpu::cornerMinEigenVal
:param borderType: Pixel extrapolation method. Only ``BORDER_REFLECT101`` and ``BORDER_REPLICATE`` are supported for now.
-See also: :c:func:`cornerMinEigenVal`
+See also: :c:cpp:func:`cornerMinEigenVal`
.. index:: gpu::mulSpectrums
Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
See Also:
-:c:func:`mulSpectrums`
+:c:cpp:func:`mulSpectrums`
.. index:: gpu::mulAndScaleSpectrums
Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
See Also:
-:c:func:`mulSpectrums`
+:c:cpp:func:`mulSpectrums`
.. index:: 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.
See Also:
-:c:func:`dft`
+:c:cpp:func:`dft`
.. index:: gpu::convolve
.. cpp:class:: gpu::ConvolveBuf
This class provides a memory buffer for the
- :c:func:`gpu::convolve` function.
+ :c:cpp:func:`gpu::convolve` function.
::
struct CV_EXPORTS ConvolveBuf
.. cpp:function:: ConvolveBuf::ConvolveBuf()
Constructs an empty buffer that is properly resized after the first call of the
- :c:func:`convolve` function.
+ :c:cpp:func:`convolve` function.
.. cpp:function:: ConvolveBuf::ConvolveBuf(Size image_size, Size templ_size)
Constructs a buffer for the
- :c:func:`convolve` function with respective arguments.
+ :c:cpp:func:`convolve` function with respective arguments.
.. index:: gpu::matchTemplate
* ``CV_TM_CCORR``
See Also:
-:c:func:`matchTemplate`
+:c:cpp:func:`matchTemplate`
.. index:: gpu::remap
Values of pixels with non-integer coordinates are computed using bilinear the interpolation.
-See Also: :c:func:`remap`
+See Also: :c:cpp:func:`remap`
.. index:: gpu::cvtColor
:param dst: Destination image with the same size and depth as ``src`` .
- :param code: Color space conversion code. For details, see :func:`cvtColor` . Conversion to/from Luv and Bayer color spaces is not supported.
+ :param code: Color space conversion code. For details, see :cpp:func:`cvtColor` . Conversion to/from Luv and Bayer color spaces is not supported.
:param dcn: Number of channels in the destination image. If the parameter is 0, the number of the channels is derived automatically from ``src`` and the ``code`` .
3-channel color spaces (like ``HSV``, ``XYZ``, and so on) can be stored in a 4-channel image for better perfomance.
See Also:
-:func:`cvtColor`
+:cpp:func:`cvtColor`
.. index:: gpu::threshold
:param maxVal: Maximum value to use with ``THRESH_BINARY`` and ``THRESH_BINARY_INV`` threshold types.
- :param thresholdType: Threshold type. For details, see :func:`threshold` . The ``THRESH_OTSU`` threshold type is not supported.
+ :param thresholdType: Threshold type. For details, see :cpp:func:`threshold` . The ``THRESH_OTSU`` threshold type is not supported.
:param stream: Stream for the asynchronous version.
See Also:
-:func:`threshold`
+:cpp:func:`threshold`
.. index:: gpu::resize
:param interpolation: Interpolation method. Only ``INTER_NEAREST`` and ``INTER_LINEAR`` are supported.
-See Also: :func:`resize`
+See Also: :cpp:func:`resize`
.. index:: gpu::warpAffine
:param dsize: Size of the destination image.
- :param flags: Combination of interpolation methods (see :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.
+ :param flags: Combination of interpolation methods (see :cpp: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.
See Also:
-:func:`warpAffine`
+:cpp:func:`warpAffine`
.. index:: gpu::warpPerspective
:param dsize: Size of the destination image.
- :param flags: Combination of interpolation methods (see :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.
+ :param flags: Combination of interpolation methods (see :cpp: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.
See Also:
-:func:`warpPerspective`
+:cpp:func:`warpPerspective`
.. index:: gpu::rotate
:param interpolation: Interpolation method. Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` are supported.
See Also:
-:func:`gpu::warpAffine`
+:cpp:func:`gpu::warpAffine`
.. index:: gpu::copyMakeBorder
:param value: Border value.
See Also:
-:func:`copyMakeBorder`
+:cpp:func:`copyMakeBorder`
.. index:: gpu::rectStdDev
The OpenCV GPU module is designed for ease of use and does not require any knowledge of CUDA. Though, such a knowledge will certainly be useful to handle non-trivial cases or achieve the highest performance. It is helpful to understand the cost of various operations, what the GPU does, what the preferred data formats are, and so on. The GPU module is an effective instrument for quick implementation of GPU-accelerated computer vision algorithms. However, if your algorithm involves many simple operations, then, for the best possible performance, you may still need to write your own kernels to avoid extra write and read operations on the intermediate results.
To enable CUDA support, configure OpenCV using ``CMake`` with ``WITH_CUDA=ON`` . When the flag is set and if CUDA is installed, the full-featured OpenCV GPU module is built. Otherwise, the module is still built, but at runtime all functions from the module throw
-:func:`Exception` with ``CV_GpuNotSupported`` error code, except for
-:func:`gpu::getCudaEnabledDeviceCount()`. The latter function returns zero GPU count in this case. Building OpenCV without CUDA support does not perform device code compilation, so it does not require the CUDA Toolkit installed. Therefore, using the
-:func:`gpu::getCudaEnabledDeviceCount()` function, you can implement a high-level algorithm that will detect GPU presence at runtime and choose an appropriate implementation (CPU or GPU) accordingly.
+:cpp:func:`Exception` with ``CV_GpuNotSupported`` error code, except for
+:cpp:func:`gpu::getCudaEnabledDeviceCount()`. The latter function returns zero GPU count in this case. Building OpenCV without CUDA support does not perform device code compilation, so it does not require the CUDA Toolkit installed. Therefore, using the
+:cpp:func:`gpu::getCudaEnabledDeviceCount()` function, you can implement a high-level algorithm that will detect GPU presence at runtime and choose an appropriate implementation (CPU or GPU) accordingly.
Compilation for Different NVIDIA* Platforms
-------------------------------------------
PTX code for compute capabilities 1.1 and 1.3 (controlled by ``CUDA_ARCH_PTX`` in ``CMake``)
This means that for devices with CC 1.3 and 2.0 binary images are ready to run. For all newer platforms, the PTX code for 1.3 is JIT'ed to a binary image. For devices with CC 1.1 and 1.2, the PTX for 1.1 is JIT'ed. For devices with CC 1.0, no code is available and the functions throw
-:func:`Exception`. For platforms where JIT compilation is performed first, the run is slow.
+:cpp:func:`Exception`. For platforms where JIT compilation is performed first, the run is slow.
On a GPU with CC 1.0, you can still compile the GPU module and most of the functions will run flawlessly. To achieve this, add "1.0" to the list of binaries, for example, ``CUDA_ARCH_BIN="1.0 1.3 2.0"`` . The functions that cannot be run on CC 1.0 GPUs throw an exception.
You can always determine at runtime whether the OpenCV GPU-built binaries (or PTX code) are compatible with your GPU. The function
-:func:`gpu::DeviceInfo::isCompatible` returns the compatibility status (true/false).
+:cpp:func:`gpu::DeviceInfo::isCompatible` returns the compatibility status (true/false).
Threading and Multi-threading
------------------------------
*
If you use only synchronous functions, create several CPU threads (one per each GPU) and from within each thread create a CUDA context for the corresponding GPU using
- :func:`gpu::setDevice()` or Driver API. Each of the threads will use the associated GPU.
+ :cpp:func:`gpu::setDevice()` or Driver API. Each of the threads will use the associated GPU.
*
If you use asynchronous functions, you can use the Driver API to create several CUDA contexts associated with different GPUs but attached to one CPU thread. Within the thread you can switch from one GPU to another by making the corresponding context "current". With non-blocking GPU calls, managing algorithm is clear.
:param stddev: Standard deviation value.
-See Also: :c:func:`meanStdDev`
+See Also: :c:cpp:func:`meanStdDev`
.. index:: gpu::norm
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
-See Also: :c:func:`norm`
+See Also: :c:cpp:func:`norm`
.. index:: gpu::sum
:param buf: Optional buffer to avoid extra memory allocations. It is resized automatically.
-See Also: :c:func:`sum`
+See Also: :c:cpp:func:`sum`
.. index:: gpu::absSum
The function does not work with ``CV_64F`` images on GPUs with the compute capability < 1.3.
-See Also: :c:func:`minMaxLoc`
+See Also: :c:cpp:func:`minMaxLoc`
.. index:: gpu::minMaxLoc
The function does not work with ``CV_64F`` images on GPU with the compute capability < 1.3.
-See Also: :c:func:`minMaxLoc`
+See Also: :c:cpp:func:`minMaxLoc`
.. index:: gpu::countNonZero
The function does not work with ``CV_64F`` images on GPUs with the compute capability < 1.3.
- See Also: :c:func:`countNonZero`
+ See Also: :c:cpp:func:`countNonZero`
Performs object detection with a multi-scale window.
- :param img: Source image. See :func:`gpu::HOGDescriptor::detect` for type limitations.
+ :param img: Source image. See :cpp:func:`gpu::HOGDescriptor::detect` for type limitations.
:param found_locations: Detected objects boundaries.
- :param hit_threshold: Threshold for the distance between features and SVM classifying plane. See :func:`gpu::HOGDescriptor::detect` for details.
+ :param hit_threshold: Threshold for the distance between features and SVM classifying plane. See :cpp:func:`gpu::HOGDescriptor::detect` for details.
:param win_stride: Window stride. It must be a multiple of block stride.
:param scale0: Coefficient of the detection window increase.
- :param group_threshold: Coefficient to regulate the similarity threshold. When detected, some objects can be covered by many rectangles. 0 means not to perform grouping. See :func:`groupRectangles` .
+ :param group_threshold: Coefficient to regulate the similarity threshold. When detected, some objects can be covered by many rectangles. 0 means not to perform grouping. See :cpp:func:`groupRectangles` .
.. index:: gpu::HOGDescriptor::getDescriptors
Returns block descriptors computed for the whole image. The function is mainly used to learn the classifier.
- :param img: Source image. See :func:`gpu::HOGDescriptor::detect` for type limitations.
+ :param img: Source image. See :cpp:func:`gpu::HOGDescriptor::detect` for type limitations.
:param win_stride: Window stride. It must be a multiple of block stride.
imshow("Faces", image_cpu);
-See Also: :c:func:`CascadeClassifier::detectMultiScale`
+See Also: :c:cpp:func:`CascadeClassifier::detectMultiScale`
:param dst: Destination matrix.
See Also:
-:c:func:`transpose`
+:c:cpp:func:`transpose`
.. index:: gpu::flip
See Also:
-:c:func:`flip`
+:c:cpp:func:`flip`
.. index:: gpu::LUT
:param dst: Destination matrix with the same depth as ``lut`` and the same number of channels as ``src``.
-See Also: :c:func:`LUT`
+See Also: :c:cpp:func:`LUT`
.. index:: gpu::merge
:param stream: Stream for the asynchronous version.
-See Also: :c:func:`merge`
+See Also: :c:cpp:func:`merge`
.. index:: gpu::split
:param stream: Stream for the asynchronous version.
-See Also: :c:func:`split`
+See Also: :c:cpp:func:`split`
.. index:: gpu::magnitude
:param stream: Stream for the asynchronous version.
See Also:
-:c:func:`magnitude`
+:c:cpp:func:`magnitude`
.. index:: gpu::magnitudeSqr
:param stream: Stream for the asynchronous version.
See Also:
-:c:func:`phase`
+:c:cpp:func:`phase`
.. index:: gpu::cartToPolar
:param stream: Stream for the asynchronous version.
See Also:
-:c:func:`cartToPolar`
+:c:cpp:func:`cartToPolar`
.. index:: gpu::polarToCart
:param stream: Stream for the asynchronous version.
See Also:
-:c:func:`polarToCart`
+:c:cpp:func:`polarToCart`
:param dst: Destination matrix with the same size and type as ``src1``.
-See Also: :c:func:`add`
+See Also: :c:cpp:func:`add`
.. index:: gpu::subtract
:param dst: Destination matrix with the same size and type as ``src1``.
-See Also: :c:func:`subtract`
+See Also: :c:cpp:func:`subtract`
:param dst: Destination matrix with the same size and type as ``src1``.
-See Also: :c:func:`multiply`
+See Also: :c:cpp:func:`multiply`
.. index:: gpu::divide
:param dst: Destination matrix with the same size and type as ``src1``.
- This function, in contrast to :c:func:`divide`, uses a round-down rounding mode.
+ This function, in contrast to :c:cpp:func:`divide`, uses a round-down rounding mode.
-See Also: :c:func:`divide`
+See Also: :c:cpp:func:`divide`
:param dst: Destination matrix with the same size and type as ``src``.
-See Also: :c:func:`exp`
+See Also: :c:cpp:func:`exp`
:param dst: Destination matrix with the same size and type as ``src``.
-See Also: :c:func:`log`
+See Also: :c:cpp:func:`log`
:param dst: Destination matrix with the same size and type as ``src1``.
-See Also: :c:func:`absdiff`
+See Also: :c:cpp:func:`absdiff`
.. index:: gpu::compare
* **CMP_LE:** ``src1(.) <= src2(.)``
* **CMP_NE:** ``src1(.) != src2(.)``
-See Also: :c:func:`compare`
+See Also: :c:cpp:func:`compare`
.. index:: gpu::bitwise_not
:param stream: Stream for the asynchronous version.
-See Also: :c:func:`min`
+See Also: :c:cpp:func:`min`
:param stream: Stream for the asynchronous version.
-See Also: :c:func:`max`
+See Also: :c:cpp:func:`max`
setWindowProperty
---------------------
-.. c:function:: void setWindowProperty(const string& name, int prop_id, double prop_value)
+.. cpp:function:: void setWindowProperty(const string& name, int prop_id, double prop_value)
Changes parameters of a window dynamically.
getWindowProperty
---------------------
-.. c:function:: void getWindowProperty(const char* name, int prop_id)
+.. cpp:function:: void getWindowProperty(const string& name, int prop_id)
Provides parameters of a window.
fontQt
----------
-.. c:function:: CvFont fontQt(const string& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), int weight = CV_FONT_NORMAL, int style = CV_STYLE_NORMAL, int spacing = 0)
+.. cpp:function:: CvFont fontQt(const string& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), int weight = CV_FONT_NORMAL, int style = CV_STYLE_NORMAL, int spacing = 0)
Creates the font to draw a text on an image.
addText
-----------
-.. c:function:: void addText(const Mat& img, const string& text, Point location, CvFont *font)
+.. cpp:function:: void addText(const Mat& img, const string& text, Point location, CvFont *font)
Creates the font to draw a text on an image.
displayOverlay
------------------
-.. c:function:: void displayOverlay(const string& name, const string& text, int delay)
+.. cpp:function:: void displayOverlay(const string& name, const string& text, int delay)
Displays a text on a window image as an overlay for a specified duration.
displayStatusBar
--------------------
-.. c:function:: void displayStatusBar(const string& name, const string& text, int delay)
+.. cpp:function:: void displayStatusBar(const string& name, const string& text, int delay)
Displays a text on the window statusbar during the specified period of time.
createOpenGLCallback
------------------------
-.. c:function:: void createOpenGLCallback( const string& window_name, OpenGLCallback callbackOpenGL, void* userdata CV_DEFAULT(NULL), double angle CV_DEFAULT(-1), double zmin CV_DEFAULT(-1), double zmax CV_DEFAULT(-1)
+.. cpp:function:: void createOpenGLCallback( const string& window_name, OpenGLCallback callbackOpenGL, void* userdata CV_DEFAULT(NULL), double angle CV_DEFAULT(-1), double zmin CV_DEFAULT(-1), double zmax CV_DEFAULT(-1)
Creates a callback function called to draw OpenGL on top the the image display by ``windowname``.
saveWindowParameters
------------------------
-.. c:function:: void saveWindowParameters(const string& name)
+.. cpp:function:: void saveWindowParameters(const string& name)
Saves parameters of the window ``windowname`` .
loadWindowParameters
------------------------
-.. c:function:: void loadWindowParameters(const string& name)
+.. cpp:function:: void loadWindowParameters(const string& name)
Loads parameters of the window ``windowname`` .
createButton
----------------
-.. c:function:: createButton( const string& button_name CV_DEFAULT(NULL),ButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL), int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0))
+.. cpp:function:: createButton( const string& button_name CV_DEFAULT(NULL),ButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL), int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0))
Creates a callback function called to draw OpenGL on top of the image display by ``windowname`` .
imdecode
------------
-.. c:function:: Mat imdecode( const Mat\& buf, int flags )
+.. cpp:function:: Mat imdecode( InputArray buf, int flags )
Reads an image from a buffer in memory.
imencode
------------
-.. c:function:: bool imencode( const string\& ext, const Mat\& img, vector<uchar>\& buf, const vector<int>\& params=vector<int>())
+.. cpp:function:: bool imencode( const string& ext, InputArray img, vector<uchar>& buf, const vector<int>& params=vector<int>())
Encode an image into a memory buffer.
imread
----------
-.. c:function:: Mat imread( const string\& filename, int flags=1 )
+.. cpp:function:: Mat imread( const string& filename, int flags=1 )
Loads an image from a file.
imwrite
-----------
-.. c:function:: bool imwrite( const string\& filename, const Mat\& img, const vector<int>\& params=vector<int>())
+.. cpp:function:: bool imwrite( const string& filename, InputArray img, const vector<int>& params=vector<int>())
Saves an image to a specified file.
VideoCapture::VideoCapture
------------------------------
-.. c:function:: VideoCapture::VideoCapture()
+.. cpp:function:: VideoCapture::VideoCapture()
-.. c:function:: VideoCapture::VideoCapture(const string& filename)
+.. cpp:function:: VideoCapture::VideoCapture(const string& filename)
-.. c:function:: VideoCapture::VideoCapture(int device)
+.. cpp:function:: VideoCapture::VideoCapture(int device)
VideoCapture constructors.
VideoCapture::get
---------------------
-.. c:function:: double VideoCapture::get(int property_id)
+.. cpp:function:: double VideoCapture::get(int property_id)
:param property_id: Property identifier. It can be one of the following:
VideoCapture::set
---------------------
-.. c:function:: bool VideoCapture::set(int property_id, double value)
+.. cpp:function:: bool VideoCapture::set(int property_id, double value)
Sets a property in the VideoCapture backend.
createTrackbar
------------------
-.. c:function:: int createTrackbar( const string& trackbarname, const string& winname, int* value, int count, TrackbarCallback onChange CV_DEFAULT(0), void* userdata CV_DEFAULT(0))
+.. cpp:function:: int createTrackbar( const string& trackbarname, const string& winname, int* value, int count, TrackbarCallback onChange=0, void* userdata=0)
Creates a trackbar and attaches it to the specified window.
getTrackbarPos
------------------
-.. c:function:: int getTrackbarPos( const string& trackbarname, const string& winname )
+.. cpp:function:: int getTrackbarPos( const string& trackbarname, const string& winname )
Returns the trackbar position.
imshow
----------
-.. c:function:: void imshow( const string& winname, const Mat& image )
+.. cpp:function:: void imshow( const string& winname, InputArray image )
Displays an image in the specified window.
namedWindow
---------------
-.. c:function:: void namedWindow( const string& winname, int flags )
+.. cpp:function:: void namedWindow( const string& winname, int flags )
Creates a window.
setTrackbarPos
------------------
-.. c:function:: void setTrackbarPos( const string& trackbarname, const string& winname, int pos )
+.. cpp:function:: void setTrackbarPos( const string& trackbarname, const string& winname, int pos )
Sets the trackbar position.
waitKey
-----------
-.. c:function:: int waitKey(int delay=0)
+.. cpp:function:: int waitKey(int delay=0)
Waits for a pressed key.
enum { WINDOW_AUTOSIZE=1 };
-CV_EXPORTS_W void namedWindow( const string& winname, int flags CV_DEFAULT(WINDOW_AUTOSIZE) );
+CV_EXPORTS_W void namedWindow( const string& winname, int flags=WINDOW_AUTOSIZE );
CV_EXPORTS_W void destroyWindow( const string& winname );
CV_EXPORTS_W int startWindowThread();
//Only for Qt
//------------------------
-CV_EXPORTS CvFont fontQt(const string& nameFont, int pointSize CV_DEFAULT(-1),
- Scalar color CV_DEFAULT(Scalar::all(0)), int weight CV_DEFAULT(CV_FONT_NORMAL),
- int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0));
+CV_EXPORTS CvFont fontQt(const string& nameFont, int pointSize=-1,
+ Scalar color=Scalar::all(0), int weight=CV_FONT_NORMAL,
+ int style=CV_STYLE_NORMAL, int spacing=0);
CV_EXPORTS void addText( const Mat& img, const string& text, Point org, CvFont font);
CV_EXPORTS void displayOverlay(const string& winname, const string& text, int delayms);
CV_EXPORTS void displayStatusBar(const string& winname, const string& text, int delayms);
typedef void (CV_CDECL *OpenGLCallback)(void* userdata);
-CV_EXPORTS void createOpenGLCallback(const string& winname, CvOpenGLCallback callbackOpenGL, void* userdata CV_DEFAULT(0));
+CV_EXPORTS void createOpenGLCallback(const string& winname, CvOpenGLCallback callbackOpenGL, void* userdata=0);
CV_EXPORTS void saveWindowParameters(const string& windowName);
CV_EXPORTS void loadWindowParameters(const string& windowName);
typedef void (CV_CDECL *ButtonCallback)(int state, void* userdata);
CV_EXPORTS int createButton( const string& bar_name, ButtonCallback on_change,
- void* userdata CV_DEFAULT(NULL), int type CV_DEFAULT(CV_PUSH_BUTTON),
- bool initial_button_state CV_DEFAULT(0));
+ void* userdata=NULL, int type=CV_PUSH_BUTTON,
+ bool initial_button_state=0);
//-------------------------
CV_EXPORTS_W void imshow( const string& winname, InputArray mat );
CV_EXPORTS int createTrackbar( const string& trackbarname, const string& winname,
int* value, int count,
- TrackbarCallback onChange CV_DEFAULT(0),
- void* userdata CV_DEFAULT(0));
+ TrackbarCallback onChange=0,
+ void* userdata=0);
CV_EXPORTS_W int getTrackbarPos( const string& trackbarname, const string& winname );
CV_EXPORTS_W void setTrackbarPos( const string& trackbarname, const string& winname, int pos );
.. index:: Canny
-.. _Canny:
-
Canny
---------
-.. c:function:: void Canny( const Mat& image, Mat& edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false )
+.. cpp:function:: void Canny( InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false )
Finds edges in an image using the Canny algorithm.
:param threshold2: The second threshold for the hysteresis procedure.
- :param apertureSize: Aperture size for the :func:`Sobel` operator.
+ :param apertureSize: Aperture size for the :cpp:func:`Sobel` operator.
:param L2gradient: Flag indicating whether a more accurate :math:`L_2` norm :math:`=\sqrt{(dI/dx)^2 + (dI/dy)^2}` should be used to compute the image gradient magnitude ( ``L2gradient=true`` ), or a faster default :math:`L_1` norm :math:`=|dI/dx|+|dI/dy|` is enough ( ``L2gradient=false`` ).
.. index:: cornerEigenValsAndVecs
-.. _cornerEigenValsAndVecs:
-
cornerEigenValsAndVecs
----------------------
-.. c:function:: void cornerEigenValsAndVecs( const Mat& src, Mat& dst, int blockSize, int apertureSize, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void cornerEigenValsAndVecs( InputArray src, OutputArray dst, int blockSize, int apertureSize, int borderType=BORDER_DEFAULT )
Calculates eigenvalues and eigenvectors of image blocks for corner detection.
:param blockSize: Neighborhood size (see details below).
- :param apertureSize: Aperture parameter for the :func:`Sobel` operator.
+ :param apertureSize: Aperture parameter for the :cpp:func:`Sobel` operator.
- :param boderType: Pixel extrapolation method. See :func:`borderInterpolate` .
+ :param boderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` .
For every pixel
:math:`p` , the function ``cornerEigenValsAndVecs`` considers a ``blockSize`` :math:`\times` ``blockSize`` neigborhood
M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}(dI/dx dI/dy)^2 \\ \sum _{S(p)}(dI/dx dI/dy)^2 & \sum _{S(p)}(dI/dy)^2 \end{bmatrix}
where the derivatives are computed using the
-:func:`Sobel` operator.
+:cpp:func:`Sobel` operator.
After that it finds eigenvectors and eigenvalues of
:math:`M` and stores them in the destination image as
The output of the function can be used for robust edge or corner detection.
See Also:
-:func:`cornerMinEigenVal`,
-:func:`cornerHarris`,
-:func:`preCornerDetect`
+:cpp:func:`cornerMinEigenVal`,
+:cpp:func:`cornerHarris`,
+:cpp:func:`preCornerDetect`
.. index:: cornerHarris
-.. _cornerHarris:
-
cornerHarris
------------
-.. c:function:: void cornerHarris( const Mat& src, Mat& dst, int blockSize, int apertureSize, double k, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void cornerHarris( InputArray src, OutputArray dst, int blockSize, int apertureSize, double k, int borderType=BORDER_DEFAULT )
Harris edge detector.
:param dst: Image to store the Harris detector responses. It has the type ``CV_32FC1`` and the same size as ``src`` .
- :param blockSize: Neighborhood size (see the details on :func:`cornerEigenValsAndVecs` ).
+ :param blockSize: Neighborhood size (see the details on :cpp:func:`cornerEigenValsAndVecs` ).
- :param apertureSize: Aperture parameter for the :func:`Sobel` operator.
+ :param apertureSize: Aperture parameter for the :cpp:func:`Sobel` operator.
:param k: Harris detector free parameter. See the formula below.
- :param boderType: Pixel extrapolation method. See :func:`borderInterpolate` .
+ :param boderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` .
The function runs the Harris edge detector on the image. Similarly to
-:func:`cornerMinEigenVal` and
-:func:`cornerEigenValsAndVecs` , for each pixel
+:cpp:func:`cornerMinEigenVal` and
+:cpp:func:`cornerEigenValsAndVecs` , for each pixel
:math:`(x, y)` it calculates a
:math:`2\times2` gradient covariation matrix
:math:`M^{(x,y)}` over a
.. index:: cornerMinEigenVal
-.. _cornerMinEigenVal:
-
cornerMinEigenVal
-----------------
-.. c:function:: void cornerMinEigenVal( const Mat& src, Mat& dst, int blockSize, int apertureSize=3, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void cornerMinEigenVal( InputArray src, OutputArray dst, int blockSize, int apertureSize=3, int borderType=BORDER_DEFAULT )
Calculates the minimal eigenvalue of gradient matrices for corner detection.
:param dst: Image to store the minimal eigenvalues. It has the type ``CV_32FC1`` and the same size as ``src`` .
- :param blockSize: Neighborhood size (see the details on :func:`cornerEigenValsAndVecs` ).
+ :param blockSize: Neighborhood size (see the details on :cpp:func:`cornerEigenValsAndVecs` ).
- :param apertureSize: Aperture parameter for the :func:`Sobel` operator.
+ :param apertureSize: Aperture parameter for the :cpp:func:`Sobel` operator.
- :param boderType: Pixel extrapolation method. See :func:`borderInterpolate` .
+ :param boderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` .
The function is similar to
-:func:`cornerEigenValsAndVecs` but it calculates and stores only the minimal eigenvalue of the covariation matrix of derivatives, that is,
+:cpp:func:`cornerEigenValsAndVecs` but it calculates and stores only the minimal eigenvalue of the covariation matrix of derivatives, that is,
:math:`\min(\lambda_1, \lambda_2)` in terms of the formulae in the
-:func:`cornerEigenValsAndVecs` description.
+:cpp:func:`cornerEigenValsAndVecs` description.
.. index:: cornerSubPix
-.. _cornerSubPix:
-
cornerSubPix
----------------
-.. c:function:: void cornerSubPix( const Mat& image, vector<Point2f>& corners, Size winSize, Size zeroZone, TermCriteria criteria )
+.. cpp:function:: void cornerSubPix( InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria )
Refines the corner locations.
.. index:: goodFeaturesToTrack
-.. _goodFeaturesToTrack:
-
goodFeaturesToTrack
-------------------
-.. c:function:: void goodFeaturesToTrack( const Mat& image, vector<Point2f>& corners, int maxCorners, double qualityLevel, double minDistance, const Mat& mask=Mat(), int blockSize=3, bool useHarrisDetector=false, double k=0.04 )
+.. cpp:function:: void goodFeaturesToTrack( InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask=None(), int blockSize=3, bool useHarrisDetector=false, double k=0.04 )
Determines strong corners on an image.
:param maxCorners: Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned.
- :param qualityLevel: Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see :func:`cornerMinEigenVal` ) or the Harris function response (see :func:`cornerHarris` ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the ``qualityLevel=0.01`` , then all the corners with the quality measure less than 15 are rejected.
+ :param qualityLevel: Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see :cpp:func:`cornerMinEigenVal` ) or the Harris function response (see :cpp:func:`cornerHarris` ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the ``qualityLevel=0.01`` , then all the corners with the quality measure less than 15 are rejected.
:param minDistance: Minimum possible Euclidean distance between the returned corners.
:param mask: Optional region of interest. If the image is not empty (it needs to have the type ``CV_8UC1`` and the same size as ``image`` ), it specifies the region in which the corners are detected.
- :param blockSize: Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See :func:`cornerEigenValsAndVecs` .
+ :param blockSize: Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See :cpp:func:`cornerEigenValsAndVecs` .
- :param useHarrisDetector: Parameter indicating whether to use a Harris detector (see :func:`cornerHarris`) or :func:`cornerMinEigenVal`.
+ :param useHarrisDetector: Parameter indicating whether to use a Harris detector (see :cpp:func:`cornerHarris`) or :cpp:func:`cornerMinEigenVal`.
:param k: Free parameter of the Harris detector.
#.
Function calculates the corner quality measure at every source image pixel using the
- :func:`cornerMinEigenVal` or
- :func:`cornerHarris` .
+ :cpp:func:`cornerMinEigenVal` or
+ :cpp:func:`cornerHarris` .
#.
Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
**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: :func:`cornerMinEigenVal`,
-:func:`cornerHarris`,
-:func:`calcOpticalFlowPyrLK`,
-:func:`estimateRigidMotion`,
-:func:`PlanarObjectDetector`,
-:func:`OneWayDescriptor`
+See Also: :cpp:func:`cornerMinEigenVal`,
+:cpp:func:`cornerHarris`,
+:cpp:func:`calcOpticalFlowPyrLK`,
+:cpp:func:`estimateRigidMotion`,
+:cpp:func:`PlanarObjectDetector`,
+:cpp:func:`OneWayDescriptor`
.. index:: HoughCircles
-.. _HoughCircles:
-
HoughCircles
------------
-.. c:function:: void HoughCircles( Mat& image, vector<Vec3f>& circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0 )
+.. cpp:function:: void HoughCircles( InputArray image, OutputArray circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0 )
Finds circles in a grayscale image using the Hough transform.
:param minDist: Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
- :param param1: The first method-specific parameter. In case of ``CV_HOUGH_GRADIENT`` , it is the higher threshold of the two passed to the :func:`Canny` edge detector (the lower one is twice smaller).
+ :param param1: The first method-specific parameter. In case of ``CV_HOUGH_GRADIENT`` , it is the higher threshold of the two passed to the :cpp:func:`Canny` edge detector (the lower one is twice smaller).
:param param2: The second method-specific parameter. In case of ``CV_HOUGH_GRADIENT`` , it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first
**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:
-:func:`fitEllipse`,
-:func:`minEnclosingCircle`
+:cpp:func:`fitEllipse`,
+:cpp:func:`minEnclosingCircle`
.. index:: HoughLines
-.. _HoughLines:
-
HoughLines
----------
-.. c:function:: void HoughLines( Mat& image, vector<Vec2f>& lines, double rho, double theta, int threshold, double srn=0, double stn=0 )
+.. cpp:function:: void HoughLines( InputArray image, OutputArray lines, double rho, double theta, int threshold, double srn=0, double stn=0 )
Finds lines in a binary image using the standard Hough transform.
:param stn: For the multi-scale Hough transform, it is a divisor for the distance resolution ``theta`` .
The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See
-:func:`HoughLinesP` for the code example.
+:cpp:func:`HoughLinesP` for the code example.
.. index:: HoughLinesP
-.. _HoughLinesP:
-
HoughLinesP
-----------
-.. c:function:: void HoughLinesP( Mat& image, vector<Vec4i>& lines, double rho, double theta, int threshold, double minLineLength=0, double maxLineGap=0 )
+.. cpp:function:: void HoughLinesP( InputArray image, OutputArray lines, double rho, double theta, int threshold, double minLineLength=0, double maxLineGap=0 )
Finds line segments in a binary image using the probabilistic Hough transform.
.. index:: preCornerDetect
-.. _preCornerDetect:
-
preCornerDetect
---------------
-.. c:function:: void preCornerDetect( const Mat& src, Mat& dst, int apertureSize, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void preCornerDetect( InputArray src, OutputArray dst, int apertureSize, int borderType=BORDER_DEFAULT )
Calculates a feature map for corner detection.
:param dst: Output image that has the type ``CV_32F`` and the same size as ``src`` .
- :param apertureSize: Aperture size of the :func:`Sobel` .
+ :param apertureSize: Aperture size of the :cpp:func:`Sobel` .
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` .
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` .
The function calculates the complex spatial derivative-based function of the source image
===============
Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images (represented as
-:func:`Mat`'s). It means that for each pixel location
+:cpp:func:`Mat`'s). It means that for each pixel location
:math:`(x,y)` in the source image (normally, rectangular), its neighborhood is considered and used to compute the response. In case of a linear filter, it is a weighted sum of pixel values. In case of morphological operations, it is the minimum or maximum values, and so on. The computed response is stored in the destination image at the same location
:math:`(x,y)` . It means that the output image will be of the same size as the input image. Normally, the functions support multi-channel arrays, in which case every channel is processed independently. Therefore, the output image will also have the same number of channels as the input one.
Another common feature of the functions and classes described in this section is that, unlike simple arithmetic functions, they need to extrapolate values of some non-existing pixels. For example, if you want to smooth an image using a Gaussian
:math:`3 \times 3` filter, then, when processing the left-most pixels in each row, you need pixels to the left of them, that is, outside of the image. You can let these pixels be the same as the left-most image pixels ("replicated border" extrapolation method), or assume that all the non-existing pixels are zeros ("contant border" extrapolation method), and so on.
-OpenCV enables you to specify the extrapolation method. For details, see the function :func:`borderInterpolate` and discussion of the ``borderType`` parameter in various functions below.
+OpenCV enables you to specify the extrapolation method. For details, see the function :cpp:func:`borderInterpolate` and discussion of the ``borderType`` parameter in various functions below.
.. index:: BaseColumnFilter
-.. _BaseColumnFilter:
-
BaseColumnFilter
----------------
-.. c:type:: BaseColumnFilter
+.. cpp:class:: BaseColumnFilter
Base class for filters with single-column kernels ::
where
:math:`F` is a filtering function but, as it is represented as a class, it can produce any side effects, memorize previously processed data, and so on. The class only defines an interface and is not used directly. Instead, there are several functions in OpenCV (and you can add more) that return pointers to the derived classes that implement specific filtering operations. Those pointers are then passed to the
-:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
+:cpp:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
See Also:
-:func:`BaseRowFilter`,
-:func:`BaseFilter`,
-:func:`FilterEngine`,
-:func:`getColumnSumFilter`,
-:func:`getLinearColumnFilter`,
-:func:`getMorphologyColumnFilter`
+:cpp:func:`BaseRowFilter`,
+:cpp:func:`BaseFilter`,
+:cpp:func:`FilterEngine`,
+:cpp:func:`getColumnSumFilter`,
+:cpp:func:`getLinearColumnFilter`,
+:cpp:func:`getMorphologyColumnFilter`
.. index:: BaseFilter
-.. _BaseFilter:
-
BaseFilter
----------
-.. c:type:: BaseFilter
+.. cpp:class:: BaseFilter
Base class for 2D image filters ::
where
:math:`F` is a filtering function. The class only defines an interface and is not used directly. Instead, there are several functions in OpenCV (and you can add more) that return pointers to the derived classes that implement specific filtering operations. Those pointers are then passed to the
-:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
+:cpp:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
See Also:
-:func:`BaseColumnFilter`,
-:func:`BaseRowFilter`,
-:func:`FilterEngine`,
-:func:`getLinearFilter`,
-:func:`getMorphologyFilter`
+:cpp:func:`BaseColumnFilter`,
+:cpp:func:`BaseRowFilter`,
+:cpp:func:`FilterEngine`,
+:cpp:func:`getLinearFilter`,
+:cpp:func:`getMorphologyFilter`
.. index:: BaseRowFilter
-.. _BaseRowFilter:
-
BaseRowFilter
-------------
-.. c:type:: BaseRowFilter
+.. cpp:class:: BaseRowFilter
Base class for filters with single-row kernels ::
where
:math:`F` is a filtering function. The class only defines an interface and is not used directly. Instead, there are several functions in OpenCV (and you can add more) that return pointers to the derived classes that implement specific filtering operations. Those pointers are then passed to the
-:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
+:cpp:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
See Also:
-:func:`BaseColumnFilter`,
-:func:`Filter`,
-:func:`FilterEngine`,
-:func:`getLinearRowFilter`,
-:func:`getMorphologyRowFilter`,
-:func:`getRowSumFilter`
+:cpp:func:`BaseColumnFilter`,
+:cpp:func:`Filter`,
+:cpp:func:`FilterEngine`,
+:cpp:func:`getLinearRowFilter`,
+:cpp:func:`getMorphologyRowFilter`,
+:cpp:func:`getRowSumFilter`
.. index:: FilterEngine
-.. _FilterEngine:
-
FilterEngine
------------
-.. c:type:: FilterEngine
+.. cpp:class:: FilterEngine
Generic image filtering class ::
It contains all the necessary intermediate buffers, computes extrapolated values
of the "virtual" pixels outside of the image, and so on. Pointers to the initialized ``FilterEngine`` instances
are returned by various ``create*Filter`` functions (see below) and they are used inside high-level functions such as
-:func:`filter2D`,
-:func:`erode`,
-:func:`dilate`, and others. Thus, the class plays a key role in many of OpenCV filtering functions.
+:cpp:func:`filter2D`,
+:cpp:func:`erode`,
+:cpp:func:`dilate`, and others. Thus, the class plays a key role in many of OpenCV filtering functions.
This class makes it easier to combine filtering operations with other operations, such as color space conversions, thresholding, arithmetic operations, and others. By combining several operations together you can get much better performance because your data will stay in cache. For example, see below the implementation of the Laplace operator for floating-point images, which is a simplified implementation of
-:func:`Laplacian` : ::
+:cpp:func:`Laplacian` : ::
void laplace_f(const Mat& src, Mat& dst)
{
Explore the data types. As it was mentioned in the
-:func:`BaseFilter` description, the specific filters can process data of any type, despite that ``Base*Filter::operator()`` only takes ``uchar`` pointers and no information about the actual types. To make it all work, the following rules are used:
+:cpp:func:`BaseFilter` description, the specific filters can process data of any type, despite that ``Base*Filter::operator()`` only takes ``uchar`` pointers and no information about the actual types. To make it all work, the following rules are used:
*
In case of separable filtering, ``FilterEngine::rowFilter`` is applied first. It transforms the input image data (of type ``srcType`` ) to the intermediate results stored in the internal buffers (of type ``bufType`` ). Then, these intermediate results are processed as
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`` .
See Also:
-:func:`BaseColumnFilter`,
-:func:`BaseFilter`,
-:func:`BaseRowFilter`,
-:func:`createBoxFilter`,
-:func:`createDerivFilter`,
-:func:`createGaussianFilter`,
-:func:`createLinearFilter`,
-:func:`createMorphologyFilter`,
-:func:`createSeparableLinearFilter`
+:cpp:func:`BaseColumnFilter`,
+:cpp:func:`BaseFilter`,
+:cpp:func:`BaseRowFilter`,
+:cpp:func:`createBoxFilter`,
+:cpp:func:`createDerivFilter`,
+:cpp:func:`createGaussianFilter`,
+:cpp:func:`createLinearFilter`,
+:cpp:func:`createMorphologyFilter`,
+:cpp:func:`createSeparableLinearFilter`
.. index:: bilateralFilter
bilateralFilter
-------------------
-.. c:function:: void bilateralFilter( const Mat& src, Mat& dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void bilateralFilter( InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT )
Applies the bilateral filter to an image.
blur
--------
-.. c:function:: void blur( const Mat& src, Mat& dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT )
+.. cpp:function:: void blur( InputArray src, OutputArray dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT )
Smoothes an image using the normalized box filter.
The call ``blur(src, dst, ksize, anchor, borderType)`` is equivalent to ``boxFilter(src, dst, src.type(), anchor, true, borderType)`` .
See Also:
-:func:`boxFilter`,
-:func:`bilateralFilter`,
-:func:`GaussianBlur`,
-:func:`medianBlur`
+:cpp:func:`boxFilter`,
+:cpp:func:`bilateralFilter`,
+:cpp:func:`GaussianBlur`,
+:cpp:func:`medianBlur`
.. index:: borderInterpolate
borderInterpolate
---------------------
-.. c:function:: int borderInterpolate( int p, int len, int borderType )
+.. cpp:function:: int borderInterpolate( int p, int len, int borderType )
Computes the source location of an extrapolated pixel.
Normally, the function is not called directly. It is used inside
-:func:`FilterEngine` and
-:func:`copyMakeBorder` to compute tables for quick extrapolation.
+:cpp:func:`FilterEngine` and
+:cpp:func:`copyMakeBorder` to compute tables for quick extrapolation.
See Also:
-:func:`FilterEngine`,
-:func:`copyMakeBorder`
+:cpp:func:`FilterEngine`,
+:cpp:func:`copyMakeBorder`
.. index:: boxFilter
boxFilter
-------------
-.. c:function:: void boxFilter( const Mat& src, Mat& dst, int ddepth, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void boxFilter( InputArray src, OutputArray dst, int ddepth, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT )
Smoothes an image using the box filter.
Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms,
and so on). If you need to compute pixel sums over variable-size windows, use
-:func:`integral` .
+:cpp:func:`integral` .
See Also:
-:func:`boxFilter`,
-:func:`bilateralFilter`,
-:func:`GaussianBlur`,
-:func:`medianBlur`,
-:func:`integral`
+:cpp:func:`boxFilter`,
+:cpp:func:`bilateralFilter`,
+:cpp:func:`GaussianBlur`,
+:cpp:func:`medianBlur`,
+:cpp:func:`integral`
.. index:: buildPyramid
buildPyramid
----------------
-.. c:function:: void buildPyramid( const Mat& src, vector<Mat>& dst, int maxlevel )
+.. cpp:function:: void buildPyramid( InputArray src, OutputArrayOfArrays dst, int maxlevel )
Constructs the Gaussian pyramid for an image.
- :param src: Source image. Check :func:`pyrDown` for the list of supported types.
+ :param src: Source image. Check :cpp:func:`pyrDown` for the list of supported types.
:param dst: Destination vector of ``maxlevel+1`` images of the same type as ``src`` . ``dst[0]`` will be the same as ``src`` . ``dst[1]`` is the next pyramid layer,
a smoothed and down-sized ``src`` , and so on.
:param maxlevel: 0-based index of the last (the smallest) pyramid layer. It must be non-negative.
The function constructs a vector of images and builds the Gaussian pyramid by recursively applying
-:func:`pyrDown` to the previously built pyramid layers, starting from ``dst[0]==src`` .
+:cpp:func:`pyrDown` to the previously built pyramid layers, starting from ``dst[0]==src`` .
.. index:: copyMakeBorder
copyMakeBorder
------------------
-.. c:function:: void copyMakeBorder( const Mat& src, Mat& dst, int top, int bottom, int left, int right, int borderType, const Scalar& value=Scalar() )
+.. cpp:function:: void copyMakeBorder( InputArray src, OutputArray dst, int top, int bottom, int left, int right, int borderType, const Scalar& value=Scalar() )
Forms a border around an image.
: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 borderType: Border type. See :func:`borderInterpolate` for details.
+ :param borderType: Border type. See :cpp:func:`borderInterpolate` for details.
:param value: Border value if ``borderType==BORDER_CONSTANT`` .
The function copies the source image into the middle of the destination image. The areas to the left, to the right, above and below the copied source image will be filled with extrapolated pixels. This is not what
-:func:`FilterEngine` or filtering functions based on it do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling.
+:cpp:func:`FilterEngine` or filtering functions based on it do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling.
The function supports the mode when ``src`` is already in the middle of ``dst`` . In this case, the function does not copy ``src`` itself but simply constructs the border, for example: ::
See Also:
-:func:`borderInterpolate`
+:cpp:func:`borderInterpolate`
.. index:: createBoxFilter
createBoxFilter
-------------------
-.. c:function:: Ptr<FilterEngine> createBoxFilter( int srcType, int dstType, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT)
+.. cpp:function:: Ptr<FilterEngine> createBoxFilter( int srcType, int dstType, Size ksize, Point anchor=Point(-1,-1), bool normalize=true, int borderType=BORDER_DEFAULT)
-.. c:function:: Ptr<BaseRowFilter> getRowSumFilter(int srcType, int sumType, int ksize, int anchor=-1)
+.. cpp:function:: Ptr<BaseRowFilter> getRowSumFilter(int srcType, int sumType, int ksize, int anchor=-1)
-.. c:function:: Ptr<BaseColumnFilter> getColumnSumFilter(int sumType, int dstType, int ksize, int anchor=-1, double scale=1)
+.. cpp:function:: Ptr<BaseColumnFilter> getColumnSumFilter(int sumType, int dstType, int ksize, int anchor=-1, double scale=1)
Returns a box filter engine.
:param anchor: Anchor position with the kernel. Negative values mean that the anchor is at the kernel center.
- :param normalize: Flag specifying whether the sums are normalized or not. See :func:`boxFilter` for details.
+ :param normalize: Flag specifying whether the sums are normalized or not. See :cpp:func:`boxFilter` for details.
:param scale: Another way to specify normalization in lower-level ``getColumnSumFilter`` .
- :param borderType: Border type to use. See :func:`borderInterpolate` .
+ :param borderType: Border type to use. See :cpp:func:`borderInterpolate` .
The function is a convenience function that retrieves the horizontal sum primitive filter with
-:func:`getRowSumFilter` , vertical sum filter with
-:func:`getColumnSumFilter` , constructs new
-:func:`FilterEngine` , and passes both of the primitive filters there. The constructed filter engine can be used for image filtering with normalized or unnormalized box filter.
+:cpp:func:`getRowSumFilter` , vertical sum filter with
+:cpp:func:`getColumnSumFilter` , constructs new
+:cpp:func:`FilterEngine` , and passes both of the primitive filters there. The constructed filter engine can be used for image filtering with normalized or unnormalized box filter.
The function itself is used by
-:func:`blur` and
-:func:`boxFilter` .
+:cpp:func:`blur` and
+:cpp:func:`boxFilter` .
See Also:
-:func:`FilterEngine`,
-:func:`blur`,
-:func:`boxFilter`
+:cpp:func:`FilterEngine`,
+:cpp:func:`blur`,
+:cpp:func:`boxFilter`
.. index:: createDerivFilter
createDerivFilter
---------------------
-.. c:function:: Ptr<FilterEngine> createDerivFilter( int srcType, int dstType, int dx, int dy, int ksize, int borderType=BORDER_DEFAULT )
+.. cpp:function:: Ptr<FilterEngine> createDerivFilter( int srcType, int dstType, int dx, int dy, int ksize, int borderType=BORDER_DEFAULT )
Returns an engine for computing image derivatives.
:param dy: Derivative order in respect of y.
- :param ksize: Aperture size See :func:`getDerivKernels` .
+ :param ksize: Aperture size See :cpp:func:`getDerivKernels` .
- :param borderType: Border type to use. See :func:`borderInterpolate` .
+ :param borderType: Border type to use. See :cpp:func:`borderInterpolate` .
-The function :func:`createDerivFilter` is a small convenience function that retrieves linear filter coefficients for computing image derivatives using
-:func:`getDerivKernels` and then creates a separable linear filter with
-:func:`createSeparableLinearFilter` . The function is used by
-:func:`Sobel` and
-:func:`Scharr` .
+The function :cpp:func:`createDerivFilter` is a small convenience function that retrieves linear filter coefficients for computing image derivatives using
+:cpp:func:`getDerivKernels` and then creates a separable linear filter with
+:cpp:func:`createSeparableLinearFilter` . The function is used by
+:cpp:func:`Sobel` and
+:cpp:func:`Scharr` .
See Also:
-:func:`createSeparableLinearFilter`,
-:func:`getDerivKernels`,
-:func:`Scharr`,
-:func:`Sobel`
+:cpp:func:`createSeparableLinearFilter`,
+:cpp:func:`getDerivKernels`,
+:cpp:func:`Scharr`,
+:cpp:func:`Sobel`
.. index:: createGaussianFilter
createGaussianFilter
------------------------
-.. c:function:: Ptr<FilterEngine> createGaussianFilter( int type, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT)
+.. cpp:function:: Ptr<FilterEngine> createGaussianFilter( int type, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT)
Returns an engine for smoothing images with the Gaussian filter.
:param type: Source and destination image type.
- :param ksize: Aperture size. See :func:`getGaussianKernel` .
+ :param ksize: Aperture size. See :cpp:func:`getGaussianKernel` .
- :param sigmaX: Gaussian sigma in the horizontal direction. See :func:`getGaussianKernel` .
+ :param sigmaX: Gaussian sigma in the horizontal direction. See :cpp:func:`getGaussianKernel` .
:param sigmaY: Gaussian sigma in the vertical direction. If 0, then :math:`\texttt{sigmaY}\leftarrow\texttt{sigmaX}` .
- :param borderType: Border type to use. See :func:`borderInterpolate` .
+ :param borderType: Border type to use. See :cpp:func:`borderInterpolate` .
-The function :func:`createGaussianFilter` computes Gaussian kernel coefficients and then returns a separable linear filter for that kernel. The function is used by
-:func:`GaussianBlur` . Note that while the function takes just one data type, both for input and output, you can pass this limitation by calling
-:func:`getGaussianKernel` and then
-:func:`createSeparableFilter` directly.
+The function :cpp:func:`createGaussianFilter` computes Gaussian kernel coefficients and then returns a separable linear filter for that kernel. The function is used by
+:cpp:func:`GaussianBlur` . Note that while the function takes just one data type, both for input and output, you can pass this limitation by calling
+:cpp:func:`getGaussianKernel` and then
+:cpp:func:`createSeparableFilter` directly.
See Also:
-:func:`createSeparableLinearFilter`,
-:func:`getGaussianKernel`,
-:func:`GaussianBlur`
+:cpp:func:`createSeparableLinearFilter`,
+:cpp:func:`getGaussianKernel`,
+:cpp:func:`GaussianBlur`
.. index:: createLinearFilter
createLinearFilter
----------------------
-.. c:function:: Ptr<FilterEngine> createLinearFilter(int srcType, int dstType, const Mat& kernel, Point _anchor=Point(-1,-1), double delta=0, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1, const Scalar& borderValue=Scalar())
+.. cpp:function:: Ptr<FilterEngine> createLinearFilter(int srcType, int dstType, InputArray kernel, Point _anchor=Point(-1,-1), double delta=0, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1, const Scalar& borderValue=Scalar())
-.. c:function:: Ptr<BaseFilter> getLinearFilter(int srcType, int dstType, const Mat& kernel, Point anchor=Point(-1,-1), double delta=0, int bits=0)
+.. cpp:function:: Ptr<BaseFilter> getLinearFilter(int srcType, int dstType, InputArray kernel, Point anchor=Point(-1,-1), double delta=0, int bits=0)
Creates a non-separable linear filter engine.
:param bits: Number of the fractional bits. the parameter is used when the kernel is an integer matrix representing fixed-point filter coefficients.
- :param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :func:`borderInterpolate` for details.
+ :param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :cpp:func:`borderInterpolate` for details.
:param borderValue: Border vaule used in case of a constant border.
The function returns a pointer to a 2D linear filter for the specified kernel, the source array type, and the destination array type. The function is a higher-level function that calls ``getLinearFilter`` and passes the retrieved 2D filter to the
-:func:`FilterEngine` constructor.
+:cpp:func:`FilterEngine` constructor.
See Also:
-:func:`createSeparableLinearFilter`,
-:func:`FilterEngine`,
-:func:`filter2D`
+:cpp:func:`createSeparableLinearFilter`,
+:cpp:func:`FilterEngine`,
+:cpp:func:`filter2D`
.. index:: createMorphologyFilter
createMorphologyFilter
--------------------------
-.. c:function:: Ptr<FilterEngine> createMorphologyFilter(int op, int type, const Mat& element, Point anchor=Point(-1,-1), int rowBorderType=BORDER_CONSTANT, int columnBorderType=-1, const Scalar& borderValue=morphologyDefaultBorderValue())
+.. cpp:function:: Ptr<FilterEngine> createMorphologyFilter(int op, int type, InputArray element, Point anchor=Point(-1,-1), int rowBorderType=BORDER_CONSTANT, int columnBorderType=-1, const Scalar& borderValue=morphologyDefaultBorderValue())
-.. c:function:: Ptr<BaseFilter> getMorphologyFilter(int op, int type, const Mat& element, Point anchor=Point(-1,-1))
+.. cpp:function:: Ptr<BaseFilter> getMorphologyFilter(int op, int type, InputArray element, Point anchor=Point(-1,-1))
-.. c:function:: Ptr<BaseRowFilter> getMorphologyRowFilter(int op, int type, int esize, int anchor=-1)
+.. cpp:function:: Ptr<BaseRowFilter> getMorphologyRowFilter(int op, int type, int esize, int anchor=-1)
-.. c:function:: Ptr<BaseColumnFilter> getMorphologyColumnFilter(int op, int type, int esize, int anchor=-1)
+.. cpp:function:: Ptr<BaseColumnFilter> getMorphologyColumnFilter(int op, int type, int esize, int anchor=-1)
-.. c:function:: static inline Scalar morphologyDefaultBorderValue(){ return Scalar::all(DBL_MAX) }
+.. cpp:function:: static inline Scalar morphologyDefaultBorderValue(){ return Scalar::all(DBL_MAX) }
Creates an engine for non-separable morphological operations.
:param anchor: Anchor position within the structuring element. Negative values mean that the anchor is at the kernel center.
- :param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :func:`borderInterpolate` for details.
+ :param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :cpp:func:`borderInterpolate` for details.
: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.
The functions construct primitive morphological filtering operations or a filter engine based on them. Normally it is enough to use
-:func:`createMorphologyFilter` or even higher-level
-:func:`erode`,
-:func:`dilate` , or
-:func:`morphologyEx` .
+:cpp:func:`createMorphologyFilter` or even higher-level
+:cpp:func:`erode`,
+:cpp:func:`dilate` , or
+:cpp:func:`morphologyEx` .
Note that
-:func:`createMorphologyFilter` analyzes the structuring element shape and builds a separable morphological filter engine when the structuring element is square.
+:cpp:func:`createMorphologyFilter` analyzes the structuring element shape and builds a separable morphological filter engine when the structuring element is square.
See Also:
-:func:`erode`,
-:func:`dilate`,
-:func:`morphologyEx`,
-:func:`FilterEngine`
+:cpp:func:`erode`,
+:cpp:func:`dilate`,
+:cpp:func:`morphologyEx`,
+:cpp:func:`FilterEngine`
.. index:: createSeparableLinearFilter
createSeparableLinearFilter
-------------------------------
-.. c:function:: Ptr<FilterEngine> createSeparableLinearFilter(int srcType, int dstType, const Mat& rowKernel, const Mat& columnKernel, Point anchor=Point(-1,-1), double delta=0, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1, const Scalar& borderValue=Scalar())
+.. cpp:function:: Ptr<FilterEngine> createSeparableLinearFilter(int srcType, int dstType, InputArray rowKernel, InputArray columnKernel, Point anchor=Point(-1,-1), double delta=0, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1, const Scalar& borderValue=Scalar())
-.. c:function:: Ptr<BaseColumnFilter> getLinearColumnFilter(int bufType, int dstType, const Mat& columnKernel, int anchor, int symmetryType, double delta=0, int bits=0)
+.. cpp:function:: Ptr<BaseColumnFilter> getLinearColumnFilter(int bufType, int dstType, InputArray columnKernel, int anchor, int symmetryType, double delta=0, int bits=0)
-.. c:function:: Ptr<BaseRowFilter> getLinearRowFilter(int srcType, int bufType, const Mat& rowKernel, int anchor, int symmetryType)
+.. cpp:function:: Ptr<BaseRowFilter> getLinearRowFilter(int srcType, int bufType, InputArray rowKernel, int anchor, int symmetryType)
Creates an engine for a separable linear filter.
:param bits: Number of the fractional bits. The parameter is used when the kernel is an integer matrix representing fixed-point filter coefficients.
- :param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :func:`borderInterpolate` for details.
+ :param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :cpp:func:`borderInterpolate` for details.
:param borderValue: Border value used in case of a constant border.
- :param symmetryType: Type of each row and column kernel. See :func:`getKernelType` .
+ :param symmetryType: Type of each row and column kernel. See :cpp:func:`getKernelType` .
The functions construct primitive separable linear filtering operations or a filter engine based on them. Normally it is enough to use
-:func:`createSeparableLinearFilter` or even higher-level
-:func:`sepFilter2D` . The function
-:func:`createMorphologyFilter` is smart enough to figure out the ``symmetryType`` for each of the two kernels, the intermediate ``bufType`` and, if filtering can be done in integer arithmetics, the number of ``bits`` to encode the filter coefficients. If it does not work for you, it is possible to call ``getLinearColumnFilter``,``getLinearRowFilter`` directly and then pass them to the
-:func:`FilterEngine` constructor.
+:cpp:func:`createSeparableLinearFilter` or even higher-level
+:cpp:func:`sepFilter2D` . The function
+:cpp:func:`createMorphologyFilter` is smart enough to figure out the ``symmetryType`` for each of the two kernels, the intermediate ``bufType`` and, if filtering can be done in integer arithmetics, the number of ``bits`` to encode the filter coefficients. If it does not work for you, it is possible to call ``getLinearColumnFilter``,``getLinearRowFilter`` directly and then pass them to the
+:cpp:func:`FilterEngine` constructor.
See Also:
-:func:`sepFilter2D`,
-:func:`createLinearFilter`,
-:func:`FilterEngine`,
-:func:`getKernelType`
+:cpp:func:`sepFilter2D`,
+:cpp:func:`createLinearFilter`,
+:cpp:func:`FilterEngine`,
+:cpp:func:`getKernelType`
.. index:: dilate
dilate
----------
-.. c:function:: void dilate( const Mat& src, Mat& dst, const Mat& element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
+.. cpp:function:: void dilate( InputArray src, OutputArray dst, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
Dilates an image by using a specific structuring element.
:param iterations: Number of times dilation is applied.
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
- :param borderValue: Border value in case of a constant border. The default value has a special meaning. See :func:`createMorphologyFilter` for details.
+ :param borderValue: Border value in case of a constant border. The default value has a special meaning. See :cpp:func:`createMorphologyFilter` for details.
The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken:
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.
See Also:
-:func:`erode`,
-:func:`morphologyEx`,
-:func:`createMorphologyFilter`
+:cpp:func:`erode`,
+:cpp:func:`morphologyEx`,
+:cpp:func:`createMorphologyFilter`
.. index:: erode
erode
---------
-.. c:function:: void erode( const Mat& src, Mat& dst, const Mat& element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
+.. cpp:function:: void erode( InputArray src, OutputArray dst, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
Erodes an image by using a specific structuring element.
:param iterations: Number of times erosion is applied.
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
- :param borderValue: Border value in case of a constant border. The default value has a special meaning. See :func:`createMorphoogyFilter` for details.
+ :param borderValue: Border value in case of a constant border. The default value has a special meaning. See :cpp:func:`createMorphoogyFilter` for details.
The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:
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.
See Also:
-:func:`dilate`,
-:func:`morphologyEx`,
-:func:`createMorphologyFilter`
+:cpp:func:`dilate`,
+:cpp:func:`morphologyEx`,
+:cpp:func:`createMorphologyFilter`
.. index:: filter2D
filter2D
------------
-.. c:function:: void filter2D( const Mat& src, Mat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void filter2D( InputArray src, OutputArray dst, int ddepth, InputArray kernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
Convolves an image with the kernel.
:param ddepth: Desired depth of the destination image. If it is negative, it will be the same as ``src.depth()`` .
- :param kernel: Convolution kernel (or rather a correlation kernel), a single-channel floating point matrix. If you want to apply different kernels to different channels, split the image into separate color planes using :func:`split` and process them individually.
+ :param kernel: Convolution kernel (or rather a correlation kernel), a single-channel floating point matrix. If you want to apply different kernels to different channels, split the image into separate color planes using :cpp:func:`split` and process them individually.
:param anchor: Anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor should lie within the kernel. The special default value (-1,-1) means that the anchor is at the kernel center.
:param delta: Optional value added to the filtered pixels before storing them in ``dst`` .
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode.
\texttt{dst} (x,y) = \sum _{ \stackrel{0\leq x' < \texttt{kernel.cols},}{0\leq y' < \texttt{kernel.rows}} } \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )
That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using
-:func:`flip` and set the new anchor to ``(kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1)`` .
+:cpp:func:`flip` and set the new anchor to ``(kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1)`` .
-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 :func:`createLinearFilter` ) for small kernels.
+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 :cpp:func:`createLinearFilter` ) for small kernels.
See Also:
-:func:`sepFilter2D`,
-:func:`createLinearFilter`,
-:func:`dft`,
-:func:`matchTemplate`
+:cpp:func:`sepFilter2D`,
+:cpp:func:`createLinearFilter`,
+:cpp:func:`dft`,
+:cpp:func:`matchTemplate`
.. index:: GaussianBlur
GaussianBlur
----------------
-.. c:function:: void GaussianBlur( const Mat& src, Mat& dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void GaussianBlur( InputArray src, OutputArray dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT )
Smoothes an image using a Gaussian filter.
:param ksize: Gaussian kernel size. ``ksize.width`` and ``ksize.height`` can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from ``sigma*`` .
- :param sigmaX, sigmaY: Gaussian kernel standard deviations in X and Y direction. If ``sigmaY`` is zero, it is set to be equal to ``sigmaX`` . If they are both zeros, they are computed from ``ksize.width`` and ``ksize.height`` , respectively. See :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, 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 :cpp: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 :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.
See Also:
-:func:`sepFilter2D`,
-:func:`filter2D`,
-:func:`blur`,
-:func:`boxFilter`,
-:func:`bilateralFilter`,
-:func:`medianBlur`
+:cpp:func:`sepFilter2D`,
+:cpp:func:`filter2D`,
+:cpp:func:`blur`,
+:cpp:func:`boxFilter`,
+:cpp:func:`bilateralFilter`,
+:cpp:func:`medianBlur`
.. index:: getDerivKernels
getDerivKernels
-------------------
-.. c:function:: void getDerivKernels( Mat& kx, Mat& ky, int dx, int dy, int ksize, bool normalize=false, int ktype=CV_32F )
+.. cpp:function:: void getDerivKernels( OutputArray kx, OutputArray ky, int dx, int dy, int ksize, bool normalize=false, int ktype=CV_32F )
Returns filter coefficients for computing spatial image derivatives.
The function computes and returns the filter coefficients for spatial image derivatives. When ``ksize=CV_SCHARR`` , the Scharr
:math:`3 \times 3` kernels are generated (see
-:func:`Scharr` ). Otherwise, Sobel kernels are generated (see
-:func:`Sobel` ). The filters are normally passed to
-:func:`sepFilter2D` or to
-:func:`createSeparableLinearFilter` .
+:cpp:func:`Scharr` ). Otherwise, Sobel kernels are generated (see
+:cpp:func:`Sobel` ). The filters are normally passed to
+:cpp:func:`sepFilter2D` or to
+:cpp:func:`createSeparableLinearFilter` .
.. index:: getGaussianKernel
getGaussianKernel
---------------------
-.. c:function:: Mat getGaussianKernel( int ksize, double sigma, int ktype=CV_64F )
+.. cpp:function:: Mat getGaussianKernel( int ksize, double sigma, int ktype=CV_64F )
Returns Gaussian filter coefficients.
:math:`\sum_i G_i=1`.
Two of such generated kernels can be passed to
-:func:`sepFilter2D` or to
-:func:`createSeparableLinearFilter`. Those functions automatically recognize smoothing kernels (i.e. symmetrical kernel with sum of weights = 1) and handle them accordingly. You may also use the higher-level
-:func:`GaussianBlur`.
+:cpp:func:`sepFilter2D` or to
+:cpp:func:`createSeparableLinearFilter`. Those functions automatically recognize smoothing kernels (i.e. symmetrical kernel with sum of weights = 1) and handle them accordingly. You may also use the higher-level
+:cpp:func:`GaussianBlur`.
See Also:
-:func:`sepFilter2D`,
-:func:`createSeparableLinearFilter`,
-:func:`getDerivKernels`,
-:func:`getStructuringElement`,
-:func:`GaussianBlur`
+:cpp:func:`sepFilter2D`,
+:cpp:func:`createSeparableLinearFilter`,
+:cpp:func:`getDerivKernels`,
+:cpp:func:`getStructuringElement`,
+:cpp:func:`GaussianBlur`
.. index:: getKernelType
getKernelType
-----------------
-.. c:function:: int getKernelType(const Mat& kernel, Point anchor)
+.. cpp:function:: int getKernelType(InputArray kernel, Point anchor)
Returns the kernel type.
getStructuringElement
-------------------------
-.. c:function:: Mat getStructuringElement(int shape, Size esize, Point anchor=Point(-1,-1))
+.. cpp:function:: Mat getStructuringElement(int shape, Size esize, Point anchor=Point(-1,-1))
Returns a structuring element of the specified size and shape for morphological operations.
:param anchor: Anchor position within the element. The default value :math:`(-1, -1)` means that the anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor position. In other cases the anchor just regulates how much the result of the morphological operation is shifted.
The function constructs and returns the structuring element that can be then passed to
-:func:`createMorphologyFilter`,
-:func:`erode`,
-:func:`dilate` or
-:func:`morphologyEx` . But you can also construct an arbitrary binary mask yourself and use it as the structuring element.
+:cpp:func:`createMorphologyFilter`,
+:cpp:func:`erode`,
+:cpp:func:`dilate` or
+:cpp:func:`morphologyEx` . But you can also construct an arbitrary binary mask yourself and use it as the structuring element.
.. index:: medianBlur
medianBlur
--------------
-.. c:function:: void medianBlur( const Mat& src, Mat& dst, int ksize )
+.. cpp:function:: void medianBlur( InputArray src, OutputArray dst, int ksize )
Smoothes an image using the median filter.
:math:`\texttt{ksize} \times \texttt{ksize}` aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported.
See Also:
-:func:`bilateralFilter`,
-:func:`blur`,
-:func:`boxFilter`,
-:func:`GaussianBlur`
+:cpp:func:`bilateralFilter`,
+:cpp:func:`blur`,
+:cpp:func:`boxFilter`,
+:cpp:func:`GaussianBlur`
.. index:: morphologyEx
morphologyEx
----------------
-.. c:function:: void morphologyEx( const Mat& src, Mat& dst, int op, const Mat& element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
+.. cpp:function:: void morphologyEx( InputArray src, OutputArray dst, int op, InputArray element, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )
Performs advanced morphological transformations.
:param iterations: Number of times erosion and dilation are applied.
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
- :param borderValue: Border value in case of a constant border. The default value has a special meaning. See :func:`createMorphoogyFilter` for details.
+ :param borderValue: Border value in case of a constant border. The default value has a special meaning. See :cpp:func:`createMorphoogyFilter` for details.
The function can perform advanced morphological transformations using an erosion and dilation as basic operations.
Any of the operations can be done in-place.
See Also:
-:func:`dilate`,
-:func:`erode`,
-:func:`createMorphologyFilter`
+:cpp:func:`dilate`,
+:cpp:func:`erode`,
+:cpp:func:`createMorphologyFilter`
.. index:: Laplacian
Laplacian
-------------
-.. c:function:: void Laplacian( const Mat& src, Mat& dst, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void Laplacian( InputArray src, OutputArray dst, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
Calculates the Laplacian of an image.
:param ddepth: Desired depth of the destination image.
- :param ksize: Aperture size used to compute the second-derivative filters. See :func:`getDerivKernels` for details. The size must be positive and odd.
+ :param ksize: Aperture size used to compute the second-derivative filters. See :cpp:func:`getDerivKernels` for details. The size must be positive and odd.
- :param scale: Optional scale factor for the computed Laplacian values. By default, no scaling is applied. See :func:`getDerivKernels` for details.
+ :param scale: Optional scale factor for the computed Laplacian values. By default, no scaling is applied. See :cpp:func:`getDerivKernels` for details.
:param delta: Optional delta value that is added to the results prior to storing them in ``dst`` .
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator:
\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}
See Also:
-:func:`Sobel`,
-:func:`Scharr`
+:cpp:func:`Sobel`,
+:cpp:func:`Scharr`
.. index:: pyrDown
pyrDown
-----------
-.. c:function:: void pyrDown( const Mat& src, Mat& dst, const Size& dstsize=Size())
+.. cpp:function:: void pyrDown( InputArray src, OutputArray dst, const Size& dstsize=Size())
Smoothes an image and downsamples it.
pyrUp
---------
-.. c:function:: void pyrUp( const Mat& src, Mat& dst, const Size& dstsize=Size())
+.. cpp:function:: void pyrUp( InputArray src, OutputArray dst, const Size& dstsize=Size())
Upsamples an image and then smoothes it.
| \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}
The function performs the upsampling step of the Gaussian pyramid construction though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in
-:func:`pyrDown` multiplied by 4.
+:cpp:func:`pyrDown` multiplied by 4.
.. index:: sepFilter2D
sepFilter2D
---------------
-.. c:function:: void sepFilter2D( const Mat& src, Mat& dst, int ddepth, const Mat& rowKernel, const Mat& columnKernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void sepFilter2D( InputArray src, OutputArray dst, int ddepth, InputArray rowKernel, InputArray columnKernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
Applies a separable linear filter to an image.
:param delta: Value added to the filtered results before storing them.
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
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`` .
See Also:
-:func:`createSeparableLinearFilter`,
-:func:`filter2D`,
-:func:`Sobel`,
-:func:`GaussianBlur`,
-:func:`boxFilter`,
-:func:`blur`
+:cpp:func:`createSeparableLinearFilter`,
+:cpp:func:`filter2D`,
+:cpp:func:`Sobel`,
+:cpp:func:`GaussianBlur`,
+:cpp:func:`boxFilter`,
+:cpp:func:`blur`
.. index:: Sobel
Sobel
---------
-.. c:function:: void Sobel( const Mat& src, Mat& dst, int ddepth, int xorder, int yorder, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void Sobel( InputArray src, OutputArray dst, int ddepth, int xorder, int yorder, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
:param ksize: Size of the extended Sobel kernel. It must be 1, 3, 5, or 7.
- :param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :func:`getDerivKernels` for details.
+ :param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :cpp:func:`getDerivKernels` for details.
:param delta: Optional delta value that is added to the results prior to storing them in ``dst`` .
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
In all cases except one, the
:math:`\texttt{ksize} \times
\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}
See Also:
-:func:`Scharr`,
-:func:`Lapacian`,
-:func:`sepFilter2D`,
-:func:`filter2D`,
-:func:`GaussianBlur`
+:cpp:func:`Scharr`,
+:cpp:func:`Lapacian`,
+:cpp:func:`sepFilter2D`,
+:cpp:func:`filter2D`,
+:cpp:func:`GaussianBlur`
.. index:: Scharr
Scharr
----------
-.. c:function:: void Scharr( const Mat& src, Mat& dst, int ddepth, int xorder, int yorder, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
+.. cpp:function:: void Scharr( InputArray src, OutputArray dst, int ddepth, int xorder, int yorder, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
Calculates the first x- or y- image derivative using Scharr operator.
:param yorder: Order of the derivative y.
- :param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :func:`getDerivKernels` for details.
+ :param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :cpp:func:`getDerivKernels` for details.
:param delta: Optional delta value that is added to the results prior to storing them in ``dst`` .
- :param borderType: Pixel extrapolation method. See :func:`borderInterpolate` for details.
+ :param borderType: Pixel extrapolation method. See :cpp:func:`borderInterpolate` for details.
The function computes the first x- or y- spatial image derivative using the Scharr operator. The call
convertMaps
-----------
-.. c:function:: void convertMaps( const Mat& map1, const Mat& map2, Mat& dstmap1, Mat& dstmap2, int dstmap1type, bool nninterpolation=false )
+.. cpp:function:: void convertMaps( InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, int dstmap1type, bool nninterpolation=false )
Converts image transformation maps from one representation to another.
:param nninterpolation: Flag indicating whether the fixed-point maps are used for the nearest-neighbor or for a more complex interpolation.
The function converts a pair of maps for
-:func:`remap` from one representation to another. The following options ( ``(map1.type(), map2.type())`` :math:`\rightarrow` ``(dstmap1.type(), dstmap2.type())`` ) are supported:
+:cpp:func:`remap` from one representation to another. The following options ( ``(map1.type(), map2.type())`` :math:`\rightarrow` ``(dstmap1.type(), dstmap2.type())`` ) are supported:
*
:math:`\texttt{(CV\_32FC1, CV\_32FC1)} \rightarrow \texttt{(CV\_16SC2, CV\_16UC1)}` . This is the most frequently used conversion operation, in which the original floating-point maps (see
- :func:`remap` ) are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only when ``nninterpolation=false`` ) contains indices in the interpolation tables.
+ :cpp:func:`remap` ) are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only when ``nninterpolation=false`` ) contains indices in the interpolation tables.
*
:math:`\texttt{(CV\_32FC2)} \rightarrow \texttt{(CV\_16SC2, CV\_16UC1)}` . The same as above but the original maps are stored in one 2-channel matrix.
Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.
See Also:
-:func:`remap`,
-:func:`undisort`,
-:func:`initUndistortRectifyMap`
+:cpp:func:`remap`,
+:cpp:func:`undisort`,
+:cpp:func:`initUndistortRectifyMap`
.. index:: getAffineTransform
-.. _getAffineTransform:
-
getAffineTransform
----------------------
-.. c:function:: Mat getAffineTransform( const Point2f src[], const Point2f dst[] )
+.. cpp:function:: Mat getAffineTransform( const Point2f src[], const Point2f dst[] )
Calculates an affine transform from three pairs of the corresponding points.
i=0,1,2
See Also:
-:func:`warpAffine`,
-:func:`transform`
+:cpp:func:`warpAffine`,
+:cpp:func:`transform`
.. index:: getPerspectiveTransform
getPerspectiveTransform
---------------------------
-.. c:function:: Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
+.. cpp:function:: Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
Calculates a perspective transform from four pairs of the corresponding points.
i=0,1,2
See Also:
-:func:`findHomography`,
-:func:`warpPerspective`,
-:func:`perspectiveTransform`
+:cpp:func:`findHomography`,
+:cpp:func:`warpPerspective`,
+:cpp:func:`perspectiveTransform`
.. index:: getRectSubPix
getRectSubPix
-----------------
-.. c:function:: void getRectSubPix( const Mat& image, Size patchSize, Point2f center, Mat& dst, int patchType=-1 )
+.. cpp:function:: void getRectSubPix( InputArray image, Size patchSize, Point2f center, OutputArray dst, int patchType=-1 )
Retrieves a pixel rectangle from an image with sub-pixel accuracy.
images is processed independently. While the center of the rectangle
must be inside the image, parts of the rectangle may be
outside. In this case, the replication border mode (see
-:func:`borderInterpolate` ) is used to extrapolate
+:cpp:func:`borderInterpolate` ) is used to extrapolate
the pixel values outside of the image.
See Also:
-:func:`warpAffine`,
-:func:`warpPerspective`
+:cpp:func:`warpAffine`,
+:cpp:func:`warpPerspective`
.. index:: getRotationMatrix2D
getRotationMatrix2D
-----------------------
-.. c:function:: Mat getRotationMatrix2D( Point2f center, double angle, double scale )
+.. cpp:function:: Mat getRotationMatrix2D( Point2f center, double angle, double scale )
Calculates an affine matrix of 2D rotation.
The transformation maps the rotation center to itself. If this is not the target, adjust the shift.
See Also:
-:func:`getAffineTransform`,
-:func:`warpAffine`,
-:func:`transform`
+:cpp:func:`getAffineTransform`,
+:cpp:func:`warpAffine`,
+:cpp:func:`transform`
.. index:: invertAffineTransform
invertAffineTransform
-------------------------
-.. c:function:: void invertAffineTransform(const Mat& M, Mat& iM)
+.. cpp:function:: void invertAffineTransform(InputArray M, OutputArray iM)
Inverts an affine transformation.
remap
-----
-.. c:function:: void remap( const Mat& src, Mat& dst, const Mat& map1, const Mat& map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
+.. cpp:function:: void remap( InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
Applies a generic geometrical transformation to an image.
:param src: Source image.
:param dst: Destination image. It has the same size as ``map1`` and the same type as ``src`` .
- :param map1: The first map of either ``(x,y)`` points or just ``x`` values having the type ``CV_16SC2`` , ``CV_32FC1`` , or ``CV_32FC2`` . See :func:`convertMaps` for details on converting a floating point representation to fixed-point for speed.
+ :param map1: The first map of either ``(x,y)`` points or just ``x`` values having the type ``CV_16SC2`` , ``CV_32FC1`` , or ``CV_32FC2`` . See :cpp:func:`convertMaps` for details on converting a floating point representation to fixed-point for speed.
:param map2: The second map of ``y`` values having the type ``CV_16UC1`` , ``CV_32FC1`` , or none (empty map if ``map1`` is ``(x,y)`` points), respectively.
- :param interpolation: Interpolation method (see :func:`resize` ). The method ``INTER_AREA`` is not supported by this function.
+ :param interpolation: Interpolation method (see :cpp:func:`resize` ). The method ``INTER_AREA`` is not supported by this function.
- :param borderMode: Pixel extrapolation method (see :func:`borderInterpolate` ). When \ ``borderMode=BORDER_TRANSPARENT`` , it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function.
+ :param borderMode: Pixel extrapolation method (see :cpp:func:`borderInterpolate` ). When \ ``borderMode=BORDER_TRANSPARENT`` , it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function.
:param borderValue: Value used in case of a constant border. By default, it is 0.
:math:`(x,y)` in
:math:`map_1` , or
fixed-point maps created by using
-:func:`convertMaps` . The reason you might want to convert from floating to fixed-point
+:cpp:func:`convertMaps` . The reason you might want to convert from floating to fixed-point
representations of a map is that they can yield much faster (~2x) remapping operations. In the converted case,
:math:`map_1` contains pairs ``(cvFloor(x), cvFloor(y))`` and
:math:`map_2` contains indices in a table of interpolation coefficients.
resize
----------
-.. c:function:: void resize( const Mat& src, Mat& dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR )
+.. cpp:function:: void resize( InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR )
Resizes an image.
See Also:
-:func:`warpAffine`,
-:func:`warpPerspective`,
-:func:`remap`
+:cpp:func:`warpAffine`,
+:cpp:func:`warpPerspective`,
+:cpp:func:`remap`
.. index:: warpAffine
warpAffine
--------------
-.. c:function:: void warpAffine( const Mat& src, Mat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
+.. cpp:function:: void warpAffine( InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
Applies an affine transformation to an image.
:param dsize: Size of the destination image.
- :param flags: Combination of interpolation methods (see :func:`resize` ) and the optional flag ``WARP_INVERSE_MAP`` that means that ``M`` is the inverse transformation ( :math:`\texttt{dst}\rightarrow\texttt{src}` ).
+ :param flags: Combination of interpolation methods (see :cpp:func:`resize` ) and the optional flag ``WARP_INVERSE_MAP`` that means that ``M`` is the inverse transformation ( :math:`\texttt{dst}\rightarrow\texttt{src}` ).
- :param borderMode: Pixel extrapolation method (see :func:`borderInterpolate` ). When \ ``borderMode=BORDER_TRANSPARENT`` , it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function.
+ :param borderMode: Pixel extrapolation method (see :cpp:func:`borderInterpolate` ). When \ ``borderMode=BORDER_TRANSPARENT`` , it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function.
:param borderValue: Value used in case of a constant border. By default, it is 0.
\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})
when the flag ``WARP_INVERSE_MAP`` is set. Otherwise, the transformation is first inverted with
-:func:`invertAffineTransform` and then put in the formula above instead of ``M`` .
+:cpp:func:`invertAffineTransform` and then put in the formula above instead of ``M`` .
The function cannot operate in-place.
See Also:
-:func:`warpPerspective`,
-:func:`resize`,
-:func:`remap`,
-:func:`getRectSubPix`,
-:func:`transform`
+:cpp:func:`warpPerspective`,
+:cpp:func:`resize`,
+:cpp:func:`remap`,
+:cpp:func:`getRectSubPix`,
+:cpp:func:`transform`
.. index:: warpPerspective
-.. _warpPerspective:
-
warpPerspective
-------------------
-.. c:function:: void warpPerspective( const Mat& src, Mat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
+.. cpp:function:: void warpPerspective( InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
Applies a perspective transformation to an image.
:param dsize: Size of the destination image.
- :param flags: Combination of interpolation methods (see :func:`resize` ) and the optional flag ``WARP_INVERSE_MAP`` that means that ``M`` is the inverse transformation ( :math:`\texttt{dst}\rightarrow\texttt{src}` ).
+ :param flags: Combination of interpolation methods (see :cpp:func:`resize` ) and the optional flag ``WARP_INVERSE_MAP`` that means that ``M`` is the inverse transformation ( :math:`\texttt{dst}\rightarrow\texttt{src}` ).
- :param borderMode: Pixel extrapolation method (see :func:`borderInterpolate` ). When \ ``borderMode=BORDER_TRANSPARENT`` , it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function.
+ :param borderMode: Pixel extrapolation method (see :cpp:func:`borderInterpolate` ). When \ ``borderMode=BORDER_TRANSPARENT`` , it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function.
:param borderValue: Value used in case of a constant border. By default, it is 0.
\frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )
when the flag ``WARP_INVERSE_MAP`` is set. Otherwise, the transformation is first inverted with
-:func:`invert` and then put in the formula above instead of ``M`` .
+:cpp:func:`invert` and then put in the formula above instead of ``M`` .
The function cannot operate in-place.
See Also:
-:func:`warpAffine`,
-:func:`resize`,
-:func:`remap`,
-:func:`getRectSubPix`,
-:func:`perspectiveTransform`
+:cpp:func:`warpAffine`,
+:cpp:func:`resize`,
+:cpp:func:`remap`,
+:cpp:func:`getRectSubPix`,
+:cpp:func:`perspectiveTransform`
+
+
+.. index:: initUndistortRectifyMap
+
+initUndistortRectifyMap
+---------------------------
+
+.. cpp:function:: void initUndistortRectifyMap( InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2 )
+
+ Computes the undistortion and rectification transformation map.
+
+ :param cameraMatrix: Input camera matrix :math:`A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}` .
+
+ :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.
+
+ :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 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` .
+
+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
+: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::
+
+ \begin{array}{l} x \leftarrow (u - {c'}_x)/{f'}_x \\ y \leftarrow (v - {c'}_y)/{f'}_y \\{[X\,Y\,W]} ^T \leftarrow R^{-1}*[x \, y \, 1]^T \\ x' \leftarrow X/W \\ y' \leftarrow Y/W \\ x" \leftarrow x' (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + 2p_1 x' y' + p_2(r^2 + 2 x'^2) \\ y" \leftarrow y' (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' \\ map_x(u,v) \leftarrow x" f_x + c_x \\ map_y(u,v) \leftarrow y" f_y + c_y \end{array}
+
+where
+:math:`(k_1, k_2, p_1, p_2[, k_3])` are the distortion coefficients.
+
+In case of a stereo camera, this function is called twice: once for each camera head, after
+:ref:`StereoRectify` , which in its turn is called after
+:ref:`StereoCalibrate` . But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from the fundamental matrix using
+:ref:`StereoRectifyUncalibrated` . For each camera, the function computes homography ``H`` as the rectification transformation in a pixel domain, not a rotation matrix ``R`` in 3D space. ``R`` can be computed from ``H`` as
+
+.. math::
+
+ \texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}
+
+where ``cameraMatrix`` can be chosen arbitrarily.
+
+
+.. index:: getDefaultNewCameraMatrix
+
+getDefaultNewCameraMatrix
+-----------------------------
+.. cpp:function:: Mat getDefaultNewCameraMatrix(InputArray cameraMatrix, Size imgSize=Size(), bool centerPrincipalPoint=false )
+
+ Returns the default new camera matrix.
+
+ :param cameraMatrix: Input camera matrix.
+
+ :param imageSize: Camera view image size in pixels.
+
+ :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).
+
+In the latter case, the new camera matrix will be:
+
+.. math::
+
+ \begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,
+
+where
+:math:`f_x` and
+:math:`f_y` are
+:math:`(0,0)` and
+: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.
+
+
+.. index:: undistort
+
+undistort
+-------------
+.. cpp:function:: void undistort( InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix=None() )
+
+ Transforms an image to compensate for lens distortion.
+
+ :param src: Input (distorted) image.
+
+ :param dst: Output (corrected) image that has the same size and type as ``src`` .
+
+ :param cameraMatrix: Input camera matrix :math:`A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}` .
+
+ :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 newCameraMatrix: Camera matrix of the distorted image. By default, it is the same as ``cameraMatrix`` but you may additionally scale and shift the result by using a different matrix.
+
+The function transforms an image to compensate radial and tangential lens distortion.
+
+The function is simply a combination of
+:ref:`InitUndistortRectifyMap` (with unity ``R`` ) and
+:ref:`Remap` (with bilinear interpolation). See the former function for details of the transformation being performed.
+
+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.
+
+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,
+:math:`f_x, f_y, c_x` and
+:math:`c_y` need to be scaled accordingly, while the distortion coefficients remain the same.
+
+
+.. index:: undistortPoints
+
+undistortPoints
+-------------------
+.. cpp:function:: void undistortPoints( InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray R=None(), InputArray P=None())
+
+ Computes the ideal point coordinates from the observed point coordinates.
+
+ :param src: Observed point coordinates, 1xN or Nx1 2-channel (CV_32FC2 or CV_64FC2).
+
+ :param dst: Output ideal point coordinates after undistortion and reverse perspective transformation.
+
+ :param cameraMatrix: Camera matrix :math:`\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}` .
+
+ :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 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.
+
+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. ::
+
+ // (u,v) is the input point, (u', v') is the output point
+ // camera_matrix=[fx 0 cx; 0 fy cy; 0 0 1]
+ // P=[fx' 0 cx' tx; 0 fy' cy' ty; 0 0 1 tz]
+ x" = (u - cx)/fx
+ y" = (v - cy)/fy
+ (x',y') = undistort(x",y",dist_coeffs)
+ [X,Y,W]T = R*[x' y' 1]T
+ x = X/W, y = Y/W
+ u' = x*fx' + cx'
+ v' = y*fy' + cy',
+
+where ``undistort()`` is an approximate iterative algorithm that estimates the normalized original point coordinates out of the normalized distorted point coordinates ("normalized" means that the coordinates do not depend on the camera matrix).
+
+The function can be used for both a stereo camera head or a monocular camera (when R is empty).
+
\ No newline at end of file
.. index:: calcHist
-.. _calcHist:
-
calcHist
------------
-.. c:function:: void calcHist( const Mat* arrays, int narrays, const int* channels, const Mat\& mask, MatND\& hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
+.. cpp:function:: void calcHist( const Mat* arrays, int narrays, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
-.. c:function:: void calcHist( const Mat* arrays, int narrays, const int* channels, const Mat\& mask, SparseMat\& hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
+.. cpp:function:: void calcHist( const Mat* arrays, int narrays, const int* channels, InputArray mask, SparseMat& hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
Calculates a histogram of a set of arrays.
.. index:: calcBackProject
-.. _calcBackProject:
-
calcBackProject
-------------------
-.. c:function:: void calcBackProject( const Mat* arrays, int narrays, const int* channels, const MatND\& hist, Mat\& backProject, const float** ranges, double scale=1, bool uniform=true )
+.. cpp:function:: void calcBackProject( const Mat* arrays, int narrays, const int* channels, InputArray hist, OutputArray backProject, const float** ranges, double scale=1, bool uniform=true )
-.. c:function:: void calcBackProject( const Mat* arrays, int narrays, const int* channels, const SparseMat\& hist, Mat\& backProject, const float** ranges, double scale=1, bool uniform=true )
+.. cpp:function:: void calcBackProject( const Mat* arrays, int narrays, const int* channels, const SparseMat& hist, OutputArray backProject, const float** ranges, double scale=1, bool uniform=true )
Calculates the back projection of a histogram.
:param backProject: Destination back projection aray that is a single-channel array of the same size and depth as ``arrays[0]`` .
- :param ranges: Array of arrays of the histogram bin boundaries in each dimension. See :func:`calcHist` .
+ :param ranges: Array of arrays of the histogram bin boundaries in each dimension. See :cpp:func:`calcHist` .
:param scale: Optional scale factor for the output back projection.
Find connected components in the resulting picture and choose, for example, the largest component.
This is an approximate algorithm of the
-:func:`CAMShift` color object tracker.
+:cpp:func:`CAMShift` color object tracker.
See Also:
-:func:`calcHist`
+:cpp:func:`calcHist`
.. index:: compareHist
-.. _compareHist:
-
compareHist
-----------
-.. c:function:: double compareHist( const MatND\& H1, const MatND\& H2, int method )
+.. cpp:function:: double compareHist( InputArray H1, InputArray H2, int method )
-.. c:function:: double compareHist( const SparseMat\& H1, const SparseMat\& H2, int method )
+.. cpp:function:: double compareHist( const SparseMat& H1, const SparseMat& H2, int method )
Compares two histograms.
:math:`d(H_1, H_2)` .
While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms or more general sparse configurations of weighted points, consider using the
-:func:`calcEMD` function.
+:cpp:func:`calcEMD` function.
.. index:: equalizeHist
-.. _equalizeHist:
-
equalizeHist
----------------
-.. c:function:: void equalizeHist( const Mat\& src, Mat\& dst )
+.. cpp:function:: void equalizeHist( InputArray src, OutputArray dst )
Equalizes the histogram of a grayscale image.
adaptiveThreshold
---------------------
-.. c:function:: void adaptiveThreshold( const Mat& src, Mat& dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C )
+.. cpp:function:: void adaptiveThreshold( InputArray src, OutputArray dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C )
Applies an adaptive threshold to an array.
:math:`T(x, y)` is a weighted sum (cross-correlation with a Gaussian window) of the
:math:`\texttt{blockSize} \times \texttt{blockSize}` neighborhood of
:math:`(x, y)` minus ``C`` . The default sigma (standard deviation) is used for the specified ``blockSize`` . See
- :func:`getGaussianKernel` .
+ :cpp:func:`getGaussianKernel` .
The function can process the image in-place.
See Also:
-:func:`threshold`,
-:func:`blur`,
-:func:`GaussianBlur`
+:cpp:func:`threshold`,
+:cpp:func:`blur`,
+:cpp:func:`GaussianBlur`
.. index:: cvtColor
cvtColor
------------
-.. c:function:: void cvtColor( const Mat& src, Mat& dst, int code, int dstCn=0 )
+.. cpp:function:: void cvtColor( InputArray src, OutputArray dst, int code, int dstCn=0 )
Converts an image from one color space to another.
..
More advanced channel reordering can also be done with
- :func:`mixChannels` .
+ :cpp:func:`mixChannels` .
*
RGB
distanceTransform
---------------------
-.. c:function:: void distanceTransform( const Mat& src, Mat& dst, int distanceType, int maskSize )
+.. cpp:function:: void distanceTransform( InputArray src, OutputArray dst, int distanceType, int maskSize )
-.. c:function:: void distanceTransform( const Mat& src, Mat& dst, Mat& labels, int distanceType, int maskSize )
+.. cpp:function:: void distanceTransform( InputArray src, OutputArray dst, OutputArray labels, int distanceType, int maskSize )
Calculates the distance to the closest zero pixel for each pixel of the source image.
floodFill
-------------
-.. c:function:: int floodFill( Mat& image, Point seed, Scalar newVal, Rect* rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4 )
+.. cpp:function:: int floodFill( InputOutputArray image, Point seed, Scalar newVal, Rect* rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4 )
-.. c:function:: int floodFill( Mat& image, Mat& mask, Point seed, Scalar newVal, Rect* rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4 )
+.. cpp:function:: int floodFill( InputOutputArray image, InputOutputArray mask, Point seed, Scalar newVal, Rect* rect=0, Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), int flags=4 )
Fills a connected component with the given color.
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:
-:func:`findContours`
+:cpp:func:`findContours`
.. index:: inpaint
inpaint
-----------
-.. c:function:: void inpaint( const Mat& src, const Mat& inpaintMask, Mat& dst, double inpaintRadius, int flags )
+.. cpp:function:: void inpaint( InputArray src, InputArray inpaintMask, OutputArray dst, double inpaintRadius, int flags )
Restores the selected region in an image using the region neighborhood.
.. index:: integral
-.. _integral:
-
integral
------------
-.. c:function:: void integral( const Mat& image, Mat& sum, int sdepth=-1 )
+.. cpp:function:: void integral( InputArray image, OutputArray sum, int sdepth=-1 )
-.. c:function:: void integral( const Mat& image, Mat& sum, Mat& sqsum, int sdepth=-1 )
+.. cpp:function:: void integral( InputArray image, OutputArray sum, OutputArray sqsum, int sdepth=-1 )
-.. c:function:: void integral( const Mat& image, Mat& sum, Mat& sqsum, Mat& tilted, int sdepth=-1 )
+.. cpp:function:: void integral( InputArray image, OutputArray sum, OutputArray sqsum, OutputArray tilted, int sdepth=-1 )
Calculates the integral of an image.
threshold
-------------
-.. c:function:: double threshold( const Mat& src, Mat& dst, double thresh, double maxVal, int thresholdType )
+.. cpp:function:: double threshold( InputArray src, OutputArray dst, double thresh, double maxVal, int thresholdType )
Applies a fixed-level threshold to each array element.
The function applies fixed-level thresholding
to a single-channel array. The function is typically used to get a
bi-level (binary) image out of a grayscale image (
-:func:`compare` could
+:cpp:func:`compare` could
be also used for this purpose) or for removing a noise, that is, filtering
out pixels with too small or too large values. There are several
types of thresholding supported by the function. They are determined by ``thresholdType`` :
.. image:: pics/threshold.png
See Also:
-:func:`adaptiveThreshold`,
-:func:`findContours`,
-:func:`compare`,
-:func:`min`,
-:func:`max`
+:cpp:func:`adaptiveThreshold`,
+:cpp:func:`findContours`,
+:cpp:func:`compare`,
+:cpp:func:`min`,
+:cpp:func:`max`
.. index:: watershed
-.. _watershed:
-
watershed
-------------
-.. c:function:: void watershed( const Mat& image, Mat& markers )
+.. cpp:function:: void watershed( InputArray image, InputOutputArray markers )
Performs a marker-based image segmentation using the watershed algrorithm.
represented as one or more connected components with the pixel values
1, 2, 3, and so on. Such markers can be retrieved from a binary mask
using
-:func:`findContours` and
-:func:`drawContours` (see the ``watershed.cpp`` demo).
+:cpp:func:`findContours` and
+:cpp:func:`drawContours` (see the ``watershed.cpp`` demo).
The markers are "seeds" of the future image
regions. All the other pixels in ``markers`` , whose relation to the
outlined regions is not known and should be defined by the algorithm,
can be found in the OpenCV samples directory (see the ``watershed.cpp`` demo).
See Also:
-:func:`findContours`
+:cpp:func:`findContours`
.. index:: grabCut
-.. _grabCut:
-
grabCut
-------
-.. c:function:: void grabCut(const Mat& image, Mat& mask, Rect rect, Mat& bgdModel, Mat& fgdModel, int iterCount, int mode )
+.. cpp:function:: void grabCut(InputArray image, InputOutputArray mask, Rect rect, InputOutputArray bgdModel, InputOutputArray fgdModel, int iterCount, int mode )
Runs the GrabCut algorithm.
accumulate
--------------
-.. c:function:: void accumulate( const Mat\& src, Mat\& dst, const Mat\& mask=Mat() )
+.. cpp:function:: void accumulate( InputArray src, InputOutputArray dst, InputArray mask=None() )
Adds an image to the accumulator.
The functions ``accumulate*`` can be used, for example, to collect statistics of a scene background viewed by a still camera and for the further foreground-background segmentation.
See Also:
-:func:`accumulateSquare`,
-:func:`accumulateProduct`,
-:func:`accumulateWeighted`
+:cpp:func:`accumulateSquare`,
+:cpp:func:`accumulateProduct`,
+:cpp:func:`accumulateWeighted`
.. index:: accumulateSquare
accumulateSquare
--------------------
-.. c:function:: void accumulateSquare( const Mat\& src, Mat\& dst, const Mat\& mask=Mat() )
+.. cpp:function:: void accumulateSquare( InputArray src, InputOutputArray dst, InputArray mask=None() )
Adds the square of a source image to the accumulator.
The function supports multi-channel images Each channel is processed independently.
See Also:
-:func:`accumulateSquare`,
-:func:`accumulateProduct`,
-:func:`accumulateWeighted`
+:cpp:func:`accumulateSquare`,
+:cpp:func:`accumulateProduct`,
+:cpp:func:`accumulateWeighted`
.. index:: accumulateProduct
accumulateProduct
---------------------
-.. c:function:: void accumulateProduct( const Mat\& src1, const Mat\& src2, Mat\& dst, const Mat\& mask=Mat() )
+.. cpp:function:: void accumulateProduct( InputArray src1, InputArray src2, InputOutputArray dst, InputArray mask=None() )
Adds the per-element product of two input images to the accumulator.
The function supports multi-channel images. Each channel is processed independently.
See Also:
-:func:`accumulate`,
-:func:`accumulateSquare`,
-:func:`accumulateWeighted`
+:cpp:func:`accumulate`,
+:cpp:func:`accumulateSquare`,
+:cpp:func:`accumulateWeighted`
.. index:: accumulateWeighted
accumulateWeighted
----------------------
-.. c:function:: void accumulateWeighted( const Mat\& src, Mat\& dst, double alpha, const Mat\& mask=Mat() )
+.. cpp:function:: void accumulateWeighted( InputArray src, InputOutputArray dst, double alpha, InputArray mask=None() )
Updates a running average.
The function supports multi-channel images. Each channel is processed independently.
See Also:
-:func:`accumulate`,
-:func:`accumulateSquare`,
-:func:`accumulateProduct`
\ No newline at end of file
+:cpp:func:`accumulate`,
+:cpp:func:`accumulateSquare`,
+:cpp:func:`accumulateProduct`
\ No newline at end of file
matchTemplate
-----------------
-.. c:function:: void matchTemplate( const Mat& image, const Mat& temp, Mat& result, int method )
+.. cpp:function:: void matchTemplate( InputArray image, InputArray temp, OutputArray result, int method )
Compares a template against overlapped image regions.
R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{ \sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2} }
After the function finishes the comparison, the best matches can be found as global minimums (when ``CV_TM_SQDIFF`` was used) or maximums (when ``CV_TM_CCORR`` or ``CV_TM_CCOEFF`` was used) using the
-:func:`minMaxLoc` function. In case of a color image, template summation in the numerator and each sum in the denominator is done over all of the channels and separate mean values are used for each channel. That is, the function can take a color template and a color image. The result will still be a single-channel image, which is easier to analyze.
+:cpp:func:`minMaxLoc` function. In case of a color image, template summation in the numerator and each sum in the denominator is done over all of the channels and separate mean values are used for each channel. That is, the function can take a color template and a color image. The result will still be a single-channel image, which is easier to analyze.
moments
-----------
-.. c:function:: Moments moments( const Mat& array, bool binaryImage=false )
+.. cpp:function:: Moments moments( InputArray array, bool binaryImage=false )
Calculates all of the moments up to the third order of a polygon or rasterized shape where the class ``Moments`` is defined as: ::
). 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:
-:func:`contourArea`,
-:func:`arcLength`
+:cpp:func:`contourArea`,
+:cpp:func:`arcLength`
.. index:: HuMoments
HuMoments
-------------
-.. c:function:: void HuMoments( const Moments& moments, double h[7] )
+.. cpp:function:: void HuMoments( const Moments& moments, double h[7] )
Calculates the seven Hu invariants.
- :param moments: Input moments computed with :func:`moments` .
+ :param moments: Input moments computed with :cpp:func:`moments` .
:param h: Output Hu invariants.
The function calculates the seven Hu invariants (see
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:
-:func:`matchShapes`
+:cpp:func:`matchShapes`
.. index:: findContours
findContours
----------------
-.. c:function:: void findContours( const Mat& image, vector<vector<Point> >& contours, vector<Vec4i>& hierarchy, int mode, int method, Point offset=Point())
+.. cpp:function:: void findContours( InputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset=Point())
-.. c:function:: void findContours( const Mat& image, vector<vector<Point> >& contours, int mode, int method, Point offset=Point())
+.. cpp:function:: void findContours( InputArray image, OutputArrayOfArrays contours, int mode, int method, Point offset=Point())
Finds contours in a binary image.
- :param image: Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero pixels remain 0's, so the image is treated as ``binary`` . You can use :func:`compare` , :func:`inRange` , :func:`threshold` , :func:`adaptiveThreshold` , :func:`Canny` , and others to create a binary image out of a grayscale or color one. The function modifies the ``image`` while extracting the contours.
+ :param image: Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero pixels remain 0's, so the image is treated as ``binary`` . You can use :cpp:func:`compare` , :cpp:func:`inRange` , :cpp:func:`threshold` , :cpp:func:`adaptiveThreshold` , :cpp:func:`Canny` , and others to create a binary image out of a grayscale or color one. The function modifies the ``image`` while extracting the contours.
:param contours: Detected contours. Each contour is stored as a vector of points.
drawContours
----------------
-.. c:function:: void drawContours( Mat& image, const vector<vector<Point> >& contours, int contourIdx, const Scalar& color, int thickness=1, int lineType=8, const vector<Vec4i>& hierarchy=vector<Vec4i>(), int maxLevel=INT_MAX, Point offset=Point() )
+.. cpp:function:: void drawContours( InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const Scalar& color, int thickness=1, int lineType=8, InputArray hierarchy=None(), int maxLevel=INT_MAX, Point offset=Point() )
Draws contours outlines or filled contours.
:param thickness: Thickness of lines the contours are drawn with. If it is negative (for example, ``thickness=CV_FILLED`` ), the contour interiors are
drawn.
- :param lineType: Line connectivity. See :func:`line` for details.
+ :param lineType: Line connectivity. See :cpp:func:`line` for details.
:param hierarchy: Optional information about hierarchy. It is only needed if you want to draw only some of the contours (see ``maxLevel`` ).
approxPolyDP
----------------
-.. c:function:: void approxPolyDP( const Mat& curve, vector<Point>& approxCurve, double epsilon, bool closed )
-
-.. c:function:: void approxPolyDP( const Mat& curve, vector<Point2f>& approxCurve, double epsilon, bool closed )
+.. cpp:function:: void approxPolyDP( InputArray curve, OutputArray approxCurve, double epsilon, bool closed )
Approximates a polygonal curve(s) with the specified precision.
- :param curve: Polygon or curve to approximate. It must be :math:`1 \times N` or :math:`N \times 1` matrix of type ``CV_32SC2`` or ``CV_32FC2`` . You can also convert ``vector<Point>`` or ``vector<Point2f>`` to the matrix by calling the ``Mat(const vector<T>&)`` constructor.
+ :param curve: Input vector of 2d point, stored in ``std::vector`` or ``Mat``.
:param approxCurve: Result of the approximation. The type should match the type of the input curve.
The functions ``approxPolyDP`` approximate a curve or a polygon with another curve/polygon with less vertices, so that the distance between them is less or equal to the specified precision. It uses the Douglas-Peucker algorithm
http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
+See http://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/contours.cpp on how to use the function.
+
.. index:: arcLength
arcLength
-------------
-.. c:function:: double arcLength( const Mat& curve, bool closed )
+.. cpp:function:: double arcLength( InputArray curve, bool closed )
Calculates a contour perimeter or a curve length.
- :param curve: Input vector of 2D points represented either by ``CV_32SC2`` or ``CV_32FC2`` matrix, or by ``vector<Point>`` /``vector<Point2f>`` converted to a matrix with the ``Mat(const vector<T>&)`` constructor.
+ :param curve: Input vector of 2D points, stored in ``std::vector`` or ``Mat``.
:param closed: Flag indicating whether the curve is closed or not.
boundingRect
----------------
-.. c:function:: Rect boundingRect( const Mat& points )
+.. cpp:function:: Rect boundingRect( InputArray points )
Calculates the up-right bounding rectangle of a point set.
- :param points: Input 2D point set represented either by ``CV_32SC2`` or ``CV_32FC2`` matrix, or by ``vector<Point>`` /``vector<Point2f>`` converted to a matrix using the ``Mat(const vector<T>&)`` constructor.
+ :param points: Input 2D point set, stored in ``std::vector`` or ``Mat``.
The function calculates and returns the minimal up-right bounding rectangle for the specified point set.
estimateRigidTransform
--------------------------
-.. c:function:: Mat estimateRigidTransform( const Mat& srcpt, const Mat& dstpt, bool fullAffine )
+.. cpp:function:: Mat estimateRigidTransform( InputArray srcpt, InputArray dstpt, bool fullAffine )
Computes an optimal affine transformation between two 2D point sets.
- :param srcpt: The first input 2D point set.
+ :param srcpt: The first input 2D point set, stored in ``std::vector`` or ``Mat``.
:param dst: The second input 2D point set of the same size and the same type as ``A`` .
-
+
:param fullAffine: If true, the function finds an optimal affine transformation with no additional resrictions (6 degrees of freedom). Otherwise, the class of transformations to choose from is limited to combinations of translation, rotation, and uniform scaling (5 degrees of freedom).
The function finds an optimal affine transform
when ``fullAffine=false`` .
See Also:
-:func:`getAffineTransform`,
-:func:`getPerspectiveTransform`,
-:func:`findHomography`
+:cpp:func:`getAffineTransform`,
+:cpp:func:`getPerspectiveTransform`,
+:cpp:func:`findHomography`
.. index:: estimateAffine3D
estimateAffine3D
--------------------
-.. c:function:: int estimateAffine3D(const Mat& srcpt, const Mat& dstpt, Mat& out, vector<uchar>& outliers, double ransacThreshold = 3.0, double confidence = 0.99)
+.. cpp:function:: int estimateAffine3D(InputArray srcpt, InputArray dstpt, OutputArray out, OutputArray outliers, double ransacThreshold = 3.0, double confidence = 0.99)
Computes an optimal affine transformation between two 3D point sets.
contourArea
---------------
-.. c:function:: double contourArea( const Mat& contour )
+.. cpp:function:: double contourArea( InputArray contour )
Calculates a contour area.
- :param contour: Contour vertices represented either by ``CV_32SC2`` or ``CV_32FC2`` matrix, or by ``vector<Point>`` /``vector<Point2f>`` converted to a matrix using the ``Mat(const vector<T>&)`` constructor.
+ :param contour: Input vector of 2d points (contour vertices), stored in ``std::vector`` or ``Mat``.
The function computes a contour area. Similarly to
-:func:`moments` , the area is computed using the Green formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using
-:func:`drawContours` or
-:func:`fillPoly` , can be different.
+:cpp:func:`moments` , the area is computed using the Green formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using
+:cpp:func:`drawContours` or
+:cpp:func:`fillPoly` , can be different.
Here is a short example: ::
vector<Point> contour;
approxPolyDP(contour, approx, 5, true);
double area1 = contourArea(approx);
- cout << "area0 = " << area0 << endl <<
- "area1 = " << area1 << endl <<
- "approx poly vertices = " << approx.size() << endl;
+ cout << "area0 =" << area0 << endl <<
+ "area1 =" << area1 << endl <<
+ "approx poly vertices" << approx.size() << endl;
.. index:: convexHull
convexHull
--------------
-.. c:function:: void convexHull( const Mat& points, vector<int>& hull, bool clockwise=false )
-
-.. c:function:: void convexHull( const Mat& points, vector<Point>& hull, bool clockwise=false )
-
-.. c:function:: void convexHull( const Mat& points, vector<Point2f>& hull, bool clockwise=false )
+.. cpp:function:: void convexHull( InputArray points, OutputArray hull, bool clockwise=false, bool returnPoints=true )
Finds the convex hull of a point set.
- :param points: Input 2D point set represented either by ``CV_32SC2`` or ``CV_32FC2`` matrix, or by ``vector<Point>`` /``vector<Point2f>`` converted to a matrix using the ``Mat(const vector<T>&)`` constructor.
+ :param points: Input 2D point set, stored in ``std::vector`` or ``Mat``.
- :param hull: Output convex hull. It is either a vector of points that form the hull (must have the same type as the input points), or a vector of 0-based point indices of the hull points in the original array (since the set of convex hull points is a subset of the original point set).
+ :param hull: Output convex hull. It is either an integer vector of indices or vector of points. In the first case the ``hull`` elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case ``hull`` elements will be the convex hull points themselves.
- :param clockwise: If true, the output convex hull will be oriented clockwise. Otherwise, it will be oriented counter-clockwise. The usual screen coordinate system is assumed where the origin is at the top-left corner, x axis is oriented to the right, and y axis is oriented downwards.
+ :param clockwise: Orientation flag. If true, the output convex hull will be oriented clockwise. Otherwise, it will be oriented counter-clockwise. The usual screen coordinate system is assumed where the origin is at the top-left corner, x axis is oriented to the right, and y axis is oriented downwards.
+
+ :param returnPoints: Operation flag. In the case of matrix, when the flag is true, the function will return convex hull points, otherwise it will return indices of the convex hull points. When the output array is ``std::vector``, the flag is ignored, and the output depends on the type of the vector - ``std::vector<int>`` implies ``returnPoints=true``, ``std::vector<Point>`` implies ``returnPoints=false``.
The functions find the convex hull of a 2D point set using the Sklansky's algorithm
Sklansky82
that has
-:math:`O(N logN)` or
-:math:`O(N)` complexity (where
-:math:`N` is the number of input points), depending on how the initial sorting is implemented (currently it is
-:math:`O(N logN)` . See the OpenCV sample ``convexhull.c`` that demonstrates the usage of different function variants.
+*O(N logN)* complexity in the current implementation. See the OpenCV sample ``convexhull.cpp`` that demonstrates the usage of different function variants.
.. index:: fitEllipse
fitEllipse
--------------
-.. c:function:: RotatedRect fitEllipse( const InputArray& points )
+.. cpp:function:: RotatedRect fitEllipse( InputArray points )
Fits an ellipse around a set of 2D points.
- :param points: Input 2D point set represented either by ``CV_32SC2`` or ``CV_32FC2`` matrix, or by ``vector<Point>`` or ``vector<Point2f>``.
+ :param points: Input vector of 2D points, stored in ``std::vector<>`` or ``Mat``.
The function calculates the ellipse that fits (in least-squares sense) a set of 2D points best of all. It returns the rotated rectangle in which the ellipse is inscribed.
fitLine
-----------
-.. c:function:: void fitLine( const InputArray& points, OutputArray& line, int distType, double param, double reps, double aeps )
+.. cpp:function:: void fitLine( InputArray points, OutputArray line, int distType, double param, double reps, double aeps )
Fits a line to a 2D or 3D point set.
- :param points: Input 2D or 3D point set represented either by ``CV_32SC2`` or ``CV_32FC2`` matrix, or by ``vector<Point>``, ``vector<Point2f>``, ``vector<Point3i>`` or ``vector<Point3f>``.
+ :param points: Input vector of 2D or 3D points, stored in ``std::vector<>`` or ``Mat``.
- :param line: Output line parameters. In case of 2D fitting it should be ``Vec4f``, a vector of 4 floats ``(vx, vy, x0, y0)``, where ``(vx, vy)`` is a normalized vector collinear to the line and ``(x0, y0)`` is a point on the line. In case of 3D fitting, it should be ``Vec6f``, a vector of 6 floats ``(vx, vy, vz, x0, y0, z0)``, where ``(vx, vy, vz)`` is a normalized vector collinear to the line and ``(x0, y0, z0)`` is a point on the line.
+ :param line: Output line parameters. In case of 2D fitting it should be a vector of 4 elements (like ``Vec4f``) - ``(vx, vy, x0, y0)``, where ``(vx, vy)`` is a normalized vector collinear to the line and ``(x0, y0)`` is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like ``Vec6f``) - ``(vx, vy, vz, x0, y0, z0)``, where ``(vx, vy, vz)`` is a normalized vector collinear to the line and ``(x0, y0, z0)`` is a point on the line.
:param distType: Distance used by the M-estimator (see the discussion).
isContourConvex
-------------------
-.. c:function:: bool isContourConvex( const InputArray& contour )
+.. cpp:function:: bool isContourConvex( InputArray contour )
Tests a contour convexity.
- :param contour: Tested contour, a matrix of type ``CV_32SC2`` or ``CV_32FC2`` , or ``vector<Point>`` or ``vector<Point2f>``.
+ :param contour: The input vector of 2D points, stored in ``std::vector<>`` or ``Mat``.
The function tests whether the input contour is convex or not. The contour must be simple, that is, without self-intersections. Otherwise, the function output is undefined.
minAreaRect
---------------
-.. c:function:: RotatedRect minAreaRect( const InputArray& points )
+.. cpp:function:: RotatedRect minAreaRect( InputArray points )
Finds a rotated rectangle of the minimum area enclosing the input 2D point set.
- :param points: Input 2D point set represented either by ``CV_32SC2`` or ``CV_32FC2`` matrix, or by ``vector<Point>`` or ``vector<Point2f>``.
+ :param points: The input vector of 2D points, stored in ``std::vector<>`` or ``Mat``.
The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a specified point set. See the OpenCV sample ``minarea.cpp`` .
minEnclosingCircle
----------------------
-.. c:function:: void minEnclosingCircle( const InputArray& points, Point2f& center, float& radius )
+.. cpp:function:: void minEnclosingCircle( InputArray points, Point2f& center, float& radius )
Finds a circle of the minimum area enclosing a 2D point set.
- :param points: Input 2D point set represented either by ``CV_32SC2`` or ``CV_32FC2`` matrix, or by ``vector<Point>`` or ``vector<Point2f>``.
+ :param points: The input vector of 2D points, stored in ``std::vector<>`` or ``Mat``.
:param center: Output center of the circle.
matchShapes
---------------
-.. c:function:: double matchShapes( const InputArray& object1, const InputArray& object2, int method, double parameter=0 )
+.. cpp:function:: double matchShapes( InputArray object1, InputArray object2, int method, double parameter=0 )
Compares two shapes.
:param parameter: Method-specific parameter (not supported now).
The function compares two shapes. All three implemented methods use the Hu invariants (see
-:func:`HuMoments` ) as follows (
+:cpp:func:`HuMoments` ) as follows (
:math:`A` denotes ``object1``,:math:`B` denotes ``object2`` ):
* method=CV\_CONTOUR\_MATCH\_I1
pointPolygonTest
--------------------
-.. c:function:: double pointPolygonTest( const InputArray& contour, Point2f pt, bool measureDist )
+.. cpp:function:: double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist )
Performs a point-in-contour test.
CvBoost::train
--------------
-.. c:function:: bool CvBoost::train( const CvMat* _train_data, int _tflag, const CvMat* _responses, const CvMat* _var_idx=0, const CvMat* _sample_idx=0, const CvMat* _var_type=0, const CvMat* _missing_mask=0, CvBoostParams params=CvBoostParams(), bool update=false )
+.. cpp:function:: bool CvBoost::train( const CvMat* _train_data, int _tflag, const CvMat* _responses, const CvMat* _var_idx=0, const CvMat* _sample_idx=0, const CvMat* _var_type=0, const CvMat* _missing_mask=0, CvBoostParams params=CvBoostParams(), bool update=false )
Trains a boosted tree classifier.
CvBoost::predict
----------------
-.. c:function:: float CvBoost::predict( const CvMat* sample, const CvMat* missing=0, CvMat* weak_responses=0, CvSlice slice=CV_WHOLE_SEQ, bool raw_mode=false ) const
+.. cpp:function:: float CvBoost::predict( const CvMat* sample, const CvMat* missing=0, CvMat* weak_responses=0, CvSlice slice=CV_WHOLE_SEQ, bool raw_mode=false ) const
Predicts a response for an input sample.
CvBoost::prune
--------------
-.. c:function:: void CvBoost::prune( CvSlice slice )
+.. cpp:function:: void CvBoost::prune( CvSlice slice )
Removes the specified weak classifiers.
CvBoost::get_weak_predictors
----------------------------
-.. c:function:: CvSeq* CvBoost::get_weak_predictors()
+.. cpp:function:: CvSeq* CvBoost::get_weak_predictors()
Returns the sequence of weak tree classifiers.
CvDTree::train
--------------
-.. c:function:: bool CvDTree::train( const CvMat* _train_data, int _tflag, const CvMat* _responses, const CvMat* _var_idx=0, const CvMat* _sample_idx=0, const CvMat* _var_type=0, const CvMat* _missing_mask=0, CvDTreeParams params=CvDTreeParams() )
+.. cpp:function:: bool CvDTree::train( const CvMat* _train_data, int _tflag, const CvMat* _responses, const CvMat* _var_idx=0, const CvMat* _sample_idx=0, const CvMat* _var_type=0, const CvMat* _missing_mask=0, CvDTreeParams params=CvDTreeParams() )
-.. c:function:: bool CvDTree::train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx )
+.. cpp:function:: bool CvDTree::train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx )
Trains a decision tree.
CvDTree::predict
----------------
-.. c:function:: CvDTreeNode* CvDTree::predict( const CvMat* _sample, const CvMat* _missing_data_mask=0, bool raw_mode=false ) const
+.. cpp:function:: CvDTreeNode* CvDTree::predict( const CvMat* _sample, const CvMat* _missing_data_mask=0, bool raw_mode=false ) const
Returns the leaf node of a decision tree corresponding to the input vector.
CvEM::train
-----------
-.. c:function:: void CvEM::train( const CvMat* samples, const CvMat* sample_idx=0, CvEMParams params=CvEMParams(), CvMat* labels=0 )
+.. cpp:function:: void CvEM::train( const CvMat* samples, const CvMat* sample_idx=0, CvEMParams params=CvEMParams(), CvMat* labels=0 )
Estimates the Gaussian mixture parameters from a sample set.
CvKNearest::train
-----------------
-.. c:function:: bool CvKNearest::train( const CvMat* _train_data, const CvMat* _responses, const CvMat* _sample_idx=0, bool is_regression=false, int _max_k=32, bool _update_base=false )
+.. cpp:function:: bool CvKNearest::train( const CvMat* _train_data, const CvMat* _responses, const CvMat* _sample_idx=0, bool is_regression=false, int _max_k=32, bool _update_base=false )
Trains the model.
CvKNearest::find_nearest
------------------------
-.. c:function:: float CvKNearest::find_nearest( const CvMat* _samples, int k, CvMat* results=0, const float** neighbors=0, CvMat* neighbor_responses=0, CvMat* dist=0 ) const
+.. cpp:function:: float CvKNearest::find_nearest( const CvMat* _samples, int k, CvMat* results=0, const float** neighbors=0, CvMat* neighbor_responses=0, CvMat* dist=0 ) const
Finds the neighbors for input vectors.
CvANN_MLP::create
-----------------
-.. c:function:: void CvANN_MLP::create( const CvMat* _layer_sizes, int _activ_func=SIGMOID_SYM, double _f_param1=0, double _f_param2=0 )
+.. cpp:function:: void CvANN_MLP::create( const CvMat* _layer_sizes, int _activ_func=SIGMOID_SYM, double _f_param1=0, double _f_param2=0 )
Constructs MLP with the specified topology.
CvANN_MLP::train
----------------
-.. c:function:: int CvANN_MLP::train( const CvMat* _inputs, const CvMat* _outputs, const CvMat* _sample_weights, const CvMat* _sample_idx=0, CvANN_MLP_TrainParams _params = CvANN_MLP_TrainParams(), int flags=0 )
+.. cpp:function:: int CvANN_MLP::train( const CvMat* _inputs, const CvMat* _outputs, const CvMat* _sample_weights, const CvMat* _sample_idx=0, CvANN_MLP_TrainParams _params = CvANN_MLP_TrainParams(), int flags=0 )
Trains/updates MLP.
CvNormalBayesClassifier::train
------------------------------
-.. c:function:: bool CvNormalBayesClassifier::train( const CvMat* _train_data, const CvMat* _responses, const CvMat* _var_idx =0, const CvMat* _sample_idx=0, bool update=false )
+.. cpp:function:: bool CvNormalBayesClassifier::train( const CvMat* _train_data, const CvMat* _responses, const CvMat* _var_idx =0, const CvMat* _sample_idx=0, bool update=false )
Trains the model.
CvNormalBayesClassifier::predict
--------------------------------
-.. c:function:: float CvNormalBayesClassifier::predict( const CvMat* samples, CvMat* results=0 ) const
+.. cpp:function:: float CvNormalBayesClassifier::predict( const CvMat* samples, CvMat* results=0 ) const
Predicts the response for sample(s).
CvRTrees::train
---------------
-.. c:function:: bool CvRTrees::train( const CvMat* train_data, int tflag, const CvMat* responses, const CvMat* comp_idx=0, const CvMat* sample_idx=0, const CvMat* var_type=0, const CvMat* missing_mask=0, CvRTParams params=CvRTParams() )
+.. cpp:function:: bool CvRTrees::train( const CvMat* train_data, int tflag, const CvMat* responses, const CvMat* comp_idx=0, const CvMat* sample_idx=0, const CvMat* var_type=0, const CvMat* missing_mask=0, CvRTParams params=CvRTParams() )
Trains the Random Tree model.
CvRTrees::predict
-----------------
-.. c:function:: double CvRTrees::predict( const CvMat* sample, const CvMat* missing=0 ) const
+.. cpp:function:: double CvRTrees::predict( const CvMat* sample, const CvMat* missing=0 ) const
Predicts the output for an input sample.
CvRTrees::get_var_importance
----------------------------
-.. c:function:: const CvMat* CvRTrees::get_var_importance() const
+.. cpp:function:: const CvMat* CvRTrees::get_var_importance() const
Retrieves the variable importance array.
CvRTrees::get_proximity
-----------------------
-.. c:function:: float CvRTrees::get_proximity( const CvMat* sample_1, const CvMat* sample_2 ) const
+.. cpp:function:: float CvRTrees::get_proximity( const CvMat* sample_1, const CvMat* sample_2 ) const
Retrieves the proximity measure between two training samples.
CvStatModel::CvStatModel
------------------------
-.. c:function:: CvStatModel::CvStatModel()
+.. cpp:function:: CvStatModel::CvStatModel()
Serves as a default constructor.
CvStatModel::CvStatModel(...)
-----------------------------
-.. c:function:: CvStatModel::CvStatModel( const CvMat* train_data ... )
+.. cpp:function:: CvStatModel::CvStatModel( const CvMat* train_data ... )
Serves as a training constructor.
CvStatModel::~CvStatModel
-------------------------
-.. c:function:: CvStatModel::~CvStatModel()
+.. cpp:function:: CvStatModel::~CvStatModel()
Serves as a virtual destructor.
CvStatModel::clear
------------------
-.. c:function:: void CvStatModel::clear()
+.. cpp:function:: void CvStatModel::clear()
Deallocates memory and resets the model state.
CvStatModel::save
-----------------
-.. c:function:: void CvStatModel::save( const char* filename, const char* name=0 )
+.. cpp:function:: void CvStatModel::save( const char* filename, const char* name=0 )
Saves the model to a file.
CvStatModel::load
-----------------
-.. c:function:: void CvStatModel::load( const char* filename, const char* name=0 )
+.. cpp:function:: void CvStatModel::load( const char* filename, const char* name=0 )
Loads the model from a file.
CvStatModel::write
------------------
-.. c:function:: void CvStatModel::write( CvFileStorage* storage, const char* name )
+.. cpp:function:: void CvStatModel::write( CvFileStorage* storage, const char* name )
Writes the model to the file storage.
CvStatModel::read
-----------------
-.. c:function:: void CvStatMode::read( CvFileStorage* storage, CvFileNode* node )
+.. cpp:function:: void CvStatMode::read( CvFileStorage* storage, CvFileNode* node )
Reads the model from the file storage.
CvStatModel::train
------------------
-.. c:function:: bool CvStatMode::train( const CvMat* train_data, [int tflag,] ..., const CvMat* responses, ..., [const CvMat* var_idx,] ..., [const CvMat* sample_idx,] ... [const CvMat* var_type,] ..., [const CvMat* missing_mask,] <misc_training_alg_params> ... )
+.. cpp:function:: bool CvStatMode::train( const CvMat* train_data, [int tflag,] ..., const CvMat* responses, ..., [const CvMat* var_idx,] ..., [const CvMat* sample_idx,] ... [const CvMat* var_type,] ..., [const CvMat* missing_mask,] <misc_training_alg_params> ... )
Trains the model.
CvStatModel::predict
--------------------
-.. c:function:: float CvStatMode::predict( const CvMat* sample[, <prediction_params>] ) const
+.. cpp:function:: float CvStatMode::predict( const CvMat* sample[, <prediction_params>] ) const
Predicts the response for a sample.
CvSVM::train
------------
-.. c:function:: bool CvSVM::train( const CvMat* _train_data, const CvMat* _responses, const CvMat* _var_idx=0, const CvMat* _sample_idx=0, CvSVMParams _params=CvSVMParams() )
+.. cpp:function:: bool CvSVM::train( const CvMat* _train_data, const CvMat* _responses, const CvMat* _var_idx=0, const CvMat* _sample_idx=0, CvSVMParams _params=CvSVMParams() )
Trains SVM.
CvSVM::train_auto
-----------------
-.. c:function:: train_auto( const CvMat* _train_data, const CvMat* _responses, const CvMat* _var_idx, const CvMat* _sample_idx, CvSVMParams params, int k_fold = 10, CvParamGrid C_grid = get_default_grid(CvSVM::C), CvParamGrid gamma_grid = get_default_grid(CvSVM::GAMMA), CvParamGrid p_grid = get_default_grid(CvSVM::P), CvParamGrid nu_grid = get_default_grid(CvSVM::NU), CvParamGrid coef_grid = get_default_grid(CvSVM::COEF), CvParamGrid degree_grid = get_default_grid(CvSVM::DEGREE) )
+.. cpp:function:: train_auto( const CvMat* _train_data, const CvMat* _responses, const CvMat* _var_idx, const CvMat* _sample_idx, CvSVMParams params, int k_fold = 10, CvParamGrid C_grid = get_default_grid(CvSVM::C), CvParamGrid gamma_grid = get_default_grid(CvSVM::GAMMA), CvParamGrid p_grid = get_default_grid(CvSVM::P), CvParamGrid nu_grid = get_default_grid(CvSVM::NU), CvParamGrid coef_grid = get_default_grid(CvSVM::COEF), CvParamGrid degree_grid = get_default_grid(CvSVM::DEGREE) )
Trains SVM with optimal parameters.
CvSVM::get_default_grid
-----------------------
-.. c:function:: CvParamGrid CvSVM::get_default_grid( int param_id )
+.. cpp:function:: CvParamGrid CvSVM::get_default_grid( int param_id )
Generates a grid for SVM parameters.
CvSVM::get_params
-----------------
-.. c:function:: CvSVMParams CvSVM::get_params() const
+.. cpp:function:: CvSVMParams CvSVM::get_params() const
Returns the current SVM parameters.
CvSVM::get_support_vector*
--------------------------
-.. c:function:: int CvSVM::get_support_vector_count() const
+.. cpp:function:: int CvSVM::get_support_vector_count() const
-.. c:function:: const float* CvSVM::get_support_vector(int i) const
+.. cpp:function:: const float* CvSVM::get_support_vector(int i) const
Retrieves a number of support vectors and the particular vector.
FeatureEvaluator::read
--------------------------
-.. c:function:: bool FeatureEvaluator::read(const FileNode\& node)
+.. cpp:function:: bool FeatureEvaluator::read(const FileNode\& node)
Reads parameters of features from the ``FileStorage`` node.
FeatureEvaluator::clone
---------------------------
-.. c:function:: Ptr<FeatureEvaluator> FeatureEvaluator::clone() const
+.. cpp:function:: Ptr<FeatureEvaluator> FeatureEvaluator::clone() const
Returns a full copy of the feature evaluator.
FeatureEvaluator::getFeatureType
------------------------------------
-.. c:function:: int FeatureEvaluator::getFeatureType() const
+.. cpp:function:: int FeatureEvaluator::getFeatureType() const
Returns the feature type (``HAAR`` or ``LBP`` for now).
FeatureEvaluator::setImage
------------------------------
-.. c:function:: bool FeatureEvaluator::setImage(const Mat\& img, Size origWinSize)
+.. cpp:function:: bool FeatureEvaluator::setImage(const Mat\& img, Size origWinSize)
Sets an image where the features are computed??.
FeatureEvaluator::setWindow
-------------------------------
-.. c:function:: bool FeatureEvaluator::setWindow(Point p)
+.. cpp:function:: bool FeatureEvaluator::setWindow(Point p)
Sets a window in the current image where the features are computed (called by ??).
FeatureEvaluator::calcOrd
-----------------------------
-.. c:function:: double FeatureEvaluator::calcOrd(int featureIdx) const
+.. cpp:function:: double FeatureEvaluator::calcOrd(int featureIdx) const
Computes the value of an ordered (numerical) feature.
FeatureEvaluator::calcCat
-----------------------------
-.. c:function:: int FeatureEvaluator::calcCat(int featureIdx) const
+.. cpp:function:: int FeatureEvaluator::calcCat(int featureIdx) const
Computes the value of a categorical feature.
FeatureEvaluator::create
----------------------------
-.. c:function:: static Ptr<FeatureEvaluator> FeatureEvaluator::create(int type)
+.. cpp:function:: static Ptr<FeatureEvaluator> FeatureEvaluator::create(int type)
Constructs the feature evaluator.
CascadeClassifier::CascadeClassifier
----------------------------------------
-.. c:function:: CascadeClassifier::CascadeClassifier(const string\& filename)
+.. cpp:function:: CascadeClassifier::CascadeClassifier(const string\& filename)
Loads a classifier from a file.
CascadeClassifier::empty
----------------------------
-.. c:function:: bool CascadeClassifier::empty() const
+.. cpp:function:: bool CascadeClassifier::empty() const
Checks if the classifier has been loaded or not.
CascadeClassifier::load
---------------------------
-.. c:function:: bool CascadeClassifier::load(const string\& filename)
+.. cpp:function:: bool CascadeClassifier::load(const string\& filename)
Loads a classifier from a file. The previous content is destroyed.
CascadeClassifier::read
---------------------------
-.. c:function:: bool CascadeClassifier::read(const FileNode\& node)
+.. cpp:function:: bool CascadeClassifier::read(const FileNode\& node)
Reads a classifier from a FileStorage node. The file may contain a new cascade classifier (trained traincascade application) only.
CascadeClassifier::detectMultiScale
---------------------------------------
-.. c:function:: void CascadeClassifier::detectMultiScale( const Mat\& image, vector<Rect>\& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size())
+.. cpp:function:: void CascadeClassifier::detectMultiScale( const Mat\& image, vector<Rect>\& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size())
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
CascadeClassifier::setImage
-------------------------------
-.. c:function:: bool CascadeClassifier::setImage( Ptr<FeatureEvaluator>\& feval, const Mat\& image )
+.. cpp:function:: bool CascadeClassifier::setImage( Ptr<FeatureEvaluator>\& feval, const Mat\& image )
Sets an image for detection, which is called by ``detectMultiScale`` at each image level.
CascadeClassifier::runAt
----------------------------
-.. c:function:: int CascadeClassifier::runAt( Ptr<FeatureEvaluator>\& feval, Point pt )
+.. cpp:function:: int CascadeClassifier::runAt( Ptr<FeatureEvaluator>\& feval, Point pt )
Runs the detector at the specified point. Use ``setImage`` to set the image that the detector is working with.
groupRectangles
-------------------
-.. c:function:: void groupRectangles(vector<Rect>\& rectList, int groupThreshold, double eps=0.2)
+.. cpp:function:: void groupRectangles(vector<Rect>\& rectList, int groupThreshold, double eps=0.2)
Groups the object candidate rectangles.
-import os, sys, re
+import os, sys, re, string
# the list only for debugging. The real list, used in the real OpenCV build, is specified in CMakeLists.txt
opencv_hdr_list = [
fnpos = 0
fname = fname[fnpos:].strip()
rettype = fdecl[:fnpos].strip()
- args0 = fdecl[fdecl.find("(")+1:fdecl.rfind(")")].strip().split(",")
+
+ if rettype.endswith("operator"):
+ fname = ("operator " + fname).strip()
+ rettype = rettype[:rettype.rfind("operator")].strip()
+ if rettype.endswith("::"):
+ rpos = rettype.rfind(" ")
+ if rpos >= 0:
+ fname = rettype[rpos+1:].strip() + fname
+ rettype = rettype[:rpos].strip()
+ else:
+ fname = rettype + fname
+ rettype = ""
+
+ apos = fdecl.find("(")
+ if fname.endswith("operator"):
+ fname += "()"
+ apos = fdecl.find("(", apos+1)
+ args0 = fdecl[apos+1:fdecl.rfind(")")].strip().split(",")
+
args = []
narg = ""
for arg in args0:
narg = ""
fname = "cv." + fname.replace("::", ".")
decl = [fname, rettype, [], []]
+
for arg in args:
dfpos = arg.find("=")
defval = ""
pos = arg.rfind(" ")
aname = arg[pos+1:]
atype = arg[:pos]
- decl[3].append([atype, aname, defval, []])
+ decl[3].append([atype, aname, defval, []])
+
return decl
def parse_func_decl(self, decl_str):
if not (("CV_EXPORTS_AS" in decl_str) or ("CV_EXPORTS_W" in decl_str) or \
("CV_WRAP" in decl_str) or ("CV_WRAP_AS" in decl_str)):
return []
-
+
+ # ignore old API in the documentation check (for now)
+ if "CVAPI(" in decl_str:
+ return []
+
top = self.block_stack[-1]
func_modlist = []
calcOpticalFlowPyrLK
------------------------
-.. c:function:: void calcOpticalFlowPyrLK( const Mat\& prevImg, const Mat\& nextImg, const vector<Point2f>\& prevPts, vector<Point2f>\& nextPts, vector<uchar>\& status, vector<float>\& err, Size winSize=Size(15,15), int maxLevel=3, TermCriteria criteria=TermCriteria( TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), double derivLambda=0.5, int flags=0 )
+.. cpp:function:: void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, InputArray prevPts, InputOutputArray nextPts, OutputArray status, OutputArray err, Size winSize=Size(15,15), int maxLevel=3, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), double derivLambda=0.5, int flags=0 )
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.
:param prevImg: The first 8-bit single-channel or 3-channel input image.
:param nextImg: The second input image of the same size and the same type as ``prevImg`` .
-
+
:param prevPts: Vector of points for which the flow needs to be found.
:param nextPts: Output vector of points containing the calculated new positions of input features in the second image.
calcOpticalFlowFarneback
----------------------------
-.. c:function:: void calcOpticalFlowFarneback( const Mat\& prevImg, const Mat\& nextImg, Mat\& flow, double pyrScale, int levels, int winsize, int iterations, int polyN, double polySigma, int flags )
+.. cpp:function:: void calcOpticalFlowFarneback( InputArray prevImg, InputArray nextImg, InputOutputArray flow, double pyrScale, int levels, int winsize, int iterations, int polyN, double polySigma, int flags )
Computes a dense optical flow using the Gunnar Farneback's algorithm.
:param prevImg: The first 8-bit single-channel input image.
:param nextImg: The second input image of the same size and the same type as ``prevImg`` .
-
+
:param flow: Computed flow image that has the same size as ``prevImg`` and type ``CV_32FC2`` .
-
+
:param pyrScale: Parameter specifying the image scale (<1) to build pyramids for each image. ``pyrScale=0.5`` means a classical pyramid, where each next layer is twice smaller than the previous one.
:param levels: Number of pyramid layers including the initial image. ``levels=1`` means that no extra layers are created and only the original images are used.
updateMotionHistory
-----------------------
-.. c:function:: void updateMotionHistory( const Mat\& silhouette, Mat\& mhi, double timestamp, double duration )
+.. cpp:function:: void updateMotionHistory( InputArray silhouette, InputOutputArray mhi, double timestamp, double duration )
Updates the motion history image by a moving silhouette.
That is, MHI pixels where the motion occurs are set to the current ``timestamp`` , while the pixels where the motion happened last time a long time ago are cleared.
The function, together with
-:func:`calcMotionGradient` and
-:func:`calcGlobalOrientation` , implements a motion templates technique described in
+:cpp:func:`calcMotionGradient` and
+:cpp:func:`calcGlobalOrientation` , implements a motion templates technique described in
Davis97
and
Bradski00
calcMotionGradient
----------------------
-.. c:function:: void calcMotionGradient( const Mat\& mhi, Mat\& mask, Mat\& orientation, double delta1, double delta2, int apertureSize=3 )
+.. cpp:function:: void calcMotionGradient( InputArray mhi, OutputArray mask, OutputArray orientation, double delta1, double delta2, int apertureSize=3 )
Calculates a gradient orientation of a motion history image.
\min ( \texttt{delta1} , \texttt{delta2} ) \le M(x,y)-m(x,y) \le \max ( \texttt{delta1} , \texttt{delta2} ).
- :param apertureSize: Aperture size of the :func:`Sobel` operator.
+ :param apertureSize: Aperture size of the :cpp:func:`Sobel` operator.
The function calculates a gradient orientation at each pixel
:math:`(x, y)` as:
\texttt{orientation} (x,y)= \arctan{\frac{d\texttt{mhi}/dy}{d\texttt{mhi}/dx}}
In fact,
-:func:`fastArctan` and
-:func:`phase` are used so that the computed angle is measured in degrees and covers the full range 0..360. Also, the ``mask`` is filled to indicate pixels where the computed angle is valid.
+:cpp:func:`fastArctan` and
+:cpp:func:`phase` are used so that the computed angle is measured in degrees and covers the full range 0..360. Also, the ``mask`` is filled to indicate pixels where the computed angle is valid.
.. index:: calcGlobalOrientation
calcGlobalOrientation
-------------------------
-.. c:function:: double calcGlobalOrientation( const Mat\& orientation, const Mat\& mask, const Mat\& mhi, double timestamp, double duration )
+.. cpp:function:: double calcGlobalOrientation( InputArray orientation, InputArray mask, InputArray mhi, double timestamp, double duration )
Calculates a global motion orientation in a selected region.
- :param orientation: Motion gradient orientation image calculated by the function :func:`calcMotionGradient` .
+ :param orientation: Motion gradient orientation image calculated by the function :cpp:func:`calcMotionGradient` .
- :param mask: Mask image. It may be a conjunction of a valid gradient mask, also calculated by :func:`calcMotionGradient` , and the mask of a region whose direction needs to be calculated.
+ :param mask: Mask image. It may be a conjunction of a valid gradient mask, also calculated by :cpp:func:`calcMotionGradient` , and the mask of a region whose direction needs to be calculated.
- :param mhi: Motion history image calculated by :func:`updateMotionHistory` .
+ :param mhi: Motion history image calculated by :cpp:func:`updateMotionHistory` .
- :param timestamp: Timestamp passed to :func:`updateMotionHistory` .
+ :param timestamp: Timestamp passed to :cpp:func:`updateMotionHistory` .
- :param duration: Maximum duration of a motion track in milliseconds, passed to :func:`updateMotionHistory` .
+ :param duration: Maximum duration of a motion track in milliseconds, passed to :cpp:func:`updateMotionHistory` .
The function calculates an average
motion direction in the selected region and returns the angle between
CamShift
------------
-.. c:function:: RotatedRect CamShift( const Mat\& probImage, Rect\& window, TermCriteria criteria )
+.. cpp:function:: RotatedRect CamShift( InputArray probImage, Rect& window, TermCriteria criteria )
Finds an object center, size, and orientation.
- :param probImage: Back projection of the object histogram. See :func:`calcBackProject` .
+ :param probImage: Back projection of the object histogram. See :cpp:func:`calcBackProject` .
:param window: Initial search window.
- :param criteria: Stop criteria for the underlying :func:`meanShift` .
+ :param criteria: Stop criteria for the underlying :cpp:func:`meanShift` .
The function implements the CAMSHIFT object tracking algrorithm
Bradski98
.
First, it finds an object center using
-:func:`meanShift` and then adjusts the window size and finds the optimal rotation. The function returns the rotated rectangle structure that includes the object position, size, and orientation. The next position of the search window can be obtained with ``RotatedRect::boundingRect()`` .
+:cpp:func:`meanShift` and then adjusts the window size and finds the optimal rotation. The function returns the rotated rectangle structure that includes the object position, size, and orientation. The next position of the search window can be obtained with ``RotatedRect::boundingRect()`` .
See the OpenCV sample ``camshiftdemo.c`` that tracks colored objects.
meanShift
-------------
-.. c:function:: int meanShift( const Mat\& probImage, Rect\& window, TermCriteria criteria )
+.. cpp:function:: int meanShift( InputArray probImage, Rect& window, TermCriteria criteria )
Finds an object on a back projection image.
- :param probImage: Back projection of the object histogram. See :func:`calcBackProject` for details.
+ :param probImage: Back projection of the object histogram. See :cpp:func:`calcBackProject` for details.
:param window: Initial search window.
:param criteria: Stop criteria for the iterative search algorithm.
The function implements the iterative object search algorithm. It takes the input back projection of an object and the initial position. The mass center in ``window`` of the back projection image is computed and the search window center shifts to the mass center. The procedure is repeated until the specified number of iterations ``criteria.maxCount`` is done or until the window center shifts by less than ``criteria.epsilon`` . The algorithm is used inside
-:func:`CamShift` and, unlike
-:func:`CamShift` , the search window size or orientation do not change during the search. You can simply pass the output of
-:func:`calcBackProject` to this function. But better results can be obtained if you pre-filter the back projection and remove the noise (for example, by retrieving connected components with
-:func:`findContours` , throwing away contours with small area (
-:func:`contourArea` ), and rendering the remaining contours with
-:func:`drawContours` ).
+:cpp:func:`CamShift` and, unlike
+:cpp:func:`CamShift` , the search window size or orientation do not change during the search. You can simply pass the output of
+:cpp:func:`calcBackProject` to this function. But better results can be obtained if you pre-filter the back projection and remove the noise (for example, by retrieving connected components with
+:cpp:func:`findContours` , throwing away contours with small area (
+:cpp:func:`contourArea` ), and rendering the remaining contours with
+:cpp:func:`drawContours` ).
.. index:: KalmanFilter