1
我正在使用OpenCV fitLine()
函数。OpenCV fitLine例外
有时以下异常抛出:
..\opencv\modules\core\src\matrix.cpp:1219: error: (-215)
dims == 2 && ((size[0] == sz.height && size[1] == sz.width) || (allocateVector
&& size[0] == sz.width && size[1] == sz.height)) in function create
也有一些断言失败:
OpenCV Error: Assertion failed (dims == 2 && ((size[0] == sz.height &&
size[1] == sz.width) || (allocateVector && size[0] == sz.width &&
size[1] == sz.height))) in create
有人曾经similiar问题?拟合线可能点太差了?我应该更改fitLine()
函数参数吗?
代码
cv::Vec4f newLine;
if(temp.size() >= 2)
{
qDebug()<<"Correcting line";
std::vector<cv::Point2f> temp2;
for(std::vector<std::pair<cv::Point2f,float> >::iterator i = temp.begin();
i != temp.end(); i++)
{
temp2.push_back((*i).first);
}
qDebug()<<"temp2 size: "<<temp2.size();
try{
cv::fitLine(temp2,newLine,CV_DIST_HUBER,0,0.01,0.01);
}
catch(cv::Exception e)
{
qDebug()<<e.what();
}
我已经改变了Vec4f newLine
到std::vector<float> newLine(4)
和它的作品。为什么?
增加了代码。 'temp2'总是大于2. – krzych
将'Vec4f newLine更改为'std :: vector newLine [4],并且一切正常。为什么? –
krzych
它不适用于newLine作为Vec4f,但与newLine一起使用作为矢量?不知道为什么。 fitLine需要一个OutputArray参数,不知道兼容性btw OutputArray,VecXf和向量 –
remi