Hello, I am trying to read movies using Pyglet, and convert them (frame by frame) into numpy arrays. I only need to keep 1 frame at a time, so my problem really is in converting image data to numpy data. The movie that I am using right now is called ica_mvl.avi, at http://hlab.phys.rug.nl/demos/ica/jiminy.html, but the image format comes up as RGBA in pyglet, so I don't think it is that.
I've searched the archives here, and found some relevant things which I am either doing wrong, or are not working for some other reason. I am tried this first: 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() then I saw that you can convert it to intensities with pyglet first, so I tried: imd=player.texture.image_data imd.format='I' s=imd.data[0:(imd.width*imd.height)] a = numpy.frombuffer(s, numpy.uint8) a.shape = (imdata.height, imdata.width) In both cases, the image comes up garbled, as if I am not converting it, or reshaping it correctly. If we have an image in RGBA format, then am I correct in saying that the image data is a string of length height x width x 4 bytes, where the bytes go: RGBARGBARGBA... for each pixel? Am I doing anything obviously wrong here? thanks, Brian Blais --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
