诸位
我已经花了3天的时间来尝试让OpenCV Python绑定发生,我已经做到了(完整的史诗斗争是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。
发布于 2010-01-08 21:17:55
似乎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 ..我设法编译了所有的东西,但当我尝试"import 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/发布于 2010-12-15 06:07:27
如果你对较新的(非SWIG)绑定没意见,不管怎样,哪种imho更好,你可以直接通过MacPorts安装:
sudo port install opencv +python26或
sudo port install opencv +python27视情况而定。
https://stackoverflow.com/questions/2020228
复制相似问题