opencv 各种输出格式

#include <iostream>
#include "opencv2/opencv.hpp"
#include <stdlib.h>

using namespace std;
using namespace cv;

int main(int argc, char ** argv)
{
    //创建一个矩阵,填充范围由randu()函数的第二个参数和第三个参数确定
    Mat R = Mat(3, 2, CV_8UC3);
    randu(R, Scalar::all(0), Scalar::all(255));

    //默认输出格式
    cout << "R (default) = " << endl << R << endl << endl;

    //以python格式输出
    cout << "R (Python) = " << endl << format(R, Formatter::FMT_PYTHON) << endl << endl;

    //以逗号分割格式输出
    cout << "R (csv) = " << endl << format(R, Formatter::FMT_CSV) << endl << endl;

    //以numpy格式输出
    cout << "R (numpy) = " << endl << format(R, Formatter::FMT_NUMPY) << endl << endl;

    //以C语言格式输出
    cout << "R (C) = " << endl << format(R, Formatter::FMT_C) << endl << endl;

    //二维点
    Point2f P(5,1);
    cout << "Point (2D) = " << P << endl << endl;

    //三维点
    Point3f P3f(2, 6, 7);
    cout << "Point (3D) = " << P3f << endl << endl;
}

最终结果:

522DD93F-17A6-4ADC-8D47-BCD70E64FC8D.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容