#include<iostream>
#include<opencv2\core\core.hpp>
#include<cv.h>
using namespace cv;
using namespace std;
void main()
{
//创建一个10行3列的矩阵,每个元素由三个通道
Mat r = Mat(10, 3, CV_8UC3);
randu(r, Scalar::all(0), Scalar::all(255));//randu()函数作用,产生随机数,从下限0到上限255,上下限可以调整。
//1.OpenCV3.0的默认的输出风格
cout << "r (OpenCV默认风格) = " << r << ";" << endl << endl;
//2.OpenCV3.0的Python风格
cout << "r (Python风格)=" << format(r, Formatter::FMT_PYTHON) << ";" << endl << endl;
//3.OpenCV3.0的逗号分隔分隔(Comma seperated values,CSV)
cout << "r (逗号分隔风格)=" << format(r, Formatter::FMT_CSV) << ";" << endl << endl;
//4.OpenCV3.0的Numpy风格
cout << "r (Numpy风格)=" << format(r,Formatter::FMT_NUMPY) << ";" << endl << endl;
//5.OpenCV3.0的C语言风格
cout << "r (C语言风格)=" << format(r, Formatter::FMT_C) << ";" << endl << endl;
//6.OpenCV3.0的MATLAB风格
cout << "r (Matlab风格)=" << format(r, Formatter::FMT_MATLAB) << ";" << endl << endl;
//7.OpenCV3.0的default风格,即OpenCV3,0的默认输出风格
cout << "r (default)" << format(r, Formatter::FMT_DEFAULT) << ";" << endl << endl;
}
运行结果: