tags:

views:

302

answers:

1

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 (I also tried --with-python and without-swig)
  • make
  • sudo make install

    import sys
    sys.path.append('/usr/local/lib/python2.6/dist-packages/opencv')
    import cv
    im = cv.LoadImage("PIL04.JPG",1)

and the error is:

im = cv.LoadImage("PIL04.JPG",1)  
AttributeError: 'module' object has no attribute 'LoadImage'
+2  A: 

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.

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.

ezod