propagated some more fixes from 2.3 branch to the trunk

pull/13383/head
Vadim Pisarevsky 14 years ago
parent f4894d57cd
commit cc9a1bb62f
  1. 53
      doc/python_fragments/calchist.py
  2. 23
      doc/python_fragments/findstereocorrespondence.py
  3. 14
      doc/python_fragments/precornerdetect.py
  4. 86
      modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst
  5. 215
      modules/core/doc/basic_structures.rst
  6. 4
      modules/core/doc/drawing_functions.rst
  7. 4
      modules/core/doc/intro.rst
  8. 10
      modules/core/doc/operations_on_arrays.rst
  9. 14
      modules/core/src/arithm.cpp
  10. 7
      modules/core/src/copy.cpp
  11. 7
      modules/core/test/test_arithm.cpp
  12. 2
      modules/ffmpeg/ffopencv.cpp
  13. 2
      modules/gpu/doc/camera_calibration_and_3d_reconstruction.rst
  14. 53
      modules/gpu/doc/image_filtering.rst
  15. 102
      modules/gpu/doc/image_processing.rst
  16. 32
      modules/imgproc/doc/feature_detection.rst
  17. 180
      modules/imgproc/doc/filtering.rst
  18. 137
      modules/imgproc/doc/geometric_transformations.rst
  19. 29
      modules/imgproc/doc/histograms.rst
  20. 34
      modules/imgproc/doc/miscellaneous_transformations.rst
  21. 11
      modules/imgproc/doc/planar_subdivisions.rst
  22. 22
      modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst
  23. 16
      modules/ml/doc/decision_trees.rst
  24. 4
      modules/ml/doc/expectation_maximization.rst
  25. 14
      modules/ml/doc/gradient_boosted_trees.rst
  26. 2
      modules/ml/doc/neural_networks.rst
  27. 20
      modules/ml/doc/random_trees.rst
  28. 10
      modules/python/test/test.py
  29. 30
      modules/video/doc/motion_analysis_and_object_tracking.rst
  30. BIN
      samples/cpp/building.jpg
  31. BIN
      samples/cpp/tsukuba_l.png
  32. BIN
      samples/cpp/tsukuba_r.png

@ -1,53 +0,0 @@
# Calculating and displaying 2D Hue-Saturation histogram of a color image
import sys
import cv
def hs_histogram(src):
# Convert to HSV
hsv = cv.CreateImage(cv.GetSize(src), 8, 3)
cv.CvtColor(src, hsv, cv.CV_BGR2HSV)
# Extract the H and S planes
h_plane = cv.CreateMat(src.rows, src.cols, cv.CV_8UC1)
s_plane = cv.CreateMat(src.rows, src.cols, cv.CV_8UC1)
cv.Split(hsv, h_plane, s_plane, None, None)
planes = [h_plane, s_plane]
h_bins = 30
s_bins = 32
hist_size = [h_bins, s_bins]
# hue varies from 0 (~0 deg red) to 180 (~360 deg red again */
h_ranges = [0, 180]
# saturation varies from 0 (black-gray-white) to
# 255 (pure spectrum color)
s_ranges = [0, 255]
ranges = [h_ranges, s_ranges]
scale = 10
hist = cv.CreateHist([h_bins, s_bins], cv.CV_HIST_ARRAY, ranges, 1)
cv.CalcHist([cv.GetImage(i) for i in planes], hist)
(_, max_value, _, _) = cv.GetMinMaxHistValue(hist)
hist_img = cv.CreateImage((h_bins*scale, s_bins*scale), 8, 3)
for h in range(h_bins):
for s in range(s_bins):
bin_val = cv.QueryHistValue_2D(hist, h, s)
intensity = cv.Round(bin_val * 255 / max_value)
cv.Rectangle(hist_img,
(h*scale, s*scale),
((h+1)*scale - 1, (s+1)*scale - 1),
cv.RGB(intensity, intensity, intensity),
cv.CV_FILLED)
return hist_img
if __name__ == '__main__':
src = cv.LoadImageM(sys.argv[1])
cv.NamedWindow("Source", 1)
cv.ShowImage("Source", src)
cv.NamedWindow("H-S Histogram", 1)
cv.ShowImage("H-S Histogram", hs_histogram(src))
cv.WaitKey(0)

@ -1,23 +0,0 @@
import sys
import cv
def findstereocorrespondence(image_left, image_right):
# image_left and image_right are the input 8-bit single-channel images
# from the left and the right cameras, respectively
(r, c) = (image_left.rows, image_left.cols)
disparity_left = cv.CreateMat(r, c, cv.CV_16S)
disparity_right = cv.CreateMat(r, c, cv.CV_16S)
state = cv.CreateStereoGCState(16, 2)
cv.FindStereoCorrespondenceGC(image_left, image_right, disparity_left, disparity_right, state, 0)
return (disparity_left, disparity_right)
if __name__ == '__main__':
(l, r) = [cv.LoadImageM(f, cv.CV_LOAD_IMAGE_GRAYSCALE) for f in sys.argv[1:]]
(disparity_left, disparity_right) = findstereocorrespondence(l, r)
disparity_left_visual = cv.CreateMat(l.rows, l.cols, cv.CV_8U)
cv.ConvertScale(disparity_left, disparity_left_visual, -16)
cv.SaveImage("disparity.pgm", disparity_left_visual)

@ -1,14 +0,0 @@
import cv
def precornerdetect(image):
# assume that the image is floating-point
corners = cv.CloneMat(image)
cv.PreCornerDetect(image, corners, 3)
dilated_corners = cv.CloneMat(image)
cv.Dilate(corners, dilated_corners, None, 1)
corner_mask = cv.CreateMat(image.rows, image.cols, cv.CV_8UC1)
cv.Sub(corners, dilated_corners, corners)
cv.CmpS(corners, 0, corner_mask, cv.CV_CMP_GE)
return (corners, corner_mask)

@ -29,11 +29,12 @@ or
where:
* :math:`(X, Y, Z)` are the coordinates of a 3D point in the world coordinate space
* :math:`(u, v)` are the coordinates of the projection point in pixels
* :math:`A` is a camera matrix, or a matrix of intrinsic parameters
* :math:`(cx, cy)` is a principal point that is usually at the image center
* :math:`fx, fy` are the focal lengths expressed in pixel-related units
* :math:`(X, Y, Z)` are the coordinates of a 3D point in the world coordinate space
* :math:`(u, v)` are the coordinates of the projection point in pixels
* :math:`A` is a camera matrix, or a matrix of intrinsic parameters
* :math:`(cx, cy)` is a principal point that is usually at the image center
* :math:`fx, fy` are the focal lengths expressed in pixel-related units
Thus, if an image from the camera is
scaled by a factor, all of these parameters should
@ -140,7 +141,7 @@ Finds the camera intrinsic and extrinsic parameters from several views of a cali
:param flags: Different flags that may be zero or a combination of the following values:
* **CV_CALIB_USE_INTRINSIC_GUESS** ``cameraMatrix`` contains valid initial values of ``fx, fy, cx, cy`` that are optimized further. Otherwise, ``(cx, cy)`` is initially set to the image center ( ``imageSize`` is used), and focal distances are computed in a least-squares fashion. Note, that if intrinsic parameters are known, there is no need to use this function just to estimate extrinsic parameters. Use :ref:`solvePnP` instead.
* **CV_CALIB_USE_INTRINSIC_GUESS** ``cameraMatrix`` contains valid initial values of ``fx, fy, cx, cy`` that are optimized further. Otherwise, ``(cx, cy)`` is initially set to the image center ( ``imageSize`` is used), and focal distances are computed in a least-squares fashion. Note, that if intrinsic parameters are known, there is no need to use this function just to estimate extrinsic parameters. Use :ocv:func:`solvePnP` instead.
* **CV_CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global optimization. It stays at the center or at a different location specified when ``CV_CALIB_USE_INTRINSIC_GUESS`` is set too.
@ -159,7 +160,7 @@ object with a known geometry and easily detectable feature points.
Such an object is called a calibration rig or calibration pattern,
and OpenCV has built-in support for a chessboard as a calibration
rig (see
:ref:`findChessboardCorners` ). Currently, initialization
:ocv:func:`findChessboardCorners` ). Currently, initialization
of intrinsic parameters (when ``CV_CALIB_USE_INTRINSIC_GUESS`` is not set) is only implemented for planar calibration patterns
(where Z-coordinates of the object points must be all zeros). 3D
calibration rigs can also be used as long as initial ``cameraMatrix`` is provided.
@ -173,7 +174,7 @@ The algorithm performs the following steps:
Estimate the initial camera pose as if the intrinsic parameters have been already known. This is done using
:ocv:func:`solvePnP` .
#.
Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points ``imagePoints`` and the projected (using the current estimates for camera parameters and the poses) object points ``objectPoints``. See :ref:`projectPoints` for details.
Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points ``imagePoints`` and the projected (using the current estimates for camera parameters and the poses) object points ``objectPoints``. See :ocv:func:`projectPoints` for details.
The function returns the final re-projection error.
@ -182,11 +183,12 @@ The function returns the final re-projection error.
If you use a non-square (=non-NxN) grid and :ocv:func:`findChessboardCorners` for calibration, and ``calibrateCamera`` returns bad values (zero distortion coefficients, an image center very far from ``(w/2-0.5,h/2-0.5)``, and/or large differences between :math:`f_x` and :math:`f_y` (ratios of 10:1 or more)), then you have probably used ``patternSize=cvSize(rows,cols)`` instead of using ``patternSize=cvSize(cols,rows)`` in :ocv:func:`findChessboardCorners` .
.. seealso::
:ocv:func:`FindChessboardCorners`,
:ocv:func:`solvePnP`,
:ocv:func:`initCameraMatrix2D`,
:ocv:func:`stereoCalibrate`,
:ocv:func:`undistort`
:ocv:func:`FindChessboardCorners`,
:ocv:func:`solvePnP`,
:ocv:func:`initCameraMatrix2D`,
:ocv:func:`stereoCalibrate`,
:ocv:func:`undistort`
@ -198,7 +200,7 @@ Computes useful camera characteristics from the camera matrix.
.. ocv:pyfunction:: cv2.calibrationMatrixValues(cameraMatrix, imageSize, apertureWidth, apertureHeight) -> fovx, fovy, focalLength, principalPoint, aspectRatio
:param cameraMatrix: Input camera matrix that can be estimated by :ref:`calibrateCamera` or :ref:`stereoCalibrate` .
:param cameraMatrix: Input camera matrix that can be estimated by :ocv:func:`calibrateCamera` or :ocv:func:`stereoCalibrate` .
:param imageSize: Input image size in pixels.
@ -249,7 +251,7 @@ The functions compute:
\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,
where :math:`\mathrm{rodrigues}` denotes a rotation vector to a rotation matrix transformation, and
:math:`\mathrm{rodrigues}^{-1}` denotes the inverse transformation. See :ref:`Rodrigues` for details.
:math:`\mathrm{rodrigues}^{-1}` denotes the inverse transformation. See :ocv:func:`Rodrigues` for details.
Also, the functions can compute the derivatives of the output vectors with regards to the input vectors (see :ocv:func:`matMulDeriv` ).
The functions are used inside :ocv:func:`stereoCalibrate` but can also be used in your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a function that contains a matrix multiplication.
@ -447,7 +449,7 @@ in a certain order (row by row, left to right in every row). Otherwise, if the f
them, it returns 0. For example, a regular chessboard has 8 x 8
squares and 7 x 7 internal corners, that is, points where the black squares touch each other.
The detected coordinates are approximate, and to determine their positions more accurately, the function calls :ocv:func:`cornerSubPix`.
You also may use the function :ref:`cornerSubPix` with different parameters if returned coordinates are not accurate enough.
You also may use the function :ocv:func:`cornerSubPix` with different parameters if returned coordinates are not accurate enough.
Sample usage of detecting and drawing chessboard corners: ::
@ -655,7 +657,8 @@ Finds a perspective transformation between two planes.
.. ocv:pyfunction:: cv2.findHomography(srcPoints, dstPoints[, method[, ransacReprojThreshold[, mask]]]) -> retval, mask
.. ocv:cfunction:: void cvFindHomography( const CvMat* srcPoints, const CvMat* dstPoints, CvMat* H int method=0, double ransacReprojThreshold=3, CvMat* status=NULL)
.. ocv:cfunction:: void cvFindHomography( const CvMat* srcPoints, const CvMat* dstPoints, CvMat* H, int method=0, double ransacReprojThreshold=3, CvMat* status=NULL)
.. ocv:pyoldfunction:: cv.FindHomography(srcPoints, dstPoints, H, method, ransacReprojThreshold=3.0, status=None)-> None
:param srcPoints: Coordinates of the points in the original plane, a matrix of the type ``CV_32FC2`` or ``vector<Point2f>`` .
@ -722,11 +725,12 @@ Homography matrix is determined up to a scale. Thus, it is normalized so that
:math:`h_{33}=1` .
.. seealso::
:ocv:func:`GetAffineTransform`,
:ocv:func:`GetPerspectiveTransform`,
:ocv:func:`EstimateRigidMotion`,
:ocv:func:`WarpPerspective`,
:ocv:func:`PerspectiveTransform`
:ocv:func:`GetAffineTransform`,
:ocv:func:`GetPerspectiveTransform`,
:ocv:func:`EstimateRigidMotion`,
:ocv:func:`WarpPerspective`,
:ocv:func:`PerspectiveTransform`
estimateAffine3D
@ -757,7 +761,7 @@ filterSpeckles
--------------
Filters off small noise blobs (speckles) in the disparity map
.. ocv:function:: void filterSpeckles( InputOutputArray img, double newVal, int maxSpeckleSize, double maxDiff, InputOutputArray buf=noArray() );
.. ocv:function:: void filterSpeckles( InputOutputArray img, double newVal, int maxSpeckleSize, double maxDiff, InputOutputArray buf=noArray() )
.. ocv:pyfunction:: cv2.filterSpeckles(img, newVal, maxSpeckleSize, maxDiff[, buf]) -> None
@ -789,8 +793,8 @@ Returns the new camera matrix based on the free scaling parameter.
:param imageSize: Original image size.
:param alpha: Free scaling parameter between 0 (when all the pixels in the undistorted image are valid) and 1 (when all the source image pixels are retained in the undistorted image). See :ref:`StereoRectify` for details.
:param alpha: Free scaling parameter between 0 (when all the pixels in the undistorted image are valid) and 1 (when all the source image pixels are retained in the undistorted image). See :ocv:func:`stereoRectify` for details.
:param newCameraMatrix: Output new camera matrix.
:param newImageSize: Image size after rectification. By default,it is set to ``imageSize`` .
@ -1130,7 +1134,7 @@ The class implements the modified H. Hirschmuller algorithm HH08 that differs fr
* Mutual information cost function is not implemented. Instead, a simpler Birchfield-Tomasi sub-pixel metric from BT96 is used. Though, the color images are supported as well.
* Some pre- and post- processing steps from K. Konolige algorithm :ocv:func:`StereoBM::operator ()` are included, for example: pre-filtering (``CV_STEREO_BM_XSOBEL`` type) and post-filtering (uniqueness check, quadratic interpolation and speckle filtering).
* Some pre- and post- processing steps from K. Konolige algorithm :ocv:func:`StereoBM::operator()` are included, for example: pre-filtering (``CV_STEREO_BM_XSOBEL`` type) and post-filtering (uniqueness check, quadratic interpolation and speckle filtering).
@ -1150,7 +1154,9 @@ StereoSGBM::StereoSGBM
:param SADWindowSize: Matched block size. It must be an odd number ``>=1`` . Normally, it should be somewhere in the ``3..11`` range.
:param P1, P2: Parameters that control disparity smoothness. The larger the values are, the smoother the disparity is. ``P1`` is the penalty on the disparity change by plus or minus 1 between neighbor pixels. ``P2`` is the penalty on the disparity change by more than 1 between neighbor pixels. The algorithm requires ``P2 > P1`` . See ``stereo_match.cpp`` sample where some reasonably good ``P1`` and ``P2`` values are shown (like ``8*number_of_image_channels*SADWindowSize*SADWindowSize`` and ``32*number_of_image_channels*SADWindowSize*SADWindowSize`` , respectively).
:param P1: The first parameter controlling the disparity smoothness. See below.
:param P2: The second parameter controlling the disparity smoothness. The larger the values are, the smoother the disparity is. ``P1`` is the penalty on the disparity change by plus or minus 1 between neighbor pixels. ``P2`` is the penalty on the disparity change by more than 1 between neighbor pixels. The algorithm requires ``P2 > P1`` . See ``stereo_match.cpp`` sample where some reasonably good ``P1`` and ``P2`` values are shown (like ``8*number_of_image_channels*SADWindowSize*SADWindowSize`` and ``32*number_of_image_channels*SADWindowSize*SADWindowSize`` , respectively).
:param disp12MaxDiff: Maximum allowed difference (in integer pixel units) in the left-right disparity check. Set it to a non-positive value to disable the check.
@ -1247,7 +1253,7 @@ stereoCalibrate
* **CV_CALIB_RATIONAL_MODEL** Enable coefficients k4, k5, and k6. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the rational model and return 8 coefficients. If the flag is not set, the function computes and returns only 5 distortion coefficients.
The function estimates transformation between two cameras making a stereo pair. If you have a stereo camera where the relative position and orientation of two cameras is fixed, and if you computed poses of an object relative to the first camera and to the second camera, (R1, T1) and (R2, T2), respectively (this can be done with
:ref:`solvePnP` ), then those poses definitely relate to each other. This means that, given (
:ocv:func:`solvePnP` ), then those poses definitely relate to each other. This means that, given (
:math:`R_1`,:math:`T_1` ), it should be possible to compute (
:math:`R_2`,:math:`T_2` ). You only need to know the position and orientation of the second camera relative to the first camera. This is what the described function does. It computes (
:math:`R`,:math:`T` ) so that:
@ -1303,11 +1309,15 @@ stereoRectify
:param T: Translation vector between coordinate systems of the cameras.
:param R1, R2: Output :math:`3 \times 3` rectification transforms (rotation matrices) for the first and the second cameras, respectively.
:param R1: Output 3x3 rectification transform (rotation matrix) for the first camera.
:param R2: Output 3x3 rectification transform (rotation matrix) for the second camera.
:param P1, P2: Output :math:`3 \times 4` projection matrices in the new (rectified) coordinate systems.
:param P1: Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
:param P2: Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
:param Q: Output :math:`4 \times 4` disparity-to-depth mapping matrix (see :ref:`reprojectImageTo3D` ).
:param Q: Output :math:`4 \times 4` disparity-to-depth mapping matrix (see :ocv:func:`reprojectImageTo3D` ).
:param flags: Operation flags that may be zero or ``CV_CALIB_ZERO_DISPARITY`` . If the flag is set, the function makes the principal points of each camera have the same pixel coordinates in the rectified views. And if the flag is not set, the function may still shift the images in the horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the useful image area.
@ -1315,7 +1325,9 @@ stereoRectify
:param newImageSize: New image resolution after rectification. The same size should be passed to :ocv:func:`initUndistortRectifyMap` (see the ``stereo_calib.cpp`` sample in OpenCV samples directory). When (0,0) is passed (default), it is set to the original ``imageSize`` . Setting it to larger value can help you preserve details in the original image, especially when there is a big radial distortion.
:param roi1, roi2: Optional output rectangles inside the rectified images where all the pixels are valid. If ``alpha=0`` , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below).
:param roi1:
:param roi2: Optional output rectangles inside the rectified images where all the pixels are valid. If ``alpha=0`` , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below).
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by
:ocv:func:`stereoCalibrate` as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
@ -1371,13 +1383,17 @@ stereoRectifyUncalibrated
.. ocv:cfunction:: void cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2, const CvMat* F, CvSize imageSize, CvMat* H1, CvMat* H2, double threshold=5 )
.. ocv:pyoldfunction:: cv.StereoRectifyUncalibrated(points1, points2, F, imageSize, H1, H2, threshold=5)-> None
:param points1, points2: Two arrays of corresponding 2D points. The same formats as in :ref:`findFundamentalMat` are supported.
:param points1: Array of feature points in the first image.
:param points2: The corresponding points in the second image. The same formats as in :ocv:func:`findFundamentalMat` are supported.
:param F: Input fundamental matrix. It can be computed from the same set of point pairs using :ref:`findFundamentalMat` .
:param F: Input fundamental matrix. It can be computed from the same set of point pairs using :ocv:func:`findFundamentalMat` .
:param imageSize: Size of the image.
:param H1, H2: Output rectification homography matrices for the first and for the second images.
:param H1: Output rectification homography matrix for the first image.
:param H2: Output rectification homography matrix for the second image.
:param threshold: Optional threshold used to filter out the outliers. If the parameter is greater than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points for which :math:`|\texttt{points2[i]}^T*\texttt{F}*\texttt{points1[i]}|>\texttt{threshold}` ) are rejected prior to computing the homographies. Otherwise,all the points are considered inliers.

