简体   繁体   English

机器学习套件人脸识别不适用于 IOS

[英]ML kit face recognition not working on IOS

I'm working on an app that does facial recognition.我正在开发一个可以进行面部识别的应用程序。 One of the steps include detecting the user smile.步骤之一包括检测用户微笑。 For that, I am currently using google's Ml Kit.为此,我目前正在使用谷歌的 Ml Kit。 The application works fine on Android platform but when I run on Ios (Iphone Xr and others) it does not recognize any faces on any image.该应用程序在 Android 平台上运行良好,但当我在 Ios(Iphone Xr 和其他)上运行时,它无法识别任何图像上的任何面孔。 I have already followed every steps on how to integrate Ios and Firebase and it runs fine.我已经遵循了如何集成 Ios 和 Firebase 的每个步骤,并且运行良好。

Here's my code.这是我的代码。 It's always falling on length == 0, as the image would not contain any faces.它总是落在 length == 0 上,因为图像不包含任何人脸。 The image passed as parameter is coming from the image_picker plugin.作为参数传递的图像来自 image_picker 插件。

Future<Face> verifyFace(File thisImage) async {
  var beforeTime = new DateTime.now();
  final image = FirebaseVisionImage.fromFile(thisImage);
  final faceDetector = FirebaseVision.instance.faceDetector(
    FaceDetectorOptions(
      mode: FaceDetectorMode.accurate,
      enableClassification: true,
    ),
  );

  var processedImages = await faceDetector.processImage(image);
  print('Processing time: ' +
      DateTime.now().difference(beforeTime).inMilliseconds.toString());

  if (processedImages.length == 0) {
    throw new NoFacesDetectedException();
  } else if (processedImages.length == 1) {
    Face face = processedImages.first;
    if(face.smilingProbability == null){
      throw new LipsNotFoundException();
    }
    else {
      return face;
    }
  } else if (processedImages.length > 1) {
    throw new TooManyFacesDetectedException();
  }
}

If someone has any tips or can tell what I am doing wrong I would be very grateful.如果有人有任何提示或可以告诉我做错了什么,我将不胜感激。

我知道这是一个老问题,但我遇到了同样的问题,结果我忘了在pod 'Firebase/MLVisionFaceModel'添加pod 'Firebase/MLVisionFaceModel'

there is configuration in some many places so i will better left you this video (although maybe you already see it) so you can see some code and how Matt Sullivan make that one you are trying to do.在很多地方都有配置,所以我最好把这个视频留给你(尽管你可能已经看过了),这样你就可以看到一些代码以及 Matt Sullivan 如何制作你正在尝试做的代码。

let met know if you already see it and please add maybe an example repo i could work with so see you exact code.如果您已经看到它,请让我知道,请添加一个我可以使用的示例存储库,以便查看您的确切代码。

From what I can tell, ML Kit face detection does work on iOS but very poorly.据我所知,ML Kit 人脸检测在 iOS 上确实有效,但效果很差。 It doesn't even seem worth it to use the SDK.使用 SDK 似乎也不值得。

The docs do say that the face itself must be at least 100x100px.文档确实说面部本身必须至少为 100x100 像素。 In my testing though the face itself needs to be at least 700px for the SDK to detect the face.在我的测试中,虽然人脸本身至少需要 700 像素才能让 SDK 检测到人脸。

The SDK on Android works super well even on small image sizes (200x200px in total).即使在小图像尺寸(总共 200x200 像素)上,Android 上的 SDK 也能很好地工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM