转换矢量<点>到Mat [英] Convert Vector<Point> to Mat

查看:105
本文介绍了转换矢量<点>到Mat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 openCV 2.1 中的函数 fitLine(),但需要转换我的向量< Point> 到Mat。我该怎么做?

I try to use the function fitLine() from OpenCV 2.1, but it's needed to convert my vector<Point> to Mat. How can i do this?

 vector<Point> line_points;
 Vec4f line;
 fitLine(line_points, line, CV_DIST_L2, 0.0, 0.01, 0.01);


推荐答案

实际上非常简单 - Mat 提供了一个构造函数,用于在点向量和 Mat 之间进行转换。所有你需要的是:

It's actually very simple - Mat provides a constructor for conversion between vector of points and a Mat. All you need is this:

fitLine(Mat(line_points), line, CV_DIST_L2, 0.0, 0.01, 0.01);

这是提到的文档

这篇关于转换矢量&lt;点&gt;到Mat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