platypush.backend.camera.pi

class platypush.backend.camera.pi.CameraPiBackend(listen_port, x_resolution=640, y_resolution=480, redis_queue='platypush/camera/pi', start_recording_on_startup=True, 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)[source]

Backend to interact with a Raspberry Pi camera. It can start and stop recordings and take pictures. It can be programmatically controlled through the platypush.plugins.camera.pi plugin. Note that the Redis backend must be configured and running to enable camera control.

Requires:

  • picamera (pip install picamera)
  • redis (pip install redis) for inter-process communication with the camera process
class CameraAction[source]

An enumeration.

__init__(listen_port, x_resolution=640, y_resolution=480, redis_queue='platypush/camera/pi', start_recording_on_startup=True, 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)[source]

See https://www.raspberrypi.org/documentation/usage/camera/python/README.md for a detailed reference about the Pi camera options.

Parameters:listen_port (int) – Port where the camera process will provide the video output while recording
run()[source]

Starts the backend thread. To be implemented in the derived classes if the loop method isn’t defined.

start_recording(video_file=None, format='h264')[source]

Start a recording.

Parameters:
  • video_file (str) – Output video file. If specified, the video will be recorded to file, otherwise it will be served via TCP/IP on the listen_port. Use stop_recording to stop the recording.
  • format (str) – Video format (default: h264)
stop_recording()[source]

Stops recording

take_picture(image_file)[source]

Take a picture.

Parameters:image_file (str) – Output image file