AugmentedFace

public class AugmentedFace

Describes a face detected by ARCore and provides methods to access additional center and face region poses as well as face mesh related data.

Augmented Faces supports front-facing (selfie) camera only, and does not support attaching anchors nor raycast hit testing. Calling Trackable.createAnchor(Pose) will result in an IllegalStateException.

To use Augmented Faces, enable the feature in the session. This can be done at session creation time, or at any time during session runtime:

Session session = new Session(context, EnumSet.of(Session.Feature.FRONT_CAMERA));
 Config config = ...
 config.setAugmentedFaceMode(AugmentedFaceMode.MESH3D);
 session.configure(config);
 
When Augmented Face mode is enabled, ARCore updates the list of detected faces for each frame. Use Session.getAllTrackables(Class) and Trackable.getTrackingState() to get a list of faces that have valid meshes that can be rendered.
for (AugmentedFace face : session.getAllTrackables(AugmentedFace.class)) {
   if (face.getTrackingState() == TrackingState.TRACKING) {
     // Render face mesh ...
   }
 }
 
Faces provide static mesh data that does not change during the session, as well as pose and mesh data that is updated each frame:
// UVs and indices can be cached as they do not change during the session.
 FloatBuffer uvs = face.getMeshTextureCoordinates();
 ShortBuffer indices = face.getMeshTriangleIndices();
 // Center and region poses, mesh vertices, and normals are updated each frame.
 Pose facePose = face.getCenterPose();
 FloatBuffer faceVertices = face.getMeshVertices();
 FloatBuffer faceNormals = face.getMeshNormals();
 

Nested Classes

enum AugmentedFace.RegionType Defines face regions to query the pose for. 

Public Methods

Anchor
createAnchor(Pose pose)
Creates an anchor that is attached to this trackable, using the given initial pose in the world coordinate space.
boolean
equals(Object obj)
Indicates whether some other object is a Trackable referencing the same logical trackable as this one.
Collection<Anchor>
getAnchors()
Gets the Anchors attached to this trackable.
Pose
getCenterPose()
Returns the pose of the center of the face, defined to have the origin located behind the nose and between the two cheek bones.
FloatBuffer
getMeshNormals()
Returns a float buffer of 3D normals in (x, y, z) packing.
FloatBuffer
getMeshTextureCoordinates()
Returns a float buffer of UV texture coordinates in (u, v) packing.
ShortBuffer
getMeshTriangleIndices()
Returns a char buffer of triangles' indices in consecutive triplets.
FloatBuffer
getMeshVertices()
Returns a float buffer of 3D vertices in (x, y, z) packing.
Pose
getRegionPose(AugmentedFace.RegionType regionType)
Returns the pose of a region in world coordinates when the face trackable state is TRACKING.
TrackingState
getTrackingState()
Gets this trackable's TrackingState.
int
hashCode()
Returns a hash code value for the object.

Inherited Methods

Public Methods