Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在Camera X support library中设置曝光补偿?_Android_Kotlin_Camera_Android Camera2_Android Camerax - Fatal编程技术网

Android 如何在Camera X support library中设置曝光补偿?

Android 如何在Camera X support library中设置曝光补偿?,android,kotlin,camera,android-camera2,android-camerax,Android,Kotlin,Camera,Android Camera2,Android Camerax,我正在使用CameraX库单击照片,希望更改曝光设置。如何设置曝光补偿或更改拍摄图片的曝光设置 // Set up the capture use case to allow users to take photos val imageCaptureConfig = ImageCaptureConfig.Builder().apply { setLensFacing(lensFacing) setCaptureMode(CaptureMode.MIN_LATENCY) /

我正在使用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 camera = cameraProvider.bindToLifecycle(viewLifecycleOwner, cameraSelector, preview, imageCapture)
val cameraControl = camera.cameraControl
cameraControl.setExposureCompensationIndex(exposure)
val camera = cameraProvider.bindToLifecycle(viewLifecycleOwner, cameraSelector, preview, imageCapture)
val cameraControl = camera.cameraControl
cameraControl.setExposureCompensationIndex(exposure)