Installing OpenCV in Mac OSx tutorial

By | January 10, 2015

Installing OpenCV in Mac OSx tutorial – OpenCV 2.4.10 on OSx 10.10 Yosemite

Please see the latest blog to install OpenCV 3 on macOS here !

Notes : Consider following suggestions before you start installing OpenCV on your Mac

1. Do not use any “beta” versions – for both OpenCV and XCode (Please Avoid / Use stable versions)

2. If you’re following this tutorial then do not cross check or mess up with other tutorials online

3. Using Macports to install OpenCV – it’s easier and perfect

4. Terminal is the best for entire installation

 

Tutorial :

Step 1 : Check XCode and Mac OSx

Make sure you are using stable version of Mac OSx and XCode. In my case, I’m using Mac OSx 10.10 Yosemite and XCode 6.1.1

Also install Command Line tools for your XCode ! Get it from here!

 

Step 2 : Macports

Using macports to install OpenCV is very perfect I found. You can find a detailed macports installation/updation tutorial here.

1. Open terminal

2. Select XCode Latest version :

sudo xcode-select -s /Applications/XCode.app/Contents/Developer

3. Run command for agreeing the license :

sudo xcodebuild -license

4. Update Macports using :

sudo port -v selfupdate

 

Step 3 : Install cmake

In terminal, run;

sudo port install cmake

 

Step 4 : Download OpenCV

First, download OpenCV latest version on Mac from here.  Do not use any beta version. I am using OpenCV 2.4.10 ! Extract the folder and keep the OpenCV folder at some better place in your mac (Not in downloads)

 

Step 5 : Install

In terminal, navigate to your opencv folder. then run following command :

note: there’s a space between two dots.

 

Screen Shot 2015-01-08 at 7.52.24 pm

now,

now, wait some time till it gets install !

 

Screen Shot 2015-01-08 at 7.51.43 pm

 

Step 6 : Run a demo program in XCode

1. Start New Project

2. Select for OSx and command line app

3. Change following settings

-> In build settings, change architecture to Native

-> Set Search paths as following :

Header search path : /usr/local/include

Library search path : /usr/local/lib

Screen Shot 2015-01-10 at 6.11.53 pm

-> C++ standard Library

Screen Shot 2015-01-10 at 6.14.17 pm

4. Add following libraries in your project (Add files)

libopencv_core.2.4.10.dylib

libopencv_highgui.2.4.10.dylib

 

5. Run this code that draws two circles

 

Installing OpenCV in Mac OSx tutorial