From 5a4a777d03f8dc1ac009024c7d42fd676c60d96d Mon Sep 17 00:00:00 2001 From: rucky Date: Tue, 28 Dec 2021 18:20:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3ios=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/index/HandTrack/index.vue | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/page/index/HandTrack/index.vue b/src/page/index/HandTrack/index.vue index 809a26b..2ee0383 100644 --- a/src/page/index/HandTrack/index.vue +++ b/src/page/index/HandTrack/index.vue @@ -260,12 +260,16 @@ export default { const videoTracks = stream.getVideoTracks(); this.stream = stream; // make variable available to browser console let streamSize = this.GetStreamDimensions(stream); - // let handledSize = this.ScaleResolutionToHeight( - // streamSize, - // window.innerHeight - // ); - // this.videoRealSize = handledSize; + // 设置视频 + this.responseVideoAndCanvas(); + + let handledSize = this.ScaleResolutionToWidth( + { width: this.video.width, height: this.video.height }, + window.innerWidth + ); + + this.videoRealSize = handledSize; console.log("Got stream with constraints:", constraints); console.log(`Using video device: ${videoTracks[0].label}`); @@ -277,10 +281,9 @@ export default { // handledSize ); - // this.responseVideoAndCanvas(handledSize); this.video.srcObject = stream; - // this.video.play(); + this.video.play(); // 开始识别 this.startDraw(); @@ -291,13 +294,12 @@ export default { }, // 视频设置 responseVideoAndCanvas(size) { - this.video.width = size.width; - this.video.height = size.height; - + this.video.width = window.innerWidth; + this.video.height = window.innerHeight; // init canvcas this.ctx = this.canvas.getContext("2d"); - this.canvas.width = size.width; - this.canvas.height = size.height; + this.canvas.width = window.innerWidth; + this.canvas.height = window.innerHeight; }, // 获得stream大小 GetStreamDimensions(stream) { @@ -540,8 +542,8 @@ export default { align-content: center; align-items: center; .video { - // .paLayout(50%,50%,auto,100%,0); - // transform: translate(-50%, -50%); + .paLayout(50%,50%,auto,100%,0); + transform: translate(-50%, -50%); // transform: scaleX(-1); // width: 750px; display: none;