Locking AE/AF/AWB
Manually locking Focus, Exposure and White-Balance
Exposure, Focus and White-Balance are typically automatically adjusted as the scene changes. For pro-Camera apps, you can manually adjust Exposure Duration/ISO, Focus Lens Position and White-Balance Temperature and Tint Value and lock them in-place, if the device supports it.
Setting specific values
Setting custom Exposure Duration/ISO
If the CameraDevice supports Exposure Locking (see supportsExposureLocking) you can set a custom Exposure Duration/ISO via setExposureLocked(...):
const controller = ...
const format = ...
if (controller.device.supportsExposureLocking) {
const exposureDuration = 1 / 60
const iso = 200
await controller.setExposureLocked(exposureDuration, iso)
}Warning
Make sure the given exposureDuration value is inside the currently selected CameraFormat's minExposureDuration and maxExposureDuration bounds.
Make sure the given iso value is inside the currently selected CameraFormat's minISO and maxISO bounds.
Setting custom Focus Lens Position
If the CameraDevice supports Focus Locking (see supportsFocusLocking) you can set a custom Focus Lens Position via setFocusLocked(...):
const controller = ...
if (controller.device.supportsFocusLocking) {
const lensPosition = 0.5
await controller.setFocusLocked(lensPosition)
}Warning
Make sure the given lensPosition value is between 0.0 and 1.0.
Setting custom White Balance Temperature and Tint
If the CameraDevice supports White-Balance Locking (see supportsWhiteBalanceLocking) you can set custom White Balance Temperature and Tint values via setWhiteBalanceLocked(...):
const controller = ...
if (controller.device.supportsWhiteBalanceLocking) {
const temperature = 4500
const tint = 20
await controller.setWhiteBalanceLocked(temperature, tint)
}Warning
A good range for temperature is between 2500K and 8000K, and a good value for tint is usually between -150 and 150.
Locking current values
To lock the current Exposure/Focus/White-Balance values at their current value (for example, after a tap to focus action), use lockCurrentExposure(...), lockCurrentFocus(...) or lockCurrentWhiteBalance(...):
const controller = ...
const meteringPoint = ...
await controller.focusTo(meteringPoint, {
autoReset: null
})
if (controller.device.supportsExposureLocking) {
await controller.lockCurrentExposure()
}
if (controller.device.supportsFocusLocking) {
await controller.lockCurrentFocus()
}
if (controller.device.supportsWhiteBalanceLocking) {
await controller.lockCurrentWhiteBalance()
}To reset Exposure/Focus/White-Balance back to auto, use resetFocus(...):
const controller = ...
await controller.resetFocus()