[C++-sig] reuse C++ classes that have been wrapped with SWIG
marco.selinger at yahoo.de
Tue Jul 20 09:31:48 CEST 2010
your explanations are very helpful.
Now it is obvious that I should not redeclare the opencv classes in boost.python
after they have been wrapped with swig. But still I did not think about it in
the right way.
>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.
Do you have some example, how this can be achieved? Do I need to do some text
processing or parsing of the swig output to find out which (un)wrap functions to
call? I have never worked on the internals of swig, so that I wouldn't know
where to find those (un)wrappers.
Von: Hans Meine <hans_meine at gmx.net>
An: Development of Python/C++ integration <cplusplus-sig at python.org>
Gesendet: Montag, den 19. Juli 2010, 10:55:49 Uhr
Betreff: Re: [C++-sig] reuse C++ classes that have been wrapped with SWIG
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
HTH from an overview point,
Cplusplus-sig mailing list
Cplusplus-sig at python.org
More information about the Cplusplus-sig