blinkenxmas.cameras

The blinkenxmas.cameras module defines abstractions for the various camera backends that Blinken’ Xmas supports. The classes are as follows:

Camera classes

class blinkenxmas.cameras.AbstractSource(config)[source]

An abstract camera source.

The config is the application configuration object (a Namespace instance).

frame

The current preview frame’s data. This is a bytes string containing the JPEG data of the frame.

frame_ready

A Condition which clients must wait upon to be notified of a new JPEG available in frame.

add_client(client)[source]

Called to add client (a BaseHTTPRequestHandler instance) to the list of clients wanting to receive live preview frames from the camera.

capture(angle, led=None)[source]

Capture a high-quality (highest possible resolution) image of the tree at angle with led lit full white. Expected to return a file-like object containing the JPEG image data.

remove_client(client)[source]

Called to remove client (a BaseHTTPRequestHandler instance) from the list of clients wanting to receive live preview frames from the camera.

start_preview(angle)[source]

Start a live preview from the camera, passing JPEG image frames to the frame attribute. The angle is the current angle of the tree.

stop_preview()[source]

Terminate the live preview from the camera.

class blinkenxmas.cameras.FilesSource(config)[source]

This “camera” is primarily intended for testing purposes. It is implemented simple as a list of JPEG files which must conform to the following naming convention:

angleA_base.jpg

The base “unlit” image of the tree at the specified angle n (in degrees), where A is zero-padded to three digits. For example angle090_base.jpg.

angleA_ledL.jpg

The image of the tree at angle A (in degrees, zero-padded to three digits) with LED at index L (zero-padded to three digits) lit bright white. For example angle090_led049.jpg.

capture(angle, led=None)[source]

Capture a high-quality (highest possible resolution) image of the tree at angle with led lit full white. Expected to return a file-like object containing the JPEG image data.

start_preview(angle)[source]

Start a live preview from the camera, passing JPEG image frames to the frame attribute. The angle is the current angle of the tree.

stop_preview()[source]

Terminate the live preview from the camera.

class blinkenxmas.cameras.PiCameraSource(config)[source]

A camera implementation that uses the legacy picamera library.

Warning

Be warned that this will only work with Raspberry Pi models up to the 4B (specifically not the Pi 5), and only with legacy 32-bit versions of RaspiOS or Ubuntu.

capture(angle, led=None)[source]

Capture a high-quality (highest possible resolution) image of the tree at angle with led lit full white. Expected to return a file-like object containing the JPEG image data.

start_preview(angle)[source]

Start a live preview from the camera, passing JPEG image frames to the frame attribute. The angle is the current angle of the tree.

stop_preview()[source]

Terminate the live preview from the camera.

class blinkenxmas.cameras.GStreamerSource(config)[source]

A camera implementation based on GStreamer.

This is primarily intended for use with USB web-cams. However, be warned that most USB web-cams have terrible quality compared to proper camera modules. You are far better off using a Pi camera module.

capture(angle, led=None)[source]

Capture a high-quality (highest possible resolution) image of the tree at angle with led lit full white. Expected to return a file-like object containing the JPEG image data.

start_preview(angle)[source]

Start a live preview from the camera, passing JPEG image frames to the frame attribute. The angle is the current angle of the tree.

stop_preview()[source]

Terminate the live preview from the camera.

Support classes

class blinkenxmas.cameras.PiCameraOutput(source)[source]

A picamera custom output used by PiCameraSource to route preview frames to clients.