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

我使用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 ...\opencv\modules\core\src\out.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.”

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

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...