Refer to "OpenCV Chinese Reference Manual"
1. Image data structure
(1) IPL : IplImage |-- int nChannels; // number of color channels (1,2,3,4) |-- int depth; // Bit depth of pixels: | // IPL_DEPTH_8U, IPL_DEPTH_8S, | // IPL_DEPTH_16U,IPL_DEPTH_16S, | // IPL_DEPTH_32S,IPL_DEPTH_32F, | // IPL_DEPTH_64F |-- int width; // image width (in pixels) |-- int height; // image height |-- char* imageData; // image data pointer | // Note that color images store data in BGR order |-- int dataOrder; // 0 - Interleave the values of different channels of the pixel to form a single pixel plane | // 1 - Arrange all pixels with the channel value to form several channel planes, and then arrange the planes | // cvCreateImage can only create images with interleaved pixels |-- int origin; // 0 - the pixel origin is the upper left corner, | // 1 - Pixel origin is bottom left corner (Windows bitmaps style) |-- int widthStep; // number of bytes between points in the same column of adjacent rows |-- int imageSize; // image size (in bytes) = height*widthStep |-- struct _IplROI *roi; // The region of interest (ROI) of the image. When the ROI is not empty, the image | // Processing is limited to the ROI area. |-- char *imageDataOrigin; // The data origin pointer when the image data is not aligned | // (need to reallocate image memory correctly) | // (needed for correct image deallocation) |-- int align; // Row alignment of image data: 4 or 8 byte alignment | // There is no such item in OpenCV, use widthSt
2. Matrices and Vectors
(1) Matrix: CvMat // 2D matrix |-- int type; // element type (uchar,short,int,float,double) and flag |-- int step; // The number of bytes of the entire line length |-- int rows, cols; // number of rows and columns |-- int height, width; // matrix height, width, corresponding to rows, cols |-- union data; |-- uchar* ptr; // data pointer for an unsigned char matrix |-- short* s; // data pointer for a short matrix |-- int* i; // data pointer for an integer matrix |-- float* fl; // data pointer for a float matrix |-- double* db; // data pointer for a double matrix CvMatND // N-dimensional matrix |-- int type; // element type (uchar,short,int,float,double) and flag |-- int dims; // matrix dimensions |-- union data; | |-- uchar* ptr; // data pointer for an unsigned char matrix | |-- short* s; // data pointer for a short matrix | |-- int* i; // data pointer for an integer matrix | |-- float* fl; // data pointer for a float matrix | |-- double* db; // data pointer for a double matrix | |-- struct dim[]; // each dimension information |-- size; // number of elements |-- step; // element spacing (bytes) CvSparseMat // N-dimensional sparse matrix
(2) General matrix: CvArr* // only used as parameter of function definition, // Indicates that the function can accept different types of matrices as parameters, // For example: IplImage*, CvMat* or even CvSeq*. // The type of matrix is determined by the first 4 bytes of information in the matrix header
(3) Scalar: CvScalar |-- double val[4]; //4D vector Initialization function: // Example: CvScalar s = cvScalar(double val0, double val1=0, double val2=0, double val3=0); CvScalar s = cvScalar(20.0); s.val[0]=20.0;3. Other structure types
(1 o'clock: CvPoint p = cvPoint(int x, int y); CvPoint2D32f p = cvPoint2D32f(float x, float y); CvPoint3D32f p = cvPoint3D32f(float x, float y, float z); //E.g.: p.x=5.0; p.y=5.0;
(2) Rectangular frame size (in pixels): CvSize r = cvSize(int width, int height); CvSize2D32f r = cvSize2D32f(float width, float height);
(3) Offset and size of the rectangular box: CvRect r = cvRect(int x, int y, int width, int height);