@ -648,6 +648,7 @@ Finally, there are STL-style iterators that are smart enough to skip gaps betwee
The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, including ``std::sort()`` .
.. _MatrixExpressions:
Matrix Expressions
------------------
@ -701,6 +702,8 @@ Below is the formal description of the ``Mat`` methods.
Mat::Mat
------------
Various Mat constructors
.. ocv:function:: Mat::Mat()
.. ocv:function:: Mat::Mat(int rows, int cols, int type)
@ -741,8 +744,6 @@ Mat::Mat
.. ocv:function:: Mat::Mat(const Mat& m, const Range* ranges)
Provides various array constructors.
:param ndims: Array dimensionality.
:param rows: Number of rows in a 2D array.
@ -786,24 +787,23 @@ often the default constructor is enough, and the proper matrix will be allocated
Mat::~Mat
------------
.. ocv:function:: Mat::~Mat()
The Mat destructor.
Provides a matrix destructor.
.. ocv:function:: Mat::~Mat()
The matrix destructor calls
:ocv:func:`Mat::release` .
The matrix destructor calls :ocv:func:`Mat::release` .
Mat::operator =
-------------------
Provides matrix assignment operators.
.. ocv:function:: Mat& Mat::operator = (const Mat& m)
.. ocv:function:: Mat& Mat::operator = (const MatExpr_Base& expr)
.. ocv:function:: Mat& operator = (const Scalar& s)
Provides matrix assignment operators.
:param m: Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that no data is copied but the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is de-referenced via :ocv:func:`Mat::release` .
:param expr: Assigned matrix expression object. As opposite to the first form of the assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, ``C=A+B`` is expanded to ``add(A, B, C)`` , and :func:`add` takes care of automatic ``C`` reallocation.
@ -815,18 +815,18 @@ These are available assignment operators. Since they all are very different, mak
Mat::operator MatExpr
-------------------------
.. ocv:function:: Mat::operator MatExpr_<Mat, Mat>() const
Provides a ``Mat`` -to- ``MatExpr`` cast operator.
Provides a ``Mat`` -to- ``MatExpr`` cast operator.
.. ocv:function:: Mat::operator MatExpr_<Mat, Mat>() const
The cast operator should not be called explicitly. It is used internally by the
:ref:`MatrixExpressions` engine.
Mat::row
------------
.. ocv:function:: Mat Mat::row(int i) const
Creates a matrix header for the specified matrix row.
Creates a matrix header for the specified matrix row.
.. ocv:function:: Mat Mat::row(int i) const
:param i: A 0-based row index.
@ -847,8 +847,7 @@ The method makes a new header for the specified matrix row and returns it. This
A.row(i) = A.row(j); // will not work
This happens because ``A.row(i)`` forms a temporary header that is further assigned to another header. Remember that each of these operations is O(1), that is, no data is copied. Thus, the above assignment is not true if you may have expected the j-th row to be copied to the i-th row. To achieve that, you should either turn this simple assignment into an expression or use the
:ocv:func:`Mat::copyTo` method: ::
This happens because ``A.row(i)`` forms a temporary header that is further assigned to another header. Remember that each of these operations is O(1), that is, no data is copied. Thus, the above assignment is not true if you may have expected the j-th row to be copied to the i-th row. To achieve that, you should either turn this simple assignment into an expression or use the :ocv:func:`Mat::copyTo` method: ::
Mat A;
...
@ -860,9 +859,9 @@ The method makes a new header for the specified matrix row and returns it. This
Mat::col
------------
.. ocv:function:: Mat Mat::col(int j) const
Creates a matrix header for the specified matrix column.
Creates a matrix header for the specified matrix column.
.. ocv:function:: Mat Mat::col(int j) const
:param j: A 0-based column index.
@ -872,12 +871,12 @@ The method makes a new header for the specified matrix column and returns it. Th
Mat::rowRange
-----------------
Creates a matrix header for the specified row span.
.. ocv:function:: Mat Mat::rowRange(int startrow, int endrow) const
.. ocv:function:: Mat Mat::rowRange(const Range& r) const
Creates a matrix header for the specified row span.
:param startrow: A 0-based start index of the row span.
:param endrow: A 0-based ending index of the row span.
@ -890,12 +889,12 @@ The method makes a new header for the specified row span of the matrix. Similarl
Mat::colRange
-----------------
Creates a matrix header for the specified row span.
.. ocv:function:: Mat Mat::colRange(int startcol, int endcol) const
.. ocv:function:: Mat Mat::colRange(const Range& r) const
Creates a matrix header for the specified row span.
:param startcol: A 0-based start index of the column span.
:param endcol: A 0-based ending index of the column span.
@ -908,12 +907,12 @@ The method makes a new header for the specified column span of the matrix. Simil
Mat::diag
-------------
Extracts a diagonal from a matrix, or creates a diagonal matrix.
.. ocv:function:: Mat Mat::diag(int d) const
.. ocv:function:: static Mat Mat::diag(const Mat& matD)
Extracts a diagonal from a matrix, or creates a diagonal matrix.
:param d: Index of the diagonal, with the following values:
* **d=0** is the main diagonal.
@ -930,20 +929,20 @@ The method makes a new header for the specified matrix diagonal. The new matrix
Mat::clone
--------------
.. ocv:function:: Mat Mat::clone() const
Creates a full copy of the array and the underlying data.
Creates a full copy of the array and the underlying data.
.. ocv:function:: Mat Mat::clone() const
The method creates a full copy of the array. The original ``step[]`` is not taken into account. So, the array copy is a continuous array occupying ``total()*elemSize()`` bytes.
Mat::copyTo
---------------
Copies the matrix to another one.
.. ocv:function:: void Mat::copyTo( OutputArray m ) const
.. ocv:function:: void Mat::copyTo( OutputArray m, InputArray mask ) const
Copies the matrix to another one.
:param m: Destination matrix. If it does not have a proper size or type before the operation, it is reallocated.
:param mask: Operation mask. Its non-zero elements indicate which matrix elements need to be copied.
@ -961,9 +960,9 @@ When the operation mask is specified, and the ``Mat::create`` call shown above r
Mat::convertTo
------------------
.. ocv:function:: void Mat::convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const
Converts an array to another datatype with optional scaling.
Converts an array to another datatype with optional scaling.
.. ocv:function:: void Mat::convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const
:param m: Destination matrix. If it does not have a proper size or type before the operation, it is reallocated.
@ -982,9 +981,9 @@ The method converts source pixel values to the target datatype. ``saturate_cast<
Mat::assignTo
-----------------
.. ocv:function:: void Mat::assignTo( Mat& m, int type=-1 ) const
Provides a functional form of ``convertTo``.
Provides a functional form of ``convertTo``.
.. ocv:function:: void Mat::assignTo( Mat& m, int type=-1 ) const
:param m: Destination array.
@ -995,9 +994,9 @@ This is an internally used method called by the
Mat::setTo
--------------
.. ocv:function:: Mat& Mat::setTo(const Scalar& s, InputArray mask=noArray())
Sets all or some of the array elements to the specified value.
Sets all or some of the array elements to the specified value.
.. ocv:function:: Mat& Mat::setTo(const Scalar& s, InputArray mask=noArray())
:param s: Assigned scalar converted to the actual array type.
@ -1006,9 +1005,9 @@ Mat::setTo
Mat::reshape
----------------
.. ocv:function:: Mat Mat::reshape(int cn, int rows=0) const
Changes the shape and/or the number of channels of a 2D matrix without copying the data.
Changes the shape and/or the number of channels of a 2D matrix without copying the data.
.. ocv:function:: Mat Mat::reshape(int cn, int rows=0) const
:param cn: New number of channels. If the parameter is 0, the number of channels remains the same.
@ -1039,9 +1038,9 @@ For example, if there is a set of 3D points stored as an STL vector, and you wan
Mat::t
----------
.. ocv:function:: MatExpr Mat::t() const
Transposes a matrix.
Transposes a matrix.
.. ocv:function:: MatExpr Mat::t() const
The method performs matrix transposition by means of matrix expressions. It does not perform the actual transposition but returns a temporary matrix transposition object that can be further used as a part of more complex matrix expressions or can be assigned to a matrix: ::
@ -1051,9 +1050,9 @@ The method performs matrix transposition by means of matrix expressions. It does
Mat::inv
------------
.. ocv:function:: MatExpr Mat::inv(int method=DECOMP_LU) const
Inverses a matrix.
Inverses a matrix.
.. ocv:function:: MatExpr Mat::inv(int method=DECOMP_LU) const
:param method: Matrix inversion method. Possible values are the following:
@ -1068,9 +1067,9 @@ The method performs a matrix inversion by means of matrix expressions. This mean
Mat::mul
------------
.. ocv:function:: MatExpr Mat::mul(InputArray m, double scale=1) const
Performs an element-wise multiplication or division of the two matrices.
Performs an element-wise multiplication or division of the two matrices.
.. ocv:function:: MatExpr Mat::mul(InputArray m, double scale=1) const
:param m: Another array of the same type and the same size as ``*this``, or a matrix expression.
@ -1085,9 +1084,9 @@ Example: ::
Mat::cross
--------------
.. ocv:function:: Mat Mat::cross(InputArray m) const
Computes a cross-product of two 3-element vectors.
Computes a cross-product of two 3-element vectors.
.. ocv:function:: Mat Mat::cross(InputArray m) const
:param m: Another cross-product operand.
@ -1096,9 +1095,9 @@ The method computes a cross-product of two 3-element vectors. The vectors must b
Mat::dot
------------
.. ocv:function:: double Mat::dot(InputArray m) const
Computes a dot-product of two vectors.
Computes a dot-product of two vectors.
.. ocv:function:: double Mat::dot(InputArray m) const
:param m: Another dot-product operand.
@ -1107,12 +1106,12 @@ The method computes a dot-product of two matrices. If the matrices are not singl
Mat::zeros
--------------
Returns a zero array of the specified size and type.
.. ocv:function:: static MatExpr Mat::zeros(int rows, int cols, int type)
.. ocv:function:: static MatExpr Mat::zeros(Size size, int type)
.. ocv:function:: static MatExpr Mat::zeros(int ndims, const int* sizes, int type)
Returns a zero array of the specified size and type.
:param ndims: Array dimensionality.
:param rows: Number of rows.
@ -1136,12 +1135,12 @@ In the example above, a new matrix is allocated only if ``A`` is not a 3x3 float
Mat::ones
-------------
Returns an array of all 1's of the specified size and type.
.. ocv:function:: static MatExpr Mat::ones(int rows, int cols, int type)
.. ocv:function:: static MatExpr Mat::ones(Size size, int type)
.. ocv:function:: static MatExpr Mat::ones(int ndims, const int* sizes, int type)
Returns an array of all 1's of the specified size and type.
:param ndims: Array dimensionality.
:param rows: Number of rows.
@ -1165,11 +1164,11 @@ The above operation does not form a 100x100 matrix of 1's and then multiply it b
Mat::eye
------------
Returns an identity matrix of the specified size and type.
.. ocv:function:: static MatExpr Mat::eye(int rows, int cols, int type)
.. ocv:function:: static MatExpr Mat::eye(Size size, int type)
Returns an identity matrix of the specified size and type.
:param rows: Number of rows.
:param cols: Number of columns.
@ -1188,12 +1187,12 @@ The method returns a Matlab-style identity matrix initializer, similarly to
Mat::create
---------------
Allocates new array data if needed.
.. ocv:function:: void Mat::create(int rows, int cols, int type)
.. ocv:function:: void Mat::create(Size size, int type)
.. ocv:function:: void Mat::create(int ndims, const int* sizes, int type)
Allocates new array data if needed.
:param ndims: New array dimensionality.
:param rows: New number of rows.
@ -1242,9 +1241,9 @@ because ``cvtColor`` , as well as the most of OpenCV functions, calls ``Mat::cre
Mat::addref
---------------
.. ocv:function:: void Mat::addref()
Increments the reference counter.
Increments the reference counter.
.. ocv:function:: void Mat::addref()
The method increments the reference counter associated with the matrix data. If the matrix header points to an external data set (see
:ocv:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It is called implicitly by the matrix assignment operator. The reference counter increment is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
@ -1252,9 +1251,9 @@ The method increments the reference counter associated with the matrix data. If
Mat::release
----------------
.. ocv:function:: void Mat::release()
Decrements the reference counter and deallocates the matrix if needed.
Decrements the reference counter and deallocates the matrix if needed.
.. ocv:function:: void Mat::release()
The method decrements the reference counter associated with the matrix data. When the reference counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers are set to NULL's. If the matrix header points to an external data set (see
:ocv:func:`Mat::Mat` ), the reference counter is NULL, and the method has no effect in this case.
@ -1263,11 +1262,11 @@ This method can be called manually to force the matrix data deallocation. But si
Mat::resize
---------------
Changes the number of matrix rows.
.. ocv:function:: void Mat::resize( size_t sz )
.. ocv:function:: void Mat::resize( size_t sz, const Scalar& s )
Changes the number of matrix rows.
:param sz: New number of rows.
:param s: Value assigned to the newly added elements.
@ -1276,9 +1275,9 @@ The methods change the number of matrix rows. If the matrix is reallocated, the
Mat::reserve
---------------
.. ocv:function:: void Mat::reserve( size_t sz )
Reserves space for the certain number of rows.
Reserves space for the certain number of rows.
.. ocv:function:: void Mat::reserve( size_t sz )
:param sz: Number of rows.
@ -1286,20 +1285,20 @@ The method reserves space for ``sz`` rows. If the matrix already has enough spac
Mat::push_back
--------------
Adds elements to the bottom of the matrix.
.. ocv:function:: template<typename T> void Mat::push_back(const T& elem)
.. ocv:function:: void Mat::push_back(const Mat& elem)
Adds elements to the bottom of the matrix.
:param elem: Added element(s).
The methods add one or more elements to the bottom of the matrix. They emulate the corresponding method of the STL vector class. When ``elem`` is ``Mat`` , its type and the number of columns must be the same as in the container matrix.
Mat::pop_back
-------------
.. ocv:function:: template<typename T> void Mat::pop_back(size_t nelems=1)
Removes elements from the bottom of the matrix.
Removes elements from the bottom of the matrix.
.. ocv:function:: template<typename T> void Mat::pop_back(size_t nelems=1)
:param nelems: Number of removed rows. If it is greater than the total number of rows, an exception is thrown.
@ -1308,9 +1307,9 @@ The method removes one or more rows from the bottom of the matrix.
Mat::locateROI
------------------
.. ocv:function:: void Mat::locateROI( Size& wholeSize, Point& ofs ) const
Locates the matrix header within a parent matrix.
Locates the matrix header within a parent matrix.
.. ocv:function:: void Mat::locateROI( Size& wholeSize, Point& ofs ) const
:param wholeSize: Output parameter that contains the size of the whole matrix containing ``*this`` is a part.
@ -1325,9 +1324,9 @@ After you extracted a submatrix from a matrix using
Mat::adjustROI
------------------
.. ocv:function:: Mat& Mat::adjustROI( int dtop, int dbottom, int dleft, int dright )
Adjusts a submatrix size and position within the parent matrix.
Adjusts a submatrix size and position within the parent matrix.
.. ocv:function:: Mat& Mat::adjustROI( int dtop, int dbottom, int dleft, int dright )
:param dtop: Shift of the top submatrix boundary upwards.
@ -1350,19 +1349,19 @@ It is your responsibility to make sure ``adjustROI`` does not cross the parent m
The function is used internally by the OpenCV filtering functions, like
:ocv:func:`filter2D` , morphological operations, and so on.
See Also:
:ocv:func:`copyMakeBorder`
.. seealso:: :ocv:func:`copyMakeBorder`
Mat::operator()
-------------------
Extracts a rectangular submatrix.
.. ocv:function:: Mat Mat::operator()( Range rowRange, Range colRange ) const
.. ocv:function:: Mat Mat::operator()( const Rect& roi ) const
.. ocv:function:: Mat Mat::operator()( const Ranges* ranges ) const
Extracts a rectangular submatrix.
:param rowRange: Start and end row of the extracted submatrix. The upper boundary is not included. To select all the rows, use ``Range::all()``.
@ -1381,9 +1380,10 @@ The operators make a new header for the specified sub-array of ``*this`` . They
Mat::operator CvMat
-----------------------
Creates the ``CvMat`` header for the matrix.
.. ocv:function:: Mat::operator CvMat() const
Creates the ``CvMat`` header for the matrix.
The operator creates the ``CvMat`` header for the matrix without copying the underlying data. The reference counter is not taken into account by this operation. Thus, you should make sure than the original matrix is not deallocated while the ``CvMat`` header is used. The operator is useful for intermixing the new and the old OpenCV API's, for example: ::
@ -1399,25 +1399,25 @@ where ``mycvOldFunc`` is a function written to work with OpenCV 1.x data structu
Mat::operator IplImage
--------------------------
.. ocv:function:: Mat::operator IplImage() const
Creates the ``IplImage`` header for the matrix.
Creates the ``IplImage`` header for the matrix.
.. ocv:function:: Mat::operator IplImage() const
The operator creates the ``IplImage`` header for the matrix without copying the underlying data. You should make sure than the original matrix is not deallocated while the ``IplImage`` header is used. Similarly to ``Mat::operator CvMat`` , the operator is useful for intermixing the new and the old OpenCV API's.
Mat::total
--------------
.. ocv:function:: size_t Mat::total() const
Returns the total number of array elements.
Returns the total number of array elements.
.. ocv:function:: size_t Mat::total() const
The method returns the number of array elements (a number of pixels if the array represents an image).
Mat::isContinuous
---------------------
.. ocv:function:: bool Mat::isContinuous() const
Reports whether the matrix is continuous or not.
Reports whether the matrix is continuous or not.
.. ocv:function:: bool Mat::isContinuous() const
The method returns ``true`` if the matrix elements are stored continuously without gaps at the end of each row. Otherwise, it returns ``false``. Obviously, ``1x1`` or ``1xN`` matrices are always continuous. Matrices created with
:ocv:func:`Mat::create` are always continuous. But if you extract a part of the matrix using
@ -1486,36 +1486,36 @@ Another OpenCV idiom in this function, a call of
Mat::elemSize
-----------------
.. ocv:function:: size_t Mat::elemSize(void) const
Returns the matrix element size in bytes.
Returns the matrix element size in bytes.
.. ocv:function:: size_t Mat::elemSize(void) const
The method returns the matrix element size in bytes. For example, if the matrix type is ``CV_16SC3`` , the method returns ``3*sizeof(short)`` or 6.
Mat::elemSize1
------------------
.. ocv:function:: size_t Mat::elemSize() const
Returns the size of each matrix element channel in bytes.
Returns the size of each matrix element channel in bytes.
.. ocv:function:: size_t Mat::elemSize() const
The method returns the matrix element channel size in bytes, that is, it ignores the number of channels. For example, if the matrix type is ``CV_16SC3`` , the method returns ``sizeof(short)`` or 2.
Mat::type
-------------
.. ocv:function:: int Mat::type() const
Returns the type of a matrix element.
Returns the type of a matrix element.
.. ocv:function:: int Mat::type() const
The method returns a matrix element type. This is an identifier compatible with the ``CvMat`` type system, like ``CV_16SC3`` or 16-bit signed 3-channel array, and so on.
Mat::depth
--------------
.. ocv:function:: int Mat::depth() const
Returns the depth of a matrix element.
Returns the depth of a matrix element.
.. ocv:function:: int Mat::depth() const
The method returns the identifier of the matrix element depth (the type of each individual channel). For example, for a 16-bit signed 3-channel array, the method returns ``CV_16S`` . A complete list of matrix types contains the following values:
@ -1536,18 +1536,18 @@ The method returns the identifier of the matrix element depth (the type of each
Mat::channels
-----------------
.. ocv:function:: int Mat::channels() const
Returns the number of matrix channels.
Returns the number of matrix channels.
.. ocv:function:: int Mat::channels() const
The method returns the number of matrix channels.
Mat::step1
--------------
.. ocv:function:: size_t Mat::step1() const
Returns a normalized step.
Returns a normalized step.
.. ocv:function:: size_t Mat::step1() const
The method returns a matrix step divided by
:ocv:func:`Mat::elemSize1()` . It can be useful to quickly access an arbitrary matrix element.
@ -1555,24 +1555,26 @@ The method returns a matrix step divided by
Mat::size
-------------
.. ocv:function:: Size Mat::size() const
Returns a matrix size.
Returns a matrix size.
.. ocv:function:: Size Mat::size() const
The method returns a matrix size: ``Size(cols, rows)`` .
The method returns a matrix size: ``Size(cols, rows)`` . When the matrix is more than 2-dimensional, the returned size is (-1, -1).
Mat::empty
--------------
.. ocv:function:: bool Mat::empty() const
Returns ``true`` if the array has no elemens.
Returns ``true`` if the array has no elemens.
.. ocv:function:: bool Mat::empty() const
The method returns ``true`` if ``Mat::total()`` is 0 or if ``Mat::data`` is NULL. Because of ``pop_back()`` and ``resize()`` methods ``M.total() == 0`` does not imply that ``M.data == NULL`` .
Mat::ptr
------------
Returns a pointer to the specified matrix row.
.. ocv:function:: uchar* Mat::ptr(int i=0)
.. ocv:function:: const uchar* Mat::ptr(int i=0) const
@ -1581,8 +1583,6 @@ Mat::ptr
.. ocv:function:: template<typename _Tp> const _Tp* Mat::ptr(int i=0) const
Returns a pointer to the specified matrix row.
:param i: A 0-based row index.
The methods return ``uchar*`` or typed pointer to the specified matrix row. See the sample in
@ -1591,6 +1591,8 @@ The methods return ``uchar*`` or typed pointer to the specified matrix row. See
Mat::at
-----------
Returns a reference to the specified array element.
.. ocv:function:: template<typename T> T& Mat::at(int i) const
.. ocv:function:: template<typename T> const T& Mat::at(int i) const
@ -1611,12 +1613,12 @@ Mat::at
.. ocv:function:: template<typename T> const T& Mat::at(const int* idx) const
Returns a reference to the specified array element.
:param i, j, k: Indices along the dimensions 0, 1, and 2, respectively.
:param i: Index along the dimension 0
:param j: Index along the dimension 1
:param k: Index along the dimension 2
:param pt: Element position specified as ``Point(j,i)`` .
:param idx: Array of ``Mat::dims`` indices.
The template methods return a reference to the specified array element. For the sake of higher performance, the index range checks are only performed in the Debug configuration.
@ -1634,9 +1636,11 @@ The example below initializes a Hilbert matrix: ::
Mat::begin
--------------
.. ocv:function:: template<typename _Tp> MatIterator_<_Tp> Mat::begin() template<typename _Tp> MatConstIterator_<_Tp> Mat::begin() const
Returns the matrix iterator and sets it to the first matrix element.
.. ocv:function:: template<typename _Tp> MatIterator_<_Tp> Mat::begin()
Returns the matrix iterator and sets it to the first matrix element.
.. ocv:function:: template<typename _Tp> MatConstIterator_<_Tp> Mat::begin() const
The methods return the matrix read-only or read-write iterators. The use of matrix iterators is very similar to the use of bi-directional STL iterators. In the example below, the alpha blending function is rewritten using the matrix iterators: ::
@ -1673,10 +1677,11 @@ The methods return the matrix read-only or read-write iterators. The use of matr
Mat::end
------------
Returns the matrix iterator and sets it to the after-last matrix element.
.. ocv:function:: template<typename _Tp> MatIterator_<_Tp> Mat::end()
.. ocv:function:: template<typename _Tp> MatConstIterator_<_Tp> Mat::end() const
Returns the matrix iterator and sets it to the after-last matrix element.
.. ocv:function:: template<typename _Tp> MatConstIterator_<_Tp> Mat::end() const
The methods return the matrix read-only or read-write iterators, set to the point following the last matrix element.

@ -271,7 +271,7 @@ InitFont
--------
Initializes font structure (OpenCV 1.x API).
.. c:function:: void cvInitFont( CvFont* font, int fontFace, double hscale, double vscale, double shear=0, int thickness=1, int lineType=8 )
.. ocv:cfunction:: void cvInitFont( CvFont* font, int fontFace, double hscale, double vscale, double shear=0, int thickness=1, int lineType=8 )
:param font: Pointer to the font structure initialized by the function
@ -308,7 +308,7 @@ Initializes font structure (OpenCV 1.x API).
:param thickness: Thickness of the text strokes
:param lineType: Type of the strokes, see :ref:`Line` description
:param lineType: Type of the strokes, see :ocv:func:`line` description
The function initializes the font structure that can be passed to text rendering functions.

@ -92,7 +92,7 @@ you can use::
Ptr<T> ptr = new T(...);
That is, ``Ptr<T> ptr`` incapsulates a pointer to a ``T`` instance and a reference counter associated with the pointer. See the
:ref:`Ptr`
:ocv:class:`Ptr`
description for details.
.. _AutomaticAllocation:
@ -176,7 +176,7 @@ Multi-channel (``n``-channel) types can be specified using the following options
.. note:: ``CV_32FC1 == CV_32F``, ``CV_32FC2 == CV_32FC(2) == CV_MAKETYPE(CV_32F, 2)``, and ``CV_MAKETYPE(depth, n) == ((x&7)<<3) + (n-1)``. This means that the constant type is formed from the ``depth``, taking the lowest 3 bits, and the number of channels minus 1, taking the next ``log2(CV_CN_MAX)`` bits.
Examples::
Examples: ::
Mat mtx(3, 3, CV_32F); // make a 3x3 floating-point matrix
Mat cmtx(10, 1, CV_64FC2); // make a 10x1 2-channel floating-point

@ -18,7 +18,7 @@ Computes an absolute value of each matrix element.
* ``C = abs(A)`` is equivalent to ``absdiff(A, Scalar::all(0), C)``
* ``C = Mat_<Vec<uchar,n> >(abs(A*alpha + beta))`` is equivalent to :ocv:funcx:`convertScaleAbs`(A, C, alpha, beta)`
* ``C = Mat_<Vec<uchar,n> >(abs(A*alpha + beta))`` is equivalent to :ocv:funcx:`convertScaleAbs` (A, C, alpha, beta)
The output matrix has the same size and the same type as the input one except for the last case, where ``C`` is ``depth=CV_8U`` .
@ -2172,7 +2172,7 @@ PCA constructors
:param maxComponents: Maximum number of components that PCA should retain. By default, all the components are retained.
The default constructor initializes an empty PCA structure. The second constructor initializes the structure and calls
:ocv:func:`PCA::operator ()` .
:ocv:func:`PCA::operator()` .
@ -3114,7 +3114,7 @@ The constructors.
* **SVD::FULL_UV** When the matrix is not square, by default the algorithm produces ``u`` and ``vt`` matrices of sufficiently large size for the further ``A`` reconstruction. If, however, ``FULL_UV`` flag is specified, ``u`` and ``vt`` will be full-size square orthogonal matrices.
The first constructor initializes an empty ``SVD`` structure. The second constructor initializes an empty ``SVD`` structure and then calls
:ocv:func:`SVD::operator ()` .
:ocv:func:`SVD::operator()` .
SVD::operator ()
@ -3163,7 +3163,7 @@ Performs SVD of a matrix
:param flags: Opertion flags - see :ocv:func:`SVD::SVD`.
The methods/functions perform SVD of matrix. Unlike ``SVD::SVD`` constructor and ``SVD::operator ()``, they store the results to the user-provided matrices. ::
The methods/functions perform SVD of matrix. Unlike ``SVD::SVD`` constructor and ``SVD::operator()``, they store the results to the user-provided matrices. ::
Mat A, w, u, vt;
SVD::compute(A, w, u, vt);
@ -3231,7 +3231,7 @@ Calculates the sum of array elements.
.. ocv:function:: Scalar sum(InputArray arr)
.. ocv:function:: cv2.sumElems(arr) -> retval
.. ocv:pyfunction:: cv2.sumElems(arr) -> retval
.. ocv:cfunction:: CvScalar cvSum(const CvArr* arr)
.. ocv:pyoldfunction:: cv.Sum(arr)-> CvScalar

@ -988,9 +988,14 @@ void binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
c = src1.channels();
}
Size sz = getContinuousSize(src1, src2, dst, c);
func(src1.data, src1.step, src2.data, src2.step, dst.data, dst.step, sz, 0);
return;
Size sz = getContinuousSize(src1, src2, dst);
size_t len = sz.width*(size_t)c;
if( len == (size_t)(int)len )
{
sz.width = (int)len;
func(src1.data, src1.step, src2.data, src2.step, dst.data, dst.step, sz, 0);
return;
}
}
if( (kind1 == _InputArray::MATX) + (kind2 == _InputArray::MATX) == 1 ||
@ -1045,6 +1050,9 @@ void binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
NAryMatIterator it(arrays, ptrs);
size_t total = it.size, blocksize = total;
if( blocksize*c > INT_MAX )
blocksize = INT_MAX/c;
if( haveMask )
{
blocksize = std::min(blocksize, blocksize0);

@ -171,11 +171,12 @@ void Mat::copyTo( OutputArray _dst ) const
// to handle the copying 1xn matrix => nx1 std vector.
Size sz = size() == dst.size() ?
getContinuousSize(*this, dst, (int)elemSize()) :
getContinuousSize(*this, (int)elemSize());
getContinuousSize(*this, dst) :
getContinuousSize(*this);
size_t len = sz.width*elemSize();
for( ; sz.height--; sptr += step, dptr += dst.step )
memcpy( dptr, sptr, sz.width );
memcpy( dptr, sptr, len );
}
return;
}

@ -195,6 +195,13 @@ struct AddWeightedOp : public BaseAddOp
struct MulOp : public BaseElemWiseOp
{
MulOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
void getValueRange(int depth, double& minval, double& maxval)
{
minval = depth < CV_32S ? cvtest::getMinVal(depth) : depth == CV_32S ? -1000000 : -1000.;
maxval = depth < CV_32S ? cvtest::getMaxVal(depth) : depth == CV_32S ? 1000000 : 1000.;
minval = std::max(minval, -30000.);
maxval = std::min(maxval, 30000.);
}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::multiply(src[0], src[1], dst, alpha);

@ -528,7 +528,7 @@ That's all there is to it!
#if defined _MSC_VER && _MSC_VER >= 1200
#if !defined(_MT) || defined(_DLL)
#if !defined(_MT) || defined(_DLL) || defined(_MSC_VER)
extern "C" { __declspec(dllexport) unsigned int __lc_codepage = 0; }
#endif
#ifdef _M_X64

@ -487,7 +487,7 @@ gpu::reprojectImageTo3D
:param xyzw: Output 4-channel floating-point image of the same size as ``disp`` . Each element of ``xyzw(x,y)`` contains 3D coordinates ``(x,y,z,1)`` of the point ``(x,y)`` , computed from the disparity map.
:param Q: :math:`4 \times 4` perspective transformation matrix that can be obtained via :ref:`StereoRectify` .
:param Q: :math:`4 \times 4` perspective transformation matrix that can be obtained via :ocv:func:`stereoRectify` .
:param stream: Stream for the asynchronous version.

@ -115,6 +115,7 @@ By using ``FilterEngine_GPU`` instead of functions you can avoid unnecessary mem
.. note:: The GPU filters do not support the in-place mode.
.. seealso::
:ocv:class:`gpu::BaseRowFilter_GPU`,
:ocv:class:`gpu::BaseColumnFilter_GPU`,
:ocv:class:`gpu::BaseFilter_GPU`,
@ -454,11 +455,13 @@ gpu::getLinearRowFilter_GPU
:param borderType: Pixel extrapolation method. For details, see :ocv:func:`borderInterpolate`. For details on limitations, see below.
There are two versions of the algorithm: NPP and OpenCV.
* NPP version is called when ``srcType == CV_8UC1`` or ``srcType == CV_8UC4`` and ``bufType == srcType`` . Otherwise, the OpenCV version is called. NPP supports only ``BORDER_CONSTANT`` border type and does not check indices outside the image.
* OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE``, and ``BORDER_CONSTANT`` border types. It checks indices outside the image.
There are two versions of the algorithm: NPP and OpenCV.
* NPP version is called when ``srcType == CV_8UC1`` or ``srcType == CV_8UC4`` and ``bufType == srcType`` . Otherwise, the OpenCV version is called. NPP supports only ``BORDER_CONSTANT`` border type and does not check indices outside the image.
* OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE``, and ``BORDER_CONSTANT`` border types. It checks indices outside the image.
See Also:,:ocv:func:`createSeparableLinearFilter` .
.. seealso:: :ocv:func:`createSeparableLinearFilter` .
.. index:: gpu::getLinearColumnFilter_GPU
@ -496,12 +499,15 @@ gpu::createSeparableLinearFilter_GPU
:param dstType: Destination array type. ``CV_8UC1``, ``CV_8UC4``, ``CV_16SC1``, ``CV_16SC2``, ``CV_32SC1``, ``CV_32FC1`` destination types are supported.
:param rowKernel, columnKernel: Filter coefficients.
:param rowKernel: Horizontal filter coefficients.
:param columnKernel: Vertical filter coefficients.
:param anchor: Anchor position within the kernel. Negative values mean that anchor is positioned at the aperture center.
:param rowBorderType, columnBorderType: Pixel extrapolation method in the horizontal and vertical directions For details, see :ocv:func:`borderInterpolate`. For details on limitations, see :ocv:func:`gpu::getLinearRowFilter_GPU`, cpp:ocv:func:`gpu::getLinearColumnFilter_GPU`.
:param rowBorderType: Pixel extrapolation method in the vertical direction For details, see :ocv:func:`borderInterpolate`. For details on limitations, see :ocv:func:`gpu::getLinearRowFilter_GPU`, cpp:ocv:func:`gpu::getLinearColumnFilter_GPU`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::getLinearRowFilter_GPU`, :ocv:func:`gpu::getLinearColumnFilter_GPU`, :ocv:func:`createSeparableLinearFilter`
@ -519,11 +525,15 @@ gpu::sepFilter2D
:param ddepth: Destination image depth. ``CV_8U``, ``CV_16S``, ``CV_32S``, and ``CV_32F`` are supported.
:param kernelX, kernelY: Filter coefficients.
:param kernelX: Horizontal filter coefficients.
:param kernelY: Vertical filter coefficients.
:param anchor: Anchor position within the kernel. The default value ``(-1, 1)`` means that the anchor is at the kernel center.
:param rowBorderType, columnBorderType: Pixel extrapolation method. For details, see :ocv:func:`borderInterpolate`.
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`sepFilter2D`
@ -545,7 +555,10 @@ gpu::createDerivFilter_GPU
:param ksize: Aperture size. See :ocv:func:`getDerivKernels` for details.
:param rowBorderType, columnBorderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`createDerivFilter`
@ -571,7 +584,9 @@ gpu::Sobel
:param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. For details, see :ocv:func:`getDerivKernels` .
:param rowBorderType, columnBorderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`Sobel`
@ -595,7 +610,9 @@ gpu::Scharr
:param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :ocv:func:`getDerivKernels` for details.
:param rowBorderType, columnBorderType: Pixel extrapolation method. For details, see :ocv:func:`borderInterpolate` and :ocv:func:`Scharr` .
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`Scharr`
@ -615,7 +632,9 @@ gpu::createGaussianFilter_GPU
:param sigmaY: Gaussian sigma in the vertical direction. If 0, then :math:`\texttt{sigmaY}\leftarrow\texttt{sigmaX}` .
:param rowBorderType, columnBorderType: Border type to use. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::createSeparableLinearFilter_GPU`, :ocv:func:`createGaussianFilter`
@ -633,9 +652,13 @@ 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 :ocv:func:`getGaussianKernel` for details. To fully control the result regardless of possible future modification of all this semantics, you are recommended to specify all of ``ksize``, ``sigmaX``, and ``sigmaY`` .
:param sigmaX: Gaussian kernel standard deviation in X direction.
:param sigmaY: Gaussian kernel standard deviation in Y direction. If ``sigmaY`` is zero, it is set to be equal to ``sigmaX`` . If they are both zeros, they are computed from ``ksize.width`` and ``ksize.height``, respectively. See :ocv:func:`getGaussianKernel` for details. To fully control the result regardless of possible future modification of all this semantics, you are recommended to specify all of ``ksize``, ``sigmaX``, and ``sigmaY`` .
:param rowBorderType, columnBorderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
.. seealso:: :ocv:func:`gpu::createGaussianFilter_GPU`, :ocv:func:`GaussianBlur`

@ -3,7 +3,7 @@ Image Processing
.. highlight:: cpp
.. index:: gpu::meanShiftFiltering
gpu::meanShiftFiltering
---------------------------
@ -21,7 +21,7 @@ gpu::meanShiftFiltering
:param criteria: Termination criteria. See :ocv:class:`TermCriteria`.
.. index:: gpu::meanShiftProc
gpu::meanShiftProc
----------------------
@ -41,10 +41,8 @@ gpu::meanShiftProc
:param criteria: Termination criteria. See :ocv:class:`TermCriteria`.
.. seealso::
:ocv:func:`gpu::meanShiftFiltering`
.. seealso:: :ocv:func:`gpu::meanShiftFiltering`
.. index:: gpu::meanShiftSegmentation
gpu::meanShiftSegmentation
------------------------------
@ -64,7 +62,7 @@ gpu::meanShiftSegmentation
:param criteria: Termination criteria. See :ocv:class:`TermCriteria`.
.. index:: gpu::integral
gpu::integral
-----------------
@ -80,10 +78,9 @@ gpu::integral
:param sqsum: Squared integral image of the ``CV_32FC1`` type.
.. seealso::
:ocv:func:`integral`
.. seealso:: :ocv:func:`integral`
.. index:: gpu::sqrIntegral
gpu::sqrIntegral
--------------------
@ -95,7 +92,7 @@ gpu::sqrIntegral
:param sqsum: Squared integral image containing 64-bit unsigned integer values packed into ``CV_64FC1`` .
.. index:: gpu::columnSum
gpu::columnSum
------------------
@ -107,7 +104,7 @@ gpu::columnSum
:param sum: Destination image of the ``CV_32FC1`` type.
.. index:: gpu::cornerHarris
gpu::cornerHarris
---------------------
@ -127,10 +124,8 @@ gpu::cornerHarris
:param borderType: Pixel extrapolation method. Only ``BORDER_REFLECT101`` and ``BORDER_REPLICATE`` are supported for now.
.. seealso::
:ocv:func:`cornerHarris`
.. seealso:: :ocv:func:`cornerHarris`
.. index:: gpu::cornerMinEigenVal
gpu::cornerMinEigenVal
--------------------------
@ -152,7 +147,7 @@ gpu::cornerMinEigenVal
.. seealso:: :ocv:func:`cornerMinEigenVal`
.. index:: gpu::mulSpectrums
gpu::mulSpectrums
---------------------
@ -172,10 +167,8 @@ gpu::mulSpectrums
Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
.. seealso::
:ocv:func:`mulSpectrums`
.. seealso:: :ocv:func:`mulSpectrums`
.. index:: gpu::mulAndScaleSpectrums
gpu::mulAndScaleSpectrums
-----------------------------
@ -197,10 +190,9 @@ gpu::mulAndScaleSpectrums
Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
.. seealso::
:ocv:func:`mulSpectrums`
.. seealso:: :ocv:func:`mulSpectrums`
.. index:: gpu::dft
gpu::dft
------------
@ -236,10 +228,9 @@ gpu::dft
*
If the source matrix is real (its type is ``CV_32FC1`` ), forward DFT is performed. The result of the DFT is packed into complex ( ``CV_32FC2`` ) matrix. So, the width of the destination matrix is ``dft_size.width / 2 + 1`` . But if the source is a single column, the height is reduced instead of the width.
.. seealso::
:ocv:func:`dft`
.. seealso:: :ocv:func:`dft`
.. index:: gpu::convolve
gpu::convolve
-----------------
@ -259,7 +250,7 @@ gpu::convolve
:param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
.. index:: gpu::ConvolveBuf
gpu::ConvolveBuf
----------------
@ -280,7 +271,7 @@ Class providing a memory buffer for the :ocv:func:`gpu::convolve` function.
};
.. index:: gpu::ConvolveBuf::ConvolveBuf
gpu::ConvolveBuf::ConvolveBuf
---------------------------------
@ -294,7 +285,7 @@ gpu::ConvolveBuf::ConvolveBuf
Constructs a buffer for the
:ocv:func:`convolve` function with respective arguments.
.. index:: gpu::matchTemplate
gpu::matchTemplate
----------------------
@ -324,10 +315,8 @@ gpu::matchTemplate
* ``CV_TM_SQDIFF``
* ``CV_TM_CCORR``
.. seealso::
:ocv:func:`matchTemplate`
.. seealso:: :ocv:func:`matchTemplate`
.. index:: gpu::remap
gpu::remap
--------------
@ -351,10 +340,8 @@ The function transforms the source image using the specified map:
Values of pixels with non-integer coordinates are computed using the bilinear interpolation.
.. seealso::
:ocv:func:`remap`
.. seealso:: :ocv:func:`remap`
.. index:: gpu::cvtColor
gpu::cvtColor
-----------------
@ -376,10 +363,9 @@ gpu::cvtColor
3-channel color spaces (like ``HSV``, ``XYZ``, and so on) can be stored in a 4-channel image for better perfomance.
.. seealso::
:ocv:func:`cvtColor`
.. seealso:: :ocv:func:`cvtColor`
.. index:: gpu::threshold
gpu::threshold
------------------
@ -401,10 +387,9 @@ gpu::threshold
:param stream: Stream for the asynchronous version.
.. seealso::
:ocv:func:`threshold`
.. seealso:: :ocv:func:`threshold`
.. index:: gpu::resize
gpu::resize
---------------
@ -439,7 +424,7 @@ gpu::resize
.. seealso:: :ocv:func:`resize`
.. index:: gpu::warpAffine
gpu::warpAffine
-------------------
@ -457,10 +442,9 @@ gpu::warpAffine
:param flags: Combination of interpolation methods (see :ocv:func:`resize`) and the optional flag ``WARP_INVERSE_MAP`` specifying that ``M`` is an inverse transformation (``dst=>src``). Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` interpolation methods are supported.
.. seealso::
:ocv:func:`warpAffine`
.. seealso:: :ocv:func:`warpAffine`
.. index:: gpu::warpPerspective
gpu::warpPerspective
------------------------
@ -478,10 +462,9 @@ gpu::warpPerspective
:param flags: Combination of interpolation methods (see :ocv:func:`resize` ) and the optional flag ``WARP_INVERSE_MAP`` specifying that ``M`` is the inverse transformation (``dst => src``). Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` interpolation methods are supported.
.. seealso::
:ocv:func:`warpPerspective`
.. seealso:: :ocv:func:`warpPerspective`
.. index:: gpu::rotate
gpu::rotate
---------------
@ -503,10 +486,9 @@ gpu::rotate
:param interpolation: Interpolation method. Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` are supported.
.. seealso::
:ocv:func:`gpu::warpAffine`
.. seealso:: :ocv:func:`gpu::warpAffine`
.. index:: gpu::copyMakeBorder
gpu::copyMakeBorder
-----------------------
@ -518,14 +500,18 @@ gpu::copyMakeBorder
:param dst: Destination image with the same type as ``src``. The size is ``Size(src.cols+left+right, src.rows+top+bottom)`` .
:param top, bottom, left, right: Number of pixels in each direction from the source image rectangle to extrapolate. For example: ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param top:
:param bottom:
:param left:
:param right: Number of pixels in each direction from the source image rectangle to extrapolate. For example: ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param value: Border value.
.. seealso::
:ocv:func:`copyMakeBorder`
.. seealso:: :ocv:func:`copyMakeBorder`
.. index:: gpu::rectStdDev
gpu::rectStdDev
-------------------
@ -541,7 +527,7 @@ gpu::rectStdDev
:param rect: Rectangular window.
.. index:: gpu::evenLevels
gpu::evenLevels
-------------------
@ -557,13 +543,11 @@ gpu::evenLevels
:param upperLevel: Upper boundary value of the greatest level.
.. index:: gpu::histEven
gpu::histEven
-----------------
.. ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel)
.. ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4])
.. ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat* hist, int* histSize, int* lowerLevel, int* upperLevel)
Calculates a histogram with evenly distributed bins.
@ -577,13 +561,11 @@ gpu::histEven
:param upperLevel: Upper boundary of highest-level bin.
.. index:: gpu::histRange
gpu::histRange
------------------
.. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels)
.. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4])
.. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat* hist, const GpuMat* levels)
Calculates a histogram with bins determined by the ``levels`` array.

