在OpenCV中将向量转换为mat [英] convert vector to mat in OpenCV
本文介绍了在OpenCV中将向量转换为mat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用opencv 2.4.3使用以下代码执行向量到矩阵转换:
I am using opencv 2.4.3 to perform vector to matrix conversion using the following code:
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;
}
但它给出一个错误,说:
But it gives out an error, saying:
OpenCV Error: Unsupported format or combination of formats() in unknown function, file ...\opencv\modules\core\src\out.cpp, line 111
我在这里做错了什么?有没有任何其他方法将此向量转换为矩阵形式?谢谢。
What am I doing wrong here? Is there any other method to convert this vector into matrix form? Thank you.
推荐答案
在文档有一个对Mat构造函数的引用,在其中他们说支持哪些类型的向量:
In the documentation there is a reference to the Mat constructor in which they say which types of vector are supported:
构造函数可以处理任意类型,其中有
正确声明的DataType,即向量元素必须是
原始数字或单一数字元组。
。 p>因此,您使用的类型不受支持,因此您会收到错误。
So the type you are using is not supported and therefore you get an error.
这篇关于在OpenCV中将向量转换为mat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文