[英]assign a double matrix to CvMat opencv
It is look trivial. 看起来微不足道。 I tried this
我试过了
double d[2];
CvMat* cvdata;
cvdata->data.db = d;
when I using debugging mood it seems that only the first element assigned to cvdata. 当我使用调试心情时,似乎只有第一个元素分配给cvdata。
any suggestions? 有什么建议么? and what about 2-Dimensional array?
那二维数组呢?
thank you 谢谢
I think you need to set these first: 我认为您需要先设置这些:
matrix size, matrix type 矩阵大小,矩阵类型
Example in C++: C ++中的示例:
double d[2];
cv::Mat* cvdata = new cv::Mat(1, 2, CV_64F);
.
.
.
http://opencv.itseez.com/modules/core/doc/intro.html#fixed-pixel-types-limited-use-of-templates http://opencv.itseez.com/modules/core/doc/intro.html#fixed-pixel-types-limited-use-of-templates
http://opencv.itseez.com/modules/core/doc/basic_structures.html#mat-mat http://opencv.itseez.com/modules/core/doc/basic_structures.html#mat-mat
You should not use a pointer to Mat, you can do it the following way: 您不应该使用指向Mat的指针,可以通过以下方式做到这一点:
int rows = ..;
int cols = ..;
cv::Mat cvdata(rows, cols, cv::DataType<double>::type);
when you copy cvdata or pass it as argument only a copy of the cv::Mat's header is created the internal data i copied. 当您复制cvdata或将其作为参数传递时,只会创建我复制的cv :: Mat标头的副本。 Opencv manages the pointers automatically.
Opencv自动管理指针。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.