FaceTrackingModule Overview
FaceTrackingModule Overview
FaceTrackingModule Overview

FaceTrackingModule

The FaceTrackingModule class enables tracking faces in 3D.

Example

//===========================================================================
// The following example demonstrates how to control the rotation and scale
// of an object using face rotation and mouth openness.
//
// Project setup:
// - Insert a plane
//===========================================================================

// Load in the required modules
const FaceTracking = require('FaceTracking');
const Scene = require('Scene');

(async function() { // Enable async/await in JS [part 1]
  
  // Locate the plane in the scene
  const plane = await Scene.root.findFirst('plane0');

  // Create a reference to a detected face
  const face = FaceTracking.face(0);


  //=========================================================================
  // Control the rotation of the plane with the rotation of the face
  //=========================================================================

  // Create references to the transforms of the plane and face
  const planeTransform = plane.transform;
  const faceTransform = face.cameraTransform;

  // Bind the rotation of the face to the rotation of the plane
  planeTransform.rotationX = faceTransform.rotationX;
  planeTransform.rotationY = faceTransform.rotationY;
  planeTransform.rotationZ = faceTransform.rotationZ;


  //=========================================================================
  // Control the scale of the plane with mouth openness
  //=========================================================================

  // Create a reference to the mouth openness and amplify the signal by  
  // multiplying it using the mul() method
  const mouthOpenness = face.mouth.openness.mul(4).add(1);

  // Bind the mouthOpenness signal to the x and y-axis scale signal of
  // the plane
  planeTransform.scaleX = mouthOpenness;
  planeTransform.scaleY = mouthOpenness;

})(); // Enable async/await in JS [part 2]

Properties

PropertyDescription
count
(get) count: ScalarSignal
(set) (Not Available)


Returns a ScalarSignal representing the number of faces tracked in the scene.

Methods

MethodDescription
createFaceMeshSceneObject
createFaceMeshSceneObject(initialState?: {[key: string]: any}): Promise<FaceMesh>


Create a 'FaceMesh' scene object asynchronously.
When creating the scene objects, keep the following in mind:
- All objects must have an existing class.
- New objects always get assigned a globally unique name and identifier.
- initialState is optional, but encouraged to be used.
createFaceTrackerSceneObject
createFaceTrackerSceneObject(initialState?: {[key: string]: any}): Promise<FaceTracker>


Create a 'FaceTracker' scene object asynchronously.
When creating the scene objects, keep the following in mind:
- All objects must have an existing class.
- New objects always get assigned a globally unique name and identifier.
- initialState is optional, but encouraged to be used.
face
face(index: number): Face


Returns the Face object from the detected face array at the specified index.

Classes

ClassDescription
CheekThe Cheek class exposes the details of a detected cheek.
ChinThe Chin class exposes the details of a detected chin.
EyeThe Eye class exposes the details of a detected eye.
EyebrowThe Eyebrow class exposes the details of a detected eyebrow.
FaceThe Face class exposes details of a tracked face.
ForeheadThe Forehead class exposes the details of a detected forehead.
MouthThe Mouth class exposes the details of a detected mouth.
NoseThe Nose class exposes the details of a detected nose.

Was this article helpful?