diff --git a/photon-client/src/components/app/photon-camera-stream.vue b/photon-client/src/components/app/photon-camera-stream.vue
index a836e4b362..34465e9389 100644
--- a/photon-client/src/components/app/photon-camera-stream.vue
+++ b/photon-client/src/components/app/photon-camera-stream.vue
@@ -1,5 +1,5 @@
-
+
{
};
const resetCurrentBuffer = () => {
// Need to clear the array in place
- while (useStateStore().currentMultitagBuffer?.length != 0) useStateStore().currentMultitagBuffer?.pop();
+ if (useStateStore().currentMultitagBuffer) useStateStore().currentMultitagBuffer!.length = 0;
};
diff --git a/photon-client/src/stores/StateStore.ts b/photon-client/src/stores/StateStore.ts
index 47ec05eb82..3a7376e12b 100644
--- a/photon-client/src/stores/StateStore.ts
+++ b/photon-client/src/stores/StateStore.ts
@@ -84,7 +84,8 @@ export const useStateStore = defineStore("state", {
return this.backendResults[this.currentCameraIndex.toString()];
},
currentMultitagBuffer(): MultitagResult[] | undefined {
- return this.multitagResultBuffer[this.currentCameraIndex.toString()];
+ if (!this.multitagResultBuffer[this.currentCameraIndex]) this.multitagResultBuffer[this.currentCameraIndex] = [];
+ return this.multitagResultBuffer[this.currentCameraIndex];
}
},
actions: {
diff --git a/photon-core/src/main/java/org/photonvision/vision/frame/provider/USBFrameProvider.java b/photon-core/src/main/java/org/photonvision/vision/frame/provider/USBFrameProvider.java
index 03459c197d..5cc5e3cbaf 100644
--- a/photon-core/src/main/java/org/photonvision/vision/frame/provider/USBFrameProvider.java
+++ b/photon-core/src/main/java/org/photonvision/vision/frame/provider/USBFrameProvider.java
@@ -18,11 +18,14 @@
package org.photonvision.vision.frame.provider;
import edu.wpi.first.cscore.CvSink;
-import org.photonvision.common.util.math.MathUtils;
+import org.photonvision.common.logging.LogGroup;
+import org.photonvision.common.logging.Logger;
import org.photonvision.vision.opencv.CVMat;
import org.photonvision.vision.processes.VisionSourceSettables;
public class USBFrameProvider extends CpuImageProcessor {
+ private static final Logger logger = new Logger(USBFrameProvider.class, LogGroup.Camera);
+
private final CvSink cvSink;
@SuppressWarnings("SpellCheckingInspection")
@@ -43,9 +46,9 @@ public CapturedFrame getInputMat() {
cvSink.grabFrame(mat.getMat())
* 1000; // Units are microseconds, epoch is the same as the Unix epoch
- // Sometimes CSCore gives us a zero frametime.
- if (time <= 1e-6) {
- time = MathUtils.wpiNanoTime();
+ if (time == 0) {
+ var error = cvSink.getError();
+ logger.error("Error grabbing image: " + error);
}
return new CapturedFrame(mat, settables.getFrameStaticProperties(), time);
diff --git a/photon-core/src/main/java/org/photonvision/vision/processes/VisionRunner.java b/photon-core/src/main/java/org/photonvision/vision/processes/VisionRunner.java
index 180135458e..932e56b53d 100644
--- a/photon-core/src/main/java/org/photonvision/vision/processes/VisionRunner.java
+++ b/photon-core/src/main/java/org/photonvision/vision/processes/VisionRunner.java
@@ -92,6 +92,12 @@ private void update() {
// Grab the new camera frame
var frame = frameSupplier.get();
+ // Frame empty -- no point in trying to do anything more?
+ if (frame.processedImage.getMat().empty() && frame.colorImage.getMat().empty()) {
+ // give up without increasing loop count
+ continue;
+ }
+
// There's no guarantee the processing type change will occur this tick, so pipelines should
// check themselves
try {