From: Brian G. <br...@ge...> - 2007-10-18 18:16:21
|
On Oct 18, 2007, at 8:32 AM, Jefferson Provost wrote: > > Actually, it turns out that SWIG doesn't do this by default. It's > the playerc.i typemaps that do it. I was able to speed things up > enormously for getting images by replacing the typemap for 'uint8_t > [ANY]' with this: > > %typemap(out) uint8_t [ANY] > { > $result = PyBuffer_FromMemory((void*)$1,sizeof(uint8_t)*$1_dim0); > } > > This just returns a Python buffer object pointing at the image data. > Then you can use PIL's Image.fromstring() or Image.frombuffer() to > very rapidly (<1ms) create an image object that can be manipulated in > python. > > I'll be happy to send a patch if you want it. Please do send a patch (to the patch tracker). brian. |