【问题标题】:Core Image Face Detector No Result核心图像人脸检测器无结果
【发布时间】:2021-06-18 23:35:18
【问题描述】:

我正在尝试使用 CIDetector 检测图像中的人脸

但似乎没有任何效果。

代码如下:

if let inputImage = UIImage(named: "taylor-swift") {
    let ciImage = CIImage(cgImage: inputImage.cgImage!)

    let options = [CIDetectorAccuracy: CIDetectorAccuracyHigh]
    let faceDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: options)!

    let faces = faceDetector.features(in: ciImage)

    if let face = faces.first as? CIFaceFeature {
        print("Found face at \(face.bounds)")

        if face.hasLeftEyePosition {
            print("Found left eye at \(face.leftEyePosition)")
        }

        if face.hasRightEyePosition {
            print("Found right eye at \(face.rightEyePosition)")
        }

        if face.hasMouthPosition {
            print("Found mouth at \(face.mouthPosition)")
        }
    }
}

我已经测试了这些图片:

【问题讨论】:

    标签: ios swift objective-c core-image cidetector


    【解决方案1】:

    这是因为我在模拟器上运行它。它可以在设备上正常运行。

    注意,这也适用于Vision 框架

    【讨论】:

      猜你喜欢
      • 2018-12-31
      • 2013-10-01
      • 2019-12-01
      • 1970-01-01
      • 2020-07-23
      • 2010-11-10
      • 1970-01-01
      • 2013-11-14
      • 2011-11-11
      相关资源
      最近更新 更多