#include <iostream>
#include "opencv2/opencv.hpp"
#include <stdlib.h>
using namespace std;
using namespace cv;
int main(int argc, char ** argv)
{
//创建一个矩阵,填充范围由randu()函数的第二个参数和第三个参数确定
Mat R = Mat(3, 2, CV_8UC3);
randu(R, Scalar::all(0), Scalar::all(255));
//默认输出格式
cout << "R (default) = " << endl << R << endl << endl;
//以python格式输出
cout << "R (Python) = " << endl << format(R, Formatter::FMT_PYTHON) << endl << endl;
//以逗号分割格式输出
cout << "R (csv) = " << endl << format(R, Formatter::FMT_CSV) << endl << endl;
//以numpy格式输出
cout << "R (numpy) = " << endl << format(R, Formatter::FMT_NUMPY) << endl << endl;
//以C语言格式输出
cout << "R (C) = " << endl << format(R, Formatter::FMT_C) << endl << endl;
//二维点
Point2f P(5,1);
cout << "Point (2D) = " << P << endl << endl;
//三维点
Point3f P3f(2, 6, 7);
cout << "Point (3D) = " << P3f << endl << endl;
}
最终结果:

522DD93F-17A6-4ADC-8D47-BCD70E64FC8D.png