###Download XCode from the App Store Get it from here
###Get cmake Use/get a package manager, such as homebrew. 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
- 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 -
Add OpenCV to your project
- Right click your project on the sidebar, select "Add files to..." screenshot
- When the file chooser dialog opens up, press
cmd+shift+Gand enter "/usr/local/lib" screenshot - Select the required OpenCV files (named in the format
libopencv_*.dylib), or select all. PressAddorReturnscreenshot - 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
-
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
Allview (top left corner) - In the search bar type "Header Search Paths", double click the value, remove the existing entries and add
/usr/local/liband/usr/local/includescreenshot - 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
-
Try the configuration
- Run one of the sample OpenCV projects