class SimulatedCamera(BaseCamera): (source)
Constructor: SimulatedCamera(shape, glyph_shape, canvas_shape, sample_limits, ...)
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 | discard |
Discard frames so that the next frame captured is fresh. |
| Method | draw |
Place one sprite on canvas at given centre coordinates. |
| Method | full |
Perform a full auto-calibration. |
| Method | generate |
Generate coordinates of blobs and their sizes, centered around (0,0). |
| Method | generate |
Generate a canvas with generated blobs centered at the middle. |
| 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. |
| Method | validate |
Validate the inputs passed to the simulation, and raises an error if invalid. |
| 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 | sample |
Undocumented |
| Instance Variable | shape |
Undocumented |
| Instance Variable | sprites |
Undocumented |
| Property | calibration |
Whether the camera needs calibrating. |
| Property | manual |
The camera settings to expose as property controls in the settings panel. |
| Property | primary |
The calibration actions for both calibration wizard and 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 |
Acquire one image from the camera as a JPEG. |
| 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 | thing |
Empty metadata dict for subclasses to populate. |
| Method | _add |
Add the EXIF metadata for a JPEG image. |
| Method | _capture |
Return the metadata for a capture, from the thing states, time and known names. |
| 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 |
type[ BaseException], _exc_value: BaseException | None, _traceback: TracebackType | None):
(source)
¶
Close the capture thread when the Thing context manager is closed.
tuple[ int, int, int] = (tuple[ int, int, int] = (tuple[ int, int, int] = (tuple[ int, int] | None = (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. |
sampletuple[ | The shape of the sample. Outside this range, the camera won't generate any blobs, preventing scanning from running indefinitely and better demonstrating background detect. |
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', wait: float | None = None) -> 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.
| Parameters | |
streamLiteral[ | Currently ignored, this argument exists to ensure consistent API across camera Things. |
wait:float | None | Currently ignored, this argument exists to ensure consistent API across camera Things. |
| Returns | |
ArrayModel | Undocumented |
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.
| Parameters | |
streamLiteral[ | Currently ignored, this argument exists to ensure consistent API across camera Things. |
wait:float | None | Currently ignored, this argument exists to ensure consistent API across camera Things. |
| Returns | |
Image | Undocumented |
Discard frames so that the next frame captured is fresh.
There is nothing to do as this is a simulation!
Place one sprite on canvas at given centre coordinates.
Note that self.canvas is modified in place.
| Parameters | |
sprite:np.ndarray | The sprite array to place on the canvas. |
centreint | The y coordinate to place the centre of the sprite. |
centreint | The x coordinate to place the centre of the sprite. |
Perform a full auto-calibration.
For the simulation microscope the process is:
- remove_sample
- set_background
- load_sample
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 | |
nint | The number of blobs to generate. |
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.
Generate an image with blobs based on supplied coordinates.
| Parameters | |
pos:tuple[ | a 3-item tuple containing the x,y,z coordinates of the 'stage' |
| Returns | |
Image | Undocumented |
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.
| Parameters | |
maintuple[ | Currently ignored, this argument exists to ensure consistent API across camera Things. |
bufferint | Currently ignored, this argument exists to ensure consistent API across camera Things. |
Validate the inputs passed to the simulation, and raises an error if invalid.
Currently only tests that the sample size is not greater than the canvas size in any dimension.