📄 cvcompat.h
字号:
cvBoxPoints( box, pt );
*anchor = pt[0];
vect1->x = pt[1].x - pt[0].x;
vect1->y = pt[1].y - pt[0].y;
vect2->x = pt[3].x - pt[0].x;
vect2->y = pt[3].y - pt[0].y;
CV_UNREFERENCED( (left, bottom, right, top) );
}
CV_INLINE void cvFitLine3D( CvPoint3D32f* points, int count, CvDisType dist,
void *param, float reps, float aeps, float* line );
CV_INLINE void cvFitLine3D( CvPoint3D32f* points, int count, CvDisType dist,
void *param, float reps, float aeps, float* line )
{
CvMat mat = cvMat( 1, count, CV_32FC3, points );
float _param = param != NULL ? *(float*)param : 0.f;
assert( dist != CV_DIST_USER );
cvFitLine( &mat, dist, _param, reps, aeps, line );
}
/* Fits a line into set of 2d points in a robust way (M-estimator technique) */
CV_INLINE void cvFitLine2D( CvPoint2D32f* points, int count, CvDisType dist,
void *param, float reps, float aeps, float* line );
CV_INLINE void cvFitLine2D( CvPoint2D32f* points, int count, CvDisType dist,
void *param, float reps, float aeps, float* line )
{
CvMat mat = cvMat( 1, count, CV_32FC2, points );
float _param = param != NULL ? *(float*)param : 0.f;
assert( dist != CV_DIST_USER );
cvFitLine( &mat, dist, _param, reps, aeps, line );
}
CV_INLINE void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box );
CV_INLINE void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box )
{
CvMat mat = cvMat( 1, count, CV_32FC2, (void*)points );
*box = cvFitEllipse2( &mat );
}
/* Retrieves value of the particular bin
of x-dimensional (x=1,2,3,...) histogram */
#define cvQueryHistValue_1D( hist, idx0 ) \
((float)cvGetReal1D( (hist)->bins, (idx0)))
#define cvQueryHistValue_2D( hist, idx0, idx1 ) \
((float)cvGetReal2D( (hist)->bins, (idx0), (idx1)))
#define cvQueryHistValue_3D( hist, idx0, idx1, idx2 ) \
((float)cvGetReal3D( (hist)->bins, (idx0), (idx1), (idx2)))
#define cvQueryHistValue_nD( hist, idx ) \
((float)cvGetRealND( (hist)->bins, (idx)))
/* Returns pointer to the particular bin of x-dimesional histogram.
For sparse histogram the bin is created if it didn't exist before */
#define cvGetHistValue_1D( hist, idx0 ) \
((float*)cvPtr1D( (hist)->bins, (idx0), 0))
#define cvGetHistValue_2D( hist, idx0, idx1 ) \
((float*)cvPtr2D( (hist)->bins, (idx0), (idx1), 0))
#define cvGetHistValue_3D( hist, idx0, idx1, idx2 ) \
((float*)cvPtr3D( (hist)->bins, (idx0), (idx1), (idx2), 0))
#define cvGetHistValue_nD( hist, idx ) \
((float*)cvPtrND( (hist)->bins, (idx), 0))
#define CV_IS_SET_ELEM_EXISTS CV_IS_SET_ELEM
CV_INLINE int cvHoughLines( CvArr* image, double rho,
double theta, int threshold,
float* lines, int linesNumber );
CV_INLINE int cvHoughLines( CvArr* image, double rho,
double theta, int threshold,
float* lines, int linesNumber )
{
CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines );
cvHoughLines2( image, &linesMat, CV_HOUGH_STANDARD,
rho, theta, threshold, 0, 0 );
return linesMat.rows;
}
CV_INLINE int cvHoughLinesP( CvArr* image, double rho,
double theta, int threshold,
int lineLength, int lineGap,
int* lines, int linesNumber );
CV_INLINE int cvHoughLinesP( CvArr* image, double rho,
double theta, int threshold,
int lineLength, int lineGap,
int* lines, int linesNumber )
{
CvMat linesMat = cvMat( 1, linesNumber, CV_32SC4, lines );
cvHoughLines2( image, &linesMat, CV_HOUGH_PROBABILISTIC,
rho, theta, threshold, lineLength, lineGap );
return linesMat.rows;
}
CV_INLINE int cvHoughLinesSDiv( CvArr* image, double rho, int srn,
double theta, int stn, int threshold,
float* lines, int linesNumber );
CV_INLINE int cvHoughLinesSDiv( CvArr* image, double rho, int srn,
double theta, int stn, int threshold,
float* lines, int linesNumber )
{
CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines );
cvHoughLines2( image, &linesMat, CV_HOUGH_MULTI_SCALE,
rho, theta, threshold, srn, stn );
return linesMat.rows;
}
/* Find fundamental matrix */
CV_INLINE void cvFindFundamentalMatrix( int* points1, int* points2,
int numpoints, int method, float* matrix );
CV_INLINE void cvFindFundamentalMatrix( int* points1, int* points2,
int numpoints, int method, float* matrix )
{
CvMat* pointsMat1;
CvMat* pointsMat2;
CvMat fundMatr = cvMat(3,3,CV_32F,matrix);
int i, curr = 0;
#ifndef __BORLANDC__
method = method;
#endif
pointsMat1 = cvCreateMat(3,numpoints,CV_64F);
pointsMat2 = cvCreateMat(3,numpoints,CV_64F);
for( i = 0; i < numpoints; i++ )
{
cvmSet(pointsMat1,0,i,points1[curr]);//x
cvmSet(pointsMat1,1,i,points1[curr+1]);//y
cvmSet(pointsMat1,2,i,1.0);
cvmSet(pointsMat2,0,i,points2[curr]);//x
cvmSet(pointsMat2,1,i,points2[curr+1]);//y
cvmSet(pointsMat2,2,i,1.0);
curr += 2;
}
cvFindFundamentalMat(pointsMat1,pointsMat2,&fundMatr,CV_FM_RANSAC,1,0.99,0);
cvReleaseMat(&pointsMat1);
cvReleaseMat(&pointsMat2);
}
CV_INLINE float cvCalcEMD( const float* signature1, int size1,
const float* signature2, int size2,
int dims, CvDisType dist_type CV_DEFAULT(CV_DIST_L2),
CvDistanceFunction dist_func CV_DEFAULT(0),
float* lower_bound CV_DEFAULT(0),
void* user_param CV_DEFAULT(0));
CV_INLINE float cvCalcEMD( const float* signature1, int size1,
const float* signature2, int size2,
int dims, CvDisType dist_type,
CvDistanceFunction dist_func,
float* lower_bound, void* user_param )
{
CvMat sign1 = cvMat( size1, dims + 1, CV_32FC1, (void*)signature1 );
CvMat sign2 = cvMat( size2, dims + 1, CV_32FC1, (void*)signature2 );
return cvCalcEMD2( &sign1, &sign2, dist_type, dist_func, 0, 0, lower_bound, user_param );
}
CV_INLINE void cvKMeans( int num_clusters, float** samples,
int num_samples, int vec_size,
CvTermCriteria termcrit, int* cluster_idx );
CV_INLINE void cvKMeans( int num_clusters, float** samples,
int num_samples, int vec_size,
CvTermCriteria termcrit, int* cluster_idx )
{
CvMat* samples_mat = cvCreateMat( num_samples, vec_size, CV_32FC1 );
CvMat cluster_idx_mat = cvMat( num_samples, 1, CV_32SC1, cluster_idx );
int i;
for( i = 0; i < num_samples; i++ )
memcpy( samples_mat->data.fl + i*vec_size, samples[i], vec_size*sizeof(float));
cvKMeans2( samples_mat, num_clusters, &cluster_idx_mat, termcrit );
cvReleaseMat( &samples_mat );
}
#define cvKalmanUpdateByTime cvKalmanPredict
#define cvKalmanUpdateByMeasurement cvKalmanCorrect
/* Creates hand mask image given several points on the hand */
OPENCVAPI void cvCreateHandMask( CvSeq* hand_points,
IplImage *img_mask, CvRect *roi);
/* Finds hand region in range image data */
OPENCVAPI void cvFindHandRegion (CvPoint3D32f* points, int count,
CvSeq* indexs,
float* line, CvSize2D32f size, int flag,
CvPoint3D32f* center,
CvMemStorage* storage, CvSeq **numbers);
/* Finds hand region in range image data (advanced version) */
OPENCVAPI void cvFindHandRegionA( CvPoint3D32f* points, int count,
CvSeq* indexs,
float* line, CvSize2D32f size, int jc,
CvPoint3D32f* center,
CvMemStorage* storage, CvSeq **numbers);
/****************************************************************************************\
* Pixel Access Macros *
\****************************************************************************************/
typedef struct _CvPixelPosition8u
{
unsigned char* currline; /* pointer to the start of the current pixel line */
unsigned char* topline; /* pointer to the start of the top pixel line */
unsigned char* bottomline; /* pointer to the start of the first line */
/* which is below the image */
int x; /* current x coordinate ( in pixels ) */
int width; /* width of the image ( in pixels ) */
int height; /* height of the image ( in pixels ) */
int step; /* distance between lines ( in elements of single */
/* plane ) */
int step_arr[3]; /* array: ( 0, -step, step ). It is used for */
/* vertical moving */
} CvPixelPosition8u;
/* this structure differs from the above only in data type */
typedef struct _CvPixelPosition8s
{
char* currline;
char* topline;
char* bottomline;
int x;
int width;
int height;
int step;
int step_arr[3];
} CvPixelPosition8s;
/* this structure differs from the CvPixelPosition8u only in data type */
typedef struct _CvPixelPosition32f
{
float* currline;
float* topline;
float* bottomline;
int x;
int width;
int height;
int step;
int step_arr[3];
} CvPixelPosition32f;
/* Initialize one of the CvPixelPosition structures. */
/* pos - initialized structure */
/* origin - pointer to the left-top corner of the ROI */
/* step - width of the whole image in bytes */
/* roi - width & height of the ROI */
/* x, y - initial position */
#define CV_INIT_PIXEL_POS(pos, origin, _step, roi, _x, _y, orientation) \
( \
(pos).step = (_step)/sizeof((pos).currline[0]) * (orientation ? -1 : 1), \
(pos).width = (roi).width, \
(pos).height = (roi).height, \
(pos).bottomline = (origin) + (pos).step*(pos).height, \
(pos).topline = (origin) - (pos).step, \
(pos).step_arr[0] = 0, \
(pos).step_arr[1] = -(pos).step, \
(pos).step_arr[2] = (pos).step, \
(pos).x = (_x), \
(pos).currline = (origin) + (pos).step*(_y) )
/* Move to specified point ( absolute shift ) */
/* pos - position structure */
/* x, y - coordinates of the new position */
/* cs - number of the image channels */
#define CV_MOVE_TO( pos, _x, _y, cs ) \
((pos).currline = (_y) >= 0 && (_y) < (pos).height ? (pos).topline + ((_y)+1)*(pos).step : 0, \
(pos).x = (_x) >= 0 && (_x) < (pos).width ? (_x) : 0, (pos).currline + (_x) * (cs) )
/* Get current coordinates */
/* pos - position structure */
/* x, y - coordinates of the new position */
/* cs - number of the image channels */
#define CV_GET_CURRENT( pos, cs ) ((pos).currline + (pos).x * (cs))
/* Move by one pixel relatively to current position */
/* pos - position structure */
/* cs - number of the image channels */
/* left */
#define CV_MOVE_LEFT( pos, cs ) \
( --(pos).x >= 0 ? (pos).currline + (pos).x*(cs) : 0 )
/* right */
#define CV_MOVE_RIGHT( pos, cs ) \
( ++(pos).x < (pos).width ? (pos).currline + (pos).x*(cs) : 0 )
/* up */
#define CV_MOVE_UP( pos, cs ) \
(((pos).currline -= (pos).step) != (pos).topline ? (pos).currline + (pos).x*(cs) : 0 )
/* down */
#define CV_MOVE_DOWN( pos, cs ) \
(((pos).currline += (pos).step) != (pos).bottomline ? (pos).currline + (pos).x*(cs) : 0 )
/* left up */
#define CV_MOVE_LU( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_UP(pos, cs))
/* right up */
#define CV_MOVE_RU( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_UP(pos, cs))
/* left down */
#define CV_MOVE_LD( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_DOWN(pos, cs))
/* right down */
#define CV_MOVE_RD( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_DOWN(pos, cs))
/* Move by one pixel relatively to current position with wrapping when the position */
/* achieves image boundary */
/* pos - position structure */
/* cs - number of the image channels */
/* left */
#define CV_MOVE_LEFT_WRAP( pos, cs ) \
((pos).currline + ( --(pos).x >= 0 ? (pos).x : ((pos).x = (pos).width-1))*(cs))
/* right */
#define CV_MOVE_RIGHT_WRAP( pos, cs ) \
((pos).currline + ( ++(pos).x < (pos).width ? (pos).x : ((pos).x = 0))*(cs) )
/* up */
#define CV_MOVE_UP_WRAP( pos, cs ) \
((((pos).currline -= (pos).step) != (pos).topline ? \
(pos).currline : ((pos).currline = (pos).bottomline - (pos).step)) + (pos).x*(cs) )
/* down */
#define CV_MOVE_DOWN_WRAP( pos, cs ) \
((((pos).currline += (pos).step) != (pos).bottomline ? \
(pos).currline : ((pos).currline = (pos).topline + (pos).step)) + (pos).x*(cs) )
/* left up */
#define CV_MOVE_LU_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs))
/* right up */
#define CV_MOVE_RU_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs))
/* left down */
#define CV_MOVE_LD_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs))
/* right down */
#define CV_MOVE_RD_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs))
/* Numeric constants which used for moving in arbitrary direction */
#define CV_SHIFT_NONE 2
#define CV_SHIFT_LEFT 1
#define CV_SHIFT_RIGHT 3
#define CV_SHIFT_UP 6
#define CV_SHIFT_DOWN 10
#define CV_SHIFT_LU 5
#define CV_SHIFT_RU 7
#define CV_SHIFT_LD 9
#define CV_SHIFT_RD 11
/* Move by one pixel in specified direction */
/* pos - position structure */
/* shift - direction ( it's value must be one of the CV_SHIFT_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -