OpenCV study notes: infrastructure

CvPoint

Point in 2D coordinate system, type is integer

typedef struct CvPoint
 {
  int x; /* X coordinate, usually based on 0*/
  int y; /* y coordinate, usually based on 0*/
 }
CvPoint;
/* Constructor*/
inline CvPoint cvPoint( int x, int y );
/* Converted from CvPoint2D32f type */
inline CvPoint cvPointFrom32f( CvPoint2D32f point )

CvPoint2D32f

Point in 2D coordinates, type is floating point

typedef struct CvPoint2D32f
 {
  float x; /* X coordinate, usually based on 0*/
  float y; /* Y coordinate, usually based on 0*/
 }
CvPoint2D32f;
/* Constructor*/
inline CvPoint2D32f cvPoint2D32f( double x, double y );
/* Convert from CvPoint to */
inline CvPoint2D32f cvPointTo32f( CvPoint point );

CvPoint3D32f

point in 3D coordinates, type is floating point

typedef struct CvPoint3D32f
 {
  float x; /* x-coordinate, usually based on 0 */
  float y; /* y-coordinate, usually based on 0 */
  float z; /* z-coordinate, usually based on 0 */
 }
 CvPoint3D32f;
/* Constructor*/
inline CvPoint3D32f cvPoint3D32f( double x, double y, double z );

CVSize

The size of the rectangle, in pixels

typedef struct CvSize
 {
  int width; /* rectangle width */
  int height; /* rectangle height */
 }
 CVSize;
/* Constructor*/
inline CvSize cvSize( int width, int height );

Note: the cv of the constructor is lowercase!

CvSize2D32f

Scalar rectangle box size with subpixel precision

typedef struct CvSize2D32f
 {
   float width; /* rectangle width*/
   float height; /* rectangle height */
 }
 CvSize2D32f;
/* Constructor*/
inline CvSize2D32f cvSize2D32f( double width, double height );
{
    CvSize2D32f s;

    s.width = (float)width;
    s.height = (float)height;

    return s;
}

CvRect

Offset and size of the rectangle

typedef struct CvRect
 {
  int x; /* the x-coordinate of the leftmost corner of the square */
  int y; /* The y-coordinate of the top or bottom corner of the square */
  int width; /* 宽 */
  int height; /* height*/
 }
 CvRect;
/* Constructor*/
inline CvRect cvRect( int x, int y, int width, int height );
{
      CvRects;
      
      os.x = x;
      os.y = y;
      os.width = width;
      os.height = heigth;
      
      retrieve them;
}

CvScalar

Container for bundled data that can be stored in 1-, 2-, 3-, 4-TUPLE types

typedef struct CvScalar
 {
  double val[4]
 }
 CvScalar;
/* Constructor: initialize val[0] with val0, initialize val[1] with val1, and so on */
inline CvScalar cvScalar( double val0, double val1,
                           double val2, double val3);

{  CvScalar  arr;
    
    arr.val[4] = {val0,val1,val2,val3};
  
    reture arr;}
/* Constructor: initialize all val[0]...val[3] with val0123 */
inline CvScalar cvScalarAll( double val0123 );
 
  { CvScalar arr;
 
     arr.val[4] = {val0123,val0123,val0123,val0123,};

     reture arr;}
/* Constructor: initialize val[0] with val0, initialize val[1], val[2], val[3] with 0 */
inline CvScalar cvRealScalar( double val0 );

    { CvScalar arr;
       
       arr.val[4] = {val0};
   
       reture arr;}
http://doc.blueruby.mydns.jp/opencv/classes/OpenCV/CvScalar.html

CvTermCriteria

Termination Criteria for Iterative Algorithms

#define CV_TERMCRIT_ITER    1
#define CV_TERMCRIT_NUMBER  CV_TERMCRIT_ITER
#define CV_TERMCRIT_EPS     2

typedef struct CvTermCriteria
 {
  int type; /* One of the binary values ​​of CV_TERMCRIT_ITER and CV_TERMCRIT_EPS, or a combination of the two */
  int max_iter; /* maximum number of iterations */
  double epsilon; /* the precision of the result */
 }
 CvTermCriteria;
/* Constructor*/
inline  CvTermCriteria  cvTermCriteria( int type, int max_iter, double epsilon );
/* Check the termination criterion while satisfying max_iter and epsilon and convert it such that type=CV_TERMCRIT_ITER+CV_TERMCRIT_EPS */
CvTermCriteria cvCheckTermCriteria( CvTermCriteria criteria,
                                    double default_eps,
                                    int default_max_iters);

CvMat

Multichannel matrix

typedef struct CvMat
 {
  int type; /* CvMat flag (CV_MAT_MAGIC_VAL), element type and mark */
  int step; /* row data length in bytes */
  int* refcount; /* data reference count */
  union
   {
    uchar * ptr;
    short* s;
    int* i;
    float* fl;
    double* db;
   } data; / * data fingertip * /
  #ifdef __cplusplus
  union
   {
     int rows;
     int height;
   };
  union
   {
     int cols;
     int width;
   };
  #else
   int rows; /* number of rows*/
   int cols; /* number of columns */
  #endif
 } CvMat;

