UC480 (Thorlabs DCx) Cameras

This module is for controlling Thorlabs DCx cameras. You should install the corresponding drivers that can be found on the Thorlabs website. Specifically, this module requires either ‘uc480.dll’ or ‘uc480_64.dll’, depending on your system. The driver library must be visible to python, so you may need to add it to your PATH or copy it to your Windows system32 directory.

Module Reference

Driver for Thorlabs DCx cameras. May be compatible with iDS cameras that use uEye software. Currently Windows-only, but Linux support should be possible to implement if desired.

class instrumental.drivers.cameras.uc480.UC480_Camera

A uc480-supported Camera.

close()

Close the camera and release associated image memory.

Should be called when you are done using the camera. Alternatively, you can use the camera as a context manager–see the documentation for __init__.

get_captured_image(timeout='1s', copy=True)

Get the image array(s) from the last capture sequence

Returns an image numpy array (or tuple of arrays for a multi-exposure sequence). The array has shape (height, width) for grayscale images, and (height, width, 3) for RGB images. Typically the dtype will be uint8, or sometimes uint16 in the case of 16-bit monochromatic cameras.

Parameters:
  • timeout (Quantity([time]) or None, optional) – Max time to wait for wait for the image data to be ready. If None, will block forever. If timeout is exceeded, a TimeoutError will be raised.
  • copy (bool, optional) – Whether to copy the image memory or directly reference the underlying buffer. It is recommended to use True (the default) unless you know what you’re doing.
get_trigger_delay()

Returns the trigger delay in microseconds

Returns:Trigger delay
Return type:string
get_trigger_level()

Get the current hardware trigger level

Returns:A value of 0 indicates trigger signal is low (not triggered)
Return type:int
grab_image(timeout='1s', copy=True, **kwds)

Perform a capture and return the resulting image array(s)

This is essentially a convenience function that calls start_capture() then get_captured_image(). See get_captured_image() for information about the returned array(s).

Parameters:
  • timeouts (Quantity([time]) or None, optional) – Max time to wait for wait for the image data to be ready. If None, will block forever. If timeout is exceeded, a TimeoutError will be raised.
  • copy (bool, optional) – Whether to copy the image memory or directly reference the underlying buffer. It is recommended to use True (the default) unless you know what you’re doing.
  • can specify other parameters of the capture as keyword arguments. These include (You) –
Other Parameters:
 
  • n_frames (int) – Number of exposures in the sequence
  • vbin (int) – Vertical binning
  • hbin (int) – Horizontal binning
  • exposure_time (Quantity([time])) – Duration of each exposure
  • width (int) – Width of the ROI
  • height (int) – Height of the ROI
  • cx (int) – X-axis center of the ROI
  • cy (int) – Y-axis center of the ROI
  • left (int) – Left edge of the ROI
  • right (int) – Right edge of the ROI
  • top (int) – Top edge of the ROI
  • bot (int) – Bottom edge of the ROI
latest_frame(copy=True)

Get the latest image frame in live mode

Returns the image array received on the most recent successful call to wait_for_frame().

Parameters:copy (bool, optional) – Whether to copy the image memory or directly reference the underlying buffer. It is recommended to use True (the default) unless you know what you’re doing.
load_params(filename=None)

Load camera parameters from file or EEPROM.

Parameters:filename (str, optional) – By default, loads the parameters from the camera’s EEPROM. Otherwise, loads it from the specified parameter file. If filename is the empty string ‘’, will open a ‘Load’ dialog to select the file.
set_auto_exposure(enable=True)

Enable or disable the auto exposure shutter.

set_trigger(mode='software', edge='rising')

Sets the camera trigger mode.

Parameters:
  • mode (string) – Either ‘off’, ‘software’(default), or ‘hardware’.
  • edge (string) – Hardware trigger is either on the ‘rising’(default) or ‘falling’ edge.
set_trigger_delay(delay)

Sets the time to delay a hardware trigger (in microsseconds)

Parameters:delay (string) – The delay time (in microseconds ‘us’) after trigger signal is received to trigger the camera
start_capture(**kwds)

Start a capture sequence and return immediately

Depending on your camera-specific shutter/trigger settings, this will either start the exposure immediately or ready the camera to start on an explicit (hardware or software) trigger.

It can be useful to invoke capture() and get_captured_image() explicitly if you expect the capture sequence to take a long time and you’d like to perform some operations while you wait for the camera:

>>> cam.capture()
>>> do_other_useful_stuff()
>>> arr = cam.get_captured_image()

See grab_image() for the set of available kwds.

start_live_video(framerate=None, **kwds)

Start live video mode

Once live video mode has been started, images will automatically and continuously be acquired. You can check if the next frame is ready by using wait_for_frame(), and access the most recent image’s data with get_captured_image().

See grab_image() for the set of available kwds.

stop_live_video()

Stop live video capture.

wait_for_frame(timeout=None)

Wait until the next frame is ready (in live mode)

Blocks and returns True once the next frame is ready, False if the timeout was reached. Using a timeout of 0 simply polls to see if the next frame is ready.

Parameters:timeout (Quantity([time]), optional) – How long to wait for wait for the image data to be ready. If None (the default), will block forever.
Returns:frame_readyTrue if the next frame is ready, False if the timeout was reached.
Return type:bool
DEFAULT_KWDS = {'exposure_time': <Quantity(10, 'millisecond')>, 'right': None, 'vbin': 1, 'cx': None, 'top': None, 'bot': None, 'n_frames': 1, 'width': None, 'cy': None, 'fix_hotpixels': False, 'vsub': 1, 'gain': 0, 'hbin': 1, 'hsub': 1, 'height': None, 'left': None}
bytes_per_line

Number of bytes used by each line of the image. Read-only

color_mode

Color mode string. Read-only

height

Height of the camera image in pixels

id

uEye camera ID number. Read-only

max_height

Max settable height of the camera image, given current binning/subpixel settings

max_width

Max settable width of the camera image, given current binning/subpixel settings

model

Camera model number string. Read-only

serial

Camera serial number string. Read-only

trigger_mode

Trigger mode string. Read-only

width

Width of the camera image in pixels