适用于OpenCV的新PythonInterface [英] New PythonInterface for OpenCV
问题描述
我正在尝试使用新的PythonInterface安装OpenCV 2.0.但是我总是失败.只有SWIG python界面.而且似乎还没有安装PythonInterface.要构建OpenCV,我使用:
Hi I'm trying to install OpenCV 2.0 with new PythonInterface. But I always fail. There is only SWIG python interface. And also it seems to be that the PythonInterface was not installed. To build the OpenCV I use:
- ./configure --without-ffmpeg(我也尝试过--with-python和without-swig)
- 制作
-
sudo make install
- ./configure --without-ffmpeg (I also tried --with-python and without-swig)
- make
sudo make install
导入系统
sys.path.append('/usr/local/lib/python2.6/dist-packages/opencv')
导入简历
im = cv.LoadImage("PIL04.JPG",1)
import sys
sys.path.append('/usr/local/lib/python2.6/dist-packages/opencv')
import cv
im = cv.LoadImage("PIL04.JPG",1)
,错误是:
im = cv.LoadImage("PIL04.JPG",1)
AttributeError: 'module' object has no attribute 'LoadImage'
推荐答案
如果您使用CMake编译OpenCV(现在比Autotools首选),我相信新的Python绑定实际上是默认的(而SWIG绑定已禁用).您可以分别使用-D BUILD_SWIG_PYTHON_SUPPORT=ON
和-D BUILD_NEW_PYTHON_SUPPORT=ON
来控制关于Python绑定的构建行为.
If you compile OpenCV using CMake, which is now preferred over Autotools, I believe the new Python bindings are actually the default (while the SWIG bindings are disabled). You can use -D BUILD_SWIG_PYTHON_SUPPORT=ON
and -D BUILD_NEW_PYTHON_SUPPORT=ON
variously to control the build behaviour with respect to Python bindings.
作为一个警告,从2.0版本开始,新的Python绑定是不完整的:许多我认为很重要的功能都缺少.同时,SWIG绑定令人苦恼.从0.8.0版开始,ctypes-opencv绑定(第三方项目)不支持OpenCV 2.0.因此,通常缺少OpenCV中的Python支持.
As a caveat, as of the 2.0 release, the new Python bindings are incomplete: many functions I would consider rather important missing. Meanwhile, the SWIG bindings are nothing short of agonizing to work with. The ctypes-opencv bindings (3rd party project), as of version 0.8.0, do not support OpenCV 2.0. So, in general, Python support in OpenCV is lacking.
这篇关于适用于OpenCV的新PythonInterface的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!