camera2 像素值与传感器曝光时间不成线性关系
Posted
技术标签:
【中文标题】camera2 像素值与传感器曝光时间不成线性关系【英文标题】:camera2 pixel values not linear to sensor exposure time 【发布时间】:2020-11-19 02:58:03 【问题描述】:我尝试通过使用 YUV_420_888 图像格式的 camera2 API 近似原始传感器输出(我的索尼 XA1 不支持原始传感器)。我将所有内容都手动设置并停用了我能找到的所有更正程序:
mBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_OFF);
mBuilder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_OFF);
mBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF);
mBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_OFF);
mBuilder.set(CaptureRequest.TONEMAP_MODE, CameraMetadata.TONEMAP_MODE_CONTRAST_CURVE);
mBuilder.set(CaptureRequest.TONEMAP_CURVE,
new TonemapCurve(
new float[]0.0f,0.0f,1.0f,1.0f,
new float[]0.0f,0.0f,1.0f,1.0f,
new float[]0.0f,0.0f,1.0f,1.0f
));
mBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, CameraMetadata.COLOR_CORRECTION_MODE_TRANSFORM_MATRIX);
mBuilder.set(CaptureRequest.COLOR_CORRECTION_TRANSFORM, new ColorSpaceTransform(new int[]
1, 1, 0, 1, 0, 1,
0, 1, 1, 1, 0, 1,
0, 1, 0, 1, 1, 1
));
mBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, new RggbChannelVector(1.0f,1.0f,1.0f,1.0f));
mBuilder.set(CaptureRequest.SHADING_MODE, CameraMetadata.SHADING_MODE_OFF);
mBuilder.set(CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE, CameraMetadata.STATISTICS_LENS_SHADING_MAP_MODE_OFF);
mBuilder.set(CaptureRequest.COLOR_CORRECTION_ABERRATION_MODE, CameraMetadata.COLOR_CORRECTION_ABERRATION_MODE_OFF);
mBuilder.set(CaptureRequest.CONTROL_AE_ANTIBANDING_MODE, CameraMetadata.CONTROL_AE_ANTIBANDING_MODE_OFF);
mBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, CameraMetadata.CONTROL_EFFECT_MODE_OFF);
mBuilder.set(CaptureRequest.CONTROL_ENABLE_ZSL, false);
mBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_DISABLED);
mBuilder.set(CaptureRequest.EDGE_MODE, CameraMetadata.EDGE_MODE_OFF);
mBuilder.set(CaptureRequest.HOT_PIXEL_MODE, CameraMetadata.HOT_PIXEL_MODE_OFF);
mBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE, CameraMetadata.NOISE_REDUCTION_MODE_OFF);
在那之后,我连拍了 10 张照片,曝光时间线性增加,ISO 为 40。我分析了 Y 层(亮度分量)的值,发现它们的线性值仅高达 203(8位全范围 = 255)。与伽马校正曲线不同,203 处的过渡非常尖锐。
问题: 这是物理传感器效应,即像素饱和吗? 我是否忘记了管道中的一些非线性校正? camera2 API 是否对 YUV_420_888 使用全范围线性变换?
感谢您的帮助!
【问题讨论】:
【参考方案1】:测试了不同的 ISO 值 (100,400),非线性仍然存在。这不包括传感器的物理饱和。
但后来我测试了 RGB 值,这些值是线性的。有问题的 Y 值 >203 转换到 RGB [0,255] 范围之外。问题解决了,但是改造需要很多时间。
【讨论】:
以上是关于camera2 像素值与传感器曝光时间不成线性关系的主要内容,如果未能解决你的问题,请参考以下文章
Android camera2 曝光问题。在使用 YUV ImageReader 的情况下预览过度曝光
论文笔记---Deblurring Shaken and Partially Saturated Images