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 cameraCharacteristics = cameraManager.getCameraCharacteristics(captureSession.device.id)
|
||||||
val orientation = outputOrientation.toSensorRelativeOrientation(cameraCharacteristics)
|
val orientation = outputOrientation.toSensorRelativeOrientation(cameraCharacteristics)
|
||||||
|
val enableHdr = configuration?.photoHdr ?: false
|
||||||
val captureRequest = captureSession.device.createPhotoCaptureRequest(
|
val captureRequest = captureSession.device.createPhotoCaptureRequest(
|
||||||
cameraManager,
|
cameraManager,
|
||||||
photoOutput.surface,
|
photoOutput.surface,
|
||||||
@ -474,6 +475,7 @@ class CameraSession(private val context: Context, private val cameraManager: Cam
|
|||||||
flashMode,
|
flashMode,
|
||||||
enableRedEyeReduction,
|
enableRedEyeReduction,
|
||||||
enableAutoStabilization,
|
enableAutoStabilization,
|
||||||
|
enableHdr,
|
||||||
orientation
|
orientation
|
||||||
)
|
)
|
||||||
Log.i(TAG, "Photo capture 1/3 - starting capture...")
|
Log.i(TAG, "Photo capture 1/3 - starting capture...")
|
||||||
|
@ -30,6 +30,7 @@ fun CameraDevice.createPhotoCaptureRequest(
|
|||||||
flashMode: Flash,
|
flashMode: Flash,
|
||||||
enableRedEyeReduction: Boolean,
|
enableRedEyeReduction: Boolean,
|
||||||
enableAutoStabilization: Boolean,
|
enableAutoStabilization: Boolean,
|
||||||
|
enableHdr: Boolean,
|
||||||
orientation: Orientation
|
orientation: Orientation
|
||||||
): CaptureRequest {
|
): CaptureRequest {
|
||||||
val cameraCharacteristics = cameraManager.getCameraCharacteristics(this.id)
|
val cameraCharacteristics = cameraManager.getCameraCharacteristics(this.id)
|
||||||
@ -40,6 +41,7 @@ fun CameraDevice.createPhotoCaptureRequest(
|
|||||||
CameraDevice.TEMPLATE_STILL_CAPTURE
|
CameraDevice.TEMPLATE_STILL_CAPTURE
|
||||||
}
|
}
|
||||||
val captureRequest = this.createCaptureRequest(template)
|
val captureRequest = this.createCaptureRequest(template)
|
||||||
|
captureRequest.addTarget(surface)
|
||||||
|
|
||||||
// TODO: Maybe we can even expose that prop directly?
|
// TODO: Maybe we can even expose that prop directly?
|
||||||
val jpegQuality = when (qualityPrioritization) {
|
val jpegQuality = when (qualityPrioritization) {
|
||||||
@ -51,6 +53,8 @@ fun CameraDevice.createPhotoCaptureRequest(
|
|||||||
|
|
||||||
captureRequest.set(CaptureRequest.JPEG_ORIENTATION, orientation.toDegrees())
|
captureRequest.set(CaptureRequest.JPEG_ORIENTATION, orientation.toDegrees())
|
||||||
|
|
||||||
|
// TODO: Use the same options as from the preview request. This is duplicate code!
|
||||||
|
|
||||||
when (flashMode) {
|
when (flashMode) {
|
||||||
// Set the Flash Mode
|
// Set the Flash Mode
|
||||||
Flash.OFF -> {
|
Flash.OFF -> {
|
||||||
@ -87,9 +91,14 @@ fun CameraDevice.createPhotoCaptureRequest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Check if that zoom value is even supported.
|
||||||
captureRequest.setZoom(zoom, cameraCharacteristics)
|
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()
|
return captureRequest.build()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user