public final class Face extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ID_UNSUPPORTED
The ID is
-1 when the optional set of fields is unsupported. |
static int |
SCORE_MAX
The maximum possible value for the confidence level.
|
static int |
SCORE_MIN
The minimum possible value for the confidence level.
|
Constructor and Description |
---|
Face(Rect bounds,
int score)
Create a new face without the optional fields.
|
Face(Rect bounds,
int score,
int id,
Point leftEyePosition,
Point rightEyePosition,
Point mouthPosition)
Create a new face with all fields set.
|
Modifier and Type | Method and Description |
---|---|
Rect |
getBounds()
Bounds of the face.
|
int |
getId()
An unique id per face while the face is visible to the tracker.
|
Point |
getLeftEyePosition()
The coordinates of the center of the left eye.
|
Point |
getMouthPosition()
The coordinates of the center of the mouth.
|
Point |
getRightEyePosition()
The coordinates of the center of the right eye.
|
int |
getScore()
The confidence level for the detection of the face.
|
String |
toString()
Represent the Face as a string for debugging purposes.
|
public static final int ID_UNSUPPORTED
-1
when the optional set of fields is unsupported.Face(Rect, int)
,
getId()
,
Constant Field Valuespublic static final int SCORE_MIN
getScore()
,
Constant Field Valuespublic static final int SCORE_MAX
getScore()
,
Constant Field Valuespublic Face(Rect bounds, int score, int id, Point leftEyePosition, Point rightEyePosition, Point mouthPosition)
The id, leftEyePosition, rightEyePosition, and mouthPosition are considered optional.
They are only required when the CaptureResult
reports that the value of key
CaptureResult.STATISTICS_FACE_DETECT_MODE
is
CameraMetadata.STATISTICS_FACE_DETECT_MODE_FULL
.
If the id is -1 then the leftEyePosition, rightEyePosition, and
mouthPositions are guaranteed to be null
. Otherwise, each of leftEyePosition,
rightEyePosition, and mouthPosition may be independently null or not-null.
bounds
- Bounds of the face.score
- Confidence level between 1-100.id
- A unique ID per face visible to the tracker.leftEyePosition
- The position of the left eye.rightEyePosition
- The position of the right eye.mouthPosition
- The position of the mouth.IllegalArgumentException
- if bounds is null
,
or if the confidence is not in the range of
1-100,
or if id is -1 and
leftEyePosition/rightEyePosition/mouthPosition aren't all null,
or else if id is negative.public Face(Rect bounds, int score)
The id, leftEyePosition, rightEyePosition, and mouthPosition are considered optional.
If the id is -1 then the leftEyePosition, rightEyePosition, and
mouthPositions are guaranteed to be null
. Otherwise, each of leftEyePosition,
rightEyePosition, and mouthPosition may be independently null or not-null. When devices
report the value of key CaptureResult.STATISTICS_FACE_DETECT_MODE
as
CameraMetadata.STATISTICS_FACE_DETECT_MODE_SIMPLE
in CaptureResult
,
the face id of each face is expected to be -1, the leftEyePosition,
rightEyePosition, and mouthPositions are expected to be null
for each face.
bounds
- Bounds of the face.score
- Confidence level between 1-100.IllegalArgumentException
- if bounds is null
,
or if the confidence is not in the range of
1-100.public Rect getBounds()
A rectangle relative to the sensor's
CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE
, with (0,0)
representing the top-left corner of the active array rectangle.
There is no constraints on the the Rectangle value other than it
is not-null
.
public int getScore()
The range is 1 to 100. 100 is the highest confidence.
Depending on the device, even very low-confidence faces may be listed, so applications should filter out faces with low confidence, depending on the use case. For a typical point-and-shoot camera application that wishes to display rectangles around detected faces, filtering out faces with confidence less than half of 100 is recommended.
public int getId()
If the face leaves the field-of-view and comes back, it will get a new id.
This is an optional field, may not be supported on all devices.
If the id is -1 then the leftEyePosition, rightEyePosition, and
mouthPositions are guaranteed to be null
. Otherwise, each of leftEyePosition,
rightEyePosition, and mouthPosition may be independently null or not-null. When devices
report the value of key CaptureResult.STATISTICS_FACE_DETECT_MODE
as
CameraMetadata.STATISTICS_FACE_DETECT_MODE_SIMPLE
in CaptureResult
,
the face id of each face is expected to be -1.
This value will either be -1 or
otherwise greater than 0
.
ID_UNSUPPORTED
public Point getLeftEyePosition()
The coordinates are in
the same space as the ones for getBounds()
. This is an
optional field, may not be supported on all devices. If not
supported, the value will always be set to null.
This value will always be null only if getId()
returns
-1.
null
if unknown.public Point getRightEyePosition()
The coordinates are
in the same space as the ones for getBounds()
.This is an
optional field, may not be supported on all devices. If not
supported, the value will always be set to null.
This value will always be null only if getId()
returns
-1.
null
if unknown.public Point getMouthPosition()
The coordinates are in
the same space as the ones for getBounds()
. This is an optional
field, may not be supported on all devices. If not
supported, the value will always be set to null.
This value will always be null only if getId()
returns
-1.
null
if unknown.