Mat的格式化输出
作者:
小小蒟蒻
,
2021-11-13 00:45:25
,
所有人可见
,
阅读 302
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat mat(2, 3, CV_8UC3);
randu(mat, Scalar(0), Scalar(255)); // 生成随机矩阵
cout << "default: \n" << mat << endl; // 直接输出是默认格式
cout << "python format: \n" << format(mat, Formatter::FMT_PYTHON) << endl;
cout << "csv format: \n" << format(mat, Formatter::FMT_CSV) << endl;
cout << "numpy format: \n" << format(mat, Formatter::FMT_NUMPY) << endl;
cout << "c format: \n" << format(mat, Formatter::FMT_C) << endl;
cout << "matlab format: \n" << format(mat, Formatter::FMT_MATLAB) << endl;
cout << "default format: \n" << format(mat, Formatter::FMT_DEFAULT) << endl;
return 0;
}