@ -77,10 +77,11 @@ After that it finds eigenvectors and eigenvalues of
The output of the function can be used for robust edge or corner detection.
See Also:
:ocv:func:`cornerMinEigenVal`,
:ocv:func:`cornerHarris`,
:ocv:func:`preCornerDetect`
.. seealso::
:ocv:func:`cornerMinEigenVal`,
:ocv:func:`cornerHarris`,
:ocv:func:`preCornerDetect`
@ -221,7 +222,8 @@ Determines strong corners on an image.
.. ocv:pyfunction:: cv2.goodFeaturesToTrack(image, maxCorners, qualityLevel, minDistance[, corners[, mask[, blockSize[, useHarrisDetector[, k]]]]]) -> corners
.. ocv:cfunction:: void cvGoodFeaturesToTrack( const CvArr* image CvArr* eigImage, CvArr* tempImage CvPoint2D32f* corners int* cornerCount double qualityLevel double minDistance const CvArr* mask=NULL int blockSize=3 int useHarris=0 double k=0.04 )
.. ocv:cfunction:: void cvGoodFeaturesToTrack( const CvArr* image, CvArr* eigImage, CvArr* tempImage CvPoint2D32f* corners, int* cornerCount, double qualityLevel, double minDistance, const CvArr* mask=NULL, int blockSize=3, int useHarris=0, double k=0.04 )
.. ocv:pyoldfunction:: cv.GoodFeaturesToTrack(image, eigImage, tempImage, cornerCount, qualityLevel, minDistance, mask=None, blockSize=3, useHarris=0, k=0.04)-> corners
:param image: Input 8-bit or floating-point 32-bit, single-channel image.
@ -266,12 +268,14 @@ The function can be used to initialize a point-based tracker of an object.
**Note**: If the function is called with different values ``A`` and ``B`` of the parameter ``qualityLevel`` , and ``A`` > {B}, the vector of returned corners with ``qualityLevel=A`` will be the prefix of the output vector with ``qualityLevel=B`` .
See Also: :ocv:func:`cornerMinEigenVal`,
:ocv:func:`cornerHarris`,
:ocv:func:`calcOpticalFlowPyrLK`,
:ocv:func:`estimateRigidMotion`,
:ocv:func:`PlanarObjectDetector`,
:ocv:func:`OneWayDescriptor`
.. seealso::
:ocv:func:`cornerMinEigenVal`,
:ocv:func:`cornerHarris`,
:ocv:func:`calcOpticalFlowPyrLK`,
:ocv:func:`estimateRigidMotion`,
:ocv:func:`PlanarObjectDetector`,
:ocv:func:`OneWayDescriptor`
@ -336,10 +340,10 @@ The function finds circles in a grayscale image using a modification of the Houg
**Note**: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( ``minRadius`` and ``maxRadius`` ) if you know it. Or, you may ignore the returned radius, use only the center, and find the correct radius using an additional procedure.
See Also:
:ocv:func:`fitEllipse`,
:ocv:func:`minEnclosingCircle`
.. seealso::
:ocv:func:`fitEllipse`,
:ocv:func:`minEnclosingCircle`
HoughLines

