diff --git a/ofm_config_full.json b/ofm_config_full.json index 7ae0469d..f182a774 100644 --- a/ofm_config_full.json +++ b/ofm_config_full.json @@ -7,12 +7,7 @@ "/camera_stage_mapping/": "openflexure_microscope_server.things.camera_stage_mapping:CameraStageMapper", "/system_control/": "openflexure_microscope_server.things.system_control:SystemControlThing", "/settings/": "openflexure_microscope_server.things.settings_manager:SettingsManager", - "/smart_scan/": { - "class": "openflexure_microscope_server.things.smart_scan:SmartScanThing", - "kwargs": { - "path_to_openflexure_stitch": "application/openflexure-stitching/.venv/bin/openflexure-stitch" - } - }, + "/smart_scan/": "openflexure_microscope_server.things.smart_scan:SmartScanThing", "/background_detect/": "openflexure_microscope_server.things.background_detect:BackgroundDetectThing", "/capture/": "openflexure_microscope_server.things.capture:CaptureThing" }, diff --git a/ofm_config_simulation.json b/ofm_config_simulation.json index 62f427fb..0d06ad87 100644 --- a/ofm_config_simulation.json +++ b/ofm_config_simulation.json @@ -7,12 +7,7 @@ "/camera_stage_mapping/": "openflexure_microscope_server.things.camera_stage_mapping:CameraStageMapper", "/system_control/": "openflexure_microscope_server.things.system_control:SystemControlThing", "/settings/": "openflexure_microscope_server.things.settings_manager:SettingsManager", - "/smart_scan/": { - "class": "openflexure_microscope_server.things.smart_scan:SmartScanThing", - "kwargs": { - "path_to_openflexure_stitch": "application/openflexure-stitching/.venv/bin/openflexure-stitch" - } - }, + "/smart_scan/": "openflexure_microscope_server.things.smart_scan:SmartScanThing", "/background_detect/": "openflexure_microscope_server.things.smart_scan:BackgroundDetectThing", "/api_test/": "openflexure_microscope_server.things.test:APITestThing" }, diff --git a/ofm_config_stub.json b/ofm_config_stub.json index 14aa1d3f..d312795e 100644 --- a/ofm_config_stub.json +++ b/ofm_config_stub.json @@ -7,12 +7,7 @@ "/camera_stage_mapping/": "openflexure_microscope_server.things.camera_stage_mapping:CameraStageMapper", "/system_control/": "openflexure_microscope_server.things.system_control:SystemControlThing", "/settings/": "openflexure_microscope_server.things.settings_manager:SettingsManager", - "/smart_scan/": { - "class": "openflexure_microscope_server.things.smart_scan:SmartScanThing", - "kwargs": { - "path_to_openflexure_stitch": "application/openflexure-stitching/.venv/bin/openflexure-stitch" - } - }, + "/smart_scan/": "openflexure_microscope_server.things.smart_scan:SmartScanThing", "/background_detect/": "openflexure_microscope_server.things.smart_scan:BackgroundDetectThing", "/api_test/": "openflexure_microscope_server.things.test:APITestThing" }, diff --git a/pyproject.toml b/pyproject.toml index 1e4e4c77..fef6c92f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ dependencies = [ "labthings-sangaboard", "camera-stage-mapping ~= 0.1.10", "opencv-python ~= 4.11.0", + "openflexure-stitching[libvips]==0.1.0", "pillow ~= 10.4", "anyio ~= 4.0", "numpy ~= 2.2", diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 92964145..3f11a7e7 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -88,6 +88,7 @@ JPEGBlob = blob_type("image/jpeg") ZipBlob = blob_type("application/zip") IMG_DIR_NAME = "images" SCAN_DATA_FILENAME = "scan_data.json" +STITCHING_CMD = "openflexure-stitch" SCAN_ZERO_PAD_DIGITS = 4 @@ -112,8 +113,7 @@ def _scan_running(method): class SmartScanThing(Thing): - def __init__(self, path_to_openflexure_stitch: str): - self._stitching_script = path_to_openflexure_stitch + def __init__(self): self._preview_stitch_popen = None self._preview_stitch_popen_lock = threading.Lock() self._scan_lock = threading.Lock() @@ -978,7 +978,7 @@ class SmartScanThing(Thing): with self._preview_stitch_popen_lock: self._preview_stitch_popen = Popen( [ - self._stitching_script, + STITCHING_CMD, "--stitching_mode", "only_stage_stitch", "--minimum_overlap", @@ -1092,7 +1092,7 @@ class SmartScanThing(Thing): self.run_subprocess( logger, [ - self._stitching_script, + STITCHING_CMD, "--stitching_mode", "all", f"{tiff_arg}",