将Vector <Point>转换为Mat

Ben*_*Ben 8 opencv vector image-processing

我尝试使用功能fitLine()OpenCV 2.1,但它需要转换我vector<Point>垫上.我怎样才能做到这一点?

 vector<Point> line_points;
 Vec4f line;
 fitLine(line_points, line, CV_DIST_L2, 0.0, 0.01, 0.01);
Run Code Online (Sandbox Code Playgroud)

Mic*_*man 13

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

fitLine(Mat(line_points), line, CV_DIST_L2, 0.0, 0.01, 0.01);
Run Code Online (Sandbox Code Playgroud)

在文档中提到.