@ -54,6 +54,7 @@ where
:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
.. seealso::
:ocv:func:`BaseRowFilter`,
:ocv:func:`BaseFilter`,
:ocv:func:`FilterEngine`,
@ -62,7 +63,6 @@ where
:ocv:func:`getMorphologyColumnFilter`
BaseFilter
----------
.. ocv:class:: BaseFilter
@ -104,11 +104,12 @@ where
:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
.. seealso::
:ocv:func:`BaseColumnFilter`,
:ocv:func:`BaseRowFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getLinearFilter`,
:ocv:func:`getMorphologyFilter`
:ocv:func:`BaseColumnFilter`,
:ocv:func:`BaseRowFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getLinearFilter`,
:ocv:func:`getMorphologyFilter`
@ -145,12 +146,13 @@ where
:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
.. seealso::
:ocv:func:`BaseColumnFilter`,
:ocv:func:`Filter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getLinearRowFilter`,
:ocv:func:`getMorphologyRowFilter`,
:ocv:func:`getRowSumFilter`
:ocv:func:`BaseColumnFilter`,
:ocv:func:`Filter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getLinearRowFilter`,
:ocv:func:`getMorphologyRowFilter`,
:ocv:func:`getRowSumFilter`
@ -356,6 +358,7 @@ Explore the data types. As it was mentioned in the
In case of non-separable filtering, ``bufType`` must be the same as ``srcType`` . The source data is copied to the temporary buffer, if needed, and then just passed to ``FilterEngine::filter2D`` . That is, the input type for ``filter2D`` is ``srcType`` (= ``bufType`` ) and the output type is ``dstType`` .
.. seealso::
:ocv:func:`BaseColumnFilter`,
:ocv:func:`BaseFilter`,
:ocv:func:`BaseRowFilter`,
@ -426,13 +429,13 @@ The function smoothes an image using the kernel:
The call ``blur(src, dst, ksize, anchor, borderType)`` is equivalent to ``boxFilter(src, dst, src.type(), anchor, true, borderType)`` .
.. seealso::
:ocv:func:`boxFilter`,
:ocv:func:`bilateralFilter`,
:ocv:func:`GaussianBlur`,
:ocv:func:`medianBlur`
borderInterpolate
---------------------
Computes the source location of an extrapolated pixel.
@ -458,8 +461,9 @@ Normally, the function is not called directly. It is used inside
:ocv:func:`copyMakeBorder` to compute tables for quick extrapolation.
.. seealso::
:ocv:func:`FilterEngine`,
:ocv:func:`copyMakeBorder`
:ocv:func:`FilterEngine`,
:ocv:func:`copyMakeBorder`
@ -500,11 +504,12 @@ and so on). If you need to compute pixel sums over variable-size windows, use
:ocv:func:`integral` .
.. seealso::
:ocv:func:`boxFilter`,
:ocv:func:`bilateralFilter`,
:ocv:func:`GaussianBlur`,
:ocv:func:`medianBlur`,
:ocv:func:`integral`
:ocv:func:`boxFilter`,
:ocv:func:`bilateralFilter`,
:ocv:func:`GaussianBlur`,
:ocv:func:`medianBlur`,
:ocv:func:`integral`
@ -540,7 +545,13 @@ Forms a border around an image.
:param dst: Destination image of the same type as ``src`` and the size ``Size(src.cols+left+right, src.rows+top+bottom)`` .
:param top, bottom, left, right: Parameter specifying how many pixels in each direction from the source image rectangle to extrapolate. For example, ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param top:
:param bottom:
:param left:
:param right: Parameter specifying how many pixels in each direction from the source image rectangle to extrapolate. For example, ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param borderType: Border type. See :ocv:func:`borderInterpolate` for details.
@ -567,7 +578,8 @@ The function supports the mode when ``src`` is already in the middle of ``dst``
.. seealso::
:ocv:func:`borderInterpolate`
:ocv:func:`borderInterpolate`
createBoxFilter
@ -606,9 +618,10 @@ The function itself is used by
:ocv:func:`boxFilter` .
.. seealso::
:ocv:func:`FilterEngine`,
:ocv:func:`blur`,
:ocv:func:`boxFilter`
:ocv:func:`FilterEngine`,
:ocv:func:`blur`,
:ocv:func:`boxFilter`
@ -637,10 +650,11 @@ The function :ocv:func:`createDerivFilter` is a small convenience function that
:ocv:func:`Scharr` .
.. seealso::
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getDerivKernels`,
:ocv:func:`Scharr`,
:ocv:func:`Sobel`
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getDerivKernels`,
:ocv:func:`Scharr`,
:ocv:func:`Sobel`
@ -666,9 +680,10 @@ The function :ocv:func:`createGaussianFilter` computes Gaussian kernel coefficie
:ocv:func:`createSeparableFilter` directly.
.. seealso::
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getGaussianKernel`,
:ocv:func:`GaussianBlur`
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getGaussianKernel`,
:ocv:func:`GaussianBlur`
@ -692,7 +707,9 @@ Creates a non-separable linear filter engine.
:param bits: Number of the fractional bits. the parameter is used when the kernel is an integer matrix representing fixed-point filter coefficients.
:param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
:param borderValue: Border vaule used in case of a constant border.
@ -700,9 +717,10 @@ The function returns a pointer to a 2D linear filter for the specified kernel, t
:ocv:func:`FilterEngine` constructor.
.. seealso::
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`filter2D`
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`filter2D`
createMorphologyFilter
@ -729,7 +747,9 @@ Creates an engine for non-separable morphological operations.
:param anchor: Anchor position within the structuring element. Negative values mean that the anchor is at the kernel center.
:param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
:param borderValue: Border value in case of a constant border. The default value, \ ``morphologyDefaultBorderValue`` , has a special meaning. It is transformed :math:`+\inf` for the erosion and to :math:`-\inf` for the dilation, which means that the minimum (maximum) is effectively computed only over the pixels that are inside the image.
@ -742,10 +762,11 @@ Note that
:ocv:func:`createMorphologyFilter` analyzes the structuring element shape and builds a separable morphological filter engine when the structuring element is square.
.. seealso::
:ocv:func:`erode`,
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`FilterEngine`
:ocv:func:`erode`,
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`FilterEngine`
createSeparableLinearFilter
@ -774,7 +795,9 @@ Creates an engine for a separable linear filter.
:param bits: Number of the fractional bits. The parameter is used when the kernel is an integer matrix representing fixed-point filter coefficients.
:param rowBorderType, columnBorderType: Pixel extrapolation methods in the horizontal and vertical directions. See :ocv:func:`borderInterpolate` for details.
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
:param borderValue: Border value used in case of a constant border.
@ -787,10 +810,11 @@ The functions construct primitive separable linear filtering operations or a fil
:ocv:func:`FilterEngine` constructor.
.. seealso::
:ocv:func:`sepFilter2D`,
:ocv:func:`createLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getKernelType`
:ocv:func:`sepFilter2D`,
:ocv:func:`createLinearFilter`,
:ocv:func:`FilterEngine`,
:ocv:func:`getKernelType`
dilate
@ -827,9 +851,10 @@ The function dilates the source image using the specified structuring element th
The function supports the in-place mode. Dilation can be applied several ( ``iterations`` ) times. In case of multi-channel images, each channel is processed independently.
.. seealso::
:ocv:func:`erode`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
:ocv:func:`erode`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
erode
@ -866,9 +891,10 @@ The function erodes the source image using the specified structuring element tha
The function supports the in-place mode. Erosion can be applied several ( ``iterations`` ) times. In case of multi-channel images, each channel is processed independently.
.. seealso::
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
:ocv:func:`dilate`,
:ocv:func:`morphologyEx`,
:ocv:func:`createMorphologyFilter`
@ -911,10 +937,11 @@ That is, the kernel is not mirrored around the anchor point. If you need a real
The function uses the DFT-based algorithm in case of sufficiently large kernels (~``11 x 11`` or larger) and the direct algorithm (that uses the engine retrieved by :ocv:func:`createLinearFilter` ) for small kernels.
.. seealso::
:ocv:func:`sepFilter2D`,
:ocv:func:`createLinearFilter`,
:ocv:func:`dft`,
:ocv:func:`matchTemplate`
:ocv:func:`sepFilter2D`,
:ocv:func:`createLinearFilter`,
:ocv:func:`dft`,
:ocv:func:`matchTemplate`
@ -932,13 +959,16 @@ Smoothes an image using a Gaussian filter.
:param ksize: Gaussian kernel size. ``ksize.width`` and ``ksize.height`` can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from ``sigma*`` .
:param sigmaX, sigmaY: Gaussian kernel standard deviations in X and Y direction. If ``sigmaY`` is zero, it is set to be equal to ``sigmaX`` . If they are both zeros, they are computed from ``ksize.width`` and ``ksize.height`` , respectively. See :ocv:func:`getGaussianKernel` for details. To fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ``ksize`` , ``sigmaX`` , and ``sigmaY`` .
:param sigmaX: Gaussian kernel standard deviation in X direction.
:param sigmaY: Gaussian kernel standard deviation in Y direction. If ``sigmaY`` is zero, it is set to be equal to ``sigmaX`` . If both sigmas are zeros, they are computed from ``ksize.width`` and ``ksize.height`` , respectively. See :ocv:func:`getGaussianKernel` for details. To fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ``ksize`` , ``sigmaX`` , and ``sigmaY`` .
:param borderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` for details.
The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.
.. seealso::
:ocv:func:`sepFilter2D`,
:ocv:func:`filter2D`,
:ocv:func:`blur`,
@ -1009,6 +1039,7 @@ Two of such generated kernels can be passed to
:ocv:func:`GaussianBlur`.
.. seealso::
:ocv:func:`sepFilter2D`,
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`getDerivKernels`,
@ -1111,10 +1142,11 @@ The function smoothes an image using the median filter with the
:math:`\texttt{ksize} \times \texttt{ksize}` aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported.
.. seealso::
:ocv:func:`bilateralFilter`,
:ocv:func:`blur`,
:ocv:func:`boxFilter`,
:ocv:func:`GaussianBlur`
:ocv:func:`bilateralFilter`,
:ocv:func:`blur`,
:ocv:func:`boxFilter`,
:ocv:func:`GaussianBlur`
@ -1188,9 +1220,10 @@ Morphological gradient:
Any of the operations can be done in-place.
.. seealso::
:ocv:func:`dilate`,
:ocv:func:`erode`,
:ocv:func:`createMorphologyFilter`
:ocv:func:`dilate`,
:ocv:func:`erode`,
:ocv:func:`createMorphologyFilter`
@ -1234,8 +1267,9 @@ This is done when ``ksize > 1`` . When ``ksize == 1`` , the Laplacian is compute
\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}
.. seealso::
:ocv:func:`Sobel`,
:ocv:func:`Scharr`
:ocv:func:`Sobel`,
:ocv:func:`Scharr`
@ -1370,6 +1404,7 @@ Applies a separable linear filter to an image.
The function applies a separable linear filter to the image. That is, first, every row of ``src`` is filtered with the 1D kernel ``rowKernel`` . Then, every column of the result is filtered with the 1D kernel ``columnKernel`` . The final result shifted by ``delta`` is stored in ``dst`` .
.. seealso::
:ocv:func:`createSeparableLinearFilter`,
:ocv:func:`filter2D`,
:ocv:func:`Sobel`,
@ -1392,7 +1427,7 @@ Smooths the image in one of several ways.
:param smoothtype: Type of the smoothing:
* **CV_BLUR_NO_SCALE** linear convolution with :math:`\texttt{param1}\times\texttt{param2}` box kernel (all 1's). If you want to smooth different pixels with different-size box kernels, you can use the integral image that is computed using :ref:`Integral`
* **CV_BLUR_NO_SCALE** linear convolution with :math:`\texttt{param1}\times\texttt{param2}` box kernel (all 1's). If you want to smooth different pixels with different-size box kernels, you can use the integral image that is computed using :ocv:func:`integral`
* **CV_BLUR** linear convolution with :math:`\texttt{param1}\times\texttt{param2}` box kernel (all 1's) with subsequent scaling by :math:`1/(\texttt{param1}\cdot\texttt{param2})`
@ -1500,11 +1535,12 @@ The second case corresponds to a kernel of:
\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}
.. seealso::
:ocv:func:`Scharr`,
:ocv:func:`Lapacian`,
:ocv:func:`sepFilter2D`,
:ocv:func:`filter2D`,
:ocv:func:`GaussianBlur`
:ocv:func:`Scharr`,
:ocv:func:`Lapacian`,
:ocv:func:`sepFilter2D`,
:ocv:func:`filter2D`,
:ocv:func:`GaussianBlur`

@ -15,8 +15,8 @@ In case when you specify the forward mapping
:math:`\left<f_x, f_y\right>: \texttt{dst} \rightarrow \texttt{src}` and then use the above formula.
The actual implementations of the geometrical transformations, from the most generic
:ref:`Remap` and to the simplest and the fastest
:ref:`Resize` , need to solve two main problems with the above formula:
:ocv:func:`remap` and to the simplest and the fastest
:ocv:func:`resize` , need to solve two main problems with the above formula:
*
Extrapolation of non-existing pixels. Similarly to the filtering functions described in the previous section, for some
@ -32,7 +32,7 @@ The actual implementations of the geometrical transformations, from the most gen
, where a polynomial function is fit into some neighborhood of the computed pixel
:math:`(f_x(x,y), f_y(x,y))` , and then the value of the polynomial at
:math:`(f_x(x,y), f_y(x,y))` is taken as the interpolated pixel value. In OpenCV, you can choose between several interpolation methods. See
:ref:`Resize` for details.
:ocv:func:`resize` for details.
convertMaps
-----------
@ -67,10 +67,11 @@ The function converts a pair of maps for
*
Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.
See Also:
:ocv:func:`remap`,
:ocv:func:`undisort`,
:ocv:func:`initUndistortRectifyMap`
.. seealso::
:ocv:func:`remap`,
:ocv:func:`undisort`,
:ocv:func:`initUndistortRectifyMap`
@ -78,11 +79,12 @@ getAffineTransform
----------------------
Calculates an affine transform from three pairs of the corresponding points.
.. ocv:function:: Mat getAffineTransform( const Point2f src[], const Point2f dst[] )
.. ocv:function:: Mat getAffineTransform( const Point2f* src, const Point2f* dst )
.. ocv:pyfunction:: cv2.getAffineTransform(src, dst) -> retval
.. ocv:cfunction:: CvMat* cvGetAffineTransform( const CvPoint2D32f* src, const CvPoint2D32f* dst, CvMat* mapMatrix )
.. ocv:pyoldfunction:: cv.GetAffineTransform(src, dst, mapMatrix)-> None
:param src: Coordinates of triangle vertices in the source image.
@ -103,9 +105,10 @@ where
src(i)=(x_i, y_i),
i=0,1,2
See Also:
:ocv:func:`warpAffine`,
:ocv:func:`transform`
.. seealso::
:ocv:func:`warpAffine`,
:ocv:func:`transform`
@ -113,11 +116,12 @@ getPerspectiveTransform
---------------------------
Calculates a perspective transform from four pairs of the corresponding points.
.. ocv:function:: Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
.. ocv:function:: Mat getPerspectiveTransform( const Point2f* src, const Point2f* dst )
.. ocv:pyfunction:: cv2.getPerspectiveTransform(src, dst) -> retval
.. ocv:cfunction:: CvMat* cvGetPerspectiveTransform( const CvPoint2D32f* src, const CvPoint2D32f* dst, CvMat* mapMatrix )
.. ocv:pyoldfunction:: cv.GetPerspectiveTransform(src, dst, mapMatrix)-> None
:param src: Coordinates of quadrangle vertices in the source image.
@ -138,10 +142,11 @@ where
src(i)=(x_i, y_i),
i=0,1,2,3
See Also:
:ocv:func:`findHomography`,
:ocv:func:`warpPerspective`,
:ocv:func:`perspectiveTransform`
.. seealso::
:ocv:func:`findHomography`,
:ocv:func:`warpPerspective`,
:ocv:func:`perspectiveTransform`
getRectSubPix
@ -179,9 +184,10 @@ outside. In this case, the replication border mode (see
:ocv:func:`borderInterpolate` ) is used to extrapolate
the pixel values outside of the image.
See Also:
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`
.. seealso::
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`
getRotationMatrix2D
@ -218,12 +224,11 @@ where
The transformation maps the rotation center to itself. If this is not the target, adjust the shift.
See Also:
:ocv:func:`getAffineTransform`,
:ocv:func:`warpAffine`,
:ocv:func:`transform`
.. seealso::
:ocv:func:`getAffineTransform`,
:ocv:func:`warpAffine`,
:ocv:func:`transform`
@ -269,21 +274,22 @@ Remaps an image to log-polar space.
:param flags: A combination of interpolation methods and the following optional flags:
* **CV_WARP_FILL_OUTLIERS** fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero
* **CV_WARP_FILL_OUTLIERS** fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero
* **CV_WARP_INVERSE_MAP** See below
* **CV_WARP_INVERSE_MAP** See below
The function ``cvLogPolar`` transforms the source image using the following transformation:
* Forward transformation (``CV_WARP_INVERSE_MAP``is not set):
*
Forward transformation (``CV_WARP_INVERSE_MAP``is not set):
.. math::
dst( \phi , \rho ) = src(x,y)
* Inverse transformation (``CV_WARP_INVERSE_MAP`` is set):
*
Inverse transformation (``CV_WARP_INVERSE_MAP`` is set):
.. math::
@ -409,12 +415,11 @@ If you want to decimate the image by factor of 2 in each direction, you can call
To shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK).
See Also:
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`,
:ocv:func:`remap`
.. seealso::
:ocv:func:`warpAffine`,
:ocv:func:`warpPerspective`,
:ocv:func:`remap`
warpAffine
@ -455,12 +460,13 @@ when the flag ``WARP_INVERSE_MAP`` is set. Otherwise, the transformation is firs
:ocv:func:`invertAffineTransform` and then put in the formula above instead of ``M`` .
The function cannot operate in-place.
See Also:
:ocv:func:`warpPerspective`,
:ocv:func:`resize`,
:ocv:func:`remap`,
:ocv:func:`getRectSubPix`,
:ocv:func:`transform`
.. seealso::
:ocv:func:`warpPerspective`,
:ocv:func:`resize`,
:ocv:func:`remap`,
:ocv:func:`getRectSubPix`,
:ocv:func:`transform`
.. note:: ``cvGetQuadrangleSubPix`` is similar to ``cvWarpAffine``, but the outliers are extrapolated using replication border mode.
@ -501,12 +507,13 @@ when the flag ``WARP_INVERSE_MAP`` is set. Otherwise, the transformation is firs
:ocv:func:`invert` and then put in the formula above instead of ``M`` .
The function cannot operate in-place.
See Also:
:ocv:func:`warpAffine`,
:ocv:func:`resize`,
:ocv:func:`remap`,
:ocv:func:`getRectSubPix`,
:ocv:func:`perspectiveTransform`
.. seealso::
:ocv:func:`warpAffine`,
:ocv:func:`resize`,
:ocv:func:`remap`,
:ocv:func:`getRectSubPix`,
:ocv:func:`perspectiveTransform`
@ -529,27 +536,27 @@ Computes the undistortion and rectification transformation map.
:param distCoeffs: Input vector of distortion coefficients :math:`(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])` of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
:param R: Optional rectification transformation in the object space (3x3 matrix). ``R1`` or ``R2`` , computed by :ref:`StereoRectify` can be passed here. If the matrix is empty, the identity transformation is assumed. In ``cvInitUndistortMap`` R assumed to be an identity matrix.
:param R: Optional rectification transformation in the object space (3x3 matrix). ``R1`` or ``R2`` , computed by :ocv:func:`stereoRectify` can be passed here. If the matrix is empty, the identity transformation is assumed. In ``cvInitUndistortMap`` R assumed to be an identity matrix.
:param newCameraMatrix: New camera matrix :math:`A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}` .
:param size: Undistorted image size.
:param m1type: Type of the first output map that can be ``CV_32FC1`` or ``CV_16SC2`` . See :ref:`convertMaps` for details.
:param m1type: Type of the first output map that can be ``CV_32FC1`` or ``CV_16SC2`` . See :ocv:func:`convertMaps` for details.
:param map1: The first output map.
:param map2: The second output map.
The function computes the joint undistortion and rectification transformation and represents the result in the form of maps for
:ref:`Remap` . The undistorted image looks like original, as if it is captured with a camera using the camera matrix ``=newCameraMatrix`` and zero distortion. In case of a monocular camera, ``newCameraMatrix`` is usually equal to ``cameraMatrix`` , or it can be computed by
:ref:`GetOptimalNewCameraMatrix` for a better control over scaling. In case of a stereo camera, ``newCameraMatrix`` is normally set to ``P1`` or ``P2`` computed by
:ref:`StereoRectify` .
:ocv:func:`remap` . The undistorted image looks like original, as if it is captured with a camera using the camera matrix ``=newCameraMatrix`` and zero distortion. In case of a monocular camera, ``newCameraMatrix`` is usually equal to ``cameraMatrix`` , or it can be computed by
:ocv:func:`getOptimalNewCameraMatrix` for a better control over scaling. In case of a stereo camera, ``newCameraMatrix`` is normally set to ``P1`` or ``P2`` computed by
:ocv:func:`stereoRectify` .
Also, this new camera is oriented differently in the coordinate space, according to ``R`` . That, for example, helps to align two heads of a stereo camera so that the epipolar lines on both images become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).
The function actually builds the maps for the inverse mapping algorithm that is used by
:ref:`Remap` . That is, for each pixel
:ocv:func:`remap` . That is, for each pixel
:math:`(u, v)` in the destination (corrected and rectified) image, the function computes the corresponding coordinates in the source image (that is, in the original image from camera). The following process is applied:
.. math::
@ -560,9 +567,9 @@ where
:math:`(k_1, k_2, p_1, p_2[, k_3])` are the distortion coefficients.
In case of a stereo camera, this function is called twice: once for each camera head, after
:ref:`StereoRectify` , which in its turn is called after
:ref:`StereoCalibrate` . But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from the fundamental matrix using
:ref:`StereoRectifyUncalibrated` . For each camera, the function computes homography ``H`` as the rectification transformation in a pixel domain, not a rotation matrix ``R`` in 3D space. ``R`` can be computed from ``H`` as
:ocv:func:`stereoRectify` , which in its turn is called after
:ocv:func:`stereoCalibrate` . But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from the fundamental matrix using
:ocv:func:`stereoRectifyUncalibrated` . For each camera, the function computes homography ``H`` as the rectification transformation in a pixel domain, not a rotation matrix ``R`` in 3D space. ``R`` can be computed from ``H`` as
.. math::
@ -587,7 +594,7 @@ Returns the default new camera matrix.
:param centerPrincipalPoint: Location of the principal point in the new camera matrix. The parameter indicates whether this location should be at the image center or not.
The function returns the camera matrix that is either an exact copy of the input ``cameraMatrix`` (when ``centerPrinicipalPoint=false`` ), or the modified one (when ``centerPrincipalPoint`` =true).
The function returns the camera matrix that is either an exact copy of the input ``cameraMatrix`` (when ``centerPrinicipalPoint=false`` ), or the modified one (when ``centerPrincipalPoint=true``).
In the latter case, the new camera matrix will be:
@ -602,8 +609,8 @@ where
:math:`(1,1)` elements of ``cameraMatrix`` , respectively.
By default, the undistortion functions in OpenCV (see
:ref:`initUndistortRectifyMap`,
:ref:`undistort`) do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.
:ocv:func:`initUndistortRectifyMap`,
:ocv:func:`undistort`) do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.
@ -639,10 +646,10 @@ The function is simply a combination of
Those pixels in the destination image, for which there is no correspondent pixels in the source image, are filled with zeros (black color).
A particular subset of the source image that will be visible in the corrected image can be regulated by ``newCameraMatrix`` . You can use
:ref:`GetOptimalNewCameraMatrix` to compute the appropriate ``newCameraMatrix`` depending on your requirements.
:ocv:func:`getOptimalNewCameraMatrix` to compute the appropriate ``newCameraMatrix`` depending on your requirements.
The camera matrix and the distortion parameters can be determined using
:ref:`calibrateCamera` . If the resolution of images is different from the resolution used at the calibration stage,
:ocv:func:`calibrateCamera` . If the resolution of images is different from the resolution used at the calibration stage,
:math:`f_x, f_y, c_x` and
:math:`c_y` need to be scaled accordingly, while the distortion coefficients remain the same.
@ -666,14 +673,14 @@ Computes the ideal point coordinates from the observed point coordinates.
:param distCoeffs: Input vector of distortion coefficients :math:`(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])` of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
:param R: Rectification transformation in the object space (3x3 matrix). ``R1`` or ``R2`` computed by :ref:`StereoRectify` can be passed here. If the matrix is empty, the identity transformation is used.
:param R: Rectification transformation in the object space (3x3 matrix). ``R1`` or ``R2`` computed by :ocv:func:`stereoRectify` can be passed here. If the matrix is empty, the identity transformation is used.
:param P: New camera matrix (3x3) or new projection matrix (3x4). ``P1`` or ``P2`` computed by :ref:`StereoRectify` can be passed here. If the matrix is empty, the identity new camera matrix is used.
:param P: New camera matrix (3x3) or new projection matrix (3x4). ``P1`` or ``P2`` computed by :ocv:func:`stereoRectify` can be passed here. If the matrix is empty, the identity new camera matrix is used.
The function is similar to
:ref:`undistort` and
:ref:`initUndistortRectifyMap` but it operates on a sparse set of points instead of a raster image. Also the function performs a reverse transformation to
:ref:`projectPoints` . In case of a 3D object, it does not reconstruct its 3D coordinates, but for a planar object, it does, up to a translation vector, if the proper ``R`` is specified. ::
:ocv:func:`undistort` and
:ocv:func:`initUndistortRectifyMap` but it operates on a sparse set of points instead of a raster image. Also the function performs a reverse transformation to
:ocv:func:`projectPoints` . In case of a 3D object, it does not reconstruct its 3D coordinates, but for a planar object, it does, up to a translation vector, if the proper ``R`` is specified. ::
// (u,v) is the input point, (u', v') is the output point
// camera_matrix=[fx 0 cx; 0 fy cy; 0 0 1]

