Using the following to detect faces in images:
var ciImage  = CIImage(CGImage:imageView.image!.CGImage)
var ciDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil,
  options: [
    CIDetectorAccuracy: CIDetectorAccuracyHigh,
    CIDetectorSmile: true,
    CIDetectorEyeBlink: true
  ])
var features = ciDetector.featuresInImage(ciImage)
for feature:CIFaceFeature in (features as! [CIFaceFeature]) {
   println("has smile: \(feature.hasSmile)")
}
I ran the former code on many images. hasSmile always returns false.
How do I have to configure face detection to detect smiles correctly?
A quick google search on "CIFaceDetector hasSmile" yields this link on Face Smiling and Blinking detection on iOS 7
It looks like you need to use a different form of the ciDetector.featuresInImage call. The code in Objective-C looks like this:
NSDictionary *options = @{ CIDetectorSmile: @(YES), CIDetectorEyeBlink: @(YES),};
NSArray *features = [detector featuresInImage:image options:options];
In Swift that would be something like this::
let options: [NSObject: AnyObject] = 
  [CIDetectorSmile: true, CIDetectorEyeBlink, true]
var features = ciDetector.featuresInImage(ciImage, options: options)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With