我正在使用 opencv 2.4.3 使用以下代码执行 vector 到矩阵的转换:
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
我在这里做错了什么?还有其他方法可以将此 vector 转换为矩阵形式吗?谢谢你。
最佳答案
在the documentation有一个对 Mat 构造函数的引用,其中他们说支持哪些类型的 vector :
"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++ - 在 OpenCV 中将 vector 转换为垫子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13699901/