pylablib.devices.PhotonFocus package
Submodules
pylablib.devices.PhotonFocus.PhotonFocus module
- class pylablib.devices.PhotonFocus.PhotonFocus.LibraryController(lib)[source]
Bases:
LibraryController
- close(opid)[source]
Mark device closing.
Return tuple
(close_result, uninit_result)
with the results of the closing and the shutdown. If library does not need to be shut down yet, setuninit_result=None
- pylablib.devices.PhotonFocus.PhotonFocus.query_camera_name(port)[source]
Query cameras name at a given port in PFCam interface
- class pylablib.devices.PhotonFocus.PhotonFocus.TCameraInfo(manufacturer, port, version, type)
Bases:
tuple
- manufacturer
- port
- type
- version
- pylablib.devices.PhotonFocus.PhotonFocus.list_cameras(only_supported=True)[source]
List all cameras available through PFCam interface.
If
only_supported==True
, only return cameras which support PFCam protocol (this check only works if the camera is not currently accessed by some other software). Return a list[(port, info)]
, whereport
is the pfcam port given toIPhotonFocusCamera
and its subclasses, andinfo
is the information returned byquery_camera_name()
.
- pylablib.devices.PhotonFocus.PhotonFocus.get_cameras_number(only_supported=True)[source]
Get the total number of connected PFCam cameras
- pylablib.devices.PhotonFocus.PhotonFocus.get_port_index(manufacturer, port)[source]
Find PhotonFocus port index based on the manufacturer and port
- class pylablib.devices.PhotonFocus.PhotonFocus.PFCamAttribute(port, name)[source]
Bases:
object
PFCam camera attribute.
Allows to query and set values and get additional information. Usually created automatically by a PhotonFocus camera instance, but could also be created manually.
- Parameters:
sid – camera session ID
name – attribute text name
- name
attribute name
- kind
attribute kind; can be
"INT"
,"UINT"
,"FLOAT"
,"BOOL"
,"MODE"
,"STRING"
, or"COMMAND"
- ivalues
list of possible integer values for enum attributes
- values
list of possible text values for enum attributes
- labels
dict
{label: index}
which shows all possible values of an enumerated attribute and their corresponding numerical values
- ilabels
dict
{index: label}
which shows labels corresponding to numerical values of an enumerated attribute
- get_value(enum_as_str=True)[source]
Get attribute value.
If
enum_as_str==True
, return enum-style values as strings; otherwise, return corresponding integer values.
- class pylablib.devices.PhotonFocus.PhotonFocus.TDeviceInfo(model, serial_number, grabber_info)
Bases:
tuple
- grabber_info
- model
- serial_number
- class pylablib.devices.PhotonFocus.PhotonFocus.IPhotonFocusCamera(pfcam_port=0, **kwargs)[source]
Bases:
IAttributeCamera
Generic PFCam interface to a PhotonFocus camera. Does not handle frames acquisition, so needs to be mixed with a frame grabber class to be fully operational. In this mixing, the class attribute
GrabberClass
should be set to this frame grabber class.- Parameters:
pfcam_port – port number for pfcam interface (can be learned by
list_cameras()
; port number is the first element of the camera data tuple) can also be a tuple(manufacturer, port)
, e.g.,("National Instruments", "port0")
.kwargs – keyword arguments passed to the frame grabber initialization
- Error
alias of
DeviceError
- GrabberClass = None
- get_attribute_value(name, enum_as_str=True, error_on_missing=True, default=None)[source]
Get value of an attribute with the given name.
If the value doesn’t exist or can not be read and
error_on_missing==True
, raise error; otherwise, return default. If default is notNone
, assume thaterror_on_missing==False
. Ifenum_as_str==True
, try to represent enums as their string values; If name points at a dictionary branch, return a dictionary with all values in this branch.
- set_attribute_value(name, value, truncate=True, error_on_missing=True)[source]
Set value of an attribute with the given name.
If the value doesn’t exist or can not be written and
error_on_missing==True
, raise error; otherwise, do nothing. If name points at a dictionary branch, set all values in this branch (in this case value must be a dictionary). Iftruncate==True
, truncate value to lie within attribute range.
- get_all_attribute_values(root='', enum_as_str=True)[source]
Get values of all attributes with the given root
- set_all_attribute_values(settings, root='', truncate=True)[source]
Set values of all attributes with the given root.
If
truncate==True
, truncate value to lie within attribute range.
- update_attribute_value(name, value, error_on_missing=True, truncate=True)[source]
Set value of the attribute with a given name, but only if it’s different from the current value.
Can take less time on some version of PFRemote (where single attribute setting is about 50ms). Arguments are the same as
set_attribute_value()
.
- call_command(name, arg=0, error_on_missing=True)[source]
Execute the given command with the given argument.
If the command doesn’t exist and
error_on_missing==True
, raise error; otherwise, do nothing.
- get_device_info()[source]
Get camera model data.
Return tuple
(model, serial_number, grabber_info)
.
- fast_shift_roi(hstart=0, vstart=0)[source]
Shift ROI by only changing its origin, but keeping the shape the same.
Note that if the ROI is invalid, it won’t be truncated (as is the standard behavior of
set_roi()
), which might lead to errors later.
- set_roi(hstart=0, hend=None, vstart=0, vend=None)[source]
Setup camera ROI.
By default, all non-supplied parameters take extreme values.
- get_frame_period()[source]
Get frame period (time between two consecutive frames in the internal trigger mode)
- set_frame_period(frame_period)[source]
Set frame period (time between two consecutive frames in the internal trigger mode)
- FrameTransferError
alias of
DefaultFrameTransferError
- TimeoutError
alias of
DeviceError
- acquisition_in_progress()
Check if acquisition is in progress
- apply_settings(settings)
Apply the settings.
settings is the dict
{name: value}
of the device available settings. Non-applicable settings are ignored.
- clear_acquisition()
Clear acquisition settings
- get_acquisition_parameters()
Get acquisition parameters.
Return dictionary
{name: value}
- get_all_attributes(copy=False)
Return a dictionary of all available attributes.
If
copy==True
, copy the dictionary; otherwise, return the internal dictionary structure (should not be modified).
- get_attribute(name, error_on_missing=True)
Get the camera attribute with the given name
- 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_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_frames_status()
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).
- 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
.
- is_opened()
Check if the device is connected
- 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_multiple_images(rng=None, peek=False, missing_frame='skip', return_info=False, return_rng=False)
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 of frame info tuples (camera-dependent, by default, only the frame index); 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.
- 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)
- setup_acquisition(**kwargs)
Setup acquisition.
Any non-specified acquisition parameters are assumed to be the same as previously set (or default, if not explicitly set before). Return the new acquisition parameters.
- snap(timeout=5.0, return_info=False)
Snap a single frame
- start_acquisition(*args, **kwargs)
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.
- stop_acquisition()
Stop acquisition
- 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.
- class pylablib.devices.PhotonFocus.PhotonFocus.PhotonFocusIMAQCamera(imaq_name='img0', pfcam_port=0)[source]
Bases:
IPhotonFocusCamera
,IMAQFrameGrabber
IMAQ+PFCam interface to a PhotonFocus camera.
- Parameters:
imaq_name – IMAQ interface name (can be learned by
IMAQ.list_cameras()
; usually, but not always, starts with"img"
)pfcam_port – port number for pfcam interface (can be learned by
list_cameras()
; port number is the first element of the camera data tuple) can also be a tuple(manufacturer, port)
, e.g.,("National Instruments", "port0")
.
- Error
alias of
DeviceError
- GrabberClass
alias of
IMAQFrameGrabber
- FrameTransferError
alias of
DefaultFrameTransferError
- TimeoutError = <Mock spec='str' id='139946410545616'>
- acquisition_in_progress()
Check if acquisition is in progress
- apply_settings(settings)
Apply the settings.
settings is the dict
{name: value}
of the device available settings. Non-applicable settings are ignored.
- call_command(name, arg=0, error_on_missing=True)
Execute the given command with the given argument.
If the command doesn’t exist and
error_on_missing==True
, raise error; otherwise, do nothing.
- clear_acquisition()
Clear all acquisition details and free all buffers
- clear_all_triggers(reset_acquisition=True)
Disable all triggers of the session
If the input triggers configuration has been changed, acquisition needs to be restart; if
reset_acquisition==True
, perform it automatically.
- close()
Close connection to the camera
- configure_trigger_in(trig_type, trig_line=0, trig_pol='high', trig_action='none', timeout=None, reset_acquisition=True)
Configure input trigger.
- Parameters:
trig_type (str) – trigger source type; can be
"ext"
,"rtsi"
,"iso_in"
, or"software"
trig_line (int) – trigger line number
trig_pol (str) – trigger polarity; can be
"high"
or"low"
trig_action (str) – trigger action; can be
"none"
(disable trigger),"capture"
(start capturing),"stop"
(stop capturing),"buffer"
(capture a single frame), or"bufflist"
(capture the whole buffer list once)timeout (float) – timeout in seconds;
None
means not timeout.reset_acquisition (bool) – if the input triggers configuration has been changed, acquisition needs to be restart; if
True
, perform it automatically
- configure_trigger_out(trig_type, trig_line=0, trig_pol='high', trig_drive='disable')
Configure trigger output.
- Parameters:
trig_type (str) – trigger drive destination type; can be
"ext"
,"rtsi"
, or"iso_out"
trig_line (int) – trigger line number
trig_pol (str) – trigger polarity; can be
"high"
or"low"
trig_drive (str) – trigger output signal; can be
"disable"
(disable drive),"acq_in_progress"
(asserted when acquisition is started),"acq_done"
(asserted when acquisition is done),"unasserted"
(force unasserted level),"asserted"
(force asserted level),"hsync"
(asserted on start of a single line start),"vsync"
(asserted on start of a frame scan),"frame_start"
(asserted when a single frame is captured), or"frame_done"
(asserted when a single frame is done)
- enable_CFR(enabled=True)
Enable constant frame rate mode
- enable_status_line(enabled=True)
Enable or disable status line
- fast_shift_roi(hstart=0, vstart=0)
Shift ROI by only changing its origin, but keeping the shape the same.
Note that if the ROI is invalid, it won’t be truncated (as is the standard behavior of
set_roi()
), which might lead to errors later.
- get_acquisition_parameters()
Get acquisition parameters.
Return dictionary
{name: value}
- get_all_attribute_values(root='', enum_as_str=True)
Get values of all attributes with the given root
- get_all_attributes(copy=False)
Return a dictionary of all available attributes.
If
copy==True
, copy the dictionary; otherwise, return the internal dictionary structure (should not be modified).
- get_all_grabber_attribute_values()
Get a dictionary of all readable attributes.
The attributes types are autodetected, and some of the types of uncommon attributes may be misrepresented.
- get_attribute(name, error_on_missing=True)
Get the camera attribute with the given name
- get_attribute_value(name, enum_as_str=True, error_on_missing=True, default=None)
Get value of an attribute with the given name.
If the value doesn’t exist or can not be read and
error_on_missing==True
, raise error; otherwise, return default. If default is notNone
, assume thaterror_on_missing==False
. Ifenum_as_str==True
, try to represent enums as their string values; If name points at a dictionary branch, return a dictionary with all values in this branch.
- get_baudrate()
Get the current baud rate
- get_black_level_offset()
Get the black level offset
- get_data_dimensions()
Get readout data dimensions (in pixels) as a tuple
(width, height)
; take indexing mode into account
- get_detector_size()
Get camera detector size (in pixels) as a tuple
(width, height)
- get_device_info()
Get camera model data.
Return tuple
(model, serial_number, grabber_info)
.
- 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_frame_timings()
Get acquisition timing.
Return tuple
(exposure, frame_period)
.
- get_frames_status()
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).
- 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_grabber_attribute_value(attr, default=None, kind='auto')
Get value of an attribute with a given name or index.
If default is not
None
, return default if the attribute is not supported; otherwise, raise an error. kind is the attribute kind, and it can be"uint32"
,"uint64"
,"double"
, or"auto"
(autodetect based on the stored list of attribute kinds).
- get_grabber_detector_size()
Get camera detector size (in pixels) as a tuple
(width, height)
- get_grabber_roi()
Get current ROI.
Return tuple
(hstart, hend, vstart, vend)
. hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start is inclusive, stop is exclusive, starting from 0).
- get_grabber_roi_limits(hbin=1, vbin=1)
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 (fixed to 1 if not binning is allowed). In some cameras, the step and the minimal size depend on the binning, which can be supplied.
- 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_roi()
Get current ROI.
Return tuple
(hstart, hend, vstart, vend)
.
- get_roi_limits(hbin=1, vbin=1)
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 (fixed to 1 if not binning is allowed). In some cameras, the step and the minimal size depend on the binning, which can be supplied.
- get_serial_params()
Return serial parameters as a tuple
(write_term, datatype)
- 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"
.
- get_trigger_interleave()
Check if the trigger interleave is on
- 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_CFR_enabled()
Check if the constant frame rate mode is enabled
- is_acquisition_setup()
Check if acquisition is set up.
If the camera does not support separate acquisition setup, always return
True
.
- is_opened()
Check if the device is connected
- is_status_line_enabled()
Check if the status line is on
- 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_multiple_images(rng=None, peek=False, missing_frame='skip', return_info=False, return_rng=False)
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 of frame info tuples (camera-dependent, by default, only the frame index); 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.
- 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()
).
- read_trigger(trig_type, trig_line=0, trig_pol='high')
Read current value of a trigger (input or output).
- reset()
Reset connection to the camera
- send_software_trigger()
Send software trigger signal
- serial_flush()
Flush CameraLink serial port
- serial_read(n, timeout=3.0, datatype=None)
Read specified number of bytes from CameraLink serial port.
- Parameters:
n – number of bytes to read
timeout – operation timeout (in seconds)
datatype – return datatype; can be
"bytes"
(return raw bytes), or"str"
(convert into UTF-8 string) ifNone
, use the value set up usingsetup_serial_params()
(by default,"bytes"
)
- serial_readline(timeout=3.0, datatype=None, maxn=1024)
Read bytes from CameraLink serial port until the termination character (defined in camera file) is encountered.
- Parameters:
timeout – operation timeout (in seconds)
datatype – return datatype; can be
"bytes"
(return raw bytes), or"str"
(convert into UTF-8 string) ifNone
, use the value set up usingsetup_serial_params()
(by default,"bytes"
)maxn – maximal number of bytes to read
- serial_write(msg, timeout=3.0, term=None)
Write message into CameraLink serial port.
- Parameters:
timeout – operation timeout (in seconds)
term – additional write terminator character to add to the message; if
None
, use the value set up usingsetup_serial_params()
(by default, no additional terminator)
- set_all_attribute_values(settings, root='', truncate=True)
Set values of all attributes with the given root.
If
truncate==True
, truncate value to lie within attribute range.
- set_attribute_value(name, value, truncate=True, error_on_missing=True)
Set value of an attribute with the given name.
If the value doesn’t exist or can not be written and
error_on_missing==True
, raise error; otherwise, do nothing. If name points at a dictionary branch, set all values in this branch (in this case value must be a dictionary). Iftruncate==True
, truncate value to lie within attribute range.
- set_black_level_offset(offset)
Set the black level offset
- set_device_variable(key, value)
Set the value of a settings parameter
- set_exposure(exposure)
Set current exposure
- 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_frame_period(frame_period)
Set frame period (time between two consecutive frames in the internal trigger mode)
- set_grabber_attribute_value(attr, value, kind='int32')
Set value of an attribute with a given name or index.
kind is the attribute kind, and it can be
"uint32"
,"uint64"
,"double"
, or"auto"
(autodetect based on the stored list of attribute kinds).
- set_grabber_roi(hstart=0, hend=None, vstart=0, vend=None)
Setup camera ROI.
hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start is inclusive, stop is exclusive, starting from 0). By default, all non-supplied parameters take extreme values (0 for start, maximal for end).
- 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)
- set_roi(hstart=0, hend=None, vstart=0, vend=None)
Setup camera ROI.
By default, all non-supplied parameters take extreme values.
- set_trigger_interleave(enabled)
Set the trigger interleave option on or off
- setup_acquisition(mode='sequence', nframes=100)
Setup acquisition mode.
mode can be either
"snap"
(single frame or a fixed number of frames) or"sequence"
(continuous acquisition). (note thatIMAQCamera.acquisition_in_progress()
would still returnTrue
in this case, even though new frames are no longer acquired). nframes sets up number of frame buffers.
- setup_max_baudrate()
Setup the maximal available baudrate
- setup_serial_params(write_term='', datatype='bytes')
Setup default serial communication parameters.
- Parameters:
write_term – default terminator character to be added to the sent messages
datatype – type of the result of read commands; can be
"bytes"
(return raw bytes), or"str"
(convert into UTF-8 string)
- snap(timeout=5.0, return_info=False)
Snap a single frame
- start_acquisition(*args, **kwargs)
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.
- stop_acquisition()
Stop acquisition
- update_attribute_value(name, value, error_on_missing=True, truncate=True)
Set value of the attribute with a given name, but only if it’s different from the current value.
Can take less time on some version of PFRemote (where single attribute setting is about 50ms). Arguments are the same as
set_attribute_value()
.
- 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.
- class pylablib.devices.PhotonFocus.PhotonFocus.PhotonFocusSiSoCamera(siso_board, siso_applet=None, siso_port=0, pfcam_port=0)[source]
Bases:
IPhotonFocusCamera
,SiliconSoftwareFrameGrabber
IMAQ+PFCam interface to a PhotonFocus camera.
- Parameters:
siso_board – Silicon Software board index, starting from 0; available boards can be learned by
fgrab.list_boards()
siso_applet – Silicon Software applet name, which can be learned by
fgrab.list_applets()
; usually, a simple applet like"DualLineGray16"
or"MediumLineGray16
are most appropriate; can be either an applet name, or a direct path to the applet DLLsiso_port – Silicon Software port number, if several ports are supported by the camera and the applet
pfcam_port – port number for pfcam interface (can be learned by
list_cameras()
; port number is the first element of the camera data tuple) can also be a tuple(manufacturer, port)
, e.g.,("National Instruments", "port0")
.
- Error
alias of
DeviceError
- GrabberClass
alias of
SiliconSoftwareFrameGrabber
- class BufferManager(fg, siso_port)
Bases:
object
Frame buffer manager which controls and schedules the buffer and the buffer copying loop
- allocate(nframes, frame_size)
Allocate and schedule buffers with the given number and size
- deallocate()
Deallocate and remove the buffers
- get_frames_data(idx, nframes=1)
Get buffer chunk addresses for the given number of frames starting from the given index
- get_status()
Get acquisition status.
Return tuple
(nread, oldest_valid_buffer, nacq, debug_info)
- start_loop(run_nframes)
Start the copying loop and, optionally, run the acquisition loop with the given number of frames
- stop_loop()
Stop the copying loop
- FrameTransferError
alias of
DefaultFrameTransferError
- TimeoutError = <Mock spec='str' id='139946298244112'>
- acquisition_in_progress()
Check if acquisition is in progress
- apply_settings(settings)
Apply the settings.
settings is the dict
{name: value}
of the device available settings. Non-applicable settings are ignored.
- call_command(name, arg=0, error_on_missing=True)
Execute the given command with the given argument.
If the command doesn’t exist and
error_on_missing==True
, raise error; otherwise, do nothing.
- clear_acquisition()
Clear all acquisition details and free all buffers
- close()
Close connection to the camera
- enable_CFR(enabled=True)
Enable constant frame rate mode
- enable_status_line(enabled=True)
Enable or disable status line
- fast_shift_roi(hstart=0, vstart=0)
Shift ROI by only changing its origin, but keeping the shape the same.
Note that if the ROI is invalid, it won’t be truncated (as is the standard behavior of
set_roi()
), which might lead to errors later.
- get_acquisition_parameters()
Get acquisition parameters.
Return dictionary
{name: value}
- get_all_attribute_values(root='', enum_as_str=True)
Get values of all attributes with the given root
- get_all_attributes(copy=False)
Return a dictionary of all available attributes.
If
copy==True
, copy the dictionary; otherwise, return the internal dictionary structure (should not be modified).
- get_all_grabber_attribute_values(root='', **kwargs)
Get values of all frame grabber attributes with the given root.
Additional arguments are passed to
get_value
methods of individual attributes.
- get_all_grabber_attributes(copy=False)
Return a dictionary of all available frame grabber grabber_attributes.
If
copy==True
, copy the dictionary; otherwise, return the internal dictionary structure (should not be modified).
- get_attribute(name, error_on_missing=True)
Get the camera attribute with the given name
- get_attribute_value(name, enum_as_str=True, error_on_missing=True, default=None)
Get value of an attribute with the given name.
If the value doesn’t exist or can not be read and
error_on_missing==True
, raise error; otherwise, return default. If default is notNone
, assume thaterror_on_missing==False
. Ifenum_as_str==True
, try to represent enums as their string values; If name points at a dictionary branch, return a dictionary with all values in this branch.
- get_available_camlink_pixel_formats()
Get all available CamLink pixel formats and the output pixel formats as a tuple of 2 lists
- get_baudrate()
Get the current baud rate
- get_black_level_offset()
Get the black level offset
- get_camlink_pixel_format()
Get CamLink pixel format and the output pixel format as a tuple
- get_data_dimensions()
Get readout data dimensions (in pixels) as a tuple
(width, height)
; take indexing mode into account
- get_detector_size()
Get camera detector size (in pixels) as a tuple
(width, height)
- get_device_info()
Get camera model data.
Return tuple
(model, serial_number, grabber_info)
.
- 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_frame_timings()
Get acquisition timing.
Return tuple
(exposure, frame_period)
.
- get_frames_status()
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).
- 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_genicam_info_xml()
Get description in Genicam-compatible XML format
- get_grabber_attribute(name, error_on_missing=True)
Get the camera attribute with the given name
- get_grabber_attribute_value(name, error_on_missing=True, default=None, **kwargs)
Get value of a frame grabber attribute with the given name.
If the value doesn’t exist and
error_on_missing==True
, raise error; otherwise, return default. If default is notNone
, automatically assume thaterror_on_missing==False
. If name points at a dictionary branch, return a dictionary with all values in this branch. Additional arguments are passed toget_value
methods of the individual attribute.
- get_grabber_detector_size()
Get camera detector size (in pixels) as a tuple
(width, height)
- get_grabber_roi()
Get current ROI.
Return tuple
(hstart, hend, vstart, vend)
. hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start is inclusive, stop is exclusive, starting from 0).
- get_grabber_roi_limits(hbin=1, vbin=1)
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 (fixed to 1 if not binning is allowed). In some cameras, the step and the minimal size depend on the binning, which can be supplied.
- 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_roi()
Get current ROI.
Return tuple
(hstart, hend, vstart, vend)
.
- get_roi_limits(hbin=1, vbin=1)
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 (fixed to 1 if not binning is allowed). In some cameras, the step and the minimal size depend on the binning, which can be supplied.
- 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"
.
- get_system_info()
Get the dictionary with all system information parameters
- get_trigger_interleave()
Check if the trigger interleave is on
- 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_CFR_enabled()
Check if the constant frame rate mode is enabled
- is_acquisition_setup()
Check if acquisition is set up.
If the camera does not support separate acquisition setup, always return
True
.
- is_opened()
Check if the device is connected
- is_status_line_enabled()
Check if the status line is on
- 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_multiple_images(rng=None, peek=False, missing_frame='skip', return_info=False, return_rng=False)
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 of frame info tuples (camera-dependent, by default, only the frame index); 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.
- 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_all_attribute_values(settings, root='', truncate=True)
Set values of all attributes with the given root.
If
truncate==True
, truncate value to lie within attribute range.
- set_all_grabber_attribute_values(settings, root='', **kwargs)
Set values of all frame grabber attributes with the given root.
Additional arguments are passed to
set_value
methods of individual attributes.
- set_attribute_value(name, value, truncate=True, error_on_missing=True)
Set value of an attribute with the given name.
If the value doesn’t exist or can not be written and
error_on_missing==True
, raise error; otherwise, do nothing. If name points at a dictionary branch, set all values in this branch (in this case value must be a dictionary). Iftruncate==True
, truncate value to lie within attribute range.
- set_black_level_offset(offset)
Set the black level offset
- set_device_variable(key, value)
Set the value of a settings parameter
- set_exposure(exposure)
Set current exposure
- 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_frame_merge(frame_merge=1)
- set_frame_period(frame_period)
Set frame period (time between two consecutive frames in the internal trigger mode)
- set_grabber_attribute_value(name, value, error_on_missing=True, **kwargs)
Set value of a frame grabber attribute with the given name.
If the value doesn’t exist and
error_on_missing==True
, raise error; otherwise, do nothing. If name points at a dictionary branch, set all values in this branch (in this case value must be a dictionary). Additional arguments are passed toset_value
methods of the individual attribute.
- set_grabber_roi(hstart=0, hend=None, vstart=0, vend=None)
Setup camera ROI.
hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start is inclusive, stop is exclusive, starting from 0). By default, all non-supplied parameters take extreme values (0 for start, maximal for end).
- 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)
- set_roi(hstart=0, hend=None, vstart=0, vend=None)
Setup camera ROI.
By default, all non-supplied parameters take extreme values.
- set_trigger_interleave(enabled)
Set the trigger interleave option on or off
- setup_acquisition(mode='sequence', nframes=100)
Setup acquisition mode.
mode can be either
"snap"
(single frame or a fixed number of frames) or"sequence"
(continuous acquisition). (note thatIMAQCamera.acquisition_in_progress()
would still returnTrue
in this case, even though new frames are no longer acquired). nframes sets up number of frame buffers.
- setup_camlink_pixel_format(bits_per_pixel=8, taps=1, output_fmt=None, fmt=None, bit_alignment='right_custom')
Set up CameraLink pixel format.
If fmt is
None
, use supplied bits_per_pixel (8, 10, 12, 14, or 16) and taps (1 or 2) to figure out the format; otherwise, fmt should be a numerical (e.g.,210
) or string (e.g.,"FG_CL_MEDIUM_10_BIT"
) format. output_fmt specifies the result frame format; ifNone
, use grayscale with the given bits_per_pixel if fmt isNone
, or 16 bit grayscale otherwise. bit_alignment can specify the alignment of the resulting data (applicable whenbits_per_pixel
is not divisible by 8); can be"left"
,"right"
,"right_custom"
(explicitly calculate and set the number of bits to shift by whenever possible; this solves some issues on ME5 cards), or an integer specifying the number of bits to shift.
- setup_max_baudrate()
Setup the maximal available baudrate
- snap(timeout=5.0, return_info=False)
Snap a single frame
- start_acquisition(*args, **kwargs)
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.
- stop_acquisition()
Stop acquisition
- update_attribute_value(name, value, error_on_missing=True, truncate=True)
Set value of the attribute with a given name, but only if it’s different from the current value.
Can take less time on some version of PFRemote (where single attribute setting is about 50ms). Arguments are the same as
set_attribute_value()
.
- 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.
- class pylablib.devices.PhotonFocus.PhotonFocus.PhotonFocusBitFlowCamera(bitflow_idx=0, bitflow_camfile=None, pfcam_port=0)[source]
Bases:
IPhotonFocusCamera
,BitFlowFrameGrabber
BitFlow+PFCam interface to a PhotonFocus camera.
- Parameters:
bitflow_idx – board index, starting from 0
bitflow_camfile – if not
None
, a path to a valid camera file used for this frame grabber and camera combination; in this case, a temporary camera file is generated based on the provided one and used to change some otherwise unavailable camera parameters such as ROI and pixel bit depth (they are otherwise fixed to whatever is specified in the default camera file)pfcam_port – port number for pfcam interface (can be learned by
list_cameras()
; port number is the first element of the camera data tuple) can also be a tuple(manufacturer, port)
, e.g.,("National Instruments", "port0")
.
- Error
alias of
DeviceError
- GrabberClass
alias of
BitFlowFrameGrabber
- setup_acquisition(mode='sequence', nframes=100, frame_merge=None)[source]
Setup acquisition.
Any non-specified acquisition parameters are assumed to be the same as previously set (or default, if not explicitly set before). Return the new acquisition parameters.
- class BufferManager(cam)
Bases:
object
Buffer manager: stores, constantly reads and re-schedules buffers, keeps track of acquired frames and buffer overflow events
- get_status()
Get counter status: tuple
(acquired,)
- is_running()
Check if the buffer loop is running
- reset()
Reset counter (on frame acquisition)
- start_loop()
Start buffer scheduling loop
- stop_loop()
Stop buffer scheduling loop
- FrameTransferError
alias of
DefaultFrameTransferError
- TimeoutError
alias of
BitFlowTimeoutError
- acquisition_in_progress()
Check if acquisition is in progress
- apply_settings(settings)
Apply the settings.
settings is the dict
{name: value}
of the device available settings. Non-applicable settings are ignored.
- call_command(name, arg=0, error_on_missing=True)
Execute the given command with the given argument.
If the command doesn’t exist and
error_on_missing==True
, raise error; otherwise, do nothing.
- clear_acquisition()
Clear all acquisition details and free all buffers
- close()
Close connection to the camera
- enable_CFR(enabled=True)
Enable constant frame rate mode
- enable_status_line(enabled=True)
Enable or disable status line
- fast_shift_roi(hstart=0, vstart=0)
Shift ROI by only changing its origin, but keeping the shape the same.
Note that if the ROI is invalid, it won’t be truncated (as is the standard behavior of
set_roi()
), which might lead to errors later.
- get_acquisition_parameters()
Get acquisition parameters.
Return dictionary
{name: value}
- get_all_attribute_values(root='', enum_as_str=True)
Get values of all attributes with the given root
- get_all_attributes(copy=False)
Return a dictionary of all available attributes.
If
copy==True
, copy the dictionary; otherwise, return the internal dictionary structure (should not be modified).
- get_attribute(name, error_on_missing=True)
Get the camera attribute with the given name
- get_attribute_value(name, enum_as_str=True, error_on_missing=True, default=None)
Get value of an attribute with the given name.
If the value doesn’t exist or can not be read and
error_on_missing==True
, raise error; otherwise, return default. If default is notNone
, assume thaterror_on_missing==False
. Ifenum_as_str==True
, try to represent enums as their string values; If name points at a dictionary branch, return a dictionary with all values in this branch.
- get_baudrate()
Get the current baud rate
- get_black_level_offset()
Get the black level offset
- get_data_dimensions()
Get readout data dimensions (in pixels) as a tuple
(width, height)
; take indexing mode into account
- get_detector_size()
Get camera detector size (in pixels) as a tuple
(width, height)
- get_device_info()
Get camera model data.
Return tuple
(model, serial_number, grabber_info)
.
- 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_frame_timings()
Get acquisition timing.
Return tuple
(exposure, frame_period)
.
- get_frames_status()
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).
- 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_grabber_detector_size()
Get camera detector size (in pixels) as a tuple
(width, height)
- get_grabber_roi()
Get current ROI.
Return tuple
(hstart, hend, vstart, vend)
. hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start is inclusive, stop is exclusive, starting from 0).
- get_grabber_roi_limits(hbin=1, vbin=1)
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 (fixed to 1 if not binning is allowed). In some cameras, the step and the minimal size depend on the binning, which can be supplied.
- 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_roi()
Get current ROI.
Return tuple
(hstart, hend, vstart, vend)
.
- get_roi_limits(hbin=1, vbin=1)
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 (fixed to 1 if not binning is allowed). In some cameras, the step and the minimal size depend on the binning, which can be supplied.
- 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"
.
- get_trigger_interleave()
Check if the trigger interleave is on
- 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_CFR_enabled()
Check if the constant frame rate mode is enabled
- is_acquisition_setup()
Check if acquisition is set up.
If the camera does not support separate acquisition setup, always return
True
.
- is_opened()
Check if the device is connected
- is_status_line_enabled()
Check if the status line is on
- 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_multiple_images(rng=None, peek=False, missing_frame='skip', return_info=False, return_rng=False)
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 of frame info tuples (camera-dependent, by default, only the frame index); 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.
- 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_all_attribute_values(settings, root='', truncate=True)
Set values of all attributes with the given root.
If
truncate==True
, truncate value to lie within attribute range.
- set_attribute_value(name, value, truncate=True, error_on_missing=True)
Set value of an attribute with the given name.
If the value doesn’t exist or can not be written and
error_on_missing==True
, raise error; otherwise, do nothing. If name points at a dictionary branch, set all values in this branch (in this case value must be a dictionary). Iftruncate==True
, truncate value to lie within attribute range.
- set_black_level_offset(offset)
Set the black level offset
- set_device_variable(key, value)
Set the value of a settings parameter
- set_exposure(exposure)
Set current exposure
- 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_frame_period(frame_period)
Set frame period (time between two consecutive frames in the internal trigger mode)
- set_grabber_roi(hstart=0, hend=None, vstart=0, vend=None)
Setup camera ROI.
hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start is inclusive, stop is exclusive, starting from 0). By default, all non-supplied parameters take extreme values (0 for start, maximal for end).
- 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)
- set_roi(hstart=0, hend=None, vstart=0, vend=None)
Setup camera ROI.
By default, all non-supplied parameters take extreme values.
- set_trigger_interleave(enabled)
Set the trigger interleave option on or off
- setup_max_baudrate()
Setup the maximal available baudrate
- snap(timeout=5.0, return_info=False)
Snap a single frame
- start_acquisition(*args, **kwargs)
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.
- stop_acquisition()
Stop acquisition
- update_attribute_value(name, value, error_on_missing=True, truncate=True)
Set value of the attribute with a given name, but only if it’s different from the current value.
Can take less time on some version of PFRemote (where single attribute setting is about 50ms). Arguments are the same as
set_attribute_value()
.
- 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.
- pylablib.devices.PhotonFocus.PhotonFocus.check_grabber_association(cam)[source]
Check if PhotonFocus camera has correct association between the frame grabber and the PFRemote interface.
cam should be an opened instance of
PhotonFocusIMAQCamera
orPhotonFocusSiSoCamera
. Note that this function changes camera parameters such as exposure, frame period, ROI, trigger source, and status line.
- pylablib.devices.PhotonFocus.PhotonFocus.get_status_lines(frames, check_transposed=True, drop_magic=True)[source]
Extract status lines (up to first 6 entries) from the given frames.
frames can be 2D array (one frame), 3D array (stack of frames, first index is frame number), or list of 1D or 2D arrays. Automatically check if the status line is present; return
None
if it’s not. Ifcheck_transposed==True
, check for the case where the image is transposed (i.e., line becomes a column). Ifdrop_magic==True
, remove the first status line entry, which is simply a special number marking the status line presence. Return a 1D or 2D numpy array, where the first axis (if present) is the frame number, and the last is the status line entry The entries after the magic are the frame index, timestamp (in us), missed trigger counters (up to 255), average frame value, and the integration time (in pixel clock cycles, which depend on the camera).
- pylablib.devices.PhotonFocus.PhotonFocus.get_status_line_position(frame, check_transposed=True)[source]
Check whether status line is present in the frame, and return its location.
Return tuple
(row, transposed)
, where row is the status line row (can be-1
or-2
) and transposed isTrue
if the line is present in the transposed image. If no status line is found, returnNone
. Ifcheck_transposed==True
, check for the case where the image is transposed (i.e., line becomes a column).
- pylablib.devices.PhotonFocus.PhotonFocus.remove_status_line(frame, sl_pos='calculate', policy='duplicate', copy=True)[source]
Remove status line from the frame.
- Parameters:
frame – a frame to process (2D or 3D numpy array; if 3D, the first axis is the frame number)
sl_pos – status line position (returned by
get_status_line_position()
); if equal to"calculate"
, calculate here; for a 3D array, assumed to be the same for all framespolicy – determines way to deal with the status line; can be
"keep"
(keep as is),"cut"
(cut off the status line row),"zero"
(set it to zero),"median"
(set it to the image median), or"duplicate"
(set it equal to the previous row; default)copy – if
True
, make copy of the original frames; otherwise, attempt to remove the line in-place
- pylablib.devices.PhotonFocus.PhotonFocus.find_skipped_frames(lines, step=1)[source]
Check if there are skipped frames based on status line reading.
step specifies expected index step between neighboring frames.
Return list
[(idx, skipped)]
, where idx is the index after which skipped frames were skipped.