OpenCV UIImageToMat链接器在Xcode中失败 [英] OpenCV UIImageToMat linker fail in xcode

查看:106
本文介绍了OpenCV UIImageToMat链接器在Xcode中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在xcode上编写了一些OpenCV代码,但是当我编译时,有两种方法导致链接器失败:UIImageToMatMatToUIImage

I wrote some OpenCV code at xcode but when I compiled, 2 methods got linker fail: UIImageToMat and MatToUIImage

我使用的是opencv2.framework(来自iOS的opencv网站,版本3.1),并且运行良好,然后我在项目中使用了cocoapods和集成的opencv 3.1.1,所有代码均相同,除了这2个代码给我链接器的功能失败.我不明白为什么它们不起作用,当我删除#include "opencv2/imgcodecs/ios.h"时,它说功能不存在(而不是链接器失败).

I was using opencv2.framework (from opencv website, version 3.1 for iOS) and it was working fine, then I used cocoapods and integrated opencv 3.1.1 in my project and all the code worked the same, except for these 2 functions that gave me linker fail. I don't understand why they don't work, when I remove the #include "opencv2/imgcodecs/ios.h" it says the functions don't exist (instead of linker fail).

有人知道如何解决此问题吗?谢谢

Does anyone knows how to fix this? Thank you

推荐答案

我能够修复它.

Cocoapods中的OpenCV 3.1.1具有#include "opencv2/imgcodecs/ios.h",但是它不包含实现(这是我得到链接器失败的原因,因为标头没有将函数链接到任何地方),而只是声明这些功能中的功能,如此处所示: https ://github.com/opencv/opencv/blob/master/modules/imgcodecs/include/opencv2/imgcodecs/ios.h

The OpenCV 3.1.1 in Cocoapods has the #include "opencv2/imgcodecs/ios.h" but it doesn't contain the implementation (which was the reason why I got linker fail, as the header wasn't linking the functions to anywhere), just the declarations of these functions, like seen here: https://github.com/opencv/opencv/blob/master/modules/imgcodecs/include/opencv2/imgcodecs/ios.h

为解决此问题,在添加了此头文件的类中,我添加了以下两个功能的实现:

To solve it, in the class where I included this header file, I added the implementation of those 2 functions found here: https://github.com/opencv/opencv/blob/master/modules/imgcodecs/src/ios_conversions.mm

它工作得很好,我想这是使UIImageToMatMatToUIImage在OpenCV 3.1.1(以及3.2)pod上运行的最简单的解决方案.

it worked just fine and I guess it's the simplest solution to get UIImageToMat and MatToUIImage working on OpenCV 3.1.1 (and 3.2 as well) pod.

这篇关于OpenCV UIImageToMat链接器在Xcode中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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