From 5c263bdb63fbfb53839c41e6f38e1481aaae2b42 Mon Sep 17 00:00:00 2001 From: appel_c Date: Wed, 6 Aug 2025 11:27:36 +0200 Subject: [PATCH] refactor(ids-camera): improve docs and camera class --- csaxs_bec/devices/ids_cameras/base_integration/camera.py | 8 ++++++-- csaxs_bec/devices/ids_cameras/base_integration/utils.py | 2 -- csaxs_bec/devices/ids_cameras/ids_camera_new.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/csaxs_bec/devices/ids_cameras/base_integration/camera.py b/csaxs_bec/devices/ids_cameras/base_integration/camera.py index a5a7d86..ed12a6d 100644 --- a/csaxs_bec/devices/ids_cameras/base_integration/camera.py +++ b/csaxs_bec/devices/ids_cameras/base_integration/camera.py @@ -29,6 +29,10 @@ class IDSCameraObject: """ def __init__(self, device_id: int, m_n_colormode, bits_per_pixel): + if ueye is None: + raise ImportError( + "The pyueye library is not installed or library files are missing. Please check your Python environment or library paths." + ) self.ueye = ueye self._device_id = device_id self.h_cam = ueye.HIDS(device_id) @@ -53,7 +57,7 @@ class IDSCameraObject: int.from_bytes(self.s_info.nColorMode.value, byteorder="big") == self.ueye.IS_COLORMODE_BAYER ): - print("Bayer color mode detected.") + logger.info("Bayer color mode detected.") # setup the color depth to the current windows setting self.ueye.is_GetColorDepth( self.h_cam, self.n_bits_per_pixel, self.m_n_colormode @@ -80,7 +84,7 @@ class IDSCameraObject: self.m_n_colormode = self.ueye.IS_CM_MONO8 self.n_bits_per_pixel = self.ueye.INT(8) self.bytes_per_pixel = int(self.n_bits_per_pixel / 8) - print("else") + logger.info("Monochrome camera mode detected.") # Can be used to set the size and position of an "area of interest"(AOI) within an image check_error( diff --git a/csaxs_bec/devices/ids_cameras/base_integration/utils.py b/csaxs_bec/devices/ids_cameras/base_integration/utils.py index 0128d52..0799178 100644 --- a/csaxs_bec/devices/ids_cameras/base_integration/utils.py +++ b/csaxs_bec/devices/ids_cameras/base_integration/utils.py @@ -1,7 +1,5 @@ """Utility functions and classes for IDS cameras using the pyueye library.""" -from unittest import mock - from bec_lib.logger import bec_logger logger = bec_logger.logger diff --git a/csaxs_bec/devices/ids_cameras/ids_camera_new.py b/csaxs_bec/devices/ids_cameras/ids_camera_new.py index ecb3f83..9d4b274 100644 --- a/csaxs_bec/devices/ids_cameras/ids_camera_new.py +++ b/csaxs_bec/devices/ids_cameras/ids_camera_new.py @@ -181,7 +181,7 @@ class IDSCamera(PSIDeviceBase): def on_connected(self): """Connect to the camera.""" self.cam.on_connect() - self.live_mode = self._inputs.get("live_mode", None) + self.live_mode = self._inputs.get("live_mode", False) self.set_rect_roi(0, 0, self.cam.cam.width.value, self.cam.cam.height.value) def on_destroy(self):