Installing OpenCV on OS/X with Python
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).
nn
nn
nn
nn
% mkdir buildn% cd buildn% cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PYTHON_SUPPORT=ON ../n
n
nn
nn
nn
nn
nn
nn
- 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
nn
nn
nn
nn
nn
nn
nn
n
n
nn
nn