From 6eefa4f25b4575a5b4dfc0553ba25abb179321e2 Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Thu, 2 Nov 2023 10:05:54 +0000 Subject: [PATCH] Add image resolution to CSM metadata The camera stage mapper should now note the resolution used when it was last calibrated - this is helpful for tiling, because we may need to scale it if the images recorded are a different resolution from the images used for calibration. This addresses https://gitlab.com/openflexure/microscope-extensions/camera-stage-mapping/-/issues/11 --- .../things/camera_stage_mapping.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openflexure_microscope_server/things/camera_stage_mapping.py b/src/openflexure_microscope_server/things/camera_stage_mapping.py index 8aae1d3a..ad44a7c5 100644 --- a/src/openflexure_microscope_server/things/camera_stage_mapping.py +++ b/src/openflexure_microscope_server/things/camera_stage_mapping.py @@ -132,6 +132,7 @@ class CameraStageMapper(Thing): result: dict = calibrate_backlash_1d(tracker, move, direction_array) result["move_history"] = move.history + result["image_resolution"] = hw.grab_image().shape[:2] return result @thing_action @@ -145,11 +146,13 @@ class CameraStageMapper(Thing): # Combine X and Y calibrations to make a 2D calibration cal_xy: dict = denumpify(image_to_stage_displacement_from_1d([cal_x, cal_y])) self.thing_settings.update(cal_xy) + self.thing_settings["image_resolution"] = cal_x["image_resolution"] data: Dict[str, dict] = { "camera_stage_mapping_calibration": cal_xy, "linear_calibration_x": cal_x, "linear_calibration_y": cal_y, + "image_resolution": cal_x["image_resolution"] } self.thing_settings["last_calibration"] = DenumpifyingDict(data).model_dump() @@ -195,4 +198,7 @@ class CameraStageMapper(Thing): "image_to_stage_displacement_matrix": ( self.image_to_stage_displacement_matrix ), + "image_resolution": ( + self.thing_settings.get("image_to_stage_displacement", None) + ) } \ No newline at end of file