Base Streaming Camera

class, time)[source]

Alias for field number 0


Alias for field number 1

class*args, **kwargs)[source]

A file-like object used to analyse and stream MJPEG frames.

Instead of analysing a load of real MJPEG frames after they’ve been stored in a BytesIO stream, we tell the camera to write frames to this class instead.

We then do analysis as the frames are written, and discard old frames as each new frame is written.


Start tracking frame sizes


Stop tracking frame sizes


Empty the array of tracked frame sizes


Write a new frame to the FrameStream. Does a few things: 1. If tracking frame size, store the size in self.frames 2. Rewind and truncate the stream (delete previous frame) 3. Store the new frame image 4. Set the new_frame event

getvalue() → bytes[source]

Clear tne new_frame event and return frame data

getframe() → bytes[source]

Wait for a new frame to be available, then return it


Base implementation of StreamingCamera.

lock = None

Access lock for the camera

stream = None

Streaming and analysis frame buffer


The current camera configuration.


The current read-only camera state.


Ensure the frame stream is actively running


Stop the active stream, if possible

update_settings(config: dict)[source]

Update settings from a config dictionary

read_settings() → dict[source]

Return the current settings as a dictionary

capture(output: Union[str, BinaryIO], fmt: str = 'jpeg', use_video_port: bool = False, resize: Optional[Tuple[int, int]] = None, bayer: bool = True, thumbnail: Optional[Tuple[int, int, int]] = None)[source]

Perform a basic capture to output

  • output – String or file-like object to write capture data to
  • fmt – Format of the capture.
  • use_video_port – Capture from the video port used for streaming. Lower resolution, faster.
  • resize – Resize the captured image.
  • bayer – Store raw bayer data in capture
  • thumbnail – Dimensions and quality (x, y, quality) of a thumbnail to generate, if supported
start_worker(**_) → bool[source]

Start the background camera thread if it isn’t running yet.

get_frame() → bytes[source]

Return the current camera frame.

Just an alias of


Close the BaseCamera and all attached StreamObjects.