zengyicheng há 4 anos atrás
pai
commit
2c1c541a35
1 ficheiros alterados com 26 adições e 19 exclusões
  1. 26 19
      src/components/function.vue

+ 26 - 19
src/components/function.vue

@@ -92,15 +92,16 @@ export default {
       ],
       isCamera: false,
       count: 0,
+      number: 0,
       isdetected: "请您保持脸部在画面中央",
       videoEl: {},
       canvasEL: {},
       // 预设样本图,支持本地,网络,beas64
       sampleArr: [
-        // {
-        //   name: "编号1",
-        //   img: []
-        // }
+        {
+          name: "编号1",
+          img: []
+        }
       ],
       // 匹配图,支持本地,网络,beas64
       detArr: [
@@ -187,6 +188,12 @@ export default {
       console.log(size); // 上传拍照信息  调用接口上传图片 .........
 
       this.detArr.push(imgBase64);
+      var json = {name:"",img:[]};
+      json.name = "编号:" + this.number++;
+      json.img.push(imgBase64);
+      this.sampleArr.push(json);
+      this.fnInit()
+      // this.resultArr.push(imgBase64);
 
       // 保存到本地
       // this.isCamera = false;
@@ -219,20 +226,20 @@ export default {
       // 加载模型
       await faceapi.loadFaceRecognitionModel("/static/models");
       // 生成人脸匹配矩阵数组对象,样本图片同步转码
-      const labeledFaceDescriptors = await Promise.all(
-        this.sampleArr.map(async item => {
-          // 临时图片转码数据,将图片对象转数据矩阵对象
-          let descriptors = [];
-          for (let image of item.img) {
-            const imageEl = await faceapi.fetchImage(image);
-            descriptors.push(await faceapi.computeFaceDescriptor(imageEl));
-          }
-          // 返回图片用户和图片转码数组
-          return new faceapi.LabeledFaceDescriptors(item.name, descriptors);
-        })
-      );
-      // 人脸匹配矩阵数组对象转码结果
-      this.faceMatcher = new faceapi.FaceMatcher(labeledFaceDescriptors);
+      // const labeledFaceDescriptors = await Promise.all(
+      //   this.sampleArr.map(async item => {
+      //     // 临时图片转码数据,将图片对象转数据矩阵对象
+      //     let descriptors = [];
+      //     for (let image of item.img) {
+      //       const imageEl = await faceapi.fetchImage(image);
+      //       descriptors.push(await faceapi.computeFaceDescriptor(imageEl));
+      //     }
+      //     // 返回图片用户和图片转码数组
+      //     return new faceapi.LabeledFaceDescriptors(item.name, descriptors);
+      //   })
+      // );
+      // // 人脸匹配矩阵数组对象转码结果
+      // this.faceMatcher = new faceapi.FaceMatcher(labeledFaceDescriptors);
     },
     // 执行遍历识别匹配图片,数值误差越小越精确
     fnRun() {
@@ -289,7 +296,7 @@ export default {
     // document.head.appendChild(_s1);
     // console.log(this.$store.state.function);
     this.$nextTick(() => {
-      this.fnInit().then(() => this.fnRun());
+      // this.fnInit().then(() => this.fnRun());
     });
 
     if (this.$store.state.function.indexOf("screen=1;") != -1) {