@ -145,9 +145,7 @@ The functions ``calcBackProject`` calculate the back project of the histogram. T
This is an approximate algorithm of the
:ocv:func:`CAMShift` color object tracker.
See Also:
:ocv:func:`calcHist`
.. seealso:: :ocv:func:`calcHist`
.. _compareHist:
compareHist
@ -312,7 +310,7 @@ Locates a template within an image by using a histogram comparison.
:param hist: Histogram
:param method: Comparison method, passed to :ref:`CompareHist` (see description of that function)
:param method: Comparison method, passed to :ocv:cfunc:`CompareHist` (see description of that function)
:param factor: Normalization factor for histograms, will affect the normalization scale of the destination image, pass 1 if unsure
@ -420,7 +418,11 @@ Returns a pointer to the histogram bin.
:param hist: Histogram
:param idx0, idx1, idx2, idx3: Indices of the bin
:param idx0: 0-th index
:param idx1: 1-st index
:param idx2: 2-nd index
:param idx: Array of indices
@ -475,9 +477,9 @@ Makes a histogram out of an array.
:param data: Array that will be used to store histogram bins
:param ranges: Histogram bin ranges, see :ref:`CreateHist`
:param ranges: Histogram bin ranges, see :ocv:cfunc:`CreateHist`
:param uniform: Uniformity flag, see :ref:`CreateHist`
:param uniform: Uniformity flag, see :ocv:cfunc:`CreateHist`
The function initializes the histogram, whose header and bins are allocated by the user. :ocv:cfunc:`ReleaseHist` does not need to be called afterwards. Only dense histograms can be initialized this way. The function returns ``hist``.
@ -511,7 +513,11 @@ Queries the value of the histogram bin.
:param hist: Histogram
:param idx0, idx1, idx2, idx3: Indices of the bin
:param idx0: 0-th index
:param idx1: 1-st index
:param idx2: 2-nd index
:param idx: Array of indices
@ -536,9 +542,9 @@ Sets the bounds of the histogram bins.
:param hist: Histogram
:param ranges: Array of bin ranges arrays, see :ref:`CreateHist`
:param ranges: Array of bin ranges arrays, see :ocv:cfunc:`CreateHist`
:param uniform: Uniformity flag, see :ref:`CreateHist`
:param uniform: Uniformity flag, see :ocv:cfunc:`CreateHist`
The function is a stand-alone function for setting bin ranges in the histogram. For a more detailed description of the parameters ``ranges`` and ``uniform`` see the :ocv:cfunc:`CalcHist` function, that can initialize the ranges as well. Ranges for the histogram bins must be set before the histogram is calculated or the backproject of the histogram is calculated.
@ -581,5 +587,4 @@ between the calculated minimum and maximum distances are incremented
.. [RubnerSept98] Y. Rubner. C. Tomasi, L.J. Guibas. The Earth Mover’s Distance as a Metric for Image Retrieval. Technical Report STAN-CS-TN-98-86, Department of Computer Science, Stanford University, September 1998.
.. [Iivarinen97] Jukka Iivarinen, Markus Peura, Jaakko Srel, and Ari Visa. Comparison of Combined Shape Descriptors for Irregular Objects, 8th British Machine Vision Conference, BMVC'97.
http://www.cis.hut.fi/research/IA/paper/publications/bmvc97/bmvc97.html
.. [Iivarinen97] Jukka Iivarinen, Markus Peura, Jaakko Srel, and Ari Visa. Comparison of Combined Shape Descriptors for Irregular Objects, 8th British Machine Vision Conference, BMVC'97. http://www.cis.hut.fi/research/IA/paper/publications/bmvc97/bmvc97.html

