0
이 코드를 사용하여 CIFaceDetector를 통해 이미지의 얼굴을 감지하고 싶습니다.이미지 방향으로 인해 이미지에서 얼굴을 감지 할 수 없습니다.
let Orientation: Int!
switch ((info[UIImagePickerControllerOriginalImage] as? UIImage)?.imageOrientation)! {
case UIImageOrientation.up:
Orientation = 1
case UIImageOrientation.down:
Orientation = 3
case UIImageOrientation.left:
Orientation = 8
case UIImageOrientation.right:
Orientation = 6
case UIImageOrientation.upMirrored:
Orientation = 2
case UIImageOrientation.downMirrored:
Orientation = 4
case UIImageOrientation.leftMirrored:
Orientation = 5
case UIImageOrientation.rightMirrored:
Orientation = 7
}
let options = [CIDetectorAccuracy: CIDetectorAccuracyHigh, CIDetectorImageOrientation: Orientation] as [String : Any]
let faceDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: options)
let faces = faceDetector?.features(in: personciImage)
그러나 가로 방향에서만 작동합니다. 왜 다른 모든 방향에서 작동하지 않는지 나는 모른다. 나는 방향이 올바르게 설정되어야 함을 의미합니다. 나는 UIImage를 CIImage에 캐스팅합니다.
guard let personciImage = CIImage(image: (info[UIImagePickerControllerOriginalImage] as? UIImage)!) else {
return
}
문제가 있습니까?