|
@@ -3,7 +3,7 @@
|
|
|
<video id="video" ref="video" :width="width" :height="height" autoplay>
|
|
|
</video>
|
|
|
<div v-if="showRecognizeButton" style="position: absolute; width: 400px; text-align: center; margin-top: -50px; color: #232323;">
|
|
|
- <span class="verify-button" @click="snap">开始识别</span>
|
|
|
+ <span class="verify-button" @click="snap">{{msg}}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -17,7 +17,7 @@ import { UPYUN_URL } from "../../constants/constants.js";
|
|
|
export default {
|
|
|
name: "FaceRecognition",
|
|
|
data() {
|
|
|
- return { hide: true };
|
|
|
+ return { hide: true, msg: "开始识别" };
|
|
|
},
|
|
|
props: {
|
|
|
width: String,
|
|
@@ -60,7 +60,7 @@ export default {
|
|
|
try {
|
|
|
console.log("启动摄像头");
|
|
|
const stream = await navigator.mediaDevices.getUserMedia({
|
|
|
- video: { facingMode: "user" }
|
|
|
+ video: { facingMode: "user", width: 400, height: 300 }
|
|
|
});
|
|
|
|
|
|
video.srcObject = stream;
|
|
@@ -83,8 +83,11 @@ export default {
|
|
|
video && video.play();
|
|
|
},
|
|
|
async snap() {
|
|
|
+ this.msg = "拍照中...";
|
|
|
const captureBlob = await this.getSnapShot();
|
|
|
+ this.msg = "上传照片中...";
|
|
|
const [, captureFilePath] = await this.uploadToServer(captureBlob);
|
|
|
+ this.msg = "人脸比对中...";
|
|
|
await this.faceCompareSync(UPYUN_URL + captureFilePath);
|
|
|
const video = this.$refs.video;
|
|
|
video && video.play();
|