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'
3
  • I'd like to know this, too. I think I'll just wait for someone to package it. Commented Nov 10, 2009 at 1:16
  • @endolith It is packaged here: launchpad.net/~gijzelaar/+archive/opencv2-karmic My problem is that both after installing from the 2.0 source and from the PPA, I still can't "import cv" from a Python console (throws ImportError). Would appreciate pointers. Commented Feb 25, 2010 at 23:45
  • Can you just use the precompiled binary? Commented Jun 24, 2012 at 12:21

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.