slmsuite.hardware.cameras.alliedvision.AlliedVision

class AlliedVision(serial='', verbose=True, **kwargs)[source]

Bases: Camera

AlliedVision camera.

sdk

AlliedVision SDK. Shared among instances of AlliedVision.

Type

vimba.Vimba

cam

Object to talk with the desired camera.

Type

vimba.Camera

Caution

The AlliedVision SDK vimba includes protections to maintain camera connectivity: specifically, the SDK vimba.Vimba and cameras vimba.Camera are designed to be used in concert with with statements. Unfortunately, this does not mesh with the architecture of slmsuite, where notebook-style operation is desired. Using with statements inside AlliedVision methods is likewise not an option, as the methods to __enter__() and __exit__() the with are time-consuming due to calls to _open() and _close() the objects, to the point of \(\mathcal{O}(\text{s})\) overhead. AlliedVision disables these protections by calling __enter__() and __exit__() directly during __init__() and close(), instead of inside with statements.

Methods

autoexposure

Sets the exposure of the camera such that the maximum value is at set_fraction of the dynamic range.

autofocus

Uses an FFT contrast metric to find optimal focus when scanning over some variable z.

close

See Camera.close()

close_sdk

Close the vimba instance.

flush

See Camera.flush().

get_adc_bitdepth

Get the digitization bitdepth.

get_exposure

See Camera.get_exposure().

get_image

See Camera.get_image().

get_images

Grab image_count images in succession.

get_properties

Print the list of camera properties.

info

Discovers all Thorlabs scientific cameras.

reset

See Camera.reset().

set_adc_bitdepth

Set the digitization bitdepth.

set_exposure

See Camera.set_exposure().

set_woi

See Camera.set_woi().

Attributes

sdk

__init__(serial='', verbose=True, **kwargs)[source]

Initialize camera and attributes.

Parameters
  • serial (str) – Serial number of the camera to open. If empty, defaults to the first camera in the list returned by vimba.get_all_cameras().

  • verbose (bool) – Whether or not to print extra information.

  • kwargs – See Camera.__init__() for permissible options.

close(close_sdk=True)[source]

See Camera.close()

Parameters

close_sdk (bool) – Whether or not to close the vimba instance.

static info(verbose=True)[source]

Discovers all Thorlabs scientific cameras.

Parameters

verbose (bool) – Whether to print the discovered information.

Returns

List of AlliedVision serial numbers.

Return type

list of str

classmethod close_sdk()[source]

Close the vimba instance.

get_properties(properties=None)[source]

Print the list of camera properties.

Parameters

properties (dict or None) – The target camera’s property dictionary. If None, the property dictionary is fetched from the camera associated with the calling instance.

set_adc_bitdepth(bitdepth)[source]

Set the digitization bitdepth.

Parameters

bitdepth (int) – Desired digitization bitdepth.

get_adc_bitdepth()[source]

Get the digitization bitdepth.

Returns

The digitization bitdepth.

Return type

int

get_exposure()[source]

See Camera.get_exposure().

set_exposure(exposure_s)[source]

See Camera.set_exposure().

set_woi(woi=None)[source]

See Camera.set_woi().

get_image(timeout_s=1)[source]

See Camera.get_image().

flush(timeout_s=0.001)[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 to exposure_bounds_s. If this attribute was not set (or not availible on a particular camera), then None instead defaults to unbounded.

  • window (array_like or None) – See window. If None, 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. This z 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 (when None) to numpy.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

reset()[source]

See Camera.reset().