openhsv.hardware package¶
Submodules¶
openhsv.hardware.camera module¶
-
class
openhsv.hardware.camera.
Camera
(verbose=True)¶ Bases:
abc.ABC
An abstract camera class
Parameters: - ABC (object) – abstract class
- verbose (bool, optional) – prints to console, defaults to True
-
openCamera
()¶ opens camera
-
configCam
(*args, **kwargs)¶ configures camera
-
setSettings
(exposure, fps, *args, **kwargs)¶ sets camera settings
Parameters: - exposure (int) – exposure time
- fps (int) – frames per second
-
isIdle
()¶ returns if camera is recording or not (boolean)
-
startGrab
()¶ Starts acquisition on camera
-
stopGrab
()¶ stops acquisition on camera
-
live
()¶ returns live image preview as numpy array
-
updateTriggerPosition
()¶ Updates the trigger position for internal memory view
-
getMemoryFrame
(frame_index, by_trigger)¶ gets memory frame from camera onboard memory
Parameters: frame_index (int) – frame index in memory
-
closeCamera
()¶ closes camera connection
-
class
openhsv.hardware.camera.
DummyCamera
(is_color=True, verbose=True)¶ Bases:
openhsv.hardware.camera.Camera
-
openCamera
()¶ opens camera
-
configCam
()¶ configures camera
-
setSettings
(*args, **kwargs)¶ sets camera settings
Parameters: - exposure (int) – exposure time
- fps (int) – frames per second
-
isIdle
()¶ returns if camera is recording or not (boolean)
-
startGrab
()¶ Starts acquisition on camera
-
stopGrab
()¶ stops acquisition on camera
-
live
()¶ returns live image preview as numpy array
-
getMemoryFrame
(frame_index, by_trigger=True)¶ gets memory frame from camera onboard memory
Parameters: frame_index (int) – frame index in memory
-
closeCamera
()¶ closes camera connection
-
updateTriggerPosition
()¶ Updates the trigger position for internal memory view
-
-
class
openhsv.hardware.camera.
IdtCamera
(verbose=True)¶ Bases:
openhsv.hardware.camera.Camera
The IdtCamera class uses the abstract
Camera
class to interact with the IDT high-speed camera API. In particular it starts and stops recording, fetches frames from the internal camera memory, and sets settings, such as exposure time and framerate.Parameters: verbose (bool, optional) – Additional information is printed to the command window. Maybe important for debugging purposes. Defaults to True. -
openCamera
()¶ Searches for attached cameras and opens the first found one
Returns: success in opening the camera Return type: bool
-
configCam
(px_gain=1, camera_gain=1)¶ Basic camera configuration, such as gain.
Parameters: - px_gain (int, optional) – Pixel gain (selects 8 from 10 bits, lower (0), middle (1) and upper (2) 8 bits), defaults to 1
- camera_gain (int, optional) – Camera gain, defaults to 1
-
setSettings
(exposure, fps, roi=(1024, 1024), rec_mode=1, sync=True)¶ Sets camera settings.
Parameters: - exposure (int) – Exposure time in us (microseconds)
- fps (int) – Camera sampling rate in frames per second
- roi (tuple or None, optional) – if camera image should cropped to ROI (i.e. may run faster). If not desired, set roi=None, otherwise (height, width). Defaults to (1024, 1024)
- rec_mode (XsCamera.XS_REC_MODE, optional) – Recording mode, defaults to XsCamera.XS_REC_MODE.XS_RM_CIRCULAR
- sync (bool, optional) – If recording should be synchronized to trigger, defaults to True
-
getStatus
()¶ Returns camera status. Status indicates if the camera is recording on a circular buffer or the camera is in idle mode or the recording is done.
Returns: business and status Return type: bool, XsCamera.XS_STATUS
-
isIdle
()¶ Determines if camera is not recording via XS_STATUS
-
startGrab
()¶ Starts recording images on camera using previous set settings
-
stopGrab
()¶ Stops data acquisition
Returns: number of recorded frames Return type: int
-
live
()¶ Returns live image using XsMemoryPreview :return:
-
correctForTrigger
(frame_index)¶ Correct frame_index for trigger index, otherwise indexing is not historically
Parameters: frame_index (int) – absolute frame index Returns: frame index relative to trigger Return type: int
-
getMemoryFrame
(frame_index, by_trigger=True)¶ Creates a buffer and retrieves a camera frame by index from the camera’s onboard memory.
Parameters: - frame_index (int) – The frame index
- by_trigger (bool, optional) – If the frame index should be relative to the trigger, defaults to True
Returns: the camera frame in RGB (height, width, 3) or grayscale (height, width, 1)
Return type: numpy.ndarray
-
updateTriggerPosition
()¶ updates internally trigger position
Returns: trigger position Return type: int
-
closeCamera
()¶ Closes camera handle
-