Skip to content
17 changes: 17 additions & 0 deletions photon-client/src/components/cameras/CameraCalibrationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import CameraCalibrationInfoCard from "@/components/cameras/CameraCalibrationInf
import { useSettingsStore } from "@/stores/settings/GeneralSettingsStore";
import { useTheme } from "vuetify";
import TooltippedLabel from "@/components/common/pv-tooltipped-label.vue";
import type { Calibration3dPipelineSettings } from "@/types/PipelineTypes";

const PromptRegular = import("@/assets/fonts/PromptRegular");
const jspdf = import("jspdf");
Expand Down Expand Up @@ -269,6 +270,11 @@ const endCalibration = () => {
};

const drawAllSnapshots = ref(true);
// We really gotta fix our typing system
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a legit todo? in that case cut an issue with more details

const bypassVal = computed<boolean>({
get: () => !!(useCameraSettingsStore().currentPipelineSettings as Calibration3dPipelineSettings | undefined)?.bypass,
set: (value) => useCameraSettingsStore().changeCurrentPipelineSetting({ bypass: value }, true)
});

const showCalDialog = ref(false);
const selectedVideoFormat = ref<VideoFormat | undefined>(undefined);
Expand Down Expand Up @@ -545,6 +551,17 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
Snapshots: {{ useStateStore().calibrationData.imageCount }} of at least
{{ useStateStore().calibrationData.minimumImageCount }}
</v-chip>
<v-spacer />
<pv-switch
v-model="bypassVal"
color="error"
hide-details
class="ml-4"
label="Bypass minimum"
:label-cols="6"
:switch-cols="6"
Comment on lines +561 to +562
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Wraps weirdly for me at 1920x1080.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has this been fixed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooltip="Bypass the minimum recommended amount of snapshots for a calibration. Should only be used for dev work or temporary tests not competitions. Still requires 10 images to calibrate."
/>
</div>
<div>
<v-btn
Expand Down
2 changes: 1 addition & 1 deletion photon-client/src/stores/StateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const useStateStore = defineStore("state", {
calibrationData: {
imageCount: 0,
videoFormatIndex: 0,
minimumImageCount: 12,
minimumImageCount: 100,
hasEnoughImages: false
},

Expand Down
4 changes: 3 additions & 1 deletion photon-client/src/types/PipelineTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export const DefaultObjectDetectionPipelineSettings: ObjectDetectionPipelineSett
export interface Calibration3dPipelineSettings extends PipelineSettings {
pipelineType: PipelineType.Calibration3d;
drawAllSnapshots: boolean;
bypass: boolean;
}
export type ConfigurableCalibration3dPipelineSettings = Partial<Omit<Calibration3dPipelineSettings, "pipelineType">> &
ConfigurablePipelineSettings;
Expand All @@ -385,7 +386,8 @@ export const DefaultCalibration3dPipelineSettings: Calibration3dPipelineSettings
ledMode: true,
outputMaximumTargets: 1,
cameraExposureRaw: 6,
drawAllSnapshots: false
drawAllSnapshots: false,
bypass: false
};

export type ActivePipelineSettings =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,25 @@ public class Calibrate3dPipeline
/// Output of the calibration, getter method is set for this.
private CVPipeResult<CameraCalibrationCoefficients> calibrationOutput;

// minSnapshots is the typical limit for the number of snapshots needed, bypassMinSnapshots is the
// limit used when the bypass flag is true
private final int minSnapshots;
private final int bypassMinSnapshots;
Comment thread
samfreund marked this conversation as resolved.

private boolean calibrating = false;

private static final FrameThresholdType PROCESSING_TYPE = FrameThresholdType.NONE;

public Calibrate3dPipeline() {
this(12);
this(100, 10);
}

public Calibrate3dPipeline(int minSnapshots) {
public Calibrate3dPipeline(int minSnapshots, int bypassMinSnapshots) {
super(PROCESSING_TYPE);
this.settings = new Calibration3dPipelineSettings();
this.foundCornersList = new ArrayList<>();
this.minSnapshots = minSnapshots;
this.bypassMinSnapshots = bypassMinSnapshots;
}

@Override
Expand Down Expand Up @@ -165,7 +169,11 @@ List<List<Point>> getCornersList() {
}

public boolean hasEnough() {
return foundCornersList.size() >= minSnapshots;
return foundCornersList.size() >= getEffectiveMinSnapshots();
}

private int getEffectiveMinSnapshots() {
return settings.bypass ? bypassMinSnapshots : minSnapshots;
}

public CameraCalibrationCoefficients tryCalibration(Path imageSavePath) {
Expand All @@ -174,7 +182,7 @@ public CameraCalibrationCoefficients tryCalibration(Path imageSavePath) {
"Not enough snapshots! Only got "
+ foundCornersList.size()
+ " of "
+ minSnapshots
+ getEffectiveMinSnapshots()
+ " -- returning null..");
return null;
}
Expand Down Expand Up @@ -216,7 +224,7 @@ public void broadcastState() {
new UICalibrationData(
foundCornersList.size(),
settings.cameraVideoModeIndex,
minSnapshots,
getEffectiveMinSnapshots(),
hasEnough(),
Units.metersToInches(settings.gridSize),
Units.metersToInches(settings.markerSize),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Calibration3dPipelineSettings extends AdvancedPipelineSettings {
public boolean useMrCal = true;
public boolean useOldPattern = false;
public boolean drawAllSnapshots;
public boolean bypass;

public Calibration3dPipelineSettings() {
super();
Expand All @@ -41,5 +42,6 @@ public Calibration3dPipelineSettings() {
this.outputShouldShow = true;
this.streamingFrameDivisor = FrameDivisor.HALF;
this.drawAllSnapshots = true;
this.bypass = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public void processSettingChanges() {
}

parentModule.saveAndBroadcastSelective(originContext, propName, newPropValue);

if (propName.equals("bypass")) {
// Rebroadcast calibration data when bypass changes
parentModule.pipelineManager.calibration3dPipeline.broadcastState();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static void calibrateCommon(

assertTrue(directoryListing.length >= 12);

Calibrate3dPipeline calibration3dPipeline = new Calibrate3dPipeline(10);
Calibrate3dPipeline calibration3dPipeline = new Calibrate3dPipeline(10, 10);
calibration3dPipeline.getSettings().boardType = boardType;
calibration3dPipeline.getSettings().markerSize = markerSize;
calibration3dPipeline.getSettings().tagFamily = tagFamily;
Expand Down
Loading