Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

ios - ML Kit face detection front camera not working

Why doesn't the following code detect a face with the front camera?

@objc private func finishButtonPressed() {
    
    let userVerificationPicture = userVerificationPictureImageView.image!
    let options = FaceDetectorOptions()

    options.performanceMode = .accurate

    let faceDetector = FaceDetector.faceDetector(options: options)
    let visionImage = VisionImage(image: userVerificationPicture)

    visionImage.orientation = userVerificationPicture.imageOrientation
    
    faceDetector.process(visionImage) { faces, error in
        
        guard error == nil, let faces = faces, !faces.isEmpty else {
            return
        }
        
        for face in faces {
            // faces array is always empty with front camera
            print(face)
        }
    }
}

I am following the documentation here using a UIImage:

https://developers.google.com/ml-kit/vision/face-detection/ios

And the code above will detect a face when the back camera is used every time, but never with the front camera. Why is it not working? I am following the documentation exactly as it says.

question from:https://stackoverflow.com/questions/65647760/ml-kit-face-detection-front-camera-not-working

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...