将OpenCV Mat转换为数组(可能是NSArray) [英] Converting OpenCV Mat to array (possibly NSArray)

查看:123
本文介绍了将OpenCV Mat转换为数组(可能是NSArray)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的C/C ++技能生锈,并且OpenCV的文档非常晦涩.有没有一种方法可以将cv::Mat data属性转换为array/NSArray?

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?

我想将其序列化为JSON,我知道我可以使用FileStorage实用程序转换为YAML/XML,但这不是我想要的.

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.

垫子-> NSArray-> JSON

Mat -> NSArray -> JSON

(我想将相机的固有校准值发送到服务器)

(I want to send intrinsic camera calibration values to the server)

谢谢

推荐答案

您可以使用:

double *d = intrinsics.ptr<double>(0);

这将为您提供9个双打的数组. (这只是强制转换,因此请注意不要让内部函数Mat超出范围.)

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.)

double d = intrinsics.at<double>(i,j);

访问单个元素.

这篇关于将OpenCV Mat转换为数组(可能是NSArray)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