Skip to content

Commit 9f6d8ca

Browse files
authored
Fix calibration resolution default bug (#2156)
1 parent 3cbac81 commit 9f6d8ca

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

photon-client/src/components/cameras/CameraCalibrationCard.vue

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { computed, ref } from "vue";
2+
import { computed, ref, watchEffect } from "vue";
33
import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore";
44
import { CalibrationBoardTypes, CalibrationTagFamilies, type VideoFormat } from "@/types/SettingTypes";
55
import MonoLogo from "@/assets/images/logoMono.png";
@@ -79,6 +79,18 @@ const calibrationDivisors = computed(() =>
7979
})
8080
);
8181
82+
const uniqueVideoResolutionString = ref("");
83+
84+
// Use a watchEffect so the value is populated/reacts when the stores become available or update.
85+
// This avoids trying to index into an array that may be empty during page reload.
86+
watchEffect(() => {
87+
const currentIndex = useCameraSettingsStore().currentVideoFormat.index ?? 0;
88+
useStateStore().calibrationData.videoFormatIndex = currentIndex;
89+
const names = useCameraSettingsStore().currentCameraSettings.validVideoFormats.map((f) =>
90+
getResolutionString(f.resolution)
91+
);
92+
uniqueVideoResolutionString.value = names[currentIndex] ?? names[0] ?? "";
93+
});
8294
const squareSizeIn = ref(1);
8395
const markerSizeIn = ref(0.75);
8496
const patternWidth = ref(8);
@@ -279,13 +291,16 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
279291
: 'MrCal failed to load, check journalctl logs for details.'
280292
"
281293
/>
282-
<!-- TODO: the default videoFormatIndex is 0, but the list of unique video mode indexes might not include 0. getUniqueVideoResolutionStrings indexing is also different from the normal video mode indexing -->
283294
<pv-select
284-
v-model="useStateStore().calibrationData.videoFormatIndex"
295+
v-model="uniqueVideoResolutionString"
285296
label="Resolution"
286297
:select-cols="8"
287298
:disabled="isCalibrating"
288299
tooltip="Resolution to calibrate at (you will have to calibrate every resolution you use 3D mode on)"
300+
@update:model-value="
301+
useStateStore().calibrationData.videoFormatIndex =
302+
getUniqueVideoResolutionStrings().find((v) => v.value === $event)?.value || 0
303+
"
289304
:items="getUniqueVideoResolutionStrings()"
290305
/>
291306
<pv-select
@@ -527,9 +542,9 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
527542
<v-card-text>
528543
Camera has been successfully calibrated for
529544
{{
530-
getUniqueVideoResolutionStrings().find(
531-
(v) => v.value === useStateStore().calibrationData.videoFormatIndex
532-
)?.name
545+
useCameraSettingsStore().currentCameraSettings.validVideoFormats.map((f) =>
546+
getResolutionString(f.resolution)
547+
)[useStateStore().calibrationData.videoFormatIndex]
533548
}}!
534549
</v-card-text>
535550
</template>

0 commit comments

Comments
 (0)