Exemplo n.º 1
0
    def __init__(self, config, camera):
        self.conf = config
        self.camera = camera
        self.printer = PrinterProxy(self.conf)

        # platform and pygame
        logger.info("PLATFORM: %s" % platform_devs.running_platform)
        platform_devs.platform_init()
        pygame.init()
        pygame.mouse.set_visible(False)

        self.clock = pygame.time.Clock()

        # peripherials
        self.button = platform_devs.Button()
        self.lights = platform_devs.Lights(self.conf['devices']['lights_external'])
        self.button.register_callback(self.button_callback)

        # view and model
        self.is_running = False
        self.live_view_running = False
        self.live_view_still_img = None
        self.view = view.PygView(self, self.conf, self.camera)
        self.model = model.PhotoBoothModel(self)
        to_upload_sessions = self.model.load_from_disk()

        # capture thread
        self.capture_names = Queue(maxsize=0)
        self.thread_capture = Thread(target=self.capture_image_worker)
        self.thread_capture.setDaemon(True)

        # upload background process (creating GIF is cpu-intensive, make it happen in other process to bypass GIL)
        self.upload_pipe = None
        if self.conf['upload']['enabled']:
            pipe = multiprocessing.Pipe()
            self.upload_pipe = pipe[0]
            self.process_upload = multiprocessing.Process(target=upload.run, args=(self.conf, pipe))
            self.process_upload.daemon = True

            # try to reupload not yet uploaded sessions
            if self.conf['upload']['retrying']:
                for sess in to_upload_sessions:
                    self.upload_pipe.send((sess.id, sess.get_medium_img_paths(),\
                        sess.get_full_img_paths(), sess.random_tags))


        self.next_fps_update_ticks = 0
Exemplo n.º 2
0
    def __init__(self, config):
        self.conf = config
        self.cam = picam.PiCam(config)
        self.printer = PrinterProxy(self.conf)

        # platform and picam
        logger.info("PLATFORM: %s" % platform_devs.running_platform)
        platform_devs.platform_init()
        self.cam.start()

        # peripherials
        self.button = platform_devs.Button()
        self.button_pressed = False
        self.lights = platform_devs.Lights(self.conf['devices']['lights_external'])
        self.button.register_callback(self.button_callback)

        # uploader
        self.upload = UploadProxy(self.conf)

        # model
        self.is_running = False
        self.model = model.VideoBoothModel(self)