Installing openCV 2.1 with Python bindings on Mac Leopard

I had a tricky time installing openCV 2.1 on my 10.5 Mac (Leopard) recently, the build instructions aren’t brilliant in the wiki. Here are my notes.

I used the Mac notes as a guide and followed the new-style CMake system to build from scratch. I made sure during ‘cmake -G’ that new-style Python support was enabled and that it would build C and Python examples. I also needed WITH_CARBON=ON else the GUI examples all seg-fault. I didn’t change the default for WITH_QUICKTIME, my cameras worked just fine.

Next ‘c’ to configure, ‘g’ to generate and then ‘sudo make -j8′ and ‘sudo make install’ – 10 minutes later it was all compiled.

The libraries need to go into DYLD_LIBRARY_PATH, my .bash_profile now has:

export DYLD_LIBRARY_PATH=[other stuff]:/Users/ian/Documents/OpenCV-2.1.0/lib:$DYLD_LIBRARY_PATH

Finally, to make it work in Python I added the following to the .bash_profile:

export PYTHONPATH=/Users/ian/Documents/OpenCV-2.1.0/lib:$PYTHONPATH

Now ‘import cv’ works in Python, it is looking for cv.so in the /lib directory, without the PYTHONPATH update you’ll find that the C demos run but the Python demos will fail on ‘import cv’.

Out of the box on my Leopard machine the built-in iSight (and later a Philips camera) worked just fine for face_detect.py. The result of a few more hours tinkering was Headroid1, instructions for this will appear on this blog later:

OpenCV Reference Book:

The openCV book is rather excellent, everything is in C++ but the Python API is easy to figure out and the reference text makes it all clear.

Comments are disabled for this post