| | |
| | | default: false |
| | | } |
| | | }, |
| | | |
| | | computed: { |
| | | |
| | | computed: { |
| | | poster() { |
| | | return "/images/player/player_poster.gif?t=" + Math.random() |
| | | } |
| | |
| | | ctx: null, |
| | | canvasWidth: 0, |
| | | canvasHeight: 0, |
| | | algoDataSocket: null |
| | | }; |
| | | }, |
| | | watch: { |
| | |
| | | if (newVal !== oldVal) { |
| | | if (this.wfs.config) { |
| | | this.wfs.destroy(); |
| | | !!this.algoDataSocket && this.algoDataSocket.close() |
| | | } |
| | | this.$nextTick(() => { |
| | | this.clickStart(); |
| | |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.clickStart(); |
| | | this.$nextTick(() => { |
| | | this.canvas = this.$refs.areaCanvas; |
| | | this.ctx = this.canvas.getContext("2d"); |
| | | this.ctx.lineWidth = 1; |
| | | this.initArea(); |
| | | |
| | | }) |
| | | }, |
| | | beforeDestroy() { |
| | | this.wfs.destroy(); |
| | | this.wfsId = ""; |
| | | |
| | | !!this.algoDataSocket && this.algoDataSocket.close() |
| | | }, |
| | | methods: { |
| | | checkConnect(id) { |
| | | // console.log(this.wfs) |
| | | if (id !== this.wfsId) { |
| | | return |
| | | } |
| | | |
| | | |
| | | if (this.wfs.websocketLoader && this.wfs.websocketLoader.client) { |
| | | if (this.wfs.websocketLoader.client.disconnected) { |
| | | this.clickStart(); |
| | |
| | | _this.ctx.lineTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion); |
| | | _this.ctx.stroke(); |
| | | _this.canvas.style.cursor = "default"; |
| | | |
| | | |
| | | }); |
| | | _this.canvasData.arrow.forEach(function (v, i) { |
| | | _this.ctx.strokeStyle = "yellow"; |
| | |
| | | 20, |
| | | 30, |
| | | "yellow" |
| | | ); |
| | | ); |
| | | _this.canvas.style.cursor = "default"; |
| | | |
| | | |
| | | }); |
| | | _this.canvasData.polygon.forEach(function (v, i) { |
| | | if (v.location.length === 0) { |
| | |
| | | _this.ctx.closePath(); |
| | | _this.ctx.stroke(); |
| | | _this.canvas.style.cursor = "default"; |
| | | |
| | | |
| | | }); |
| | | }, |
| | | |
| | | |
| | | // 箭头绘制函数 |
| | | drawArrow(ctx, fromX, fromY, toX, toY, theta=30, headlen=10, width=1, color="yellow") { |
| | | drawArrow(ctx, fromX, fromY, toX, toY, theta = 30, headlen = 10, width = 1, color = "yellow") { |
| | | // ctx:Canvas绘图环境 |
| | | // fromX, fromY:起点坐标(也可以换成p1,只不过它是一个数组) |
| | | // toX, toY:终点坐标 (也可以换成p2,只不过它是一个数组) |
| | |
| | | ctx.stroke(); |
| | | ctx.restore(); |
| | | }, |
| | | |
| | | |
| | | // 回显图形备注 |
| | | showRemarks(x, y, remarks) { |
| | | this.ctx.moveTo(x, y - 10); // 因为放大之后是y-20,所以缩小版的为y-10 |
| | |
| | | this.Camera.getCameraTask(); |
| | | }); |
| | | }, |
| | | setWidthHeight(){ |
| | | setWidthHeight() { |
| | | this.canvasWidth = this.$refs.videoPlayer.offsetWidth; |
| | | this.canvasHeight = this.$refs.videoPlayer.offsetHeight; |
| | | console.log(this.canvasWidth,this.canvasHeight) |
| | | console.log(this.canvasWidth, this.canvasHeight) |
| | | }, |
| | | async initArea(){ |
| | | async initArea() { |
| | | console.log('init') |
| | | const res = await getAllPolygon({cameraId: this.TreeDataPool.selectedNode.id}); |
| | | const res = await getAllPolygon({ cameraId: this.TreeDataPool.selectedNode.id }); |
| | | this.canvasData.line = res.data.line; |
| | | this.canvasData.rect = res.data.rect; |
| | | this.canvasData.arrow = res.data.arrow; |
| | | this.canvasData.polygon = res.data.polygon; |
| | | console.log(this.canvasData) |
| | | this.clickSelect(this.canvasData); |
| | | }, |
| | | initAlgoDataWebScoket() { |
| | | if (typeof (WebSocket) === "undefined") { |
| | | console.log("error,您的浏览器不支持socket") |
| | | } else { |
| | | this.algoDataSocket = new WebSocket() |
| | | this.algoDataSocket.onopen = () => { |
| | | console.log("socket连接成功") |
| | | } |
| | | this.algoDataSocket.onerror = () => { |
| | | console.log("连接错误") |
| | | } |
| | | this.algoDataSocket.onmessage = msg => { |
| | | console.log(msg) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.clickStart(); |
| | | this.$nextTick(()=>{ |
| | | this.canvas = this.$refs.areaCanvas; |
| | | this.ctx = this.canvas.getContext("2d"); |
| | | this.ctx.lineWidth = 1; |
| | | this.initArea(); |
| | | |
| | | }) |
| | | }, |
| | | beforeDestroy() { |
| | | this.wfs.destroy(); |
| | | this.wfsId = ""; |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | #area-canvas{ |
| | | #area-canvas { |
| | | background: transparent; |
| | | position: absolute; |
| | | top: 0; |