From: Sebastian H. <ha...@ms...> - 2003-05-14 02:13:13
|
Hi - I hope it's OK to just resent my posting from Feb 22. I didn't get any response at the time. Also - looking into the code again - I am wondering what the best way to handle the reference counting would be ? Here come my original posting: > Short follow up: > 1) Is it planned to support this more directly? > 2) How much does it cost to create a buffer object if it > uses my already allocated memory ? > 3) Can I change the pointer so that it points to a > different memory space WITHOUT having to recreate any > python objects? Or would that "confuse" the buffer or > numarray? (We are hoping to aquire 30 images per second > - the images should get written into a circular buffer so > that the data can be written to disk in larger chunks - > but the python array should always refer to the current > image ) > > Thanks for all the nice toys (tools) ;-) > Sebastian Haase > > > > On Fri, 17 Jan 2003 18:16:01 -0500 > Todd Miller <jm...@st...> wrote: > >Sebastian Haase wrote: > > > >>Hi, > >>What is the C API to make an array that got allocated, > >>let's say, by a = new short[512*512], > >>accessible to python as numarray. > >> > >What you want to do is not currently supported well in C. > > The way to do what you want is: > > > >1. Create a buffer object from your C++ array. The > >buffer object can be built such that it refers to the > >original copy of the data. > > > >2. Call back into Python (numarray.NumArray) with your > >buffer object as the buffer parameter. > > > >You can scavenge the code in NA_newAll (Src/newarray.ch) > >for most of the callback. > > > >>I tried NA_New - but that seems to make a copy. > >>I would need it to use the original memory space > >>so that I can "observe" the array from Python WHILE > >>the underlying C array changes (it's actually a camera > >>image) > >> > >That sounds cool! > > > >> > >>Thanks, > >>Sebastian Haase |