diff --git a/src/openflexure_microscope_server/things/autofocus.py b/src/openflexure_microscope_server/things/autofocus.py index edb208e3..89bbc8a8 100644 --- a/src/openflexure_microscope_server/things/autofocus.py +++ b/src/openflexure_microscope_server/things/autofocus.py @@ -36,8 +36,8 @@ from .capture import CaptureThing CaptureDep = direct_thing_client_dependency(CaptureThing, "/capture/") -SETTLING_TIME = 0.3 STACK_OVERSHOOT = 200 +SETTLING_TIME = 0.3 class JPEGSharpnessMonitor: @@ -322,7 +322,8 @@ class AutofocusThing(Thing): if capture_count + 1 < images_to_capture: stage.move_relative(z=stack_dz) moved = time.time() - image = image.resize(target_resolution, Image.BOX) + if image.size != target_resolution: + image = image.resize(target_resolution, Image.BOX) downsampled = time.time() capture._save_capture( jpeg_path=jpeg_path, @@ -331,6 +332,11 @@ class AutofocusThing(Thing): logger=logger, ) saved = time.time() + if saved - start < SETTLING_TIME: + time.sleep(SETTLING_TIME - (saved - start)) + logger.info( + f"Settled for an extra {round(SETTLING_TIME - (saved - start), 3)} seconds" + ) logger.debug(f"Capturing took {round(captured - start, 2)} s") logger.debug(f"Resizing took {round(downsampled - moved, 2)} s") logger.debug(f"Saving took {round(saved - downsampled, 2)} s") diff --git a/src/openflexure_microscope_server/things/camera/__init__.py b/src/openflexure_microscope_server/things/camera/__init__.py index 12424116..24219f09 100644 --- a/src/openflexure_microscope_server/things/camera/__init__.py +++ b/src/openflexure_microscope_server/things/camera/__init__.py @@ -84,7 +84,6 @@ class CameraProtocol(Protocol): for the main stream""" ... - @thing_action def capture_image(self, stream_name, wait): """Capture a PIL image from stream stream_name with timeout wait""" ...