Base Streaming Camera

class openflexure_microscope.camera.base.TrackerFrame(size, time)
size

Alias for field number 0

time

Alias for field number 1

class openflexure_microscope.camera.base.FrameStream(*args, **kwargs)[source]

A file-like object used to analyse 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 the heavier image data.

write(s)[source]

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

class openflexure_microscope.camera.base.BaseCamera[source]

Base implementation of StreamingCamera.

configuration

The current camera configuration.

state

The current read-only camera state.

update_settings(config: dict)[source]

Update settings from a config dictionary

read_settings() → dict[source]

Return the current settings as a dictionary

close()[source]

Close the BaseCamera and all attached StreamObjects.

start_worker(timeout: int = 5) → bool[source]

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

stop_worker(timeout: int = 5) → bool[source]

Flag worker thread for stop. Waits for thread close or timeout.

get_frame()[source]

Return the current camera frame.

frames()[source]

Create generator that returns frames from the camera.