你们,
我已经花了 3 天时间试图让 OpenCV Python 绑定(bind)发生,而且我有(完整的史诗般的斗争是 documented here)但是尽管在通过 macports 安装 swig 后在 CMake 中打开了 SWIG 标志,但我没有得到任何 SWIG 行动 :(
我的 cmake 命令如下所示:
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 ..
这会导致此错误:
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - not found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
所以我想它没有找到我在的那个:
/opt/local/include/libavformat/avformat.h
我该怎么说呢?有类似的东西
-D CMAKE_CXX_FLAGS="-I/opt/local/include" -D CMAKE_SHARED_LINKER_FLAGS="-L/opt/local/lib"
???
我正在通过 Macports 使用 OSX 10.5.8、Python 2.6 并编译最新的 OpenCV-trunk。
最佳答案
似乎 cmake 标志并没有太大的区别。我变得系统化并将它们减少到最低限度:
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 ..
我设法编译了所有东西,但是当我厌倦了“导入 cv”win Python 时,我不断收到以下错误:
Fatal Python error: Interpreter not initialized (version mismatch?)
这是因为darwin上的编译器默认是python的系统版本。我关注了some advice并发现这很有魅力:
sudo chmod 000 /System/Library/Frameworks/Python.framework/
cmake ...
sudo chmod 755 /System/Library/Frameworks/Python.framework/
关于python - OpenCV 2.0 与 MacPorts 的 SWIG Python 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2020228/