ios - swift : CoreImage Face Detection will Detect Every round object as a Face

标签 ios swift4 core-image

在我的应用程序中,我想对 UIImage 使用人脸检测,所以我使用库中的 CoreImage 构建(我知道 Vision Library 也是最新的人脸检测库。但它仅支持 ios 11.0 及以上)。该库工作正常,直到我注意到任何具有圆形表面的图像都会被检测为人脸,即使它不是。

这是我的代码:

func checkFaceDetection(image: UIImage) -> Bool {
        var isFace = false
        let personciImage = CIImage(image: image)

        let accuracy = [CIDetectorAccuracy: CIDetectorAccuracyHigh]
        let faceDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: accuracy)
        let faces = faceDetector?.features(in: personciImage!)

        if let face = faces?.first as? CIFaceFeature {
            print("Found face at \(face.bounds)")
            if face.hasLeftEyePosition && face.hasRightEyePosition && face.hasMouthPosition && face.hasFaceAngle{
                isFace = true
            }else{
                isFace = false
            }
        }
        return isFace
    }

即使我用左眼、右眼、嘴巴和脸角过滤该图像,它仍然无法解决我的问题。

最佳答案

您可以将 CIDetectorAccuracyHigh 更改为 Low。它会更有用

关于ios - swift : CoreImage Face Detection will Detect Every round object as a Face,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52179617/

相关文章:

ios - Swift 3 - 为什么我的导航栏不显示?

ios - 导出视频 Assets 时出现未知异常

ios - Swift - 使用 Codeable 保存对象会导致应用程序崩溃

ios - 如何将多个 UITextFields 放入 Swift 4 的一个字符串中?

ios - CIImage 的平均颜色......更快的方法

ios - 一个 CIImage 中有多个 CIFilter?

ios - 下载存储在RAM中?

android - 将 TypeScript 与 HTML5 iOS 应用程序的专有属性结合使用

swift - 应用程序崩溃相机设备后部 : Terminated due to memory issue

cocoa - CILanczosScaleTransform 后出现奇怪的现象