我正在开发一款面部识别应用。其中一个步骤包括检测用户微笑。为此,我目前正在使用谷歌的 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/