-
-
Save bkrukowski/f3bacb1791d72332af42250f1fa239f3 to your computer and use it in GitHub Desktop.
How to: Set up OpenCV on MacOS X and XCode 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###Download XCode from the App Store | |
Get it from [here](https://itunes.apple.com/en/app/xcode/id497799835?mt=12) | |
###Get cmake | |
Use/get a package manager, such as [homebrew](http://brew.sh/). | |
Open a terminal window and type the following | |
``` | |
brew install cmake | |
``` | |
This will get the required packages for *cmake*. | |
###Get and install OpenCV | |
* Download the latest [OpenCV for Linux/Mac](http://opencv.org/downloads.html) | |
* Navigate to location of downloaded file and untar it with the following command | |
``` | |
tar xvzf opencv-2.4.6.1.tar.gz | |
``` | |
* Navigate to extracted folder `cd path/to/folder` | |
* Create a build directory and build opencv with the following commands | |
``` | |
mkdir build | |
cd build | |
cmake -G "Unix Makefiles"... | |
``` | |
* Make and install | |
``` | |
make -j8 | |
sudo make install | |
``` | |
###Set up an OpenCV project in XCode | |
* Start XCode | |
* Create new "Command Line Tool" project with type `C++` [screenshot](https://f.cloud.github.com/assets/285590/1329495/379c7872-3518-11e3-8e11-3a83b45c01f8.png) | |
* **Add OpenCV to your project** | |
* Right click your project on the sidebar, select "Add files to..." [screenshot](https://f.cloud.github.com/assets/285590/1329506/6ec69918-3518-11e3-9a17-c09404fe4d28.png) | |
* When the file chooser dialog opens up, press `cmd` + `shift` + `G` and enter "/usr/local/lib" [screenshot](https://f.cloud.github.com/assets/285590/1329515/974f0ff0-3518-11e3-9568-ce6530c7c6c0.png) | |
* Select the required OpenCV files (named in the format `libopencv_*.dylib`), or select all. Press `Add` or `Return` [screenshot](https://f.cloud.github.com/assets/285590/1329526/af92fb62-3518-11e3-9b41-b012f00b09b2.png) | |
* You will see that all selected files are now in the sidebar. You can youp them together by creating a new _Group_ and dragging the files in there. [screenshot](https://f.cloud.github.com/assets/285590/1329527/c25dac2e-3518-11e3-8ab3-5b3d3412260a.png) | |
* **Configure your project** | |
* Click on the project (in the side bar), and you should see the Project settings come up in the middle of the editor | |
* Click the `All` view (top left corner) | |
* In the search bar type "**Header Search Paths**", double click the value, remove the existing entries and add | |
`/usr/local/lib` and `/usr/local/include` [screenshot](https://f.cloud.github.com/assets/285590/1329534/00b1b416-3519-11e3-86f8-fa214990f7f2.png) | |
* Now search for "**Library Search Paths**" and replace the values with `/usr/local/lib` | |
* Search for "**C++ Standard Library**" and select "*libstdc++ (GNU C++ Standard Library)*" [screenshot](https://f.cloud.github.com/assets/285590/1329538/0f478456-3519-11e3-9643-1b6500bb7080.png) | |
* **Try the configuration** | |
* Run one of the sample OpenCV projects | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment