[Numpy-discussion] load movie frames in python?

Brian Blais bblais at bryant.edu
Wed Jan 30 08:39:57 EST 2008


On Jan 29, 2008, at Jan 29:9:25 PM, Andrew Straw wrote:

> I'm pretty sure there's code floating around the pyglet mailing list.
> I'd be happy to add it to
> http://code.astraw.com/projects/motmot/wiki/pygarrayimage if it seems
> reasonable. (pygarrayimage goes from numpy array to pyglet texture).
>


I checked the pyglet users group, and the only mention I see is from:

http://groups.google.com/group/pyglet-users/browse_thread/thread/ 
5981f764902c7df/888328e19653be1a?lnk=gst&q=numpy#888328e19653be1a


there, he has the solution:

a = numpy.frombuffer(surf_clip.get_data(), numpy.uint8)
a.shape = (sw, sh, 4)
a = a[:,:,0:3] #drop alpha channel

but when I do it (see code below) the image is clearly munged, so I  
think the decoding is not quite right.

any ideas?


		thanks,


			Brian Blais
-- 
Brian Blais
bblais at bryant.edu
http://web.bryant.edu/~bblais


import pylab
import numpy
from pyglet import media,window

win = window.Window(resizable=True)
player = media.Player()
filename='ica_mvl.avi' # from http://hlab.phys.rug.nl/demos/ica/ 
jiminy.html
source = media.load(filename)
player.queue(source)

player.play()

if True:
     player.dispatch_events()

     imdata=player.texture.get_image_data()

     a = numpy.frombuffer(player.texture.get_image_data().data,  
numpy.uint8)

     a.shape = (imdata.width, imdata.height, 4)
     a = a[:,:,0:3] #drop alpha channel

     # make gray
     im=a.sum(axis=1)/3

     pylab.imshow(im,cmap=pylab.cm.gray)
     pylab.show()
     pylab.draw()


  
    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080130/e601e104/attachment.html>


More information about the NumPy-Discussion mailing list