Reputation: 5217
My C/C++ skills are rusty and the documentation for OpenCV is pretty obscure. Is there a way of getting a cv::Mat
data
attribute converted to array/NSArray?
I want to serialize it to JSON, I know I can use the FileStorage utility to convert to YAML/XML, but that's not what I want to do.
Mat -> NSArray -> JSON
(I want to send intrinsic camera calibration values to the server)
Thanks
Upvotes: 3
Views: 3066
Reputation: 39796
you can use:
double *d = intrinsics.ptr<double>(0);
this will give you an array of 9 doubles. (it's just a cast, so be careful not to let the intrinsics Mat go out of scope.)
or
double d = intrinsics.at<double>(i,j);
to access a single element.
Upvotes: 3