FocusMeteringAction

public class FocusMeteringAction
extends Object

java.lang.Object
   ↳ androidx.camera.core.FocusMeteringAction


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

To construct a FocusMeteringAction, apps have to create a FocusMeteringAction.Builder by FocusMeteringAction.Builder.from(MeteringPoint) or FocusMeteringAction.Builder.from(MeteringPoint, MeteringMode). 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 FocusMeteringAction.MeteringMode is FocusMeteringAction.MeteringMode.AF_AE_AWB which means the point is used for all AF/AE/AWB regions. Apps can set the proper FocusMeteringAction.MeteringMode to optionally exclude some 3A regions. Multiple regions for specific 3A type are also supported via FocusMeteringAction.Builder.addPoint(MeteringPoint) or FocusMeteringAction.Builder.addPoint(MeteringPoint, MeteringMode). App can also this API to enable different region for AF and AE respectively.

If any AF points are specified, it will trigger AF to start a manual AF scan and cancel AF trigger when CameraControl.cancelFocusAndMetering() is called. When triggering AF is done, it will call the FocusMeteringAction.OnAutoFocusListener.onFocusCompleted(boolean) which is set via FocusMeteringAction.Builder.setAutoFocusCallback(OnAutoFocusListener). If AF point is not specified or the action is cancelled before AF is locked, CameraX will call the FocusMeteringAction.OnAutoFocusListener.onFocusCompleted(boolean) with isFocusLocked set to false.

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 FocusMeteringAction.Builder.disableAutoCancel() to disable auto-cancel.

Summary

Nested classes

class FocusMeteringAction.Builder

The builder used to create the FocusMeteringAction

enum FocusMeteringAction.MeteringMode

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

interface FocusMeteringAction.OnAutoFocusListener

Listener for receiving auto-focus completion event. 

Public methods

long getAutoCancelDurationInMs()

Returns auto-cancel duration.

List<MeteringPoint> getMeteringPointsAE()

Returns all MeteringPoints used for AE regions.

List<MeteringPoint> getMeteringPointsAF()

Returns all MeteringPoints used for AF regions.

List<MeteringPoint> getMeteringPointsAWB()

Returns all MeteringPoints used for AWB regions.

FocusMeteringAction.OnAutoFocusListener getOnAutoFocusListener()

Returns current FocusMeteringAction.OnAutoFocusListener.

boolean isAutoCancelEnabled()

Returns if auto-cancel is enabled or not.

Inherited methods

Public methods

getAutoCancelDurationInMs

public long getAutoCancelDurationInMs ()

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

Returns
long

getMeteringPointsAE

public List<MeteringPoint> getMeteringPointsAE ()

Returns all MeteringPoints used for AE regions.

Returns
List<MeteringPoint>

getMeteringPointsAF

public List<MeteringPoint> getMeteringPointsAF ()

Returns all MeteringPoints used for AF regions.

Returns
List<MeteringPoint>

getMeteringPointsAWB

public List<MeteringPoint> getMeteringPointsAWB ()

Returns all MeteringPoints used for AWB regions.

Returns
List<MeteringPoint>

getOnAutoFocusListener

public FocusMeteringAction.OnAutoFocusListener getOnAutoFocusListener ()

Returns current FocusMeteringAction.OnAutoFocusListener.

Returns
FocusMeteringAction.OnAutoFocusListener

isAutoCancelEnabled

public boolean isAutoCancelEnabled ()

Returns if auto-cancel is enabled or not.

Returns
boolean