【问题标题】:Get RAW Bayer pixel data from CVPixelBufferRef从 CVPixelBufferRef 获取 RAW 拜耳像素数据
【发布时间】:2017-10-26 09:26:44
【问题描述】:

我正在使用AVCaptureSessionAVCapturePhotoOutput 从设备的相机中以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 }
}

我现在正在尝试按照this question 的答案从CVPixelBufferRef 获取像素值,但是当使用 14 位 Bayer RGGB 像素格式而不是 32 位 RGB 格式时,我无法弄清楚如何做到这一点答案中提到。

【问题讨论】:

  • 你找到答案了吗?
  • 我没有得到任何答案

标签: ios image-processing cvpixelbuffer


【解决方案1】:

首先你需要找出缓冲区的“像素格式类型”。这是通过CVPixelBufferGetPixelFormatType 函数完成的。

列出了可用的类型here。在你的情况下,我猜是kCVPixelFormatType_14Bayer_BGGR

然后你需要知道数据是如何存储的。根据What is a CVPixelBuffer in iOS?

“Bayer 14 位 Little-Endian,打包成 16 位,有序 R G R G... 与 G B G B...交替...”

然后您提取Uint16 的像素,方法与在Get pixel value from CVPixelBufferRef in Swift 中提取Uint8 的方式相同。

【讨论】:

    猜你喜欢
    • 2018-08-05
    • 2013-05-08
    • 2016-04-06
    • 2012-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-24
    相关资源
    最近更新 更多