The Essay on learning OpenCV--The 3rd chapter of OPENCV

Source: Internet
Author: User

Cvpoint This type is similar to the corresponding structure in MFC and Qt, and is an integer type X, Y. However, its variant types are cvpoint2d32f and cvpoint3d32f. The former also has two members, but is a floating-point type. The latter is a floating-point type and has a Z.

Cvsize This type is similar to Cvpoint. At the end of this chapter, two types of C language definitions are given. The Cvsize data member is the width and height of the integer type, and if you want to use a floating-point type, you can use cvsize2d32f. The Cvrect type is derived from Cvpoint and Cvsize, which contains 4 members, X,y,width,height.

The cvscalar contains 4 integer members, and Cvscalar has a separate member, Val, which is a pointer to only 4 double-precision floating-point array, double val[4]. This type is important, and many of the matrix manipulation functions are followed by his figure.

cvarr-"cvmat-" iplimage. This belongs in turn, that is, Cvarr as the remaining two parent class. This is similar to C + + and embodies the very strong idea of object-oriented programming. Therefore, when we see the need for the cvarr* type parameter in the formal parameter list, we can consider bringing the two in, so that we can do a series of operations.

The concept of OpenCV matrices is more abstract than linear algebra, especially the elements of matrices, not only numeric types.

The matrix consists of the width, height, type, length of the row data (step, the length of the line in bytes instead of shaping or floating-point length), and a pointer to the data.

typedef struct CVMAT{INT type;int step;int *refcount;union{uchar*ptr;short* s;int * i;float* fl;double *db;} Data;union{int rows;int height;}; Union{int cols;int width;};} Cvmat;

The above code is the type structure of the Cvmat, and we can see that there are three consortia in the 32-bit system, sizeof (CVMAT) = 24.

There are many ways to create matrices, and the most common method is to create them using the Cvcreatemat () function. It consists of several primitive functions, for example, Cvcreatematheader () and Cvcreatedata (). The Cvcreatematheader () function creates the CVMAT structure, does not allocate memory for the data, and the two cvcreatedata () functions are responsible only for the memory allocation of the data. Sometimes, only the function Cvcreatematheader () is required because storage space has been allocated for other reasons, or because storage space is not yet ready to be allocated. The third method uses the function Cvclonemat (cvmat*), which creates a new matrix based on an existing matrix. When the matrix is no longer needed, you can call the function Cvreleasemat (cvmat*) to release it. The above functions, which are basically the meaning in the manual.

Query matrix, we can use function Cvgetelemtype (const cvarr* arr), cvgetdims (const cvarr*arr,int *size=null) and cvgetdimsize (const cvarr*, int index), the first returns an integer constant representing the type of element stored in the array. The second takes out the array and an optional shaping pointer that returns the dimension, and if the integer pointer is not empty, it stores the height and width of the corresponding array. The last function simply returns the size of the matrix on that number by means of an integer indicating the number of dimensions.

Access to matrix data

Macro Cv_mat_elem (), passed in the matrix, the type of element to be extracted, the number of rows and columns 4 parameters, returns the value of the extracted element.

The Essay on learning OpenCV--The 3rd chapter of OPENCV

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.