Compare commits

...

3 Commits

Author SHA1 Message Date
Sam Freund
3e879cc30f feat: crosshair toggle for driver mode (#1822)
closes #1818 

![image of added
toggle](https://github.com/user-attachments/assets/9a8a4f88-3ce2-4fcd-b0ac-61f5b96d26e4)
Here's what the added toggle looks like, I just put in the input
settings. It'll also hide itself when drivermode is off.
2025-03-19 14:29:59 -07:00
JA-01
c2127ac820 [Docs] Fix broken hyperlink (Fixes #1802) (#1821) 2025-03-19 12:47:29 -07:00
Sam Freund
002373e395 fix: remove debugging printout for snapshot methods (#1823) 2025-03-19 12:46:35 -07:00
5 changed files with 18 additions and 8 deletions

View File

@@ -1,10 +1,10 @@
# 3D Tracking
3D AprilTag tracking will allow you to track the real-world position and rotation of a tag relative to the camera's image sensor. This is useful for robot pose estimation and other applications like autonomous scoring. In order to use 3D tracking, you must first {ref}`calibrate your camera <docs/calibration/calibration:Calibrating Your Camera>`. Once you have, you need to enable 3D mode in the UI and you will now be able to get 3D pose information from the tag! For information on getting and using this information in your code, see {ref}`the programming reference. <docs/programming/index:Programming Reference>`.
3D AprilTag tracking will allow you to track the real-world position and rotation of a tag relative to the camera's image sensor. This is useful for robot pose estimation and other applications like autonomous scoring. In order to use 3D tracking, you must first {ref}`calibrate your camera <docs/calibration/calibration:Calibrating Your Camera>`. Once you have, you need to enable 3D mode in the UI and you will now be able to get 3D pose information from the tag! For information on getting and using this information in your code, see {ref}`the programming reference <docs/programming/index:Programming Reference>`.
## Ambiguity
Translating from 2D to 3D using data from the calibration and the four tag corners can lead to "pose ambiguity", where it appears that the AprilTag pose is flipping between two different poses. You can read more about this issue `here. <https://docs.wpilib.org/en/stable/docs/software/vision-processing/apriltag/apriltag-intro.html#d-to-3d-ambiguity>` Ambiguity is calculated as the ratio of reprojection errors between two pose solutions (if they exist), where reprojection error is the error corresponding to the image distance between where the apriltag's corners are detected vs where we expect to see them based on the tag's estimated camera relative pose.
Translating from 2D to 3D using data from the calibration and the four tag corners can lead to "pose ambiguity", where it appears that the AprilTag pose is flipping between two different poses. You can read more about this issue [here](https://docs.wpilib.org/en/stable/docs/software/vision-processing/apriltag/apriltag-intro.html#d-to-3d-ambiguity). Ambiguity is calculated as the ratio of reprojection errors between two pose solutions (if they exist), where reprojection error is the error corresponding to the image distance between where the apriltag's corners are detected vs where we expect to see them based on the tag's estimated camera relative pose.
There are a few steps you can take to resolve/mitigate this issue:

View File

@@ -170,5 +170,13 @@ const interactiveCols = computed(() =>
:select-cols="interactiveCols"
@input="(args) => handleStreamResolutionChange(args)"
/>
<pv-switch
v-if="useCameraSettingsStore().isDriverMode"
v-model="useCameraSettingsStore().currentPipelineSettings.crosshair"
label="Crosshair"
:switch-cols="interactiveCols"
tooltip="Enables or disables a crosshair overlay on the camera stream"
@input="(args) => useCameraSettingsStore().changeCurrentPipelineSetting({ crosshair: args }, false)"
/>
</div>
</template>

View File

@@ -84,8 +84,6 @@ public class FileSaveFrameConsumer implements Consumer<CVMat> {
public void accept(CVMat image, Date now) {
long currentCount = saveFrameEntry.get();
System.out.println("currentCount: " + currentCount + " savedImagesCount: " + savedImagesCount);
// Await save request
if (currentCount == -1) return;

View File

@@ -68,10 +68,12 @@ public class DriverModePipeline
if (!emptyIn) {
totalNanos += resizeImagePipe.run(inputMat).nanosElapsed;
var draw2dCrosshairResult = draw2dCrosshairPipe.run(Pair.of(inputMat, List.of()));
if (settings.crosshair) {
var draw2dCrosshairResult = draw2dCrosshairPipe.run(Pair.of(inputMat, List.of()));
// calculate elapsed nanoseconds
totalNanos += draw2dCrosshairResult.nanosElapsed;
// calculate elapsed nanoseconds
totalNanos += draw2dCrosshairResult.nanosElapsed;
}
}
var fpsResult = calculateFPSPipe.run(null);
@@ -92,6 +94,7 @@ public class DriverModePipeline
@Override
public void release() {
// we never actually need to give resources up since pipelinemanager only makes one of us
// we never actually need to give resources up since pipelinemanager only makes
// one of us
}
}

View File

@@ -24,6 +24,7 @@ import org.photonvision.vision.processes.PipelineManager;
@JsonTypeName("DriverModePipelineSettings")
public class DriverModePipelineSettings extends CVPipelineSettings {
public DoubleCouple offsetPoint = new DoubleCouple();
public boolean crosshair = true;
public DriverModePipelineSettings() {
super();