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

308 lines
13 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">
<CVselect v-if="isCameraNameEdit == false" name="Camera" v-model="currentCameraIndex" :list="cameraList" @input="handleInput('currentCamera',currentCameraIndex)"></CVselect>
<CVinput v-else name="Camera" v-model="newCameraName" @Enter="saveCameraNameChange" :errorMessage="checkCameraName"></CVinput>
2019-09-28 18:27:17 +03:00
</div>
</v-col>
2019-10-02 00:14:37 +03:00
<v-col :cols="1">
<CVicon color="#c5c5c5" v-if="isCameraNameEdit == false" hover text="edit" @click="toCameraNameChange" tooltip="Edit camera name"></CVicon>
<div v-else>
<CVicon color="#c5c5c5" style="display: inline-block;" hover text="save" @click="saveCameraNameChange" tooltip="Save Camera Name"></CVicon>
<CVicon color="error" style="display: inline-block;" hover text="close" @click="discardCameraNameChange" tooltip="Discard Changes"></CVicon>
</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">
<CVselect v-if="isPipelineEdit == false" name="Pipeline" :list="pipelineList" v-model="currentPipelineIndex" @input="handleInput('currentPipeline',currentPipelineIndex)"></CVselect>
<CVinput v-else name="Pipeline" v-model="newPipelineName" @Enter="savePipelineNameChange"></CVinput>
2019-09-28 18:27:17 +03:00
</v-col>
2019-10-02 00:14:37 +03:00
<v-col :cols="1" class="colsClass">
<v-menu v-if="isPipelineEdit == false" offset-y dark auto>
2019-10-02 00:14:37 +03:00
<template v-slot:activator="{ on }">
<v-icon color="white" v-on="on">menu</v-icon>
2019-10-02 00:14:37 +03:00
</template>
<v-list dense>
<v-list-item @click="toPipelineNameChange">
2019-10-02 00:14:37 +03:00
<v-list-item-title>
2019-10-10 22:40:51 +03:00
<CVicon color="#c5c5c5" :right="true" text="edit" tooltip="Edit pipeline name"></CVicon>
2019-10-02 00:14:37 +03:00
</v-list-item-title>
</v-list-item>
<v-list-item @click="handleInput('command','addNewPipeline')">
2019-10-02 00:14:37 +03:00
<v-list-item-title>
2019-10-10 22:40:51 +03:00
<CVicon color="#c5c5c5" :right="true" text="add" tooltip="Add new pipeline"></CVicon>
2019-10-02 00:14:37 +03:00
</v-list-item-title>
</v-list-item>
<v-list-item @click="deleteCurrentPipeline">
2019-10-02 00:14:37 +03:00
<v-list-item-title>
<CVicon color="red darken-2" :right="true" text="delete" tooltip="Delete pipeline"></CVicon>
</v-list-item-title>
</v-list-item>
<v-list-item @click="duplicateDialog = true">
2019-10-02 00:14:37 +03:00
<v-list-item-title>
2019-10-10 22:40:51 +03:00
<CVicon color="#c5c5c5" :right="true" text="mdi-content-copy" tooltip="Duplicate pipeline"></CVicon>
2019-10-02 00:14:37 +03:00
</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>
<CVicon color="error" style="display: inline-block;" hover text="close" @click="discardPipelineNameChange" tooltip="Discard Changes"></CVicon>
</div>
2019-09-28 18:27:17 +03:00
</v-col>
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">
<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">
<!-- vision component -->
2019-09-28 18:27:17 +03:00
<component v-model="pipeline" :is="selectedComponent"></component>
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-17 22:31:51 +03: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-10-10 22:40:51 +03:00
<img v-if="cameraList.length > 0" :src="steamAdress">
<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>
</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-21 20:34:47 +03:00
<CVselect name="Pipeline" :list="pipelineList" v-model="pipelineDuplicate.pipeline"></CVselect>
<v-checkbox v-if="cameraList.length > 1" dark :label="'To another camera'" v-model="anotherCamera"></v-checkbox>
2019-10-21 21:19:44 +03:00
<CVselect v-if="anotherCamera === true" name="Camera" v-model="pipelineDuplicate.camera" :list="cameraList"></CVselect>
</v-card-text>
<v-divider>
</v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="#4baf62" text @click="duplicatePipeline">Duplicate</v-btn>
<v-btn color="error" text @click="closeDuplicateDialog">Discard</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- snack bar -->
<v-snackbar :timeout="3000" v-model="snackbar" top color="error">
<span style="color:#000">Only one pipeline left</span>
<v-btn color="black" text @click="snackbar = false">Close</v-btn>
</v-snackbar>
2019-09-20 20:56:24 +03:00
</div>
</template>
<script>
2019-09-22 00:14:12 +03:00
import InputTab from './CameraViewes/InputTab'
import ThresholdTab from './CameraViewes/ThresholdTab'
import ContoursTab from './CameraViewes/ContoursTab'
import OutputTab from './CameraViewes/OutputTab'
2019-09-28 18:27:17 +03:00
import CVselect from '../components/cv-select'
2019-10-02 00:14:37 +03:00
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',
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
},
methods:{
test(value){
2019-10-11 01:18:14 +03:00
console.log(value)
},
toCameraNameChange(){
this.newCameraName = this.cameraList[this.currentCameraIndex];
this.isCameraNameEdit = true;
},
saveCameraNameChange(){
if(this.cameraNameError === ""){
this.handleInput("changeCameraName",this.newCameraName);
this.discardCameraNameChange();
}
},
discardCameraNameChange(){
this.isCameraNameEdit = false;
this.newCameraName = "";
},
toPipelineNameChange(){
this.newPipelineName = this.pipelineList[this.currentPipelineIndex];
this.isPipelineEdit = true;
},
savePipelineNameChange(){
this.handleInput("changePipelineName",this.newPipelineName);
this.discardPipelineNameChange();
},
discardPipelineNameChange(){
this.isPipelineEdit = false;
this.newPipelineName = "";
},
duplicatePipeline(){
2019-10-21 21:19:44 +03:00
if(!this.anotherCamera){
this.pipelineDuplicate.camera = -1
}
2019-10-19 17:45:40 +03:00
this.handleInput("duplicatePipeline",this.pipelineDuplicate);
this.closeDuplicateDialog();
},
closeDuplicateDialog(){
this.duplicateDialog = false;
this.pipelineDuplicate = {
pipeline:undefined,
2019-10-21 21:19:44 +03:00
camera:-1
}
},
deleteCurrentPipeline(){
if (this.pipelineList.length > 1) {
this.andleInput('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-09-22 00:14:12 +03:00
selectedTab:0,
// camera edit variables
isCameraNameEdit:false,
newCameraName:"",
cameraNameError:"",
// pipeline edit variables
isPipelineEdit:false,
newPipelineName:"",
duplicateDialog:false,
2019-10-21 21:19:44 +03:00
anotherCamera:false,
pipelineDuplicate:{
pipeline:undefined,
2019-10-21 21:19:44 +03:00
camera:-1
},
snackbar:false
2019-09-22 00:14:12 +03: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 ""
},
isBinaryNumber:{
get(){
return this.pipeline.isBinary ? 1:0
2019-10-17 22:31:51 +03:00
},
set(value){
this.pipeline.isBinary = !!value;
}
},
2019-10-10 22:40:51 +03:00
selectedComponent:{
get(){
switch(this.selectedTab){
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
},
point:{
get:function(){
let p = this.$store.state.point.calculated;
let fps = this.$store.state.point.fps;
2019-10-02 22:07:04 +03:00
if(p !== undefined){
return ("Pitch: " + parseFloat(p['pitch']).toFixed(2) + " Yaw: " + parseFloat(p['yaw']).toFixed(2) + " FPS: " + fps.toFixed(2))
2019-10-02 22:07:04 +03:00
} else{
return undefined;
}
}
},
currentCameraIndex:{
get(){
return this.$store.state.currentCameraIndex;
},
set(value){
this.$store.commit('currentCameraIndex',value);
2019-10-02 22:07:04 +03:00
}
},
currentPipelineIndex:{
get(){
return this.$store.state.currentPipelineIndex;
},
set(value){
this.$store.commit('currentPipelineIndex',value);
2019-10-02 22:07:04 +03:00
}
},
cameraList:{
get(){
return this.$store.state.cameraList;
}
},
pipelineList:{
get(){
return this.$store.state.pipelineList;
2019-10-02 22:07:04 +03:00
}
},
pipeline:{
get(){
return this.$store.state.pipeline;
}
},
steamAdress: {
get: function(){
return "http://"+location.hostname + ":"+ this.$store.state.port +"/stream.mjpg";
}
},
2019-09-20 20:56:24 +03:00
}
}
</script>
<style scoped>
.colsClass{
padding: 0 !important;
}
.videoClass{
2019-10-02 23:37:35 +03:00
text-align: center;
}
.videoClass img{
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-09-22 00:14:12 +03:00
#Point{
padding-top: 5px;
text-align: center;
color: #f4f4f4;
}
2019-09-20 20:56:24 +03:00
</style>