Opencv Mat 6种输出格式分别是:默认、Matlab、Csv、Python、Numpy、C。
6种输出格式枚举定义。
1 2 3 4 5 6 7 |
enum { FMT_DEFAULT = 0, FMT_MATLAB = 1, FMT_CSV = 2, FMT_PYTHON = 3, FMT_NUMPY = 4, FMT_C = 5 }; |
Opencv Mat 6种输出格式测试代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
//梁笔记 //https://zouzhongliang.com/ #include <iostream> #include <opencv2/opencv.hpp>//opencv的头文件 using namespace std; using namespace cv; int main() { Mat array(10, 3, CV_8UC3); randu(array, Scalar::all(0), Scalar::all(255)); cout << "【默认风格】" << endl << array << endl << endl; cout << "【Python风格】" << endl << format(array, Formatter::FMT_PYTHON) << endl << endl; cout << "【逗号分隔风格】" << endl << format(array, Formatter::FMT_CSV) << endl << endl; cout << "【Numpy风格】" << endl << format(array, Formatter::FMT_NUMPY) << endl << endl; cout << "【C语言风格】" << endl << format(array, Formatter::FMT_C) << endl << endl; return 0; } |
Opencv Mat 6种输出格式测试结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
【默认风格】 [ 91, 2, 79, 179, 52, 205, 236, 8, 181; 239, 26, 248, 207, 218, 45, 183, 158, 101; 102, 18, 118, 68, 210, 139, 198, 207, 211; 181, 162, 197, 191, 196, 40, 7, 243, 230; 45, 6, 48, 173, 242, 125, 175, 90, 63; 90, 22, 112, 221, 167, 224, 113, 208, 123; 214, 35, 229, 6, 143, 138, 98, 81, 118; 187, 167, 140, 218, 178, 23, 43, 133, 154; 150, 76, 101, 8, 38, 238, 84, 47, 7; 117, 246, 163, 237, 69, 129, 60, 101, 41] 【Python风格】 [[[ 91, 2, 79], [179, 52, 205], [236, 8, 181]], [[239, 26, 248], [207, 218, 45], [183, 158, 101]], [[102, 18, 118], [ 68, 210, 139], [198, 207, 211]], [[181, 162, 197], [191, 196, 40], [ 7, 243, 230]], [[ 45, 6, 48], [173, 242, 125], [175, 90, 63]], [[ 90, 22, 112], [221, 167, 224], [113, 208, 123]], [[214, 35, 229], [ 6, 143, 138], [ 98, 81, 118]], [[187, 167, 140], [218, 178, 23], [ 43, 133, 154]], [[150, 76, 101], [ 8, 38, 238], [ 84, 47, 7]], [[117, 246, 163], [237, 69, 129], [ 60, 101, 41]]] 【逗号分隔风格】 91, 2, 79, 179, 52, 205, 236, 8, 181 239, 26, 248, 207, 218, 45, 183, 158, 101 102, 18, 118, 68, 210, 139, 198, 207, 211 181, 162, 197, 191, 196, 40, 7, 243, 230 45, 6, 48, 173, 242, 125, 175, 90, 63 90, 22, 112, 221, 167, 224, 113, 208, 123 214, 35, 229, 6, 143, 138, 98, 81, 118 187, 167, 140, 218, 178, 23, 43, 133, 154 150, 76, 101, 8, 38, 238, 84, 47, 7 117, 246, 163, 237, 69, 129, 60, 101, 41 【Numpy风格】 array([[[ 91, 2, 79], [179, 52, 205], [236, 8, 181]], [[239, 26, 248], [207, 218, 45], [183, 158, 101]], [[102, 18, 118], [ 68, 210, 139], [198, 207, 211]], [[181, 162, 197], [191, 196, 40], [ 7, 243, 230]], [[ 45, 6, 48], [173, 242, 125], [175, 90, 63]], [[ 90, 22, 112], [221, 167, 224], [113, 208, 123]], [[214, 35, 229], [ 6, 143, 138], [ 98, 81, 118]], [[187, 167, 140], [218, 178, 23], [ 43, 133, 154]], [[150, 76, 101], [ 8, 38, 238], [ 84, 47, 7]], [[117, 246, 163], [237, 69, 129], [ 60, 101, 41]]], dtype='uint8') 【C语言风格】 { 91, 2, 79, 179, 52, 205, 236, 8, 181, 239, 26, 248, 207, 218, 45, 183, 158, 101, 102, 18, 118, 68, 210, 139, 198, 207, 211, 181, 162, 197, 191, 196, 40, 7, 243, 230, 45, 6, 48, 173, 242, 125, 175, 90, 63, 90, 22, 112, 221, 167, 224, 113, 208, 123, 214, 35, 229, 6, 143, 138, 98, 81, 118, 187, 167, 140, 218, 178, 23, 43, 133, 154, 150, 76, 101, 8, 38, 238, 84, 47, 7, 117, 246, 163, 237, 69, 129, 60, 101, 41} |