ios - ML 套件人脸识别不适用于 IOS

标签 ios flutter dart firebase-mlkit

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

这是我的代码。它总是落在 length == 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();
  }
}

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

最佳答案

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

关于ios - ML 套件人脸识别不适用于 IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57011891/

相关文章:

iPhone 应用程序 - fork 或创建新版本?

ios - 我需要未知元素的最高约束

dart - VSCode Dart 导入快捷方式

c++ - 使 Flutter C/C++ 互操作示例工作

flutter - 如何在 flutter 中从该列表中导入文本

iOS - 在不使用 CLLocationManager 的情况下确定用户的国家

iphone - 如果 friend 在应用程序中的进度还不足以到达 installInvitationHandler 方法,如何处理游戏中心邀请?

dart - 该类没有默认构造函数

dart - 如何获取抽象类中字段的默认值

dart - 我如何在 travis ci 部署上发布 dart pub