CameraControl
interface CameraControl
androidx.camera.core.CameraControl |
The CameraControl
provides various asynchronous operations like zoom, focus and metering which affects output of all UseCase
s currently bound to that camera.
The application can retrieve the CameraControl
instance via Camera#getCameraControl()
. CameraControl
is ready to start operations immediately after Camera
is retrieved and UseCase
s are bound to that camera. When all UseCase
s are unbound, or when camera is closing or closed because lifecycle onStop happens, the CameraControl
will reject all operations.
Each method Of CameraControl
returns a ListenableFuture
which apps can use to check the asynchronous result. If the operation is not allowed in current state, the returned ListenableFuture
will fail immediately with CameraControl.OperationCanceledException
.
Summary
Nested classes | |
---|---|
An exception representing a failure that the operation is canceled which might be caused by a new value is set or camera is closed. |
Public methods | |
---|---|
abstract ListenableFuture<Void!> |
Cancels current |
abstract ListenableFuture<Void!> |
enableTorch(torch: Boolean) Enable the torch or disable the torch. |
abstract ListenableFuture<Int!> |
setExposureCompensationIndex(value: Int) Set the exposure compensation value for the camera. |
abstract ListenableFuture<Void!> |
setLinearZoom(@FloatRange(0.0, 1.0) linearZoom: Float) Sets current zoom by a linear zoom value ranging from 0f to 1. |
abstract ListenableFuture<Void!> |
setZoomRatio(ratio: Float) Sets current zoom by ratio. |
abstract ListenableFuture<FocusMeteringResult!> |
startFocusAndMetering(@NonNull action: FocusMeteringAction) Starts a focus and metering action configured by the |
Public methods
cancelFocusAndMetering
@NonNull abstract fun cancelFocusAndMetering(): ListenableFuture<Void!>
Cancels current FocusMeteringAction
and clears AF/AE/AWB regions.
Clear the AF/AE/AWB regions and update current AF mode to continuous AF (if supported). If current FocusMeteringAction
has not completed, the returned ListenableFuture
in startFocusAndMetering
will fail with OperationCanceledException
.
Return | |
---|---|
ListenableFuture<Void!> |
A ListenableFuture which completes when the AF/AE/AWB regions is clear and AF mode is set to continuous focus (if supported). Cancellation of this future is a no-op. |
enableTorch
@NonNull abstract fun enableTorch(torch: Boolean): ListenableFuture<Void!>
Enable the torch or disable the torch.
CameraInfo#getTorchState()
can be used to query the torch state. If the camera doesn't have a flash unit (see CameraInfo#hasFlashUnit()
), then the call will do nothing, the returned ListenableFuture
will complete immediately with a failed result and the torch state will be TorchState#OFF
.
When the torch is enabled, the torch will remain enabled during photo capture regardless of the flashMode setting. When the torch is disabled, flash will function as the flash mode set by either ImageCapture#setFlashMode(int)
or ImageCapture.Builder#setFlashMode(int)
.
Parameters | |
---|---|
torch |
Boolean: true to turn on the torch, false to turn it off. |
Return | |
---|---|
ListenableFuture<Void!> |
A ListenableFuture which is successful when the torch was changed to the value specified. It fails when it is unable to change the torch state. Cancellation of this future is a no-op. |
setExposureCompensationIndex
@NonNull abstract fun setExposureCompensationIndex(value: Int): ListenableFuture<Int!>
Set the exposure compensation value for the camera.
Only one setExposureCompensationIndex
is allowed to run at the same time. If multiple setExposureCompensationIndex
are executed in a row, only the latest one setting will be kept in the camera. The other actions will be cancelled and the ListenableFuture will fail with the OperationCanceledException
. After all the previous actions is cancelled, the camera device will adjust the brightness according to the latest setting.
Parameters | |
---|---|
value |
Int: the exposure compensation value to set on the camera which must be within the range of ExposureState#getExposureCompensationRange(). If the exposure compensation value is not in the range defined above, the returned ListenableFuture will fail with IllegalArgumentException and the value from ExposureState#getExposureCompensationIndex will not change. |
Return | |
---|---|
ListenableFuture<Int!> |
a ListenableFuture which is finished when the camera reaches the newly requested exposure target. Cancellation of this future is a no-op. The result of the ListenableFuture is the new target exposure value, or cancelled with the following exceptions,
|
setLinearZoom
@NonNull abstract fun setLinearZoom(@FloatRange(0.0, 1.0) linearZoom: Float): ListenableF