Reputation: 1431
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.
any suggestions? and what about 2-Dimensional array?
thank you
Upvotes: 0
Views: 12124
Reputation: 314
You should not use a pointer to Mat, you can do it the following way:
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. Opencv manages the pointers automatically.
Upvotes: 1
Reputation: 21
I think you need to set these first:
matrix size, matrix type
Example in 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/basic_structures.html#mat-mat
Upvotes: 2