// you’re reading...

C / C++ / Objective-C

Getting OpenCV setup on iOS

Let me start off by saying, I don’t claim to be an expert. I had to find out how to get OpenCV running on an iOS device by reading a lot of other people’s advice, hacking, then trial and error.

Step 1. Use port to install OpenCV and all the dependencies.

sudo port selfupdate
sudo port -v install opencv +python27

Step 2. Follow directions from this site and this site.

As of, 2013-05-15, my directions are:

cd ~/
git clone https://github.com/Itseez/opencv.git
cd opencv
git checkout 2.4.3.2
cd ..
sudo ln -s /Applications/Xcode.app/Contents/Developer /Developer
python opencv/ios/build_framework.py ios

Step 3. Next, create a new single view iOS project.


Xcode iOS Single View Project


Step 4. Change your view controller file extension to “.mm” – yes, it’s crazy like that.

file name change .mm


Step 5. Add all these frameworks to your project:


iOS Frameworks

Step 6. Add this to your -Prefix.pch :

#ifdef __cplusplus
#import 
#endif

Step 7. Add the OpenCV framework build to your project.


xcode add framework


xcode add framework


xcode add framework


Step 8. Add these headers to your View Controller .h file

#import <QuartzCore/QuartzCore.h>
#import <CoreVideo/CoreVideo.h>
#import <opencv2/highgui/cap_ios.h>
#import <opencv2/objdetect/objdetect.hpp>
#import <opencv2/imgproc/imgproc_c.h>
#include <opencv2/core/core.hpp>

Finally, setup and run this tutorial:

Discussion

No comments for “Getting OpenCV setup on iOS”

Post a comment

Help support my site and buy a domain name at http://domainsemailhosting.com/

%d bloggers like this: