Swift代码" captureOutput()"方法不检测面孔

时间:2015-12-29 06:42:46

标签: ios swift face-detection

请告诉我在此代码中是否有任何错误。

  faceDetectorOptions  = [CIDetectorAccuracy: CIDetectorAccuracyLow]
    faceDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: faceDetectorOptions )

    let pixelBuffer : CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)!
    let attachments : CFDictionaryRef  = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, sampleBuffer, CMAttachmentMode(kCMAttachmentMode_ShouldPropagate))!
    let ciImage     : CIImage   = CIImage(CVPixelBuffer: pixelBuffer, options: attachments as? [String : AnyObject])


     let imageOptions = [CIDetectorSmile : true, CIDetectorEyeBlink : true , CIDetectorImageOrientation : 6 ]
    let features = faceDetector.featuresInImage(ciImage, options: imageOptions)

我无法检测到任何面孔,它可能会起作用。 任何建议将不胜感激!

0 个答案:

没有答案