Skip to content

Commit cd9dd07

Browse files
authored
Camera view updated to better respond to state (#1437)
1 parent 3225c07 commit cd9dd07

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

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

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,41 @@ const props = defineProps<{
1111
id: string;
1212
}>();
1313
14+
const emptyStreamSrc = "//:0";
1415
const streamSrc = computed<string>(() => {
1516
const port =
1617
useCameraSettingsStore().currentCameraSettings.stream[props.streamType === "Raw" ? "inputPort" : "outputPort"];
1718
1819
if (!useStateStore().backendConnected || port === 0) {
19-
return loadingImage;
20+
return emptyStreamSrc;
2021
}
2122
2223
return `http://${inject("backendHostname")}:${port}/stream.mjpg`;
2324
});
2425
const streamDesc = computed<string>(() => `${props.streamType} Stream View`);
2526
const streamStyle = computed<StyleValue>(() => {
2627
if (useStateStore().colorPickingMode) {
27-
return { width: "100%", cursor: "crosshair" };
28+
return { cursor: "crosshair" };
2829
}
2930
30-
return { width: "100%" };
31+
return {};
32+
});
33+
34+
const containerStyle = computed<StyleValue>(() => {
35+
const resolution = useCameraSettingsStore().currentVideoFormat.resolution;
36+
const rotation = useCameraSettingsStore().currentPipelineSettings.inputImageRotationMode;
37+
if (rotation === 1 || rotation === 3) {
38+
return {
39+
aspectRatio: `${resolution.height}/${resolution.width}`
40+
};
41+
}
42+
return {
43+
aspectRatio: `${resolution.width}/${resolution.height}`
44+
};
3145
});
3246
3347
const overlayStyle = computed<StyleValue>(() => {
34-
if (useStateStore().colorPickingMode || streamSrc.value == loadingImage) {
48+
if (useStateStore().colorPickingMode || streamSrc.value == emptyStreamSrc) {
3549
return { display: "none" };
3650
} else {
3751
return {};
@@ -57,13 +71,23 @@ const handleFullscreenRequest = () => {
5771
const mjpgStream: any = ref(null);
5872
onBeforeUnmount(() => {
5973
if (!mjpgStream.value) return;
60-
mjpgStream.value["src"] = "//:0";
74+
mjpgStream.value["src"] = emptyStreamSrc;
6175
});
6276
</script>
6377

6478
<template>
65-
<div class="stream-container">
66-
<img :id="id" ref="mjpgStream" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" />
79+
<div class="stream-container" :style="containerStyle">
80+
<img :src="loadingImage" class="stream-loading" />
81+
<img
82+
:id="id"
83+
class="stream-video"
84+
ref="mjpgStream"
85+
v-show="streamSrc !== emptyStreamSrc"
86+
crossorigin="anonymous"
87+
:src="streamSrc"
88+
:alt="streamDesc"
89+
:style="streamStyle"
90+
/>
6791
<div class="stream-overlay" :style="overlayStyle">
6892
<pv-icon
6993
icon-name="mdi-camera-image"
@@ -89,7 +113,21 @@ onBeforeUnmount(() => {
89113

90114
<style scoped>
91115
.stream-container {
116+
display: flex;
92117
position: relative;
118+
width: 100%;
119+
}
120+
121+
.stream-loading {
122+
position: absolute;
123+
width: 100%;
124+
height: 100%;
125+
}
126+
127+
.stream-video {
128+
position: absolute;
129+
width: 100%;
130+
height: 100%;
93131
}
94132
95133
.stream-overlay {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ const fpsTooLow = computed<boolean>(() => {
8484
<div class="stream-container pb-4">
8585
<div class="stream">
8686
<photon-camera-stream
87-
v-show="value.includes(0)"
87+
v-if="value.includes(0)"
8888
id="input-camera-stream"
8989
stream-type="Raw"
9090
style="max-width: 100%"
9191
/>
9292
</div>
9393
<div class="stream">
9494
<photon-camera-stream
95-
v-show="value.includes(1)"
95+
v-if="value.includes(1)"
9696
id="output-camera-stream"
9797
stream-type="Processed"
9898
style="max-width: 100%"
@@ -149,6 +149,7 @@ th {
149149
.stream {
150150
display: flex;
151151
justify-content: center;
152+
width: 100%;
152153
}
153154
154155
@media only screen and (min-width: 960px) {

photon-client/src/components/dashboard/CamerasCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ const performanceRecommendation = computed<string>(() => {
8181
</v-row>
8282
<v-divider style="border-color: white" />
8383
<v-row class="stream-viewer-container pa-3">
84-
<v-col v-show="value.includes(0)" class="stream-view">
84+
<v-col v-if="value.includes(0)" class="stream-view">
8585
<photon-camera-stream id="input-camera-stream" stream-type="Raw" style="width: 100%; height: auto" />
8686
</v-col>
87-
<v-col v-show="value.includes(1)" class="stream-view">
87+
<v-col v-if="value.includes(1)" class="stream-view">
8888
<photon-camera-stream id="output-camera-stream" stream-type="Processed" style="width: 100%; height: auto" />
8989
</v-col>
9090
</v-row>

0 commit comments

Comments
 (0)