With VNImageRequestHandler
we ned to pass CVImageBuffer
.
Which is basically the output of AVCaptureVideoDataOutput
with a specific videoSetting.
override func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {N
.........
let imageRequestHandler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: exifOrientation, options: [:])
......
}
Question 1:
Does it have to be kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
or it can be kCVPixelFormatType_32BGRA
?
videoDataOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)]
Question 2: In case it allows 32BGRA , then when to use kCVPixelFormatType_32BGRA
and how does the VNImageRequestHandler
differentiate between YCBCR and 32BGRA for best and efficient image identification ?