Installing OpenCV in Mac OSx tutorial – OpenCV 2.4.10 on OSx 10.10 Yosemite
OpenCV on Mac OSX: A step-by-step guide I’m using OpenCV for my 4th year design project and setting it up was a huge pain. I had to look through a whole bunch of different sites to figure out what to do. There are various ways to install it – through package managers such as Homebrew or Macports, or through the tarball + cmake. Use Homebrew to install OpenCV 3 with Python bindings on macOS. This is by far the easiest method to install OpenCV on macOS. OpenCV for Mac focuses mainly towards real-time image processing, as such, if it finds Intel's Integrated Performance Primitives on the system, it will use these commercial optimized routines to accelerate itself. Jun 15, 2015 OpenCV 3.0 is finally here! And to celebrate the OpenCV 3.0 release, we are going to performing an OpenCV 3.0 install-fest for both Python 2.7+ and Python 3+ on a variety of operating systems including OSX, Ubuntu, and the Raspberry Pi!
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)
Opencv For Mac C++
Step 5 : Install
In terminal, navigate to your opencv folder. then run following command :
2 4 |
Opencv 2.4.9 For Mac
note: there’s a space between two dots.
now,
2 |
now, wait some time till it gets install !
Step 6 : Run a demo program in XCode
Opencv Framework For Mac
![Opencv Opencv](/uploads/1/3/4/0/134054346/758505921.jpg)
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
-> C++ standard Library
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
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 | IplImage*img=cvCreateImage(cvSize(320,320),IPL_DEPTH_8U,3); cvCircle(img,cvPoint(75,100),70,cvScalar(255,0,100,255),9,10,0); cvCircle(img,cvPoint(240,100),70,cvScalar(128,30,60,50),9,10,0); cvNamedWindow('OpenCV Demo',CV_WINDOW_NORMAL); cvShowImage('OpenCV Demo',img); cvWaitKey(0); cvDestroyWindow('OpenCV Demo'); cvReleaseImage(&img ); } |