Re: [pygame] Re: Accessing opengl surface as a numpy array

2010-11-15 Thread Nicolas
In the case of neuroscience experiments, trough psychopy for example, graphics are rendered "on line", so there is no data to be loaded as a texture. Additionally the down-sampling process is realised by pseudo-retina cells, which are implemented on the software side and should be independent of

Re: [pygame] Re: Accessing opengl surface as a numpy array

2010-11-15 Thread Greg Ewing
Nicolas wrote: I understood what you explain to me about GPU and CPU sides, but I do not have the choice about the input type and it is not possible to move my processes onto the GPU side. Have you considered just moving the downsampling step onto the GPU? You could do it by loading the image

Re: [pygame] Re: Accessing opengl surface as a numpy array

2010-11-15 Thread Nicolas
Hi, I tried both solutions (full read back or one pixel access) and in my case the latter one is clearly faster since sampling rate reduces information by a factor of 10**3. There are only several hundreds receptive fields cells which read some pixels, instead of a full 800x600 pixels sized displa

Re: [pygame] Re: Accessing opengl surface as a numpy array

2010-11-14 Thread Ian Mallett
Hi, Depending on your sampling rate, it may be best to just copy all the data back, and then select only those samples you want. These operations are easily vectorized, and the Python overhead, combined with the requests to and from the GPU might not be worth individually getting pixels. Once ag

Re: [pygame] Re: Accessing opengl surface as a numpy array

2010-11-14 Thread Nicolas
2010/11/12 Ian Mallett : > On Fri, Nov 12, 2010 at 1:25 PM, nbl wrote: >> >> In fact, I work on a software implementing some processes on a >> "visual" stream. >> >> I don't need all frames' pixels as long as frames are spatially >> sampled before all. > > Not sure what you mean exactly here.  If

Re: [pygame] Re: Accessing opengl surface as a numpy array

2010-11-12 Thread Ian Mallett
On Fri, Nov 12, 2010 at 1:25 PM, nbl wrote: > In fact, I work on a software implementing some processes on a > "visual" stream. > > I don't need all frames' pixels as long as frames are spatially > sampled before all. > Not sure what you mean exactly here. If you're doing mostly software operati

[pygame] Re: Accessing opengl surface as a numpy array

2010-11-12 Thread nbl
In fact, I work on a software implementing some processes on a "visual" stream. I don't need all frames' pixels as long as frames are spatially sampled before all. I probably could not read all the buffer but only update relevant cells in a pre-allocated array. Is it correct to use glReadPixels

Re: [pygame] Re: Accessing opengl surface as a numpy array

2010-11-12 Thread Ian Mallett
On Fri, Nov 12, 2010 at 11:57 AM, nbl wrote: > Thank you Ian ! > > I just tried it and glReadPixels does the job ! However it clearly > slows down the rendering loop... > > Probably because it is a copy operation, is there not a direct access > method to the pixels data ? > > Sorry for my ignoran

[pygame] Re: Accessing opengl surface as a numpy array

2010-11-12 Thread nbl
Thank you Ian ! I just tried it and glReadPixels does the job ! However it clearly slows down the rendering loop... Probably because it is a copy operation, is there not a direct access method to the pixels data ? Sorry for my ignorance of OpenGL, I guess I would find a good book on it ! Nicola