From e639d361fff683d5fbead361ec4ddba6a7374bf0 Mon Sep 17 00:00:00 2001
From: hanbaoshan <hanbaoshan@aiotlink.com>
Date: 星期三, 09 九月 2020 09:23:34 +0800
Subject: [PATCH] 同步处理批量添加摄像机结果,实时监控区域比例调整,解决线条虚化的问题
---
src/components/LeftNav.vue | 27 ++++----
src/components/player/index.vue | 94 +++++++++++++------------------
2 files changed, 53 insertions(+), 68 deletions(-)
diff --git a/src/components/LeftNav.vue b/src/components/LeftNav.vue
index 98e72a4..2ef7e0d 100644
--- a/src/components/LeftNav.vue
+++ b/src/components/LeftNav.vue
@@ -548,7 +548,7 @@
let succeed = 0;
let failed = 0;
-
+ let promiseArr = [];
for (let item in sheetArray) {
let camera = this.newCamera();
camera.areaid = this.importAreaId;
@@ -556,26 +556,27 @@
camera.rtsp = String(sheetArray[item].rtsp);
camera.addr = String(sheetArray[item].addr);
- createCamera(camera).then(rsp => {
- if (rsp && rsp.success) {
+ promiseArr.push(createCamera(camera));
+ }
+ let _this = this;
+ Promise.allSettled(promiseArr).then(res=>{
+ res.forEach(item=>{
+ if(item.status === 'fulfilled'){
succeed++;
- } else {
+ }else{
failed++;
}
- }).catch(err => {
- failed++;
- })
- }
-
- let _this = this
- setTimeout(() => {
- this.menuLoading = false;
+ });
+ _this.menuLoading = false;
_this.$message({
type: "success",
message: "鎿嶄綔瀹屾垚, 瀵煎叆鎴愬姛:" + succeed + "涓� 澶辫触:" + failed + "涓�"
})
_this.TreeDataPool.fetchTreeData();
- }, 2000)
+ }).catch(e=>{
+ console.log(e)
+ });
+
}
} catch (e) {
this.menuLoading = false
diff --git a/src/components/player/index.vue b/src/components/player/index.vue
index 1d8e80b..6d1c004 100644
--- a/src/components/player/index.vue
+++ b/src/components/player/index.vue
@@ -1,6 +1,6 @@
<template>
<div class="video-player">
- <canvas id="area-canvas" ref="areaCanvas" ></canvas>
+ <canvas id="area-canvas" ref="areaCanvas" :width="canvasWidth" :height="canvasHeight"></canvas>
<video ref="videoPlayer" :poster="poster" preload="auto" muted></video>
<div class="controls">
<!-- 鍏ㄥ睆 -->
@@ -62,10 +62,14 @@
arrow: [],
polygon: []
},
- showProportion: 3.2,
- showProportionY: 3.58,
+ //showProportion: 3.2,
+ //showProportionY: 3.58,
+ showProportion: 1.036,
+ showProportionY: 1.039,
canvas: null,
- ctx: null
+ ctx: null,
+ canvasWidth: 0,
+ canvasHeight: 0,
};
},
watch: {
@@ -171,11 +175,11 @@
_this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion);
_this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion);
_this.ctx.stroke();
- _this.showRemarks(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion,
- v.name
- );
+ // _this.showRemarks(
+ // v.location[0].x / _this.showProportion,
+ // v.location[0].y / _this.showProportion,
+ // v.name
+ // );
_this.canvas.style.cursor = "default";
if (e && _this.ctx.isPointInStroke(e.offsetX, e.offsetY)) {
// 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
@@ -207,11 +211,11 @@
_this.ctx.lineTo(v.location[3].x / _this.showProportion, v.location[3].y / _this.showProportion);
_this.ctx.lineTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion);
_this.ctx.stroke();
- _this.showRemarks(
- v.location[0].x / _this.showProportion,
- v.location[0].y / _this.showProportion,
- v.name
- );
+ // _this.showRemarks(
+ // v.location[0].x / _this.showProportion,
+ // v.location[0].y / _this.showProportion,
+ // v.name
+ // );
_this.canvas.style.cursor = "default";
if (e && _this.ctx.isPointInPath(e.offsetX, e.offsetY)) {
// 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
@@ -301,11 +305,11 @@
}
_this.ctx.closePath();
_this.ctx.stroke();
- _this.showRemarks(
- v.location[v.location.length - 1].x / _this.showProportion,
- v.location[v.location.length - 1].y / _this.showProportionY,
- v.name
- );
+ // _this.showRemarks(
+ // v.location[v.location.length - 1].x / _this.showProportion,
+ // v.location[v.location.length - 1].y / _this.showProportionY,
+ // v.name
+ // );
_this.canvas.style.cursor = "default";
if (e && _this.ctx.isPointInPath(e.offsetX, e.offsetY)) {
// 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
@@ -349,27 +353,9 @@
this.Camera.getCameraTask();
});
},
- async initCanvas(id){
-
- //this.canvas = document.querySelector("#area-canvas");
- this.canvas = this.$refs.areaCanvas;
- this.ctx = this.canvas.getContext("2d");
-
- // this.Camera.getPolygon();x:758,y:280
- // console.log(this.Camera.canvasData);
- const rsp = await getAllPolygon({ cameraId: id });
- debugger
- if (rsp && rsp.success) {
- this.canvasData = {
- line: rsp.data.line,
- arrow: rsp.data.arrow,
- polygon: [{id:'uuid', name: '澶氳竟褰�1', location: [{ x: 735, y: 155 }, { x: 830, y: 156 }, { x: 809, y: 351 }, { x: 809, y: 364 }, { x: 753, y: 396 }, { x: 755, y: 520 },{ x: 706, y: 524 },{ x: 722, y: 392 },{x:758,y:280},{ x: 735, y: 155 }] }],
- //rect: rsp.data.rect
- rect: [{id:'uuid', name: '鐭╁舰1', location: [{ x: 20, y: 30 }, { x: 20, y: 60 }, { x: 100, y: 60 }, { x: 100, y: 30 }] }]
- };
- }
- debugger
- this.clickSelect(this.canvasData);
+ setWidthHeight(){
+ this.canvasWidth = this.$refs.videoPlayer.offsetWidth;
+ this.canvasHeight = this.$refs.videoPlayer.offsetHeight;
},
async initArea(){
console.log('init')
@@ -391,13 +377,19 @@
},
mounted() {
this.clickStart();
+ //鑾峰彇video瀹介珮骞剁粰鍖哄煙canvas璧嬪��
+ this.setWidthHeight();
+ window.addEventListener('resize',()=>{
+ //this.setWidthHeight();
+ //this.initArea();
+ });
this.$nextTick(()=>{
this.canvas = this.$refs.areaCanvas;
this.ctx = this.canvas.getContext("2d");
this.ctx.lineWidth = 1;
-
- this.initArea()
-
+
+ this.initArea();
+
})
},
beforeDestroy() {
@@ -409,23 +401,15 @@
<style lang="scss">
#area-canvas{
- width: 100%;
- height: 100%;
background: transparent;
position: absolute;
top: 0;
left: 0;
+ padding: 0;
+ width: 100%;
+ height: 100%;
}
-// .cavas{
-// width: 100%;
-// height: 100%;
-// position: absolute;
-// top: 0;
-// left: 0;
-// canvas{
-// background: transparent!important;
-// }
-// }
+
video {
object-fit: fill;
width: 100%;
--
Gitblit v1.8.0