问题描述
我正在尝试将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指针传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!