The following types can be forgotten Wensengyi
Cvpoint
Cvsize
Cvrect
Cvscalar//scalar translation as scalars
typedef struct CVSCALAR
{
Double val[4];
}
Cvscalar; So cvscalar can exist a color space value such as: Rgba color space
These four types of C language version are structured, members are integral type (specific can go to their header file view)
Add 2d32f, 2d64f, 3d32f, and 3d64f into a float or double type.
These 4 types of functions are generated (following can be added 2d32f, etc.):
Cvpoint
Cvsize
Cvrect
Cvscalar
Characteristics:
If CV, the data type
If CV, the function that produces the corresponding data type
Matrix and Image types OpenCV 2.0+ versions can be divided into C and C + +, the C + + version is encapsulated as a class, (the header file is. hpp, defined in the CV namespace, with using namespace CV, functions and classes do not need to add CVS, such as the class is cv::m at).
C language version of the structure, the corresponding header file is (*.h), so the function and type prefix are CV or CV or CV
Cvarr Not for type
View header file discovery: #typedef void Cvarr, there are a number of functions passing in this type of pointer, void *,,,: where you typically need to pass in cvarr*, you can pass in cvmat* or iplimage* pointers
Cvmat Matrix, Image type
Iplimage Types of storage images
The storage types are:
Cv_
RGBA color space, RGB for red-green-blue, alpha-channel for opacity
Cvmat the corresponding function:
Cvapi (cvmat*) cvcreatemat (int rows, int cols, int type);//create Cvmat struct and its assigned data
Cvapi (cvmat*) cvcreatematheader (int rows, int cols, int type);//Generate only Cvmat structure
Cvapi (void) cvcreatedata (cvarr* arr); Assigning data spaces to Cvmat
Cvapi (cvmat*) cvclonemat (const cvmat* MAT)//Full clone Cvmat, including data
Cvapi (cvmat*) Cvinitmatheader (cvmat* mat, int rows, int cols, int type, void* data Cv_default (NULL), int step Cv_default ( Cv_autostep));//Initialize the existing Cvmat type
Cvapi (void) Cvreleasemat (cvmat** mat);
CVAPI (int) cvgetelemtype (const cvarr* arr)
CVAPI (int) cvgetdims (const cvarr* arr, int* sizes Cv_default (NULL));
CVAPI (int) cvgetdimsize (const cvarr* arr, int index)
Cvmat Data read: 1. To use a macro (simple method):
Cv_mat_elem//cv_mat_elem (MAT, Elemtype, Row, col) returns the value of the Elemtype type, read-only
CV_MAT_ELEM_PTR//returns void * Pointer, used to force itself into the corresponding type
#define Cv_mat_elem (Mat, Elemtype, Row, col) (* (elemtype*) Cv_mat_elem_ptr_fast (Mat, row, col, sizeof (elemtype)))
#define CV_MAT_ELEM_PTR (Mat, Row, col) Cv_mat_elem_ptr_fast (Mat, Row, col, Cv_elem_size ((MAT). Type))
2. Troublesome method (get values or pointers with a function)
Cvapi (double) cvgetreal1d (const cvarr* arr, int idx0)//one-dimensional
Cvapi (double) cvgetreal2d (const cvarr* arr, int idx0, int idx1)//Two D
Cvapi (double) Cvgetreal3d (const cvarr* arr, int idx0, int idx1, int idx2)
Cvapi (double) cvgetrealnd (const cvarr* arr, const int* IDX)
Cvapi (cvscalar) cvget1d (const cvarr* arr, int idx0)
Cvapi (cvscalar) cvget2d (const cvarr* arr, int idx0, int idx1)
Cvapi (cvscalar) Cvget3d (const cvarr* arr, int idx0, int idx1, int idx2)
Cvapi (cvscalar) cvgetnd (const cvarr* arr, const int* IDX)
This is the way to get the matrix value.
The one with real can only be used in the single-channel matrix!
A matrix without real that can be used in any number of channels, the returned value is a cvscalar
If it is a single channel, then the Cvscalar is stored in 4 double, only the first one is useful. If the matrix is an RGB image, the value obtained at (row,col) RGB corresponds exactly to the first three double members of Cvscalar
Because the storage of image data, such as for RGB color space, is interleaved: Rgbrgbrgbrgb ...
How to get the pointer to an element:
Cvapi (uchar*) cvptr1d (const cvarr* arr, int idx0, int* type Cv_default (NULL))
Cvapi (uchar*) cvptr2d (const cvarr* arr, int idx0, int idx1, int* type Cv_default (NULL))
Cvapi (uchar*) cvptr3d (const cvarr* arr, int idx0, int idx1, int idx2, int* type Cv_default (NULL))
These three functions are given a uchar*-type pointer, the unsigned char * pointer, which must be coerced into a corresponding pointer when used, such as double *, float *, int *, etc.
The corresponding functions are also read and stored:
Cvapi (void) cvsetreal1d (cvarr* arr, int idx0, double value)//pair single channel
... ... 3D.. 4D.. ND
Cvapi (void) cvset1d (cvarr* arr, int idx0, cvscalar value)//on multi-channel
.. ... 3D.. 4D
For floating-point single channels there is a dedicated function access (that is, type CV_64FC1):
Cv_inline double cvmget (const cvmat* mat, int row, int col)
cv_inline void Cvmset (cvmat* mat, int row, int col, double value)
Appropriate method (direct manipulation with pointers)
Do image processing is computationally intensive, using the above function to access the method will be slower,
There is a step member in the Cvmat and Iplimage types, and the step member refers to the number of bytes in a row