@the-horizon-dev/fast-face-detection
Version:
Fast face detection package using TensorFlow.js MediaPipe models for browser and Node.js environments
56 lines (55 loc) • 1.54 kB
TypeScript
import '@tensorflow/tfjs-core';
import '@tensorflow/tfjs-backend-webgl';
import { BaseDetector } from './base-detector';
import { MediaElement, DetectionOptions, Point3D } from '../types/types';
/**
* Configuration for MediaPipe Face Mesh landmark detection model
*/
export interface LandmarkDetectorConfig {
runtime: 'mediapipe' | 'tfjs';
refineLandmarks: boolean;
maxFaces: number;
staticImageMode?: boolean;
flipHorizontal?: boolean;
}
/**
* Face detection result with full mesh
*/
export interface FaceLandmarkResult {
meshPoints: Point3D[];
}
/**
* Responsible for detecting facial landmarks using the MediaPipe Face Mesh model
*/
export declare class LandmarkDetector extends BaseDetector {
private detector;
private config;
/**
* Creates a new landmark detector
*/
constructor(options?: DetectionOptions);
/**
* Ensures the detector is loaded before use
*/
private ensureDetectorLoaded;
/**
* Maps TensorFlow.js model keypoints to our standard Point3D format
*/
private processTensorflowKeypoints;
/**
* Detects the full facial mesh in an image or video
*/
detectLandmarks(input: MediaElement): Promise<Array<FaceLandmarkResult>>;
/**
* Called when options are updated
*/
protected onOptionsUpdated(): void;
/**
* Called for model preloading/warmup
*/
protected onWarmup(): Promise<void>;
/**
* Called when the detector is disposed
*/
protected onDispose(): void;
}