face-validator-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ import type { NormalizedLandmark } from '@mediapipe/tasks-vision';
2
+ import { DetectedFaceData, DetectedHandData, ValidationStatus, BoundingBox } from './types';
3
+ /**
4
+ * Calcula o brilho médio de uma região da imagem (0-255).
5
+ */
6
+ export declare function calculateAverageBrightness(imageData: ImageData): number;
7
+ /**
8
+ * Verifica se a face está na distância adequada (baseado no tamanho do bounding box).
9
+ */
10
+ export declare function checkFaceDistance(boundingBox: BoundingBox, minFaceSizeFactor?: number, maxFaceSizeFactor?: number): 'OK' | 'TOO_FAR' | 'TOO_CLOSE';
11
+ /**
12
+ * Verifica se um ponto (normalizado 0-1) está dentro do oval de enquadramento.
13
+ */
14
+ export declare function isPointInsideOval(pointX: number, pointY: number, frameWidth: number, frameHeight: number): boolean;
15
+ /**
16
+ * Verifica se o bounding box da face cabe dentro do oval de enquadramento.
17
+ * Versão simplificada: verifica apenas o centro e limites principais sem margem excessiva.
18
+ */
19
+ export declare function isFaceBoundingBoxInsideOval(boundingBox: BoundingBox, frameWidth: number, frameHeight: number): boolean;
20
+ /**
21
+ * Verifica se a cabeça está reta (sem inclinação lateral, horizontal ou vertical).
22
+ * MediaPipe: usa landmarks dos olhos, nariz e boca.
23
+ */
24
+ export declare function isHeadStraight(landmarks: NormalizedLandmark[], maxTiltDegrees?: number): boolean;
25
+ /**
26
+ * Verifica se a geometria do rosto é plausível (boca visível, não obstruída por mão).
27
+ * MediaPipe: analisa distância nariz-boca e extensão vertical da boca.
28
+ */
29
+ export declare function isFaceGeometryPlausible(landmarks: NormalizedLandmark[], boundingBox: BoundingBox): boolean;
30
+ /**
31
+ * Detecta se a pessoa está usando óculos escuros através da análise de luminosidade dos olhos.
32
+ * Óculos de grau geralmente não bloqueiam completamente a luz, permitindo ver os olhos.
33
+ */
34
+ export declare function hasDarkGlasses(video: HTMLVideoElement, landmarks: NormalizedLandmark[]): boolean;
35
+ /**
36
+ * Verifica se a expressão facial é neutra (sem sorriso, boca fechada, olhos abertos).
37
+ * Rejeita: sorriso, boca aberta, olhos fechados.
38
+ */
39
+ export declare function isNeutralExpression(landmarks: NormalizedLandmark[]): boolean;
40
+ /**
41
+ * Verifica yaw (inclinação lateral) usando visibilidade das orelhas.
42
+ * Quando o rosto está virado para o lado, uma orelha fica mais visível que a outra.
43
+ */
44
+ export declare function isYawAcceptable(landmarks: NormalizedLandmark[]): boolean;
45
+ /**
46
+ * Verifica se a face está estável (sem movimento significativo entre frames).
47
+ */
48
+ export declare function isFaceStable(currentFace: DetectedFaceData | null, previousFace: DetectedFaceData | null, movementThreshold?: number, frameWidth?: number, frameHeight?: number): boolean;
49
+ /**
50
+ * Calcula distância entre um ponto da mão e o centro do rosto (normalizado).
51
+ * Retorna true se a mão estiver próxima ao rosto (indicando possível obstrução).
52
+ */
53
+ export declare function isHandNearFace(handData: DetectedHandData, faceBoundingBox: BoundingBox, maxDistance?: number): boolean;
54
+ /**
55
+ * Desenha overlay de feedback visual (oval, status, debug info).
56
+ */
57
+ export declare function drawOverlay(canvas: HTMLCanvasElement, debugMode: boolean, status: ValidationStatus, faceData?: DetectedFaceData, handData?: DetectedHandData[]): void;
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "face-validator-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Real-time selfie validation SDK with face detection, i18n (pt-BR, en, es). Built on MediaPipe.",
5
+ "license": "MIT",
6
+ "author": "rwmsousa",
7
+ "main": "dist/face-validator-sdk.cjs.js",
8
+ "module": "dist/face-validator-sdk.esm.js",
9
+ "browser": "dist/face-validator-sdk.umd.js",
10
+ "types": "dist/types/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": {
14
+ "types": "./dist/types/index.d.ts",
15
+ "default": "./dist/face-validator-sdk.esm.js"
16
+ },
17
+ "require": {
18
+ "types": "./dist/types/index.d.ts",
19
+ "default": "./dist/face-validator-sdk.cjs.js"
20
+ },
21
+ "browser": "./dist/face-validator-sdk.umd.js",
22
+ "default": "./dist/face-validator-sdk.cjs.js"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "scripts": {
27
+ "start": "webpack serve --config webpack.demo.js --mode development",
28
+ "demo": "webpack serve --config webpack.demo.js --mode development",
29
+ "dev": "webpack serve --config webpack.demo.js --mode development",
30
+ "build": "rimraf dist && webpack --mode production && tsc --emitDeclarationOnly --outDir dist/types",
31
+ "build:demo": "rimraf demo/dist && webpack --config webpack.demo-prod.js --mode production && cp demo/public/index.html demo/dist/index.html",
32
+ "build:watch": "webpack --watch --mode development",
33
+ "lint": "eslint . --ext .ts --report-unused-disable-directives --max-warnings 0",
34
+ "format": "prettier --write \"src/**/*.ts\"",
35
+ "test": "jest",
36
+ "prepublishOnly": "npm run build"
37
+ },
38
+ "keywords": [
39
+ "selfie",
40
+ "validation",
41
+ "face detection",
42
+ "hand detection",
43
+ "mediapipe",
44
+ "camera",
45
+ "typescript",
46
+ "sdk",
47
+ "javascript",
48
+ "i18n",
49
+ "l10n"
50
+ ],
51
+ "files": [
52
+ "dist",
53
+ "LICENSE",
54
+ "README.md",
55
+ "CHANGELOG.md"
56
+ ],
57
+ "dependencies": {
58
+ "@mediapipe/tasks-vision": "^0.10.15"
59
+ },
60
+ "devDependencies": {
61
+ "@types/jest": "^29.5.12",
62
+ "@typescript-eslint/eslint-plugin": "^7.10.0",
63
+ "@typescript-eslint/parser": "^7.10.0",
64
+ "eslint": "^8.57.0",
65
+ "eslint-config-prettier": "^9.1.0",
66
+ "eslint-plugin-prettier": "^5.1.3",
67
+ "html-webpack-plugin": "^5.6.6",
68
+ "jest": "^29.7.0",
69
+ "prettier": "^3.2.5",
70
+ "rimraf": "^5.0.7",
71
+ "ts-jest": "^29.1.4",
72
+ "ts-loader": "^9.5.1",
73
+ "typescript": "^5.4.5",
74
+ "webpack": "^5.91.0",
75
+ "webpack-cli": "^5.1.4",
76
+ "webpack-dev-server": "^5.0.4"
77
+ },
78
+ "engines": {
79
+ "node": ">=16.0.0"
80
+ },
81
+ "repository": {
82
+ "type": "git",
83
+ "url": "git+https://github.com/rwmsousa/face-validator-sdk.git"
84
+ }
85
+ }