OpenCV的5种格式化输出方法Mat类型数据

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;

int main()
{
     system("chcp 65001");  //控制台中文支持
     Mat r = Mat(10, 3, CV_8UC3);
     randu(r, Scalar::all(0), Scalar::all(255));  //randu随机矩阵[0, 255]之间

     cout << "r(opencv默认风格) = " << r << ";" << endl << endl;

    // cout << "r(Python风格_openCV2) = " << format(r, "python") << ";" << endl << endl;
    cout << "r(Python风格_openCV3) = " << format(r, Formatter::FMT_PYTHON) << ";" << endl << endl;

    //cout << "r(,分隔风格_openCV2) = " << format(r, "csv") << ";" << endl << endl;
    cout << "r(,分隔风格_openCV3) = " << format(r, Formatter::FMT_CSV) << ";" << endl << endl;

    //cout << "r(numpy风格_openCV2) = " << format(r, "numpy") << ";" << endl << endl;
    cout << "r(numpy风格_openCV3) = " << format(r, Formatter::FMT_NUMPY) << ";" << endl << endl;

    // cout << "r(C语言风格_openCV2) = " << format(r, "c") << ";" << endl << endl;
    cout << "r(C语言风格_openCV3) = " << format(r, Formatter::FMT_C) << ";" << endl << endl;
    return 0;
}

 

0、准备python

system("chcp 65001");  //控制台中文支持
     Mat r = Mat(10, 3, CV_8UC3);
     randu(r, Scalar::all(0), Scalar::all(255));  //randu随机矩阵[0, 255]之间

一、默认风格ios

cout << "r(opencv默认风格) = " << r << ";" << endl << endl;

二、spa

cout << "r(Python风格_openCV2) = " << format(r, "python") << ";" << endl << endl;
    cout << "r(Python风格_openCV3) = " << format(r, Formatter::FMT_PYTHON) << ";" << endl << endl;

三、code

cout << "r(,分隔风格_openCV2) = " << format(r, "csv") << ";" << endl << endl;
    cout << "r(,分隔风格_openCV3) = " << format(r, Formatter::FMT_CSV) << ";" << endl << endl;

四、orm

cout << "r(numpy风格_openCV2) = " << format(r, "numpy") << ";" << endl << endl;
    cout << "r(numpy风格_openCV3) = " << format(r, Formatter::FMT_NUMPY) << ";" << endl << endl;

五、blog

// cout << "r(C语言风格_openCV2) = " << format(r, "c") << ";" << endl << endl;
    cout << "r(C语言风格_openCV3) = " << format(r, Formatter::FMT_C) << ";" << endl << endl;

 

-----io

相关文章
相关标签/搜索