CameraController

A CameraController controls a CameraDevice connected to a CameraSession: zoom, torch, exposure, focus…

One CameraController is returned per CameraSessionConnection by CameraSession.configure.

Properties

Link copied to clipboard
abstract val device: CameraDevice

The CameraDevice this controller controls.

Link copied to clipboard

The zoom factor to display to the user, which may differ from zoom on virtual devices (e.g. 0.5x on a Triple-Camera whose minZoom is 1).

Link copied to clipboard
abstract val exposureBias: Double

The current exposure bias, in EV units.

Link copied to clipboard
abstract val exposureDuration: Double

The current exposure duration, in seconds, or 0 if the device does not support exposure locking.

Link copied to clipboard

The current ExposureMode.

Link copied to clipboard
abstract val focusMode: FocusMode

The current FocusMode.

Link copied to clipboard
abstract val isConnected: Boolean

Whether the device is currently connected and usable.

Link copied to clipboard

Whether distortion correction is currently enabled.

Link copied to clipboard

Whether low-light boost is currently enabled.

Link copied to clipboard
abstract val iso: Double

The current ISO, or 0 if the device does not support exposure locking.

Link copied to clipboard

Whether smooth auto-focus is currently enabled.

Link copied to clipboard
abstract val isSuspended: Boolean

Whether the device is currently suspended (e.g. a lens cover is closed).

Link copied to clipboard

Whether the device is currently used by another app.

Link copied to clipboard
abstract val lensPosition: Double

The current lens position, from 0.0 (closest) to 1.0 (furthest), or 0 if the device does not support CameraDevice.supportsFocusLocking.

Link copied to clipboard

The maximum exposure duration for setExposureLocked, in seconds, or 0 if not supported.

Link copied to clipboard
abstract val maxISO: Double

The maximum ISO for setExposureLocked, or 0 if not supported.

Link copied to clipboard
abstract val maxZoom: Double

The maximum zoom value supported in the current session configuration.

Link copied to clipboard

The minimum exposure duration for setExposureLocked, in seconds, or 0 if not supported.

Link copied to clipboard
abstract val minISO: Double

The minimum ISO for setExposureLocked, or 0 if not supported.

Link copied to clipboard
abstract val minZoom: Double

The minimum zoom value supported in the current session configuration.

Link copied to clipboard
abstract val torchMode: TorchMode

The current TorchMode.

Link copied to clipboard
abstract val torchStrength: Double

The current torch strength.

Link copied to clipboard

The current white balance gains, or (0, 0, 0) if the device does not support CameraDevice.supportsWhiteBalanceLocking.

Link copied to clipboard
Link copied to clipboard
abstract val zoom: Double

The current zoom value.

Functions

Link copied to clipboard
abstract fun addSubjectAreaChangedListener(onSubjectAreaChanged: () -> Unit): ListenerSubscription

Adds a listener called every time the subject area substantially changes, e.g. when the user pans away from a scene previously in focus. Useful to resetFocus after locking focus.

Link copied to clipboard
abstract suspend fun cancelZoomAnimation()

Cancels any zoom animation started with startZoomAnimation.

Link copied to clipboard
abstract suspend fun configure(config: CameraControllerConfiguration)

Configures this controller with the given config. null values are left unchanged.

Converts the given temperature and tint values to WhiteBalanceGains. Only supported on iOS.

Link copied to clipboard
abstract suspend fun enableTorchWithStrength(strength: Double)

Turns the torch on at the given strength, between CameraDevice.minTorchStrength and CameraDevice.maxTorchStrength. Turn it off again with setTorchMode.

Link copied to clipboard
abstract suspend fun focusTo(point: MeteringPoint, options: FocusOptions = FocusOptions())

Focuses the Camera pipeline to the given point, using the MeteringModes of options (by default, every mode the device supports, ideally 3A: AE, AF and AWB).

Link copied to clipboard
abstract suspend fun lockCurrentExposure()

Locks the current exposure (exposureDuration and iso) until resetFocus is called. Requires CameraDevice.supportsExposureLocking. Only supported on iOS.

Link copied to clipboard
abstract suspend fun lockCurrentFocus()

Locks the current focus (lensPosition) until resetFocus is called. Requires CameraDevice.supportsFocusLocking. Only supported on iOS.

Link copied to clipboard
abstract suspend fun lockCurrentWhiteBalance()

Locks the current white balance (whiteBalanceGains) until resetFocus is called. Requires CameraDevice.supportsWhiteBalanceLocking. Only supported on iOS.

Link copied to clipboard
abstract suspend fun resetFocus()

Cancels any focus operation from focusTo, resets every 3A mode back to continuous auto mode if it was locked (e.g. via setFocusLocked or lockCurrentFocus), and resets the point of interest to the center.

Link copied to clipboard
abstract suspend fun setExposureBias(exposure: Double)

Biases the auto-exposure by the given value in EV units. Requires CameraDevice.supportsExposureBias.

Link copied to clipboard
abstract suspend fun setExposureLocked(duration: Double, iso: Double)

Locks the exposure at the given duration (in seconds, between minExposureDuration and maxExposureDuration) and iso (between minISO and maxISO). Requires CameraDevice.supportsExposureLocking. Only supported on iOS.

Link copied to clipboard
abstract suspend fun setFocusLocked(lensPosition: Double)

Locks the focus at the given lensPosition, from 0.0 (closest) to 1.0 (furthest). Requires CameraDevice.supportsFocusLocking. Only supported on iOS.

Link copied to clipboard
abstract suspend fun setTorchMode(mode: TorchMode)

Sets the torch to the given mode, at the system default level. Requires CameraDevice.hasTorch.

Link copied to clipboard
abstract suspend fun setWhiteBalanceLocked(whiteBalanceGains: WhiteBalanceGains)

Locks the white balance at the given whiteBalanceGains, each channel between 1 and CameraDevice.maxWhiteBalanceGain. Requires CameraDevice.supportsWhiteBalanceLocking. Only supported on iOS.

Link copied to clipboard
abstract suspend fun setZoom(zoom: Double)

Sets the zoom to the given value.

Link copied to clipboard
abstract suspend fun startZoomAnimation(zoom: Double, rate: Double)

Starts animating the zoom to the given value, at the given rate (in doublings of the zoom factor per second).