diff --git a/catkit2/services/hamamatsu_camera/hamamatsu_camera.py b/catkit2/services/hamamatsu_camera/hamamatsu_camera.py index a817ce004..92d620101 100644 --- a/catkit2/services/hamamatsu_camera/hamamatsu_camera.py +++ b/catkit2/services/hamamatsu_camera/hamamatsu_camera.py @@ -207,6 +207,12 @@ def acquisition_loop(self): self.log.warning('Timeout while waiting for frame') if self.cam.wait_capevent_frameready(timeout_millisec) is False: raise RuntimeError(f'Dcam.wait_capevent_frameready({timeout_millisec}) fails with error {self.cam.lasterr()}') + + if self.cam.buf_getframedata(-2) is False: + # If there is no second to last frame, it means we just acquired the first frame. + # In this case, drop the current frame since it always contains systematic errors. + break + img = self.cam.buf_getlastframedata() self.images.submit_data(img.astype('float32'))