opencv函数“convertPointsFromHomogeneous”给出错误消息“通道数或列数或行数必须= 1”

时间:2014-11-26 13:21:55

标签: c++ opencv

我尝试使用方法convertPointsFromHomogeneous,如下所示:

Mat coord(1, 3, CV_32F, Scalar(3)),
    homo;
cout<<coord<<endl
    <<coord.channels()<<", "<<coord.size()<<endl;
cv::convertPointsFromHomogeneous(coord, homo);

cout给了我:

[3, 3, 3]
1, [3 x 1]

convertPointsFromHomogeneous收到错误消息:

  

OpenCV错误:输入数组的大小不正确(数量为   通道或列或行必须= 1)in   cvConvertPointsHomogeneous,文件...... \ modules \ c   alib3d \ src \ fundam.cpp,第865行

var coord只有一行,那么错误究竟发生在哪里?


我跟踪了源代码 fundam.cpp ,第862行:

else
{
    if( !((src->rows > 1) ^ (CV_MAT_CN(src->type) > 1)) )
        CV_Error( CV_StsBadSize, "Either the number of channels or columns or rows must be =1" );

    s_dims = CV_MAT_CN(src->type)*src->rows;
    s_count = src->cols;
}

var src->rows1src->type0x42424005,这使得CV_MAT_CN(src->type)1,所以我怀疑逻辑是错了,是真的吗?

0 个答案:

没有答案