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 useOldPattern = ref(false);
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 doc = new JsPDF({ unit: "in", format: "letter" });
@@ -169,7 +160,6 @@ const startCalibration = () => {
patternHeight: patternHeight.value,
patternWidth: patternWidth.value,
boardType: boardType.value,
useMrCal: useMrCal.value,
useOldPattern: useOldPattern.value,
tagFamily: tagFamily.value
});
@@ -201,6 +191,8 @@ const endCalibration = () => {
});
};
let drawAllSnapshots = ref(true);
let showCalDialog = ref(false);
let selectedVideoFormat = ref<VideoFormat | undefined>(undefined);
const setSelectedVideoFormat = (format: VideoFormat) => {
@@ -251,7 +243,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
<pv-select
v-model="useStateStore().calibrationData.videoFormatIndex"
label="Resolution"
:select-cols="7"
:select-cols="8"
:disabled="isCalibrating"
tooltip="Resolution to calibrate at (you will have to calibrate every resolution you use 3D mode on)"
:items="getUniqueVideoResolutionStrings()"
@@ -262,14 +254,14 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
label="Decimation"
tooltip="Resolution to which camera frames are downscaled for detection. Calibration still uses full-res"
:items="calibrationDivisors"
:select-cols="7"
:select-cols="8"
@input="(v) => useCameraSettingsStore().changeCurrentPipelineSetting({ streamingFrameDivisor: v }, false)"
/>
<pv-select
v-model="boardType"
label="Board Type"
tooltip="Calibration board pattern to use"
:select-cols="7"
:select-cols="8"
:items="['Chessboard', 'Charuco']"
:disabled="isCalibrating"
/>
@@ -278,7 +270,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
v-model="tagFamily"
label="Tag Family"
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']"
:disabled="isCalibrating"
/>
@@ -288,7 +280,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
tooltip="Spacing between pattern features in inches"
:disabled="isCalibrating"
:rules="[(v) => v > 0 || 'Size must be positive']"
:label-cols="5"
:label-cols="4"
/>
<pv-number-input
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"
:disabled="isCalibrating"
:rules="[(v) => v > 0 || 'Size must be positive']"
:label-cols="5"
:label-cols="4"
/>
<pv-number-input
v-model="patternWidth"
@@ -305,7 +297,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
tooltip="Width of the board in dots or chessboard squares"
:disabled="isCalibrating"
:rules="[(v) => v >= 4 || 'Width must be at least 4']"
:label-cols="5"
:label-cols="4"
/>
<pv-number-input
v-model="patternHeight"
@@ -313,7 +305,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
tooltip="Height of the board in dots or chessboard squares"
:disabled="isCalibrating"
:rules="[(v) => v >= 4 || 'Height must be at least 4']"
:label-cols="5"
:label-cols="4"
/>
<pv-switch
v-show="boardType == CalibrationBoardTypes.Charuco"
@@ -321,15 +313,18 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
label="Old OpenCV Pattern"
:disabled="isCalibrating"
tooltip="If enabled, Photon will use the old OpenCV pattern for calibration."
:label-cols="5"
/>
<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"
:label-cols="4"
/>
<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-show="!useSettingsStore().general.mrCalWorking"
rounded
@@ -463,6 +458,16 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
</v-btn>
</v-col>
</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>
</v-card>
<v-dialog v-model="showCalibEndDialog" width="500px" :persistent="true">

View File

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

View File

@@ -142,7 +142,9 @@ export const DefaultPipelineSettings: Omit<
hsvSaturation: { first: 50, second: 255 },
contourIntersection: 1,
cameraAutoWhiteBalance: false,
cameraWhiteBalanceTemp: 4000
cameraWhiteBalanceTemp: 4000,
cameraMinExposureRaw: 1,
cameraMaxExposureRaw: 2
};
export interface ReflectivePipelineSettings extends PipelineSettings {
@@ -314,16 +316,34 @@ export const DefaultObjectDetectionPipelineSettings: ObjectDetectionPipelineSett
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 =
| ReflectivePipelineSettings
| ColoredShapePipelineSettings
| AprilTagPipelineSettings
| ArucoPipelineSettings
| ObjectDetectionPipelineSettings;
| ObjectDetectionPipelineSettings
| Calibration3dPipelineSettings;
export type ActiveConfigurablePipelineSettings =
| ConfigurableReflectivePipelineSettings
| ConfigurableColoredShapePipelineSettings
| ConfigurableAprilTagPipelineSettings
| ConfigurableArucoPipelineSettings
| ConfigurableObjectDetectionPipelineSettings;
| ConfigurableObjectDetectionPipelineSettings
| ConfigurableCalibration3dPipelineSettings;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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