AugmentedFaceNode
AR Augmented Face positioned 3D model node
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. Trackable.createAnchor 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 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();
}
Properties
Gets the Anchors attached to this node trackable.
Is the AR camera tracking.
The center of the face, defined to have the origin located behind the nose and between the two cheek bones.
The region nodes at the tip of the nose, the detected face's left side of the forehead, the detected face's right side of the forehead.
The TrackingState of this Node.
Set the node to be visible only on those camera tracking states
Set the node to be visible only on those tracking states
Functions
Creates an anchor that is attached to this trackable, using the given initial pose in the world coordinate space.
Creates an AnchorNode that is attached to this trackable, using the given initial pose in the world coordinate space.