[visionegg] Re: raw movies
- From: Martin Spacek <visionegg@xxxxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Thu, 22 Sep 2005 16:02:55 -0700
Hi Gabriel,
Here's some snippets of how I ended up reading in an 8bit greyscale raw
movie:
# open the movie file for reading in binary format
f = file(fname, 'rb')
# read the whole file in using numarray
m.data = numarray.fromfile(f, numarray.UInt8, (nframes,height,width))
# flip the movie frames vertically for OpenGL's bottom left origin
m.data = m.data[::,::-1,::]
# Create an instance of the texture stim class
texturestim = TextureStimulus(position = orig,
anchor = 'center',
mask = maskObject,
max_alpha = 1.0,
mipmaps_enabled = 0,
texture_min_filter = gl.GL_NEAREST,
texture_mag_filter = gl.GL_NEAREST,
on = 0) # leave it off for now
tp = texturestim.parameters
to = tp.texture.get_texture_object()
# Init OpenGL graphics screen
screen = get_default_screen()
# Create a Viewport instance
viewport = Viewport(screen=screen, stimuli=[texturestim])
# make a new texture that's sized according to the frame size of movie m
tp.texture = Texture(m.data[0] , :: , :: ] ) # init texture to 1st frame
tp.size = (m.regionwidth, m.regionheight) # size it, in screen pixels
tp.on = 1; texturestim.draw() # draw it to the frame buffer
# here's the movie loop
for framei in range(0,nframes):
# load the frame you want into the texture object
to.put_sub_image(m.data[ framei , :: , :: ] )
screen.clear()
viewport.draw()
swap_buffers()
About a year ago, Andrew made a change in the TextureStimulus() class
that lets you make a texture object out of a numarray. Previously, that
wasn't allowed, and I had to use a Numeric array instead - which is
really slow at loading in big raw movie files. See:
http://www.freelists.org/archives/visionegg/09-2004/msg00007.html
Loading the file as a numarray and updating the texture in the movie
loop in pure Python ended up being as fast as (or maybe faster than?)
doing it with a C extension. If you want some more context for the above
snippets, download the whole module:
http://www.ece.ualberta.ca/~mspacek/Dimstim_2005-06-08.zip
and take a look at the Movies.py file in the Dimstim folder. It's
invoked by the movies.py file in the Experiments folder.
Cheers,
Martin Spacek
PhD student, Graduate Program in Neuroscience
Dept. of Ophthalmology and Visual Sciences
University of British Columbia, Vancouver, BC, Canada
+1-604-875-4555 ext. 66282
visionegg@xxxxxxxxxxxxx | http://swindale.ecc.ubc.ca
Gabriel Nevarez wrote:
Hi, Martin,
I noticed in a post you sent last year about loading raw movies into
visionegg, was wondering if you had any recommendations on the best way to
create them.
I'm running into a situation where python's simply too slow to create trials
on the fly, so I need to play them back as movies.
Right now, I'm importing TIFF files individually into the playback numarray,
but I guess loadup times would be much quicker if they were in a single raw
movie.
Btw, have you found a better way to play back movies in visionegg? I
noticed you mentioned having created a c extension, does it tend to work
quicker?
Cheers,
-=Gabriel Nevarez
Research Programmer
Psychology Department
Cardiff University
http://www.cf.ac.uk/psych
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- Follow-Ups:
- [visionegg] Re: raw movies
- From: Gabriel Nevarez
- References:
- [visionegg] raw movies
- From: Gabriel Nevarez
Other related posts:
- » [visionegg] raw movies
- » [visionegg] Re: raw movies
- » [visionegg] Re: raw movies
- » [visionegg] Re: raw movies
- » [visionegg] Re: raw movies
I noticed in a post you sent last year about loading raw movies into visionegg, was wondering if you had any recommendations on the best way to create them.
I'm running into a situation where python's simply too slow to create trials on the fly, so I need to play them back as movies.
Right now, I'm importing TIFF files individually into the playback numarray, but I guess loadup times would be much quicker if they were in a single raw movie.
Btw, have you found a better way to play back movies in visionegg? I noticed you mentioned having created a c extension, does it tend to work quicker?
Cheers, -=Gabriel Nevarez
Research Programmer
Psychology Department
Cardiff University
http://www.cf.ac.uk/psych
====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
- [visionegg] Re: raw movies
- From: Gabriel Nevarez
- [visionegg] raw movies
- From: Gabriel Nevarez