@ -60,10 +60,11 @@ where
The function can process the image in-place.
See Also:
:ocv:func:`threshold`,
:ocv:func:`blur`,
:ocv:func:`GaussianBlur`
.. seealso::
:ocv:func:`threshold`,
:ocv:func:`blur`,
:ocv:func:`GaussianBlur`
@ -579,10 +580,7 @@ where
Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on. Various modes of the function are demonstrated in the ``floodfill.cpp`` sample.
See Also:
:ocv:func:`findContours`
.. seealso:: :ocv:func:`findContours`
@ -743,13 +741,13 @@ Currently, Otsu's method is implemented only for 8-bit images.
.. image:: pics/threshold.png
See Also:
:ocv:func:`adaptiveThreshold`,
:ocv:func:`findContours`,
:ocv:func:`compare`,
:ocv:func:`min`,
:ocv:func:`max`
.. seealso::
:ocv:func:`adaptiveThreshold`,
:ocv:func:`findContours`,
:ocv:func:`compare`,
:ocv:func:`min`,
:ocv:func:`max`
watershed
@ -787,9 +785,7 @@ example, when such tangent components exist in the initial
marker image. Visual demonstration and usage example of the function
can be found in the OpenCV samples directory (see the ``watershed.cpp`` demo).
See Also:
:ocv:func:`findContours`
.. seealso:: :ocv:func:`findContours`
grabCut
@ -814,7 +810,9 @@ Runs the GrabCut algorithm.
:param rect: ROI containing a segmented object. The pixels outside of the ROI are marked as "obvious background". The parameter is only used when ``mode==GC_INIT_WITH_RECT`` .
:param bgdModel, fgdModel: Temporary arrays used for segmentation. Do not modify them while you are processing the same image.
:param bgdModel: Temporary array for the background model. Do not modify it while you are processing the same image.
:param fgdModel: Temporary arrays for the foreground model. Do not modify it while you are processing the same image.
:param iterCount: Number of iterations the algorithm should make before returning the result. Note that the result can be refined with further calls with ``mode==GC_INIT_WITH_MASK`` or ``mode==GC_EVAL`` .

