我正在使用 CIDetector 进行面部检测(结合 YOLO 框架进行身体检测)。
在设置我使用的 videoCapturevideoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = .portrait
以便 YOLO 框架可以工作时,但这会立即破坏面部检测,因为它返回的坐标非常疯狂。
我知道 faceDetector 有一个 CIDetectorImageOrientation 选项,即:
let imageOptions: NSDictionary = [CIDetectorImageOrientation: NSNumber(value: exifOrientation), CIDetectorSmile: false, CIDetectorEyeBlink: false]
faces = faceDetector.features(in: ciImage, options: imageOptions as? [String : Any])
我已经尝试了所有 8 个枚举值,CIDetectorImageOrientation
而videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = .portrait
面部检测器仍然只吐出最疯狂的坐标。
为了澄清起见,面部检测在videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation
保留为默认值时工作得很好(我认为它是风景左边?)。
似乎CIDetector
又videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = .portrait
不能和睦相处。
我的问题是,我是否缺少一些可以使 CIDetector 工作的东西videoOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = .portrait
?