📄 cvtypes.h
字号:
m.step = m.cols*CV_ELEM_SIZE(type);
m.data.ptr = (uchar*)data;
m.refcount = NULL;
return m;
}
#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \
(assert( (unsigned)(row) < (unsigned)(mat).rows && \
(unsigned)(col) < (unsigned)(mat).cols ), \
(mat).data.ptr + (mat).step*(row) + (pix_size)*(col))
#define CV_MAT_ELEM_PTR( mat, row, col ) \
CV_MAT_ELEM_PTR_FAST( mat, row, col, CV_ELEM_SIZE((mat).type) )
#define CV_MAT_ELEM( mat, elemtype, row, col ) \
(*(elemtype*)CV_MAT_ELEM_PTR_FAST( mat, row, col, sizeof(elemtype)))
CV_INLINE double cvmGet( const CvMat* mat, int i, int j );
CV_INLINE double cvmGet( const CvMat* mat, int i, int j )
{
int type;
type = CV_MAT_TYPE(mat->type);
assert( (unsigned)i < (unsigned)mat->rows &&
(unsigned)j < (unsigned)mat->cols );
if( type == CV_32FC1 )
return ((float*)(mat->data.ptr + i*mat->step))[j];
else
{
assert( type == CV_64FC1 );
return ((double*)(mat->data.ptr + i*mat->step))[j];
}
}
CV_INLINE void cvmSet( CvMat* mat, int i, int j, double val );
CV_INLINE void cvmSet( CvMat* mat, int i, int j, double val )
{
int type;
type = CV_MAT_TYPE(mat->type);
assert( (unsigned)i < (unsigned)mat->rows &&
(unsigned)j < (unsigned)mat->cols );
if( type == CV_32FC1 )
((float*)(mat->data.ptr + i*mat->step))[j] = (float)val;
else
{
assert( type == CV_64FC1 );
((double*)(mat->data.ptr + i*mat->step))[j] = (double)val;
}
}
/****************************************************************************************\
* Multi-dimensional dense array (CvMatND) *
\****************************************************************************************/
#define CV_MATND_MAGIC_VAL 0x42430000
#define CV_MAX_DIM 16
#define CV_MAT_LIKE_FLAG_SHIFT 11
#define CV_MAT_LIKE_FLAG (1 << CV_MAT_LIKE_FLAG_SHIFT)
typedef struct CvMatND
{
int type;
int dims;
int* refcount;
union
{
uchar* ptr;
float* fl;
double* db;
int* i;
short* s;
} data;
struct
{
int size;
int step;
}
dim[CV_MAX_DIM];
}
CvMatND;
#define CV_IS_MATND_HDR(mat) \
((mat) != NULL && (((const CvMatND*)(mat))->type & CV_MAGIC_MASK) == CV_MATND_MAGIC_VAL)
#define CV_IS_MATND(mat) \
(CV_IS_MATND_HDR(mat) && ((const CvMatND*)(mat))->data.ptr != NULL)
/****************************************************************************************\
* Multi-dimensional sparse array (CvSparseMat) *
\****************************************************************************************/
#define CV_SPARSE_MAT_MAGIC_VAL 0x42440000
struct CvSet;
typedef struct CvSparseMat
{
int type;
int dims;
int* refcount;
struct CvSet* heap;
void** hashtable;
int hashsize;
int total;
int valoffset;
int idxoffset;
int size[CV_MAX_DIM];
}
CvSparseMat;
#define CV_IS_SPARSE_MAT_HDR(mat) \
((mat) != NULL && \
(((const CvSparseMat*)(mat))->type & CV_MAGIC_MASK) == CV_SPARSE_MAT_MAGIC_VAL)
#define CV_IS_SPARSE_MAT(mat) \
CV_IS_SPARSE_MAT_HDR(mat)
/**************** iteration through a sparse array *****************/
typedef struct CvSparseNode
{
unsigned hashval;
struct CvSparseNode* next;
}
CvSparseNode;
typedef struct CvSparseMatIterator
{
CvSparseMat* mat;
CvSparseNode* node;
int curidx;
}
CvSparseMatIterator;
#define CV_NODE_VAL(mat,node) ((void*)((uchar*)(node) + (mat)->valoffset))
#define CV_NODE_IDX(mat,node) ((int*)((uchar*)(node) + (mat)->idxoffset))
/****************************************************************************************\
* Histogram *
\****************************************************************************************/
typedef int CvHistType;
#define CV_HIST_MAGIC_VAL 0x42450000
#define CV_HIST_UNIFORM_FLAG (1 << 10)
/* indicates whether bin ranges are set already or not */
#define CV_HIST_RANGES_FLAG (1 << 11)
#define CV_HIST_ARRAY 0
#define CV_HIST_SPARSE 1
#define CV_HIST_TREE CV_HIST_SPARSE
#define CV_HIST_UNIFORM 1 /* should be used as a parameter only,
it turns to CV_HIST_UNIFORM_FLAG of hist->type */
typedef struct CvHistogram
{
int type;
CvArr* bins;
float thresh[CV_MAX_DIM][2]; /* for uniform histograms */
float** thresh2; /* for non-uniform histograms */
CvMatND mat; /* embedded matrix header for array histograms */
}
CvHistogram;
#define CV_IS_HIST( hist ) \
((hist) != NULL && \
(((CvHistogram*)(hist))->type & CV_MAGIC_MASK) == CV_HIST_MAGIC_VAL && \
(hist)->bins != NULL)
#define CV_IS_UNIFORM_HIST( hist ) \
(((hist)->type & CV_HIST_UNIFORM_FLAG) != 0)
#define CV_IS_SPARSE_HIST( hist ) \
CV_IS_SPARSE_MAT((hist)->bins)
#define CV_HIST_HAS_RANGES( hist ) \
(((hist)->type & CV_HIST_RANGES_FLAG) != 0)
/****************************************************************************************\
* Other supplementary data type definitions *
\****************************************************************************************/
/* ************************************************************* *\
substitutions for round(x), floor(x), ceil(x):
the algorithm was taken from Agner Fog's optimization guide
at http://www.agner.org/assem
\* ************************************************************* */
CV_INLINE int cvRound( double val );
CV_INLINE int cvRound( double val )
{
double temp = val + 6755399441055744.0;
return (int)*((uint64*)&temp);
}
CV_INLINE int cvFloor( double val );
CV_INLINE int cvFloor( double val )
{
double temp = val + 6755399441055744.0;
float diff = (float)(val - (int)*((uint64*)&temp));
return (int)*((uint64*)&temp) - (*(int*)&diff < 0);
}
CV_INLINE int cvCeil( double val );
CV_INLINE int cvCeil( double val )
{
double temp = val + 6755399441055744.0;
float diff = (float)((int)*((uint64*)&temp) - val);
return (int)*((uint64*)&temp) + (*(int*)&diff < 0);
}
/*************************************** CvRect *****************************************/
typedef struct CvRect
{
int x;
int y;
int width;
int height;
}
CvRect;
CV_INLINE CvRect cvRect( int x, int y, int width, int height );
CV_INLINE CvRect cvRect( int x, int y, int width, int height )
{
CvRect r;
r.x = x;
r.y = y;
r.width = width;
r.height = height;
return r;
}
CV_INLINE IplROI cvRectToROI( CvRect rect, int coi CV_DEFAULT(0));
CV_INLINE IplROI cvRectToROI( CvRect rect, int coi )
{
IplROI roi;
roi.xOffset = rect.x;
roi.yOffset = rect.y;
roi.width = rect.width;
roi.height = rect.height;
roi.coi = coi;
return roi;
}
CV_INLINE CvRect cvROIToRect( IplROI roi );
CV_INLINE CvRect cvROIToRect( IplROI roi )
{
return cvRect( roi.xOffset, roi.yOffset, roi.width, roi.height );
}
/*********************************** CvTermCriteria *************************************/
#define CV_TERMCRIT_ITER 1
#define CV_TERMCRIT_NUMB CV_TERMCRIT_ITER
#define CV_TERMCRIT_EPS 2
typedef struct CvTermCriteria
{
int type; /* may be combination of
CV_TERMCRIT_ITER
CV_TERMCRIT_EPS */
int maxIter;
double epsilon;
}
CvTermCriteria;
CV_INLINE CvTermCriteria cvTermCriteria( int type, int maxIter, double epsilon );
CV_INLINE CvTermCriteria cvTermCriteria( int type, int maxIter, double epsilon )
{
CvTermCriteria t;
t.type = type;
t.maxIter = maxIter;
t.epsilon = (float)epsilon;
return t;
}
/******************************* CvPoint and variants ***********************************/
typedef struct CvPoint
{
int x;
int y;
}
CvPoint;
CV_INLINE CvPoint cvPoint( int x, int y );
CV_INLINE CvPoint cvPoint( int x, int y )
{
CvPoint p;
p.x = x;
p.y = y;
return p;
}
typedef struct CvPoint2D32f
{
float x;
float y;
}
CvPoint2D32f;
CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y );
CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y )
{
CvPoint2D32f p;
p.x = (float)x;
p.y = (float)y;
return p;
}
CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint pt );
CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint pt )
{
return cvPoint2D32f( (float)pt.x, (float)pt.y );
}
CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f pt );
CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f pt )
{
return cvPoint( cvRound(pt.x), cvRound(pt.y) );
}
typedef struct CvPoint3D32f
{
float x;
float y;
float z;
}
CvPoint3D32f;
CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z );
CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z )
{
CvPoint3D32f p;
p.x = (float)x;
p.y = (float)y;
p.z = (float)z;
return p;
}
typedef struct CvPoint2D64d
{
double x;
double y;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -