Skip to content

Commit e462114

Browse files
authored
Merge branch 'PhotonVision:master' into master
2 parents 214facc + 0106880 commit e462114

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed

photon-client/src/components/app/photon-camera-stream.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { computed, inject } from "vue";
2+
import { computed, inject, ref, onBeforeUnmount } from "vue";
33
import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore";
44
import { useStateStore } from "@/stores/StateStore";
55
import loadingImage from "@/assets/images/loading.svg";
@@ -53,11 +53,17 @@ const handleFullscreenRequest = () => {
5353
if (!stream) return;
5454
stream.requestFullscreen();
5555
};
56+
57+
const mjpgStream: any = ref(null);
58+
onBeforeUnmount(() => {
59+
if (!mjpgStream.value) return;
60+
mjpgStream.value["src"] = null;
61+
});
5662
</script>
5763

5864
<template>
5965
<div class="stream-container">
60-
<img :id="id" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" />
66+
<img :id="id" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" ref="mjpgStream" />
6167
<div class="stream-overlay" :style="overlayStyle">
6268
<pv-icon
6369
icon-name="mdi-camera-image"

photon-client/src/components/cameras/CamerasView.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ th {
151151
justify-content: center;
152152
}
153153
154+
@media only screen and (min-width: 960px) {
155+
#camera-settings-camera-view-card {
156+
position: sticky;
157+
top: 12px;
158+
}
159+
}
154160
@media only screen and (min-width: 512px) and (max-width: 960px) {
155161
.stream-container {
156162
flex-wrap: nowrap;

photon-client/src/components/dashboard/tabs/TargetsTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const calculateStdDev = (values: number[]): number => {
2828
};
2929
const resetCurrentBuffer = () => {
3030
// Need to clear the array in place
31-
while (useStateStore().currentMultitagBuffer?.length != 0) useStateStore().currentMultitagBuffer?.pop();
31+
if (useStateStore().currentMultitagBuffer) useStateStore().currentMultitagBuffer!.length = 0;
3232
};
3333
</script>
3434

photon-client/src/stores/StateStore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export const useStateStore = defineStore("state", {
8484
return this.backendResults[this.currentCameraIndex.toString()];
8585
},
8686
currentMultitagBuffer(): MultitagResult[] | undefined {
87-
return this.multitagResultBuffer[this.currentCameraIndex.toString()];
87+
if (!this.multitagResultBuffer[this.currentCameraIndex]) this.multitagResultBuffer[this.currentCameraIndex] = [];
88+
return this.multitagResultBuffer[this.currentCameraIndex];
8889
}
8990
},
9091
actions: {

photon-core/src/main/java/org/photonvision/vision/frame/provider/USBFrameProvider.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
package org.photonvision.vision.frame.provider;
1919

2020
import edu.wpi.first.cscore.CvSink;
21-
import org.photonvision.common.util.math.MathUtils;
21+
import org.photonvision.common.logging.LogGroup;
22+
import org.photonvision.common.logging.Logger;
2223
import org.photonvision.vision.opencv.CVMat;
2324
import org.photonvision.vision.processes.VisionSourceSettables;
2425

2526
public class USBFrameProvider extends CpuImageProcessor {
27+
private static final Logger logger = new Logger(USBFrameProvider.class, LogGroup.Camera);
28+
2629
private final CvSink cvSink;
2730

2831
@SuppressWarnings("SpellCheckingInspection")
@@ -43,9 +46,9 @@ public CapturedFrame getInputMat() {
4346
cvSink.grabFrame(mat.getMat())
4447
* 1000; // Units are microseconds, epoch is the same as the Unix epoch
4548

46-
// Sometimes CSCore gives us a zero frametime.
47-
if (time <= 1e-6) {
48-
time = MathUtils.wpiNanoTime();
49+
if (time == 0) {
50+
var error = cvSink.getError();
51+
logger.error("Error grabbing image: " + error);
4952
}
5053

5154
return new CapturedFrame(mat, settables.getFrameStaticProperties(), time);

photon-core/src/main/java/org/photonvision/vision/processes/VisionRunner.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ private void update() {
9292
// Grab the new camera frame
9393
var frame = frameSupplier.get();
9494

95+
// Frame empty -- no point in trying to do anything more?
96+
if (frame.processedImage.getMat().empty() && frame.colorImage.getMat().empty()) {
97+
// give up without increasing loop count
98+
continue;
99+
}
100+
95101
// There's no guarantee the processing type change will occur this tick, so pipelines should
96102
// check themselves
97103
try {

0 commit comments

Comments
 (0)