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 blob_density.setter Undocumented
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 colour.setter Undocumented
Method discard_frames Discard frames so that the next frame captured is fresh.
Method draw_sprite_on_canvas Place one sprite on canvas at given centre coordinates.
Method full_auto_calibrate Perform a full auto-calibration.
Method generate_blobs Generate coordinates of blobs and their sizes, centered around (0,0).
Method generate_canvas Generate a canvas with generated blobs centered at the middle.
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 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
Class Variable repeating Undocumented
Instance Variable blank_canvas Undocumented
Instance Variable blobs Undocumented
Instance Variable canvas Undocumented
Instance Variable canvas_shape Undocumented
Instance Variable ds_shape Undocumented
Instance Variable frame_interval Undocumented
Instance Variable glyph_size Undocumented
Instance Variable shape Undocumented
Instance Variable sprites Undocumented
Property blob_density The number of blobs per million pixels.
Property calibration_required Whether the camera needs calibrating.
Property colour The colour of the blobs as a HTML hex string.
Property manual_camera_settings The camera settings to expose as property controls in the settings panel.
Property primary_calibration_actions The calibration actions for both calibration wizard and 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
Class Variable _stage Undocumented
Instance Variable _blob_density Undocumented
Instance Variable _capture_enabled Undocumented
Instance Variable _capture_thread Undocumented
Instance Variable _colour Undocumented
Instance Variable _show_sample Undocumented

Inherited from BaseCamera:

Method background_detector_name The name of the active background selector.
Method background_detector_name.setter Validate and set background_detector_name.
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_jpeg Acquire one image from the camera as a JPEG.
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 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.
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.
Property background_detector The active background detector instance.
Property thing_state Empty metadata dict for subclasses to populate.
Method _add_metadata_to_capture Add the EXIF metadata for a JPEG image.
Method _capture_metadata Return the metadata for a capture, from the thing states, time and known names.
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 _all_background_detectors Undocumented
Class Variable _memory_buffer Undocumented
Instance Variable _background_detector_name Undocumented
Instance Variable _default_background_detector Undocumented
def __enter__(self) -> Self: (source)

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

def __exit__(self, exc_type: type[BaseException], exc_value: BaseException | None, traceback: TracebackType | None): (source)

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

def __init__(self, thing_server_interface: lt.ThingServerInterface, shape: tuple[int, int, int] = (616, 820, 3), canvas_shape: tuple[int, int, int] = (1500, 2000, 3), frame_interval: float = 0.1): (source)

Initialise the simulated with settings for how images are generated.

Parameters
thing_server_interface:lt.ThingServerInterfaceUndocumented
shape:tuple[int, int, int]The shape (size) of the generated image.
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 blob_density(self, value: int): (source)

Undocumented

@lt.action
def capture_array(self, stream_name: Literal['main', 'lores', 'raw', 'full'] = 'full', wait: float | None = None) -> NDArray: (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.

Parameters
stream_name:Literal['main', 'lores', 'raw', 'full']Currently ignored, this argument exists to ensure consistent API across camera Things.
wait:float | NoneCurrently ignored, this argument exists to ensure consistent API across camera Things.
Returns
NDArrayUndocumented
def capture_image(self, stream_name: Literal['main', 'lores', 'full'], wait: float | None = None) -> Image.Image: (source)

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

It is used for capture to memory.

Parameters
stream_name:Literal['main', 'lores', 'full']Currently ignored, this argument exists to ensure consistent API across camera Things.
wait:float | NoneCurrently ignored, this argument exists to ensure consistent API across camera Things.
Returns
Image.ImageUndocumented
def colour(self, colour_value: str): (source)

Undocumented

@lt.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 draw_sprite_on_canvas(self, canvas: np.ndarray, sprite: np.ndarray, centre_y: int, centre_x: int): (source)

Place one sprite on canvas at given centre coordinates.

Note that self.canvas is modified in place.

Parameters
canvas:np.ndarrayUndocumented
sprite:np.ndarrayThe sprite array to place on the canvas.
centre_y:intThe y coordinate to place the centre of the sprite.
centre_x:intThe x coordinate to place the centre of the sprite.
@lt.action
def full_auto_calibrate(self): (source)

Perform a full auto-calibration.

For the simulation microscope the process is:

  • remove_sample
  • set_background
  • load_sample
def generate_blobs(self, n_blobs: int = 1000): (source)

Generate coordinates of blobs and their sizes, centered around (0,0).

Note that blob density is determined by sample size and n_blobs, and for larger samples n_blobs will need increasing to keep a high level of sample coverage per field of view.

Parameters
n_blobs:intThe number of blobs to generate.
def generate_canvas(self): (source)

Generate a canvas with generated blobs centered at the middle.

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

def generate_frame(self) -> Image.Image: (source)

Generate a frame with blobs based on the stage coordinates.

def generate_image(self, pos: tuple[int, int, int]) -> Image.Image: (source)

Generate an image with blobs based on supplied coordinates.

Parameters
pos:tuple[int, int, int]a 3-item tuple containing the x,y,z coordinates of the 'stage'
Returns
Image.ImageUndocumented
def generate_sprites(self): (source)

Generate sprites to populate the image.

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

Show the simulated sample.

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

Show the simulated background with no sample.

@lt.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.

Parameters
main_resolution:tuple[int, int]Currently ignored, this argument exists to ensure consistent API across camera Things.
buffer_count:intCurrently ignored, this argument exists to ensure consistent API across camera Things.
noise_level: float = (source)

Undocumented

repeating: bool = (source)

Undocumented

blank_canvas = (source)

Undocumented

Undocumented

Undocumented

canvas_shape = (source)

Undocumented

ds_shape = (source)

Undocumented

frame_interval = (source)

Undocumented

glyph_size = (source)

Undocumented

Undocumented

sprites: list = (source)

Undocumented

@lt.property
blob_density: int = (source)

The number of blobs per million pixels.

@lt.property
calibration_required: bool = (source)

Whether the camera needs calibrating.

@lt.property
colour: str = (source)

The colour of the blobs as a HTML hex string.

The string can either be a single colour (e.g. "#c5247f") or a list of colours separated by semicolons (e.g. "#c5247f; #b937b9"). Additional spaces are allowed between colours.

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

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

@lt.property
primary_calibration_actions: list[ActionButton] = (source)

The calibration actions for both calibration wizard and settings panel.

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

The calibration actions that appear only in settings panel.

@lt.property
stream_active: bool = (source)

Whether the MJPEG stream is active.

def _capture_frames(self): (source)

Undocumented

Undocumented

_blob_density: int = (source)

Undocumented

_capture_enabled: bool = (source)

Undocumented

_capture_thread: Thread | None = (source)

Undocumented

_colour: str = (source)

Undocumented

_show_sample: bool = (source)

Undocumented