+class RGB :
+ def __init__(self) :
+ self.context = Context()
+ self.context.init()
+ self.imgGene = ImageGenerator()
+ self.imgGene.create(self.context)
+ self.imgGene.set_resolution_preset(RES_VGA)
+ self.imgGene.fps = FPS
+ self.context.start_generating_all()
+
+ def capture(self) :
+ rgb_frame = numpy.fromstring(self.imgGene.get_raw_image_map_bgr(), dtype=numpy.uint8).reshape(480, 640, 3)
+ image = cv.fromarray(rgb_frame)
+ cv.CvtColor(cv.fromarray(rgb_frame), image, cv.CV_BGR2RGB)
+ pyimage = pygame.image.frombuffer(image.tostring(), cv.GetSize(image), 'RGB')