/**
* Provides tracking results obtained by visage|SDK.
* To enable this module pass the appropriate license to the SDKProvider.
*/
export class FaceTracker {
static async Create(modulesManager) {
const bsc = modulesManager.modules.visage.module;
const bscAnalyzer = bsc.GetFaceTracker();
return new FaceTracker(bscAnalyzer, bsc);
}
constructor(bscAnalyzer, bsc) {
this.bscAnalyzer = bscAnalyzer;
this.bsc = bsc;
}
/**
*@callback FaceTrackerCallback
*@param {Object} BeautyFaceData - Structure used as container for all face tracking and detection results.
* WARNING: this returns unmanaged objects and BeautyFaceData and all resources accessed
* should be cleaned up with delete() to prevent memory leaks
*/
/**
* Initiates face tracking. When a frame has been analyzed a call to the {@link FaceTrackerCallback}
* function is issued, with the analysis results passed as an argument.
* <br/>
*
* @example
* StartAnalysis(faceData => {
* //look at data
* faceData.delete();
* })
*
* @param {FaceTrackerCallback} FaceTrackerCallback - callback which will be called every time a new frame is analyzed
*/
StartAnalysis(FaceTrackerCallback) {
this.bscAnalyzer.SetCallback(FaceTrackerCallback);
this.bscAnalyzer.StartAnalysis();
}
/**
* Stops the face tracker and stops issuing calls to the callback given as an argument to the
* {@link StartAnalysis} function.
* <br/>
*/
StopAnalysis() {
this.bscAnalyzer.StopAnalysis();
}
/**
* Resets the internal state of the face tracker.
*/
Reset() {
this.bscAnalyzer.Reset();
}
}