FaceTracker class
Tracks faces detected by the device front camera as they are found and lost from view. Specific face properties can be separately subscribed to once the face has been added.
Signature:
export declare class FaceTracker extends ExternalObject
Extends: ExternalObject
Remarks
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the FaceTracker
class.
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
FaceAdded | readonly | O3hEvent<readonly [FaceEventData]> | The event that's triggered when a face is detected. |
FaceRemoved | readonly | O3hEvent<readonly [FaceEventData]> | The event that's triggered when a face is lost |
Methods
Method | Modifiers | Description |
---|---|---|
destroy() | Clean up the face tracker when you've finished with it | |
getBlendShapeLookupInfo() | Gets the list of action units that you can subscribe to via FaceTracker.subscribeToBlendShapeCoefficients() | |
getCurrentlyTrackedFaces() | Queries the system for the collection of currently tracked faces | |
setTargetFps(fps) | Sets the system to process at a target FPS. Will only reach the maximum real fps supported by system & device capture. | |
start() | Starts the face tracker so that it begins detecting faces | |
stop() | Stop face tracking | |
subscribeToBlendShapeCoefficients(faceId) | Subscribe for updates to the expression of the tracked face. | |
subscribeToFaceLandmarks(faceId) | Subscribe for updates to the raw position of landmark points on the tracked face | |
subscribeToFaceLandmarks3D(faceId) | Subscribe for updates to the raw position of landmark points on the tracked face |
FaceTracker.destroy() method
Clean up the face tracker when you've finished with it
Signature:
destroy(): void;
Returns:
void
FaceTracker.FaceAdded property
The event that's triggered when a face is detected.
Signature:
get FaceAdded(): O3hEvent<readonly [FaceEventData]>;
Remarks
Will trigger again if the same face is lost and then detected again with a new id value. Be sure to re-subscribe to events on each face added.
FaceTracker.FaceRemoved property
The event that's triggered when a face is lost
Signature:
get FaceRemoved(): O3hEvent<readonly [FaceEventData]>;
FaceTracker.getBlendShapeLookupInfo() method
Gets the list of action units that you can subscribe to via FaceTracker.subscribeToBlendShapeCoefficients()
Signature:
getBlendShapeLookupInfo(): Promise<readonly BlendShapeNamesAndIndices[]>;
Returns:
Promise<readonly BlendShapeNamesAndIndices[]>
FaceTracker.getCurrentlyTrackedFaces() method
Queries the system for the collection of currently tracked faces
Signature:
getCurrentlyTrackedFaces(): Promise<readonly string[]>;
Returns:
Promise<readonly string[]>
The list of tracked face identifiers
FaceTracker.setTargetFps() method
Sets the system to process at a target FPS. Will only reach the maximum real fps supported by system & device capture.
Signature:
setTargetFps(fps: number): void;
Parameters
Parameter | Type | Description |
---|---|---|
fps | number | The number of frames per second you would like results at. Must be a positive integer. |
Returns:
void
FaceTracker.start() method
Starts the face tracker so that it begins detecting faces
Signature:
start(): void;
Returns:
void
FaceTracker.stop() method
Stop face tracking
Signature:
stop(): void;
Returns:
void
FaceTracker.subscribeToBlendShapeCoefficients() method
Subscribe for updates to the expression of the tracked face.
Signature:
subscribeToBlendShapeCoefficients(faceId: string): Subject<readonly number[]>;
Parameters
Parameter | Type | Description |
---|---|---|
faceId | string | The identifier of the face currently detected to track |
Returns:
Subject<readonly number[]>
The collection of intensity values indexed by BlendShapeIndex
Remarks
A facial expression is decomposed into an array of action units; see BlendShapeIndex for more information.
Note the returned subject will only fire events for the first face detected (ie: faceId == 0).
Each value in the array is indexed by a BlendShapeIndex value and represents an intensity value from 0 to 100 (int value).
FaceTracker.subscribeToFaceLandmarks() method
Subscribe for updates to the raw position of landmark points on the tracked face
Signature:
subscribeToFaceLandmarks(faceId: string): Subject<readonly Vector2[]>;
Parameters
Parameter | Type | Description |
---|---|---|
faceId | string | The identifier of the face currently detected to track |
Returns:
Positions of face points in 2D space indexed by FacePointIndex
Remarks
If the face tracker was created from a Component, the position is in viewport coordinate space in pixels with the origin at the top left of the screen.
If the face tracker was created from a O3hMediaSource, the x and y coordinates are a fraction of the source image width and height respectively, between 0 and 1, with the origin at the top left of the source image.
FaceTracker.subscribeToFaceLandmarks3D() method
Warning: This API is now obsolete.
Use FaceTracker.subscribeToFaceLandmarks() instead
Subscribe for updates to the raw position of landmark points on the tracked face
Signature:
subscribeToFaceLandmarks3D(faceId: string): Subject<readonly Vector3[]>;
Parameters
Parameter | Type | Description |
---|---|---|
faceId | string | The identifier of the face currently detected to track |
Returns:
Positions of face points in 3D space with the origin in the top left of the screen indexed by FacePointIndex
Updated over 1 year ago