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
[EMAIL PROTECTED]
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()


_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to