feat: Enable HDR extension for photo capture if available (#2162)

This commit is contained in:
Marc Rousavy 2023-11-15 18:39:56 +01:00 committed by GitHub
parent aad872bb9c
commit f24c00d4ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -466,6 +466,7 @@ class CameraSession(private val context: Context, private val cameraManager: Cam
val cameraCharacteristics = cameraManager.getCameraCharacteristics(captureSession.device.id)
val orientation = outputOrientation.toSensorRelativeOrientation(cameraCharacteristics)
val enableHdr = configuration?.photoHdr ?: false
val captureRequest = captureSession.device.createPhotoCaptureRequest(
cameraManager,
photoOutput.surface,
@ -474,6 +475,7 @@ class CameraSession(private val context: Context, private val cameraManager: Cam
flashMode,
enableRedEyeReduction,
enableAutoStabilization,
enableHdr,
orientation
)
Log.i(TAG, "Photo capture 1/3 - starting capture...")

View File

@ -30,6 +30,7 @@ fun CameraDevice.createPhotoCaptureRequest(
flashMode: Flash,
enableRedEyeReduction: Boolean,
enableAutoStabilization: Boolean,
enableHdr: Boolean,
orientation: Orientation
): CaptureRequest {
val cameraCharacteristics = cameraManager.getCameraCharacteristics(this.id)
@ -40,6 +41,7 @@ fun CameraDevice.createPhotoCaptureRequest(
CameraDevice.TEMPLATE_STILL_CAPTURE
}
val captureRequest = this.createCaptureRequest(template)
captureRequest.addTarget(surface)
// TODO: Maybe we can even expose that prop directly?
val jpegQuality = when (qualityPrioritization) {
@ -51,6 +53,8 @@ fun CameraDevice.createPhotoCaptureRequest(
captureRequest.set(CaptureRequest.JPEG_ORIENTATION, orientation.toDegrees())
// TODO: Use the same options as from the preview request. This is duplicate code!
when (flashMode) {
// Set the Flash Mode
Flash.OFF -> {
@ -87,9 +91,14 @@ fun CameraDevice.createPhotoCaptureRequest(
}
}
// TODO: Check if that zoom value is even supported.
captureRequest.setZoom(zoom, cameraCharacteristics)
captureRequest.addTarget(surface)
// Set HDR
// TODO: Check if that value is even supported
if (enableHdr) {
captureRequest.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HDR)
}
return captureRequest.build()
}