@ -137,7 +137,7 @@ ClearSubdivVoronoi2D
The function removes all of the virtual points. It
is called internally in
:ref:`CalcSubdivVoronoi2D`
:ocv:cfunc:`CalcSubdivVoronoi2D`
if the subdivision
was modified after previous call to the function.
@ -154,7 +154,7 @@ Creates an empty Delaunay triangulation.
The function creates an empty Delaunay
subdivision, where 2d points can be added using the function
:ref:`SubdivDelaunay2DInsert`
:ocv:cfunc:`SubdivDelaunay2DInsert`
. All of the points to be added must be within
the specified rectangle, otherwise a runtime error will be raised.
@ -177,7 +177,7 @@ The function is another function that
locates the input point within the subdivision. It finds the subdivision vertex that
is the closest to the input point. It is not necessarily one of vertices
of the facet containing the input point, though the facet (located using
:ref:`Subdiv2DLocate`
:ocv:cfunc:`Subdiv2DLocate`
) is used as a starting
point. The function returns a pointer to the found subdivision vertex.
@ -194,8 +194,7 @@ The function returns the edge destination. The
returned pointer may be NULL if the edge is from dual subdivision and
the virtual point coordinates are not calculated yet. The virtual points
can be calculated using the function
:ref:`CalcSubdivVoronoi2D`
.
:ocv:cfunc:`CalcSubdivVoronoi2D`.
Subdiv2DGetEdge
---------------
@ -319,7 +318,7 @@ Inserts a single point into a Delaunay triangulation.
.. ocv:cfunction:: CvSubdiv2DPoint* cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt)
.. ocv:pyoldfunction:: cv.SubdivDelaunay2DInsert(subdiv, pt)-> point
:param subdiv: Delaunay subdivision created by the function :ref:`CreateSubdivDelaunay2D`
:param subdiv: Delaunay subdivision created by the function :ocv:cfunc:`CreateSubdivDelaunay2D`
:param pt: Inserted point

