Source: http://www.onevcat.com/2012/03/opencv-build-and-config/
Original: Onev ' Den http://www.onevcat.com/2012/03/opencv-build-and-config/
2014.5.3 Update
It is now generally straightforward to use CocoaPods for dependency management, especially for complex libraries such as OpenCV. You can access the CocoaPods page and search OpenCV to find the relevant pod information for a simple import. If you haven't or haven't started using CocoaPods, now is the time to learn and practice!
Recently in writing a own app that uses some image recognition and processing stuff. The study found that using OPENCV is the most convenient, but for the iOS development environment to compile and configure the OpenCV library still need a bit of effort, the online data is not very full, and many have expired. Here is a summary of the showings, but also hope to be helpful to other people.
OpenCV (Open source computer Vision Library) is a cross-platform, open source project consisting of a series of C functions and a small number of C + + classes that provide many common algorithms for image processing and computer vision. When developing apps for image recognition and processing, OPENCV offers a range of easy-to-use, lightweight APIs that follow the BSD License.
OpenCV for iOS one-click compilation
OpenCV is used on iOS and is generally provided as a static library, so the source code needs to be compiled first. If you want to save time, here is a pre-compiled library, can be used directly (OPENCV version 2.3, although the file name has part1, but only this one package, open the bag ready to eat), if you need the latest version of OPENCV, you can choose to compile yourself.
Download the latest OpenCV from OpenCV's repository first
https://code.ros.org/svn/opencv/trunk
This includes the source code and all the sample tutorials, there are more than 1G, small pipes need to be cautious. If you just want to download the source code, you can check out here
svn co https://code.ros.org/svn/opencv/trunk/opencv
If you have checked out before, then update with SVN update to get the latest version of the source code, or to SourceForge to download.
Since Darwin does not have a built-in cmake, it is necessary to download and install the CMake before compiling, which can be found on CMake's website. Eugene Khvedchenya wrote a super-awesome script that can be found here, or there is a local copy (no longer updated). Put the downloaded script in the trunk directory and run
sh BuildOpenCV.sh opencv/ opencv_ios_build
After a few minutes, you can find the header file and the compiled static library in the OpenCViOSbuild directory.
If you are checking out the OpenCV from the official library and are not afraid of trouble, you can also use the official script to complete the compilation, in particular, see the downloaded /opencv/ios/readme.txt file.
Library configuration for OpenCV
The configuration is basically consistent with other static libraries, taking XCODE4 as an example.
- Drag the compiled OpenCV folder into the project, and remember to tick the copy items into destination group ' s folder (if needed)
- In the header search paths and library search paths of build settings, fill in the corresponding header file location and vault file location, and tick always Search User paths Yes
- Add the library file you used in link Binary libraries in build phases
Compiling scripts
Compile the OpenCV script as follows, do not copy and paste the script directly, and some symbols may have problems during character conversion. You can download the latest version of the script here, or click here to get a copy of the script.
OpenCV compilation and configuration in the IOS development environment