I need to get OpenCV working on my system for a couple of image processing tasks I have for work, and as with many complex software systems, it was somewhat difficult to get it working on my system, a macbook pro running Leopard (OS/X 10.5).
n
nn
n Their installation instructions were fairly good. I first tried to use regular old make, but I had a few issues with libraries that regular old make couldn’t find. So I installed cmake to use for this purpose. I highly recommend it.n
nn
n
nn
n With cmake, I was successful with the suggested instructions:n
nn
n
% mkdir buildn% cd buildn% cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PYTHON_SUPPORT=ON ../n
n
nn
n
nn
n After that, ‘make’ and ‘make install’. n
nn
n
nn
n I ran into a few issues during this process.n
nn
n
nn
n
- n
- n No swig on my system. The installation page lists it as an optional install, but it’s needed for python, and python is what I want (they say this, but I thought it would do something other than just ignore my desire for python). So install swig, and use the CMake GUI tool to make sure that your SWIG_DIR is set correctly.n
- n Couldn’t find my Python.h file. Since I had installed my python using darwinports, my Python.h isn’t really where it was looking. I fixed this by editing the CMakeCache.txt to change PYTHON_INCLUDE_PATH:PATH=/sw/include/python2.5. If your swig stuff is complaining about no Python.h (but you have one), find your Python.h and change this line in CMakeCache.txt. There’s probably a more elegant solution, but this worked.n
- n For some reason CMake was pointing to the wrong SDK on my system (. It wanted to use the 1.4u version, but I’ve got 1.5, so I changed /Developer/SDKs/MacOSX10.4u.sdk to /Developer/SDKs/MacOSX10.5.sdk using the CMake GUI.n
- n Couldn’t find my resulting opencv library. I copied it to the /Library/Python path.n
- n I wanted to make sure it installed all of the examples, so I selected them using hte CMake GUI utility.n
n
n
n
n
n
n n
n Note that I did try the darwinports version, and lost a couple of hours trying to figure out how to get the python piece of that to work on my system. I don’t suggest that path.n
nn
n
nn
n I am pleased to report that now the python examples (at least) work on my system. Including the houghlines.py which I needed to do the actual task ahead of me. So, hurray.n
nn
n
nn
n I decided that to implement a houghcircles example I should really get the C code examples working, and thanks to the helpful instructions here I was able to do it easily. Follow those instructions and then you’ll be able to compile and run all of the C example files (and make your own, and run them too!)n
nn
n
nn
n So I wrote a houghcircles example using some of the example code from the opencv book, and it works, kinda. Pretty well I think, for just futzing around for an evening:n
nn
n
nn
n
n
n
n

n
nn
n Someone wrote to me about this blog post and said they were having some trouble with using the iSight for video input. I discovered I was having the same problem. The answer, gleaned from various places on the internets, was to unset DYLD_LIBRARY_PATH in my environment. Confuses the heck out of openCV. Which is kind of a problem because ROS requires it, at least to build. So if you get weird library missing/wrong errors, unset that bad boy and see if it helps.n
nn
Leave a Reply