[visionegg] Re: raw movies

  • From: Gabriel Nevarez <nevarezg@xxxxxxxx>
  • To: <visionegg@xxxxxxxxxxxxx>
  • Date: Mon, 26 Sep 2005 09:40:29 +0100

Hi, martin, 

Thanks for the code snippets.  Actually, I pretty much figured out
everything you sent below from your previous post (talk about efficiency of
posting!).

My main question was on the actual creation of the raw movies... Assuming
you have a bunch of bitmaps (such as those dumped by the makemovie.py demo),
what tools do you use to dump them into a raw movie?  I've used a little mac
os9 app called Moover that compiles bitmaps into quicktime movies, but then
converting a quicktime movie to a raw movie (frame by frame raw output)
would be nice.

Probably wouldn't take to long to write such an app (i.e, converting bitmaps
to a neutral format, such as PPM, then dumping as binary raw dumps), but
still, I'm sure there's one already out there to do it.

Cheers, 
-=Gabriel Nevarez
Research Programmer
Psychology Department
Cardiff University
http://www.cf.ac.uk/psych


On 23/9/05 12:02 am, "Martin Spacek" <visionegg@xxxxxxxxxxxxx> wrote:

> 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:
> 
> //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: //www.freelists.org/archives/visionegg
>> Website: http://www.visionegg.org/mailinglist.html
> ======================================
> The Vision Egg mailing list
> Archives: //www.freelists.org/archives/visionegg
> Website: http://www.visionegg.org/mailinglist.html


======================================
The Vision Egg mailing list
Archives: //www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: