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

相關文章
相關標籤/搜索