class documentation

A Thing that simulates a camera for testing.

Method __enter__ Start the capture thread when the Thing context manager is opened.
Method __exit__ Close the capture thread when the Thing context manager is closed.
Method __init__ Initialise the simulated with settings for how images are generated.
Method attach_to_server Wrap the attach_to_server method so the server instance can be stored.
Method capture_array Acquire one image from the camera and return as an array.
Method capture_image Capture to a PIL image. This is not exposed as a ThingAction.
Method capture_jpeg Acquire one image from the camera and return as a JPEG blob.
Method discard_frames Discard frames so that the next frame captured is fresh.
Method generate_blobs Generate coordinates of blobs and their sizes.
Method generate_canvas Generate a canvas.
Method generate_frame Generate a frame with blobs based on the stage coordinates.
Method generate_image Generate an image with blobs based on supplied coordinates.
Method generate_sprites Generate sprites to populate the image.
Method get_stage_position Return the stage position.
Method load_sample Show the simulated sample.
Method remove_sample Show the simulated background with no sample.
Method start_streaming Start the live stream.
Class Variable noise_level Undocumented
Instance Variable blank_canvas Undocumented
Instance Variable blobs Undocumented
Instance Variable canvas Undocumented
Instance Variable canvas_shape Undocumented
Instance Variable frame_interval Undocumented
Instance Variable glyph_shape Undocumented
Instance Variable shape Undocumented
Instance Variable sprites Undocumented
Property manual_camera_settings The camera settings to expose as property controls in the settings panel.
Property secondary_calibration_actions The calibration actions that appear only in settings panel.
Property stream_active Whether the MJPEG stream is active.
Method _capture_frames Undocumented
Instance Variable _capture_enabled Undocumented
Instance Variable _capture_thread Undocumented
Instance Variable _server Undocumented
Instance Variable _show_sample Undocumented
Instance Variable _stage Undocumented

Inherited from BaseCamera:

Method background_detector_data The data for each background detector, used to save to disk.
Method background_detector_data.setter Set the data for each detector. Only to be used as settings are loaded from disk.
Method capture_and_save Capture an image and save it to disk.
Method capture_downsampled_array Acquire one image from the camera, downsample, and return as an array.
Method capture_to_memory Capture an image to memory. This can be saved later with save_from_memory.
Method clear_buffers Clear all images in memory.
Method detector_name The name of the active background selector.
Method detector_name.setter Validate and set detector_name.
Method grab_as_array Acquire one image from the preview stream and return as an array.
Method grab_jpeg Acquire one image from the preview stream and return as blob of JPEG data.
Method grab_jpeg_size Acquire one image from the preview stream and return its size.
Method image_is_sample Label the current image as either background or sample.
Method kill_mjpeg_streams Kill the streams now as the server is shutting down.
Method save_from_memory Save an image that has been captured to memory.
Method set_background Grab an image, and use its statistics to set the background.
Method settle Sleep for the settling time, ready to provide a fresh frame.
Method update_detector_settings Update the settings of the current detector.
Class Variable downsampled_array_factor The downsampling factor when calling capture_downsampled_array.
Class Variable lores_mjpeg_stream Undocumented
Class Variable mjpeg_stream Undocumented
Class Variable settling_time The settling time when calling the settle() method.
Instance Variable background_detectors Undocumented
Property active_detector The active background detector instance.
Property background_detector_status The status of the active detector for the UI.
Property primary_calibration_actions The calibration actions for both calibration wizard and settings panel.
Method _robust_image_capture Capture an image in memory and return it with metadata.
Method _save_capture Save the captured image and metadata to disk.
Class Variable _memory_buffer Undocumented
Instance Variable _detector_name Undocumented
def __enter__(self): (source)

Start the capture thread when the Thing context manager is opened.

def __exit__(self, _exc_type, _exc_value, _traceback): (source)

Close the capture thread when the Thing context manager is closed.

def __init__(self, shape: tuple[int, int, int] = (616, 820, 3), glyph_shape: tuple[int, int, int] = (91, 91, 3), canvas_shape: tuple[int, int, int] = (3000, 4000, 3), frame_interval: float = 0.1): (source)

