CameraX 相当于 Camera2 的 CaptureRequest

CameraX equivalent of Camera2's CaptureRequest

我想在 CameraX 上使用 ImageAnalysis,但要调整一些相机设置,例如自动对焦或自动白平衡、曝光和帧持续时间。

这是我需要的设置示例以及我如何使用 Camera2 设置它们:

    captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF)
    captureRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_OFF)
    captureRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, FRAME_DURATION_NS)
    captureRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, EXPOSURE_TIME_LIMIT_NS)

我怎样才能 "translate" 把它传给 CameraX?

有自定义CaptureRequest参数的Camera2InterOp。示例:

fun buildImageAnalysis() : ImageAnalysis {
    val builder = ImageAnalysis.Builder()
    val camera2InterOp = Camera2Interop.Extender(builder)
    camera2InterOp.setCaptureRequestOption(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF)
    camera2InterOp.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_OFF)
    camera2InterOp.setCaptureRequestOption(CaptureRequest.SENSOR_FRAME_DURATION, FRAME_DURATION_NS);
    camera2InterOp.setCaptureRequestOption(CaptureRequest.SENSOR_EXPOSURE_TIME, EXPOSURE_TIME_LIMIT_NS)
    return builder.build()
}