Exemplo n.º 1
0
 def test_CameraManager_update_0(self):
     s1 = Mock_Surface("s1")
     s2 = Mock_Surface("s2")
     camera_manager.CameraManager().update(s1, s2)
     expected = "s1 blitted onto s2"
     actual = s1.output
     self.assertEqual(expected, actual)
Exemplo n.º 2
0
 def test_CameraManager_update_5(self):
     s1, s2 = "source", "target"
     mock_cam_list = [Mock_Camera(str(i)) for i in range(5)]
     cam_list = camera_manager.Cameras().extend(mock_cam_list)
     camera_manager.CameraManager(cam_list).update(s1, s2)
     expected = ["updated " + str(i) for i in range(5)]
     actual = [cam.output for cam in cam_list]
     self.assertEqual(expected, actual)
Exemplo n.º 3
0
 def test_CameraManager_update_1(self):
     s1, s2 = "source", "target"
     mock_cam1 = Mock_Camera("cam1")
     cam1 = camera_manager.Cameras().append(mock_cam1)
     camera_manager.CameraManager(cam1).update(s1, s2)
     expected = "updated cam1"
     actual = mock_cam1.output
     self.assertEqual(expected, actual)
Exemplo n.º 4
0
def make_camera_manager(rotation, image_path, light_sensor):
    """Creates a camera manager instance.

    Args:
        rotation: The amount (in whole degrees) to rotate the camera image.
        image_path: The directory in which to save images.
        light_sensor: A light sensor instance.

    Returns:
        A CameraManager instance with the given settings.
    """
    #~ camera = picamera.PiCamera(resolution=picamera.PiCamera.MAX_RESOLUTION)
    #~ camera.rotation = 0
    return camera_manager.CameraManager(image_path, clock.Clock(),
                                        light_sensor)
Exemplo n.º 5
0
    def __init__(self, verbose):
        logfile = "../resources/files/logfile"
        if verbose:
            logfile = ""
        self.init_logging(logfile)
        self.logger = logging.getLogger("DomoRoom-kernel")  # Default logger
        if not database_manager.DatabaseManager.file_exist("telegram"):
            self.logger.warning(
                "Resources not found, initializing 'first access setup'")
            control_panel.ControlPanel.first_access_setup()

        key = raw_input("Insert the key: ")  # TODO verify & hide the key
        self.database_manager = database_manager.DatabaseManager(key)
        self.camera_manager = camera_manager.CameraManager(self)
        self.telegram_manager = telegram_manager.TelegramManager(self)
        self.control_panel = control_panel.ControlPanel(self)
        self.remote_devices = remote_devices.RemoteDevices(self)
        self.data_mining = None
        self.integrity_system = None
        self.routines = routines.RoutinesManager(self)
        self.remote_controller = None
Exemplo n.º 6
0
def main(arguments):
    pm = printer_manager.PrinterManager()

    default_configuration = {
        'camera-device': '/dev/video0',
        'time-delay': 3,
        'number-of-photos': 4,
        'output-directory': './sessions/',
        'printer': pm.get_default_printer_name(),
        'logging-level': logging.INFO
    }

    configuration = parse_configuration(arguments, default_configuration)

    level = configuration['logging-level']

    logging.basicConfig(
        format='%(asctime)s %(levelname)s %(name)s %(message)s', level=level)

    logger = logging.getLogger('photobooth')
    logger.debug('configuration: %s' % (configuration))

    logger.info('starting photobooth')

    logger.debug('creating camera manager')
    cm = camera_manager.CameraManager(configuration)

    logger.debug('creating controller')
    controller = photobooth_controller.PhotoboothController(
        configuration, pm, cm)

    logger.debug('creating gui')
    gui = photobooth_gui.PhotoboothGUI(controller)

    logger.debug('starting gui')
    gui.run()

    logger.info('shutting down photobooth')
    logging.shutdown()
Exemplo n.º 7
0
    last_sample = None
    current_sample = None
    camera = None
    while True:
        # If there's a video available then just
        # stop filming
        if should_be_sleeping() or video_available():
            if camera is not None:
                camera.cleanup()
                camera = None
            time.sleep(10)
            continue

        # Setup the camera
        if camera is None:
            camera = camera_manager.CameraManager()
            camera.setup()
            camera.light(True)

        # Check if we should be filming
        current_sample = get_last_sample()
        video = None
        if is_active(last_sample, current_sample):
            print "Is active, filming"
            video = camera.capture_video()
        else:
            print "Not active"

        time.sleep(13)
        # Update sample
        last_sample = current_sample
Exemplo n.º 8
0
 def test_CameraManager_emptylist(self):
     cam_list = []
     self.assertRaises(AssertionError,
                       lambda: camera_manager.CameraManager(cam_list))