如何将unsafemutablerawpointer作为目标C ++的C指针传递? [英] how can I pass unsafemutablerawpointer as a C's pointer to objective c++?

查看:159
本文介绍了如何将unsafemutablerawpointer作为目标C ++的C指针传递?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将CoreML模型集成到我的应用程序中.输出由MLMultiArray给出,但是我想要其中的数据以便生成OpenCV矩阵. MLMultiArray中有一个dataPointer属性,它是一个UnsafeMutableRawPointer.如何将其作为C的指针传递,以便可以直接使用它生成OpenCV矩阵?

I'm trying to integrate CoreML model into my app. The output is given by a MLMultiArray, but I want the data in it in order to generate an OpenCV matrix. There is a dataPointer property in MLMultiArray, which is a UnsafeMutableRawPointer. How can I pass it as a C's pointer so that I can directly use it to generate an OpenCV matrix?

提前谢谢!

推荐答案

我找到了解决方案.我不需要将dataPointer作为C的指针从Swift传递到Objective-C ++.只要导入obj-c ++文件,我就可以传递整个MLMultiArray.然后我可以直接使用dataPointer来获取OpenCV Mat

I found a solution. I don't need to pass the dataPointer as C's pointer from Swift to Objective-C++. I can just pass the whole MLMultiArray as long as I import in the obj-c++ file. And then I can directly use dataPointer to get a OpenCV Mat

这篇关于如何将unsafemutablerawpointer作为目标C ++的C指针传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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