|
@@ -253,42 +253,41 @@
|
|
|
let ctx = uni.createCanvasContext('cvs', this);
|
|
let ctx = uni.createCanvasContext('cvs', this);
|
|
|
// let ctx = this.$refs.canvas.getContext("2d");
|
|
// let ctx = this.$refs.canvas.getContext("2d");
|
|
|
const _this = this
|
|
const _this = this
|
|
|
- // this.intervalTakeImg = setInterval(() => {
|
|
|
|
|
-
|
|
|
|
|
- // }, 4000)
|
|
|
|
|
- // 把当前视频帧内容渲染到canvas上
|
|
|
|
|
- // ctx.drawImage(document.createElement('canvas'), 0, 0, 520, 520);
|
|
|
|
|
- // 修改后代码 将 html2Cvs 修改为 (window.html2Cvs || html2Cvs)
|
|
|
|
|
- html2Cvs(document.querySelector('video'), {
|
|
|
|
|
- backgroundColor: null,
|
|
|
|
|
- useCORS: true
|
|
|
|
|
- }).then(cvs => {
|
|
|
|
|
- let imgData = cvs.toDataURL('image/png')
|
|
|
|
|
- this.faceImgData = imgData
|
|
|
|
|
- // this.type = 2
|
|
|
|
|
- this.faceRecognition()
|
|
|
|
|
- // this.intervalTakeImg = null
|
|
|
|
|
- // clearInterval(this.intervalTakeImg)
|
|
|
|
|
- // ctx.drawImage(imgData, 0, 0, 520, 520);
|
|
|
|
|
- })
|
|
|
|
|
- // 转base64格式、图片格式转换、图片质量压缩
|
|
|
|
|
- // console.log('canvas', document.createElement('canvas').toDataURL("image/jpeg", 0.7))
|
|
|
|
|
- // return
|
|
|
|
|
- let imgBase64 = document.createElement('canvas').toDataURL("image/jpeg", 0.7); // 由字节转换为KB 判断大小
|
|
|
|
|
- // let imgBase64 = this.$refs["canvas"].toDataURL("image/jpeg", 0.7); // 由字节转换为KB 判断大小
|
|
|
|
|
- // console.log('canver', this.$refs["canvas"])
|
|
|
|
|
-
|
|
|
|
|
- // console.log('%cHealthEduOnline.vue line:92 imgBase64', 'color: white; background-color: #26bfa5;', imgBase64);
|
|
|
|
|
- let str = imgBase64.replace("data:image/jpeg;base64,", "");
|
|
|
|
|
- let strLength = str.length;
|
|
|
|
|
- let fileLength = parseInt(strLength - (strLength / 8) * 2); // 图片尺寸 用于判断
|
|
|
|
|
- let size = (fileLength / 1024).toFixed(2);
|
|
|
|
|
- console.log(size); // 上传拍照信息 调用接口上传图片 .........
|
|
|
|
|
-
|
|
|
|
|
- // 保存到本地
|
|
|
|
|
- this.dialogCamera = false;
|
|
|
|
|
- // this.faceRecognition()
|
|
|
|
|
- clearInterval(this.intervalTakeImg)
|
|
|
|
|
|
|
+ this.intervalTakeImg = setInterval(() => {
|
|
|
|
|
+ // 把当前视频帧内容渲染到canvas上
|
|
|
|
|
+ // ctx.drawImage(document.createElement('canvas'), 0, 0, 520, 520);
|
|
|
|
|
+ // 修改后代码 将 html2Cvs 修改为 (window.html2Cvs || html2Cvs)
|
|
|
|
|
+ html2Cvs(document.querySelector('video'), {
|
|
|
|
|
+ backgroundColor: null,
|
|
|
|
|
+ useCORS: true
|
|
|
|
|
+ }).then(cvs => {
|
|
|
|
|
+ let imgData = cvs.toDataURL('image/png')
|
|
|
|
|
+ this.faceImgData = imgData
|
|
|
|
|
+ // this.type = 2
|
|
|
|
|
+ this.faceRecognition()
|
|
|
|
|
+ // this.intervalTakeImg = null
|
|
|
|
|
+ // clearInterval(this.intervalTakeImg)
|
|
|
|
|
+ // ctx.drawImage(imgData, 0, 0, 520, 520);
|
|
|
|
|
+ })
|
|
|
|
|
+ // 转base64格式、图片格式转换、图片质量压缩
|
|
|
|
|
+ // console.log('canvas', document.createElement('canvas').toDataURL("image/jpeg", 0.7))
|
|
|
|
|
+ // return
|
|
|
|
|
+ let imgBase64 = document.createElement('canvas').toDataURL("image/jpeg", 0.7); // 由字节转换为KB 判断大小
|
|
|
|
|
+ // let imgBase64 = this.$refs["canvas"].toDataURL("image/jpeg", 0.7); // 由字节转换为KB 判断大小
|
|
|
|
|
+ // console.log('canver', this.$refs["canvas"])
|
|
|
|
|
+
|
|
|
|
|
+ // console.log('%cHealthEduOnline.vue line:92 imgBase64', 'color: white; background-color: #26bfa5;', imgBase64);
|
|
|
|
|
+ let str = imgBase64.replace("data:image/jpeg;base64,", "");
|
|
|
|
|
+ let strLength = str.length;
|
|
|
|
|
+ let fileLength = parseInt(strLength - (strLength / 8) * 2); // 图片尺寸 用于判断
|
|
|
|
|
+ let size = (fileLength / 1024).toFixed(2);
|
|
|
|
|
+ console.log(size); // 上传拍照信息 调用接口上传图片 .........
|
|
|
|
|
+
|
|
|
|
|
+ // 保存到本地
|
|
|
|
|
+ this.dialogCamera = false;
|
|
|
|
|
+ // this.faceRecognition()
|
|
|
|
|
+ clearInterval(this.intervalTakeImg)
|
|
|
|
|
+ }, 4000)
|
|
|
// let ADOM = document.createElement("a");
|
|
// let ADOM = document.createElement("a");
|
|
|
// ADOM.href = imgBase64 ;
|
|
// ADOM.href = imgBase64 ;
|
|
|
// ADOM.download = new Date().getTime() + ".jpeg";
|
|
// ADOM.download = new Date().getTime() + ".jpeg";
|
|
@@ -315,18 +314,24 @@
|
|
|
this.name = res.data[0].name
|
|
this.name = res.data[0].name
|
|
|
this.getBasics()
|
|
this.getBasics()
|
|
|
this.closeCamera()
|
|
this.closeCamera()
|
|
|
- if(this.intervalTakeImg){
|
|
|
|
|
- this.show = false
|
|
|
|
|
- clearInterval(this.intervalTakeImg)
|
|
|
|
|
- this.intervalTakeImg = null
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if(this.intervalTakeImg){
|
|
|
|
|
+ // this.show = false
|
|
|
|
|
+ // clearInterval(this.intervalTakeImg)
|
|
|
|
|
+ // this.intervalTakeImg = null
|
|
|
|
|
+ // }
|
|
|
// clearInterval(this.intervalTakeImg)
|
|
// clearInterval(this.intervalTakeImg)
|
|
|
|
|
+ this.show = false
|
|
|
|
|
+ clearInterval(this.intervalTakeImg)
|
|
|
|
|
+ this.intervalTakeImg = null
|
|
|
return
|
|
return
|
|
|
}else{
|
|
}else{
|
|
|
// this.toAdd(res.data[0].name)
|
|
// this.toAdd(res.data[0].name)
|
|
|
console.log('w')
|
|
console.log('w')
|
|
|
this.type = 3
|
|
this.type = 3
|
|
|
this.closeCamera()
|
|
this.closeCamera()
|
|
|
|
|
+ this.show = false
|
|
|
|
|
+ clearInterval(this.intervalTakeImg)
|
|
|
|
|
+ this.intervalTakeImg = null
|
|
|
|
|
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|