简体   繁体   English

opencv cmake文件,如何在iOS中使用它们

[英]opencv cmake files, how to use them in iOS

These stuff stuck me another 3 days to figure out. 这些东西让我又花了三天才弄清楚。

I'm implementing opencv and I need to use xfeatures2d module in objc xcode . 我正在实现opencv,我需要在objc xcode中使用xfeatures2d模块。 I previously downloaded the opencv.framework and successfully imported it in my iOS project and it works. 我以前下载过opencv.framework并将其成功导入到我的iOS项目中,并且可以正常工作。 But there is no xfeatures2d in it. 但是其中没有xfeatures2d。 So then I finally figured out that it is an extra module and it is in a package call opencv_contrib . 因此,我最终弄清楚了它是一个额外的模块 ,并且在一个名为opencv_contrib的程序包中。

To make use of it, it seems like people recommend to use cmake to build the source code of opencv-master with opencv-contrib-master 要利用它,似乎人们建议使用cmakeopencv-contrib-master一起构建opencv-master的源代码。

I did it, and it looks build correctly. 我做到了,它看起来正确构建。 And I got lots of funky things in my folder. 而且文件夹中有很多时髦的东西。 However, it seems like nothing I can use to #import to my .xcodeproj project. 但是,似乎没有什么可以#import到我的.xcodeproj项目中的。 (Sorry I can't embed my screenshot yet.) (对不起,我还不能嵌入我的屏幕截图。)

So did I do something wrong? 那我做错了吗? Or,is it the correct way to build the file I need?? 或者,这是构建我所需文件的正确方法吗?

Please help, Thanks! 请帮忙,谢谢!

Finally I found a solution. 终于我找到了解决方案。 @thachnb 's solution is referred from here . @thachnb的解决方案从这里引用。 This instruction guide you to generate an opencv2.framework in use of your iOS project from the opencv-master package. 本说明指导您从opencv-master软件包使用iOS项目生成opencv2.framework。 If you want to use the modules in opencv_contrib, you need to physically copy the module from opencv_contrib (in my case is xfeatures2d, or you can just copy everything over), to opencv-master/module , and then use 如果要使用opencv_contrib中的模块,则需要从opencv_contrib中物理复制模块(在我的情况下是xfeatures2d,或者可以将所有内容复制过来)复制到opencv-master / module ,然后使用

python opencv/platforms/ios/build_framework.py ios python opencv / platforms / ios / build_framework.py ios

command to compile it. 命令进行编译。 After this compilation, you will have a opencv2.framework containing everything you need. 编译之后,您将拥有一个包含所需内容的opencv2.framework。 This also helps. 也有帮助。

Thanks @thachnb ! 谢谢@thachnb!

Q1. Q1。 Did you run below command? 您是否在命令下运行?

python opencv/platforms/ios/build_framework.py ios

if yes, move to question 2 如果是,请转到问题2

Q2. Q2。 Did you see opencv.framework in ios subfolder? 您是否在ios子文件夹中看到opencv.framework?

if yes, move to question 3 如果是,请转到问题3

Q3. Q3。 Did you add that opencv.framework folder to your xcode project? 您是否已将opencv.framework文件夹添加到您的xcode项目中? or drag and drop it to Framework folder of your xcode project? 或将其拖放到xcode项目的Framework文件夹中?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM