Merge branch 'main' into 2027

This commit is contained in:
Sam Freund
2026-05-05 10:55:54 -05:00
committed by GitHub
5 changed files with 25 additions and 26 deletions

View File

@@ -35,9 +35,19 @@ public abstract class FrameProvider implements Supplier<Frame>, Releasable {
cameraPropertiesCached = true;
}
public abstract boolean isConnected();
/** Internal provider for if the camera is currently connected. */
protected abstract boolean checkCameraConnected();
public abstract boolean checkCameraConnected();
/** Checks if the camera is currently connected. Also handles connection events. */
public boolean isConnected() {
boolean connected = this.checkCameraConnected();
if (!cameraPropertiesCached && connected) {
onCameraConnected();
}
return connected;
}
/**
* Returns if the camera has connected at some point. This is not if it is currently connected.

View File

@@ -37,11 +37,6 @@ public class LibcameraGpuFrameProvider extends FrameProvider {
public LibcameraGpuFrameProvider(LibcameraGpuSettables visionSettables) {
this.settables = visionSettables;
var vidMode = settables.getCurrentVideoMode();
settables.setVideoMode(vidMode);
this.cameraPropertiesCached =
true; // Camera properties are not able to be changed so they are always cached
}
@Override
@@ -160,9 +155,13 @@ public class LibcameraGpuFrameProvider extends FrameProvider {
return false;
}
// To our knowledge the camera is always connected (after boot) with csi cameras
@Override
public boolean isConnected() {
return checkCameraConnected();
protected void onCameraConnected() {
logger.info("Camera connected! running callback");
super.onCameraConnected();
var vidMode = settables.getCurrentVideoMode();
settables.setVideoMode(vidMode);
}
}

View File

@@ -57,18 +57,6 @@ public class USBFrameProvider extends CpuImageProcessor {
this.connectedCallback = connectedCallback;
}
@Override
public boolean checkCameraConnected() {
boolean connected = camera.isConnected();
if (!cameraPropertiesCached && connected) {
logger.info("Camera connected! running callback");
onCameraConnected();
}
return connected;
}
final double CSCORE_DEFAULT_FRAME_TIMEOUT = 1.0 / 4.0;
@Override
@@ -145,13 +133,15 @@ public class USBFrameProvider extends CpuImageProcessor {
@Override
public void onCameraConnected() {
logger.info("Camera connected! running callback");
super.onCameraConnected();
this.connectedCallback.run();
}
@Override
public boolean isConnected() {
public boolean checkCameraConnected() {
return camera.isConnected();
}

View File

@@ -132,7 +132,7 @@ public class VisionRunner {
private void update() {
// wait for the camera to connect
while (!frameSupplier.checkCameraConnected() && !Thread.interrupted()) {
while (!frameSupplier.isConnected() && !Thread.interrupted()) {
// yield
pipelineResultConsumer.accept(new CVPipelineResult(0l, 0, 0, null, new Frame()));
try {

View File

@@ -102,6 +102,7 @@ const presentations = [
"Information on the Rubik Pi 3 and how to use Object Detection with PhotonVision.",
slidedeckLink:
"https://docs.google.com/presentation/d/1eCt9OmOISldCxsxp-aWAvT6YFkfdPzhbeEZn2ihcltA/edit?usp=sharing",
videoEmbedUrl: "https://www.youtube-nocookie.com/embed/layhsbOIJx4",
},
{
title: "Champs 2024 Talk",
@@ -110,8 +111,7 @@ const presentations = [
slidedeckLink:
"https://docs.google.com/presentation/d/1Gh5InslM5p7aDxjzK8DHoEorpATOl-MQWWixY5GjGgs/edit#slide=id.p",
codeLink: "https://github.com/PhotonVision/champs_2024",
videoEmbedUrl:
"https://www.youtube-nocookie.com/embed/iV2v7F_9GwE?si=4wgaT1IrZBpA71dF",
videoEmbedUrl: "https://www.youtube-nocookie.com/embed/iV2v7F_9GwE",
},
];
</script>