本文介绍了CameraX相当于Camera2的CaptureRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在CameraX中使用 ImageAnalysis ,但是要调整一些Camera设置,例如自动对焦或自动白平衡,曝光和帧长。

I want to use ImageAnalysis with CameraX, but adjust some Camera settings such as auto-focus or auto-white balance, exposure and frame duration.

以下是我需要的设置以及如何使用Camera2进行设置的示例:

Here's an example of the settings I need and how I set them with 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)

如何将其翻译为CameraX?

How can I "translate" this to CameraX?

推荐答案

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

There is Camera2InterOp for customizing CaptureRequest parameters. Example:

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()
}

这篇关于CameraX相当于Camera2的CaptureRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 17:45