mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 01:13:28 +08:00
Update documentation
This commit is contained in:
parent
71f4281080
commit
dcd4f8f5db
@ -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<Feature2D> 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<KeyPoint> 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
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ template<typename _Tp> class Complex
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructors
|
||||
//! default constructor
|
||||
Complex();
|
||||
Complex( _Tp _re, _Tp _im = 0 );
|
||||
|
||||
@ -159,7 +159,7 @@ template<typename _Tp> 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_<int> Point2i;
|
||||
@ -239,7 +239,7 @@ template<typename _Tp> 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_<int> Point3i;
|
||||
@ -316,7 +317,7 @@ template<typename _Tp> 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<typename _Tp2> operator Size_<_Tp2>() const;
|
||||
|
||||
_Tp width, height; // the width and the height
|
||||
_Tp width; //!< the width
|
||||
_Tp height; //!< the height
|
||||
};
|
||||
|
||||
typedef Size_<int> Size2i;
|
||||
@ -416,7 +418,7 @@ template<typename _Tp> 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_<int> 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
|
||||

|
||||
|
||||
@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_<float> 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<typename _Tp> 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
|
||||
};
|
||||
|
||||
|
||||
|
@ -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 <opencv2/opencv.hpp>
|
||||
|
||||
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<Vec4b>(i, j);
|
||||
bgra[0] = UCHAR_MAX; // Blue
|
||||
bgra[1] = saturate_cast<uchar>((float (mat.cols - j)) / ((float)mat.cols) * UCHAR_MAX); // Green
|
||||
bgra[2] = saturate_cast<uchar>((float (mat.rows - i)) / ((float)mat.rows) * UCHAR_MAX); // Red
|
||||
bgra[3] = saturate_cast<uchar>(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<int> 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
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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<vector<Point> > 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;
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ int main()
|
||||
Mat m = (Mat_<uchar>(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]
|
||||
|
53
samples/cpp/tutorial_code/snippets/core_various.cpp
Normal file
53
samples/cpp/tutorial_code/snippets/core_various.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
int main()
|
||||
{
|
||||
//! [Algorithm]
|
||||
Ptr<Feature2D> 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<KeyPoint> keypoints;
|
||||
sbd->detect(image, keypoints, Mat());
|
||||
|
||||
drawKeypoints(image, keypoints, result);
|
||||
for (vector<KeyPoint>::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;
|
||||
}
|
45
samples/cpp/tutorial_code/snippets/imgcodecs_imwrite.cpp
Normal file
45
samples/cpp/tutorial_code/snippets/imgcodecs_imwrite.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
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<Vec4b>(i, j);
|
||||
bgra[0] = UCHAR_MAX; // Blue
|
||||
bgra[1] = saturate_cast<uchar>((float (mat.cols - j)) / ((float)mat.cols) * UCHAR_MAX); // Green
|
||||
bgra[2] = saturate_cast<uchar>((float (mat.rows - i)) / ((float)mat.rows) * UCHAR_MAX); // Red
|
||||
bgra[3] = saturate_cast<uchar>(0.5 * (bgra[1] + bgra[2])); // Alpha
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// Create mat with alpha channel
|
||||
Mat mat(480, 640, CV_8UC4);
|
||||
createAlphaMat(mat);
|
||||
vector<int> 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user