Create "Hide calibration corners" switch, default to mrcal on if possible (#1462)

This commit is contained in:
Matt
2024-10-25 10:05:03 -07:00
committed by GitHub
parent aee432127a
commit f906295c39
9 changed files with 67 additions and 38 deletions

View File

@@ -81,15 +81,6 @@ const patternHeight = ref(8);
const boardType = ref<CalibrationBoardTypes>(CalibrationBoardTypes.Charuco); const boardType = ref<CalibrationBoardTypes>(CalibrationBoardTypes.Charuco);
const useOldPattern = ref(false); const useOldPattern = ref(false);
const tagFamily = ref<CalibrationTagFamilies>(CalibrationTagFamilies.Dict_4X4_1000); const tagFamily = ref<CalibrationTagFamilies>(CalibrationTagFamilies.Dict_4X4_1000);
const useMrCalRef = ref(true);
const useMrCal = computed<boolean>({
get() {
return useMrCalRef.value && useSettingsStore().general.mrCalWorking;
},
set(value) {
useMrCalRef.value = value && useSettingsStore().general.mrCalWorking;
}
});
const downloadCalibBoard = () => { const downloadCalibBoard = () => {
const doc = new JsPDF({ unit: "in", format: "letter" }); const doc = new JsPDF({ unit: "in", format: "letter" });
@@ -169,7 +160,6 @@ const startCalibration = () => {
patternHeight: patternHeight.value, patternHeight: patternHeight.value,
patternWidth: patternWidth.value, patternWidth: patternWidth.value,
boardType: boardType.value, boardType: boardType.value,
useMrCal: useMrCal.value,
useOldPattern: useOldPattern.value, useOldPattern: useOldPattern.value,
tagFamily: tagFamily.value tagFamily: tagFamily.value
}); });
@@ -201,6 +191,8 @@ const endCalibration = () => {
}); });
}; };
let drawAllSnapshots = ref(true);
let showCalDialog = ref(false); let showCalDialog = ref(false);
let selectedVideoFormat = ref<VideoFormat | undefined>(undefined); let selectedVideoFormat = ref<VideoFormat | undefined>(undefined);
const setSelectedVideoFormat = (format: VideoFormat) => { const setSelectedVideoFormat = (format: VideoFormat) => {
@@ -251,7 +243,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
<pv-select <pv-select
v-model="useStateStore().calibrationData.videoFormatIndex" v-model="useStateStore().calibrationData.videoFormatIndex"
label="Resolution" label="Resolution"
:select-cols="7" :select-cols="8"
:disabled="isCalibrating" :disabled="isCalibrating"
tooltip="Resolution to calibrate at (you will have to calibrate every resolution you use 3D mode on)" tooltip="Resolution to calibrate at (you will have to calibrate every resolution you use 3D mode on)"
:items="getUniqueVideoResolutionStrings()" :items="getUniqueVideoResolutionStrings()"
@@ -262,14 +254,14 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
label="Decimation" label="Decimation"
tooltip="Resolution to which camera frames are downscaled for detection. Calibration still uses full-res" tooltip="Resolution to which camera frames are downscaled for detection. Calibration still uses full-res"
:items="calibrationDivisors" :items="calibrationDivisors"
:select-cols="7" :select-cols="8"
@input="(v) => useCameraSettingsStore().changeCurrentPipelineSetting({ streamingFrameDivisor: v }, false)" @input="(v) => useCameraSettingsStore().changeCurrentPipelineSetting({ streamingFrameDivisor: v }, false)"
/> />
<pv-select <pv-select
v-model="boardType" v-model="boardType"
label="Board Type" label="Board Type"
tooltip="Calibration board pattern to use" tooltip="Calibration board pattern to use"
:select-cols="7" :select-cols="8"
:items="['Chessboard', 'Charuco']" :items="['Chessboard', 'Charuco']"
:disabled="isCalibrating" :disabled="isCalibrating"
/> />
@@ -278,7 +270,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
v-model="tagFamily" v-model="tagFamily"
label="Tag Family" label="Tag Family"
tooltip="Dictionary of aruco markers on the charuco board" tooltip="Dictionary of aruco markers on the charuco board"
:select-cols="7" :select-cols="8"
:items="['Dict_4X4_1000', 'Dict_5X5_1000', 'Dict_6X6_1000', 'Dict_7X7_1000']" :items="['Dict_4X4_1000', 'Dict_5X5_1000', 'Dict_6X6_1000', 'Dict_7X7_1000']"
:disabled="isCalibrating" :disabled="isCalibrating"
/> />
@@ -288,7 +280,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
tooltip="Spacing between pattern features in inches" tooltip="Spacing between pattern features in inches"
:disabled="isCalibrating" :disabled="isCalibrating"
:rules="[(v) => v > 0 || 'Size must be positive']" :rules="[(v) => v > 0 || 'Size must be positive']"
:label-cols="5" :label-cols="4"
/> />
<pv-number-input <pv-number-input
v-show="boardType == CalibrationBoardTypes.Charuco" v-show="boardType == CalibrationBoardTypes.Charuco"
@@ -297,7 +289,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
tooltip="Size of the tag markers in inches must be smaller than pattern spacing" tooltip="Size of the tag markers in inches must be smaller than pattern spacing"
:disabled="isCalibrating" :disabled="isCalibrating"
:rules="[(v) => v > 0 || 'Size must be positive']" :rules="[(v) => v > 0 || 'Size must be positive']"
:label-cols="5" :label-cols="4"
/> />
<pv-number-input <pv-number-input
v-model="patternWidth" v-model="patternWidth"
@@ -305,7 +297,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
tooltip="Width of the board in dots or chessboard squares" tooltip="Width of the board in dots or chessboard squares"
:disabled="isCalibrating" :disabled="isCalibrating"
:rules="[(v) => v >= 4 || 'Width must be at least 4']" :rules="[(v) => v >= 4 || 'Width must be at least 4']"
:label-cols="5" :label-cols="4"
/> />
<pv-number-input <pv-number-input
v-model="patternHeight" v-model="patternHeight"
@@ -313,7 +305,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
tooltip="Height of the board in dots or chessboard squares" tooltip="Height of the board in dots or chessboard squares"
:disabled="isCalibrating" :disabled="isCalibrating"
:rules="[(v) => v >= 4 || 'Height must be at least 4']" :rules="[(v) => v >= 4 || 'Height must be at least 4']"
:label-cols="5" :label-cols="4"
/> />
<pv-switch <pv-switch
v-show="boardType == CalibrationBoardTypes.Charuco" v-show="boardType == CalibrationBoardTypes.Charuco"
@@ -321,15 +313,18 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
label="Old OpenCV Pattern" label="Old OpenCV Pattern"
:disabled="isCalibrating" :disabled="isCalibrating"
tooltip="If enabled, Photon will use the old OpenCV pattern for calibration." tooltip="If enabled, Photon will use the old OpenCV pattern for calibration."
:label-cols="5" :label-cols="4"
/>
<pv-switch
v-model="useMrCal"
label="Try using MrCal over OpenCV"
:disabled="!useSettingsStore().general.mrCalWorking || isCalibrating"
tooltip="If enabled, Photon will (try to) use MrCal instead of OpenCV for camera calibration."
:label-cols="5"
/> />
<v-banner
v-show="useSettingsStore().general.mrCalWorking"
rounded
color="secondary"
text-color="white"
class="mt-3"
icon="mdi-alert-circle-outline"
>
Mrcal was successfully loaded, and will be used!
</v-banner>
<v-banner <v-banner
v-show="!useSettingsStore().general.mrCalWorking" v-show="!useSettingsStore().general.mrCalWorking"
rounded rounded
@@ -463,6 +458,16 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
</v-btn> </v-btn>
</v-col> </v-col>
</v-row> </v-row>
<v-row v-if="isCalibrating" style="display: flex; flex-direction: column">
<pv-switch
v-model="drawAllSnapshots"
class="pt-2"
label="Draw Collected Corners"
:switch-cols="8"
tooltip="Draw all snapshots"
@input="(args) => useCameraSettingsStore().changeCurrentPipelineSetting({ drawAllSnapshots: args }, false)"
/>
</v-row>
</div> </div>
</v-card> </v-card>
<v-dialog v-model="showCalibEndDialog" width="500px" :persistent="true"> <v-dialog v-model="showCalibEndDialog" width="500px" :persistent="true">

View File

@@ -339,7 +339,6 @@ export const useCameraSettingsStore = defineStore("cameraSettings", {
patternWidth: number; patternWidth: number;
patternHeight: number; patternHeight: number;
boardType: CalibrationBoardTypes; boardType: CalibrationBoardTypes;
useMrCal: boolean;
useOldPattern: boolean; useOldPattern: boolean;
tagFamily: CalibrationTagFamilies; tagFamily: CalibrationTagFamilies;
}, },

View File

@@ -142,7 +142,9 @@ export const DefaultPipelineSettings: Omit<
hsvSaturation: { first: 50, second: 255 }, hsvSaturation: { first: 50, second: 255 },
contourIntersection: 1, contourIntersection: 1,
cameraAutoWhiteBalance: false, cameraAutoWhiteBalance: false,
cameraWhiteBalanceTemp: 4000 cameraWhiteBalanceTemp: 4000,
cameraMinExposureRaw: 1,
cameraMaxExposureRaw: 2
}; };
export interface ReflectivePipelineSettings extends PipelineSettings { export interface ReflectivePipelineSettings extends PipelineSettings {
@@ -314,16 +316,34 @@ export const DefaultObjectDetectionPipelineSettings: ObjectDetectionPipelineSett
model: "" model: ""
}; };
export interface Calibration3dPipelineSettings extends PipelineSettings {
drawAllSnapshots: boolean;
}
export type ConfigurableCalibration3dPipelineSettings = Partial<Omit<Calibration3dPipelineSettings, "pipelineType">> &
ConfigurablePipelineSettings;
export const DefaultCalibration3dPipelineSettings: Calibration3dPipelineSettings = {
...DefaultPipelineSettings,
pipelineType: PipelineType.ObjectDetection,
cameraGain: 20,
targetModel: TargetModel.InfiniteRechargeHighGoalOuter,
ledMode: true,
outputShowMultipleTargets: false,
cameraExposureRaw: 6,
drawAllSnapshots: false
};
export type ActivePipelineSettings = export type ActivePipelineSettings =
| ReflectivePipelineSettings | ReflectivePipelineSettings
| ColoredShapePipelineSettings | ColoredShapePipelineSettings
| AprilTagPipelineSettings | AprilTagPipelineSettings
| ArucoPipelineSettings | ArucoPipelineSettings
| ObjectDetectionPipelineSettings; | ObjectDetectionPipelineSettings
| Calibration3dPipelineSettings;
export type ActiveConfigurablePipelineSettings = export type ActiveConfigurablePipelineSettings =
| ConfigurableReflectivePipelineSettings | ConfigurableReflectivePipelineSettings
| ConfigurableColoredShapePipelineSettings | ConfigurableColoredShapePipelineSettings
| ConfigurableAprilTagPipelineSettings | ConfigurableAprilTagPipelineSettings
| ConfigurableArucoPipelineSettings | ConfigurableArucoPipelineSettings
| ConfigurableObjectDetectionPipelineSettings; | ConfigurableObjectDetectionPipelineSettings
| ConfigurableCalibration3dPipelineSettings;

