class SimulatedCamera(BaseCamera): (source)
Constructor: SimulatedCamera(shape, glyph_shape, canvas_shape, frame_interval)
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 |
Wrap the attach_to_server method so the server instance can be stored. |
| Method | capture |
Acquire one image from the camera and return as an array. |
| Method | capture |
Capture to a PIL image. This is not exposed as a ThingAction. |
| Method | capture |
Acquire one image from the camera and return as a JPEG blob. |
| Method | discard |
Discard frames so that the next frame captured is fresh. |
| Method | generate |
Generate coordinates of blobs and their sizes. |
| Method | generate |
Generate a canvas. |
| Method | generate |
Generate a frame with blobs based on the stage coordinates. |
| Method | generate |
Generate an image with blobs based on supplied coordinates. |
| Method | generate |
Generate sprites to populate the image. |
| Method | get |
Return the stage position. |
| Method | load |
Show the simulated sample. |
| Method | remove |
Show the simulated background with no sample. |
| Method | start |
Start the live stream. |
| Class Variable | noise |
Undocumented |
| Instance Variable | blank |
Undocumented |
| Instance Variable | blobs |
Undocumented |
| Instance Variable | canvas |
Undocumented |
| Instance Variable | canvas |
Undocumented |
| Instance Variable | frame |
Undocumented |
| Instance Variable | glyph |
Undocumented |
| Instance Variable | shape |
Undocumented |
| Instance Variable | sprites |
Undocumented |
| Property | manual |
The camera settings to expose as property controls in the settings panel. |
| Property | secondary |
The calibration actions that appear only in settings panel. |
| Property | stream |
Whether the MJPEG stream is active. |
| Method | _capture |
Undocumented |
| Instance Variable | _capture |
Undocumented |
| Instance Variable | _capture |
Undocumented |
| Instance Variable | _server |
Undocumented |
| Instance Variable | _show |
Undocumented |
| Instance Variable | _stage |
Undocumented |
Inherited from BaseCamera:
| Method | background |
The data for each background detector, used to save to disk. |
| Method | background |
Set the data for each detector. Only to be used as settings are loaded from disk. |
| Method | capture |
Capture an image and save it to disk. |
| Method | capture |
Acquire one image from the camera, downsample, and return as an array. |
| Method | capture |
Capture an image to memory. This can be saved later with save_from_memory. |
| Method | clear |
Clear all images in memory. |
| Method | detector |
The name of the active background selector. |
| Method | detector |
Validate and set detector_name. |
| Method | grab |
Acquire one image from the preview stream and return as an array. |
| Method | grab |
Acquire one image from the preview stream and return as blob of JPEG data. |
| Method | grab |
Acquire one image from the preview stream and return its size. |
| Method | image |
Label the current image as either background or sample. |
| Method | kill |
Kill the streams now as the server is shutting down. |
| Method | save |
Save an image that has been captured to memory. |
| Method | set |
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 |
Update the settings of the current detector. |
| Class Variable | downsampled |
The downsampling factor when calling capture_downsampled_array. |
| Class Variable | lores |
Undocumented |
| Class Variable | mjpeg |
Undocumented |
| Class Variable | settling |
The settling time when calling the settle() method. |
| Instance Variable | background |
Undocumented |
| Property | active |
The active background detector instance. |
| Property | background |
The status of the active detector for the UI. |
| Property | primary |
The calibration actions for both calibration wizard and settings panel. |
| Method | _robust |
Capture an image in memory and return it with metadata. |
| Method | _save |
Save the captured image and metadata to disk. |
| Class Variable | _memory |
Undocumented |
| Instance Variable | _detector |
Undocumented |
tuple[ int, int, int] = (tuple[ int, int, int] = (tuple[ int, int, int] = (float = 0.1):
(source)
¶
Initialise the simulated with settings for how images are generated.
| Parameters | |
shape:tuple[ | The shape (size) of the generated image. |
glyphtuple[ | The size randomly positioned glyphs. |
canvastuple[ | 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. |
framefloat | Nominally the time between frames on the MJPEG stream, however the rate may be slower due to calculation time for focus. |
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.
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.
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.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.
Discard frames so that the next frame captured is fresh.
There is nothing to do as this is a simulation!
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
Generate a canvas.
Canvas is int16 so that random noise can be added to simulation image before changing to unit8 to stop wrapping.
Return the stage position.
The simulation camera has access to the stage position so it can generate a different image as the stage moves.
tuple[ int, int] = (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.