@ -71,9 +71,10 @@ The moments of a contour are defined in the same way but computed using Green's
http://en.wikipedia.org/wiki/Green_theorem
). So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour.
See Also:
:ocv:func:`contourArea`,
:ocv:func:`arcLength`
.. seealso::
:ocv:func:`contourArea`,
:ocv:func:`arcLength`
@ -81,7 +82,7 @@ HuMoments
-------------
Calculates the seven Hu invariants.
.. ocv:function:: void HuMoments( const Moments& moments, double h[7] )
.. ocv:function:: void HuMoments( const Moments& moments, double* hu )
.. ocv:pyfunction:: cv2.HuMoments(m) -> hu
@ -90,14 +91,14 @@ Calculates the seven Hu invariants.
.. ocv:pyoldfunction:: cv.GetHuMoments(moments) -> hu
:param moments: Input moments computed with :ocv:func:`moments` .
:param h: Output Hu invariants.
:param hu: Output Hu invariants.
The function calculates the seven Hu invariants (introduced in [Hu62]_; see also
http://en.wikipedia.org/wiki/Image_moment) defined as:
.. math::
\begin{array}{l} h[0]= \eta _{20}+ \eta _{02} \\ h[1]=( \eta _{20}- \eta _{02})^{2}+4 \eta _{11}^{2} \\ h[2]=( \eta _{30}-3 \eta _{12})^{2}+ (3 \eta _{21}- \eta _{03})^{2} \\ h[3]=( \eta _{30}+ \eta _{12})^{2}+ ( \eta _{21}+ \eta _{03})^{2} \\ h[4]=( \eta _{30}-3 \eta _{12})( \eta _{30}+ \eta _{12})[( \eta _{30}+ \eta _{12})^{2}-3( \eta _{21}+ \eta _{03})^{2}]+(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ h[5]=( \eta _{20}- \eta _{02})[( \eta _{30}+ \eta _{12})^{2}- ( \eta _{21}+ \eta _{03})^{2}]+4 \eta _{11}( \eta _{30}+ \eta _{12})( \eta _{21}+ \eta _{03}) \\ h[6]=(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}]-( \eta _{30}-3 \eta _{12})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ \end{array}
\begin{array}{l} hu[0]= \eta _{20}+ \eta _{02} \\ hu[1]=( \eta _{20}- \eta _{02})^{2}+4 \eta _{11}^{2} \\ hu[2]=( \eta _{30}-3 \eta _{12})^{2}+ (3 \eta _{21}- \eta _{03})^{2} \\ hu[3]=( \eta _{30}+ \eta _{12})^{2}+ ( \eta _{21}+ \eta _{03})^{2} \\ hu[4]=( \eta _{30}-3 \eta _{12})( \eta _{30}+ \eta _{12})[( \eta _{30}+ \eta _{12})^{2}-3( \eta _{21}+ \eta _{03})^{2}]+(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ hu[5]=( \eta _{20}- \eta _{02})[( \eta _{30}+ \eta _{12})^{2}- ( \eta _{21}+ \eta _{03})^{2}]+4 \eta _{11}( \eta _{30}+ \eta _{12})( \eta _{21}+ \eta _{03}) \\ hu[6]=(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}]-( \eta _{30}-3 \eta _{12})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ \end{array}
where
:math:`\eta_{ji}` stands for
@ -105,8 +106,7 @@ where
These values are proved to be invariants to the image scale, rotation, and reflection except the seventh one, whose sign is changed by reflection. This invariance is proved with the assumption of infinite image resolution. In case of raster images, the computed Hu invariants for the original and transformed images are a bit different.
See Also:
:ocv:func:`matchShapes`
.. seealso:: :ocv:func:`matchShapes`
findContours
@ -280,7 +280,7 @@ Approximates Freeman chain(s) with a polygonal curve.
:param storage: Storage location for the resulting polylines
:param method: Approximation method (see the description of the function :ref:`FindContours` )
:param method: Approximation method (see the description of the function :ocv:cfunc:`FindContours` )
:param parameter: Method parameter (not used now)
@ -463,7 +463,9 @@ Fits a line to a 2D or 3D point set.
:param param: Numerical parameter ( ``C`` ) for some types of distances. If it is 0, an optimal value is chosen.
:param reps, aeps: Sufficient accuracy for the radius (distance between the coordinate origin and the line) and angle, respectively. 0.01 would be a good default value for both.
:param reps: Sufficient accuracy for the radius (distance between the coordinate origin and the line).
:param aeps: Sufficient accuracy for the angle. 0.01 would be a good default value for ``reps`` and ``aeps``.
The function ``fitLine`` fits a line to a 2D or 3D point set by minimizing
:math:`\sum_i \rho(r_i)` where

@ -78,7 +78,7 @@ The structure represents a possible decision tree node split. It has public memb
Pointer to the next split in the node list of splits.
.. ocv:member:: int subset[2]
.. ocv:member:: int[] subset
Bit array indicating the value subset in case of split on a categorical variable. The rule is:
@ -90,13 +90,11 @@ The structure represents a possible decision tree node split. It has public memb
.. ocv:member:: float ord.c
The threshold value in case of split on an ordered variable. The rule is:
The threshold value in case of split on an ordered variable. The rule is: ::
::
if var_value < c
then next_node<-left
else next_node<-right
if var_value < c
then next_node<-left
else next_node<-right
.. ocv:member:: int ord.split_point
@ -125,7 +123,7 @@ The structure represents a node in a decision tree. It has public members:
Pointer to the parent node.
.. ocv:mebmer:: CvDTreeNode* left
.. ocv:member:: CvDTreeNode* left
Pointer to the left child node.
@ -137,7 +135,7 @@ The structure represents a node in a decision tree. It has public members:
Pointer to the first (primary) split in the node list of splits.
.. ocv:mebmer:: int sample_count
.. ocv:member:: int sample_count
The number of samples that fall into the node at the training stage. It is used to resolve the difficult cases - when the variable for the primary split is missing and all the variables for other surrogate splits are missing too. In this case the sample is directed to the left if ``left->sample_count > right->sample_count`` and to the right otherwise.

@ -62,7 +62,7 @@ Alternatively, the algorithm may start with the M-step when the initial values f
:math:`p_{i,k}` can be provided. Another alternative when
:math:`p_{i,k}` are unknown is to use a simpler clustering algorithm to pre-cluster the input samples and thus obtain initial
:math:`p_{i,k}` . Often (including macnine learning) the
:ref:`kmeans` algorithm is used for that purpose.
:ocv:func:`kmeans` algorithm is used for that purpose.
One of the main problems of the EM algorithm is a large number
of parameters to estimate. The majority of the parameters reside in
@ -176,7 +176,7 @@ Unlike many of the ML models, EM is an unsupervised learning algorithm and it do
:math:`\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N` (indices of the most probable mixture component for each sample).
The trained model can be used further for prediction, just like any other classifier. The trained model is similar to the
:ref:`Bayes classifier`.
:ocv:class:`CvBayesClassifier`.
For an example of clustering random samples of the multi-Gaussian distribution using EM, see ``em.cpp`` sample in the OpenCV distribution.

@ -13,6 +13,7 @@ differential loss function, some popular ones are implemented.
Decision trees (:ocv:class:`CvDTree`) usage as base learners allows to process ordered
and categorical variables.
.. _Training GBT:
Training the GBT model
----------------------
@ -67,7 +68,7 @@ The following loss functions are implemented for regression problems:
\delta\cdot\left(|y-f(x)|-\dfrac{\delta}{2}\right) & : |y-f(x)|>\delta\\
\dfrac{1}{2}\cdot(y-f(x))^2 & : |y-f(x)|\leq\delta \end{array} \right.`,
where :math:`\delta` is the :math:`\alpha`-quantile estimation of the
where :math:`\delta` is the :math:`\alpha`-quantile estimation of the
:math:`|y-f(x)|`. In the current implementation :math:`\alpha=0.2`.
@ -88,9 +89,10 @@ where :math:`f_0` is the initial guess (the best constant model) and :math:`\nu`
is a regularization parameter from the interval :math:`(0,1]`, futher called
*shrinkage*.
.. _Predicting with GBT:
Predicting with the GBT Model
-------------------------
-----------------------------
To get the GBT model prediciton, you need to compute the sum of responses of
all the trees in the ensemble. For regression problems, it is the answer.
@ -118,7 +120,7 @@ CvGBTreesParams::CvGBTreesParams
.. ocv:function:: CvGBTreesParams::CvGBTreesParams( int loss_function_type, int weak_count, float shrinkage, float subsample_portion, int max_depth, bool use_surrogates )
:param loss_function_type: Type of the loss function used for training
(see :ref:`Training the GBT model`). It must be one of the
(see :ref:`Training GBT`). It must be one of the
following types: ``CvGBTrees::SQUARED_LOSS``, ``CvGBTrees::ABSOLUTE_LOSS``,
``CvGBTrees::HUBER_LOSS``, ``CvGBTrees::DEVIANCE_LOSS``. The first three
types are used for regression problems, and the last one for
@ -128,7 +130,7 @@ CvGBTreesParams::CvGBTreesParams
count of trees in the GBT model, where ``K`` is the output classes count
(equal to one in case of a regression).
:param shrinkage: Regularization parameter (see :ref:`Training the GBT model`).
:param shrinkage: Regularization parameter (see :ref:`Training GBT`).
:param subsample_portion: Portion of the whole training set used for each algorithm iteration.
Subset is generated randomly. For more information see
@ -222,13 +224,13 @@ Predicts a response for an input sample.
only one model.
:param k: Number of tree ensembles built in case of the classification problem
(see :ref:`Training the GBT model`). Use this
(see :ref:`Training GBT`). Use this
parameter to change the ouput to sum of the trees' predictions in the
``k``-th ensemble only. To get the total GBT model prediction, ``k`` value
must be -1. For regression problems, ``k`` is also equal to -1.
The method predicts the response corresponding to the given sample
(see :ref:`Predicting with the GBT model`).
(see :ref:`Predicting with GBT`).
The result is either the class label or the estimated function value. The
:ocv:func:`predict` method enables using the parallel version of the GBT model
prediction if the OpenCV is built with the TBB library. In this case, predictions

@ -71,7 +71,7 @@ so the error on the test set usually starts increasing after the network
size reaches a limit. Besides, the larger networks are trained much
longer than the smaller ones, so it is reasonable to pre-process the data,
using
:ocv:func:`PCA::operator ()` or similar technique, and train a smaller network
:ocv:func:`PCA::operator()` or similar technique, and train a smaller network
on only essential features.
Another MPL feature is an inability to handle categorical

@ -32,25 +32,13 @@ For the random trees usage example, please, see letter_recog.cpp sample in OpenC
**References:**
*
*Machine Learning*, Wald I, July 2002.
* *Machine Learning*, Wald I, July 2002. http://stat-www.berkeley.edu/users/breiman/wald2002-1.pdf
http://stat-www.berkeley.edu/users/breiman/wald2002-1.pdf
* *Looking Inside the Black Box*, Wald II, July 2002. http://stat-www.berkeley.edu/users/breiman/wald2002-2.pdf
*
*Looking Inside the Black Box*, Wald II, July 2002.
* *Software for the Masses*, Wald III, July 2002. http://stat-www.berkeley.edu/users/breiman/wald2002-3.pdf
http://stat-www.berkeley.edu/users/breiman/wald2002-2.pdf
*
*Software for the Masses*, Wald III, July 2002.
http://stat-www.berkeley.edu/users/breiman/wald2002-3.pdf
*
And other articles from the web site
http://www.stat.berkeley.edu/users/breiman/RandomForests/cc_home.htm
.
* And other articles from the web site http://www.stat.berkeley.edu/users/breiman/RandomForests/cc_home.htm
CvRTParams
----------

@ -659,7 +659,7 @@ class FunctionTests(OpenCVTests):
self.assert_(li[0] != None)
def test_InPaint(self):
src = self.get_sample("doc/pics/building.jpg")
src = self.get_sample("samples/cpp/building.jpg")
msk = cv.CreateImage(cv.GetSize(src), cv.IPL_DEPTH_8U, 1)
damaged = cv.CloneMat(src)
repaired = cv.CreateImage(cv.GetSize(src), cv.IPL_DEPTH_8U, 3)
@ -866,7 +866,7 @@ class FunctionTests(OpenCVTests):
def yield_line_image(self):
""" Needed by HoughLines tests """
src = self.get_sample("doc/pics/building.jpg", 0)
src = self.get_sample("samples/cpp/building.jpg", 0)
dst = cv.CreateImage(cv.GetSize(src), 8, 1)
cv.Canny(src, dst, 50, 200, 3)
return dst
@ -2104,7 +2104,7 @@ class DocumentFragmentTests(OpenCVTests):
""" Test the fragments of code that are included in the documentation """
def setUp(self):
OpenCVTests.setUp(self)
sys.path.append("../doc/python_fragments")
sys.path.append(".")
def test_precornerdetect(self):
from precornerdetect import precornerdetect
@ -2118,7 +2118,7 @@ class DocumentFragmentTests(OpenCVTests):
def test_findstereocorrespondence(self):
from findstereocorrespondence import findstereocorrespondence
(l,r) = [self.get_sample("doc/pics/tsukuba_%s.png" % c, cv.CV_LOAD_IMAGE_GRAYSCALE) for c in "lr"]
(l,r) = [self.get_sample("samples/cpp/tsukuba_%s.png" % c, cv.CV_LOAD_IMAGE_GRAYSCALE) for c in "lr"]
(disparity_left, disparity_right) = findstereocorrespondence(l, r)
@ -2129,7 +2129,7 @@ class DocumentFragmentTests(OpenCVTests):
def test_calchist(self):
from calchist import hs_histogram
i1 = self.get_sample("samples/c/lena.jpg")
i2 = self.get_sample("doc/pics/building.jpg")
i2 = self.get_sample("samples/cpp/building.jpg")
i3 = cv.CloneMat(i1)
cv.Flip(i3, i3, 1)
h1 = hs_histogram(i1)

@ -205,10 +205,10 @@ In case of point sets, the problem is formulated as follows: you need to find a
when ``fullAffine=false`` .
.. seealso::
:ocv:func:`getAffineTransform`,
:ocv:func:`getPerspectiveTransform`,
:ocv:func:`findHomography`
:ocv:func:`getAffineTransform`,
:ocv:func:`getPerspectiveTransform`,
:ocv:func:`findHomography`
@ -242,14 +242,10 @@ That is, MHI pixels where the motion occurs are set to the current ``timestamp``
The function, together with
:ocv:func:`calcMotionGradient` and
:ocv:func:`calcGlobalOrientation` , implements a motion templates technique described in
[Davis97]_
and
[Bradski00]_
.
[Davis97]_ and [Bradski00]_.
See also the OpenCV sample ``motempl.c`` that demonstrates the use of all the motion template functions.
calcMotionGradient
----------------------
Calculates a gradient orientation of a motion history image.
@ -267,7 +263,9 @@ Calculates a gradient orientation of a motion history image.
:param orientation: Output motion gradient orientation image that has the same type and the same size as ``mhi`` . Each pixel of the image is a motion orientation, from 0 to 360 degrees.
:param delta1, delta2: Minimum and maximum allowed difference between ``mhi`` values within a pixel neighorhood. That is, the function finds the minimum ( :math:`m(x,y)` ) and maximum ( :math:`M(x,y)` ) ``mhi`` values over :math:`3 \times 3` neighborhood of each pixel and marks the motion orientation at :math:`(x, y)` as valid only if
:param delta1: Minimal (or maximal) allowed difference between ``mhi`` values within a pixel neighorhood.
:param delta2: Maximal (or minimal) allowed difference between ``mhi`` values within a pixel neighorhood. That is, the function finds the minimum ( :math:`m(x,y)` ) and maximum ( :math:`M(x,y)` ) ``mhi`` values over :math:`3 \times 3` neighborhood of each pixel and marks the motion orientation at :math:`(x, y)` as valid only if
.. math::
@ -354,6 +352,7 @@ Finds an object center, size, and orientation.
.. ocv:pyfunction:: cv2.CamShift(probImage, window, criteria) -> retval, window
.. ocv:cfunction:: int cvCamShift( const CvArr* probImage, CvRect window, CvTermCriteria criteria, CvConnectedComp* comp, CvBox2D* box=NULL )
.. ocv:pyoldfunction:: cv.CamShift(probImage, window, criteria)-> (int, comp, box)
:param probImage: Back projection of the object histogram. See :ocv:func:`calcBackProject` .
@ -501,7 +500,7 @@ BackgroundSubtractor::operator()
--------------------------------
Computes a foreground mask.
.. ocv:function:: virtual void BackgroundSubtractor::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
.. ocv:function:: void BackgroundSubtractor::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
.. ocv:pyfunction:: cv2.BackgroundSubtractor.apply(image[, fgmask[, learningRate]]) -> fgmask
@ -514,7 +513,7 @@ BackgroundSubtractor::getBackgroundImage
----------------------------------------
Computes a background image.
.. ocv:function:: virtual void BackgroundSubtractor::getBackgroundImage(OutputArray backgroundImage) const
.. ocv:function:: void BackgroundSubtractor::getBackgroundImage(OutputArray backgroundImage) const
:param backgroundImage: The output background image.
@ -559,7 +558,7 @@ BackgroundSubtractorMOG::operator()
-----------------------------------
Updates the background model and returns the foreground mask
.. ocv:function:: virtual void BackgroundSubtractorMOG::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
.. ocv:function:: void BackgroundSubtractorMOG::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
Parameters are the same as in ``BackgroundSubtractor::operator()``
@ -636,17 +635,16 @@ BackgroundSubtractorMOG2::operator()
------------------------------------
Updates the background model and computes the foreground mask
.. ocv:function:: virtual void BackgroundSubtractorMOG2::operator()(InputArray image, OutputArray fgmask, double learningRate=-1)
See ``BackgroundSubtractor::operator ()``.
.. ocv:function:: void BackgroundSubtractorMOG2::operator()(InputArray image, OutputArray fgmask, double learningRate=-1)
See :ocv:func:`BackgroundSubtractor::operator()`.
BackgroundSubtractorMOG2::getBackgroundImage
--------------------------------------------
Returns background image
.. ocv:function:: virtual void BackgroundSubtractorMOG2::getBackgroundImage(OutputArray backgroundImage)
.. ocv:function:: void BackgroundSubtractorMOG2::getBackgroundImage(OutputArray backgroundImage)
See :ocv:func:`BackgroundSubtractor::getBackgroundImage`.

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Loading…
Cancel
Save