View File

@@ -43,6 +43,8 @@ public class DrawCalibrationPipe
@Override @Override
protected Void process(Pair<Mat, List<TrackedTarget>> in) { protected Void process(Pair<Mat, List<TrackedTarget>> in) {
if (!params.drawAllSnapshots) return null;
var image = in.getLeft(); var image = in.getLeft();
var imgSz = image.size(); var imgSz = image.size();
@@ -82,9 +84,11 @@ public class DrawCalibrationPipe
public static class DrawCalibrationPipeParams { public static class DrawCalibrationPipeParams {
private final FrameDivisor divisor; private final FrameDivisor divisor;
public boolean drawAllSnapshots;
public DrawCalibrationPipeParams(FrameDivisor divisor) { public DrawCalibrationPipeParams(FrameDivisor divisor, boolean drawSnapshots) {
this.divisor = divisor; this.divisor = divisor;
this.drawAllSnapshots = drawSnapshots;
} }
} }
} }

View File

@@ -230,7 +230,6 @@ public class Calibrate3dPipeline
settings.boardWidth, settings.boardWidth,
settings.boardHeight, settings.boardHeight,
settings.boardType, settings.boardType,
settings.useMrCal,
settings.useOldPattern, settings.useOldPattern,
settings.tagFamily)); settings.tagFamily));

