From 270e7443a1e4b8993918347f8094e38cc15cc861 Mon Sep 17 00:00:00 2001
From: hanbaoshan <hanbaoshan@aiotlink.com>
Date: 星期日, 06 九月 2020 19:03:45 +0800
Subject: [PATCH] 修复内存信息展示,实时监控视频区域展示测试
---
src/pages/cameraAccess/index/App.vue | 1
src/components/player/index.vue | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/pages/cameraAccess/components/SeparateRules.vue | 3
3 files changed, 234 insertions(+), 4 deletions(-)
diff --git a/src/components/player/index.vue b/src/components/player/index.vue
index 0f30b78..8a13ecd 100644
--- a/src/components/player/index.vue
+++ b/src/components/player/index.vue
@@ -1,5 +1,6 @@
<template>
<div class="video-player">
+ <canvas id="area-canvas" ></canvas>
<video ref="videoPlayer" :poster="poster" preload="auto" muted></video>
<div class="controls">
<!-- 鍏ㄥ睆 -->
@@ -9,7 +10,9 @@
</template>
<script>
import Wfs from "./wfs";
-
+import VideoRuleData from "@/Pool/VideoRuleData";
+import TreeDataPool from "@/Pool/TreeData";
+import { getAllPolygon } from "@/api/polygon";
export default {
name: "CameraPlayer",
props: {
@@ -47,10 +50,25 @@
data() {
return {
wfs: {},
- wfsId: 0
+ wfsId: 0,
+ Camera: new VideoRuleData(),
+ canvasData: {
+ line: [],
+ rect: [], // {id:'uuid', name: '鐭╁舰1', location: [{ x: 20, y: 30 }, { x: 20, y: 60 }, { x: 100, y: 60 }, { x: 100, y: 30 }] }
+ arrow: [],
+ polygon: []
+ },
+ showProportion: 1.71,
+ canvas: null,
+ ctx: null
};
},
watch: {
+ "TreeDataPool.selectedNode": function(node){
+ debugger;
+ this.initCanvas(node);
+
+ },
rtspUrl: function (newVal, oldVal) {
if (newVal !== oldVal) {
if (this.wfs.config) {
@@ -125,10 +143,214 @@
},
fullScreen() {
this.$refs.videoPlayer.webkitRequestFullScreen();
+ },
+ // 鍥炴樉cavas鏁版嵁
+ // 鐐瑰嚮閫変腑鍙樿壊 灏嗗綋鍓嶉〉闈㈡墍鏈夎矾寰勯噸缁樺垽鏂綋鍓嶉紶鏍囩殑鍧愭爣鍦ㄥ摢涓浘褰㈠唴 濡傛灉涓嶄紶鍧愭爣鍙傛暟灏辨槸鍥炴樉鐨勬柟娉�
+ clickSelect(e) {
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
+ let _this = this; // 闆嗗悎涓亶鍘嗛渶瑕佸皢this杞瓨涓�涓嬩娇鐢�
+ _this.canvasData.line.forEach(function (v, i) {
+ _this.ctx.strokeStyle = "yellow";
+ _this.ctx.beginPath();
+ _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.canvas.style.cursor = "default";
+ if (e && _this.ctx.isPointInStroke(e.offsetX, e.offsetY)) {
+ // 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
+ // 濡傛灉褰撳墠鐜瑕嗙洊浜嗚鍧愭爣锛屽氨灏嗗浘褰㈢殑index鏀惧埌鏁扮粍閲�
+ // 褰撻紶鏍囩Щ鍏ヤ箣鍚庡皢褰撳墠鐨勬ā寮忓垏鎹负閫変腑妯″紡
+ _this.type = "0";
+ _this.delCursor.type = "1";
+ _this.delCursor.index = i;
+ // 灏嗗綋鍓嶅厓绱犳爣绾�
+ _this.ctx.strokeStyle = "red";
+ _this.ctx.beginPath();
+ _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.canvas.style.cursor = "pointer";
+ }
+ });
+ _this.canvasData.rect.forEach(function (v, i) {
+ _this.ctx.strokeStyle = "yellow";
+ _this.ctx.beginPath();
+ _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.lineTo(v.location[2].x / _this.showProportion, v.location[2].y / _this.showProportion);
+ _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.canvas.style.cursor = "default";
+ if (e && _this.ctx.isPointInPath(e.offsetX, e.offsetY)) {
+ // 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
+ // 褰撻紶鏍囩Щ鍏ヤ箣鍚庡皢褰撳墠鐨勬ā寮忓垏鎹负閫変腑妯″紡
+ _this.type = "0";
+ _this.delCursor.type = "2";
+ _this.delCursor.index = i;
+ // 灏嗗綋鍓嶅厓绱犳爣绾�
+ _this.ctx.strokeStyle = "red";
+ _this.ctx.beginPath();
+ _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.lineTo(v.location[2].x / _this.showProportion, v.location[2].y / _this.showProportion);
+ _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.canvas.style.cursor = "pointer";
+ }
+ });
+ _this.canvasData.arrow.forEach(function (v, i) {
+ _this.ctx.strokeStyle = "yellow";
+ // _this.ctx.beginPath()
+ // _this.ctx.moveTo(v.location[0].x / 2, v.location[0].y / 2)
+ // _this.ctx.lineTo(v.location[1].x / 2, v.location[1].y / 2)
+ // _this.ctx.stroke()
+ _this.drawArrow(
+ _this.ctx,
+ v.location[0].x / _this.showProportion,
+ v.location[0].y / _this.showProportion,
+ v.location[1].x / _this.showProportion,
+ v.location[1].y / _this.showProportion,
+ 20,
+ 30,
+ "yellow"
+ ); // 缁樺埗鏂规硶
+ _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鍒ゆ柇涓�涓�
+ // 濡傛灉褰撳墠鐜瑕嗙洊浜嗚鍧愭爣锛屽氨灏嗗浘褰㈢殑index鏀惧埌鏁扮粍閲�
+ // 褰撻紶鏍囩Щ鍏ヤ箣鍚庡皢褰撳墠鐨勬ā寮忓垏鎹负閫変腑妯″紡
+ _this.type = "0";
+ _this.delCursor.type = "4";
+ _this.delCursor.index = i;
+ // 灏嗗綋鍓嶅厓绱犳爣绾�
+ _this.ctx.strokeStyle = "red";
+ // _this.ctx.beginPath()
+ // _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.drawArrow(
+ _this.ctx,
+ v.location[0].x / _this.showProportion,
+ v.location[0].y / _this.showProportion,
+ v.location[1].x / _this.showProportion,
+ v.location[1].y / _this.showProportion,
+ 20,
+ 30,
+ "red"
+ ); // 缁樺埗鏂规硶
+ _this.showRemarks(
+ v.location[0].x / _this.showProportion,
+ v.location[0].y / _this.showProportion,
+ v.name
+ );
+ _this.canvas.style.cursor = "pointer";
+ }
+ });
+ _this.canvasData.polygon.forEach(function (v, i) {
+ if (v.location.length === 0) {
+ return;
+ }
+ _this.ctx.strokeStyle = "yellow";
+ _this.ctx.beginPath();
+ _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion);
+ for (let i = 1; i < v.location.length; i++) {
+ _this.ctx.lineTo(v.location[i].x / _this.showProportion, v.location[i].y / _this.showProportion);
+ }
+ _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.showProportion,
+ v.name
+ );
+ _this.canvas.style.cursor = "default";
+ if (e && _this.ctx.isPointInPath(e.offsetX, e.offsetY)) {
+ // 濡傛灉浼犲叆浜嗕簨浠跺潗鏍囷紝灏辩敤isPointInStroke鍒ゆ柇涓�涓�
+ // 濡傛灉褰撳墠鐜瑕嗙洊浜嗚鍧愭爣锛屽氨灏嗗浘褰㈢殑index鏀惧埌鏁扮粍閲�
+ // 褰撻紶鏍囩Щ鍏ヤ箣鍚庡皢褰撳墠鐨勬ā寮忓垏鎹负閫変腑妯″紡
+ _this.type = "0";
+ _this.delCursor.type = "5";
+ _this.delCursor.index = i;
+ // 灏嗗綋鍓嶅厓绱犳爣绾�
+ _this.ctx.strokeStyle = "red";
+ _this.ctx.beginPath();
+ _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion);
+ for (let i = 1; i < v.location.length; i++) {
+ _this.ctx.lineTo(v.location[i].x / _this.showProportion, v.location[i].y / _this.showProportion);
+ }
+ _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.showProportion,
+ v.name
+ );
+ _this.canvas.style.cursor = "pointer";
+ }
+ });
+ },
+ // 鍥炴樉鍥惧舰澶囨敞
+ showRemarks(x, y, remarks) {
+ this.ctx.moveTo(x, y - 10); // 鍥犱负鏀惧ぇ涔嬪悗鏄痽-20锛屾墍浠ョ缉灏忕増鐨勪负y-10
+ this.ctx.fillStyle = "green"; // 璁剧疆濉厖棰滆壊涓虹豢鑹�
+ this.ctx.font = '10px "寰蒋闆呴粦"'; // 璁剧疆瀛椾綋
+ this.ctx.textBaseline = "bottom"; // 璁剧疆瀛椾綋搴曠嚎瀵归綈缁樺埗鍩虹嚎
+ this.ctx.textAlign = "left"; // 璁剧疆瀛椾綋瀵归綈鐨勬柟寮�
+ this.ctx.fillText(remarks, x, y - 10); // 濉厖鏂囧瓧
+ },
+
+ async initCanvas(id){
+
+ this.canvas = document.querySelector("#area-canvas");
+ this.ctx = this.canvas.getContext("2d");
+
+ // this.Camera.getPolygon();
+ // 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: rsp.data.polygon,
+ //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);
}
},
mounted() {
this.clickStart();
+
},
beforeDestroy() {
this.wfs.destroy();
@@ -138,6 +360,14 @@
</script>
<style lang="scss">
+#area-canvas{
+ width: 100%;
+ height: 100%;
+ background: transparent;
+ position: absolute;
+ top: 0;
+ left: 0;
+}
video {
object-fit: fill;
width: 100%;
diff --git a/src/pages/cameraAccess/components/SeparateRules.vue b/src/pages/cameraAccess/components/SeparateRules.vue
index 358ad1a..1faa16f 100644
--- a/src/pages/cameraAccess/components/SeparateRules.vue
+++ b/src/pages/cameraAccess/components/SeparateRules.vue
@@ -253,7 +253,8 @@
};
},
mounted() {
- this.mockAsync()
+ this.mockAsync();
+ this.PollData.statistics();
},
methods: {
diff --git a/src/pages/cameraAccess/index/App.vue b/src/pages/cameraAccess/index/App.vue
index 6a5120d..b83a14a 100644
--- a/src/pages/cameraAccess/index/App.vue
+++ b/src/pages/cameraAccess/index/App.vue
@@ -37,7 +37,6 @@
}
},
mounted() {
- debugger
this.screenHeight = document.documentElement.clientHeight;
window.onresize = () => {
return (() => {
--
Gitblit v1.8.0