tags:

views:

282

answers:

2

Having successfully installed opencv 2.0 with python bindings I'm starting to run into trouble and before I go any further I wondered if I should change to another option. As ezod on this post says:

"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, should I soldier on with 2.0 or should I go for ctypes? What am I missing out on either way?

I'm using OSX, python 2.5 and wanting to do tracking in 2d of moving object and neither a python nor machine vision expert!

+1  A: 

I'm using a self-compiled OpenCV 2.0 and it's built-in python binding. Up to now I was missing 2 or 3 functions (e.g. FindFundamentalMat). If you get the source code of OpenCV you find a text file interfaces/python/api that defines the parameter and return types for each OpenCV function that is available from Python. Upon recompilation an automatic generator will parse this file and build the python extension. For all the cases I've been through I found that adding an appropriate definition to the api for the functions I needed, then recompiling opencv, worked quite well.

dudemeister
Can you see any disadvantages of going this route instead of using ctypes?
ctypes-opencv does not work with OpenCV 2.0 afaik (didn't check though). I just found a new one though, http://code.google.com/p/pyopencv/ I never tried it but it looks extremely promising! It claims to have good numpy integration :-)
dudemeister
I just saw that pyopencv (link that i posted) is based on Boost.Python instead of ctypes. This is a very good decision since ctypes only supports flat function wrapping (you cannot directly wrap a C++ class but have to handcode C++ object wrapping by hand). This means that pyopencv could be even better since it wraps real OpenCV object (like Mat). It even supplies the neat numpy-indexing syntax directly into OpenCV arrays \o/
dudemeister
A: 

I'd recommend you use the official Python bindings to OpenCV 2.1 which as far as I've seen has feature parity with the C++ libraries. Most of them have either a pythonic wrapper, or a direct translation from the C++ version.

Python's OpenCV documentation isn't as complete as C++'s, but if you feel that the language advantages for prototyping are worth it, you'll be able to understand the Python usage from the C++ documentation.

Beware that much of the existing example code you'll find is from the previous versions and are incompatible (for example now everything resides under the cv package), but it's not hard to figure out how update it.

voyager