points, size, rectangle 和 Scalar 三元组的结构
结构 |
成员 |
意义 |
CvPoint | int x, y | 图像中的点 |
CvPoint2D32f | float x, y | 二维空间中的点 |
CvPoint3D32f | float x, y, z | 三维空间中的点 |
CvSize | int width, height | 图像的尺寸 |
CvRect | int x, y, width, height | 图像的部分区域 |
CvScalar | double val[4] | RGBA 值 |
typedef struct CvMat {
int type; // 类型 CV_(S|U|F)C
int step; // 以字节为单位的行数据长度
int* refcount; // for internal use only
union{ // data 指针,4 种类型
uchar* ptr;
short* s;
int* i;
float* fl;
double* db;
}data;
union{ // 行数/高度
int rows;
int height;
};
union{ // 列数/宽度
int cols;
int width;
};
} CvMat;
// create a new rows by cols matrix of type 'type'
CvMat* cvCreateMat(int rows,int cols,int type);
// create only matrix header without allocating data
Cvmat* cvCreateMatHeader(int rows,int cols,int type);
// initialize header on existing CvMat structure
CvMat* cvInitMatHeader(CvMat* mat,int rows,int cols,int type,void* data = NULL,int step = CV_AUTOSTEP);
// like cvinitmatheader() but allocate CvMat as well
CvMat cvMat(int rows,int cols,int type,void* data = NULL);
// allocate a new matricx just like the matrix 'mat'
CvMate* cvCloneMat(const CvMat* mat);
// free the matrix 'mat', both header and data
void cvReleaseMat(CvMat** mat);
// create an OpenCV Matrix containing some fixed data
float vals[] = {0.866025,-0.500000,0.500000,0.866025};
CvMat rotmat;
cvInitMatHeader(&rotmat,2,2,CV_32FC1,vals);
int sizes[CV_MAX_DIM]; int i, total = 1; int dims = cvGetDims(arr, size); for(i = 0; i < dims; i++ ) // 每个维度上的矩阵大小(元素个数)相乘 total *= sizes[i];