Thorlabs TSI Cameras¶
This module is for controlling Thorlabs cameras that use the TSI SDK. Note that Thorlabs DCx cameras use a separate SDK.
Installation¶
This module requires the TSI SDK and the NiceLib
package.
Module Reference¶
-
class
instrumental.drivers.cameras.tsi.
TSI_Camera
(cam_num)¶ -
class
TriggerMode
¶ -
auto
= 'NORMAL'¶ Auto-trigger as fast as possible once capture has started
-
hw_bulb
= 'PDX'¶ Trigger a single exposure on an edge of a pulse, and stop the exposure at the end of the pulse
-
hw_edge
= 'TOE'¶ Trigger a single exposure on an edge, using a software-defined exposure time
-
-
TSI_Camera.
__init__
(cam_num)¶
-
TSI_Camera.
close
()¶
-
TSI_Camera.
get_captured_image
(timeout='1s', copy=True, wait_for_all=True, **kwds)¶ 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 sometimesuint16
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.
-
TSI_Camera.
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()
thenget_captured_image()
. Seeget_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
-
TSI_Camera.
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.
-
TSI_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()
andget_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.
-
TSI_Camera.
start_live_video
(**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 withget_captured_image()
.See
grab_image()
for the set of available kwds.
-
TSI_Camera.
stop_live_video
()¶ Stop live video mode
-
TSI_Camera.
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_ready – True if the next frame is ready, False if the timeout was reached. Return type: bool
-
TSI_Camera.
DEFAULT_KWDS
= {'exposure_time': <Mock object>, 'right': None, 'vbin': 1, 'cx': None, 'top': None, 'bot': None, 'n_frames': 1, 'width': None, 'cy': None, 'fix_hotpixels': False, 'rising': True, 'gain': 0, 'hbin': 1, 'height': None, 'trig': 'auto', 'left': None}¶
-
TSI_Camera.
height
¶ Height of the camera image in pixels
-
TSI_Camera.
led_on
¶
-
TSI_Camera.
max_height
¶ Max settable height of the camera image, given current binning/subpixel settings
-
TSI_Camera.
max_width
¶ Max settable width of the camera image, given current binning/subpixel settings
-
TSI_Camera.
model
¶
-
TSI_Camera.
name
¶
-
TSI_Camera.
serial
¶
-
TSI_Camera.
width
¶ Width of the camera image in pixels
-
class
-
class
instrumental.drivers.cameras.tsi.
TSI_DLL_Camera
(ptr)¶ -
ClearError
()¶
-
Close
()¶
-
FreeImage
(image)¶
-
GetAcquisitionStatus
()¶
-
GetCameraName
()¶
-
GetDataTypeSize
(data_type)¶
-
GetErrorCode
()¶
-
GetErrorStr
(code)¶
-
GetExposeCount
()¶
-
GetFrameCount
()¶
-
GetLastErrorStr
()¶
-
GetParameter
(param_id)¶
-
GetPendingImage
()¶
-
Open
()¶
-
ResetCamera
()¶
-
ResetExposure
()¶
-
SetCameraName
(name)¶
-
SetParameter
(param_id, data)¶
-
Start
()¶
-
StartAndWait
(timeout_ms)¶
-
Status
()¶
-
Stop
()¶
-
WaitForImage
(timeout_ms=-1)¶
-
__init__
(ptr)¶
-
-
class
instrumental.drivers.cameras.tsi.
TSI_DLL_SDK
¶ -
Close
()¶
-
GetCamera
(camera_number)¶
-
GetCameraAddressStr
(camera_number, address_select)¶
-
GetCameraInterfaceTypeStr
(camera_number)¶
-
GetCameraName
(camera_number)¶
-
GetCameraSerialNumStr
(camera_number)¶
-
GetNumberOfCameras
()¶
-
Open
()¶
-
__init__
()¶
-
destroy
()¶
-
-
instrumental.drivers.cameras.tsi.
from_enum
(item)¶
-
instrumental.drivers.cameras.tsi.
list_instruments
()¶