Installing OpenCV on Mac OS X Snow Leopard

OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision. Version 2 ships with Python bindings and simply you can “import cv” module in Python after you’ve installed it.

The easiest way to install OpenCV on Mac is to use package management systems like port, fink or homebrew. They will automatically download, compile and install needed packages for you.

In this tutorial I’ll use brew, how ever you can use your preferred package manager.

Here is the short explanation of the installation process (every thing will be done on Terminal.app)

1. Install brew package manager. (instructions here)
2. Update brew formulas:

brew install git
brew update

3. Install opencv:

brew install opencv

and brew will automatically installs CMake and checks out opencv repository, Builds and installs it.

Note that you should edit your PYTHONPATH to make opencv working with Python. I wrote a simple script to do this automatically for Python 2.6 (Also brew should be installed on it’s default location).

RND=/tmp/$RANDOM
PYTHONPATH=`echo $PYTHONPATH | sed -e 's/\/usr\/local\/lib\/python2.6\/site-packages\/://g'`
cat ~/.bash_profile | grep -Ev "PYTHONPATH" > $RND
echo export PYTHONPATH="/usr/local/lib/python2.6/site-packages/:"'$PYTHONPATH' >> $RND
mv $RND ~/.bash_profile

Just copy the script above and type:

pbpaste | sh

Close the Terminal and reopen it.

Now you can simply open your Python interpreter and type “import cv”.

Done. :)

Installing Eric5 on Mac

Eric IDE is a Cross-Platform Python and Ruby IDE, written in Python based on Qt toolkit. It looks really nice and powerful.

Recently I tried to install it on my Mac and had some troubles. Finally I managed to make it running and now I’d like to make a step-by-step installation tutorial:

1. Install Python 3:

Download and install Python 3.

2. Install GCC Compilers:

You will need GCC compilers to compile some source packages. The easiest way to install them is to Install XCode. You can download it here or install it from your OS X installation DVD.

3. Install Qt SDK:

Download Qt SDK for Mac. The installation process is pretty simple and straightforward.

4. Install SIP, PyQt4 and QScintilla2:

First, Grab SIP Linux, UNIX, MacOS/X source, PyQt4 MacOS/X source and QScintilla2 Linux, UNIX, MacOS/X source and extract them all in a directory. It’s also a good idea to rename the directories to something more comfortable:

Then open a terminal window and navigate into the path you’ve extracted source packages before, and execute the following commands:

cd sip-4.12
python3 configure.py --arch i386
make
sudo make install

cd ../PyQt-4.8.2
python3 configure.py --use-arch i386
make
sudo make install

cd ../QScintilla-2.4.6/Qt4
qmake --spec macx-g++ qscintilla.pro
make
sudo make install

cd ../Python
python3 configure.py
make
sudo make install

5. Install Eric5:

Download Eric5 and extract it somewhere.
Open the Terminal and navigate into the directory you’ve extracted Eric5 before and execute the following command:

sudo python3 install.py

Congratulations :) Now you can open Eric5 IDE by executing eric5 (ex. in the Terminal).

Hope it helps.

Follow

Get every new post delivered to your Inbox.