class SimulatedCamera(BaseCamera): (source)
Constructor: SimulatedCamera(thing_server_interface, 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 | blob |
Undocumented |
| 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 | colour |
Undocumented |
| 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 | load |
Show the simulated sample. |
| Method | remove |
Show the simulated background with no sample. |
| Method | start |
Start the live stream. |
| Class Variable | noise |
Undocumented |
| Class Variable | repeating |
Undocumented |
| Instance Variable | blank |
Undocumented |
| Instance Variable | blobs |
Undocumented |
| Instance Variable | canvas |
Undocumented |
| Instance Variable | canvas |
Undocumented |
| Instance Variable | ds |
Undocumented |
| Instance Variable | frame |
Undocumented |
| Instance Variable | glyph |
Undocumented |
| Instance Variable | shape |
Undocumented |
| Instance Variable | sprites |
Undocumented |
| Property | blob |
The number of blobs per million pixels. |
| Property | calibration |
Whether the camera needs calibrating. |
| Property | colour |
The colour of the blobs as a HTML hex string. |
| 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 |
| Class Variable | _stage |
Undocumented |
| Instance Variable | _blob |
Undocumented |
| Instance Variable | _capture |
Undocumented |
| Instance Variable | _capture |
Undocumented |
| Instance Variable | _colour |
Undocumented |
| Instance Variable | _show |
Undocumented |
Inherited from BaseCamera:
| Method | background |
The name of the active background selector. |
| Method | background |
Validate and set background_detector_name. |
| 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 | 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. |
| 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. |
| Property | background |
The active background detector instance. |
| 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 | _all |
Undocumented |
| Class Variable | _memory |
Undocumented |
| Instance Variable | _background |
Undocumented |
| Instance Variable | _default |
Undocumented |
type[ BaseException], exc_value: BaseException | None, traceback: TracebackType | None):
(source)
¶
Close the capture thread when the Thing context manager is closed.
lt.ThingServerInterface, shape: tuple[ int, int, int] = (tuple[ int, int, int] = (float = 0.1):
(source)
¶
Initialise the simulated with settings for how images are generated.
| Parameters | |
thinglt.ThingServerInterface | Undocumented |
shape:tuple[ | The shape (size) of the generated image. |
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. |
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 | |
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 | |
NDArray | Undocumented |
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 | |
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.Image | Undocumented |
Discard frames so that the next frame captured is fresh.
There is nothing to do as this is a simulation!
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.ndarray | Undocumented |
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.Image | Undocumented |
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. |
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.