fix: Disable precapture sequence by default (#2629)

This commit is contained in:
Marc Rousavy 2024-03-04 12:49:03 +01:00 committed by GitHub
parent e8dd1e0b2e
commit 3f1a7c9e32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 3 deletions

View File

@ -32,6 +32,7 @@ suspend fun CameraView.takePhoto(optionsMap: ReadableMap): WritableMap {
val flash = options["flash"] as? String ?: "off" val flash = options["flash"] as? String ?: "off"
val enableAutoStabilization = options["enableAutoStabilization"] == true val enableAutoStabilization = options["enableAutoStabilization"] == true
val enableShutterSound = options["enableShutterSound"] as? Boolean ?: true val enableShutterSound = options["enableShutterSound"] as? Boolean ?: true
val enablePrecapture = options["enablePrecapture"] as? Boolean ?: false
// TODO: Implement Red Eye Reduction // TODO: Implement Red Eye Reduction
options["enableAutoRedEyeReduction"] options["enableAutoRedEyeReduction"]
@ -44,6 +45,7 @@ suspend fun CameraView.takePhoto(optionsMap: ReadableMap): WritableMap {
flashMode, flashMode,
enableShutterSound, enableShutterSound,
enableAutoStabilization, enableAutoStabilization,
enablePrecapture,
orientation orientation
) )

View File

@ -369,6 +369,7 @@ class CameraSession(private val context: Context, private val cameraManager: Cam
flash: Flash, flash: Flash,
enableShutterSound: Boolean, enableShutterSound: Boolean,
enableAutoStabilization: Boolean, enableAutoStabilization: Boolean,
enablePrecapture: Boolean,
outputOrientation: Orientation outputOrientation: Orientation
): CapturedPhoto { ): CapturedPhoto {
val photoOutput = photoOutput ?: throw PhotoNotEnabledError() val photoOutput = photoOutput ?: throw PhotoNotEnabledError()
@ -380,7 +381,8 @@ class CameraSession(private val context: Context, private val cameraManager: Cam
enableAutoStabilization, enableAutoStabilization,
photoOutput.enableHdr, photoOutput.enableHdr,
outputOrientation, outputOrientation,
enableShutterSound enableShutterSound,
enablePrecapture
) )
try { try {

View File

@ -145,7 +145,8 @@ class PersistentCameraCaptureSession(private val cameraManager: CameraManager, p
enableAutoStabilization: Boolean, enableAutoStabilization: Boolean,
enablePhotoHdr: Boolean, enablePhotoHdr: Boolean,
orientation: Orientation, orientation: Orientation,
enableShutterSound: Boolean enableShutterSound: Boolean,
enablePrecapture: Boolean
): TotalCaptureResult { ): TotalCaptureResult {
// Cancel any ongoing focus jobs // Cancel any ongoing focus jobs
focusJob?.cancel() focusJob?.cancel()
@ -169,7 +170,8 @@ class PersistentCameraCaptureSession(private val cameraManager: CameraManager, p
val outputs = outputs val outputs = outputs
val repeatingOutputs = outputs.filter { it.isRepeating } val repeatingOutputs = outputs.filter { it.isRepeating }
if (qualityPrioritization == QualityPrioritization.SPEED && flash == Flash.OFF) { val skipPrecapture = !enablePrecapture || qualityPrioritization == QualityPrioritization.SPEED
if (skipPrecapture && flash == Flash.OFF) {
// 0. We want to take a picture as fast as possible, so skip any precapture sequence and just capture one Frame. // 0. We want to take a picture as fast as possible, so skip any precapture sequence and just capture one Frame.
Log.i(TAG, "Using fast capture path without pre-capture sequence...") Log.i(TAG, "Using fast capture path without pre-capture sequence...")
val singleRequest = photoRequest.createCaptureRequest(device, deviceDetails, outputs) val singleRequest = photoRequest.createCaptureRequest(device, deviceDetails, outputs)

View File

@ -44,6 +44,14 @@ export interface TakePhotoOptions {
* @default true * @default true
*/ */
enableShutterSound?: boolean enableShutterSound?: boolean
/**
* Whether to run the pre-capture sequence to properly lock AF, AE and AWB values.
* Enabling this results in greater photos, but might not work on some devices.
*
* @platform Android
* @default false
*/
enablePrecapture?: boolean
} }
/** /**