From: Guy K. K. <G....@ma...> - 2007-04-27 02:29:55
|
On Friday 27 April 2007 7:11:50 am John Lenz wrote: > I don't really understand all the details you are explaining, but I > suspect you are looking for typemaps. > > See, the way a pointer to some C++ class is stored in a python object is > probably different between SWIG and the native cv. =A0It might be encoded > inside a python integer inside some class, or embedded into a string or > something. That's why I'm eager to use the existing OpenCV SWIG binding interfaces. If= I=20 use them (correctly), then I shouldn't have any problem in accessing/passin= g=20 the types as they should undergo the same type of mapping. > So by default, SWIG assumes the pointer is encoded in its own format. > This is done by the functions SWIG_Python_NewPointerObj and > SWIG_Python_MustGetPtr, which appear near the top of a _wrap.cxx output > file. > > What I think you will need to do is write a typemap that extracts the > C++ pointer from the python format cv uses. Well, I don't want to re-solve the problem that has been solved initially=20 creating those OpenCV bindings already. Maybe the question could be re-phrased: """ I've got an already SWIG-wrapped (to Python) library libfoo I'm also using = in=20 native C++ code, which presents custom types. How can I expose self created functions/methods using these types as=20 parameters or return values consistently to python, preferably using the=20 existing SWIG interfaces? """ Guy =2D-=20 Guy K. Kloss Institute of Information and Mathematical Sciences Room 2.63, Quad Block A Building Massey University, Auckland, Albany Private Bag 102 904, North Shore Mail Centre voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 eMail: G....@ma... http://iims.massey.ac.nz |