Initialise the simulated with settings for how images are generated.

Parameters
shape:tuple[int, int, int]The shape (size) of the generated image.
glyph_shape:tuple[int, int, int]The size randomly positioned glyphs.
canvas_shape:tuple[int, int, int]The shape (size) of the canvas generated on initialisation that images are cropped from. If this is too large the it uses resources, but its size limits the range of motion of the simulation.
frame_interval:floatNominally the time between frames on the MJPEG stream, however the rate may be slower due to calculation time for focus.
def attach_to_server(self, server: lt.ThingServer, path: str, setting_storage_path: str): (source)

Wrap the attach_to_server method so the server instance can be stored.

Direct access to the server instance is needed to get the stage position while maintaining the same public API as a real camera that doesn't need this access.

@lt.thing_action
def capture_array(self, resolution: Literal['main', 'full'] = 'full') -> ArrayModel: (source)

Acquire one image from the camera and return as an array.

This function will produce a nested list containing an uncompressed RGB image. It's likely to be highly inefficient - raw and/or uncompressed captures using binary image formats will be added in due course.

def capture_image(self, stream_name: Literal['main', 'lores', 'raw'], wait: float | None = None) -> Image: (source)

Capture to a PIL image. This is not exposed as a ThingAction.

It is used for capture to memory.

@lt.thing_action
def capture_jpeg(self, metadata_getter: lt.deps.GetThingStates, resolution: Literal['main', 'full'] = 'main') -> JPEGBlob: (source)

Acquire one image from the camera and return as a JPEG blob.

This function will produce a JPEG image.

@lt.thing_action
def discard_frames(self): (source)

Discard frames so that the next frame captured is fresh.

There is nothing to do as this is a simulation!

def generate_blobs(self, n_blobs: int = 1000): (source)

Generate coordinates of blobs and their sizes.

A 1000x3 array is returned. Each row represents (x,y) coordinate of the sprite and the index representing the size of the sprite.

Blobs are characterised by X, Y, sprite We also generate a KD tree to rapidly find blobs in an image

def generate_canvas(self): (source)

Generate a canvas.

Canvas is int16 so that random noise can be added to simulation image before changing to unit8 to stop wrapping.

def generate_frame(self): (source)

Generate a frame with blobs based on the stage coordinates.

def generate_image(self, pos: tuple[int, int, int]): (source)

Generate an image with blobs based on supplied coordinates.

def generate_sprites(self): (source)

Generate sprites to populate the image.

def get_stage_position(self): (source)

Return the stage position.

The simulation camera has access to the stage position so it can generate a different image as the stage moves.

@lt.thing_action
def load_sample(self): (source)

Show the simulated sample.

@lt.thing_action
def remove_sample(self): (source)

Show the simulated background with no sample.

@lt.thing_action
def start_streaming(self, main_resolution: tuple[int, int] = (820, 616), buffer_count: int = 1): (source)

Start the live stream.

The start_streaming method is used a camera Thing to begin streaming images or to adjust the stream resolution if streaming is already active.

The simulation camera does not currently support the resolution argument. It will always issue a warning that the resolution is not respected. If called while already streaming, the warning will be emitted and no other action will be taken.

noise_level = (source)

Undocumented

blank_canvas = (source)

Undocumented

Undocumented

Undocumented

canvas_shape = (source)

Undocumented

frame_interval = (source)

Undocumented

glyph_shape = (source)

Undocumented

Undocumented

sprites: list = (source)

Undocumented

@lt.thing_property
manual_camera_settings: list[PropertyControl] = (source)

The camera settings to expose as property controls in the settings panel.

@lt.thing_property
secondary_calibration_actions: list[ActionButton] = (source)

The calibration actions that appear only in settings panel.

@lt.thing_property
stream_active: bool = (source)

Whether the MJPEG stream is active.

def _capture_frames(self): (source)

Undocumented

_capture_enabled: bool = (source)

Undocumented

_capture_thread: Thread | None = (source)

Undocumented

_server: lt.ThingServer | None = (source)

Undocumented

_show_sample: bool = (source)

Undocumented

_stage: BaseStage | None = (source)

Undocumented