android.hardware.camera2
API for new
applications.@Deprecated public static class Camera.Face extends Object
When face detection is used with a camera, the Camera.FaceDetectionListener
returns a
list of face objects for use in focusing and metering.
Camera.FaceDetectionListener
Modifier and Type | Field and Description |
---|---|
int |
id
Deprecated.
An unique id per face while the face is visible to the tracker.
|
Point |
leftEye
Deprecated.
The coordinates of the center of the left eye.
|
Point |
mouth
Deprecated.
The coordinates of the center of the mouth.
|
Rect |
rect
Deprecated.
Bounds of the face. (-1000, -1000) represents the top-left of the
camera field of view, and (1000, 1000) represents the bottom-right of
the field of view.
|
Point |
rightEye
Deprecated.
The coordinates of the center of the right eye.
|
int |
score
Deprecated.
The confidence level for the detection of the face.
|
Constructor and Description |
---|
Face()
Deprecated.
Create an empty face.
|
public Rect rect
The direction is relative to the sensor orientation, that is, what
the sensor sees. The direction is not affected by the rotation or
mirroring of Camera.setDisplayOrientation(int)
. The face bounding
rectangle does not provide any information about face orientation.
Here is the matrix to convert driver coordinates to View coordinates in pixels.
Matrix matrix = new Matrix(); CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId]; // Need mirror for front camera. boolean mirror = (info.facing == CameraInfo.CAMERA_FACING_FRONT); matrix.setScale(mirror ? -1 : 1, 1); // This is the value for android.hardware.Camera.setDisplayOrientation. matrix.postRotate(displayOrientation); // Camera driver coordinates range from (-1000, -1000) to (1000, 1000). // UI coordinates range from (0, 0) to (width, height). matrix.postScale(view.getWidth() / 2000f, view.getHeight() / 2000f); matrix.postTranslate(view.getWidth() / 2f, view.getHeight() / 2f);
Camera.startFaceDetection()
public int score
The confidence level for the detection of the face. 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 50 is recommended.
Camera.startFaceDetection()
public int id
public Point leftEye
rect
. This is an optional
field, may not be supported on all devices. If not supported, the
value will always be set to null. The optional fields are supported
as a set. Either they are all valid, or none of them are.public Point rightEye
rect
.This is an optional
field, may not be supported on all devices. If not supported, the
value will always be set to null. The optional fields are supported
as a set. Either they are all valid, or none of them are.public Point mouth
rect
. This is an optional
field, may not be supported on all devices. If not supported, the
value will always be set to null. The optional fields are supported
as a set. Either they are all valid, or none of them are.