Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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. I have already followed every steps on how to integrate Ios and Firebase and it runs fine.

Here's my code. It's always falling on length == 0, as the image would not contain any faces. The image passed as parameter is coming from the image_picker plugin.

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.

like image 782
Léo Moraes Avatar asked Oct 15 '22 13:10

Léo Moraes


1 Answers

I know this is an old issue, but I was having the same problem and turns out I just forgot to add the pod 'Firebase/MLVisionFaceModel' in the podfile.

like image 197
joaortk Avatar answered Oct 18 '22 14:10

joaortk