From dcd4f8f5db5adc932e3f052e10971b0ec4871928 Mon Sep 17 00:00:00 2001 From: Suleyman TURKMEN Date: Sun, 31 Dec 2017 14:13:13 +0300 Subject: [PATCH] Update documentation --- modules/core/include/opencv2/core.hpp | 123 ++--- modules/core/include/opencv2/core/types.hpp | 80 ++- .../imgcodecs/include/opencv2/imgcodecs.hpp | 43 +- modules/imgproc/include/opencv2/imgproc.hpp | 479 +++++++++--------- .../ImgTrans/imageSegmentation.cpp | 12 +- .../tutorial_code/snippets/core_reduce.cpp | 18 +- .../tutorial_code/snippets/core_various.cpp | 53 ++ .../snippets/imgcodecs_imwrite.cpp | 45 ++ 8 files changed, 452 insertions(+), 401 deletions(-) create mode 100644 samples/cpp/tutorial_code/snippets/core_various.cpp create mode 100644 samples/cpp/tutorial_code/snippets/imgcodecs_imwrite.cpp diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index fe3af39365..81eab1107a 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -140,7 +140,7 @@ public: By default the function prints information about the error to stderr, then it either stops if cv::setBreakOnError() had been called before or raises the exception. -It is possible to alternate error processing by using cv::redirectError(). +It is possible to alternate error processing by using #redirectError(). @param exc the exception raisen. @deprecated drop this version */ @@ -175,7 +175,7 @@ enum CovarFlags { /**The output covariance matrix is calculated as: \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...] \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T,\f] covar will be a square matrix of the same size as the total number of elements in each input - vector. One and only one of COVAR_SCRAMBLED and COVAR_NORMAL must be specified.*/ + vector. One and only one of #COVAR_SCRAMBLED and #COVAR_NORMAL must be specified.*/ COVAR_NORMAL = 1, /** If the flag is specified, the function does not calculate mean from the input vectors but, instead, uses the passed mean vector. This is useful if mean has been @@ -266,8 +266,8 @@ Normally, the function is not called directly. It is used inside filtering funct copyMakeBorder. @param p 0-based coordinate of the extrapolated pixel along one of the axes, likely \<0 or \>= len @param len Length of the array along the corresponding axis. -@param borderType Border type, one of the cv::BorderTypes, except for cv::BORDER_TRANSPARENT and -cv::BORDER_ISOLATED . When borderType==cv::BORDER_CONSTANT , the function always returns -1, regardless +@param borderType Border type, one of the #BorderTypes, except for #BORDER_TRANSPARENT and +#BORDER_ISOLATED . When borderType==#BORDER_CONSTANT , the function always returns -1, regardless of p and len. @sa copyMakeBorder @@ -304,7 +304,7 @@ function does not copy src itself but simply constructs the border, for example: @endcode @note When the source image is a part (ROI) of a bigger image, the function will try to use the pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as -if src was not a ROI, use borderType | BORDER_ISOLATED. +if src was not a ROI, use borderType | #BORDER_ISOLATED. @param src Source image. @param dst Destination image of the same type as src and the size Size(src.cols+left+right, @@ -642,7 +642,7 @@ CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stdde /** @brief Calculates the absolute norm of an array. -This version of cv::norm calculates the absolute norm of src1. The type of norm to calculate is specified using cv::NormTypes. +This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes. As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ @@ -664,7 +664,7 @@ It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} When the mask parameter is specified and it is not empty, the norm is -If normType is not specified, NORM_L2 is used. +If normType is not specified, #NORM_L2 is used. calculated only over the region specified by the mask. Multi-channel input arrays are treated as single-channel arrays, that is, @@ -673,7 +673,7 @@ the results for all channels are combined. Hamming norms can only be calculated with CV_8U depth arrays. @param src1 first input array. -@param normType type of the norm (see cv::NormTypes). +@param normType type of the norm (see #NormTypes). @param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type. */ CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mask = noArray()); @@ -682,18 +682,18 @@ CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mas This version of cv::norm calculates the absolute difference norm or the relative difference norm of arrays src1 and src2. -The type of norm to calculate is specified using cv::NormTypes. +The type of norm to calculate is specified using #NormTypes. @param src1 first input array. @param src2 second input array of the same size and the same type as src1. -@param normType type of the norm (cv::NormTypes). +@param normType type of the norm (see #NormTypes). @param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type. */ CV_EXPORTS_W double norm(InputArray src1, InputArray src2, int normType = NORM_L2, InputArray mask = noArray()); /** @overload @param src first input array. -@param normType type of the norm (see cv::NormTypes). +@param normType type of the norm (see #NormTypes). */ CV_EXPORTS double norm( const SparseMat& src, int normType ); @@ -859,11 +859,11 @@ CV_EXPORTS void minMaxLoc(const SparseMat& a, double* minVal, /** @brief Reduces a matrix to a vector. -The function cv::reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of +The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of 1D vectors and performing the specified operation on the vectors until a single row/column is obtained. For example, the function can be used to compute horizontal and vertical projections of a -raster image. In case of REDUCE_MAX and REDUCE_MIN , the output image should have the same type as the source one. -In case of REDUCE_SUM and REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy. +raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one. +In case of #REDUCE_SUM and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction modes. The following code demonstrates its usage for a single channel matrix. @@ -876,7 +876,7 @@ And the following code demonstrates its usage for a two-channel matrix. @param dst output vector. Its size and type is defined by dim and dtype parameters. @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to a single row. 1 means that the matrix is reduced to a single column. -@param rtype reduction operation that could be one of cv::ReduceTypes +@param rtype reduction operation that could be one of #ReduceTypes @param dtype when negative, the output vector will have the same type as the input matrix, otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()). @sa repeat @@ -1802,15 +1802,15 @@ The function cv::invert inverts the matrix src and stores the result in dst the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is minimal, where I is an identity matrix. -In case of the DECOMP_LU method, the function returns non-zero value if +In case of the #DECOMP_LU method, the function returns non-zero value if the inverse has been successfully calculated and 0 if src is singular. -In case of the DECOMP_SVD method, the function returns the inverse +In case of the #DECOMP_SVD method, the function returns the inverse condition number of src (the ratio of the smallest singular value to the largest singular value) and 0 if src is singular. The SVD method calculates a pseudo-inverse matrix if src is singular. -Similarly to DECOMP_LU, the method DECOMP_CHOLESKY works only with +Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with non-singular square matrices that should also be symmetrical and positively defined. In this case, the function stores the inverted matrix in dst and returns non-zero. Otherwise, it returns 0. @@ -1826,10 +1826,10 @@ CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags = DECOMP_L The function cv::solve solves a linear system or least-squares problem (the latter is possible with SVD or QR methods, or by specifying the flag -DECOMP_NORMAL ): +#DECOMP_NORMAL ): \f[\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\f] -If DECOMP_LU or DECOMP_CHOLESKY method is used, the function returns 1 +If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1 if src1 (or \f$\texttt{src1}^T\texttt{src1}\f$ ) is non-singular. Otherwise, it returns 0. In the latter case, dst is not valid. Other methods find a pseudo-solution in case of a singular left-hand side part. @@ -1841,7 +1841,7 @@ will not do the work. Use SVD::solveZ instead. @param src1 input matrix on the left-hand side of the system. @param src2 input matrix on the right-hand side of the system. @param dst output solution. -@param flags solution (matrix inversion) method (cv::DecompTypes) +@param flags solution (matrix inversion) method (#DecompTypes) @sa invert, SVD, eigen */ CV_EXPORTS_W bool solve(InputArray src1, InputArray src2, @@ -1857,7 +1857,7 @@ proper comparison predicate. @param src input single-channel array. @param dst output array of the same size and type as src. -@param flags operation flags, a combination of cv::SortFlags +@param flags operation flags, a combination of #SortFlags @sa sortIdx, randShuffle */ CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags); @@ -1953,7 +1953,7 @@ the set of input vectors. @param nsamples number of samples @param covar output covariance matrix of the type ctype and square size. @param mean input or output (depending on the flags) array as the average value of the input vectors. -@param flags operation flags as a combination of cv::CovarFlags +@param flags operation flags as a combination of #CovarFlags @param ctype type of the matrixl; it equals 'CV_64F' by default. @sa PCA, mulTransposed, Mahalanobis @todo InputArrayOfArrays @@ -1962,11 +1962,11 @@ CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, M int flags, int ctype = CV_64F); /** @overload -@note use cv::COVAR_ROWS or cv::COVAR_COLS flag +@note use #COVAR_ROWS or #COVAR_COLS flag @param samples samples stored as rows/columns of a single matrix. @param covar output covariance matrix of the type ctype and square size. @param mean input or output (depending on the flags) array as the average value of the input vectors. -@param flags operation flags as a combination of cv::CovarFlags +@param flags operation flags as a combination of #CovarFlags @param ctype type of the matrixl; it equals 'CV_64F' by default. */ CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, @@ -1999,8 +1999,8 @@ CV_EXPORTS_W void SVBackSubst( InputArray w, InputArray u, InputArray vt, The function cv::Mahalanobis calculates and returns the weighted distance between two vectors: \f[d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\f] -The covariance matrix may be calculated using the cv::calcCovarMatrix function and then inverted using -the invert function (preferably using the cv::DECOMP_SVD method, as the most accurate). +The covariance matrix may be calculated using the #calcCovarMatrix function and then inverted using +the invert function (preferably using the #DECOMP_SVD method, as the most accurate). @param v1 first 1D input vector. @param v2 second 1D input vector. @param icovar inverse covariance matrix. @@ -2030,28 +2030,28 @@ is how 2D *CCS* spectrum looks: In case of 1D transform of a real vector, the output looks like the first row of the matrix above. So, the function chooses an operation mode depending on the flags and size of the input array: -- If DFT_ROWS is set or the input array has a single row or single column, the function - performs a 1D forward or inverse transform of each row of a matrix when DFT_ROWS is set. +- If #DFT_ROWS is set or the input array has a single row or single column, the function + performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set. Otherwise, it performs a 2D transform. -- If the input array is real and DFT_INVERSE is not set, the function performs a forward 1D or +- If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or 2D transform: - - When DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as + - When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as input. - - When DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as + - When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as input. In case of 2D transform, it uses the packed format as shown above. In case of a single 1D transform, it looks like the first row of the matrix above. In case of - multiple 1D transforms (when using the DFT_ROWS flag), each row of the output matrix + multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix looks like the first row of the matrix above. -- If the input array is complex and either DFT_INVERSE or DFT_REAL_OUTPUT are not set, the +- If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the output is a complex array of the same size as input. The function performs a forward or inverse 1D or 2D transform of the whole input array or each row of the input array independently, depending on the flags DFT_INVERSE and DFT_ROWS. -- When DFT_INVERSE is set and the input array is real, or it is complex but DFT_REAL_OUTPUT +- When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT is set, the output is a real array of the same size as input. The function performs a 1D or 2D inverse transformation of the whole input array or each individual row, depending on the flags - DFT_INVERSE and DFT_ROWS. + #DFT_INVERSE and #DFT_ROWS. -If DFT_SCALE is set, the scaling is done after the transformation. +If #DFT_SCALE is set, the scaling is done after the transformation. Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the @@ -2117,7 +2117,7 @@ To optimize this sample, consider the following approaches: - If different tiles in C can be calculated in parallel and, thus, the convolution is done by parts, the loop can be threaded. -All of the above improvements have been implemented in matchTemplate and filter2D . Therefore, by +All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by using them, you can get the performance even better than with the above theoretically optimal implementation. Though, those two functions actually calculate cross-correlation, not convolution, so you need to "flip" the second convolution operand B vertically and horizontally using flip . @@ -2130,10 +2130,10 @@ so you need to "flip" the second convolution operand B vertically and horizontal opencv_source/samples/python/dft.py @param src input array that could be real or complex. @param dst output array whose size and type depends on the flags . -@param flags transformation flags, representing a combination of the cv::DftFlags +@param flags transformation flags, representing a combination of the #DftFlags @param nonzeroRows when the parameter is not zero, the function assumes that only the first -nonzeroRows rows of the input array (DFT_INVERSE is not set) or only the first nonzeroRows of the -output array (DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the +nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the +output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the rows more efficiently and save some time; this technique is very useful for calculating array cross-correlation or convolution using DFT. @sa dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar , @@ -2143,13 +2143,13 @@ CV_EXPORTS_W void dft(InputArray src, OutputArray dst, int flags = 0, int nonzer /** @brief Calculates the inverse Discrete Fourier Transform of a 1D or 2D array. -idft(src, dst, flags) is equivalent to dft(src, dst, flags | DFT_INVERSE) . -@note None of dft and idft scales the result by default. So, you should pass DFT_SCALE to one of +idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) . +@note None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of dft or idft explicitly to make these transforms mutually inverse. @sa dft, dct, idct, mulSpectrums, getOptimalDFTSize @param src input floating-point real or complex array. @param dst output array whose size and type depend on the flags. -@param flags operation flags (see dft and cv::DftFlags). +@param flags operation flags (see dft and #DftFlags). @param nonzeroRows number of dst rows to process; the rest of the rows have undefined content (see the convolution sample in dft description. */ @@ -2174,9 +2174,9 @@ floating-point array: \f[X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\f] The function chooses the mode of operation by looking at the flags and size of the input array: -- If (flags & DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it +- If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it is an inverse 1D or 2D transform. -- If (flags & DCT_ROWS) != 0 , the function performs a 1D transform of each row. +- If (flags & #DCT_ROWS) != 0 , the function performs a 1D transform of each row. - If the array is a single column or a single row, the function performs a 1D transform. - If none of the above is true, the function performs a 2D transform. @@ -2713,7 +2713,7 @@ public: if you need to solve many linear systems with the same left-hand side (for example, src ). If all you need is to solve a single system (possibly with multiple rhs immediately available), simply call solve - add pass DECOMP_SVD there. It does absolutely the same thing. + add pass #DECOMP_SVD there. It does absolutely the same thing. */ void backSubst( InputArray rhs, OutputArray dst ) const; @@ -2976,7 +2976,7 @@ function parameter). after every attempt. The best (minimum) value is chosen and the corresponding labels and the compactness value are returned by the function. Basically, you can use only the core of the function, set the number of attempts to 1, initialize labels each time using a custom algorithm, -pass them with the ( flags = KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best +pass them with the ( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best (most-compact) clustering. */ CV_EXPORTS_W double kmeans( InputArray data, int K, InputOutputArray bestLabels, @@ -3053,31 +3053,8 @@ matching, graph-cut etc.), background subtraction (which can be done using mixtu models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck etc.). -Here is example of SIFT use in your application via Algorithm interface: -@code - #include "opencv2/opencv.hpp" - #include "opencv2/xfeatures2d.hpp" - using namespace cv::xfeatures2d; - - Ptr sift = SIFT::create(); - FileStorage fs("sift_params.xml", FileStorage::READ); - if( fs.isOpened() ) // if we have file with parameters, read them - { - sift->read(fs["sift_params"]); - fs.release(); - } - else // else modify the parameters and store them; user can later edit the file to use different parameters - { - sift->setContrastThreshold(0.01f); // lower the contrast threshold, compared to the default value - { - WriteStructContext ws(fs, "sift_params", CV_NODE_MAP); - sift->write(fs); - } - } - Mat image = imread("myimage.png", 0), descriptors; - vector keypoints; - sift->detectAndCompute(image, noArray(), keypoints, descriptors); -@endcode +Here is example of SimpleBlobDetector use in your application via Algorithm interface: +@snippet snippets/core_various.cpp Algorithm */ class CV_EXPORTS_W Algorithm { diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index f3a7b518bf..6d8782058a 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -75,7 +75,7 @@ template class Complex { public: - //! constructors + //! default constructor Complex(); Complex( _Tp _re, _Tp _im = 0 ); @@ -159,7 +159,7 @@ template class Point_ public: typedef _Tp value_type; - // various constructors + //! default constructor Point_(); Point_(_Tp _x, _Tp _y); Point_(const Point_& pt); @@ -181,8 +181,8 @@ public: double cross(const Point_& pt) const; //! checks whether the point is inside the specified rectangle bool inside(const Rect_<_Tp>& r) const; - - _Tp x, y; //< the point coordinates + _Tp x; //!< x coordinate of the point + _Tp y; //!< y coordinate of the point }; typedef Point_ Point2i; @@ -239,7 +239,7 @@ template class Point3_ public: typedef _Tp value_type; - // various constructors + //! default constructor Point3_(); Point3_(_Tp _x, _Tp _y, _Tp _z); Point3_(const Point3_& pt); @@ -262,8 +262,9 @@ public: double ddot(const Point3_& pt) const; //! cross product of the 2 3D points Point3_ cross(const Point3_& pt) const; - - _Tp x, y, z; //< the point coordinates + _Tp x; //!< x coordinate of the 3D point + _Tp y; //!< y coordinate of the 3D point + _Tp z; //!< z coordinate of the 3D point }; typedef Point3_ Point3i; @@ -316,7 +317,7 @@ template class Size_ public: typedef _Tp value_type; - //! various constructors + //! default constructor Size_(); Size_(_Tp _width, _Tp _height); Size_(const Size_& sz); @@ -331,7 +332,8 @@ public: //! conversion of another data type. template operator Size_<_Tp2>() const; - _Tp width, height; // the width and the height + _Tp width; //!< the width + _Tp height; //!< the height }; typedef Size_ Size2i; @@ -416,7 +418,7 @@ template class Rect_ public: typedef _Tp value_type; - //! various constructors + //! default constructor Rect_(); Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height); Rect_(const Rect_& r); @@ -442,7 +444,10 @@ public: //! checks whether the rectangle contains the point bool contains(const Point_<_Tp>& pt) const; - _Tp x, y, width, height; //< the top-left corner, as well as width and height of the rectangle + _Tp x; //!< x coordinate of the top-left corner + _Tp y; //!< y coordinate of the top-left corner + _Tp width; //!< width of the rectangle + _Tp height; //!< height of the rectangle }; typedef Rect_ Rect2i; @@ -481,24 +486,10 @@ struct Type< Rect_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; /** @brief The class represents rotated (i.e. not up-right) rectangles on a plane. Each rectangle is specified by the center point (mass center), length of each side (represented by -cv::Size2f structure) and the rotation angle in degrees. +#Size2f structure) and the rotation angle in degrees. The sample below demonstrates how to use RotatedRect: -@code - Mat image(200, 200, CV_8UC3, Scalar(0)); - RotatedRect rRect = RotatedRect(Point2f(100,100), Size2f(100,50), 30); - - Point2f vertices[4]; - rRect.points(vertices); - for (int i = 0; i < 4; i++) - line(image, vertices[i], vertices[(i+1)%4], Scalar(0,255,0)); - - Rect brect = rRect.boundingRect(); - rectangle(image, brect, Scalar(255,0,0)); - - imshow("rectangles", image); - waitKey(0); -@endcode +@snippet snippets/core_various.cpp RotatedRect_demo ![image](pics/rotatedrect.png) @sa CamShift, fitEllipse, minAreaRect, CvBox2D @@ -506,9 +497,9 @@ The sample below demonstrates how to use RotatedRect: class CV_EXPORTS RotatedRect { public: - //! various constructors + //! default constructor RotatedRect(); - /** + /** full constructor @param center The rectangle mass center. @param size Width and height of the rectangle. @param angle The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., @@ -529,10 +520,12 @@ public: Rect boundingRect() const; //! returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images Rect_ boundingRect2f() const; - - Point2f center; //< the rectangle mass center - Size2f size; //< width and height of the rectangle - float angle; //< the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. + //! returns the rectangle mass center + Point2f center; + //! returns width and height of the rectangle + Size2f size; + //! returns the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. + float angle; }; template<> class DataType< RotatedRect > @@ -637,7 +630,7 @@ OpenCV to pass pixel values. template class Scalar_ : public Vec<_Tp, 4> { public: - //! various constructors + //! default constructor Scalar_(); Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0); Scalar_(_Tp v0); @@ -654,10 +647,10 @@ public: //! per-element product Scalar_<_Tp> mul(const Scalar_<_Tp>& a, double scale=1 ) const; - // returns (v0, -v1, -v2, -v3) + //! returns (v0, -v1, -v2, -v3) Scalar_<_Tp> conj() const; - // returns true iff v1 == v2 == v3 == 0 + //! returns true iff v1 == v2 == v3 == 0 bool isReal() const; }; @@ -695,14 +688,13 @@ struct Type< Scalar_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) } /** @brief Data structure for salient point detectors. The class instance stores a keypoint, i.e. a point feature found by one of many available keypoint -detectors, such as Harris corner detector, cv::FAST, cv::StarDetector, cv::SURF, cv::SIFT, -cv::LDetector etc. +detectors, such as Harris corner detector, #FAST, %StarDetector, %SURF, %SIFT etc. The keypoint is characterized by the 2D position, scale (proportional to the diameter of the neighborhood that needs to be taken into account), orientation and some other parameters. The keypoint neighborhood is then analyzed by another algorithm that builds a descriptor (usually represented as a feature vector). The keypoints representing the same object in different images -can then be matched using cv::KDTree or another method. +can then be matched using %KDTree or another method. */ class CV_EXPORTS_W_SIMPLE KeyPoint { @@ -808,9 +800,9 @@ public: CV_WRAP DMatch(int _queryIdx, int _trainIdx, float _distance); CV_WRAP DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance); - CV_PROP_RW int queryIdx; // query descriptor index - CV_PROP_RW int trainIdx; // train descriptor index - CV_PROP_RW int imgIdx; // train image index + CV_PROP_RW int queryIdx; //!< query descriptor index + CV_PROP_RW int trainIdx; //!< train descriptor index + CV_PROP_RW int imgIdx; //!< train image index CV_PROP_RW float distance; @@ -868,8 +860,8 @@ public: TermCriteria(int type, int maxCount, double epsilon); int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS - int maxCount; // the maximum number of iterations/elements - double epsilon; // the desired accuracy + int maxCount; //!< the maximum number of iterations/elements + double epsilon; //!< the desired accuracy }; diff --git a/modules/imgcodecs/include/opencv2/imgcodecs.hpp b/modules/imgcodecs/include/opencv2/imgcodecs.hpp index 567344dc5b..dcb038a985 100644 --- a/modules/imgcodecs/include/opencv2/imgcodecs.hpp +++ b/modules/imgcodecs/include/opencv2/imgcodecs.hpp @@ -197,48 +197,7 @@ should have alpha set to 0, fully opaque pixels should have alpha set to 255/655 The sample below shows how to create such a BGRA image and store to PNG file. It also demonstrates how to set custom compression parameters : -@code - #include - - using namespace cv; - using namespace std; - - void createAlphaMat(Mat &mat) - { - CV_Assert(mat.channels() == 4); - for (int i = 0; i < mat.rows; ++i) { - for (int j = 0; j < mat.cols; ++j) { - Vec4b& bgra = mat.at(i, j); - bgra[0] = UCHAR_MAX; // Blue - bgra[1] = saturate_cast((float (mat.cols - j)) / ((float)mat.cols) * UCHAR_MAX); // Green - bgra[2] = saturate_cast((float (mat.rows - i)) / ((float)mat.rows) * UCHAR_MAX); // Red - bgra[3] = saturate_cast(0.5 * (bgra[1] + bgra[2])); // Alpha - } - } - } - - int main(int argv, char **argc) - { - // Create mat with alpha channel - Mat mat(480, 640, CV_8UC4); - createAlphaMat(mat); - - vector compression_params; - compression_params.push_back(IMWRITE_PNG_COMPRESSION); - compression_params.push_back(9); - - try { - imwrite("alpha.png", mat, compression_params); - } - catch (cv::Exception& ex) { - fprintf(stderr, "Exception converting image to PNG format: %s\n", ex.what()); - return 1; - } - - fprintf(stdout, "Saved PNG file with alpha data.\n"); - return 0; - } -@endcode +@include snippets/imgcodecs_imwrite.cpp @param filename Name of the file. @param img Image to be saved. @param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 0d1ba52f58..6d4d830822 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -67,7 +67,7 @@ processing the left-most pixels in each row, you need pixels to the left of them of the image. You can let these pixels be the same as the left-most image pixels ("replicated border" extrapolation method), or assume that all the non-existing pixels are zeros ("constant border" extrapolation method), and so on. OpenCV enables you to specify the extrapolation method. -For details, see cv::BorderTypes +For details, see #BorderTypes @anchor filter_depths ### Depth combinations @@ -102,7 +102,7 @@ the simplest and the fastest resize, need to solve two main problems with the ab previous section, for some \f$(x,y)\f$, either one of \f$f_x(x,y)\f$, or \f$f_y(x,y)\f$, or both of them may fall outside of the image. In this case, an extrapolation method needs to be used. OpenCV provides the same selection of extrapolation methods as in the filtering functions. In -addition, it provides the method BORDER_TRANSPARENT. This means that the corresponding pixels in +addition, it provides the method #BORDER_TRANSPARENT. This means that the corresponding pixels in the destination image will not be modified at all. - Interpolation of pixel values. Usually \f$f_x(x,y)\f$ and \f$f_y(x,y)\f$ are floating-point @@ -194,7 +194,7 @@ int main(int argc, const char *argv[]) } @endcode -@see cv::ColormapTypes +@see #ColormapTypes @defgroup imgproc_subdiv2d Planar Subdivision @@ -235,8 +235,8 @@ namespace cv //! type of morphological operation enum MorphTypes{ - MORPH_ERODE = 0, //!< see cv::erode - MORPH_DILATE = 1, //!< see cv::dilate + MORPH_ERODE = 0, //!< see #erode + MORPH_DILATE = 1, //!< see #dilate MORPH_OPEN = 2, //!< an opening operation //!< \f[\texttt{dst} = \mathrm{open} ( \texttt{src} , \texttt{element} )= \mathrm{dilate} ( \mathrm{erode} ( \texttt{src} , \texttt{element} ))\f] MORPH_CLOSE = 3, //!< a closing operation @@ -288,7 +288,7 @@ enum InterpolationFlags{ WARP_FILL_OUTLIERS = 8, /** flag, inverse transformation - For example, @ref cv::linearPolar or @ref cv::logPolar transforms: + For example, #linearPolar or #logPolar transforms: - flag is __not__ set: \f$dst( \rho , \phi ) = src(x,y)\f$ - flag is set: \f$dst(x,y) = src( \rho , \phi )\f$ */ @@ -308,7 +308,7 @@ enum InterpolationMasks { //! @{ //! Distance types for Distance Transform and M-estimators -//! @see cv::distanceTransform, cv::fitLine +//! @see distanceTransform, fitLine enum DistanceTypes { DIST_USER = -1, //!< User defined distance DIST_L1 = 1, //!< distance = |x1-x2| + |y1-y2| @@ -341,7 +341,7 @@ enum ThresholdTypes { }; //! adaptive threshold algorithm -//! see cv::adaptiveThreshold +//! @see adaptiveThreshold enum AdaptiveThresholdTypes { /** the threshold value \f$T(x,y)\f$ is a mean of the \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$ minus C */ @@ -349,7 +349,7 @@ enum AdaptiveThresholdTypes { /** the threshold value \f$T(x, y)\f$ is a weighted sum (cross-correlation with a Gaussian window) of the \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$ minus C . The default sigma (standard deviation) is used for the specified blockSize . See - cv::getGaussianKernel*/ + #getGaussianKernel*/ ADAPTIVE_THRESH_GAUSSIAN_C = 1 }; @@ -911,16 +911,35 @@ public: virtual int getPosThresh() const = 0; }; - +/** @brief Base class for Contrast Limited Adaptive Histogram Equalization. : + */ class CV_EXPORTS_W CLAHE : public Algorithm { public: + /** @brief Equalizes the histogram of a grayscale image using Contrast Limited Adaptive Histogram Equalization. + + @param src Source image with CV_8UC1 type. + @param dst Destination image. + */ CV_WRAP virtual void apply(InputArray src, OutputArray dst) = 0; + /** @brief Sets threshold for contrast limiting. + + @param clipLimit threshold value. + */ CV_WRAP virtual void setClipLimit(double clipLimit) = 0; + + //! Returns threshold value for contrast limiting. CV_WRAP virtual double getClipLimit() const = 0; + /** @brief Sets size of grid for histogram equalization. Input image will be divided into + equally sized rectangular tiles. + + @param tileGridSize defines the number of tiles in row and column. + */ CV_WRAP virtual void setTilesGridSize(Size tileGridSize) = 0; + + //!@brief Returns Size defines the number of tiles in row and column. CV_WRAP virtual Size getTilesGridSize() const = 0; CV_WRAP virtual void collectGarbage() = 0; @@ -953,7 +972,7 @@ public: }; /** creates an empty Subdiv2D object. - To create a new empty Delaunay subdivision you need to use the initDelaunay() function. + To create a new empty Delaunay subdivision you need to use the #initDelaunay function. */ CV_WRAP Subdiv2D(); @@ -1005,15 +1024,15 @@ public: or vertices. @returns an integer which specify one of the following five cases for point location: - - The point falls into some facet. The function returns PTLOC_INSIDE and edge will contain one of + - The point falls into some facet. The function returns #PTLOC_INSIDE and edge will contain one of edges of the facet. - - The point falls onto the edge. The function returns PTLOC_ON_EDGE and edge will contain this edge. - - The point coincides with one of the subdivision vertices. The function returns PTLOC_VERTEX and + - The point falls onto the edge. The function returns #PTLOC_ON_EDGE and edge will contain this edge. + - The point coincides with one of the subdivision vertices. The function returns #PTLOC_VERTEX and vertex will contain a pointer to the vertex. - - The point is outside the subdivision reference rectangle. The function returns PTLOC_OUTSIDE_RECT + - The point is outside the subdivision reference rectangle. The function returns #PTLOC_OUTSIDE_RECT and no pointers are filled. - One of input arguments is invalid. A runtime error is raised or, if silent or "parent" error - processing mode is selected, CV_PTLOC_ERROR is returned. + processing mode is selected, #PTLOC_ERROR is returned. */ CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex); @@ -1225,7 +1244,7 @@ public: - -1 corresponds to 10 mean false alarms - 0 corresponds to 1 mean false alarm - 1 corresponds to 0.1 mean false alarms - This vector will be calculated only when the objects type is LSD_REFINE_ADV. + This vector will be calculated only when the objects type is #LSD_REFINE_ADV. */ CV_WRAP virtual void detect(InputArray _image, OutputArray _lines, OutputArray width = noArray(), OutputArray prec = noArray(), @@ -1256,7 +1275,7 @@ public: The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application. -@param _refine The way found lines will be refined, see cv::LineSegmentDetectorModes +@param _refine The way found lines will be refined, see #LineSegmentDetectorModes @param _scale The scale of the image that will be used to find the lines. Range (0..1]. @param _sigma_scale Sigma for Gaussian filter. It is computed as sigma = _sigma_scale/_scale. @param _quant Bound to the quantization error on the gradient norm. @@ -1299,8 +1318,8 @@ CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype = CV_64F /** @brief Returns filter coefficients for computing spatial image derivatives. The function computes and returns the filter coefficients for spatial image derivatives. When -`ksize=CV_SCHARR`, the Scharr \f$3 \times 3\f$ kernels are generated (see cv::Scharr). Otherwise, Sobel -kernels are generated (see cv::Sobel). The filters are normally passed to sepFilter2D or to +`ksize=CV_SCHARR`, the Scharr \f$3 \times 3\f$ kernels are generated (see #Scharr). Otherwise, Sobel +kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to @param kx Output matrix of row filter coefficients. It has the type ktype . @param ky Output matrix of column filter coefficients. It has the type ktype . @@ -1339,11 +1358,11 @@ static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX /** @brief Returns a structuring element of the specified size and shape for morphological operations. -The function constructs and returns the structuring element that can be further passed to cv::erode, -cv::dilate or cv::morphologyEx. But you can also construct an arbitrary binary mask yourself and use it as +The function constructs and returns the structuring element that can be further passed to #erode, +#dilate or #morphologyEx. But you can also construct an arbitrary binary mask yourself and use it as the structuring element. -@param shape Element shape that could be one of cv::MorphShapes +@param shape Element shape that could be one of #MorphShapes @param ksize Size of the structuring element. @param anchor Anchor position within the element. The default value \f$(-1, -1)\f$ means that the anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor @@ -1363,7 +1382,7 @@ The function smoothes an image using the median filter with the \f$\texttt{ksize \texttt{ksize}\f$ aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported. -@note The median filter uses BORDER_REPLICATE internally to cope with border pixels, see cv::BorderTypes +@note The median filter uses #BORDER_REPLICATE internally to cope with border pixels, see #BorderTypes @param src input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U. @@ -1386,10 +1405,10 @@ positive and odd. Or, they can be zero's and then they are computed from sigma. @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 cv::getGaussianKernel for details); to fully control the result regardless of +respectively (see #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 cv::BorderTypes +@param borderType pixel extrapolation method, see #BorderTypes @sa sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur */ @@ -1423,7 +1442,7 @@ in larger areas of semi-equal color. farther pixels will influence each other as long as their colors are close enough (see sigmaColor ). When d\>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace. -@param borderType border mode used to extrapolate pixels outside of the image, see cv::BorderTypes +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes */ CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, @@ -1441,7 +1460,7 @@ where Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow -algorithms, and so on). If you need to compute pixel sums over variable-size windows, use cv::integral. +algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral. @param src input image. @param dst output image of the same size and type as src. @@ -1450,7 +1469,7 @@ algorithms, and so on). If you need to compute pixel sums over variable-size win @param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel center. @param normalize flag, specifying whether the kernel is normalized by its area or not. -@param borderType border mode used to extrapolate pixels outside of the image, see cv::BorderTypes +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes @sa blur, bilateralFilter, GaussianBlur, medianBlur, integral */ CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth, @@ -1473,7 +1492,7 @@ variance and standard deviation around the neighborhood of a pixel. @param anchor kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel center. @param normalize flag, specifying whether the kernel is to be normalized by it's area or not. -@param borderType border mode used to extrapolate pixels outside of the image, see cv::BorderTypes +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes @sa boxFilter */ CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth, @@ -1496,7 +1515,7 @@ the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. @param ksize blurring kernel size. @param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel center. -@param borderType border mode used to extrapolate pixels outside of the image, see cv::BorderTypes +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes @sa boxFilter, bilateralFilter, GaussianBlur, medianBlur */ CV_EXPORTS_W void blur( InputArray src, OutputArray dst, @@ -1514,7 +1533,7 @@ The function does actually compute correlation, not the convolution: \f[\texttt{dst} (x,y) = \sum _{ \stackrel{0\leq x' < \texttt{kernel.cols},}{0\leq y' < \texttt{kernel.rows}} } \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\f] That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip -the kernel using cv::flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - +the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1)`. The function uses the DFT-based algorithm in case of sufficiently large kernels (~`11 x 11` or @@ -1530,7 +1549,7 @@ separate color planes using split and process them individually. the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center. @param delta optional value added to the filtered pixels before storing them in dst. -@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderType pixel extrapolation method, see #BorderTypes @sa sepFilter2D, dft, matchTemplate */ CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth, @@ -1551,7 +1570,7 @@ kernel kernelY. The final result shifted by delta is stored in dst . @param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor is at the kernel center. @param delta Value added to the filtered results before storing them. -@param borderType Pixel extrapolation method, see cv::BorderTypes +@param borderType Pixel extrapolation method, see #BorderTypes @sa filter2D, Sobel, GaussianBlur, boxFilter, blur */ CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth, @@ -1571,7 +1590,7 @@ calculate the derivative. When \f$\texttt{ksize = 1}\f$, the \f$3 \times 1\f$ or kernel is used (that is, no Gaussian smoothing is done). `ksize = 1` can only be used for the first or the second x- or y- derivatives. -There is also the special value `ksize = CV_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr +There is also the special value `ksize = #CV_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr filter that may give more accurate results than the \f$3\times3\f$ Sobel. The Scharr aperture is \f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f] @@ -1601,9 +1620,9 @@ The second case corresponds to a kernel of: @param dy order of the derivative y. @param ksize size of the extended Sobel kernel; it must be 1, 3, 5, or 7. @param scale optional scale factor for the computed derivative values; by default, no scaling is -applied (see cv::getDerivKernels for details). +applied (see #getDerivKernels for details). @param delta optional delta value that is added to the results prior to storing them in dst. -@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderType pixel extrapolation method, see #BorderTypes @sa Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar */ CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth, @@ -1624,7 +1643,7 @@ Sobel( src, dy, CV_16SC1, 0, 1, 3 ); @param dx output image with first-order derivative in x. @param dy output image with first-order derivative in y. @param ksize size of Sobel kernel. It must be 3. -@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderType pixel extrapolation method, see #BorderTypes @sa Sobel */ @@ -1642,7 +1661,7 @@ call is equivalent to -\f[\texttt{Sobel(src, dst, ddepth, dx, dy, CV\_SCHARR, scale, delta, borderType)} .\f] +\f[\texttt{Sobel(src, dst, ddepth, dx, dy, CV_SCHARR, scale, delta, borderType)} .\f] @param src input image. @param dst output image of the same size and the same number of channels as src. @@ -1650,9 +1669,9 @@ is equivalent to @param dx order of the derivative x. @param dy order of the derivative y. @param scale optional scale factor for the computed derivative values; by default, no scaling is -applied (see getDerivKernels for details). +applied (see #getDerivKernels for details). @param delta optional delta value that is added to the results prior to storing them in dst. -@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderType pixel extrapolation method, see #BorderTypes @sa cartToPolar */ CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth, @@ -1678,12 +1697,12 @@ with the following \f$3 \times 3\f$ aperture: @param src Source image. @param dst Destination image of the same size and the same number of channels as src . @param ddepth Desired depth of the destination image. -@param ksize Aperture size used to compute the second-derivative filters. See getDerivKernels for +@param ksize Aperture size used to compute the second-derivative filters. See #getDerivKernels for details. The size must be positive and odd. @param scale Optional scale factor for the computed Laplacian values. By default, no scaling is -applied. See getDerivKernels for details. +applied. See #getDerivKernels for details. @param delta Optional delta value that is added to the results prior to storing them in dst . -@param borderType Pixel extrapolation method, see cv::BorderTypes +@param borderType Pixel extrapolation method, see #BorderTypes @sa Sobel, Scharr */ CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth, @@ -1728,7 +1747,13 @@ Finds edges in an image using the Canny algorithm with custom image gradient. @param dx 16-bit x derivative of input image (CV_16SC1 or CV_16SC3). @param dy 16-bit y derivative of input image (same type as dx). -@param edges,threshold1,threshold2,L2gradient See cv::Canny +@param edges output edge map; single channels 8-bit image, which has the same size as image . +@param threshold1 first threshold for the hysteresis procedure. +@param threshold2 second threshold for the hysteresis procedure. +@param L2gradient a flag, indicating whether a more accurate \f$L_2\f$ norm +\f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( +L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( +L2gradient=false ). */ CV_EXPORTS_W void Canny( InputArray dx, InputArray dy, OutputArray edges, @@ -1744,9 +1769,9 @@ of the formulae in the cornerEigenValsAndVecs description. @param src Input single-channel 8-bit or floating-point image. @param dst Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src . -@param blockSize Neighborhood size (see the details on cornerEigenValsAndVecs ). +@param blockSize Neighborhood size (see the details on #cornerEigenValsAndVecs ). @param ksize Aperture parameter for the Sobel operator. -@param borderType Pixel extrapolation method. See cv::BorderTypes. +@param borderType Pixel extrapolation method. See #BorderTypes. */ CV_EXPORTS_W void cornerMinEigenVal( InputArray src, OutputArray dst, int blockSize, int ksize = 3, @@ -1766,10 +1791,10 @@ Corners in the image can be found as the local maxima of this response map. @param src Input single-channel 8-bit or floating-point image. @param dst Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src . -@param blockSize Neighborhood size (see the details on cornerEigenValsAndVecs ). +@param blockSize Neighborhood size (see the details on #cornerEigenValsAndVecs ). @param ksize Aperture parameter for the Sobel operator. @param k Harris detector free parameter. See the formula below. -@param borderType Pixel extrapolation method. See cv::BorderTypes. +@param borderType Pixel extrapolation method. See #BorderTypes. */ CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize, int ksize, double k, @@ -1797,7 +1822,7 @@ The output of the function can be used for robust edge or corner detection. @param dst Image to store the results. It has the same size as src and the type CV_32FC(6) . @param blockSize Neighborhood size (see details below). @param ksize Aperture parameter for the Sobel operator. -@param borderType Pixel extrapolation method. See cv::BorderTypes. +@param borderType Pixel extrapolation method. See #BorderTypes. @sa cornerMinEigenVal, cornerHarris, preCornerDetect */ @@ -1826,7 +1851,7 @@ The corners can be found as local maximums of the functions, as shown below: @param src Source single-channel 8-bit of floating-point image. @param dst Output image that has the type CV_32F and the same size as src . @param ksize %Aperture size of the Sobel . -@param borderType Pixel extrapolation method. See cv::BorderTypes. +@param borderType Pixel extrapolation method. See #BorderTypes. */ CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize, int borderType = BORDER_DEFAULT ); @@ -1881,7 +1906,7 @@ The function finds the most prominent corners in the image or in the specified i described in @cite Shi94 - Function calculates the corner quality measure at every source image pixel using the - cornerMinEigenVal or cornerHarris . + #cornerMinEigenVal or #cornerHarris . - Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained). - The corners with the minimal eigenvalue less than @@ -1903,7 +1928,7 @@ the strongest of them is returned. `maxCorners <= 0` implies that no limit on th and all detected corners are returned. @param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue -(see cornerMinEigenVal ) or the Harris function response (see cornerHarris ). The corners with the +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected. @@ -1912,8 +1937,8 @@ less than 15 are rejected. CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. @param blockSize Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs . -@param useHarrisDetector Parameter indicating whether to use a Harris detector (see cornerHarris) -or cornerMinEigenVal. +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. @param k Free parameter of the Harris detector. @sa cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform, @@ -2100,16 +2125,16 @@ search, and find the correct radius using an additional procedure. @param image 8-bit, single-channel, grayscale input image. @param circles Output vector of found circles. Each vector is encoded as a 3-element floating-point vector \f$(x, y, radius)\f$ . -@param method Detection method, see cv::HoughModes. Currently, the only implemented method is HOUGH_GRADIENT +@param method Detection method, see #HoughModes. Currently, the only implemented method is #HOUGH_GRADIENT @param dp Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height. @param minDist Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed. -@param param1 First method-specific parameter. In case of CV_HOUGH_GRADIENT , it is the higher +@param param1 First method-specific parameter. In case of #HOUGH_GRADIENT , it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). -@param param2 Second method-specific parameter. In case of CV_HOUGH_GRADIENT , it is the +@param param2 Second method-specific parameter. In case of #HOUGH_GRADIENT , it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first. @@ -2149,11 +2174,11 @@ case of multi-channel images, each channel is processed independently. CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. @param dst output image of the same size and type as src. @param kernel structuring element used for erosion; if `element=Mat()`, a `3 x 3` rectangular -structuring element is used. Kernel can be created using getStructuringElement. +structuring element is used. Kernel can be created using #getStructuringElement. @param anchor position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center. @param iterations number of times erosion is applied. -@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderType pixel extrapolation method, see #BorderTypes @param borderValue border value in case of a constant border @sa dilate, morphologyEx, getStructuringElement */ @@ -2178,13 +2203,13 @@ case of multi-channel images, each channel is processed independently. @param src input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. -@param dst output image of the same size and type as src\`. +@param dst output image of the same size and type as src. @param kernel structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular -structuring element is used. Kernel can be created using getStructuringElement +structuring element is used. Kernel can be created using #getStructuringElement @param anchor position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center. @param iterations number of times dilation is applied. -@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderType pixel extrapolation method, see #BorderTypes @param borderValue border value in case of a constant border @sa erode, morphologyEx, getStructuringElement */ @@ -2195,7 +2220,7 @@ CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel, /** @brief Performs advanced morphological transformations. -The function morphologyEx can perform advanced morphological transformations using an erosion and dilation as +The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as basic operations. Any of the operations can be done in-place. In case of multi-channel images, each channel is @@ -2204,12 +2229,12 @@ processed independently. @param src Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. @param dst Destination image of the same size and type as source image. -@param op Type of a morphological operation, see cv::MorphTypes -@param kernel Structuring element. It can be created using cv::getStructuringElement. +@param op Type of a morphological operation, see #MorphTypes +@param kernel Structuring element. It can be created using #getStructuringElement. @param anchor Anchor position with the kernel. Negative values mean that the anchor is at the kernel center. @param iterations Number of times erosion and dilation are applied. -@param borderType Pixel extrapolation method, see cv::BorderTypes +@param borderType Pixel extrapolation method, see #BorderTypes @param borderValue Border value in case of a constant border. The default value has a special meaning. @sa dilate, erode, getStructuringElement @@ -2244,8 +2269,8 @@ way: // specify fx and fy and let the function compute the destination image size. resize(src, dst, Size(), 0.5, 0.5, interpolation); @endcode -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 +To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to +enlarge an image, it will generally look best with c#INTER_CUBIC (slow) or #INTER_LINEAR (faster but still looks OK). @param src input image. @@ -2258,7 +2283,7 @@ src.size(), fx, and fy; the type of dst is the same as of src. \f[\texttt{(double)dsize.width/src.cols}\f] @param fy scale factor along the vertical axis; when it equals 0, it is computed as \f[\texttt{(double)dsize.height/src.rows}\f] -@param interpolation interpolation method, see cv::InterpolationFlags +@param interpolation interpolation method, see #InterpolationFlags @sa warpAffine, warpPerspective, remap */ @@ -2272,19 +2297,19 @@ The function warpAffine transforms the source image using the specified matrix: \f[\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\f] -when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted -with cv::invertAffineTransform and then put in the formula above instead of M. The function cannot +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted +with #invertAffineTransform and then put in the formula above instead of M. The function cannot operate in-place. @param src input image. @param dst output image that has the size dsize and the same type as src . @param M \f$2\times 3\f$ transformation matrix. @param dsize size of the output image. -@param flags combination of interpolation methods (see cv::InterpolationFlags) and the optional -flag WARP_INVERSE_MAP that means that M is the inverse transformation ( +@param flags combination of interpolation methods (see #InterpolationFlags) and the optional +flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( \f$\texttt{dst}\rightarrow\texttt{src}\f$ ). -@param borderMode pixel extrapolation method (see cv::BorderTypes); when -borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to +@param borderMode pixel extrapolation method (see #BorderTypes); when +borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function. @param borderValue value used in case of a constant border; by default, it is 0. @@ -2306,17 +2331,17 @@ The function warpPerspective transforms the source image using the specified mat \f[\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\f] -when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert and then put in the formula above instead of M. The function cannot operate in-place. @param src input image. @param dst output image that has the size dsize and the same type as src . @param M \f$3\times 3\f$ transformation matrix. @param dsize size of the output image. -@param flags combination of interpolation methods (INTER_LINEAR or INTER_NEAREST) and the -optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation ( +@param flags combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the +optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( \f$\texttt{dst}\rightarrow\texttt{src}\f$ ). -@param borderMode pixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE). +@param borderMode pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE). @param borderValue value used in case of a constant border; by default, it equals 0. @sa warpAffine, resize, remap, getRectSubPix, perspectiveTransform @@ -2350,10 +2375,10 @@ CV_32FC1, or CV_32FC2. See convertMaps for details on converting a floating poin representation to fixed-point for speed. @param map2 The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively. -@param interpolation Interpolation method (see cv::InterpolationFlags). The method INTER_AREA is +@param interpolation Interpolation method (see #InterpolationFlags). The method #INTER_AREA is not supported by this function. -@param borderMode Pixel extrapolation method (see cv::BorderTypes). When -borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image that +@param borderMode Pixel extrapolation method (see #BorderTypes). When +borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function. @param borderValue Value used in case of a constant border. By default, it is 0. @note @@ -2525,11 +2550,11 @@ rotation-invariant template matching, for object tracking and so forth. @param dst Destination image. It will have same size and type as src. @param center The transformation center; where the output precision is maximal @param M Magnitude scale parameter. It determines the radius of the bounding circle to transform too. -@param flags A combination of interpolation methods, see cv::InterpolationFlags +@param flags A combination of interpolation methods, see #InterpolationFlags @note - The function can not operate in-place. -- To calculate magnitude and angle in degrees @ref cv::cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. +- To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. */ CV_EXPORTS_W void logPolar( InputArray src, OutputArray dst, Point2f center, double M, int flags ); @@ -2563,11 +2588,11 @@ and @param dst Destination image. It will have same size and type as src. @param center The transformation center; @param maxRadius The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too. -@param flags A combination of interpolation methods, see cv::InterpolationFlags +@param flags A combination of interpolation methods, see #InterpolationFlags @note - The function can not operate in-place. -- To calculate magnitude and angle in degrees @ref cv::cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. +- To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. */ CV_EXPORTS_W void linearPolar( InputArray src, OutputArray dst, @@ -2770,25 +2795,24 @@ CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type); /** @brief Applies a fixed-level threshold to each array element. The function applies fixed-level thresholding to a multiple-channel array. The function is typically -used to get a bi-level (binary) image out of a grayscale image ( cv::compare could be also used for +used to get a bi-level (binary) image out of a grayscale image ( #compare could be also used for this purpose) or for removing a noise, that is, filtering out pixels with too small or too large values. There are several types of thresholding supported by the function. They are determined by type parameter. -Also, the special values cv::THRESH_OTSU or cv::THRESH_TRIANGLE may be combined with one of the +Also, the special values #THRESH_OTSU or #THRESH_TRIANGLE may be combined with one of the above values. In these cases, the function determines the optimal threshold value using the Otsu's -or Triangle algorithm and uses it instead of the specified thresh . The function returns the -computed threshold value. Currently, the Otsu's and Triangle methods are implemented only for 8-bit -images. +or Triangle algorithm and uses it instead of the specified thresh. -@note Input image should be single channel only in case of CV_THRESH_OTSU or CV_THRESH_TRIANGLE flags +@note Currently, the Otsu's and Triangle methods are implemented only for 8-bit single-channel images. @param src input array (multiple-channel, 8-bit or 32-bit floating point). @param dst output array of the same size and type and the same number of channels as src. @param thresh threshold value. -@param maxval maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding +@param maxval maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding types. -@param type thresholding type (see the cv::ThresholdTypes). +@param type thresholding type (see #ThresholdTypes). +@return the computed threshold value if Otsu's or Triangle methods used. @sa adaptiveThreshold, findContours, compare, min, max */ @@ -2810,10 +2834,10 @@ The function can process the image in-place. @param src Source 8-bit single-channel image. @param dst Destination image of the same size and the same type as src. @param maxValue Non-zero value assigned to the pixels for which the condition is satisfied -@param adaptiveMethod Adaptive thresholding algorithm to use, see cv::AdaptiveThresholdTypes. -The BORDER_REPLICATE | BORDER_ISOLATED is used to process boundaries. -@param thresholdType Thresholding type that must be either THRESH_BINARY or THRESH_BINARY_INV, -see cv::ThresholdTypes. +@param adaptiveMethod Adaptive thresholding algorithm to use, see #AdaptiveThresholdTypes. +The #BORDER_REPLICATE | #BORDER_ISOLATED is used to process boundaries. +@param thresholdType Thresholding type that must be either #THRESH_BINARY or #THRESH_BINARY_INV, +see #ThresholdTypes. @param blockSize Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on. @param C Constant subtracted from the mean or weighted mean (see the details below). Normally, it @@ -2850,7 +2874,7 @@ Then, it downsamples the image by rejecting even rows and columns. @param src input image. @param dst output image; it has the specified size and the same type as src. @param dstsize size of the output image. -@param borderType Pixel extrapolation method, see cv::BorderTypes (BORDER_CONSTANT isn't supported) +@param borderType Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported) */ CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst, const Size& dstsize = Size(), int borderType = BORDER_DEFAULT ); @@ -2870,7 +2894,7 @@ pyrDown multiplied by 4. @param src input image. @param dst output image. It has the specified size and the same type as src . @param dstsize size of the output image. -@param borderType Pixel extrapolation method, see cv::BorderTypes (only BORDER_DEFAULT is supported) +@param borderType Pixel extrapolation method, see #BorderTypes (only #BORDER_DEFAULT is supported) */ CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst, const Size& dstsize = Size(), int borderType = BORDER_DEFAULT ); @@ -2884,7 +2908,7 @@ pyrDown to the previously built pyramid layers, starting from `dst[0]==src`. @param dst Destination vector of maxlevel+1 images of the same type as src. dst[0] will be the same as src. dst[1] is the next pyramid layer, a smoothed and down-sized src, and so on. @param maxlevel 0-based index of the last (the smallest) pyramid layer. It must be non-negative. -@param borderType Pixel extrapolation method, see cv::BorderTypes (BORDER_CONSTANT isn't supported) +@param borderType Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported) */ CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst, int maxlevel, int borderType = BORDER_DEFAULT ); @@ -2898,7 +2922,7 @@ CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst, The function transforms an image to compensate radial and tangential lens distortion. -The function is simply a combination of cv::initUndistortRectifyMap (with unity R ) and cv::remap +The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap (with bilinear interpolation). See the former function for details of the transformation being performed. @@ -2906,10 +2930,10 @@ Those pixels in the destination image, for which there is no correspondent pixel 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 cv::getOptimalNewCameraMatrix to compute the appropriate +by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate newCameraMatrix depending on your requirements. -The camera matrix and the distortion parameters can be determined using cv::calibrateCamera. If +The camera matrix and the distortion parameters can be determined using #calibrateCamera. If the resolution of images is different from the resolution used at the calibration stage, \f$f_x, f_y, c_x\f$ and \f$c_y\f$ need to be scaled accordingly, while the distortion coefficients remain the same. @@ -2934,8 +2958,8 @@ The function computes the joint undistortion and rectification transformation an result in the form of maps for 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 -cv::getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera, -newCameraMatrix is normally set to P1 or P2 computed by cv::stereoRectify . +#getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera, +newCameraMatrix is normally set to P1 or P2 computed by #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 @@ -2969,9 +2993,9 @@ where \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x are the distortion coefficients. In case of a stereo camera, this function is called twice: once for each camera head, after -stereoRectify, which in its turn is called after cv::stereoCalibrate. But if the stereo camera +stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from -the fundamental matrix using cv::stereoRectifyUncalibrated. For each camera, the function computes +the fundamental matrix using #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 \f[\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\f] @@ -2982,11 +3006,11 @@ where cameraMatrix can be chosen arbitrarily. \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of 4, 5, 8, 12 or 14 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 stereoRectify can be passed here. If the matrix is empty, the identity transformation +computed by #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 \f$A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\f$. @param size Undistorted image size. -@param m1type Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see cv::convertMaps +@param m1type Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps @param map1 The first output map. @param map2 The second output map. */ @@ -2994,7 +3018,7 @@ CV_EXPORTS_W void initUndistortRectifyMap( InputArray cameraMatrix, InputArray d InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2 ); -//! initializes maps for cv::remap() for wide-angle +//! initializes maps for #remap for wide-angle CV_EXPORTS_W float initWideAngleProjMap( InputArray cameraMatrix, InputArray distCoeffs, Size imageSize, int destImageWidth, int m1type, OutputArray map1, OutputArray map2, @@ -3011,7 +3035,7 @@ In the latter case, the new camera matrix will be: where \f$f_x\f$ and \f$f_y\f$ are \f$(0,0)\f$ and \f$(1,1)\f$ elements of cameraMatrix, respectively. -By default, the undistortion functions in OpenCV (see initUndistortRectifyMap, undistort) do not +By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #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 @@ -3027,7 +3051,7 @@ CV_EXPORTS_W Mat getDefaultNewCameraMatrix( InputArray cameraMatrix, Size imgsiz /** @brief Computes the ideal point coordinates from the observed point coordinates. -The function is similar to cv::undistort and cv::initUndistortRectifyMap but it operates on a +The function is similar to #undistort and #initUndistortRectifyMap but it operates on a sparse set of points instead of a raster image. Also the function performs a reverse transformation to 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. @@ -3061,15 +3085,15 @@ transformation. If matrix P is identity or omitted, dst will contain normalized \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of 4, 5, 8, 12 or 14 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 -cv::stereoRectify can be passed here. If the matrix is empty, the identity transformation is used. +#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) \f$\begin{bmatrix} {f'}_x & 0 & {c'}_x & t_x \\ 0 & {f'}_y & {c'}_y & t_y \\ 0 & 0 & 1 & t_z \end{bmatrix}\f$. P1 or P2 computed by -cv::stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used. +#stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used. */ CV_EXPORTS_W void undistortPoints( InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray R = noArray(), InputArray P = noArray()); /** @overload - @note Default version of cv::undistortPoints does 5 iterations to compute undistorted points. + @note Default version of #undistortPoints does 5 iterations to compute undistorted points. */ CV_EXPORTS_AS(undistortPointsIter) void undistortPoints( InputArray src, OutputArray dst, @@ -3181,7 +3205,7 @@ CV_EXPORTS void calcHist( const Mat* images, int nimages, /** @overload -this variant uses cv::SparseMat for output +this variant uses %SparseMat for output */ CV_EXPORTS void calcHist( const Mat* images, int nimages, const int* channels, InputArray mask, @@ -3200,7 +3224,7 @@ CV_EXPORTS_W void calcHist( InputArrayOfArrays images, /** @brief Calculates the back projection of a histogram. The function cv::calcBackProject calculates the back project of the histogram. That is, similarly to -cv::calcHist , at each location (x, y) the function collects the values from the selected channels +#calcHist , at each location (x, y) the function collects the values from the selected channels in the input images and finds the corresponding histogram bin. But instead of incrementing it, the function reads the bin value, scales it by scale , and stores in backProject(x,y) . In terms of statistics, the function computes probability of each element value in respect with the empirical @@ -3230,11 +3254,11 @@ images[0].channels() + images[1].channels()-1, and so on. @param hist Input histogram that can be dense or sparse. @param backProject Destination back projection array that is a single-channel array of the same size and depth as images[0] . -@param ranges Array of arrays of the histogram bin boundaries in each dimension. See cv::calcHist . +@param ranges Array of arrays of the histogram bin boundaries in each dimension. See #calcHist . @param scale Optional scale factor for the output back projection. @param uniform Flag indicating whether the histogram is uniform or not (see above). -@sa cv::calcHist, cv::compareHist +@sa calcHist, compareHist */ CV_EXPORTS void calcBackProject( const Mat* images, int nimages, const int* channels, InputArray hist, @@ -3262,11 +3286,11 @@ The function returns \f$d(H_1, H_2)\f$ . While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms -or more general sparse configurations of weighted points, consider using the cv::EMD function. +or more general sparse configurations of weighted points, consider using the #EMD function. @param H1 First compared histogram. @param H2 Second compared histogram of the same size as H1 . -@param method Comparison method, see cv::HistCompMethods +@param method Comparison method, see #HistCompMethods */ CV_EXPORTS_W double compareHist( InputArray H1, InputArray H2, int method ); @@ -3309,7 +3333,7 @@ non-negative and have at least one non-zero value. may be different. The total weights may be different. In this case an extra "dummy" point is added to either signature1 or signature2. The weights must be non-negative and have at least one non-zero value. -@param distType Used metric. See cv::DistanceTypes. +@param distType Used metric. See #DistanceTypes. @param cost User-defined \f$\texttt{size1}\times \texttt{size2}\f$ cost matrix. Also, if a cost matrix is used, lower boundary lowerBound cannot be calculated because it needs a metric function. @param lowerBound Optional input/output parameter: lower boundary of a distance between the two @@ -3346,7 +3370,7 @@ algorithm, described in @cite Meyer92 . Before passing the image to the function, you have to roughly outline the desired regions in the image markers with positive (\>0) indices. So, every region is represented as one or more connected components with the pixel values 1, 2, 3, and so on. Such markers can be retrieved from a binary -mask using findContours and drawContours (see the watershed.cpp demo). The markers are "seeds" of +mask using #findContours and #drawContours (see the watershed.cpp demo). The markers are "seeds" of the future image regions. All the other pixels in markers , whose relation to the outlined regions is not known and should be defined by the algorithm, should be set to 0's. In the function output, each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the @@ -3425,17 +3449,17 @@ The function implements the [GrabCut image segmentation algorithm](http://en.wik @param img Input 8-bit 3-channel image. @param mask Input/output 8-bit single-channel mask. The mask is initialized by the function when -mode is set to GC_INIT_WITH_RECT. Its elements may have one of the cv::GrabCutClasses. +mode is set to #GC_INIT_WITH_RECT. Its elements may have one of the #GrabCutClasses. @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 . +"obvious background". The parameter is only used when mode==#GC_INIT_WITH_RECT . @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 +that the result can be refined with further calls with mode==#GC_INIT_WITH_MASK or mode==GC_EVAL . -@param mode Operation mode that could be one of the cv::GrabCutModes +@param mode Operation mode that could be one of the #GrabCutModes */ CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect, InputOutputArray bgdModel, InputOutputArray fgdModel, @@ -3451,7 +3475,7 @@ An example on using the distance transform\ The function cv::distanceTransform calculates the approximate or precise distance from every binary image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero. -When maskSize == DIST_MASK_PRECISE and distanceType == DIST_L2 , the function runs the +When maskSize == #DIST_MASK_PRECISE and distanceType == #DIST_L2 , the function runs the algorithm described in @cite Felzenszwalb04 . This algorithm is parallelized with the TBB library. In other cases, the algorithm @cite Borgefors86 is used. This means that for a pixel the function @@ -3460,8 +3484,8 @@ diagonal, or knight's move (the latest is available for a \f$5\times 5\f$ mask). distance is calculated as a sum of these basic distances. Since the distance function should be symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a ), all the diagonal shifts must have the same cost (denoted as `b`), and all knight's moves must have the -same cost (denoted as `c`). For the cv::DIST_C and cv::DIST_L1 types, the distance is calculated -precisely, whereas for cv::DIST_L2 (Euclidean distance) the distance can be calculated only with a +same cost (denoted as `c`). For the #DIST_C and #DIST_L1 types, the distance is calculated +precisely, whereas for #DIST_L2 (Euclidean distance) the distance can be calculated only with a relative error (a \f$5\times 5\f$ mask gives more accurate results). For `a`,`b`, and `c`, OpenCV uses the values suggested in the original paper: - DIST_L1: `a = 1, b = 2` @@ -3470,21 +3494,21 @@ uses the values suggested in the original paper: - `5 x 5`: `a=1, b=1.4, c=2.1969` - DIST_C: `a = 1, b = 1` -Typically, for a fast, coarse distance estimation DIST_L2, a \f$3\times 3\f$ mask is used. For a -more accurate distance estimation DIST_L2, a \f$5\times 5\f$ mask or the precise algorithm is used. +Typically, for a fast, coarse distance estimation #DIST_L2, a \f$3\times 3\f$ mask is used. For a +more accurate distance estimation #DIST_L2, a \f$5\times 5\f$ mask or the precise algorithm is used. Note that both the precise and the approximate algorithms are linear on the number of pixels. This variant of the function does not only compute the minimum distance for each pixel \f$(x, y)\f$ but also identifies the nearest connected component consisting of zero pixels -(labelType==DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==DIST_LABEL_PIXEL). Index of the -component/pixel is stored in `labels(x, y)`. When labelType==DIST_LABEL_CCOMP, the function +(labelType==#DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==#DIST_LABEL_PIXEL). Index of the +component/pixel is stored in `labels(x, y)`. When labelType==#DIST_LABEL_CCOMP, the function automatically finds connected components of zero pixels in the input image and marks them with -distinct labels. When labelType==DIST_LABEL_CCOMP, the function scans through the input image and +distinct labels. When labelType==#DIST_LABEL_CCOMP, the function scans through the input image and marks all the zero pixels with distinct labels. In this mode, the complexity is still linear. That is, the function provides a very fast way to compute the Voronoi diagram for a binary image. Currently, the second variant can use only the -approximate distance transform algorithm, i.e. maskSize=DIST_MASK_PRECISE is not supported +approximate distance transform algorithm, i.e. maskSize=#DIST_MASK_PRECISE is not supported yet. @param src 8-bit, single-channel (binary) source image. @@ -3492,12 +3516,12 @@ yet. single-channel image of the same size as src. @param labels Output 2D array of labels (the discrete Voronoi diagram). It has the type CV_32SC1 and the same size as src. -@param distanceType Type of distance, see cv::DistanceTypes -@param maskSize Size of the distance transform mask, see cv::DistanceTransformMasks. -DIST_MASK_PRECISE is not supported by this variant. In case of the DIST_L1 or DIST_C distance type, +@param distanceType Type of distance, see #DistanceTypes +@param maskSize Size of the distance transform mask, see #DistanceTransformMasks. +#DIST_MASK_PRECISE is not supported by this variant. In case of the #DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \f$3\times 3\f$ mask gives the same result as \f$5\times 5\f$ or any larger aperture. -@param labelType Type of the label array to build, see cv::DistanceTransformLabelTypes. +@param labelType Type of the label array to build, see #DistanceTransformLabelTypes. */ CV_EXPORTS_AS(distanceTransformWithLabels) void distanceTransform( InputArray src, OutputArray dst, OutputArray labels, int distanceType, int maskSize, @@ -3507,12 +3531,12 @@ CV_EXPORTS_AS(distanceTransformWithLabels) void distanceTransform( InputArray sr @param src 8-bit, single-channel (binary) source image. @param dst Output image with calculated distances. It is a 8-bit or 32-bit floating-point, single-channel image of the same size as src . -@param distanceType Type of distance, see cv::DistanceTypes -@param maskSize Size of the distance transform mask, see cv::DistanceTransformMasks. In case of the -DIST_L1 or DIST_C distance type, the parameter is forced to 3 because a \f$3\times 3\f$ mask gives +@param distanceType Type of distance, see #DistanceTypes +@param maskSize Size of the distance transform mask, see #DistanceTransformMasks. In case of the +#DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \f$3\times 3\f$ mask gives the same result as \f$5\times 5\f$ or any larger aperture. @param dstType Type of output image. It can be CV_8U or CV_32F. Type CV_8U can be used only for -the first variant of the function and distanceType == DIST_L1. +the first variant of the function and distanceType == #DIST_L1. */ CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst, int distanceType, int maskSize, int dstType=CV_32F); @@ -3569,7 +3593,7 @@ Use these functions to either mark a connected component with the specified colo a mask and then extract the contour, or copy the region to another image, and so on. @param image Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the -function unless the FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See +function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See the details below. @param mask Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller than image. Since this is both an input and output parameter, you must take responsibility @@ -3594,7 +3618,7 @@ will be considered. The next 8 bits (8-16) contain a value between 1 and 255 wit the mask (the default value is 1). For example, 4 | ( 255 \<\< 8 ) will consider 4 nearest neighbours and fill the mask with a value of 255. The following additional options occupy higher bits and therefore may be further combined with the connectivity and mask fill values using -bit-wise or (|), see cv::FloodFillFlags. +bit-wise or (|), see #FloodFillFlags. @note Since the mask is larger than the filled image, a pixel \f$(x, y)\f$ in image corresponds to the pixel \f$(x+1, y+1)\f$ in the mask . @@ -3624,13 +3648,13 @@ In case of linear transformations, the range does not matter. But in case of a n transformation, an input RGB image should be normalized to the proper value range to get the correct results, for example, for RGB \f$\rightarrow\f$ L\*u\*v\* transformation. For example, if you have a 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will -have the 0..255 value range instead of 0..1 assumed by the function. So, before calling cvtColor , +have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor , you need first to scale the image down: @code img *= 1./255; cvtColor(img, img, COLOR_BGR2Luv); @endcode -If you use cvtColor with 8-bit images, the conversion will have some information lost. For many +If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many applications, this will not be noticeable but it is recommended to use 32-bit images in applications that need the full range of colors or that convert an image before an operation and then convert back. @@ -3641,7 +3665,7 @@ range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F. @param src input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision floating-point. @param dst output image of the same size and depth as src. -@param code color space conversion code (see cv::ColorConversionCodes). +@param code color space conversion code (see #ColorConversionCodes). @param dstCn number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code. @@ -3727,8 +3751,8 @@ for the available comparison methods ( \f$I\f$ denotes image, \f$T\f$ template, is done over template and/or the image patch: \f$x' = 0...w-1, y' = 0...h-1\f$ After the function finishes the comparison, the best matches can be found as global minimums (when -TM_SQDIFF was used) or maximums (when TM_CCORR or TM_CCOEFF was used) using the -minMaxLoc function. In case of a color image, template summation in the numerator and each sum in +#TM_SQDIFF was used) or maximums (when #TM_CCORR or #TM_CCOEFF was used) using the +#minMaxLoc function. In case of a color image, template summation in the numerator and each sum in the denominator is done over all of the channels and separate mean values are used for each channel. That is, the function can take a color template and a color image. The result will still be a single-channel image, which is easier to analyze. @@ -3738,9 +3762,9 @@ single-channel image, which is easier to analyze. data type. @param result Map of comparison results. It must be single-channel 32-bit floating-point. If image is \f$W \times H\f$ and templ is \f$w \times h\f$ , then result is \f$(W-w+1) \times (H-h+1)\f$ . -@param method Parameter specifying the comparison method, see cv::TemplateMatchModes +@param method Parameter specifying the comparison method, see #TemplateMatchModes @param mask Mask of searched template. It must have the same datatype and size with templ. It is -not set by default. Currently, only the TM_SQDIFF and TM_CCORR_NORMED methods are supported. +not set by default. Currently, only the #TM_SQDIFF and #TM_CCORR_NORMED methods are supported. */ CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ, OutputArray result, int method, InputArray mask = noArray() ); @@ -3756,16 +3780,16 @@ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N represents the background label. ltype specifies the output label image type, an important consideration based on the total number of labels or alternatively the total number of pixels in the source image. ccltype specifies the connected components labeling algorithm to use, currently -Grana (BBDT) and Wu's (SAUF) algorithms are supported, see the cv::ConnectedComponentsAlgorithmsTypes +Grana (BBDT) and Wu's (SAUF) algorithms are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces a row major ordering of labels while BBDT does not. This function uses parallel version of both Grana and Wu's algorithms if at least one allowed -parallel framework is enabled and if the rows of the image are at least twice the number returned by getNumberOfCPUs. +parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs. @param image the 8-bit single-channel image to be labeled @param labels destination labeled image @param connectivity 8 or 4 for 8-way or 4-way connectivity respectively @param ltype output image label type. Currently CV_32S and CV_16U are supported. -@param ccltype connected components algorithm type (see the cv::ConnectedComponentsAlgorithmsTypes). +@param ccltype connected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes). */ CV_EXPORTS_AS(connectedComponentsWithAlgorithm) int connectedComponents(InputArray image, OutputArray labels, int connectivity, int ltype, int ccltype); @@ -3788,21 +3812,21 @@ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N represents the background label. ltype specifies the output label image type, an important consideration based on the total number of labels or alternatively the total number of pixels in the source image. ccltype specifies the connected components labeling algorithm to use, currently -Grana's (BBDT) and Wu's (SAUF) algorithms are supported, see the cv::ConnectedComponentsAlgorithmsTypes +Grana's (BBDT) and Wu's (SAUF) algorithms are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces a row major ordering of labels while BBDT does not. This function uses parallel version of both Grana and Wu's algorithms (statistics included) if at least one allowed -parallel framework is enabled and if the rows of the image are at least twice the number returned by getNumberOfCPUs. +parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs. @param image the 8-bit single-channel image to be labeled @param labels destination labeled image @param stats statistics output for each label, including the background label, see below for available statistics. Statistics are accessed via stats(label, COLUMN) where COLUMN is one of -cv::ConnectedComponentsTypes. The data type is CV_32S. +#ConnectedComponentsTypes. The data type is CV_32S. @param centroids centroid output for each label, including the background label. Centroids are accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F. @param connectivity 8 or 4 for 8-way or 4-way connectivity respectively @param ltype output image label type. Currently CV_32S and CV_16U are supported. -@param ccltype connected components algorithm type (see the cv::ConnectedComponentsAlgorithmsTypes). +@param ccltype connected components algorithm type (see #ConnectedComponentsAlgorithmsTypes). */ CV_EXPORTS_AS(connectedComponentsWithStatsWithAlgorithm) int connectedComponentsWithStats(InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, @@ -3813,7 +3837,7 @@ CV_EXPORTS_AS(connectedComponentsWithStatsWithAlgorithm) int connectedComponents @param labels destination labeled image @param stats statistics output for each label, including the background label, see below for available statistics. Statistics are accessed via stats(label, COLUMN) where COLUMN is one of -cv::ConnectedComponentsTypes. The data type is CV_32S. +#ConnectedComponentsTypes. The data type is CV_32S. @param centroids centroid output for each label, including the background label. Centroids are accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F. @param connectivity 8 or 4 for 8-way or 4-way connectivity respectively @@ -3832,9 +3856,9 @@ OpenCV sample directory. @note Since opencv 3.2 source image is not modified by this function. @param image Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero -pixels remain 0's, so the image is treated as binary . You can use cv::compare, cv::inRange, cv::threshold , -cv::adaptiveThreshold, cv::Canny, and others to create a binary image out of a grayscale or color one. -If mode equals to cv::RETR_CCOMP or cv::RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1). +pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold , +#adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one. +If mode equals to #RETR_CCOMP or #RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1). @param contours Detected contours. Each contour is stored as a vector of points (e.g. std::vector >). @param hierarchy Optional output vector (e.g. std::vector), containing information about the image topology. It has @@ -3843,8 +3867,8 @@ hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are se in contours of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative. -@param mode Contour retrieval mode, see cv::RetrievalModes -@param method Contour approximation method, see cv::ContourApproximationModes +@param mode Contour retrieval mode, see #RetrievalModes +@param method Contour approximation method, see #ContourApproximationModes @param offset Optional offset by which every contour point is shifted. This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context. @@ -3895,7 +3919,7 @@ CV_EXPORTS_W Rect boundingRect( InputArray points ); The function computes a contour area. Similarly to moments , the area is computed using the Green formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using -drawContours or fillPoly , can be different. Also, the function will most certainly give a wrong +#drawContours or #fillPoly , can be different. Also, the function will most certainly give a wrong results for contours with self-intersections. Example: @@ -3936,10 +3960,8 @@ CV_EXPORTS_W RotatedRect minAreaRect( InputArray points ); /** @brief Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle. The function finds the four vertices of a rotated rectangle. This function is useful to draw the -rectangle. In C++, instead of using this function, you can directly use box.points() method. Please -visit the [tutorial on bounding -rectangle](http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.html#bounding-rects-circles) -for more information. +rectangle. In C++, instead of using this function, you can directly use RotatedRect::points method. Please +visit the @ref tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information. @param box The input rotated rectangle. It may be the output of @param points The output array of four vertices of rectangles. @@ -3970,9 +3992,9 @@ area. The output for a given 2D point set is shown in the image below. 2D points The implementation of the algorithm is based on O'Rourke's @cite ORourke86 and Klee and Laskowski's @cite KleeLaskowski85 papers. O'Rourke provides a \f$\theta(n)\f$ algorithm for finding the minimal -enclosing triangle of a 2D convex polygon with n vertices. Since the minEnclosingTriangle function +enclosing triangle of a 2D convex polygon with n vertices. Since the #minEnclosingTriangle function takes a 2D point set as input an additional preprocessing step of computing the convex hull of the -2D point set is required. The complexity of the convexHull function is \f$O(n log(n))\f$ which is higher +2D point set is required. The complexity of the #convexHull function is \f$O(n log(n))\f$ which is higher than \f$\theta(n)\f$. Thus the overall complexity of the function is \f$O(n log(n))\f$. @param points Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector\<\> or Mat @@ -3983,11 +4005,11 @@ CV_EXPORTS_W double minEnclosingTriangle( InputArray points, CV_OUT OutputArray /** @brief Compares two shapes. -The function compares two shapes. All three implemented methods use the Hu invariants (see cv::HuMoments) +The function compares two shapes. All three implemented methods use the Hu invariants (see #HuMoments) @param contour1 First contour or grayscale image. @param contour2 Second contour or grayscale image. -@param method Comparison method, see cv::ShapeMatchModes +@param method Comparison method, see #ShapeMatchModes @param parameter Method-specific parameter (not supported now). */ CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2, @@ -4000,8 +4022,7 @@ An example using the convexHull functionality /** @brief Finds the convex hull of a point set. The function cv::convexHull finds the convex hull of a 2D point set using the Sklansky's algorithm @cite Sklansky82 -that has *O(N logN)* complexity in the current implementation. See the OpenCV sample convexhull.cpp -that demonstrates the usage of different function variants. +that has *O(N logN)* complexity in the current implementation. @param points Input 2D point set, stored in std::vector or Mat. @param hull Output convex hull. It is either an integer vector of indices or vector of points. In @@ -4032,7 +4053,7 @@ The figure below displays convexity defects of a hand contour: @param convexhull Convex hull obtained using convexHull that should contain indices of the contour points that make the hull. @param convexityDefects The output vector of convexity defects. In C++ and the new Python/Java -interface each convexity defect is represented as 4-element integer vector (a.k.a. cv::Vec4i): +interface each convexity defect is represented as 4-element integer vector (a.k.a. #Vec4i): (start_index, end_index, farthest_pt_index, fixpt_depth), where indices are 0-based indices in the original contour of the convexity defect beginning, end and the farthest point, and fixpt_depth is fixed-point approximation (with 8 fractional bits) of the distance between the @@ -4081,7 +4102,7 @@ CV_EXPORTS_W RotatedRect fitEllipse( InputArray points ); However, to specify an ellipse, all that is needed is five numbers; the major and minor axes lengths \f$ (a,b) \f$, the position \f$ (x_0,y_0) \f$, and the orientation \f$ \theta \f$. This is because the basis set includes lines, quadratics, parabolic and hyperbolic functions as well as elliptical functions as possible fits. - If the fit is found to be a parabolic or hyperbolic function then the standard fitEllipse method is used. + If the fit is found to be a parabolic or hyperbolic function then the standard #fitEllipse method is used. The AMS method restricts the fit to parabolic, hyperbolic and elliptical curves by imposing the condition that \f$ A^T ( D_x^T D_x + D_y^T D_y) A = 1 \f$ where the matrices \f$ Dx \f$ and \f$ Dy \f$ are the partial derivatives of the design matrix \f$ D \f$ with @@ -4180,7 +4201,7 @@ weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ . (x0, y0) is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line and (x0, y0, z0) is a point on the line. -@param distType Distance used by the M-estimator, see cv::DistanceTypes +@param distType Distance used by the M-estimator, see #DistanceTypes @param param Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value is chosen. @param reps Sufficient accuracy for the radius (distance between the coordinate origin and the line). @@ -4220,12 +4241,17 @@ intersecting region and the red vertices are returned by the function. @param rect2 Second rectangle @param intersectingRegion The output array of the vertices of the intersecting region. It returns at most 8 vertices. Stored as std::vector\ or cv::Mat as Mx1 of type CV_32FC2. -@returns One of cv::RectanglesIntersectTypes +@returns One of #RectanglesIntersectTypes */ CV_EXPORTS_W int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion ); //! @} imgproc_shape +/** @brief Creates implementation for cv::CLAHE . +@param clipLimit Threshold for contrast limiting. +@param tileGridSize Size of grid for histogram equalization. Input image will be divided into +equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column. + */ CV_EXPORTS_W Ptr createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8)); //! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122. @@ -4273,7 +4299,7 @@ An example using applyColorMap function @param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3. @param dst The result is the colormapped source image. Note: Mat::create is called on dst. -@param colormap The colormap to apply, see cv::ColormapTypes +@param colormap The colormap to apply, see #ColormapTypes */ CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap); @@ -4302,7 +4328,7 @@ lines are drawn using Gaussian filtering. @param pt2 Second point of the line segment. @param color Line color. @param thickness Line thickness. -@param lineType Type of the line, see cv::LineTypes. +@param lineType Type of the line. See #LineTypes. @param shift Number of fractional bits in the point coordinates. */ CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color, @@ -4310,14 +4336,14 @@ CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& /** @brief Draws a arrow segment pointing from the first point to the second one. -The function arrowedLine draws an arrow between pt1 and pt2 points in the image. See also cv::line. +The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line. @param img Image. @param pt1 The point the arrow starts from. @param pt2 The point the arrow points to. @param color Line color. @param thickness Line thickness. -@param line_type Type of the line, see cv::LineTypes +@param line_type Type of the line. See #LineTypes @param shift Number of fractional bits in the point coordinates. @param tipLength The length of the arrow tip in relation to the arrow length */ @@ -4326,16 +4352,16 @@ CV_EXPORTS_W void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const /** @brief Draws a simple, thick, or filled up-right rectangle. -The function rectangle draws a rectangle outline or a filled rectangle whose two opposite corners +The function cv::rectangle draws a rectangle outline or a filled rectangle whose two opposite corners are pt1 and pt2. @param img Image. @param pt1 Vertex of the rectangle. @param pt2 Vertex of the rectangle opposite to pt1 . @param color Rectangle color or brightness (grayscale image). -@param thickness Thickness of lines that make up the rectangle. Negative values, like CV_FILLED , +@param thickness Thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle. -@param lineType Type of the line. See the line description. +@param lineType Type of the line. See #LineTypes @param shift Number of fractional bits in the point coordinates. */ CV_EXPORTS_W void rectangle(InputOutputArray img, Point pt1, Point pt2, @@ -4356,14 +4382,14 @@ An example using drawing functions */ /** @brief Draws a circle. -The function circle draws a simple or filled circle with a given center and radius. +The function cv::circle draws a simple or filled circle with a given center and radius. @param img Image where the circle is drawn. @param center Center of the circle. @param radius Radius of the circle. @param color Circle color. -@param thickness Thickness of the circle outline, if positive. Negative thickness means that a -filled circle is to be drawn. -@param lineType Type of the circle boundary. See the line description. +@param thickness Thickness of the circle outline, if positive. Negative values, like #FILLED, +mean that a filled circle is to be drawn. +@param lineType Type of the circle boundary. See #LineTypes @param shift Number of fractional bits in the coordinates of the center and in the radius value. */ CV_EXPORTS_W void circle(InputOutputArray img, Point center, int radius, @@ -4376,7 +4402,7 @@ The function cv::ellipse with more parameters draws an ellipse outline, a filled arc, or a filled ellipse sector. The drawing code uses general parametric form. A piecewise-linear curve is used to approximate the elliptic arc boundary. If you need more control of the ellipse rendering, you can retrieve the curve using -cv::ellipse2Poly and then render it with polylines or fill it with cv::fillPoly. If you use the first +#ellipse2Poly and then render it with #polylines or fill it with #fillPoly. If you use the first variant of the function and want to draw the whole ellipse, not an arc, pass `startAngle=0` and `endAngle=360`. If `startAngle` is greater than `endAngle`, they are swapped. The figure below explains the meaning of the parameters to draw the blue arc. @@ -4392,7 +4418,7 @@ the meaning of the parameters to draw the blue arc. @param color Ellipse color. @param thickness Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn. -@param lineType Type of the ellipse boundary. See the line description. +@param lineType Type of the ellipse boundary. See #LineTypes @param shift Number of fractional bits in the coordinates of the center and values of axes. */ CV_EXPORTS_W void ellipse(InputOutputArray img, Point center, Size axes, @@ -4407,7 +4433,7 @@ an ellipse inscribed in the rotated rectangle. @param color Ellipse color. @param thickness Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn. -@param lineType Type of the ellipse boundary. See the line description. +@param lineType Type of the ellipse boundary. See #LineTypes */ CV_EXPORTS_W void ellipse(InputOutputArray img, const RotatedRect& box, const Scalar& color, int thickness = 1, int lineType = LINE_8); @@ -4430,15 +4456,15 @@ enum MarkerTypes /** @brief Draws a marker on a predefined position in an image. -The function drawMarker draws a marker on a given position in the image. For the moment several -marker types are supported, see cv::MarkerTypes for more information. +The function cv::drawMarker draws a marker on a given position in the image. For the moment several +marker types are supported, see #MarkerTypes for more information. @param img Image. @param position The point where the crosshair is positioned. @param color Line color. -@param markerType The specific type of marker you want to use, see cv::MarkerTypes +@param markerType The specific type of marker you want to use, see #MarkerTypes @param thickness Line thickness. -@param line_type Type of the line, see cv::LineTypes +@param line_type Type of the line, See #LineTypes @param markerSize The length of the marker axis [default = 20 pixels] */ CV_EXPORTS_W void drawMarker(CV_IN_OUT Mat& img, Point position, const Scalar& color, @@ -4456,15 +4482,15 @@ CV_EXPORTS void fillConvexPoly(Mat& img, const Point* pts, int npts, /** @brief Fills a convex polygon. -The function fillConvexPoly draws a filled convex polygon. This function is much faster than the -function cv::fillPoly . It can fill not only convex polygons but any monotonic polygon without +The function cv::fillConvexPoly draws a filled convex polygon. This function is much faster than the +function #fillPoly . It can fill not only convex polygons but any monotonic polygon without self-intersections, that is, a polygon whose contour intersects every horizontal line (scan line) twice at the most (though, its top-most and/or the bottom edge could be horizontal). @param img Image. @param points Polygon vertices. @param color Polygon color. -@param lineType Type of the polygon boundaries. See the line description. +@param lineType Type of the polygon boundaries. See #LineTypes @param shift Number of fractional bits in the vertex coordinates. */ CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray points, @@ -4482,14 +4508,14 @@ An example using drawing functions */ /** @brief Fills the area bounded by one or more polygons. -The function fillPoly fills an area bounded by several polygonal contours. The function can fill +The function cv::fillPoly fills an area bounded by several polygonal contours. The function can fill complex areas, for example, areas with holes, contours with self-intersections (some of their parts), and so forth. @param img Image. @param pts Array of polygons where each polygon is represented as an array of points. @param color Polygon color. -@param lineType Type of the polygon boundaries. See the line description. +@param lineType Type of the polygon boundaries. See #LineTypes @param shift Number of fractional bits in the vertex coordinates. @param offset Optional offset of all points of the contours. */ @@ -4510,10 +4536,10 @@ CV_EXPORTS void polylines(Mat& img, const Point* const* pts, const int* npts, the function draws a line from the last vertex of each curve to its first vertex. @param color Polyline color. @param thickness Thickness of the polyline edges. -@param lineType Type of the line segments. See the line description. +@param lineType Type of the line segments. See #LineTypes @param shift Number of fractional bits in the vertex coordinates. -The function polylines draws one or more polygonal curves. +The function cv::polylines draws one or more polygonal curves. */ CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts, bool isClosed, const Scalar& color, @@ -4580,8 +4606,8 @@ connected components from the binary image and label them: : @param contourIdx Parameter indicating a contour to draw. If it is negative, all the contours are drawn. @param color Color of the contours. @param thickness Thickness of lines the contours are drawn with. If it is negative (for example, -thickness=CV_FILLED ), the contour interiors are drawn. -@param lineType Line connectivity. See cv::LineTypes. +thickness=#FILLED ), the contour interiors are drawn. +@param lineType Line connectivity. See #LineTypes @param hierarchy Optional information about hierarchy. It is only needed if you want to draw only some of the contours (see maxLevel ). @param maxLevel Maximal level for drawn contours. If it is 0, only the specified contour is drawn. @@ -4590,10 +4616,10 @@ draws the contours, all the nested contours, all the nested-to-nested contours, parameter is only taken into account when there is hierarchy available. @param offset Optional contour shift parameter. Shift all the drawn contours by the specified \f$\texttt{offset}=(dx,dy)\f$ . -@note When thickness=CV_FILLED, the function is designed to handle connected components with holes correctly +@note When thickness=#FILLED, the function is designed to handle connected components with holes correctly even when no hierarchy date is provided. This is done by analyzing all the outlines together using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved -contours. In order to solve this problem, you need to call drawContours separately for each sub-group +contours. In order to solve this problem, you need to call #drawContours separately for each sub-group of contours, or iterate over the collection using contourIdx parameter. */ CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours, @@ -4630,11 +4656,11 @@ CV_EXPORTS_W bool clipLine(Rect imgRect, CV_OUT CV_IN_OUT Point& pt1, CV_OUT CV_ /** @brief Approximates an elliptic arc with a polyline. The function ellipse2Poly computes the vertices of a polyline that approximates the specified -elliptic arc. It is used by cv::ellipse. If `arcStart` is greater than `arcEnd`, they are swapped. +elliptic arc. It is used by #ellipse. If `arcStart` is greater than `arcEnd`, they are swapped. @param center Center of the arc. -@param axes Half of the size of the ellipse main axes. See the ellipse for details. -@param angle Rotation angle of the ellipse in degrees. See the ellipse for details. +@param axes Half of the size of the ellipse main axes. See #ellipse for details. +@param angle Rotation angle of the ellipse in degrees. See #ellipse for details. @param arcStart Starting angle of the elliptic arc in degrees. @param arcEnd Ending angle of the elliptic arc in degrees. @param delta Angle between the subsequent polyline vertices. It defines the approximation @@ -4647,12 +4673,11 @@ CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle, /** @overload @param center Center of the arc. -@param axes Half of the size of the ellipse main axes. See the ellipse for details. -@param angle Rotation angle of the ellipse in degrees. See the ellipse for details. +@param axes Half of the size of the ellipse main axes. See #ellipse for details. +@param angle Rotation angle of the ellipse in degrees. See #ellipse for details. @param arcStart Starting angle of the elliptic arc in degrees. @param arcEnd Ending angle of the elliptic arc in degrees. -@param delta Angle between the subsequent polyline vertices. It defines the approximation -accuracy. +@param delta Angle between the subsequent polyline vertices. It defines the approximation accuracy. @param pts Output vector of polyline vertices. */ CV_EXPORTS void ellipse2Poly(Point2d center, Size2d axes, int angle, @@ -4661,18 +4686,18 @@ CV_EXPORTS void ellipse2Poly(Point2d center, Size2d axes, int angle, /** @brief Draws a text string. -The function putText renders the specified text string in the image. Symbols that cannot be rendered -using the specified font are replaced by question marks. See getTextSize for a text rendering code +The function cv::putText renders the specified text string in the image. Symbols that cannot be rendered +using the specified font are replaced by question marks. See #getTextSize for a text rendering code example. @param img Image. @param text Text string to be drawn. @param org Bottom-left corner of the text string in the image. -@param fontFace Font type, see cv::HersheyFonts. +@param fontFace Font type, see #HersheyFonts. @param fontScale Font scale factor that is multiplied by the font-specific base size. @param color Text color. @param thickness Thickness of the lines used to draw a text. -@param lineType Line type. See the line for details. +@param lineType Line type. See #LineTypes @param bottomLeftOrigin When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner. */ @@ -4683,7 +4708,7 @@ CV_EXPORTS_W void putText( InputOutputArray img, const String& text, Point org, /** @brief Calculates the width and height of a text string. -The function getTextSize calculates and returns the size of a box that contains the specified text. +The function cv::getTextSize calculates and returns the size of a box that contains the specified text. That is, the following code renders some text, the tight box surrounding it, and the baseline: : @code String text = "Funny text inside the box"; @@ -4717,14 +4742,14 @@ That is, the following code renders some text, the tight box surrounding it, and @endcode @param text Input text string. -@param fontFace Font to use, see cv::HersheyFonts. +@param fontFace Font to use, see #HersheyFonts. @param fontScale Font scale factor that is multiplied by the font-specific base size. -@param thickness Thickness of lines used to render the text. See putText for details. +@param thickness Thickness of lines used to render the text. See #putText for details. @param[out] baseLine y-coordinate of the baseline relative to the bottom-most text point. @return The size of a box that contains the specified text. -@see cv::putText +@see putText */ CV_EXPORTS_W Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, diff --git a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp index 01783cc62d..bdaed0c1b1 100644 --- a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp +++ b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp @@ -73,15 +73,15 @@ int main() //! [bin] // Create binary image from source image Mat bw; - cvtColor(src, bw, CV_BGR2GRAY); - threshold(bw, bw, 40, 255, CV_THRESH_BINARY | CV_THRESH_OTSU); + cvtColor(src, bw, COLOR_BGR2GRAY); + threshold(bw, bw, 40, 255, THRESH_BINARY | THRESH_OTSU); imshow("Binary Image", bw); //! [bin] //! [dist] // Perform the distance transform algorithm Mat dist; - distanceTransform(bw, dist, CV_DIST_L2, 3); + distanceTransform(bw, dist, DIST_L2, 3); // Normalize the distance image for range = {0.0, 1.0} // so we can visualize and threshold it @@ -92,7 +92,7 @@ int main() //! [peaks] // Threshold to obtain the peaks // This will be the markers for the foreground objects - threshold(dist, dist, .4, 1., CV_THRESH_BINARY); + threshold(dist, dist, .4, 1., THRESH_BINARY); // Dilate a bit the dist image Mat kernel1 = Mat::ones(3, 3, CV_8UC1); @@ -108,7 +108,7 @@ int main() // Find total markers vector > contours; - findContours(dist_8u, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); + findContours(dist_8u, contours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE); // Create the marker image for the watershed algorithm Mat markers = Mat::zeros(dist.size(), CV_32SC1); @@ -165,4 +165,4 @@ int main() waitKey(0); return 0; -} \ No newline at end of file +} diff --git a/samples/cpp/tutorial_code/snippets/core_reduce.cpp b/samples/cpp/tutorial_code/snippets/core_reduce.cpp index 91711098ca..b9d89629bb 100644 --- a/samples/cpp/tutorial_code/snippets/core_reduce.cpp +++ b/samples/cpp/tutorial_code/snippets/core_reduce.cpp @@ -23,8 +23,8 @@ int main() Mat m = (Mat_(3,2) << 1,2,3,4,5,6); Mat col_sum, row_sum; - reduce(m, col_sum, 0, CV_REDUCE_SUM, CV_32F); - reduce(m, row_sum, 1, CV_REDUCE_SUM, CV_32F); + reduce(m, col_sum, 0, REDUCE_SUM, CV_32F); + reduce(m, row_sum, 1, REDUCE_SUM, CV_32F); /* m = [ 1, 2; @@ -40,22 +40,22 @@ int main() //! [example] Mat col_average, row_average, col_min, col_max, row_min, row_max; - reduce(m, col_average, 0, CV_REDUCE_AVG, CV_32F); + reduce(m, col_average, 0, REDUCE_AVG, CV_32F); cout << "col_average =\n" << col_average << endl; - reduce(m, row_average, 1, CV_REDUCE_AVG, CV_32F); + reduce(m, row_average, 1, REDUCE_AVG, CV_32F); cout << "row_average =\n" << row_average << endl; - reduce(m, col_min, 0, CV_REDUCE_MIN, CV_8U); + reduce(m, col_min, 0, REDUCE_MIN, CV_8U); cout << "col_min =\n" << col_min << endl; - reduce(m, row_min, 1, CV_REDUCE_MIN, CV_8U); + reduce(m, row_min, 1, REDUCE_MIN, CV_8U); cout << "row_min =\n" << row_min << endl; - reduce(m, col_max, 0, CV_REDUCE_MAX, CV_8U); + reduce(m, col_max, 0, REDUCE_MAX, CV_8U); cout << "col_max =\n" << col_max << endl; - reduce(m, row_max, 1, CV_REDUCE_MAX, CV_8U); + reduce(m, row_max, 1, REDUCE_MAX, CV_8U); cout << "row_max =\n" << row_max << endl; /* @@ -86,7 +86,7 @@ int main() char d[] = {1,2,3,4,5,6}; Mat m(3, 1, CV_8UC2, d); Mat col_sum_per_channel; - reduce(m, col_sum_per_channel, 0, CV_REDUCE_SUM, CV_32F); + reduce(m, col_sum_per_channel, 0, REDUCE_SUM, CV_32F); /* col_sum_per_channel = [9, 12] diff --git a/samples/cpp/tutorial_code/snippets/core_various.cpp b/samples/cpp/tutorial_code/snippets/core_various.cpp new file mode 100644 index 0000000000..01f69496aa --- /dev/null +++ b/samples/cpp/tutorial_code/snippets/core_various.cpp @@ -0,0 +1,53 @@ +#include + +using namespace std; +using namespace cv; + +int main() +{ + //! [Algorithm] + Ptr sbd = SimpleBlobDetector::create(); + FileStorage fs_read("SimpleBlobDetector_params.xml", FileStorage::READ); + + if (fs_read.isOpened()) // if we have file with parameters, read them + { + sbd->read(fs_read.root()); + fs_read.release(); + } + else // else modify the parameters and store them; user can later edit the file to use different parameters + { + fs_read.release(); + FileStorage fs_write("SimpleBlobDetector_params.xml", FileStorage::WRITE); + sbd->write(fs_write); + fs_write.release(); + } + + Mat result, image = imread("../data/detect_blob.png", IMREAD_COLOR); + vector keypoints; + sbd->detect(image, keypoints, Mat()); + + drawKeypoints(image, keypoints, result); + for (vector::iterator k = keypoints.begin(); k != keypoints.end(); ++k) + circle(result, k->pt, (int)k->size, Scalar(0, 0, 255), 2); + + imshow("result", result); + waitKey(0); + //! [Algorithm] + + //! [RotatedRect_demo] + Mat test_image(200, 200, CV_8UC3, Scalar(0)); + RotatedRect rRect = RotatedRect(Point2f(100,100), Size2f(100,50), 30); + + Point2f vertices[4]; + rRect.points(vertices); + for (int i = 0; i < 4; i++) + line(test_image, vertices[i], vertices[(i+1)%4], Scalar(0,255,0), 2); + + Rect brect = rRect.boundingRect(); + rectangle(test_image, brect, Scalar(255,0,0), 2); + + imshow("rectangles", test_image); + waitKey(0); + //! [RotatedRect_demo] + return 0; +} diff --git a/samples/cpp/tutorial_code/snippets/imgcodecs_imwrite.cpp b/samples/cpp/tutorial_code/snippets/imgcodecs_imwrite.cpp new file mode 100644 index 0000000000..a42fce2672 --- /dev/null +++ b/samples/cpp/tutorial_code/snippets/imgcodecs_imwrite.cpp @@ -0,0 +1,45 @@ +#include + +using namespace cv; +using namespace std; + +static void createAlphaMat(Mat &mat) +{ + CV_Assert(mat.channels() == 4); + for (int i = 0; i < mat.rows; ++i) + { + for (int j = 0; j < mat.cols; ++j) + { + Vec4b& bgra = mat.at(i, j); + bgra[0] = UCHAR_MAX; // Blue + bgra[1] = saturate_cast((float (mat.cols - j)) / ((float)mat.cols) * UCHAR_MAX); // Green + bgra[2] = saturate_cast((float (mat.rows - i)) / ((float)mat.rows) * UCHAR_MAX); // Red + bgra[3] = saturate_cast(0.5 * (bgra[1] + bgra[2])); // Alpha + } + } +} + +int main() +{ + // Create mat with alpha channel + Mat mat(480, 640, CV_8UC4); + createAlphaMat(mat); + vector compression_params; + compression_params.push_back(IMWRITE_PNG_COMPRESSION); + compression_params.push_back(9); + + bool result = false; + try + { + result = imwrite("alpha.png", mat, compression_params); + } + catch (const cv::Exception& ex) + { + fprintf(stderr, "Exception converting image to PNG format: %s\n", ex.what()); + } + if (result) + printf("Saved PNG file with alpha data.\n"); + else + printf("ERROR: Can't save PNG file.\n"); + return result ? 0 : 1; +}