Opencv note (1) Naming rules for data structures (cvmat ,...)

Source: Internet
Author: User
Tags scalar

I checked a lot on the Internet and found that it is better to check the source code for information.

Classes starting with CV do not contain specific data (only store pointers)

Cvmat

typedef struct CvMat{    int type;    int step;    /* for internal use only */    int* refcount;    int hdr_refcount;    union    {        uchar* ptr;        short* s;        int* i;        float* fl;        double* db;    } data;<pre name="code" class="cpp">
# Ifdef _ cplusplus Union {int rows; int height ;}; Union {int Cols; int width ;};# else int rows; int Cols; # endif} cvmat;

 
 
<pre name="code" class="cpp">CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL)){    CvMat m;    assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F );    type = CV_MAT_TYPE(type);    m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type;    m.cols = cols;    m.rows = rows;    m.step = m.cols*CV_ELEM_SIZE(type);    m.data.ptr = (uchar*)data;    m.refcount = NULL;    m.hdr_refcount = 0;    return m;}




 
Cv_inline double cvmget (const cvmat * mat, int row, int col) {// inefficient access! Int type; type = cv_mat_type (mat-> type); Assert (unsigned) Row <(unsigned) mat-> rows & (unsigned) COL <(unsigned) mat-> Cols); If (type = cv_32fc1) Return (float *) (void *) (mat-> data. PTR + (size_t) mat-> step * row) [col]; else {assert (type = cv_64fc1); Return (double *) (void *) (mat-> data. PTR + (size_t) mat-> step * row) [col] ;}} cv_inline void cvmset (cvmat * mat, int row, int Col, double value) {int type; type = cv_mat_type (mat-> type); Assert (unsigned) Row <(unsigned) mat-> rows & (unsigned) COL <(unsigned) mat-> Cols ); if (type = cv_32fc1) (float *) (void *) (mat-> data. PTR + (size_t) mat-> step * row) [col] = (float) value; else {assert (type = cv_64fc1); (double *) (void *) (mat-> data. PTR + (size_t) mat-> step * row) [col] = (double) value ;}}
 
typedef struct CvMatND{    int type;    int dims;    int* refcount;    int hdr_refcount;    union    {        uchar* ptr;        float* fl;        double* db;        int* i;        short* s;    } data;    struct    {        int size;        int step;    }    dim[CV_MAX_DIM];}CvMatND;
 
/* Basic element of the file storage - scalar or collection: */typedef struct CvFileNode{    int tag;    struct CvTypeInfo* info; /* type information            (only for user-defined object, for others it is 0) */    union    {        double f; /* scalar floating-point number */        int i;    /* scalar integer number */        CvString str; /* text string */        CvSeq* seq; /* sequence (ordered collection of file nodes) */        CvFileNodeHash* map; /* map (collection of named file nodes) */    } data;}CvFileNode;




Opencv note (1) Naming rules for data structures (cvmat ,...)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.