View File

@@ -32,6 +32,7 @@ public class Calibration3dPipelineSettings extends AdvancedPipelineSettings {
public Size resolution = new Size(640, 480); public Size resolution = new Size(640, 480);
public boolean useMrCal = true; public boolean useMrCal = true;
public boolean useOldPattern = false; public boolean useOldPattern = false;
public boolean drawAllSnapshots;
public Calibration3dPipelineSettings() { public Calibration3dPipelineSettings() {
super(); super();
@@ -39,5 +40,6 @@ public class Calibration3dPipelineSettings extends AdvancedPipelineSettings {
this.inputShouldShow = true; this.inputShouldShow = true;
this.outputShouldShow = true; this.outputShouldShow = true;
this.streamingFrameDivisor = FrameDivisor.HALF; this.streamingFrameDivisor = FrameDivisor.HALF;
this.drawAllSnapshots = true;
} }
} }

View File

@@ -114,8 +114,12 @@ public class OutputStreamPipeline {
resizeImagePipe.setParams( resizeImagePipe.setParams(
new ResizeImagePipe.ResizeImageParams(settings.streamingFrameDivisor)); new ResizeImagePipe.ResizeImageParams(settings.streamingFrameDivisor));
drawCalibrationPipe.setParams( if (settings instanceof Calibration3dPipelineSettings) {
new DrawCalibrationPipe.DrawCalibrationPipeParams(settings.streamingFrameDivisor)); drawCalibrationPipe.setParams(
new DrawCalibrationPipe.DrawCalibrationPipeParams(
settings.streamingFrameDivisor,
((Calibration3dPipelineSettings) settings).drawAllSnapshots));
}
} }
public CVPipelineResult process( public CVPipelineResult process(

View File

@@ -28,7 +28,6 @@ public class UICalibrationData {
public int patternWidth; public int patternWidth;
public int patternHeight; public int patternHeight;
public BoardType boardType; public BoardType boardType;
public boolean useMrCal;
public double markerSizeIn; public double markerSizeIn;
public boolean useOldPattern; public boolean useOldPattern;
public TagFamily tagFamily; public TagFamily tagFamily;
@@ -45,7 +44,6 @@ public class UICalibrationData {
int patternWidth, int patternWidth,
int patternHeight, int patternHeight,
BoardType boardType, BoardType boardType,
boolean useMrCal,
boolean useOldPattern, boolean useOldPattern,
TagFamily tagFamily) { TagFamily tagFamily) {
this.count = count; this.count = count;
@@ -57,7 +55,6 @@ public class UICalibrationData {
this.patternWidth = patternWidth; this.patternWidth = patternWidth;
this.patternHeight = patternHeight; this.patternHeight = patternHeight;
this.boardType = boardType; this.boardType = boardType;
this.useMrCal = useMrCal;
this.useOldPattern = useOldPattern; this.useOldPattern = useOldPattern;
this.tagFamily = tagFamily; this.tagFamily = tagFamily;
} }

View File

@@ -355,7 +355,6 @@ public class VisionModule {
settings.boardHeight = data.patternHeight; settings.boardHeight = data.patternHeight;
settings.boardWidth = data.patternWidth; settings.boardWidth = data.patternWidth;
settings.boardType = data.boardType; settings.boardType = data.boardType;
settings.useMrCal = data.useMrCal;
settings.resolution = resolution; settings.resolution = resolution;
settings.useOldPattern = data.useOldPattern; settings.useOldPattern = data.useOldPattern;
settings.tagFamily = data.tagFamily; settings.tagFamily = data.tagFamily;