Basic Data Structure of opencv
Cvpoint: the point in the image.
Cvpoint2d32f: point in two-dimensional space
Cvpoint3d32f: Point in 3D space
These are struct and are not classes in the C ++ language. Therefore, their constructor is a simple inline function.
1 typedef struct CvPoint 2 { 3 int x; 4 int y; 5 } 6 CvPoint; 7 8 9 CV_INLINE CvPoint cvPoint( int x, int y )10 {11 CvPoint p;12 13 p.x = x;14 p.y = y;15 16 return p;17 }
Cv_inline is a macro definition:
1 define CV_INLINE inline
Cvsize: indicates the image size.
Cvsize2d32f: float data indicates the image size
1 typedef struct CvSize 2 { 3 int width; 4 int height; 5 } 6 CvSize; 7 8 CV_INLINE CvSize cvSize( int width, int height ) 9 {10 CvSize s;11 12 s.width = width;13 s.height = height;14 15 return s;16 }
Cvrect indicates part of the image
1 typedef struct CvRect 2 { 3 int x; 4 int y; 5 int width; 6 int height; 7 } 8 CvRect; 9 10 CV_INLINE CvRect cvRect( int x, int y, int width, int height )11 {12 CvRect r;13 14 r.x = x;15 r.y = y;16 r.width = width;17 r.height = height;18 19 return r;20 }
Cvscalar contains four floating point Members, which can be used to represent B, G, R, and Alpha. It has three constructors with specific definitions:
Typedef struct cvscalar
{
Double Val [4];
}
Cvscalar;
// Specify at least one parameter. If the last three parameters do not exist, the default value is 0.
Cv_inline cvscalar (double val0, double val1 cv_default (0 ),
Double val2 cv_default (0), double val3 cv_default (0 ))
{
Cvscalar scalar;
Scalar. Val [0] = val0; scalar. Val [1] = val1;
Scalar. Val [2] = val2; scalar. Val [3] = val3;
Return scalar;
}
// Only assign values to the first parameter, followed by 0
Cv_inline cvscalar cvrealscalar (double val0)
{
Cvscalar scalar;
Scalar. Val [0] = val0;
Scalar. Val [1] = scalar. Val [2] = scalar. Val [3] = 0;
Return scalar;
}
// Assign all four parameters to the input parameter
Cv_inline cvscalar cvscalarall (double val0123)
{
Cvscalar scalar;
Scalar. Val [0] = val0123;
Scalar. Val [1] = val0123;
Scalar. Val [2] = val0123;
Scalar. Val [3] = val0123;
Return scalar;
}
Relationship between cvarr, cvmat, and iplimage
The derivation is: cvarr --> cvmat --> iplimage. When cvarr is used as a function parameter, cvmat is used internally, regardless of whether cvmat or iplimage is passed in.