先初始化一个矩阵
1.Opencv默认风格
代码如下:
include <opencv2/opencv.hpp>
#include"opencv2/highgui/highgui.hpp"
#include<iostream>
using namespace std;
using namespace cv;
int main(int argc,char** argv)
{
Mat r = Mat(10, 3, CV_8UC3);
randu(r, Scalar::all(0), Scalar::all(255));
cout << "r(Opencv默认风格)=" << r << ";" << endl << endl;
}
2.python风格
#include <opencv2/opencv.hpp>
#include"opencv2/highgui/highgui.hpp"
#include<iostream>
using namespace std;
using namespace cv;
int main(int argc,char** argv)
{
Mat r = Mat(10, 3, CV_8UC3);
randu(r, Scalar::all(0), Scalar::all(255));
cout << "r(python风格)=" << format(r,Formatter::FMT_PYTHON)<< ";" << endl << endl;
}
3.逗号分隔风格
#include <opencv2/opencv.hpp>
#include"opencv2/highgui/highgui.hpp"
#include<iostream>
using namespace std;
using namespace cv;
int main(int argc,char** argv)
{
Mat r = Mat(10, 3, CV_8UC3);
randu(r, Scalar::all(0), Scalar::all(255));
cout << "r(逗号分隔风格)=" << format(r,Formatter::FMT_CSV)<< ";" << endl << endl;
}
4.Numpy风格
#include <opencv2/opencv.hpp>
#include"opencv2/highgui/highgui.hpp"
#include<iostream>
using namespace std;
using namespace cv;
int main(int argc,char** argv)
{
Mat r = Mat(10, 3, CV_8UC3);
randu(r, Scalar::all(0), Scalar::all(255));
cout << "r(Numpy风格)=" << format(r,Formatter::FMT_NUMPY)<< ";" << endl << endl;
}
5.c语言风格
#include <opencv2/opencv.hpp>
#include"opencv2/highgui/highgui.hpp"
#include<iostream>
using namespace std;
using namespace cv;
int main(int argc,char** argv)
{
Mat r = Mat(10, 3, CV_8UC3);
randu(r, Scalar::all(0), Scalar::all(255));
cout << "r(c语言风格)=" << format(r,Formatter::FMT_C)<< ";" << endl << endl;
}