feat: Enable HDR extension for photo capture if available (#2162)
This commit is contained in:
parent
aad872bb9c
commit
f24c00d4ce
@ -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...")
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user