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

问题描述

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

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 06:12