diff --git a/src/crappy/tool/camera_config/camera_config.py b/src/crappy/tool/camera_config/camera_config.py index 8fe53601..25792f5b 100644 --- a/src/crappy/tool/camera_config/camera_config.py +++ b/src/crappy/tool/camera_config/camera_config.py @@ -112,6 +112,7 @@ def __init__(self, self._run = True self._n_loops = 0 self._max_freq = max_freq + self._got_first_img: bool = False # Settings for adjusting the behavior of the zoom self._zoom_ratio = 0.9 @@ -1025,13 +1026,12 @@ def _update_img(self) -> None: ret = self._camera.get_image() # Flag raised if no image could be grabbed - no_img = False + no_img = ret is None # If no frame could be grabbed from the camera - if ret is None: - no_img = True + if no_img: # If it's the first call, generate error image to initialize the window - if not self._n_loops: + if not self._got_first_img: self.log(logging.WARNING, "Could not get an image from the camera, " "displaying an error image instead") ret = None, np.array(Image.open(BytesIO(resource_string( @@ -1043,6 +1043,8 @@ def _update_img(self) -> None: sleep(0.001) return + # Always set, so that the error image is only ever loaded once + self._got_first_img = True self._n_loops += 1 _, img = ret