FocusMeteringAction
public
final
class
FocusMeteringAction
extends Object
java.lang.Object | |
↳ | androidx.camera.core.FocusMeteringAction |
A configuration used to trigger a focus and/or metering action.
A FocusMeteringAction
must be created by the FocusMeteringAction.Builder
. To construct a
FocusMeteringAction.Builder
, a MeteringPoint
is required to specify the focus/metering area. Apps
can use various MeteringPointFactory
to create the points. After the
FocusMeteringAction
is built, apps can pass it to
CameraControl.startFocusAndMetering(FocusMeteringAction)
to initiate the focus
and metering action.
When specifying a MeteringPoint
, a metering mode can also be specified. Metering
mode is a combination of flags consisting of FLAG_AF
, FLAG_AE
, and
FLAG_AWB
. This combination indicates whether the MeteringPoint
is
used to set an AF(Auto Focus) region, AE(Auto Exposure) region or AWB(Auto White Balance) region.
The default meteringMode is FLAG_AF
| FLAG_AE
| FLAG_AWB
which
means the point is used for all AF/AE/AWB regions. Apps can set the proper metering mode to
optionally exclude some 3A regions. Multiple regions for specific 3A types are also supported
via FocusMeteringAction.Builder.addPoint(MeteringPoint)
or FocusMeteringAction.Builder.addPoint(MeteringPoint, int)
.
An app can also use this API to enable different regions 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 the specified AF/AE/AWB regions are updated in capture result, the returned
ListenableFuture
in CameraControl.startFocusAndMetering(FocusMeteringAction)
will complete with FocusMeteringResult.isFocusSuccessful()
set to indicate if focus is
done successfully or not. If an 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 FocusMeteringAction.Builder.disableAutoCancel()
to disable auto-cancel.
Summary
Nested classes | |
---|---|
class |
FocusMeteringAction.Builder
The builder used to create the |
Constants | |
---|---|
int |
FLAG_AE
A flag used in metering mode indicating the AE (Auto Exposure) region is enabled. |
int |
FLAG_AF
A flag used in metering mode indicating the AF (Auto Focus) region is enabled. |
int |
FLAG_AWB
A flag used in metering mode indicating the AWB (Auto White Balance) region is enabled. |
Public methods | |
---|---|
long
|
getAutoCancelDurationInMillis()
Returns auto-cancel duration. |
List<MeteringPoint>
|
getMeteringPointsAe()
Returns all |
List<MeteringPoint>
|
getMeteringPointsAf()
Returns all |
List<MeteringPoint>
|
getMeteringPointsAwb()
Returns all |
boolean
|
isAutoCancelEnabled()
Returns if auto-cancel is enabled or not. |
Inherited methods | |
---|---|
Constants
FLAG_AE
public static final int FLAG_AE
A flag used in metering mode indicating the AE (Auto Exposure) region is enabled.
Constant Value: 2 (0x00000002)
FLAG_AF
public static final int FLAG_AF
A flag used in metering mode indicating the AF (Auto Focus) region is enabled. An autofocus scan is also triggered when FLAG_AF is assigned.
Constant Value: 1 (0x00000001)
FLAG_AWB
public static final int FLAG_AWB
A flag used in metering mode indicating the AWB (Auto White Balance) region is enabled.
Constant Value: 4 (0x00000004)
Public methods
getAutoCancelDurationInMillis
public long getAutoCancelDurationInMillis ()
Returns auto-cancel duration. Returns 0 if auto-cancel is disabled.
Returns | |
---|---|
long |
getMeteringPointsAe
public List<MeteringPoint> getMeteringPointsAe ()
Returns all MeteringPoint
s used for AE regions.
Returns | |
---|---|
List<MeteringPoint> |
getMeteringPointsAf
public List<MeteringPoint> getMeteringPointsAf ()
Returns all MeteringPoint
s used for AF regions.
Returns | |
---|---|
List<MeteringPoint> |
getMeteringPointsAwb
public List<MeteringPoint> getMeteringPointsAwb ()
Returns all MeteringPoint
s used for AWB regions.
Returns | |
---|---|
List<MeteringPoint> |
isAutoCancelEnabled
public boolean isAutoCancelEnabled ()
Returns if auto-cancel is enabled or not.
Returns | |
---|---|
boolean |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-09-30 UTC.