Opencv mat type definition and assignment

Source: Internet
Author: User

For details, please refer to the relevant part of the official website links: http://docs.opencv.org/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.html

1. General mat definition method: CV: mat M (height, width, <type>), for example:

CV: mat M (480,640, cv_8uc3); defines a matrix of 480 rows and 640 columns. Each unit of the matrix consists of three (C3: 3 channels) the 8-bit unsigned u8 is composed of unsigned u8 digits.

2. assign an existing array to the mat matrix:

CV: mat M = CV: MAT (height, width, <type>, data), for example:

Float K [3] [3] = {FC [0], 0, CC [0], 0, FC [1], CC [1], 0, 0, 1}; // camera parameter matrix k cv: mat Mk = CV: MAT (, cv_32fc1, k); // The parameter k mat Type Variable

3. Initialization methods similar to MATLAB: zeros (), ones (), and eyes:

CV: mat M = CV: mat: Eye (height, width, <type>)

CV: mat M = CV: mat: ones (height, width, <type>)

CV: mat M = CV: mat: zeros (height, width, <type>)

4. assign a value to a given value of the Small matrix:

CV: mat M = (CV: mat _ <type> (height, width) <0)

Obtain the following matrix m =

[0-1 0

-1 5-1

0-1 0]

 

Opencv mat type definition and assignment

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.