ML 套件人脸识别在 IOS 上不起作用



我正在开发一个进行面部识别的应用程序。其中一个步骤包括检测用户的微笑。为此,我目前正在使用谷歌的Ml Kit。该应用程序在Android平台上运行良好,但是当我在Ios(iPhone Xr等(上运行时,它无法识别任何图像上的任何面孔。我已经遵循了有关如何集成ios和Firebase的每个步骤,并且运行良好。

这是我的代码。它总是落在长度 == 0 上,因为图像不包含任何面孔。作为参数传递的图像来自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();
  }
}

如果有人有任何提示或可以说出我做错了什么,我将不胜感激。

我知道

这是一个老问题,但我遇到了同样的问题,结果我只是忘记在 pod 文件中添加pod 'Firebase/MLVisionFaceModel'

很多地方都有配置,所以我最好把这个视频留给你(虽然你可能已经看到了(,这样你就可以看到一些代码以及Matt Sullivan如何制作你正在尝试做的那个。

如果您已经看到它,请让 met 知道,请添加我可以使用的示例存储库,以便查看确切的代码。

我所知,ML Kit人脸检测确实适用于iOS,但效果很差。使用SDK似乎也不值得。

文档确实说脸部本身必须至少为 100x100 像素。在我的测试中,虽然面部本身需要至少为 700px,但 SDK 才能检测到面部。

Android 上的 SDK 即使在小图像尺寸(总共 200x200 像素(上也能很好地工作。

最新更新