UNPKG

@nuralogix.ai/anura-web-core-sdk

Version:

Anura Web Core SDK

236 lines (221 loc) 6.71 kB
/** * The objectFit sets how the content of an element should be resized to fit its container. * * `contain`: * * The content is scaled to maintain its aspect ratio while fitting within the element's * content box. The entire object is made to fill the box, while preserving its aspect ratio, * so the object will be "letterboxed" or "pillarboxed" if its aspect ratio does not match the * aspect ratio of the box. * * `cover`: * * The content is sized to maintain its aspect ratio while filling the element's entire * content box. If the object's aspect ratio does not match the aspect ratio of its box, then * the object will be clipped to fit. * * `none`: * * The content is not resized. * @enum */ declare const objectFit: { readonly CONTAIN: "contain"; readonly COVER: "cover"; readonly NONE: "none"; }; type ObjectFit = typeof objectFit[keyof typeof objectFit]; interface PipelineStats { cameraFps: number; faceTrackerFps: number; faceCount: number; detectionAvgMs: number; /** Pure ONNX session.run() time inside worker (excludes message overhead) */ detectionInferenceMs: number; detectionSkipN: number; landmarkAvgMs: number; /** Pure ONNX session.run() time inside worker (excludes message overhead) */ landmarkInferenceMs: number; landmarkSkipPct: number; costPerFrameMs: number; } interface DfxFace { detected: boolean; id: string; poseValid: boolean; posePoints: PosePoints, faceRect: DfxRect; } interface PosePoints { [x: string]: { point: number[], valid: boolean; estimated: boolean; quality: number; } } interface DfxRect { x: number; y: number; width: number; height: number; } interface MeshAnnotation { x: number; y: number; z: number; } interface Direction { yaw: number; pitch: number; roll: number; } interface VideoElementSize { width: number; height: number; offsetX: number; offsetY: number; } interface Annotations { silhouette: MeshAnnotation[], direction: Direction; relativeFaceSize: number; shouldersVisible: boolean; movementConstraintExceeded: boolean; } declare const constraintCodes: { readonly DISTANCE: { readonly OK: "OK"; readonly TOO_CLOSE: "TOO_CLOSE"; readonly TOO_FAR: "TOO_FAR"; }; readonly DIRECTION: { readonly OK: "OK"; readonly TURN_LEFT: "TURN_LEFT"; readonly TURN_RIGHT: "TURN_RIGHT"; readonly TURN_UP: "TURN_UP"; readonly TURN_DOWN: "TURN_DOWN"; }; readonly ROLL: { readonly OK: "OK"; readonly TILT_LEFT: "TILT_LEFT"; readonly TILT_RIGHT: "TILT_RIGHT"; }; readonly MOVEMENT: { readonly OK: "OK"; readonly TOO_MUCH_MOVEMENT: "TOO_MUCH_MOVEMENT"; }; readonly CENTER: { readonly OK: "OK"; readonly NOT_CENTERED: "NOT_CENTERED"; }; }; interface Drawables$1 { face: DfxFace; annotations: Annotations; starRating: number; percentCompleted: number; stats: PipelineStats; } type Values<T> = T[keyof T]; type DistanceConstraint = Values<typeof constraintCodes.DISTANCE>; type DirectionConstraint = Values<typeof constraintCodes.DIRECTION>; type RollConstraint = Values<typeof constraintCodes.ROLL>; type MovementConstraint = Values<typeof constraintCodes.MOVEMENT>; type CenterConstraint = Values<typeof constraintCodes.CENTER>; interface ConstraintResults { distanceConstraint: DistanceConstraint; directionConstraint: DirectionConstraint; rollConstraint: RollConstraint; centerConstraint: CenterConstraint; movementConstraint: MovementConstraint; } interface IMask { objectFit: ObjectFit; getSvg(): SVGSVGElement; resize(resizeInfo: IMaskResize): void; draw(drawables: Drawables$1): void; setMaskVisibility(isVisible: boolean): void; setIntermediateResults(points: { [x: string]: { value: string; }; }): void; setLoadingState(isLoading: boolean): void; } interface IMediaElementSize { width: number; height: number; x: number; y: number; } interface IFrameInfo { mediaStreamWidth: number; mediaStreamHeight: number; faceTrackerWidth: number; faceTrackerHeight: number; } interface IMaskResize { mediaElementSize: IMediaElementSize; videoElementSize: VideoElementSize; frameInfo: IFrameInfo; isPortrait: boolean; aspectRatio: number; } type AnimationType = 'TOO_CLOSE' | 'TOO_FAR' | 'LEFT' | 'RIGHT' | 'UP' | 'DOWN' | 'TILT_LEFT' | 'TILT_RIGHT' | 'CENTER_FACE' | 'DEFAULT'; interface IAnuraMask extends IMask { resize(resizeInfo: IMaskResize, settings?: Partial<AnuraMaskSettings>): void; setText(text: string, animation?: AnimationType): void; checkConstraints(face: DfxFace, annotations: Annotations): ConstraintResults; draw(drawables: Drawables, constraints?: ConstraintResults): void; } interface AnuraMaskSettings { starFillColor: string; starBorderColor: string; pulseRateColor: string; pulseRateLabelColor: string; backgroundColor: string; countDownLabelColor: string; faceNotCenteredColor: string; /** must be > 0 and <= 1 */ diameter: number; /** must be > 0 and <= 1 */ bottomMargin: number; /** must be > 0 and <= 1. */ topMargin: number; shouldFlipHorizontally: boolean; swapCoordinates?: boolean; } /** * @document ../../../documents/source/external/howToUseAnuraMask.md */ declare class AnuraMask implements IAnuraMask { #private; static version: string; static name: string; objectFit: ObjectFit; constructor(settings?: Partial<AnuraMaskSettings>); checkConstraints(face: DfxFace, annotations: Annotations): ConstraintResults; getSvg(): SVGSVGElement; resize(resizeInfo: IMaskResize, settings?: Partial<AnuraMaskSettings>): void; setText(text: string, animation?: string): void; draw(drawables: Drawables$1, constraints?: ConstraintResults): void; setMaskVisibility(isVisible: boolean): void; setLoadingState(isLoading: boolean): void; setIntermediateResults(points: { [x: string]: { value: string; }; }): void; } export { AnuraMask, type AnuraMaskSettings, type CenterConstraint, type ConstraintResults, type DirectionConstraint, type DistanceConstraint, type IAnuraMask, type IFrameInfo, type IMaskResize, type IMediaElementSize, type MovementConstraint, type ObjectFit, type RollConstraint, type VideoElementSize, constraintCodes, objectFit };