0
点赞
收藏
分享

微信扫一扫

OpenCV 常用数据结构输出

#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main(int argc, char ** argv)
{
// 定义和输出二维点
Point2f p2f(6, 2);
cout << "【二维点】 P2f = " << p2f << ";\n" << endl;

// 定义和输出三维点
Point3f p3f(8, 2, 0);
cout << "【三维点】 p2f = " << p3f << ";\n" << endl;

// 定义和输出基于 Mat 的 std::vector
vector<float> v;
v.push_back(3);
v.push_back(5);
v.push_back(7);
cout << "【基于 Mat 的 vector】 shortvec = " << Mat(v) << ";\n" << endl;

// 定义和输出 std::vector 点
vector<Point2f> points(20);
for (size_t i = 0; i < points.size(); ++i) {
points[i] = Point2f((float)(i * 5), (float)(i % 7));
}

cout << "【二维点向量】 points = " << points << ";\n";

return 0;
}

运行:

【二维点】 P2f = [6, 2];

【三维点】 p2f = [8, 2, 0];

【基于 Mat 的 vector】 shortvec = [3;
5;
7];

【二维点向量】 points = [0, 0;
5, 1;
10, 2;
15, 3;
20, 4;
25, 5;
30, 6;
35, 0;
40, 1;
45, 2;
50, 3;
55, 4;
60, 5;
65, 6;
70, 0;
75, 1;
80, 2;
85, 3;
90, 4;
95, 5];




参考:

《OpenCV3 编程入门》 毛星云 P94



举报

相关推荐

0 条评论