OpenCV:fitLine()函数的固定大小错误

时间:2016-05-19 20:04:56

标签: c++ opencv

我目前正在使用OpenCV的fitLine()函数。

这是我的代码:

float lineParams[16];
Mat lineParamsMat(Size(4,4), CV_32F, lineParams);
Point2f points[6];

//point parameters for line
Mat point_mat(Size(1, 6), CV_32FC2, points);

//The line is stored in a row in the lineParamsMat Matrix
fitLine (point_mat, lineParamsMat.row(i), CV_DIST_L2, 0, 0.01, 0.01);

错误发生在最后一行。错误消息,一如既往地清除:

OpenCV Error: Assertion failed (!fixedSize() || ((Mat*)obj)->size.operator()() == Size(_cols, _rows)) in create, file /Applications/opencv-3.1.0/modules/core/src/matrix.cpp, line 2232
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Applications/opencv-3.1.0/modules/core/src/matrix.cpp:2232: error: (-215) !fixedSize() || ((Mat*)obj)->size.operator()() == Size(_cols, _rows) in function create

之前是否有人遇到此错误?

1 个答案:

答案 0 :(得分:0)

证明将lineParamsMat.row()更改为lineParamsMat.col()可以正常工作!