[C++-sig] reuse C++ classes that have been wrapped with SWIG
Hans Meine
hans_meine at gmx.net
Mon Jul 19 10:55:49 CEST 2010
On Thursday 15 July 2010 13:35:55 Marco Selinger wrote:
> There is a complete SWIG wrapper for the OpenCV
> (http://opencv.willowgarage.com) project.
>
> I am developing a small image processing application that uses some of the
> OpenCV classes. This application will be wrapped using Boost.Python.
> How do I declare those classes in Boost.Python that have already been
> wrapped with SWIG?
For all these questions (involving SIP/SWIG/BPL/...), remember that they're
all based on the common Python/C API. Thus, each of these wrapping libraries
have means to convert from/to python, i.e. wrapping a C++ object pointer into
a (PyObject *) and vice versa. One just needs to know how this is done with
each of the above, and depending on the lifetime management.
Additionally, you should *not* "declare those classes in Boost.Python" again,
i.e. using class_<...>. (That would lead to incompatible wrappers.) Instead,
you *may* define a manual converter to make your life easier, i.e. let
boost::python wrap your functions and automatically call SWIGs wrap/unwrap
functions for the corresponding OpenCV classes. (The alternative is to
declare your functions with (PyObject *) pointers and manually call these SWIG
functions, which is probably easier if you have just one or two functions to
wrap.)
HTH from an overview point,
Hans
More information about the Cplusplus-sig
mailing list