Other versions of this page
Controls
Camera sensors can be configured using the CameraCapabilities
and CameraConfiguration
classes.
- The capabilities object lets you understand which settings are supported (read only)
- The configuration object lets you apply them
For example, for white balance:
kotlinval capabilities: CameraCapabilities = device.capabilities
val options: Set<WhiteBalance> = capabilities.whiteBalance
// Let user choose among the set above, then apply:
device.configure(whiteBalance = options[selectedIndex])
// Or with the lambda syntax:
device.configure { whiteBalance = options[selectedIndex] }
swiftlet capabilities: CameraCapabilities = device.capabilities
let options: Set<WhiteBalance> = capabilities.whiteBalance
// Let user choose among the set above, then apply:
try await device.configure(whiteBalance: options[selectedIndex])
// Or with the lambda syntax:
device.configure { $0.whiteBalance = options[selectedIndex] }
Settings
The list below documents all the settings that can be configured through the capabilities/configuration mechanism.
Flash
Controls the device flash.
- Type:
Flash
enumeration - Set of supported values:
CameraCapabilities.flash
- Configuration field:
CameraConfiguration.flash
Value | Description |
---|---|
WhiteBalance.Off WhiteBalance.off | Flash is disabled. |
WhiteBalance.Auto WhiteBalance.auto | The sensor automatically determines whether flash is needed or not during takePicture . |
WhiteBalance.On WhiteBalance.on | Flash is always triggered during takePicture . |
WhiteBalance.Torch WhiteBalance.torch | Flash stays on in torch mode. |
Zoom
Controls zoom. The available range is that of the camera sensor. For logical cameras, changing zoom may also cause it to use a different lens under the hood (e.g. switch to wide angle for low zoom).
- Type:
Float
- Range of supported values:
CameraCapabilities.zoom
- Configuration field:
CameraConfiguration.zoom
Stabilization
Controls the device flash.
- Type:
Stabilization
enumeration - Set of supported values:
CameraCapabilities.stabilization
- Configuration field:
CameraConfiguration.stabilization
Value | Description |
---|---|
Stabilization.Off | Stabilization is off. |
Stabilization.Optical | Optical stabilization (OIS) is active. |
Stabilization.Digital | Digital stabilization is active. |
Value | Description |
---|---|
Stabilization.off | Stabilization is off. |
Stabilization.auto | Stabilization, either optical or digital, is active. |
White Balance
Adjusts the white balance to a different, fixed value. Note that any value different than
Auto
auto
will disable continuous AWB metering.
- Type:
WhiteBalance
enumeration - Set of supported values:
CameraCapabilities.whiteBalance
- Configuration field:
CameraConfiguration.whiteBalance
Value | Description |
---|---|
WhiteBalance.Auto WhiteBalance.auto | White balance is automatically, continuously adapted to the scene. |
WhiteBalance.Fluorescent WhiteBalance.fluorescent | Appropriate for fluorescent illumination (CIE standard illuminant F2). |
WhiteBalance.Incandescent WhiteBalance.incandescent | Appropriate for incandescent illumination (CIE standard illuminant A). |
WhiteBalance.Daylight WhiteBalance.daylight | Appropriate for incandescent illumination (CIE standard illuminant D65). |
WhiteBalance.Cloudy WhiteBalance.cloudy | Appropriate for cloud light. |
WhiteBalance.Twilight WhiteBalance.twilight | Appropriate for twilight light. |
Exposure Compensation
Manually corrects the sensor's exposure value (EV), in camera stops. A positive EV will make the resulting picture or video brighter,
a negative EV will make it darker. You can use 0
to undo any previous modification.
- Type:
Float
- Range of supported values:
CameraCapabilities.exposureCompensation
- Configuration field:
CameraConfiguration.exposureCompensation
Metering Modes
Metering modes determine how to interpret the center
parameter in a scan()
operation, which is described in the metering documentation.
- Type:
MeteringMode
enumeration - Sets of supported values:
CameraCapabilities.exposureMetering
,CameraCapabilities.focusMetering
,CameraCapabilities.whiteBalanceMetering
- Configuration fields:
CameraConfiguration.exposureMetering
,CameraCapabilities.focusMetering
,CameraCapabilities.whiteBalanceMetering
Find a list of possible values and their meaning here.
Observing changes
Configuration is applied with the configure()
API, and can be observed with the configuration
property.
This can be useful to implement reactive UI components that depend on the configuration state.
kotlinval current: CameraConfiguration = device.configuration.value
val flow: StateFlow<CameraConfiguration> = device.CameraConfiguration
swiftlet current: CameraConfiguration = device.configuration
let publisher: AnyPublisher<CameraConfiguration, Never> = device.configurationPublisher