Mat*_*iss 8 image-processing ios cvpixelbuffer
我正在使用AVCaptureSession&AVCapturePhotoOutput以格式从设备的相机捕获RAW照片数据kCVPixelFormatType_14Bayer_RGGB.
我已经获得了AVCapturePhotoCaptureDelegate回调中的原始照片样本缓冲区:
func capture(captureOutput: AVCapturePhotoOutput,
didFinishProcessingRawPhotoSampleBuffer rawSampleBuffer: CMSampleBuffer?,
previewPhotoSampleBuffer: CMSampleBuffer?,
resolvedSettings: AVCaptureResolvedPhotoSettings,
bracketSettings: AVCaptureBracketedStillImageSettings?,
error: Error?) {
guard let rawSampleBuffer = rawSampleBuffer else { return }
guard let pixelBuffer = CMSampleBufferGetImageBuffer(rawSampleBuffer) else { return }
}
Run Code Online (Sandbox Code Playgroud)
我现在正试图按照这个问题的答案来获取像素值,CVPixelBufferRef但是当使用14位拜耳RGGB像素格式而不是答案中提到的32位RGB格式时,我无法弄清楚如何做到这一点.
首先,您需要找出缓冲区的“像素格式类型”。这是通过CVPixelBufferGetPixelFormatType函数完成的。
此处列出了可用的类型。在你的情况下,我猜测kCVPixelFormatType_14Bayer_BGGR。
然后你需要知道数据是如何存储的。根据iOS 中的 CVPixelBuffer 是什么?这是
“Bayer 14 位 Little-Endian,打包为 16 位,订购 RGR G...与 GBG B 交替...”
然后,按照与 Swift 中从 CVPixelBufferRef 获取像素值中Uint16相同的方式提取像素。Uint8
| 归档时间: |
|
| 查看次数: |
554 次 |
| 最近记录: |