CIDetector doesn't work in portrait mode

178 Views Asked by At

I am using CIDetector for facial detection (in conjunction with the YOLO framework for body detection).

When setting up the videoCapture I use videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = .portrait so that the YOLO framework will work, but this immediately breaks the facial detection in that the coordinates it returns are just crazy.

I am aware that the faceDetector has a CIDetectorImageOrientation option, i.e.:

let imageOptions: NSDictionary = [CIDetectorImageOrientation: NSNumber(value: exifOrientation), CIDetectorSmile: false, CIDetectorEyeBlink: false] faces = faceDetector.features(in: ciImage, options: imageOptions as? [String : Any])

I have tried all 8 enumerated values for CIDetectorImageOrientation in conjunction with videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = .portrait and the face detector still spits out just the craziest coordinates.

For clarification, facial detection works just fine when videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation is left to be it's default value (I think it's landscape left?).

It seems CIDetector and videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = .portrait can't live in harmony.

My question is, is there something I'm missing that will make CIDetector work with videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = .portrait?

0

There are 0 best solutions below