id-scanner-lib
Version:
Browser-based ID card, QR code, and face recognition scanner with liveness detection
80 lines (75 loc) • 1.62 kB
text/typescript
/**
* Face detection options
*/
export interface FaceDetectionOptions {
/** Maximum number of faces to detect */
maxFaces?: number;
/** Minimum face size (0-1, relative to image) */
minFaceSize?: number;
/** Confidence threshold (0-1) */
confidenceThreshold?: number;
/** Whether to return facial landmarks */
landmarks?: boolean;
/** Input image/frame width (for normalization) */
inputWidth?: number;
/** Input image/frame height (for normalization) */
inputHeight?: number;
}
/**
* Detected face result
*/
export interface FaceDetectionResult {
/** Unique face ID (for tracking) */
faceId: string;
/** Bounding box */
box: BoundingBox;
/** Detection confidence (0-1) */
confidence: number;
/** Facial landmarks (optional) */
landmarks?: FaceLandmarks;
/** Face embedding vector (optional, for comparison) */
embedding?: number[];
/** Detection timestamp */
timestamp: number;
}
/**
* Bounding box
*/
export interface BoundingBox {
x: number;
y: number;
width: number;
height: number;
}
/**
* Face landmarks
*/
export interface FaceLandmarks {
leftEye?: Point;
rightEye?: Point;
nose?: Point;
leftMouth?: Point;
rightMouth?: Point;
leftEar?: Point;
rightEar?: Point;
}
/**
* 2D point
*/
export interface Point {
x: number;
y: number;
}
/**
* Face comparison result
*/
export interface FaceCompareResult {
/** Similarity score (0-1) */
similarity: number;
/** Whether faces match (threshold-based) */
isMatch: boolean;
/** Threshold used */
threshold: number;
/** Comparison algorithm used */
algorithm: string;
}