(1)使用Mat构造函数
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main() {
Mat mat(3, 2, CV_8UC3, Scalar(0, 0, 255));
cout << "mat = " << endl << mat << endl;
cout << "mat.size = " << mat.size << endl;
return 0;
}
运行结果:
mat =
[ 0, 0, 255, 0, 0, 255;
0, 0, 255, 0, 0, 255;
0, 0, 255, 0, 0, 255]
mat.size = 3 x 2
(2)