Files
PhotonVision/chameleon-client/src/views/Camera.vue

342 lines
14 KiB
Vue
Raw Normal View History

2019-09-20 20:56:24 +03:00
<template>
<div>
2019-09-28 18:27:17 +03:00
<div>
<v-row align="center">
<v-col :cols="3" class="colsClass">
<div style="padding-left:30px">
2019-10-26 23:41:45 +03:00
<CVselect v-if="isCameraNameEdit === false" name="Camera" v-model="currentCameraIndex"
:list="cameraList" @input="handleInput('currentCamera',currentCameraIndex)"/>
<CVinput v-else name="Camera" v-model="newCameraName" @Enter="saveCameraNameChange"
:errorMessage="checkCameraName"/>
2019-09-28 18:27:17 +03:00
</div>
</v-col>
2019-10-02 00:14:37 +03:00
<v-col :cols="1">
2019-10-26 23:41:45 +03:00
<CVicon color="#c5c5c5" v-if="isCameraNameEdit === false" hover text="edit"
@click="toCameraNameChange" tooltip="Edit camera name"/>
<div v-else>
2019-10-26 23:41:45 +03:00
<CVicon color="#c5c5c5" style="display: inline-block;" hover text="save"
@click="saveCameraNameChange" tooltip="Save Camera Name"/>
<CVicon color="error" style="display: inline-block;" hover text="close"
@click="discardCameraNameChange" tooltip="Discard Changes"/>
</div>
2019-10-02 00:14:37 +03:00
</v-col>
2019-09-28 18:27:17 +03:00
<v-col :cols="3" class="colsClass">
2019-10-26 23:41:45 +03:00
<CVselect v-if="isPipelineEdit === false" name="Pipeline" :list="pipelineList"
v-model="currentPipelineIndex"
@input="handleInput('currentPipeline',currentPipelineIndex)"/>
<CVinput v-else name="Pipeline" v-model="newPipelineName" @Enter="savePipelineNameChange"/>
2019-09-28 18:27:17 +03:00
</v-col>
2019-10-29 23:58:06 +02:00
<v-col :cols="1" class="colsClass" md="3">
<v-menu v-if="isPipelineEdit === false" offset-y dark auto>
<template v-slot:activator="{ on }">
<v-icon color="white" v-on="on">menu</v-icon>
</template>
<v-list dense>
<v-list-item @click="toPipelineNameChange">
<v-list-item-title>
<CVicon color="#c5c5c5" :right="true" text="edit" tooltip="Edit pipeline name"/>
</v-list-item-title>
</v-list-item>
<v-list-item @click="handleInput('command','addNewPipeline')">
<v-list-item-title>
<CVicon color="#c5c5c5" :right="true" text="add" tooltip="Add new pipeline"/>
</v-list-item-title>
</v-list-item>
<v-list-item @click="deleteCurrentPipeline">
<v-list-item-title>
<CVicon color="red darken-2" :right="true" text="delete"
tooltip="Delete pipeline"/>
</v-list-item-title>
</v-list-item>
<v-list-item @click="openDuplicateDialog">
<v-list-item-title>
<CVicon color="#c5c5c5" :right="true" text="mdi-content-copy"
tooltip="Duplicate pipeline"/>
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<div v-else>
<CVicon color="#c5c5c5" style="display: inline-block;" hover text="save"
@click="savePipelineNameChange" tooltip="Save Pipeline Name"/>
<CVicon color="error" style="display: inline-block;" hover text="close"
@click="discardPipelineNameChange" tooltip="Discard Changes"/>
</div>
2019-09-28 18:27:17 +03:00
</v-col>
2019-10-29 23:58:06 +02:00
<v-btn style="position: absolute; top:5px;right: 0;" tile color="#4baf62"
@click="handleInput('command','save')">
<v-icon>save</v-icon>
Save
</v-btn>
2019-09-28 18:27:17 +03:00
</v-row>
</div>
<v-row>
<!-- vision tabs -->
2019-09-20 20:56:24 +03:00
<v-col cols="6" class="colsClass">
2019-10-29 23:58:06 +02:00
<v-tabs fixed-tabs background-color="#212121" dark height="48" slider-color="#4baf62"
v-model="selectedTab">
2019-09-22 00:14:12 +03:00
<v-tab>Input</v-tab>
<v-tab>Threshold</v-tab>
<v-tab>Contours</v-tab>
<v-tab>Output</v-tab>
2019-09-20 20:56:24 +03:00
</v-tabs>
<div style="padding-left:30px">
2019-10-29 23:58:06 +02:00
<keep-alive>
<!-- vision component -->
2019-12-03 00:28:36 +02:00
<component v-model="pipeline" :is="selectedComponent" ref="component" @update="$emit('save')"/>
2019-10-29 23:58:06 +02:00
</keep-alive>
2019-09-20 20:56:24 +03:00
</div>
</v-col>
2019-09-28 18:27:17 +03:00
<v-col cols="6" class="colsClass">
2019-09-22 00:14:12 +03:00
<div>
<!-- camera image tabs -->
2019-10-29 23:58:06 +02:00
<v-tabs background-color="#212121" dark height="48" slider-color="#4baf62" centered
style="padding-bottom:10px" v-model="isBinaryNumber"
@change="handleInput('isBinary',pipeline.isBinary)">
2019-09-28 18:27:17 +03:00
<v-tab>Normal</v-tab>
<v-tab>Threshold</v-tab>
</v-tabs>
<!-- camera image stream -->
2019-10-02 23:37:35 +03:00
<div class="videoClass">
2019-12-03 00:28:36 +02:00
<img id="CameraStream" v-if="cameraList.length > 0" :src="streamAddress" @click="onImageClick" crossorigin="Anonymous"/>
2019-10-10 22:40:51 +03:00
<span v-else>No Cameras Are connected</span>
<h5 id="Point">{{point}}</h5>
2019-10-02 23:37:35 +03:00
</div>
2019-09-22 00:14:12 +03:00
</div>
2019-09-20 20:56:24 +03:00
</v-col>
2019-10-29 23:58:06 +02:00
</v-row>
<!-- pipeline duplicate dialog -->
<v-dialog dark v-model="duplicateDialog" width="500" height="357">
<v-card dark>
<v-card-title class="headline" primary-title>Duplicate Pipeline</v-card-title>
<v-card-text>
2019-10-26 23:41:45 +03:00
<CVselect name="Pipeline" :list="pipelineList" v-model="pipelineDuplicate.pipeline"/>
<v-checkbox v-if="cameraList.length > 1" dark :label="'To another camera'" v-model="anotherCamera"/>
<CVselect v-if="anotherCamera === true" name="Camera" v-model="pipelineDuplicate.camera"
:list="cameraList"/>
</v-card-text>
<v-divider>
</v-divider>
<v-card-actions>
2019-10-26 23:41:45 +03:00
<v-spacer/>
<v-btn color="#4baf62" text @click="duplicatePipeline">Duplicate</v-btn>
<v-btn color="error" text @click="closeDuplicateDialog">Cancels</v-btn>
</v-card-actions>
2019-10-29 23:58:06 +02:00
</v-card>
</v-dialog>
<!-- snack bar -->
<v-snackbar :timeout="3000" v-model="snackbar" top color="error">
<span style="color:#000">Can not remove the only pipeline!</span>
<v-btn color="black" text @click="snackbar = false">Close</v-btn>
2019-10-29 23:58:06 +02:00
</v-snackbar>
2019-09-20 20:56:24 +03:00
</div>
</template>
<script>
2019-10-29 23:58:06 +02:00
import InputTab from './CameraViewes/InputTab'
import ThresholdTab from './CameraViewes/ThresholdTab'
import ContoursTab from './CameraViewes/ContoursTab'
import OutputTab from './CameraViewes/OutputTab'
import CVselect from '../components/cv-select'
import CVicon from '../components/cv-icon'
import CVinput from '../components/cv-input'
2019-09-20 20:56:24 +03:00
export default {
2019-09-22 00:14:12 +03:00
name: 'CameraTab',
2019-10-29 23:58:06 +02:00
components: {
InputTab,
ThresholdTab,
ContoursTab,
2019-09-28 18:27:17 +03:00
OutputTab,
2019-10-02 00:14:37 +03:00
CVselect,
CVicon,
CVinput
2019-09-28 18:27:17 +03:00
},
2019-10-29 23:58:06 +02:00
methods: {
2019-12-03 00:28:36 +02:00
onImageClick(event){
this.$refs.component.onClick(event);
},
2019-10-29 23:58:06 +02:00
toCameraNameChange() {
this.newCameraName = this.cameraList[this.currentCameraIndex];
this.isCameraNameEdit = true;
},
2019-10-29 23:58:06 +02:00
saveCameraNameChange() {
if (this.cameraNameError === "") {
this.handleInput("changeCameraName", this.newCameraName);
this.discardCameraNameChange();
}
},
2019-10-29 23:58:06 +02:00
discardCameraNameChange() {
this.isCameraNameEdit = false;
this.newCameraName = "";
},
2019-10-29 23:58:06 +02:00
toPipelineNameChange() {
this.newPipelineName = this.pipelineList[this.currentPipelineIndex];
this.isPipelineEdit = true;
},
2019-10-29 23:58:06 +02:00
savePipelineNameChange() {
this.handleInput("changePipelineName", this.newPipelineName);
this.discardPipelineNameChange();
},
2019-10-29 23:58:06 +02:00
discardPipelineNameChange() {
this.isPipelineEdit = false;
this.newPipelineName = "";
},
2019-10-29 23:58:06 +02:00
duplicatePipeline() {
if (!this.anotherCamera) {
2019-10-21 21:19:44 +03:00
this.pipelineDuplicate.camera = -1
}
2019-10-29 23:58:06 +02:00
this.handleInput("duplicatePipeline", this.pipelineDuplicate);
this.closeDuplicateDialog();
},
2019-10-29 23:58:06 +02:00
openDuplicateDialog() {
this.pipelineDuplicate = {
2019-10-29 23:58:06 +02:00
pipeline: this.currentPipelineIndex,
camera: -1
};
this.duplicateDialog = true;
},
2019-10-29 23:58:06 +02:00
closeDuplicateDialog() {
this.duplicateDialog = false;
this.pipelineDuplicate = {
2019-10-29 23:58:06 +02:00
pipeline: undefined,
camera: -1
2019-10-21 21:19:44 +03:00
}
},
2019-10-29 23:58:06 +02:00
deleteCurrentPipeline() {
if (this.pipelineList.length > 1) {
2019-10-29 23:58:06 +02:00
this.handleInput('command', 'deleteCurrentPipeline');
} else {
this.snackbar = true;
}
2019-10-11 01:18:14 +03:00
}
2019-09-22 00:14:12 +03:00
},
2019-09-20 20:56:24 +03:00
data() {
return {
2019-10-29 23:58:06 +02:00
selectedTab: 1,
// camera edit variables
2019-10-29 23:58:06 +02:00
isCameraNameEdit: false,
newCameraName: "",
cameraNameError: "",
// pipeline edit variables
2019-10-29 23:58:06 +02:00
isPipelineEdit: false,
newPipelineName: "",
duplicateDialog: false,
anotherCamera: false,
pipelineDuplicate: {
pipeline: undefined,
camera: -1
},
2019-10-29 23:58:06 +02:00
snackbar: false,
2019-09-22 00:14:12 +03:00
}
},
2019-10-29 23:58:06 +02:00
computed: {
checkCameraName() {
if (this.newCameraName !== this.cameraList[this.currentCameraIndex]) {
for (let cam in this.cameraList) {
if (this.newCameraName === this.cameraList[cam]) {
return "Camera by that name already Exists"
}
}
}
return ""
},
2019-10-29 23:58:06 +02:00
isBinaryNumber: {
get() {
return this.pipeline.isBinary ? 1 : 0
2019-10-17 22:31:51 +03:00
},
2019-10-29 23:58:06 +02:00
set(value) {
2019-10-17 22:31:51 +03:00
this.pipeline.isBinary = !!value;
}
},
2019-10-29 23:58:06 +02:00
selectedComponent: {
get() {
switch (this.selectedTab) {
2019-10-10 22:40:51 +03:00
case 0:
return "InputTab";
case 1:
return "ThresholdTab";
case 2:
return "ContoursTab";
case 3:
return "OutputTab";
}
2019-10-10 23:58:27 +03:00
return "";
2019-09-22 00:14:12 +03:00
}
2019-10-02 22:07:04 +03:00
},
2019-10-29 23:58:06 +02:00
point: {
get: function () {
let p = this.$store.state.point.calculated;
let fps = this.$store.state.point.fps;
2019-10-29 23:58:06 +02:00
if (p !== undefined) {
return ("Pitch: " + parseFloat(p['pitch']).toFixed(2) + " Yaw: " + parseFloat(p['yaw']).toFixed(2) + " FPS: " + fps.toFixed(2))
2019-10-29 23:58:06 +02:00
} else {
2019-10-02 22:07:04 +03:00
return undefined;
}
}
},
2019-10-29 23:58:06 +02:00
currentCameraIndex: {
get() {
2019-10-02 22:07:04 +03:00
return this.$store.state.currentCameraIndex;
},
2019-10-29 23:58:06 +02:00
set(value) {
this.$store.commit('currentCameraIndex', value);
2019-10-02 22:07:04 +03:00
}
},
2019-10-29 23:58:06 +02:00
currentPipelineIndex: {
get() {
2019-10-02 22:07:04 +03:00
return this.$store.state.currentPipelineIndex;
},
2019-10-29 23:58:06 +02:00
set(value) {
this.$store.commit('currentPipelineIndex', value);
2019-10-02 22:07:04 +03:00
}
},
2019-10-29 23:58:06 +02:00
cameraList: {
get() {
2019-10-02 22:07:04 +03:00
return this.$store.state.cameraList;
}
},
2019-10-29 23:58:06 +02:00
pipelineList: {
get() {
return this.$store.state.pipelineList;
2019-10-02 22:07:04 +03:00
}
},
2019-10-29 23:58:06 +02:00
pipeline: {
get() {
2019-10-02 22:07:04 +03:00
return this.$store.state.pipeline;
}
},
2019-10-26 23:41:45 +03:00
streamAddress: {
2019-10-29 23:58:06 +02:00
get: function () {
return "http://" + location.hostname + ":" + this.$store.state.port + "/stream.mjpg";
2019-10-02 22:07:04 +03:00
}
},
2019-09-20 20:56:24 +03:00
}
}
</script>
<style scoped>
2019-10-29 23:58:06 +02:00
.colsClass {
2019-09-20 20:56:24 +03:00
padding: 0 !important;
2019-10-29 23:58:06 +02:00
2019-09-20 20:56:24 +03:00
}
2019-10-29 23:58:06 +02:00
.videoClass {
2019-10-02 23:37:35 +03:00
text-align: center;
}
2019-10-29 23:58:06 +02:00
.videoClass img {
2019-10-02 23:37:35 +03:00
height: auto !important;
width: 70%;
2019-10-02 23:37:35 +03:00
vertical-align: middle;
2019-09-20 20:56:24 +03:00
}
2019-10-29 23:58:06 +02:00
#Point {
2019-09-22 00:14:12 +03:00
padding-top: 5px;
text-align: center;
color: #f4f4f4;
}
2019-09-20 20:56:24 +03:00
</style>