camera.pi#

class platypush.backend.camera.pi.CameraPiBackend(listen_port, bind_address='0.0.0.0', 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]#

Bases: Backend

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)

This backend is DEPRECATED. Use the plugin platypush.plugins.camera.pi.CameraPiPlugin instead to run Pi camera actions. If you want to start streaming the camera on application start then simply create an event hook on platypush.message.event.application.ApplicationStartedEvent that runs camera.pi.start_streaming.

class CameraAction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

__init__(listen_port, bind_address='0.0.0.0', 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

  • bind_address (str) – Bind address (default: 0.0.0.0).

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