From 0e834f0851584237b0dd0913381b52fe6110dd08 Mon Sep 17 00:00:00 2001 From: David Vo Date: Mon, 11 May 2026 12:47:29 +1000 Subject: [PATCH] Allow calibration dimensions in mm (#2479) --- .../cameras/CameraCalibrationCard.vue | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/photon-client/src/components/cameras/CameraCalibrationCard.vue b/photon-client/src/components/cameras/CameraCalibrationCard.vue index b0b185efc..f22e50481 100644 --- a/photon-client/src/components/cameras/CameraCalibrationCard.vue +++ b/photon-client/src/components/cameras/CameraCalibrationCard.vue @@ -20,6 +20,7 @@ const PromptRegular = import("@/assets/fonts/PromptRegular"); const jspdf = import("jspdf"); const theme = useTheme(); +const MM_PER_INCH = 25.4; const settingsValid = ref(true); @@ -108,6 +109,7 @@ watchEffect(() => { useStateStore().calibrationData.videoFormatIndex = currentIndex; uniqueVideoResolutionIndex.value = currentIndex; }); +const dimensionUnit = ref<"in" | "mm">("in"); const squareSizeIn = ref(1); const markerSizeIn = ref(0.75); const patternWidth = ref(8); @@ -117,6 +119,28 @@ const useOldPattern = ref(false); const tagFamily = ref(CalibrationTagFamilies.Dict_4X4_1000); const requestedVideoFormatIndex = ref(0); +const convertInchesToDisplay = (valueInInches: number) => + dimensionUnit.value === "mm" ? valueInInches * MM_PER_INCH : valueInInches; + +const convertDisplayToInches = (displayValue: number) => + dimensionUnit.value === "mm" ? displayValue / MM_PER_INCH : displayValue; + +const squareSize = computed({ + get: () => convertInchesToDisplay(squareSizeIn.value), + set(value) { + squareSizeIn.value = convertDisplayToInches(value); + } +}); + +const markerSize = computed({ + get: () => convertInchesToDisplay(markerSizeIn.value), + set(value) { + markerSizeIn.value = convertDisplayToInches(value); + } +}); + +const dimensionStep = computed(() => (dimensionUnit.value === "mm" ? 0.1 : 0.01)); + // Emperical testing - with stack size limit of 1MB, we can handle at -least- 700k points const tooManyPoints = computed( () => useStateStore().calibrationData.imageCount * patternWidth.value * patternHeight.value > 700000 @@ -364,22 +388,35 @@ const setSelectedVideoFormat = (format: VideoFormat) => { ]" :disabled="isCalibrating" /> +