views:

201

answers:

1

Y'all,

I've been at to for 3 days trying to get OpenCV Python binds happening, and I have (the full epic struggle is documented here) but despite turning the SWIG flag on in CMake after installing swig via macports, I'm not getting any SWIG action :(

My cmake command looks like:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_SWIG_PYTHON_SUPPORT=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON -D BUILD_TESTS=ON -D PYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Headers -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_SWIG_PYTHON_SUPPORT=ON -D CMAKE_CXX_COMPILER=/usr/bin/g++-4.2 -D CMAKE_C_COMPILER=/usr/bin/gcc-4.2 ..

which pulls this error:

-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - not found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found

SO I guess its not finding the one i have at:

/opt/local/include/libavformat/avformat.h

How do I tell it about that? With something like

-D CMAKE_CXX_FLAGS="-I/opt/local/include" -D CMAKE_SHARED_LINKER_FLAGS="-L/opt/local/lib"

???

I'm using OSX 10.5.8, Python 2.6 via Macports and compiling the latest OpenCV-trunk.

A: 

Seems that the cmake flags didn't make much of a difference. I became systematic and reduced them to the minimum:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_SWIG_PYTHON_SUPPORT=OFF -D BUILD_NEW_PYTHON_SUPPORT=ON -D PYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Headers -D CMAKE_CXX_COMPILER=/usr/bin/g++-4.2 -D CMAKE_C_COMPILER=/usr/bin/gcc-4.2 -D BUILD_SWIG_PYTHON_SUPPORT=ON ..

and I managed to compile everything, but when I tired to "import cv" win Python I kept getting the following error:

Fatal Python error: Interpreter not initialized (version mismatch?)

which is because the compiler on darwin defaults to the system version of python. I followed some advice and found this worked like a charm:

sudo chmod 000 /System/Library/Frameworks/Python.framework/
cmake ...
sudo chmod 755 /System/Library/Frameworks/Python.framework/
CpILL