Pages

2012/11/13

How to use OpenCV in iOS?

This article shows the steps to build the OpenCV application under the iOS.
Step1:Download the pre-compile binary OpenCV library for iOS framework. Refers to the link. Direct download link OpenCV-2.4-build.zip.
Step2:Extract the zip file to the directory, for example, '~/opencv-2.4-build'.
Step3:Open the XCode project to setup the project.Go to the Targets build setting.
Add a Header Search Paths for debug and release with the string "~/opencv-2.4-build/**".
Add a Library Search Paths for debug with the string "~/opencv-2.4-build/lib/debug".
And for release path with string "~/opencv-2.4-build/lib/release".
Step4:Setting linking path to the project.
Add the string "-lopencv_calib3d -lzlib -lopencv_contrib -lopencv_legacy -lopencv_features2d -lopencv_imgproc -lopencv_video -lopencv_core" to the Other Linker flag.
Step5:Modify the project Prefix header.
Add these code to the [YourProjectName]-Prefix.pch file.
#ifdef __cplusplus
    #include <opencv2/opencv.hpp>
    #include <opencv2/nonfree/nonfree.hpp>
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif

Step6:Now you can use the OpenCV API.

No comments:

Post a Comment