OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision, developed by Intel, and now supported by Willow Garage and Itseez. It is free for use under the open source BSD license. The library is cross-platform. It focuses mainly on real-time image processing. If the library finds Intel’s Integrated Performance Primitives on the system, it will use these proprietary optimized routines to accelerate itself.
Here in this BlogPost I will explain you to install OpenCV(version 2.3, 2.4) on your MAC 🙂
There are two way to build openCV on your MAC.
1. You can use MacPorts
For this first you have to install MacPorts. The easiest way to install MacPorts on a Mac OS X system is by downloading the dmg for Mountain Lion, Lion, Snow Leopard orLeopard and running the system’s Installer by double-clicking on the pkg contained therein, following the on-screen instructions until completion. Installation package is here.
After installing MacPort you have to update it to latest version.
$ sudo port selfupdate
Now you can install OpenCV by running following command
$ sudo port install opencv
If you want to install python building
$ sudo port install opencv +python27
or with python 2.6
$ sudo port install opencv +python26
or with QT
$ sudo port install opencv +qt4
So by this way you can install OpenCV in your MAC OS.
2. You can use CMake
By using CMAKE you can also install OpenCV on your mac. For that first you should have to install CMake, which thankfully comes with Mac binaries – so that was easy. You can download .dmg file here.
After installing CMake you have to download the OpenSource Package that you can download by clicking here. Now you have OpenCV-2.4.3 ter.bz2 and unzip to folder. Now open terminal and go to that folder and write following commands in Terminal.
$ mkdir build $ cd build $ cmake -G "Unix Makefiles" .. $ make -j8 $ sudo make install
Now You have done. Congrats you have installed OpenCV on your MAC 🙂
Now you can check by doing following thing.
GO to TerminalType Python
>>> import cv
Now if it run without any error then \m/ but if you encountered with following error
>>> import cv Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named cv
Then close python by pressing ctrl + D key and now you have to run following command
$ export PYTHONPATH=/usr/local/lib/python2.7/site-packages/
after running this command restart the Terminal and then open python and import cv this will work 🙂
If you have any doubt or problem then you can comment here. Thanks.