FocusMeteringAction

class FocusMeteringAction
kotlin.Any
   ↳ androidx.camera.core.FocusMeteringAction

A configuration used to trigger a focus and/or metering action.

To construct a FocusMeteringAction, apps have to create a Builder by Builder#from(MeteringPoint) or Builder#from(MeteringPoint, int). MeteringPoint is a point used to specify the focus/metering areas. Apps can use various MeteringPointFactory to create the points. When the FocusMeteringAction is built, pass it to CameraControl#startFocusAndMetering(FocusMeteringAction) to initiate the focus and metering action.

The default MeteringMode is MeteringMode#AF | MeteringMode#AE | MeteringMode#AWB which means the point is used for all AF/AE/AWB regions. Apps can set the proper MeteringMode to optionally exclude some 3A regions. Multiple regions for specific 3A type are also supported via Builder#addPoint(MeteringPoint) or Builder#addPoint(MeteringPoint, int). App can also this API to enable different region for AF and AE respectively.

If any AF points are specified, it will trigger autofocus to start a manual scan. When focus is locked and specified AF/AE/AWB regions are updated in capture result, the returned ListenableFuture in CameraControl#startFocusAndMetering(FocusMeteringAction) will completed with FocusMeteringResult#isFocusSuccessful() set to indicate if focus is done successfully or not. If AF point is not specified, it will not trigger autofocus and simply wait for specified AE/AWB regions being updated to complete the returned ListenableFuture. In the case of AF points not specified, FocusMeteringResult#isFocusSuccessful() will be set to false. If Af points are specified but current camera does not support auto focus, FocusMeteringResult#isFocusSuccessful() will be set to true .

App can set a auto-cancel duration to let CameraX call CameraControl#cancelFocusAndMetering() automatically in the specified duration. By default the auto-cancel duration is 5 seconds. Apps can call Builder#disableAutoCancel() to disable auto-cancel.

Summary

Nested classes

The builder used to create the FocusMeteringAction.

Focus/Metering mode used to specify which 3A regions is activated for corresponding MeteringPoint.

Public methods

Long

Returns auto-cancel duration.

MutableList<MeteringPoint!>

Returns all MeteringPoints used for AE regions.

MutableList<MeteringPoint!>

Returns all MeteringPoints used for AF regions.

MutableList<MeteringPoint!>

Returns all MeteringPoints used for AWB regions.

Boolean

Returns if auto-cancel is enabled or not.

Public methods

getAutoCancelDurationInMillis

fun getAutoCancelDurationInMillis(): Long

Returns auto-cancel duration. Returns 0 if auto-cancel is disabled.

getMeteringPointsAe

@NonNull fun getMeteringPointsAe(): MutableList<MeteringPoint!>

Returns all MeteringPoints used for AE regions.

getMeteringPointsAf

@NonNull fun getMeteringPointsAf(): MutableList<MeteringPoint!>

Returns all MeteringPoints used for AF regions.

getMeteringPointsAwb

@NonNull fun getMeteringPointsAwb(): MutableList<MeteringPoint!>

Returns all MeteringPoints used for AWB regions.

isAutoCancelEnabled

fun isAutoCancelEnabled(): Boolean

Returns if auto-cancel is enabled or not.