VNImageRequestHandler
我们必须通过CVImageBuffer
。
这基本上是AVCaptureVideoDataOutput
具有特定视频设置的输出。
override func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {N
.........
let imageRequestHandler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: exifOrientation, options: [:])
......
}
问题1:必须是kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
还是可以kCVPixelFormatType_32BGRA
?
videoDataOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)]
问题 2:如果它允许 32BGRA,那么何时使用kCVPixelFormatType_32BGRA
以及如何VNImageRequestHandler
区分 YCBCR 和 32BGRA 以实现最佳和高效的图像识别?