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