📄 cv.h
字号:
#define CV_SHAPE_RECT 0
#define CV_SHAPE_CROSS 1
#define CV_SHAPE_ELLIPSE 2
#define CV_SHAPE_CUSTOM 100
/* creates structuring element used for morphological operations */
CVAPI(IplConvKernel*) cvCreateStructuringElementEx(
int cols, int rows, int anchor_x, int anchor_y,
int shape, int* values CV_DEFAULT(NULL) );
/* releases structuring element */
CVAPI(void) cvReleaseStructuringElement( IplConvKernel** element );
/* erodes input image (applies minimum filter) one or more times.
If element pointer is NULL, 3x3 rectangular element is used */
CVAPI(void) cvErode( const CvArr* src, CvArr* dst,
IplConvKernel* element CV_DEFAULT(NULL),
int iterations CV_DEFAULT(1) );
/* dilates input image (applies maximum filter) one or more times.
If element pointer is NULL, 3x3 rectangular element is used */
CVAPI(void) cvDilate( const CvArr* src, CvArr* dst,
IplConvKernel* element CV_DEFAULT(NULL),
int iterations CV_DEFAULT(1) );
#define CV_MOP_OPEN 2
#define CV_MOP_CLOSE 3
#define CV_MOP_GRADIENT 4
#define CV_MOP_TOPHAT 5
#define CV_MOP_BLACKHAT 6
/* Performs complex morphological transformation */
CVAPI(void) cvMorphologyEx( const CvArr* src, CvArr* dst,
CvArr* temp, IplConvKernel* element,
int operation, int iterations CV_DEFAULT(1) );
/* Calculates all spatial and central moments up to the 3rd order */
CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
/* Retrieve particular spatial, central or normalized central moments */
CVAPI(double) cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
CVAPI(double) cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
CVAPI(double) cvGetNormalizedCentralMoment( CvMoments* moments,
int x_order, int y_order );
/* Calculates 7 Hu's invariants from precalculated spatial and central moments */
CVAPI(void) cvGetHuMoments( CvMoments* moments, CvHuMoments* hu_moments );
/*********************************** data sampling **************************************/
/* Fetches pixels that belong to the specified line segment and stores them to the buffer.
Returns the number of retrieved points. */
CVAPI(int) cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
int connectivity CV_DEFAULT(8));
/* Retrieves the rectangular image region with specified center from the input array.
dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
Values of pixels with fractional coordinates are retrieved using bilinear interpolation*/
CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
/* Retrieves quadrangle from the input array.
matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b)
( a21 a22 | b2 ) (bilinear interpolation is used to retrieve pixels
with fractional coordinates)
*/
CVAPI(void) cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
const CvMat* map_matrix );
/* Methods for comparing two array */
#define CV_TM_SQDIFF 0
#define CV_TM_SQDIFF_NORMED 1
#define CV_TM_CCORR 2
#define CV_TM_CCORR_NORMED 3
#define CV_TM_CCOEFF 4
#define CV_TM_CCOEFF_NORMED 5
/* Measures similarity between template and overlapped windows in the source image
and fills the resultant image with the measurements */
CVAPI(void) cvMatchTemplate( const CvArr* image, const CvArr* templ,
CvArr* result, int method );
/* Computes earth mover distance between
two weighted point sets (called signatures) */
CVAPI(float) cvCalcEMD2( const CvArr* signature1,
const CvArr* signature2,
int distance_type,
CvDistanceFunction distance_func CV_DEFAULT(NULL),
const CvArr* cost_matrix CV_DEFAULT(NULL),
CvArr* flow CV_DEFAULT(NULL),
float* lower_bound CV_DEFAULT(NULL),
void* userdata CV_DEFAULT(NULL));
/****************************************************************************************\
* Contours retrieving *
\****************************************************************************************/
/* Retrieves outer and optionally inner boundaries of white (non-zero) connected
components in the black (zero) background */
CVAPI(int) cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
int header_size CV_DEFAULT(sizeof(CvContour)),
int mode CV_DEFAULT(CV_RETR_LIST),
int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
CvPoint offset CV_DEFAULT(cvPoint(0,0)));
/* Initalizes contour retrieving process.
Calls cvStartFindContours.
Calls cvFindNextContour until null pointer is returned
or some other condition becomes true.
Calls cvEndFindContours at the end. */
CVAPI(CvContourScanner) cvStartFindContours( CvArr* image, CvMemStorage* storage,
int header_size CV_DEFAULT(sizeof(CvContour)),
int mode CV_DEFAULT(CV_RETR_LIST),
int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
CvPoint offset CV_DEFAULT(cvPoint(0,0)));
/* Retrieves next contour */
CVAPI(CvSeq*) cvFindNextContour( CvContourScanner scanner );
/* Substitutes the last retrieved contour with the new one
(if the substitutor is null, the last retrieved contour is removed from the tree) */
CVAPI(void) cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
/* Releases contour scanner and returns pointer to the first outer contour */
CVAPI(CvSeq*) cvEndFindContours( CvContourScanner* scanner );
/* Approximates a single Freeman chain or a tree of chains to polygonal curves */
CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
double parameter CV_DEFAULT(0),
int minimal_perimeter CV_DEFAULT(0),
int recursive CV_DEFAULT(0));
/* Initalizes Freeman chain reader.
The reader is used to iteratively get coordinates of all the chain points.
If the Freeman codes should be read as is, a simple sequence reader should be used */
CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
/* Retrieves the next chain point */
CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
/****************************************************************************************\
* Motion Analysis *
\****************************************************************************************/
/************************************ optical flow ***************************************/
/* Calculates optical flow for 2 images using classical Lucas & Kanade algorithm */
CVAPI(void) cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr,
CvSize win_size, CvArr* velx, CvArr* vely );
/* Calculates optical flow for 2 images using block matching algorithm */
CVAPI(void) cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr,
CvSize block_size, CvSize shift_size,
CvSize max_range, int use_previous,
CvArr* velx, CvArr* vely );
/* Calculates Optical flow for 2 images using Horn & Schunck algorithm */
CVAPI(void) cvCalcOpticalFlowHS( const CvArr* prev, const CvArr* curr,
int use_previous, CvArr* velx, CvArr* vely,
double lambda, CvTermCriteria criteria );
#define CV_LKFLOW_PYR_A_READY 1
#define CV_LKFLOW_PYR_B_READY 2
#define CV_LKFLOW_INITIAL_GUESSES 4
/* It is Lucas & Kanade method, modified to use pyramids.
Also it does several iterations to get optical flow for
every point at every pyramid level.
Calculates optical flow between two images for certain set of points (i.e.
it is a "sparse" optical flow, which is opposite to the previous 3 methods) */
CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr,
CvArr* prev_pyr, CvArr* curr_pyr,
const CvPoint2D32f* prev_features,
CvPoint2D32f* curr_features,
int count,
CvSize win_size,
int level,
char* status,
float* track_error,
CvTermCriteria criteria,
int flags );
/* Modification of a previous sparse optical flow algorithm to calculate
affine flow */
/*CVAPI void cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr,
CvArr* prev_pyr, CvArr* curr_pyr,
CvPoint2D32f* prev_features,
CvPoint2D32f* curr_features,
float* matrices, int count,
CvSize win_size, int level,
char* status, float* track_error,
CvTermCriteria criteria, int flags );*/
/********************************* motion templates *************************************/
/****************************************************************************************\
* All the motion template functions work only with single channel images. *
* Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S *
* Motion history image must have depth IPL_DEPTH_32F, *
* Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S, *
* Motion orientation image - IPL_DEPTH_32F *
* Segmentation mask - IPL_DEPTH_32F *
* All the angles are in degrees, all the times are in milliseconds *
\****************************************************************************************/
/* Updates motion history image given motion silhouette */
CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi,
double timestamp, double duration );
/* Calculates gradient of the motion history image and fills
a mask indicating where the gradient is valid */
CVAPI(void) cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation,
double delta1, double delta2,
int aperture_size CV_DEFAULT(3));
/* Calculates average motion direction within a selected motion region
(region can be selected by setting ROIs and/or by composing a valid gradient mask
with the region mask) */
CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask,
const CvArr* mhi, double timestamp,
double duration );
/* Splits a motion history image into a few parts corresponding to separate independent motions
(e.g. left hand, right hand) */
CVAPI(CvSeq*) cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask,
CvMemStorage* storage,
double timestamp, double seg_thresh );
/*********************** Background statistics accumulation *****************************/
/* Adds image to accumulator */
CVAPI(void) cvAcc( const CvArr* image, CvArr* sum,
const CvArr* mask CV_DEFAULT(NULL) );
/* Adds squared image to accumulator */
CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum,
const CvArr* mask CV_DEFAULT(NULL) );
/* Adds a product of two images to accumulator */
CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
const CvArr* mask CV_DEFAULT(NULL) );
/* Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha */
CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
const CvArr* mask CV_DEFAULT(NULL) );
/****************************************************************************************\
* Tracking *
\****************************************************************************************/
/* Implements CAMSHIFT algorithm - determines object position, size and orientation
from the object histogram back project (extension of meanshift) */
CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window,
CvTermCriteria criteria, CvConnectedComp* comp,
CvBox2D* box CV_DEFAULT(NULL) );
/* Implements MeanShift algorithm - determines object position
from the object histogram back project */
CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window,
CvTermCriteria criteria, CvConnectedComp* comp );
/* Creates ConDensation filter state */
CVAPI(CvConDensation*) cvCreateConDensation( int dynam_params,
int measure_params,
int sample_count );
/* Releases ConDensation filter state */
CVAPI(void) cvReleaseConDensation( CvConDensation** condens );
/* Updates ConDensation filter by time (predict future state of the system) */
CVAPI(void) cvConDensUpdateByTime( CvConDensation* condens);
/* Initializes ConDensation filter samples */
CVAPI(void) cvConDensInitSampleSet( CvConDensation* condens, CvMat* lower_bound, CvMat* upper_bound );
/* Creates Kalman filter and sets A, B, Q, R and state to some initial values */
CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params,
int control_params CV_DEFAULT(0));
/* Releases Kalman filter state */
CVAPI(void) cvReleaseKalman( CvKalman** kalman);
/* Updates Kalman filter by time (predicts future state of the system) */
CVAPI(const CvMat*) cvKalmanPredict( CvKalman* kalman,
const CvMat* control CV_DEFAULT(NULL));
/* Updates Kalman filter by measurement
(corrects state of the system and internal matrices) */
CVAPI(const CvMat*) cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement );
/****************************************************************************************\
* Planar subdivisions *
\****************************************************************************************/
/* Initializes Delaunay triangulation */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -