M
mateom
Hello,
I'm using Queue to send images from one thread to another, and some of
the images are not appearing in the consumer thread....maybe 1 in 3
arrive. I've tried passing the image data in both string form and as a
PIL Image object, with the same result.
It does work, however, if I use zlib to compress the image string
before passing it to Queue and then decompress it in the consumer
thread. So, my question: Does Queue have some capacity limitation?
(Uncompressed, my images are 786432 long... 512x512x3)
Here's a bit of the code:
# Producer --------
img = rayCaster.ReadTexture()
iq.put(img)
#iq.put(zlib.compress(img)) #this works fine
# End producer
# Consumer --------
class imageQueue(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.filenum = 0
self.theQueue = Queue.Queue(-1)
def run(self):
while 1:
# for testing, do something simple with images
img = self.theQueue.get()
imgt = Image.frombuffer('RGB',(512,512), img)
#imgt = Image.frombuffer('RGB',(512,512),
zlib.decompress(img)) #this one works
imgt.save( "./imgs_out/%i.png" % self.filenum, "PNG")
self.filenum += 1
def SetQueue(self, q_):
self.theQueue = q_
####
Thanks,
Matt
I'm using Queue to send images from one thread to another, and some of
the images are not appearing in the consumer thread....maybe 1 in 3
arrive. I've tried passing the image data in both string form and as a
PIL Image object, with the same result.
It does work, however, if I use zlib to compress the image string
before passing it to Queue and then decompress it in the consumer
thread. So, my question: Does Queue have some capacity limitation?
(Uncompressed, my images are 786432 long... 512x512x3)
Here's a bit of the code:
# Producer --------
img = rayCaster.ReadTexture()
iq.put(img)
#iq.put(zlib.compress(img)) #this works fine
# End producer
# Consumer --------
class imageQueue(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.filenum = 0
self.theQueue = Queue.Queue(-1)
def run(self):
while 1:
# for testing, do something simple with images
img = self.theQueue.get()
imgt = Image.frombuffer('RGB',(512,512), img)
#imgt = Image.frombuffer('RGB',(512,512),
zlib.decompress(img)) #this one works
imgt.save( "./imgs_out/%i.png" % self.filenum, "PNG")
self.filenum += 1
def SetQueue(self, q_):
self.theQueue = q_
####
Thanks,
Matt