Mat:
The matrix header contains the size of matrices;
A pointer contains the values in the matrix. To create a mat:
Mat M (2,2,cv_8uc3,scalar (0,0,125));
Note: 2,2 represents matrix size;
CV_8UC3 says
Cv_[the number of bits per itrm][signed or Unsigned][type prefix]c[the channel number];
Scalar (0,0,125) represents the initial value.
Use the Create () function
M.create (4,4,CV_8UC (2));
Note: You cannot initialize a matrix using this method.
To create a special mat matrix:
0 Matrix--zeros ()
Mat Zero=mat::zeros (3,3,CV_8UC1);
Unit Matrix--eye ()
Mat I=mat::eye (4,4,cv_64f);
All 1 matrix--ones ()
Mat One=mat::ones (2,2,cv_32f);
Other common output items:
The point
POINT2F P (5, 1);
cout << "point (2D) =" << P << endl << Endl;
3D Point
point3f p3f (2, 6, 7);
cout << "point (3D) =" << p3f << endl << Endl;
Std::vector via Cv::mat
Vector<float> v;
V.push_back ((float) cv_pi); V.push_back (2); V.push_back (3.01f);
cout << "Vector of floats via Mat =" << Mat (v) << Endl << Endl;
Std::vector of Points
Vector<point2f> vpoints ();
for (size_t i = 0; i < vpoints.size (); ++i)
vpoints[i] = point2f ((float) (i * 5), (float) (i% 7));
cout << "A vector of 2D Points =" << vpoints << endl << Endl;