From 1f2b5432b3acd15d96d556a876734e60e15829fb Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 24 Mar 2018 14:43:18 +0100 Subject: [PATCH] Extended Pi camera options --- platypush/backend/camera/pi.py | 35 ++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/platypush/backend/camera/pi.py b/platypush/backend/camera/pi.py index b2a5849f5..a595c399c 100644 --- a/platypush/backend/camera/pi.py +++ b/platypush/backend/camera/pi.py @@ -7,25 +7,40 @@ from platypush.backend import Backend class CameraPiBackend(Backend): def __init__(self, listen_port, x_resolution=640, y_resolution=480, - framerate=24, hflip=False, vflip=False, **kwargs): + framerate=24, hflip=False, vflip=False, + sharpness=0, contrast=0, brightness=50, + video_stabilization=False, ISO=0, exposure_compensation=0, + exposure_mode='auto', meter_mode='average', awb_mode='auto', + image_effect='none', color_effects=None, rotation=0, + crop=(0.0, 0.0, 1.0, 1.0), **kwargs): + """ See https://www.raspberrypi.org/documentation/usage/camera/python/README.md + for a detailed reference about the Pi camera options """ + super().__init__(**kwargs) self.listen_port = listen_port - self.x_resolution = x_resolution - self.y_resolution = y_resolution - self.framerate = framerate - self.hflip = hflip - self.vflip = vflip - self.server_socket = socket.socket() self.server_socket.bind(('0.0.0.0', self.listen_port)) self.server_socket.listen(0) self.camera = picamera.PiCamera() - self.camera.resolution = (self.x_resolution, self.y_resolution) + self.camera.resolution = (x_resolution, y_resolution) self.camera.framerate = framerate - self.camera.hflip = self.hflip - self.camera.vflip = self.vflip + self.camera.hflip = hflip + self.camera.vflip = vflip + self.camera.sharpness = sharpness + self.camera.contrast = contrast + self.camera.brightness = brightness + self.camera.video_stabilization = video_stabilization + self.camera.ISO = ISO + self.camera.exposure_compensation = exposure_compensation + self.camera.exposure_mode = exposure_mode + self.camera.meter_mode = meter_mode + self.camera.awb_mode = awb_mode + self.camera.image_effect = image_effect + self.camera.color_effects = color_effects + self.camera.rotation = rotation + self.camera.crop = crop logging.info('Initialized Pi camera backend')