From 058df18f97abfebddb9d266a16d2f7a00237c380 Mon Sep 17 00:00:00 2001 From: Stephen Just Date: Sat, 28 Sep 2024 12:25:20 -0700 Subject: [PATCH 1/3] Camera view updated to better respond to state In the previous camera view code, the frame didn't respond well to losses of connection, camera aspect ratio changes, etc. Instead of changing the stream src, we can layer the camera view on top of the loading image, so that any time the camera signal is lost, even if it's because PhotonVision is restarting or you lose connection to the robot, the loading image is still in memory. This also fixes the responsiveness to connection loss. --- .../components/app/photon-camera-stream.vue | 45 ++++++++++++++++--- .../src/components/cameras/CamerasView.vue | 1 + 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/photon-client/src/components/app/photon-camera-stream.vue b/photon-client/src/components/app/photon-camera-stream.vue index 710fd81b2a..7bc0c74d99 100644 --- a/photon-client/src/components/app/photon-camera-stream.vue +++ b/photon-client/src/components/app/photon-camera-stream.vue @@ -11,12 +11,13 @@ const props = defineProps<{ id: string; }>(); +const emptyStreamSrc = "//:0"; const streamSrc = computed(() => { const port = useCameraSettingsStore().currentCameraSettings.stream[props.streamType === "Raw" ? "inputPort" : "outputPort"]; if (!useStateStore().backendConnected || port === 0) { - return loadingImage; + return emptyStreamSrc; } return `http://${inject("backendHostname")}:${port}/stream.mjpg`; @@ -24,14 +25,27 @@ const streamSrc = computed(() => { const streamDesc = computed(() => `${props.streamType} Stream View`); const streamStyle = computed(() => { if (useStateStore().colorPickingMode) { - return { width: "100%", cursor: "crosshair" }; + return { cursor: "crosshair" }; } - return { width: "100%" }; + return { }; +}); + +const containerStyle = computed(() => { + const resolution = useCameraSettingsStore().currentVideoFormat.resolution; + const rotation = useCameraSettingsStore().currentPipelineSettings.inputImageRotationMode; + if (rotation === 1 || rotation === 3) { + return { + aspectRatio: `${resolution.height}/${resolution.width}` + }; + } + return { + aspectRatio: `${resolution.width}/${resolution.height}` + }; }); const overlayStyle = computed(() => { - if (useStateStore().colorPickingMode || streamSrc.value == loadingImage) { + if (useStateStore().colorPickingMode || streamSrc.value == emptyStreamSrc) { return { display: "none" }; } else { return {}; @@ -57,13 +71,16 @@ const handleFullscreenRequest = () => { const mjpgStream: any = ref(null); onBeforeUnmount(() => { if (!mjpgStream.value) return; - mjpgStream.value["src"] = null; + mjpgStream.value["src"] = emptyStreamSrc; }); + +