gpt4 book ai didi

android - 如何在Camera X支持库中设置曝光补偿?

转载 作者:行者123 更新时间:2023-11-30 05:02:42 27 4
gpt4 key购买 nike

我正在使用 CameraX 库单击照片并想要更改曝光设置。如何设置曝光补偿或更改拍摄照片的曝光设置?

// Set up the capture use case to allow users to take photos
val imageCaptureConfig = ImageCaptureConfig.Builder().apply {
setLensFacing(lensFacing)
setCaptureMode(CaptureMode.MIN_LATENCY)
// We request aspect ratio but no resolution to match preview config but letting
// CameraX optimize for whatever specific resolution best fits requested capture mode
setTargetAspectRatio(screenAspectRatio)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
setTargetRotation(viewFinder.display.rotation)
}.build()


imageCapture = ImageCapture(imageCaptureConfig)

// Setup image analysis pipeline that computes average pixel luminance in real time
val analyzerConfig = ImageAnalysisConfig.Builder().apply {
setLensFacing(lensFacing)
// Use a worker thread for image analysis to prevent preview glitches
setCallbackHandler(Handler(analyzerThread.looper))
// In our analysis, we care more about the latest image than analyzing *every* image
setImageReaderMode(ImageAnalysis.ImageReaderMode.ACQUIRE_LATEST_IMAGE)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
setTargetRotation(viewFinder.display.rotation)
}.build()

最佳答案

val imageCaptureBuilder = ImageCapture.Builder().apply {
setLensFacing(lensFacing)
setCaptureMode(CaptureMode.MIN_LATENCY)
// We request aspect ratio but no resolution to match preview config but letting
// CameraX optimize for whatever specific resolution best fits requested capture mode
setTargetAspectRatio(screenAspectRatio)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
setTargetRotation(viewFinder.display.rotation)
}

Camera2Interop.Extender(imageCaptureBuilder).setCaptureRequestOption(
CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, exposure)

imageCapture = imageCaptureBuilder.build()

其中曝光是您想要的值

理想情况下,您应该查询CONTROL_AE_COMPENSATION_RANGE来设置曝光的有效值。

关于android - 如何在Camera X支持库中设置曝光补偿?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57951781/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com