diff --git a/photon-client/src/components/cameras/CameraCalibrationCard.vue b/photon-client/src/components/cameras/CameraCalibrationCard.vue index b0b185efc0..f22e504811 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" /> +