2

我正在使用 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()
4

2 回答 2

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

exposure你想要的价值在哪里

理想情况下,您应该查询CONTROL_AE_COMPENSATION_RANGE为 设置有效值exposure

于 2019-10-25T15:00:30.463 回答
1

CameraX 1.0.0-beta09增加了一个实验接口ExposureCompensation

您可以通过以下方式设置曝光:

val camera = cameraProvider.bindToLifecycle(viewLifecycleOwner, cameraSelector, preview, imageCapture)
val cameraControl = camera.cameraControl
cameraControl.setExposureCompensationIndex(exposure)
于 2020-09-19T13:11:12.143 回答