From 0ebc507eff20ac05f5fd61bf768b0b5cf451ffd7 Mon Sep 17 00:00:00 2001
From: Julian Stirling
Date: Wed, 22 Oct 2025 22:45:19 +0100
Subject: [PATCH] Add camera calibration steps into refactored calibration
wizard.
---
.../things/camera/simulation.py | 30 ++++++++++++++
.../modalComponents/calibrationWizard.vue | 7 +++-
.../calibrationWizardContents.vue | 24 +----------
.../calibrationWizardTask.vue | 9 ++--
.../camCalibrationExplanation.vue | 20 +++++++++
.../cameraMainCalibrationStep.vue | 34 +++++++++++++++
.../cameraCalibrationTask.vue | 41 +++++++++++++++++++
.../calibrationWizardComponents/finalStep.vue | 17 ++++++++
.../singleStepTask.vue | 9 ++--
.../stepTemplateWithStream.vue | 27 ++++++++++++
10 files changed, 186 insertions(+), 32 deletions(-)
create mode 100644 webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationSteps/camCalibrationExplanation.vue
create mode 100644 webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationSteps/cameraMainCalibrationStep.vue
create mode 100644 webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationTask.vue
create mode 100644 webapp/src/components/modalComponents/calibrationWizardComponents/finalStep.vue
create mode 100644 webapp/src/components/modalComponents/calibrationWizardComponents/stepTemplateWithStream.vue
diff --git a/src/openflexure_microscope_server/things/camera/simulation.py b/src/openflexure_microscope_server/things/camera/simulation.py
index 7c32aa08..b93b9c78 100644
--- a/src/openflexure_microscope_server/things/camera/simulation.py
+++ b/src/openflexure_microscope_server/things/camera/simulation.py
@@ -86,6 +86,11 @@ class SimulatedCamera(BaseCamera):
self.generate_blobs()
self.generate_canvas()
+ @lt.thing_property
+ def calibration_required(self) -> bool:
+ """Whether the camera needs calibrating."""
+ return not self.background_detector_status.ready
+
def validate_inputs(self) -> None:
"""Validate the inputs passed to the simulation, and raises an error if invalid.
@@ -367,6 +372,22 @@ class SimulatedCamera(BaseCamera):
LOGGER.warning(f"Simulation camera camera doesn't respect {stream_name=}")
return Image.fromarray(self.generate_frame())
+ @lt.thing_action
+ def full_auto_calibrate(self, portal: lt.deps.BlockingPortal) -> None:
+ """Perform a full auto-calibration.
+
+ For the simulation microscope the process is:
+
+ * ``remove_sample``
+ * ``set_background``
+ * ``load_sample``
+ """
+ self.remove_sample()
+ time.sleep(0.2)
+ self.set_background(portal)
+ time.sleep(0.2)
+ self.load_sample()
+
@lt.thing_action
def remove_sample(self) -> None:
"""Show the simulated background with no sample."""
@@ -381,6 +402,15 @@ class SimulatedCamera(BaseCamera):
raise RuntimeError("Sample is already in place.")
self._show_sample = True
+ @lt.thing_property
+ def primary_calibration_actions(self) -> list[ActionButton]:
+ """The calibration actions for both calibration wizard and settings panel."""
+ return [
+ action_button_for(
+ self.full_auto_calibrate, submit_label="Full Auto Calibrate"
+ ),
+ ]
+
@lt.thing_property
def secondary_calibration_actions(self) -> list[ActionButton]:
"""The calibration actions that appear only in settings panel."""
diff --git a/webapp/src/components/modalComponents/calibrationWizard.vue b/webapp/src/components/modalComponents/calibrationWizard.vue
index 92f121f8..446e3b03 100644
--- a/webapp/src/components/modalComponents/calibrationWizard.vue
+++ b/webapp/src/components/modalComponents/calibrationWizard.vue
@@ -22,6 +22,8 @@
diff --git a/webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationSteps/cameraMainCalibrationStep.vue b/webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationSteps/cameraMainCalibrationStep.vue
new file mode 100644
index 00000000..7089adeb
--- /dev/null
+++ b/webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationSteps/cameraMainCalibrationStep.vue
@@ -0,0 +1,34 @@
+
+
+
+
+
Once you're ready, click auto-calibrate.
+
+
+
+
+
+
+
+
diff --git a/webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationTask.vue b/webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationTask.vue
new file mode 100644
index 00000000..be5d4e83
--- /dev/null
+++ b/webapp/src/components/modalComponents/calibrationWizardComponents/cameraCalibrationTask.vue
@@ -0,0 +1,41 @@
+
+
+
+
+
diff --git a/webapp/src/components/modalComponents/calibrationWizardComponents/finalStep.vue b/webapp/src/components/modalComponents/calibrationWizardComponents/finalStep.vue
new file mode 100644
index 00000000..edf59bc4
--- /dev/null
+++ b/webapp/src/components/modalComponents/calibrationWizardComponents/finalStep.vue
@@ -0,0 +1,17 @@
+
+
+
+ Calibration complete
+
+
+ Click Finish to return to your microscope.
+
+
+
+
+
diff --git a/webapp/src/components/modalComponents/calibrationWizardComponents/singleStepTask.vue b/webapp/src/components/modalComponents/calibrationWizardComponents/singleStepTask.vue
index 908772c7..c7da2345 100644
--- a/webapp/src/components/modalComponents/calibrationWizardComponents/singleStepTask.vue
+++ b/webapp/src/components/modalComponents/calibrationWizardComponents/singleStepTask.vue
@@ -1,5 +1,6 @@
({})
},
// Standard calibrationWizardTask props below:
+ title: {
+ type: String,
+ default: null
+ },
first: Boolean,
final: Boolean,
startOnLast: {
@@ -39,9 +44,5 @@ export default {
]
};
},
-
- mounted(){
- console.log(this.stepComponent);
- }
}
diff --git a/webapp/src/components/modalComponents/calibrationWizardComponents/stepTemplateWithStream.vue b/webapp/src/components/modalComponents/calibrationWizardComponents/stepTemplateWithStream.vue
new file mode 100644
index 00000000..ce56967b
--- /dev/null
+++ b/webapp/src/components/modalComponents/calibrationWizardComponents/stepTemplateWithStream.vue
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+