Facepublic final class Face extends Object Describes a face detected in an image. |
Fields Summary |
---|
public static final int | ID_UNSUPPORTEDThe ID is {@code -1} when the optional set of fields is unsupported. | public static final int | SCORE_MINThe minimum possible value for the confidence level. | public static final int | SCORE_MAXThe maximum possible value for the confidence level. | private final android.graphics.Rect | mBounds | private final int | mScore | private final int | mId | private final android.graphics.Point | mLeftEye | private final android.graphics.Point | mRightEye | private final android.graphics.Point | mMouth |
Constructors Summary |
---|
public Face(android.graphics.Rect bounds, int score, int id, android.graphics.Point leftEyePosition, android.graphics.Point rightEyePosition, android.graphics.Point mouthPosition)Create a new face with all fields set.
The id, leftEyePosition, rightEyePosition, and mouthPosition are considered optional.
They are only required when the {@link CaptureResult} reports that the value of key
{@link CaptureResult#STATISTICS_FACE_DETECT_MODE} is
{@link CameraMetadata#STATISTICS_FACE_DETECT_MODE_FULL}.
If the id is {@value #ID_UNSUPPORTED} then the leftEyePosition, rightEyePosition, and
mouthPositions are guaranteed to be {@code null}. Otherwise, each of leftEyePosition,
rightEyePosition, and mouthPosition may be independently null or not-null.
checkNotNull("bounds", bounds);
if (score < SCORE_MIN || score > SCORE_MAX) {
throw new IllegalArgumentException("Confidence out of range");
} else if (id < 0 && id != ID_UNSUPPORTED) {
throw new IllegalArgumentException("Id out of range");
}
if (id == ID_UNSUPPORTED) {
checkNull("leftEyePosition", leftEyePosition);
checkNull("rightEyePosition", rightEyePosition);
checkNull("mouthPosition", mouthPosition);
}
mBounds = bounds;
mScore = score;
mId = id;
mLeftEye = leftEyePosition;
mRightEye = rightEyePosition;
mMouth = mouthPosition;
| public Face(android.graphics.Rect bounds, int score)Create a new face without the optional fields.
The id, leftEyePosition, rightEyePosition, and mouthPosition are considered optional.
If the id is {@value #ID_UNSUPPORTED} then the leftEyePosition, rightEyePosition, and
mouthPositions are guaranteed to be {@code null}. Otherwise, each of leftEyePosition,
rightEyePosition, and mouthPosition may be independently null or not-null. When devices
report the value of key {@link CaptureResult#STATISTICS_FACE_DETECT_MODE} as
{@link CameraMetadata#STATISTICS_FACE_DETECT_MODE_SIMPLE} in {@link CaptureResult},
the face id of each face is expected to be {@value #ID_UNSUPPORTED}, the leftEyePosition,
rightEyePosition, and mouthPositions are expected to be {@code null} for each face.
this(bounds, score, ID_UNSUPPORTED,
/*leftEyePosition*/null, /*rightEyePosition*/null, /*mouthPosition*/null);
|
Methods Summary |
---|
private static void | checkNotNull(java.lang.String name, java.lang.Object obj)
if (obj == null) {
throw new IllegalArgumentException(name + " was required, but it was null");
}
| private static void | checkNull(java.lang.String name, java.lang.Object obj)
if (obj != null) {
throw new IllegalArgumentException(name + " was required to be null, but it wasn't");
}
| public android.graphics.Rect | getBounds()Bounds of the face.
A rectangle relative to the sensor's
{@link 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-{@code null}.
return mBounds;
| public int | getId()An unique id per face while the face is visible to the tracker.
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 {@value #ID_UNSUPPORTED} then the leftEyePosition, rightEyePosition, and
mouthPositions are guaranteed to be {@code null}. Otherwise, each of leftEyePosition,
rightEyePosition, and mouthPosition may be independently null or not-null. When devices
report the value of key {@link CaptureResult#STATISTICS_FACE_DETECT_MODE} as
{@link CameraMetadata#STATISTICS_FACE_DETECT_MODE_SIMPLE} in {@link CaptureResult},
the face id of each face is expected to be {@value #ID_UNSUPPORTED}.
This value will either be {@value #ID_UNSUPPORTED} or
otherwise greater than {@code 0}.
return mId;
| public android.graphics.Point | getLeftEyePosition()The coordinates of the center of the left eye.
The coordinates are in
the same space as the ones for {@link #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 {@link #getId()} returns
{@value #ID_UNSUPPORTED}.
return mLeftEye;
| public android.graphics.Point | getMouthPosition()The coordinates of the center of the mouth.
The coordinates are in
the same space as the ones for {@link #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 {@link #getId()} returns
{@value #ID_UNSUPPORTED}.
return mMouth;
| public android.graphics.Point | getRightEyePosition()The coordinates of the center of the right eye.
The coordinates are
in the same space as the ones for {@link #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 {@link #getId()} returns
{@value #ID_UNSUPPORTED}.
return mRightEye;
| public int | getScore()The confidence level for the detection of the face.
The range is {@value #SCORE_MIN} to {@value #SCORE_MAX}.
{@value #SCORE_MAX} 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 {@value #SCORE_MAX}
is recommended.
return mScore;
| public java.lang.String | toString()Represent the Face as a string for debugging purposes.
return String.format("{ bounds: %s, score: %s, id: %d, " +
"leftEyePosition: %s, rightEyePosition: %s, mouthPosition: %s }",
mBounds, mScore, mId, mLeftEye, mRightEye, mMouth);
|
|