pylablib.devices.uc480 package¶
Submodules¶
pylablib.devices.uc480.uc480 module¶
-
class
pylablib.devices.uc480.uc480.
TCameraInfo
(cam_id, dev_id, sens_id, model, serial_number, in_use, status)¶ Bases:
tuple
-
cam_id
¶
-
count
()¶ Return number of occurrences of value.
-
dev_id
¶
-
in_use
¶
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
model
¶
-
sens_id
¶
-
serial_number
¶
-
status
¶
-
-
pylablib.devices.uc480.uc480.
list_cameras
(backend='uc480')[source]¶ List all uc480/ueye camera connections (interface kind and camera index).
backend is the camera DLL backend; can be either
"uc480"
for Thorlabs-associated cameras, or"ueye"
for IDS uEye-associated cameras
-
pylablib.devices.uc480.uc480.
get_cameras_number
(backend='uc480')[source]¶ Get the total number of connected uc480/ueye cameras.
backend is the camera DLL backend; can be either
"uc480"
for Thorlabs-associated cameras, or"ueye"
for IDS uEye-associated cameras
-
pylablib.devices.uc480.uc480.
find_by_serial
(serial_number, backend='uc480')[source]¶ Find device ID using its serial number.
backend is the camera DLL backend; can be either
"uc480"
for Thorlabs-associated cameras, or"ueye"
for IDS uEye-associated cameras
-
class
pylablib.devices.uc480.uc480.
TDeviceInfo
(cam_id, model, manufacturer, serial_number, usb_version, date, dll_version, camera_type)¶ Bases:
tuple
-
cam_id
¶
-
camera_type
¶
-
count
()¶ Return number of occurrences of value.
-
date
¶
-
dll_version
¶
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
manufacturer
¶
-
model
¶
-
serial_number
¶
-
usb_version
¶
-
-
class
pylablib.devices.uc480.uc480.
TAcquiredFramesStatus
(acquired, transfer_missed, frameskip_events)¶ Bases:
tuple
-
acquired
¶
-
count
()¶ Return number of occurrences of value.
-
frameskip_events
¶
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
transfer_missed
¶
-
-
class
pylablib.devices.uc480.uc480.
TTimestamp
(year, month, day, hour, minute, second, millisecond)¶ Bases:
tuple
-
count
()¶ Return number of occurrences of value.
-
day
¶
-
hour
¶
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
millisecond
¶
-
minute
¶
-
month
¶
-
second
¶
-
year
¶
-
-
class
pylablib.devices.uc480.uc480.
TFrameInfo
(frame_index, framestamp, timestamp, timestamp_dev, size, io_status, flags)¶ Bases:
tuple
-
count
()¶ Return number of occurrences of value.
-
flags
¶
-
frame_index
¶
-
framestamp
¶
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
io_status
¶
-
size
¶
-
timestamp
¶
-
timestamp_dev
¶
-
-
class
pylablib.devices.uc480.uc480.
UC480Camera
(cam_id=0, roi_binning_mode='auto', dev_id=None, backend='uc480')[source]¶ Bases:
pylablib.devices.interface.camera.IBinROICamera
,pylablib.devices.interface.camera.IExposureCamera
Thorlabs uc480 / IDS uEye camera.
Parameters: - cam_id (int) – camera ID; use 0 to get the first available camera
- roi_binning_mode – determines whether binning in ROI refers to binning or subsampling;
can be
"bin"
,"subsample"
, or"auto"
(since most cameras only support one, it will pick the one which has non-trivial value, or"bin"
if both are available). - dev_id (int) – if
None
use cam_id as a camera id (cam_id
field of the camera info returned bylist_cameras()
); otherwise, ignore value of cam_id and use dev_id as device id (dev_id
field of the camera info). The first method requires assigning camera IDs beforehand (otherwise IDs might overlap, in which case only one camera can be accessed), but the assigned IDs are permanent; the second method always has unique IDs, but they might change if the cameras are disconnected and reconnected. For a more reliable assignment, one can usefind_by_serial()
function to find device ID based on the camera serial number. - backend – camera DLL backend; can be either
"uc480"
for Thorlabs-associated cameras, or"ueye"
for IDS uEye-associated cameras
-
Error
= <Mock name='mock.uc480Error' id='140259574245840'>¶
-
TimeoutError
= <Mock spec='str' id='140259550092368'>¶
-
FrameTransferError
= <Mock spec='str' id='140259550090832'>¶
-
get_device_info
()[source]¶ Get camera model data.
Return tuple
(model, manufacturer, serial_number, usb_version, date, dll_version, camera_type)
.
-
set_camera_id
(cam_id)[source]¶ Set the new camera id (stored in non-volatile memory, i.e., survives power cycling)
-
set_frame_period
(frame_time)[source]¶ Set frame period (time between two consecutive frames in the internal trigger mode)
-
get_pixel_rates_range
()[source]¶ Get range of allowed pixel rates (in Hz).
Return tuple
(min, max, step)
if minimal and maximal value, and a step.
-
set_pixel_rate
(rate=None)[source]¶ Set camera pixel rate (in Hz)
The rate is always rounded to the closest available. If rate is
None
, set the maximal possible rate.
-
get_color_mode
()[source]¶ Get current color mode.
For possible modes, see
get_all_color_modes()
.
-
set_color_mode
(mode)[source]¶ Set current color mode.
For possible modes, see
get_all_color_modes()
.
-
get_gains
()[source]¶ Get current gains.
Return tuple
(master, red, green, blue)
of corresponding gain factors.
-
get_max_gains
()[source]¶ Get maximal gains.
Return tuple
(master, red, green, blue)
of corresponding maximal gain factors.
-
set_gains
(master=None, red=None, green=None, blue=None)[source]¶ Set current gains.
If supplied value is
None
, keep it unchanged.
-
setup_acquisition
(nframes=100)[source]¶ Setup acquisition.
nframes determines number of size of the ring buffer (by default, 100).
-
start_acquisition
(*args, **kwargs)[source]¶ Start acquisition.
Can take the same keyword parameters as :meth:``setup_acquisition. If the acquisition is not set up yet, set it up using the supplied parameters (use default of
setup_acquisition()
,if the parameter isNone
). Otherwise, if any supplied parameters are different from the current ones, change them and reset the acquisition.
-
get_frames_status
()[source]¶ Get acquisition and buffer status.
Return tuple
(acquired, unread, skipped, size)
, whereacquired
is the total number of acquired frames,unread
is the number of acquired but not read frames,skipped
is the number of skipped (not read and then written over) frames, andbuffer_size
is the total buffer size (in frames).
-
set_frameskip_behavior
(behavior)[source]¶ Choose the camera behavior if frame skip event is encountered when waiting for a new frame, reading frames, getting buffer status, etc.
Can be
"error"
(raiseuc480FrameTransferError
),"ignore"
(continue acquisition, ignore the gap), or"skip"
(mark some number of frames as skipped, but keep the frame counters consistent).
-
get_supported_subsampling_modes
()[source]¶ Get all supported subsampling modes.
Return tuple
(horizontal, vertical)
of lists with all possible supported subsampling factors.
-
set_subsampling
(hsub=1, vsub=1)[source]¶ Set subsampling.
If values are not supported, get the closest value below the requested. Automatically turns off binning.
-
get_supported_binning_modes
()[source]¶ Get all supported binning modes.
Return tuple
(horizontal, vertical)
of lists with all possible supported binning factors.
-
set_binning
(hbin=1, vbin=1)[source]¶ Set binning.
If values are not supported, get the closest value below the requested. Automatically turns off subsampling.
-
set_roi
(hstart=0, hend=None, vstart=0, vend=None, hbin=1, vbin=1)[source]¶ Setup camera ROI.
hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start are inclusive, stop are exclusive, starting from 0), hbin and vbin specify binning. By default, all non-supplied parameters take extreme values.
-
get_roi_limits
(hbin=1, vbin=1)[source]¶ Get the minimal and maximal ROI parameters.
Return tuple
(hlim, vlim)
, where each element is in turn a limit 5-tuple(min, max, pstep, sstep, maxbin)
with, correspondingly, minimal and maximal size, position and size step, and the maximal binning. In some cameras, the step and the minimal size depend on the binning, which can be supplied.
-
class
NoParameterCaller
(device, kind)¶ Bases:
object
Class to simplify calling functions without a parameter
-
apply_settings
(settings)¶ Apply the settings.
settings is the dict
{name: value}
of the device available settings. Non-applicable settings are ignored.
-
get_acquisition_parameters
()¶ Get acquisition parameters.
Return dictionary
{name: value}
-
get_data_dimensions
()¶ Get readout data dimensions (in pixels) as a tuple
(width, height)
; take indexing mode into account
-
get_device_variable
(key)¶ Get the value of a settings, status, or full info parameter
-
get_exposure
()¶ Get current exposure
-
get_frame_format
()¶ Get format for the returned images.
Can be
"list"
(list of 2D arrays),"array"
(a single 3D array), or"chunks"
(list of 3D “chunk” arrays; supported for some cameras and provides the best performance).
-
get_frame_info_fields
()¶ Get the names of frame info fields.
Applicable when frame info format (set by
set_frame_info_format()
) is"list"
or"array"
.
-
get_frame_info_format
()¶ Get format of the frame info.
Can be
"namedtuple"
(potentially nested named tuples; convenient to get particular values),"list"
(flat list of values, with field names are given byget_frame_info_fields()
; convenient for building a table),"array"
(same as"list"
, but with a numpy array, which is easier to use for"chunks"
frame format), or"dict"
(flat dictionary with the same fields as the"list"
format; more resilient to future format changes)
-
get_frame_info_period
()¶ Get period of frame info acquisition.
Frame info might be skipped (set to
None
) except for frames which indices are divisible by period. Useful for certain cameras where acquiring frame info takes a lot of time and can reduce performance at higher frame rates. Note that this parameter can still be ignored (i.e., always set to 1) if the performance is not an issue for a given camera class.
-
get_frame_period
()¶ Get frame period (time between two consecutive frames in the internal trigger mode)
-
get_full_info
(include=0)¶ Get dict
{name: value}
containing full device information (including status and settings).include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or
"all"
(all available variables). Since the lowest priority is -10, settinginclude=-10
queries all available variables, which is equivalent toinclude="all"
.
-
get_full_status
(include=0)¶ Get dict
{name: value}
containing the device status (including settings).include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or
"all"
(all available variables). Since the lowest priority is -10, settinginclude=-10
queries all available variables, which is equivalent toinclude="all"
.
-
get_image_indexing
()¶ Get indexing for the returned images.
Can be
"rct"
(first index row, second index column, rows counted from the top),"rcb"
(same as"rc"
, rows counted from the bottom),"xyt"
(first index column, second index row, rows counted from the top), or"xyb"
(same as"xyt"
, rows counted from the bottom)
-
get_new_images_range
()¶ Get the range of the new images.
Return tuple
(first, last)
with images range (first inclusive). If no images are available, returnNone
. If some images were in the buffer were overwritten, exclude them from the range.
-
get_settings
(include=0)¶ Get dict
{name: value}
containing all the device settings.include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or
"all"
(all available variables). Since the lowest priority is -10, settinginclude=-10
queries all available variables, which is equivalent toinclude="all"
.
-
grab
(nframes=1, frame_timeout=5.0, missing_frame='skip', return_info=False, buff_size=None)¶ Snap nframes images (with preset image read mode parameters)
buff_size determines buffer size (if
None
, use the default size). Timeout is specified for a single-frame acquisition, not for the whole acquisition time. missing_frame determines what to do with frames which have been lost: can be"none"
(replacing them withNone
),"zero"
(replacing them with zero-filled frame), or"skip"
(skipping them, while still keeping total returned frames number to n). Ifreturn_info==True
, return tuple(frames, infos)
, whereinfos
is a list of frame info tuples (camera-dependent); if some frames are missing andmissing_frame!="skip"
, the corresponding frame info isNone
.
-
is_acquisition_setup
()¶ Check if acquisition is set up.
If the camera does not support separate acquisition setup, always return
True
.
-
pausing_acquisition
(clear=None, stop=True, setup_after=None, start_after=True, combine_nested=True)¶ Context manager which temporarily pauses acquisition during execution of
with
block.Useful for applying certain settings which can’t be changed during the acquisition. If
clear==True
, clear acquisition in addition to stopping (by default, use the class default specified as_clear_pausing_acquisition
attribute). Ifstop==True
, stop the acquisition (ifclear==True
, stop regardless). Ifsetup_after==True
, setup the acquisition after pause if necessary (None
means setup only if clearing was required). Ifstart_after==True
, start the acquisition after pause if necessary (None
means start only if stopping was required). Ifcombine_nested==True
, then any nestedpausing_acquisition
calls will stop/clear acquisition as necessary, but won’t setup/start it again until thispausing_acquisition
call is complete.Yields tuple
(acq_in_progress, acq_params)
, which indicates whether acquisition is currently in progress, and what are the current acquisition parameters.
-
read_newest_image
(peek=False, return_info=False)¶ Read the newest un-read image.
If no un-read frames are available, return
None
. Ifpeek==True
, return the image but not mark it as read. Ifreturn_info==True
, return tuple(frame, info)
, whereinfo
is an info tuples (camera-dependent, seeread_multiple_images()
).
-
read_oldest_image
(peek=False, return_info=False)¶ Read the oldest un-read image.
If no un-read frames are available, return
None
. Ifpeek==True
, return the image but not mark it as read. Ifreturn_info==True
, return tuple(frame, info)
, whereinfo
is an info tuples (camera-dependent, seeread_multiple_images()
).
-
set_device_variable
(key, value)¶ Set the value of a settings parameter
-
set_frame_format
(fmt)¶ Set format for the returned images.
Can be
"list"
(list of 2D arrays),"array"
(a single 3D array),"chunks"
(list of 3D “chunk” arrays; supported for some cameras and provides the best performance), or"try_chunks"
(same as"chunks"
, but if chunks are not supported, set to"list"
instead). If format is"chunks"
and chunks are not supported by the camera, it results in one frame per chunk. Note that if the format is set to"array"
or"chunks"
, the frame info format is also automatically set to"array"
. If the format is set to"chunks"
, then the image info is also returned in chunks form (list of 2D info arrays with the same length as the corresponding frame chunks).
-
set_frame_info_format
(fmt, include_fields=None)¶ Set format of the frame info.
Can be
"namedtuple"
(potentially nested named tuples; convenient to get particular values),"list"
(flat list of values, with field names are given byget_frame_info_fields()
; convenient for building a table),"array"
(same as"list"
, but with a numpy array, which is easier to use for"chunks"
frame format), or"dict"
(flat dictionary with the same fields as the"list"
format; more resilient to future format changes) If include_fields is notNone
, it specifies the fields included for non-"tuple"
formats; note that order or include_fields is ignored, and the resulting fields are always ordered same as in the original.
-
set_frame_info_period
(period=1)¶ Set period of frame info acquisition.
Frame info might be skipped (set to
None
) except for frames which indices are divisible by period. Useful for certain cameras where acquiring frame info takes a lot of time and can reduce performance at higher frame rates. Note that this parameter can still be ignored (i.e., always set to 1) if the performance is not an issue for a given camera class.
-
set_image_indexing
(indexing)¶ Set up indexing for the returned images.
Can be
"rct"
(first index row, second index column, rows counted from the top),"rcb"
(same as"rc"
, rows counted from the bottom),"xyt"
(first index column, second index row, rows counted from the top), or"xyb"
(same as"xyt"
, rows counted from the bottom)
-
snap
(timeout=5.0, return_info=False)¶ Snap a single frame
-
wait_for_frame
(since='lastread', nframes=1, timeout=20.0, error_on_stopped=False)¶ Wait for one or several new camera frames.
since specifies the reference point for waiting to acquire nframes frames; can be “lastread”`` (from the last read frame),
"lastwait"
(wait for the last successfulwait_for_frame()
call),"now"
(from the start of the current call), or"start"
(from the acquisition start, i.e., wait until nframes frames have been acquired). timeout can be either a number,None
(infinite timeout), or a tuple(timeout, frame_timeout)
, in which case the call times out if the total time exceedstimeout
, or a single frame wait exceedsframe_timeout
. If the call times out, raiseTimeoutError
. Iferror_on_stopped==True
and the acquisition is not running, raiseError
; otherwise, simply returnFalse
without waiting.
-
read_multiple_images
(rng=None, peek=False, missing_frame='skip', return_info=False, return_rng=False)[source]¶ Read multiple images specified by rng (by default, all un-read images).
If rng is specified, it is a tuple
(first, last)
with images range (first inclusive). If no new frames are available, return an empty list; if no acquisition is running, returnNone
. Ifpeek==True
, return images but not mark them as read. missing_frame determines what to do with frames which are out of range (missing or lost): can be"none"
(replacing them withNone
),"zero"
(replacing them with zero-filled frame), or"skip"
(skipping them). Ifreturn_info==True
, return tuple(frames, infos)
, whereinfos
is a list ofTFrameInfo
instances describing frame index, framestamp, global timestamp (real time), device timestamp (time from camera restart, in 0.1us steps), frame size, digital input state, and additional flags; if some frames are missing andmissing_frame!="skip"
, the corresponding frame info isNone
. ifreturn_rng==True
, return the range covered resulting frames; ifmissing_frame=="skip"
, the range can be smaller than the supplied rng if some frames are skipped. Note that obtaining frame info might take about 2ms, so at high frame rates it will become a limiting factor.