CvMatND

Multidimensional, multichannel dense arrays

typedef struct CvMatND
    {
        int type; /* CvMatND mark (CV_MATND_MAGIC_VAL), element type and label */
        int dims; /* array dimensions*/

        int* refcount; /* data reference count */

        union
        {
            uchar * ptr;
            short* s;
            int* i;
            float* fl;
            double* db;
        } data; / * data finger * /

        /* The data structure of each dimension (element number, distance between elements in bytes) is defined by the companion */
        struct
        {
            int size;
            int step;
        }
        dim[CV_MAX_DIM];

    } CvMatND;

CvSparseMat

Multidimensional, multichannel sparse arrays

typedef struct CvSparseMat
    {
        int type; /* CvSparseMat identification (CV_SPARSE_MAT_MAGIC_VAL), element type and label */
        int dims; /* dimensions*/
        int* refcount; /* refcount - unused */
        struct CvSet* heap; /* HASH table node pool*/
        void** hashtable; /* HASH table: each entry has a node list with the same "HASH value with HASH size as template" */
        int hashsize; /* HASH table size*/
        int total; /* the number of nodes in the sparse array */
        int valoffset; /* Offset of array node value in bytes */
        int idxoffset; /* Offset of array node index in bytes */
        int size[CV_MAX_DIM]; /*Dimension size*/

    } CvSparseMat;

IplImage

IPL image header

typedef struct _IplImage
    {
        int nSize; / * IplImage , , = sizeof (IplImage) * /
        int ID; /* version (=0)*/
        int nChannels; /* Most OPENCV functions support 1, 2, 3 or 4 channels */
        int alphaChannel; /* ignored by OpenCV */
        int depth; /* Pixel bit depth: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16U,
                               IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported*/
        char colorModel[4]; /* ignored by OpenCV */
        char channelSeq[4]; /* ignored by OpenCV */
        int dataOrder; /* 0 - interleave color channels, for three-channel RGB images, pixel storage order is BGR BGR BGR ... BGR;
                                     1 - Separate color channels, for three-channel RGB images, pixel storage order is RRR...R GGG...G BBB...B.
                                  cvCreateImage can only create interleaved images */
        int origin; /* 0 - top-left structure,
                               1 - bottom-left structure (Windows bitmaps style) */
        int align; /* image line alignment (4 or 8). OpenCV ignores it and uses widthStep instead */
        int width; /* image width in pixels */
        int height; /* image height in pixels */
        struct _IplROI *roi;/* The region of interest in the image. When the value is not empty, only the region is processed*/
        struct _IplImage *maskROI; /* Must be NULL in OpenCV */
        void *imageId; /* same as above*/
        struct _IplTileInfo * tileInfo; / * 同上 * /
        int imageSize; /* Image data size (imageSize=image->height*image->widthStep in interleaved format), in bytes*/
        char *imageData; /* points to the arrayed image data */
        int widthStep; /* The size of the arrayed image line in bytes */
        int BorderMode[4]; /* Border end mode, ignored by OpenCV */
        int BorderConst[4]; /* same as above*/
        char *imageDataOrigin; /* Pointer to a different image data structure (not necessarily arranged), prepared to correct image memory allocation */
    }
    IplImage;
The IplImage structure comes from the Intel Image Processing Library (which it has). OpenCV only supports a subset of them:
alphaChannel is ignored in OpenCV.
colorModel and channelSeq are ignored by OpenCV. The only function for color conversion in OpenCV, cvCvtColor, takes both the color space of the original image and the color space of the target image as a parameter.
dataOrder must be IPL_DATA_ORDER_PIXEL (color channels are interleaved), however selected channels of flat images can be processed as if the COI (channel of interest) were set.
align is ignored by OpenCV, and widthStep is used to access subsequent image lines.
maskROI is not supported. Functions that handle MASK treat it as a separate parameter. MASK is 8-bit in OpenCV, but 1-bit in IPL.
tileInfo is not supported.
BorderMode and BorderConst are not supported. Each OpenCV function processes adjacent pixels of a pixel, usually using a single fixed code margin mode.

In addition to the above limitations, OpenCV has different requirements for handling ROI. It is required that the size of the original image and the target image or the size of the ROI must be exactly matched (according to different operations, such as cvPyrDown, the width (height) of the target image must be equal to the width (height) of the original image divided by 2 ± 1), and IPL handles the intersection Regions such as image size or ROI size may be completely independent.

CvArr

indeterminate array

typedef void CvArr;

CvArr* is only used as a parameter of the function to indicate that the function can receive more than one array type, such as IplImage*, CvMat* or even CvSeq*. The final array type is analyzed at runtime by analyzing the first 4 of the array header Byte judgment.

Content source: OpenCV Infrastructure

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325766024&siteId=291194637