1

I am creating a iOS app that uses the Firebase ML Kit Face Detection and I am trying to allow users to take a photo from their camera and check if there was a face in it. So I have followed the documentation and some youtube videos but it seems that it just doesn't work properly/accurately for me. I did some testing using a photo library not just pictures that I take, and what I found is it works well when I use selfies from google, but when I take my own selfies it never seems to work. I noticed when I take a selfie on my camera it does like a "mirror" kind of thing where it flips it, but I even took a picture of my friend using the front facing camera and it still didn't work. So I am not sure if I implemented this wrong, or what is going on. I have attached some of the relevant code to show how it was implemented. Thanks to anyone who takes the time to help out, I am a novice at iOS development so hopefully this isn't a waste of your time.

    func photoVerification(){
        let options = VisionFaceDetectorOptions()
        let vision = Vision.vision()
        let faceDetector = vision.faceDetector(options: options)
        let image = VisionImage(image: image_one.image!)
        faceDetector.process(image) { (faces, error) in
            guard error == nil, let faces = faces, !faces.isEmpty else{
                //No face detected provide error on image
                print("No face detected!")
                self.markImage(isVerified: false)
                return
            }
            //Face Has been detected Offer Verified Tag to user
            print("Face detected!")
            self.markImage(isVerified: true)
        }

    }
Wana_B3_Nerd
  • 613
  • 3
  • 7
  • 21
  • I am facing the same problem. Did you find any solution or other APIs which can do the same? – tensor Apr 15 '20 at 14:34
  • I was able to fix it, it was due to the images that were being passed in not being oriented correctly. So debug it by printing the orientation of your images that you are about to pass in. If that is the issue I can send you some code I used to fix the orientation before passed it through the ML function – Wana_B3_Nerd Apr 16 '20 at 18:13
  • Hi, I am using it for Android and it would be good if you can send some code because it flips the image as soon as I take a selfie and the exact two images are not matched. – tensor Apr 17 '20 at 06:40
  • Just for the record, this thread might be related and helpful: https://stackoverflow.com/questions/61149127/ensuring-image-data-is-correctly-oriented-on-ios-app-in-swift-5 – Julie Zhou May 13 '20 at 00:26

0 Answers0