加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 将矢量转换为OpenCV中的图块

发布时间:2020-12-16 05:28:39 所属栏目:百科 来源:网络整理
导读:我使用opencv 2.4.3使用以下代码执行向量到矩阵转换: struct Component{ cv::Rect box; double area; double circularity; }int main ( ... ){ cv::vector Component components; cv::Mat componentMat ( components,true ); std::cout componentMat; retur
我使用opencv 2.4.3使用以下代码执行向量到矩阵转换:
struct Component
{
    cv::Rect box;
    double area;
    double circularity; 
}

int main ( ... )
{
     cv::vector < Component > components;         
     cv::Mat componentMat ( components,true );
     std::cout << componentMat;
     return 0; 
}

但是它发出一个错误,说:

OpenCV Error: Unsupported format or combination of formats() in unknown function,file ...opencvmodulescoresrcout.cpp,line 111

我在这里做错了什么?有没有其他方法将此向量转换为矩阵形式?谢谢.

解决方法

在 the documentation中,有一个Mat构造函数的引用,它们表示支持哪种类型的向量:

“The constructor can handle arbitrary types,for which there is
properly declared DataType,i.e. the vector elements must be
primitive numbers or uni-type numerical tuples of numbers
. Mixed-type
structures are not supported
,of course.”

所以您所使用的类型不受支持,因此您会收到错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读