From a215f03f935a77168849239077ddbf8c1f109ae7 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Mon, 22 Apr 2024 14:35:11 +0200 Subject: [PATCH] Drop first frame in acquisition loop --- catkit2/services/hamamatsu_camera/hamamatsu_camera.py | 6 ++++++ 1 file changed, 6 insertions(+) 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'))