📄 cv.h
字号:
OPENCVAPI CvScalar cvGet2D( const CvArr* arr, int idx1, int idx2 );
OPENCVAPI CvScalar cvGet3D( const CvArr* arr, int idx1, int idx2, int idx3 );
OPENCVAPI CvScalar cvGetND( const CvArr* arr, int* idx );
/* for 1-channel arrays */
OPENCVAPI double cvGetReal1D( const CvArr* arr, int idx1 );
OPENCVAPI double cvGetReal2D( const CvArr* arr, int idx1, int idx2 );
OPENCVAPI double cvGetReal3D( const CvArr* arr, int idx1, int idx2, int idx3 );
OPENCVAPI double cvGetRealND( const CvArr* arr, int* idx );
/* arr(idx1,idx2,...) = value */
OPENCVAPI void cvSet1D( CvArr* arr, int idx1, CvScalar value );
OPENCVAPI void cvSet2D( CvArr* arr, int idx1, int idx2, CvScalar value );
OPENCVAPI void cvSet3D( CvArr* arr, int idx1, int idx2, int idx3, CvScalar value );
OPENCVAPI void cvSetND( CvArr* arr, int* idx, CvScalar value );
/* for 1-channel arrays */
OPENCVAPI void cvSetReal1D( CvArr* arr, int idx1, double value );
OPENCVAPI void cvSetReal2D( CvArr* arr, int idx1, int idx2, double value );
OPENCVAPI void cvSetReal3D( CvArr* arr, int idx1,
int idx2, int idx3, double value );
OPENCVAPI void cvSetRealND( CvArr* arr, int* idx, double value );
/* Converts CvArr (IplImage or CvMat,...) to CvMat.
If the last parameter is non-zero, function can
convert multi(>2)-dimensional array to CvMat as long as
the last array's dimension is continous. The resultant
matrix will be have appropriate (a huge) number of rows */
OPENCVAPI CvMat* cvGetMat( const CvArr* src, CvMat* header,
int* coi CV_DEFAULT(NULL),
int allowND CV_DEFAULT(0));
/* Converts CvArr (IplImage or CvMat) to IplImage */
OPENCVAPI IplImage* cvGetImage( const CvArr* array, IplImage* img );
/* Changes a shape of multi-dimensional array.
new_cn == 0 means that number of channels remains unchanged.
new_dims == 0 means that number and sizes of dimensions remain the same
(unless they need to be changed to set the new number of channels)
if new_dims == 1, there is no need to specify new dimension sizes
The resultant configuration should be achievable w/o data copying.
If the resultant array is sparse, CvSparseMat header should be passed
to the function else if the result is 1 or 2 dimensional,
CvMat header should be passed to the function
else CvMatND header should be passed */
OPENCVAPI CvArr* cvReshapeMatND( const CvArr* array,
int sizeof_header, CvArr* header,
int new_cn, int new_dims, int* new_sizes );
#define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \
cvReshapeMatND( (arr), sizeof(*(header)), (header), \
(new_cn), (new_dims), (new_sizes))
OPENCVAPI CvMat* cvReshape( const CvArr* array, CvMat* header,
int new_cn, int new_rows CV_DEFAULT(0) );
/* Repeats source 2d array several times in both horizontal and
vertical direction to fit destination array */
OPENCVAPI void cvRepeat( const CvArr* src, CvArr* dst );
/* Allocates array data */
OPENCVAPI void cvCreateData( CvArr* array );
/* Releases array data */
OPENCVAPI void cvReleaseData( CvArr* array );
/* Attaches user data to the array header. The step is reffered to
the pre-last dimension. That is, all the planes of the array
must be joint (w/o gaps) */
OPENCVAPI void cvSetData( CvArr* array, void* data, int step );
/* Retrieves raw data of CvMat, IplImage or CvMatND.
In the latter case the function raises an error if
the array can not be represented as a matrix */
OPENCVAPI void cvGetRawData( const CvArr* array, uchar** data,
int* step CV_DEFAULT(NULL),
CvSize* roi_size CV_DEFAULT(NULL));
/* Returns width and height of array in elements */
OPENCVAPI CvSize cvGetSize( const CvArr* arr );
/* Copies source array to destination array */
OPENCVAPI void cvCopy( const CvArr* src, CvArr* dst,
const CvArr* mask CV_DEFAULT(NULL) );
/* Sets all or "masked" elements of input array
to the same <scalar> value*/
OPENCVAPI void cvSet( CvArr* arr, CvScalar scalar,
const CvArr* mask CV_DEFAULT(NULL) );
/* Clears all the array elements (sets them to 0) */
OPENCVAPI void cvSetZero( CvArr* mat );
#define cvZero cvSetZero
/* Splits a multi-channel array into the set of single-channel arrays or
extracts particular [color] plane */
OPENCVAPI void cvCvtPixToPlane( const void *src, void *dst0, void *dst1,
void *dst2, void *dst3 );
/* Merges a set of single-channel arrays into the single multi-channel array
or inserts one particular [color] plane to the array */
OPENCVAPI void cvCvtPlaneToPix( const void *src0, const void *src1,
const void *src2, const void *src3,
void *dst );
/* Performs linear transformation on every source array element:
dst(x,y,c) = scale*src(x,y,c)+shift.
Arbitrary combination of input and output array depths are allowed
(number of channels must be the same), thus the function can be used
for depth conversion */
OPENCVAPI void cvConvertScale( const CvArr *src, CvArr *dst,
double scale CV_DEFAULT(1),
double shift CV_DEFAULT(0) );
#define cvCvtScale cvConvertScale
#define cvScale cvConvertScale
#define cvConvert( src, dst ) cvConvertScale( (src), (dst), 1, 0 )
/* Performs linear transformation on every source array element,
stores absolute value of the result:
dst(x,y,c) = abs(scale*src(x,y,c)+shift).
destination array must have 8u type.
In other cases one may use cvConvertScale + cvAbsDiffS */
OPENCVAPI void cvConvertScaleAbs( const void *src, void *dst,
double scale CV_DEFAULT(1),
double shift CV_DEFAULT(0) );
#define cvCvtScaleAbs cvConvertScaleAbs
/* Finds minimum rectangle containing two given rectangles */
OPENCVAPI CvRect cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
/* Finds coordinates of the box vertices */
OPENCVAPI void cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
/****************************************************************************************\
* Arithmetic, logic and comparison operations *
\****************************************************************************************/
/* dst(mask) = srcA(mask) + srcB(mask) */
OPENCVAPI void cvAdd( const CvArr* srcA, const CvArr* srcB, CvArr* dst,
const CvArr* mask CV_DEFAULT(NULL));
/* dst(mask) = src(mask) + value */
OPENCVAPI void cvAddS( const CvArr* src, CvScalar value, CvArr* dst,
const CvArr* mask CV_DEFAULT(NULL));
/* dst(mask) = srcA(mask) - srcB(mask) */
OPENCVAPI void cvSub( const CvArr* srcA, const CvArr* srcB, CvArr* dst,
const CvArr* mask CV_DEFAULT(NULL));
/* dst(mask) = src(mask) - value = src(mask) + (-value) */
CV_INLINE void cvSubS( const CvArr* src, CvScalar value, CvArr* dst,
const CvArr* mask CV_DEFAULT(NULL));
CV_INLINE void cvSubS( const CvArr* src, CvScalar value, CvArr* dst,
const CvArr* mask )
{
cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]),
dst, mask );
}
/* dst(mask) = value - src(mask) */
OPENCVAPI void cvSubRS( const CvArr* src, CvScalar value, CvArr* dst,
const CvArr* mask CV_DEFAULT(NULL));
/* dst(idx) = srcA(idx) * srcB(idx) * scale (element-wise multiplication with scale) */
OPENCVAPI void cvMul( const CvArr* srcA, const CvArr* srcB,
CvArr* dst, double scale CV_DEFAULT(1) );
/* element-wise division/inversion with scaling:
dst(idx) = srcA(idx) * scale / srcB(idx)
or dst(idx) = scale / srcB(idx) if srcA == 0 */
OPENCVAPI void cvDiv( const CvArr* srcA, const CvArr* srcB,
CvArr* dst, double scale CV_DEFAULT(1));
/* dst = srcA * scale + srcB */
OPENCVAPI void cvScaleAdd( const CvArr* srcA, CvScalar scale,
const CvArr* srcB, CvArr* dst );
/* dst = srcA * alpha + srcB * beta + gamma */
OPENCVAPI void cvAddWeighted( const CvArr* srcA, double alpha,
const CvArr* srcB, double beta,
double gamma, CvArr* dst );
/* result = sum(srcA(i) * srcB*(i)) (srcB is conjugated)
i */
OPENCVAPI double cvDotProduct( const CvArr* srcA, const CvArr* srcB );
/* dst(idx) = src1(idx) & src2(idx) */
OPENCVAPI void cvAnd( const CvArr* src1, const CvArr* src2,
CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
/* dst(idx) = src(idx) & value */
OPENCVAPI void cvAndS( const CvArr* src, CvScalar value,
CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
/* dst(idx) = src1(idx) | src2(idx) */
OPENCVAPI void cvOr( const CvArr* src1, const CvArr* src2,
CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
/* dst(idx) = src(idx) | value */
OPENCVAPI void cvOrS( const CvArr* src, CvScalar value,
CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
/* dst(idx) = src1(idx) ^ src2(idx) */
OPENCVAPI void cvXor( const CvArr* src1, const CvArr* src2,
CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
/* dst(idx) = src(idx) ^ value */
OPENCVAPI void cvXorS( const CvArr* src, CvScalar value,
CvArr* dst, const CvArr* mask CV_DEFAULT(NULL));
/* dst(idx) = ~src(idx) */
OPENCVAPI void cvNot( const CvArr* src, CvArr* dst );
/* dst(idx) = lower(idx) <= src(idx) < upper(idx) */
OPENCVAPI void cvInRange( const CvArr* src, const CvArr* lower,
const CvArr* upper, CvArr* dst );
/* dst(idx) = lower <= src(idx) < upper */
OPENCVAPI void cvInRangeS( const CvArr* src, CvScalar lower,
CvScalar upper, CvArr* dst );
#define CV_CMP_EQ 0
#define CV_CMP_GT 1
#define CV_CMP_GE 2
#define CV_CMP_LT 3
#define CV_CMP_LE 4
#define CV_CMP_NE 5
/* The comparison operation support single-channel arrays only.
Destination image should be 8uC1 or 8sC1 */
/* dst(idx) = src1(idx) _cmp_op_ src2(idx) */
OPENCVAPI void cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmpOp );
/* dst(idx) = src1(idx) _cmp_op_ scalar */
OPENCVAPI void cvCmpS( const CvArr* src1, double scalar, CvArr* dst, int cmpOp );
/* dst(idx) = min(src1(idx),src2(idx)) */
OPENCVAPI void cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst );
/* dst(idx) = max(src1(idx),src2(idx)) */
OPENCVAPI void cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst );
/* dst(idx) = min(src(idx),scalar) */
OPENCVAPI void cvMinS( const CvArr* src, double scalar, CvArr* dst );
/* dst(idx) = max(src(idx),scalar) */
OPENCVAPI void cvMaxS( const CvArr* src, double scalar, CvArr* dst );
/****************************************************************************************\
* Math operations *
\****************************************************************************************/
/* Does cartesian->polar coordinates conversion.
Either of output components (magnitude or angle) is optional */
OPENCVAPI void cvCartToPolar( const CvArr* x, const CvArr* y,
CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL),
int angle_in_degrees CV_DEFAULT(0));
/* Does polar->cartesian coordinates conversion.
Either of output components (magnitude or angle) is optional.
If magnitude is missing it is assumed to be all 1's */
OPENCVAPI void cvPolarToCart( const CvArr* magnitude, const CvArr* angle,
CvArr* x, CvArr* y,
int angle_in_degrees CV_DEFAULT(0));
/* Does powering: dst(idx) = src(idx)^power */
OPENCVAPI void cvPow( const CvArr* src, CvArr* dst, double power );
/* Does exponention: dst(idx) = exp(src(idx)).
Overflow is not handled yet. Underflow is handled.
Maximal relative error is ~7e-6 */
OPENCVAPI void cvExp( const CvArr* src, CvArr* dst );
/* Calculates natural logarithms: dst(idx) = log(abs(src(idx))).
Logarithm of 0 gives large negative number(~-700)
Maximal relative error is ~3e-7
*/
OPENCVAPI void cvLog( const CvArr* src, CvArr* dst );
/* Checks array values for NaNs, Infs or simply for too large numbers
(if CV_CHECK is set). If CV_CHECK_QUIET is set,
no runtime errors is raised (function returns zero value in case of "bad" values).
Otherwise cvError is called */
#define CV_CHECK_RANGE 1
#define CV_CHECK_QUIET 2
OPENCVAPI int cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0),
double minVal CV_DEFAULT(0), double maxVal CV_DEFAULT(0));
#define cvCheckArray cvCheckArr
/* RNG state */
typedef struct CvRandState
{
uint64 state; /* RNG state (the current seed and carry)*/
int disttype; /* distribution type */
CvScalar param[2]; /* parameters of RNG */
}
CvRandState;
/* Initalized RNG state */
#define CV_RAND_UNI 0
#define CV_RAND_NORMAL 1
OPENCVAPI void cvRandInit( CvRandState* state, double param1,
double param2, int seed,
int disttype CV_DEFAULT(CV_RAND_UNI));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -