2015年8月5日 星期三

[OpenCV] How to install OpenCV in Mac OS

安裝過程摘要

1. download latest opencv package from  http://opencv.org/
$ wget https://github.com/Itseez/opencv/archive/3.0.0.zip

 
2. unzip the package
$ unzip opencv-3.0.0.zip 
 
3. install xcode and macport
a. http://guide.macports.org/#installing.xcode
b. https://www.macports.org/install.php
 
4. install cmake
$ sudo port install cmake 
 
5. build and install
$ mkdir build
$ cd build
$ cmake -G "Unix Makefiles" ..
$ make -j8
$ sudo make install

6. open xcode, create a new project named "helloCV", and set path
a. select [project], select [Build Settings], select [library search paths], add below setting
/usr/local/lib
b. select [project], select [Build Settings], select [header search paths], add below setting
/usr/local/include
/usr/local/include/opencv
c. select [Targets], select [Build Phases], select [Link Binnary With Libraries], press [Add]
add all files in /usr/local/lib

7. modify default main.cpp to show a image
The source code can be get from  https://github.com/alb423/opencv_practice

Reference: