chenyc
2025-05-29 92f69c57b920cf62ecc9f15f9ed196fa26dbf2ac
app.js.js
File was renamed from app.js
@@ -90,14 +90,20 @@
       // 调整图像大小
      const resizedImage = faceapi.resizeResults(img, { width: 600, height: 600 });
       // 设置检测选项
      const options = new faceapi.SsdMobilenetv1Options({ minConfidence: 0.3 });
      const options = new faceapi.SsdMobilenetv1Options({ minConfidence: 0.6 });
      counter = (i / images.length) * 100;
      console.log(`Progress = ${counter}%`);
      // Read each face and save the face descriptions in the descriptions array
      const detections = await faceapi.detectSingleFace(resizedImage,options).withFaceLandmarks().withFaceDescriptor();
      if(detections?.descriptor){
      console.log('kankan ================')
      console.log('kankan ================')
      console.log('kankan ================')
      console.log(detections===undefined)
      if(detections&&detections.descriptor){
        descriptions.push(detections.descriptor);
        imgs.push(images[i])
      }else{
        return '录入失败';
      }
      
    }
@@ -112,6 +118,9 @@
      descriptions: descriptions,
      images:imgs
    });
    console.log(label)
    console.log(descriptions)
    console.log(imgs)
    try{
      await createFace.save();
      console.log('人脸录入成功!')
@@ -165,14 +174,15 @@
  }
  // 加载面匹配器以查找匹配面
  const faceMatcher = new faceapi.FaceMatcher(faces, 0.5);
  const faceMatcher = new faceapi.FaceMatcher(faces, 0.48);
  // 使用画布或其他方法读取图像
  const img = await canvas.loadImage(image);
  // // 调整图像大小
  // const resizedImage = faceapi.resizeResults(img, { width: 600, height: 600 });
  // // 设置检测选项
  const options = new faceapi.SsdMobilenetv1Options({ minConfidence: 0.3 });
  // // 设置检测选项 味着只有当人脸检测的置信度大于或等于0.3时,该检测结果才会被接受。换句话说,如果模型认为检测到的对象是人脸的确定性低于30%,
  //则不会将这个检测结果包含在最终输出中。这有助于减少误报(即错误地将非人脸区域识别为人脸的情况)。
  const options = new faceapi.SsdMobilenetv1Options({ minConfidence: 0.4 });
  let temp = faceapi.createCanvasFromMedia(img);
  // 处理模型的图像