Esempio n. 1
0
    def chainfunc(self, pad, buffer):
        try:
            print 'Got resize buffer'
            # Simplest: just propagate the data
            # self.srcpad.push(buffer)
            
            # Import into PIL and downsize it
            # Raw jpeg to pr0n PIL wrapper object
            print 'resize chain', len(buffer.data), len(buffer.data) / 3264.0
            #open('temp.jpg', 'w').write(buffer.data)
            #io = StringIO.StringIO(buffer.data)
            io = StringIO.StringIO(str(buffer))
            try:
                image = PImage.from_image(Image.open(io))
            except:
                print 'failed to create image'
                return gst.FLOW_OK
            # Use a fast filter since this is realtime
            image = image.get_scaled(0.5, Image.NEAREST)

            output = StringIO.StringIO()
            image.save(output, 'jpeg')
            self.srcpad.push(gst.Buffer(output.getvalue()))
        except:
            traceback.print_exc()
            os._exit(1)
        
        return gst.FLOW_OK
Esempio n. 2
0
 def captureSnapshot(self, image_id):
     print 'RX image for saving'
     image = PImage.from_image(self.capture_sink.pop_image(image_id))
     fn_full = os.path.join(config['imager']['snapshot_dir'], str(self.snapshot_fn_le.text()))
     factor = float(config['imager']['scalar'])
     # Use a reasonably high quality filter
     image.get_scaled(factor, Image.ANTIALIAS).save(fn_full)
     
     # That image is done, get read for the next
     self.snapshot_next_serial()
     self.snapshot_pb.setEnabled(True)
Esempio n. 3
0
                    def take_picture(self, file_name_out = None):
                        print 'gstreamer imager: taking image to %s' % file_name_out
                        def emitSnapshotCaptured(image_id):
                            print 'Image captured reported: %s' % image_id
                            self.image_id = image_id
                            self.image_ready.set()

                        self.image_id = None
                        self.image_ready.clear()
                        self.gui.capture_sink.request_image(emitSnapshotCaptured)
                        print 'Waiting for next image...'
                        self.image_ready.wait()
                        print 'Got image %s' % self.image_id
                        image = PImage.from_image(self.gui.capture_sink.pop_image(self.image_id))
                        factor = float(config['imager']['scalar'])
                        # Use a reasonably high quality filter
                        scaled = image.get_scaled(factor, Image.ANTIALIAS)
                        if not self.gui.dry():
                            scaled.save(file_name_out)