FileDocCategorySizeDatePackage
Face.javaAPI DocAndroid 5.1 API9904Thu Mar 12 22:22:10 GMT 2015android.hardware.camera2.params

Face

public final class Face extends Object
Describes a face detected in an image.

Fields Summary
public static final int
ID_UNSUPPORTED
The ID is {@code -1} when the optional set of fields is unsupported.
public static final int
SCORE_MIN
The minimum possible value for the confidence level.
public static final int
SCORE_MAX
The 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.

param
bounds Bounds of the face.
param
score Confidence level between {@value #SCORE_MIN}-{@value #SCORE_MAX}.
param
id A unique ID per face visible to the tracker.
param
leftEyePosition The position of the left eye.
param
rightEyePosition The position of the right eye.
param
mouthPosition The position of the mouth.
throws
IllegalArgumentException if bounds is {@code null}, or if the confidence is not in the range of {@value #SCORE_MIN}-{@value #SCORE_MAX}, or if id is {@value #ID_UNSUPPORTED} and leftEyePosition/rightEyePosition/mouthPosition aren't all null, or else if id is negative.
hide


                                                                                                                                                                                                                                            
          
                  
        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.

param
bounds Bounds of the face.
param
score Confidence level between {@value #SCORE_MIN}-{@value #SCORE_MAX}.
throws
IllegalArgumentException if bounds is {@code null}, or if the confidence is not in the range of {@value #SCORE_MIN}-{@value #SCORE_MAX}.
hide

        this(bounds, score, ID_UNSUPPORTED,
                /*leftEyePosition*/null, /*rightEyePosition*/null, /*mouthPosition*/null);
    
Methods Summary
private static voidcheckNotNull(java.lang.String name, java.lang.Object obj)

        if (obj == null) {
            throw new IllegalArgumentException(name + " was required, but it was null");
        }
    
private static voidcheckNull(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.RectgetBounds()
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 intgetId()
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}.

see
#ID_UNSUPPORTED

        return mId;
    
public android.graphics.PointgetLeftEyePosition()
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
The left eye position, or {@code null} if unknown.

        return mLeftEye;
    
public android.graphics.PointgetMouthPosition()
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
The mouth position, or {@code null} if unknown.

        return mMouth;
    
public android.graphics.PointgetRightEyePosition()
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
The right eye position, or {@code null} if unknown.

        return mRightEye;
    
public intgetScore()
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.

see
#SCORE_MAX
see
#SCORE_MIN

        return mScore;
    
public java.lang.StringtoString()
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);