When it comes recognizing face but you realize the module is not in opencv, what to do? Cry? Maybe. I spent 1.2 days to figure out that the face module is not in that repository. Instead, it’s in opencv_contrib. Even worse, we can’t use Podfile to generate the framework to include a single module in opencv_contrib!
Not much blogs online have solution for that. So I’m writing what I figured out. Here’re the steps to manually add a single module in opencv_contrib to opencv2.framework:
- Download opencv from https://github.com/opencv/opencv
- Download opencv_contrib from https://github.com/opencv/opencv_contrib
- Copy the face module in opencv_contrib (opencv_contrib/modules/face) to opencv’s modules folder (opencv/modules).
- Build opencv2.framework [2]:
- Make symbolic link for Xcode to let OpenCV build scripts find the compiler, header files etc.
cd / sudo ln -s /Applications/Xcode.app/Contents/Developer Developer
- Build opencv2.framework
cd ~/ python opencv/platforms/ios/build_framework.py ios
- Make symbolic link for Xcode to let OpenCV build scripts find the compiler, header files etc.
- If everything works, a few minutes later you will get ~//ios/opencv2.framework. You can add this framework to your Xcode projects [2].
- Add the following builtin frameworks to the project because opencv2.framework is dependent on those:
- AssetsLibrary.framework
- CoreMedia.framework
- AVFoundation.framework
- Done! Now you can compile and run the project with face recognition included!
References
[1] Integrating armco in opencv_contrib into opencv2.framework. https://github.com/opencv/opencv/issues/6530.
[2] Installation in iOS. http://docs.opencv.org/2.4/doc/tutorials/introduction/ios_install/ios_install.html#ios-installation.
how to do this if i am using windows
Hi Rohan, theoretically it’s possible to run python on windows to build opencv2.framework =)