问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/20797312/converting-opencv-mat-to-array-possibly-nsarray