[英]How to set Exposure compensation in Camera X support library?
我正在使用 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()
其中exposure
是您想要的價值
理想情況下,您應該查詢CONTROL_AE_COMPENSATION_RANGE
以設置exposure
的有效值。
CameraX 1.0.0-beta09為ExposureCompensation
添加了實驗性接口
您可以通過以下方式設置曝光:
val camera = cameraProvider.bindToLifecycle(viewLifecycleOwner, cameraSelector, preview, imageCapture)
val cameraControl = camera.cameraControl
cameraControl.setExposureCompensationIndex(exposure)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.