camera.pi

class platypush.plugins.camera.pi.CameraPiPlugin(device: int = 0, fps: float = 30.0, warmup_seconds: float = 2.0, sharpness: int = 0, contrast: int = 0, brightness: int = 50, video_stabilization: bool = False, iso: int = 0, exposure_compensation: int = 0, exposure_mode: str = 'auto', meter_mode: str = 'average', awb_mode: str = 'auto', image_effect: str = 'none', led_pin: Optional[int] = None, color_effects: Optional[Union[str, List[str]]] = None, zoom: Tuple[float, float, float, float] = (0.0, 0.0, 1.0, 1.0), **camera)[source]

Plugin to control a Pi camera.

Requires:

  • picamera (pip install picamera)

  • numpy (pip install numpy)

  • Pillow (pip install Pillow)

__init__(device: int = 0, fps: float = 30.0, warmup_seconds: float = 2.0, sharpness: int = 0, contrast: int = 0, brightness: int = 50, video_stabilization: bool = False, iso: int = 0, exposure_compensation: int = 0, exposure_mode: str = 'auto', meter_mode: str = 'average', awb_mode: str = 'auto', image_effect: str = 'none', led_pin: Optional[int] = None, color_effects: Optional[Union[str, List[str]]] = None, zoom: Tuple[float, float, float, float] = (0.0, 0.0, 1.0, 1.0), **camera)[source]

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

Parameters

camera – Options for the base camera plugin (see platypush.plugins.camera.CameraPlugin).

capture_frame(camera: platypush.plugins.camera.model.camera.Camera, *args, **kwargs)[source]

Capture a frame from a device using the plugin-specific logic - to be implemented by the derived classes.

Parameters

device – An initialized platypush.plugins.camera.Camera object.

capture_preview(duration: Optional[float] = None, n_frames: Optional[int] = None, **camera)dict[source]

Start a camera preview session.

Parameters
  • duration – Preview duration (default: until stop_capture() is called).

  • n_frames – Number of frames to display before closing (default: until stop_capture() is called).

  • camera – Camera object properties.

Returns

The status of the device.

prepare_device(device: platypush.plugins.camera.pi.model.PiCamera)[source]

Prepare a device using the plugin-specific logic - to be implemented by the derived classes.

Parameters

device – An initialized platypush.plugins.camera.Camera object.

release_device(device: platypush.plugins.camera.pi.model.PiCamera)[source]

Release a device using the plugin-specific logic - to be implemented by the derived classes.

Parameters

device – An initialized platypush.plugins.camera.Camera object.

start_preview(camera: platypush.plugins.camera.model.camera.Camera)[source]

Start camera preview.

start_streaming(duration: Optional[float] = None, stream_format: str = 'h264', **camera)dict[source]

Expose the video stream of a camera over a TCP connection.

Parameters
  • duration – Streaming thread duration (default: until stop_streaming() is called).

  • stream_format – Format of the output stream - e.g. h264, mjpeg, mkv etc. (default: mkv).

  • camera – Camera object properties - see constructor parameters.

Returns

The status of the device.

stop_preview(camera: platypush.plugins.camera.model.camera.Camera)[source]

Stop camera preview.