slmsuite.hardware.cameras.template.Template
- class Template(serial='', verbose=True, **kwargs)[source]
Bases:
Camera
Template for adding a new camera to
slmsuite
. ReplaceTemplate
with the desired subclass name.Camera
is the superclass that sets the requirements forTemplate
.- sdk
Many cameras have a singleton SDK class which handles all the connected cameras of a certain brand. This is generally implemented as a class variable.
- Type
object
- cam
Most cameras will wrap some handle which connects to the the hardware.
- Type
object
Methods
Sets the exposure of the camera such that the maximum value is at
set_fraction
of the dynamic range.Uses an FFT contrast metric to find optimal focus when scanning over some variable
z
.See
Camera.close()
.See
Camera.flush()
.See
Camera.get_image()
.Grab
image_count
images in succession.Discovers all cameras detected by the SDK.
Abstract method to reset the camera to a default state.
See
Camera.set_woi()
.Attributes
- __init__(serial='', verbose=True, **kwargs)[source]
Initialize camera and attributes.
- Parameters
serial (str) – Most SDKs identify different cameras by some serial number or string.
verbose (bool) – Whether or not to print extra information.
kwargs – See
Camera.__init__()
for permissible options.
- close()[source]
See
Camera.close()
.
- static info(verbose=True)[source]
Discovers all cameras detected by the SDK. Useful for a user to identify the correct serial numbers / etc.
- Parameters
verbose (bool) – Whether to print the discovered information.
- Returns
List of serial numbers or identifiers.
- Return type
list of str
- set_woi(woi=None)[source]
See
Camera.set_woi()
.
- get_image(timeout_s=1)[source]
See
Camera.get_image()
.
- flush()[source]
See
Camera.flush()
.
- autoexposure(set_fraction=0.5, tol=0.05, exposure_bounds_s=None, window=None, average_count=5, timeout_s=5, verbose=True)[source]
Sets the exposure of the camera such that the maximum value is at
set_fraction
of the dynamic range. Useful for mitigating deleterious over- or under- exposure.- Parameters
set_fraction (float) – Fraction of camera dynamic range to target image maximum.
tol (float) – Fractional tolerance for exposure adjustment.
exposure_bounds_s ((float, float) OR None) – Shortest and longest allowable integration in seconds. If
None
, defaults toexposure_bounds_s
. If this attribute was not set (or not availible on a particular camera), thenNone
instead defaults to unbounded.window (array_like or None) – See
window
. IfNone
, the full camera frame will be used.average_count (int) – Number of frames to average intensity over for noise reduction.
timeout_s (float) – Stop attempting to autoexpose after
timeout_s
seconds.verbose (bool) – Whether to print exposure updates.
- Returns
Resulting exposure in seconds.
- Return type
float
- autofocus(z_get, z_set, z_list=None, plot=False)[source]
Uses an FFT contrast metric to find optimal focus when scanning over some variable
z
. Thisz
often takes the form of a vertical stage to position a sample precisely at the plane of imaging of a lens or objective. The contrast metric works particularly well when combined with a projected spot array hologram.- Parameters
z_get (lambda) – Gets the current position of the focusing stage. Should return a
float
.z_set (lambda) – Sets the position of the focusing stage to a given
float
.z_list (array_like or None) –
z
values to sweep over during search. Defaults (whenNone
) tonumpy.linspace(-4,4,16)
.plot (bool) – Whether to provide illustrative plots.
- get_images(image_count, flush=False)[source]
Grab
image_count
images in succession. Overwrite this implementation if a camera supports faster batch acquisition.- Parameters
image_count (int) – Number of images to grab.
flush (bool) – Whether to flush before grabbing.
- Returns
Array of shape
(image_count, height, width)
.- Return type
numpy.ndarray