I\'m trying to implement the built-in iOS 5 face detection API. I\'m using an instance of UIImagePickerController
to allow the user to take a photo and then I\'
Swift 3 Version
var exifOrientation : Int
switch (inputImage.imageOrientation)
{
case UIImageOrientation.up:
exifOrientation = 1;
case UIImageOrientation.down:
exifOrientation = 3;
case UIImageOrientation.left:
exifOrientation = 8;
case UIImageOrientation.right:
exifOrientation = 6;
case UIImageOrientation.upMirrored:
exifOrientation = 2;
case UIImageOrientation.downMirrored:
exifOrientation = 4;
case UIImageOrientation.leftMirrored:
exifOrientation = 5;
case UIImageOrientation.rightMirrored:
exifOrientation = 7;
}
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, options:["CIDetectorImageOrientation":exifOrientation])