如何查询解释 RAW_SENSOR 图像所需的信息?

How do I query the information needed to interpret a RAW_SENSOR image?

我需要编写一个 Android 应用程序,除其他外,它使用 Camera2 API 以 RAW 格式捕获图像并在应用程序中处理生成的图像数据。 YUV 等其他图像格式不足以满足我的用例,需要真正的 RAW 图像。我想捕获图像并立即在内存中处理它,而不写出中间 .dng 文件。

为此,我需要使用 ImageFormat.RAW_SENSOR 来获取我想要的图像。 The documentation for RAW_SENSOR 声明如下:

The layout of the color mosaic, the maximum and minimum encoding values of the raw pixel data, the color space of the image, and all other needed information to interpret a raw sensor image must be queried from the android.hardware.camera2.CameraDevice which produced the image.

但是,CameraDevice 的文档不包含任何关于查询此信息的内容。 Google 搜索没有任何帮助。我发现 的答案只是引用了我上面引用的内容,并没有帮助弄清楚如何实际去做。

于是我迷路了。如何查询这些信息?

Android 的 RAW 支持在很大程度上取决于 Adobe DNG raw file format 的要求,因此阅读该规范可能会有所帮助,以了解 RAW 转换的实际步骤。

CameraCharacteristics and CaptureResult 对象中的相当多的字段需要解释原始缓冲区。大多数以 SENSOR_ 开头的字段都是处理所必需的。

也请参阅 RAW capability 的列表,尽管这仍然相当模糊。

Android 合规性测试包括一个 very simple RAW processor,因此您也可以检查它以查看它读取的内容。