@masumdev/rn-camera-ai-tflite 0.0.0-stage → 0.2.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.
Files changed (121) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +405 -2
  3. package/lib/commonjs/detector/TFLiteCatAnalyzer.js +609 -0
  4. package/lib/commonjs/detector/TFLiteCatAnalyzer.js.map +1 -0
  5. package/lib/commonjs/detector/TFLiteFaceRecognizer.js +690 -0
  6. package/lib/commonjs/detector/TFLiteFaceRecognizer.js.map +1 -0
  7. package/lib/commonjs/detector/TFLiteObjectDetector.js +392 -0
  8. package/lib/commonjs/detector/TFLiteObjectDetector.js.map +1 -0
  9. package/lib/commonjs/detector/index.js +50 -0
  10. package/lib/commonjs/detector/index.js.map +1 -0
  11. package/lib/commonjs/detector/modelLoader.js +139 -0
  12. package/lib/commonjs/detector/modelLoader.js.map +1 -0
  13. package/lib/commonjs/detector/workletFrameHelper.js +233 -0
  14. package/lib/commonjs/detector/workletFrameHelper.js.map +1 -0
  15. package/lib/commonjs/index.js +39 -0
  16. package/lib/commonjs/index.js.map +1 -0
  17. package/lib/commonjs/package.json +1 -0
  18. package/lib/commonjs/parser/blazeFaceParser.js +771 -0
  19. package/lib/commonjs/parser/blazeFaceParser.js.map +1 -0
  20. package/lib/commonjs/parser/catParser.js +752 -0
  21. package/lib/commonjs/parser/catParser.js.map +1 -0
  22. package/lib/commonjs/parser/index.js +39 -0
  23. package/lib/commonjs/parser/index.js.map +1 -0
  24. package/lib/commonjs/parser/outputParser.js +196 -0
  25. package/lib/commonjs/parser/outputParser.js.map +1 -0
  26. package/lib/commonjs/types/cat.js +6 -0
  27. package/lib/commonjs/types/cat.js.map +1 -0
  28. package/lib/commonjs/types/index.js +28 -0
  29. package/lib/commonjs/types/index.js.map +1 -0
  30. package/lib/commonjs/types/resize-plugin.d.ts +20 -0
  31. package/lib/commonjs/types/tflite.js +6 -0
  32. package/lib/commonjs/types/tflite.js.map +1 -0
  33. package/lib/module/detector/TFLiteCatAnalyzer.js +605 -0
  34. package/lib/module/detector/TFLiteCatAnalyzer.js.map +1 -0
  35. package/lib/module/detector/TFLiteFaceRecognizer.js +684 -0
  36. package/lib/module/detector/TFLiteFaceRecognizer.js.map +1 -0
  37. package/lib/module/detector/TFLiteObjectDetector.js +386 -0
  38. package/lib/module/detector/TFLiteObjectDetector.js.map +1 -0
  39. package/lib/module/detector/index.js +7 -0
  40. package/lib/module/detector/index.js.map +1 -0
  41. package/lib/module/detector/modelLoader.js +133 -0
  42. package/lib/module/detector/modelLoader.js.map +1 -0
  43. package/lib/module/detector/workletFrameHelper.js +226 -0
  44. package/lib/module/detector/workletFrameHelper.js.map +1 -0
  45. package/lib/module/index.js +6 -0
  46. package/lib/module/index.js.map +1 -0
  47. package/lib/module/package.json +1 -0
  48. package/lib/module/parser/blazeFaceParser.js +756 -0
  49. package/lib/module/parser/blazeFaceParser.js.map +1 -0
  50. package/lib/module/parser/catParser.js +739 -0
  51. package/lib/module/parser/catParser.js.map +1 -0
  52. package/lib/module/parser/index.js +6 -0
  53. package/lib/module/parser/index.js.map +1 -0
  54. package/lib/module/parser/outputParser.js +192 -0
  55. package/lib/module/parser/outputParser.js.map +1 -0
  56. package/lib/module/types/cat.js +4 -0
  57. package/lib/module/types/cat.js.map +1 -0
  58. package/lib/module/types/index.js +5 -0
  59. package/lib/module/types/index.js.map +1 -0
  60. package/lib/module/types/resize-plugin.d.ts +20 -0
  61. package/lib/module/types/tflite.js +4 -0
  62. package/lib/module/types/tflite.js.map +1 -0
  63. package/lib/typescript/commonjs/detector/TFLiteCatAnalyzer.d.ts +6 -0
  64. package/lib/typescript/commonjs/detector/TFLiteCatAnalyzer.d.ts.map +1 -0
  65. package/lib/typescript/commonjs/detector/TFLiteFaceRecognizer.d.ts +59 -0
  66. package/lib/typescript/commonjs/detector/TFLiteFaceRecognizer.d.ts.map +1 -0
  67. package/lib/typescript/commonjs/detector/TFLiteObjectDetector.d.ts +41 -0
  68. package/lib/typescript/commonjs/detector/TFLiteObjectDetector.d.ts.map +1 -0
  69. package/lib/typescript/commonjs/detector/index.d.ts +5 -0
  70. package/lib/typescript/commonjs/detector/index.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/detector/modelLoader.d.ts +23 -0
  72. package/lib/typescript/commonjs/detector/modelLoader.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/detector/workletFrameHelper.d.ts +40 -0
  74. package/lib/typescript/commonjs/detector/workletFrameHelper.d.ts.map +1 -0
  75. package/lib/typescript/commonjs/index.d.ts +4 -0
  76. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  77. package/lib/typescript/commonjs/package.json +1 -0
  78. package/lib/typescript/commonjs/parser/blazeFaceParser.d.ts +68 -0
  79. package/lib/typescript/commonjs/parser/blazeFaceParser.d.ts.map +1 -0
  80. package/lib/typescript/commonjs/parser/catParser.d.ts +61 -0
  81. package/lib/typescript/commonjs/parser/catParser.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/parser/index.d.ts +4 -0
  83. package/lib/typescript/commonjs/parser/index.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/parser/outputParser.d.ts +17 -0
  85. package/lib/typescript/commonjs/parser/outputParser.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/types/cat.d.ts +109 -0
  87. package/lib/typescript/commonjs/types/cat.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/types/index.d.ts +3 -0
  89. package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/types/tflite.d.ts +233 -0
  91. package/lib/typescript/commonjs/types/tflite.d.ts.map +1 -0
  92. package/lib/typescript/module/detector/TFLiteCatAnalyzer.d.ts +6 -0
  93. package/lib/typescript/module/detector/TFLiteCatAnalyzer.d.ts.map +1 -0
  94. package/lib/typescript/module/detector/TFLiteFaceRecognizer.d.ts +59 -0
  95. package/lib/typescript/module/detector/TFLiteFaceRecognizer.d.ts.map +1 -0
  96. package/lib/typescript/module/detector/TFLiteObjectDetector.d.ts +41 -0
  97. package/lib/typescript/module/detector/TFLiteObjectDetector.d.ts.map +1 -0
  98. package/lib/typescript/module/detector/index.d.ts +5 -0
  99. package/lib/typescript/module/detector/index.d.ts.map +1 -0
  100. package/lib/typescript/module/detector/modelLoader.d.ts +23 -0
  101. package/lib/typescript/module/detector/modelLoader.d.ts.map +1 -0
  102. package/lib/typescript/module/detector/workletFrameHelper.d.ts +40 -0
  103. package/lib/typescript/module/detector/workletFrameHelper.d.ts.map +1 -0
  104. package/lib/typescript/module/index.d.ts +4 -0
  105. package/lib/typescript/module/index.d.ts.map +1 -0
  106. package/lib/typescript/module/package.json +1 -0
  107. package/lib/typescript/module/parser/blazeFaceParser.d.ts +68 -0
  108. package/lib/typescript/module/parser/blazeFaceParser.d.ts.map +1 -0
  109. package/lib/typescript/module/parser/catParser.d.ts +61 -0
  110. package/lib/typescript/module/parser/catParser.d.ts.map +1 -0
  111. package/lib/typescript/module/parser/index.d.ts +4 -0
  112. package/lib/typescript/module/parser/index.d.ts.map +1 -0
  113. package/lib/typescript/module/parser/outputParser.d.ts +17 -0
  114. package/lib/typescript/module/parser/outputParser.d.ts.map +1 -0
  115. package/lib/typescript/module/types/cat.d.ts +109 -0
  116. package/lib/typescript/module/types/cat.d.ts.map +1 -0
  117. package/lib/typescript/module/types/index.d.ts +3 -0
  118. package/lib/typescript/module/types/index.d.ts.map +1 -0
  119. package/lib/typescript/module/types/tflite.d.ts +233 -0
  120. package/lib/typescript/module/types/tflite.d.ts.map +1 -0
  121. package/package.json +116 -4
@@ -0,0 +1,771 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.computeFaceLivenessMetrics = computeFaceLivenessMetrics;
7
+ exports.cosineSimilarity = cosineSimilarity;
8
+ exports.cropAndResizeFaceToFloat32Buffer = cropAndResizeFaceToFloat32Buffer;
9
+ exports.cropAndResizeFaceToNormalized01Float32Buffer = cropAndResizeFaceToNormalized01Float32Buffer;
10
+ exports.decodeBlazeFaceOutputs = decodeBlazeFaceOutputs;
11
+ exports.decodeFaceMeshOutputs = decodeFaceMeshOutputs;
12
+ exports.expandFaceRoiBox = expandFaceRoiBox;
13
+ exports.extractFaceDescriptorFromRgbAndLandmarks = extractFaceDescriptorFromRgbAndLandmarks;
14
+ exports.generateBlazeFaceAnchors = generateBlazeFaceAnchors;
15
+ exports.generateBlazeFaceFullRangeAnchors = generateBlazeFaceFullRangeAnchors;
16
+ exports.l2NormalizeEmbedding = l2NormalizeEmbedding;
17
+ exports.nonMaxSuppression = nonMaxSuppression;
18
+ const LANDMARK_TYPES = ['rightEye', 'leftEye', 'noseTip', 'mouth', 'rightEar', 'leftEar'];
19
+
20
+ /**
21
+ * Generates the standard 896 SSD anchors for MediaPipe BlazeFace Short-Range (128x128):
22
+ * - Layer 0: 16x16 grid (stride 8), 2 anchors per cell = 512 anchors
23
+ * - Layer 1: 8x8 grid (stride 16), 6 anchors per cell = 384 anchors
24
+ * Total = 896 anchors.
25
+ */
26
+ function generateBlazeFaceAnchors() {
27
+ 'worklet';
28
+
29
+ const anchors = [];
30
+
31
+ // Layer 0: 16x16 feature map, 2 anchors per grid point
32
+ const grid0 = 16;
33
+ for (let y = 0; y < grid0; y++) {
34
+ const anchorY = (y + 0.5) / grid0;
35
+ for (let x = 0; x < grid0; x++) {
36
+ const anchorX = (x + 0.5) / grid0;
37
+ anchors.push({
38
+ x: anchorX,
39
+ y: anchorY
40
+ });
41
+ anchors.push({
42
+ x: anchorX,
43
+ y: anchorY
44
+ });
45
+ }
46
+ }
47
+
48
+ // Layer 1: 8x8 feature map, 6 anchors per grid point
49
+ const grid1 = 8;
50
+ for (let y = 0; y < grid1; y++) {
51
+ const anchorY = (y + 0.5) / grid1;
52
+ for (let x = 0; x < grid1; x++) {
53
+ const anchorX = (x + 0.5) / grid1;
54
+ for (let a = 0; a < 6; a++) {
55
+ anchors.push({
56
+ x: anchorX,
57
+ y: anchorY
58
+ });
59
+ }
60
+ }
61
+ }
62
+ return anchors;
63
+ }
64
+
65
+ /**
66
+ * Generates the standard 2,304 SSD anchors for MediaPipe BlazeFace Full-Range (192x192):
67
+ * - Single layer: 48x48 grid (stride 4), 1 anchor per cell = 2,304 anchors.
68
+ */
69
+ function generateBlazeFaceFullRangeAnchors() {
70
+ 'worklet';
71
+
72
+ const anchors = [];
73
+ const grid = 48;
74
+ for (let y = 0; y < grid; y++) {
75
+ const anchorY = (y + 0.5) / grid;
76
+ for (let x = 0; x < grid; x++) {
77
+ const anchorX = (x + 0.5) / grid;
78
+ anchors.push({
79
+ x: anchorX,
80
+ y: anchorY
81
+ });
82
+ }
83
+ }
84
+ return anchors;
85
+ }
86
+ function extractFloatArray(tensor) {
87
+ 'worklet';
88
+
89
+ if (tensor === null || tensor === undefined) {
90
+ return null;
91
+ }
92
+ if (tensor instanceof Float32Array) {
93
+ return tensor;
94
+ }
95
+ if (tensor instanceof ArrayBuffer) {
96
+ const usable = tensor.byteLength - tensor.byteLength % 4;
97
+ return usable > 0 ? new Float32Array(tensor, 0, usable / 4) : [];
98
+ }
99
+ if (ArrayBuffer.isView(tensor)) {
100
+ const view = tensor;
101
+ const usable = view.byteLength - view.byteLength % 4;
102
+ if (usable <= 0) {
103
+ return [];
104
+ }
105
+ return new Float32Array(view.buffer, view.byteOffset, usable / 4);
106
+ }
107
+ if (Array.isArray(tensor)) {
108
+ return tensor;
109
+ }
110
+ return null;
111
+ }
112
+ function computeIoU(a, b) {
113
+ 'worklet';
114
+
115
+ const xA = Math.max(a.x, b.x);
116
+ const yA = Math.max(a.y, b.y);
117
+ const xB = Math.min(a.x + a.width, b.x + b.width);
118
+ const yB = Math.min(a.y + a.height, b.y + b.height);
119
+ const interWidth = Math.max(0, xB - xA);
120
+ const interHeight = Math.max(0, yB - yA);
121
+ const interArea = interWidth * interHeight;
122
+ if (interArea <= 0) {
123
+ return 0;
124
+ }
125
+ const areaA = a.width * a.height;
126
+ const areaB = b.width * b.height;
127
+ const unionArea = areaA + areaB - interArea;
128
+ return unionArea > 0 ? interArea / unionArea : 0;
129
+ }
130
+
131
+ /**
132
+ * Applies Greedy IoU Non-Maximum Suppression (NMS) to candidate face detections.
133
+ */
134
+ function nonMaxSuppression(candidates, iouThreshold = 0.3, maxResults = 5) {
135
+ 'worklet';
136
+
137
+ if (!candidates || candidates.length === 0 || maxResults <= 0) {
138
+ return [];
139
+ }
140
+ const sorted = candidates.slice().sort((a, b) => b.confidence - a.confidence);
141
+ const selected = [];
142
+ for (let i = 0; i < sorted.length; i++) {
143
+ const candidate = sorted[i];
144
+ let shouldSuppress = false;
145
+ for (let j = 0; j < selected.length; j++) {
146
+ if (computeIoU(candidate.boundingBox, selected[j].boundingBox) > iouThreshold) {
147
+ shouldSuppress = true;
148
+ break;
149
+ }
150
+ }
151
+ if (!shouldSuppress) {
152
+ selected.push(candidate);
153
+ if (selected.length >= maxResults) {
154
+ break;
155
+ }
156
+ }
157
+ }
158
+ return selected;
159
+ }
160
+
161
+ /**
162
+ * Decodes MediaPipe BlazeFace Short-Range output tensors:
163
+ * - Output 0 (regressors): [1, 896, 16] -> (dx, dy, w, h, kp0_x, kp0_y, ..., kp5_x, kp5_y)
164
+ * - Output 1 (classificators): [1, 896, 1] -> raw logit score
165
+ */
166
+ function decodeBlazeFaceOutputs(rawOutputs, anchors, options) {
167
+ 'worklet';
168
+
169
+ if (!rawOutputs || !Array.isArray(rawOutputs) || rawOutputs.length < 2 || !anchors || anchors.length === 0) {
170
+ return [];
171
+ }
172
+ const first = extractFloatArray(rawOutputs[0]);
173
+ const second = extractFloatArray(rawOutputs[1]);
174
+ if (!first || !second) {
175
+ return [];
176
+ }
177
+
178
+ // Determine which tensor is regressors (896 * 16 = 14336) and which is classificators (896)
179
+ let regressors;
180
+ let classificators;
181
+ if (first.length >= second.length * 4) {
182
+ regressors = first;
183
+ classificators = second;
184
+ } else {
185
+ regressors = second;
186
+ classificators = first;
187
+ }
188
+ const rawAnchorCount = Math.min(Math.floor(regressors.length / 16), classificators.length);
189
+ const resolvedAnchors = rawAnchorCount === 2304 && anchors.length !== 2304 ? generateBlazeFaceFullRangeAnchors() : anchors;
190
+ const numAnchors = Math.min(resolvedAnchors.length, rawAnchorCount);
191
+ if (numAnchors <= 0) {
192
+ return [];
193
+ }
194
+ const defaultScale = rawAnchorCount === 2304 ? 192 : 128;
195
+ const confidenceThreshold = typeof options?.confidenceThreshold === 'number' && Number.isFinite(options.confidenceThreshold) ? Math.max(0.01, Math.min(0.99, options.confidenceThreshold)) : 0.55;
196
+ const iouThreshold = typeof options?.iouThreshold === 'number' && Number.isFinite(options.iouThreshold) ? Math.max(0.05, Math.min(0.95, options.iouThreshold)) : 0.3;
197
+ const maxResults = typeof options?.maxResults === 'number' && Number.isFinite(options.maxResults) && options.maxResults >= 0 ? Math.floor(options.maxResults) : 5;
198
+ const scaleW = typeof options?.inputWidth === 'number' && options.inputWidth > 0 ? options.inputWidth : defaultScale;
199
+ const scaleH = typeof options?.inputHeight === 'number' && options.inputHeight > 0 ? options.inputHeight : defaultScale;
200
+ const aspectCorrection = typeof options?.frameAspectRatio === 'number' && Number.isFinite(options.frameAspectRatio) && options.frameAspectRatio > 1.05 ? Math.min(1.75, options.frameAspectRatio * 0.95) : 1.0;
201
+
202
+ // Convert threshold probability to logit threshold to skip Math.exp on low-confidence anchors
203
+ const logitThreshold = Math.log(confidenceThreshold / (1 - confidenceThreshold));
204
+ const candidates = [];
205
+ for (let i = 0; i < numAnchors; i++) {
206
+ const rawLogit = classificators[i];
207
+ if (typeof rawLogit !== 'number' || !Number.isFinite(rawLogit) || rawLogit < logitThreshold) {
208
+ continue;
209
+ }
210
+ const clampedLogit = Math.max(-80, Math.min(80, rawLogit));
211
+ const score = 1 / (1 + Math.exp(-clampedLogit));
212
+ if (score < confidenceThreshold) {
213
+ continue;
214
+ }
215
+ const base = i * 16;
216
+ const dx = regressors[base + 0];
217
+ const dy = regressors[base + 1];
218
+ const rawW = regressors[base + 2];
219
+ const rawH = regressors[base + 3];
220
+ if (!Number.isFinite(dx) || !Number.isFinite(dy) || !Number.isFinite(rawW) || !Number.isFinite(rawH) || rawW <= 0 || rawH <= 0) {
221
+ continue;
222
+ }
223
+ const anchor = resolvedAnchors[i];
224
+ const cx = anchor.x + dx / scaleW;
225
+ const cy = anchor.y + dy / scaleH;
226
+ const w = rawW / scaleW * aspectCorrection;
227
+ const h = rawH / scaleH * 1.06;
228
+ const xmin = Math.max(0, Math.min(1, cx - w / 2));
229
+ const ymin = Math.max(0, Math.min(1, cy - h / 2));
230
+ const xmax = Math.max(0, Math.min(1, cx + w / 2));
231
+ const ymax = Math.max(0, Math.min(1, cy + h / 2));
232
+ const boxWidth = xmax - xmin;
233
+ const boxHeight = ymax - ymin;
234
+ if (boxWidth <= 0.01 || boxHeight <= 0.01) {
235
+ continue;
236
+ }
237
+ const landmarks = [];
238
+ for (let k = 0; k < 6; k++) {
239
+ const kpDx = regressors[base + 4 + k * 2];
240
+ const kpDy = regressors[base + 5 + k * 2];
241
+ if (Number.isFinite(kpDx) && Number.isFinite(kpDy)) {
242
+ const rawKpX = anchor.x + kpDx / scaleW;
243
+ const correctedKpX = cx + (rawKpX - cx) * aspectCorrection;
244
+ landmarks.push({
245
+ x: Math.max(0, Math.min(1, correctedKpX)),
246
+ y: Math.max(0, Math.min(1, anchor.y + kpDy / scaleH)),
247
+ type: LANDMARK_TYPES[k]
248
+ });
249
+ }
250
+ }
251
+ candidates.push({
252
+ id: `face-${i}-${score.toFixed(4)}`,
253
+ label: 'Face',
254
+ confidence: score,
255
+ classIndex: 0,
256
+ boundingBox: {
257
+ x: xmin,
258
+ y: ymin,
259
+ width: boxWidth,
260
+ height: boxHeight
261
+ },
262
+ landmarks
263
+ });
264
+ }
265
+ return nonMaxSuppression(candidates, iouThreshold, maxResults);
266
+ }
267
+
268
+ /**
269
+ * L2-normalizes a feature embedding vector so its Euclidean norm equals 1.0.
270
+ */
271
+ function l2NormalizeEmbedding(vector) {
272
+ 'worklet';
273
+
274
+ if (!vector || vector.length === 0) {
275
+ return [];
276
+ }
277
+ let sumSq = 0;
278
+ for (let i = 0; i < vector.length; i++) {
279
+ const val = vector[i];
280
+ if (typeof val === 'number' && Number.isFinite(val)) {
281
+ sumSq += val * val;
282
+ }
283
+ }
284
+ const norm = Math.sqrt(sumSq);
285
+ const out = new Array(vector.length);
286
+ if (norm <= 1e-12) {
287
+ for (let i = 0; i < vector.length; i++) {
288
+ out[i] = 0;
289
+ }
290
+ return out;
291
+ }
292
+ for (let i = 0; i < vector.length; i++) {
293
+ const val = vector[i];
294
+ out[i] = typeof val === 'number' && Number.isFinite(val) ? val / norm : 0;
295
+ }
296
+ return out;
297
+ }
298
+
299
+ /**
300
+ * Computes the Cosine Similarity in [0, 1] between two face embedding vectors.
301
+ */
302
+ function cosineSimilarity(a, b) {
303
+ 'worklet';
304
+
305
+ if (!a || !b || a.length === 0 || b.length === 0) {
306
+ return 0;
307
+ }
308
+ const len = Math.min(a.length, b.length);
309
+ let dot = 0;
310
+ let normA = 0;
311
+ let normB = 0;
312
+ for (let i = 0; i < len; i++) {
313
+ const va = typeof a[i] === 'number' && Number.isFinite(a[i]) ? a[i] : 0;
314
+ const vb = typeof b[i] === 'number' && Number.isFinite(b[i]) ? b[i] : 0;
315
+ dot += va * vb;
316
+ normA += va * va;
317
+ normB += vb * vb;
318
+ }
319
+ const denom = Math.sqrt(normA) * Math.sqrt(normB);
320
+ if (denom <= 1e-12) {
321
+ return 0;
322
+ }
323
+ const rawCos = dot / denom;
324
+ return Math.max(0, Math.min(1, rawCos));
325
+ }
326
+
327
+ /**
328
+ * Crops a detected face bounding box from an RGB uint8 image buffer and resizes it
329
+ * to a normalized [-1, 1] Float32Array buffer (e.g. [1, 112, 112, 3] for MobileFaceNet).
330
+ */
331
+ function cropAndResizeFaceToFloat32Buffer(rgbBuffer, imgWidth, imgHeight, box, targetWidth = 112, targetHeight = 112) {
332
+ 'worklet';
333
+
334
+ const bytes = new Uint8Array(rgbBuffer);
335
+ const out = new Float32Array(targetWidth * targetHeight * 3);
336
+ const x0 = Math.max(0, Math.min(1, box.x));
337
+ const y0 = Math.max(0, Math.min(1, box.y));
338
+ const bw = Math.max(0.05, Math.min(1 - x0, box.width));
339
+ const bh = Math.max(0.05, Math.min(1 - y0, box.height));
340
+ let dstIdx = 0;
341
+ for (let ty = 0; ty < targetHeight; ty++) {
342
+ const ny = y0 + (ty + 0.5) / targetHeight * bh;
343
+ const sy = Math.max(0, Math.min(imgHeight - 1, Math.floor(ny * imgHeight)));
344
+ const rowBase = sy * imgWidth;
345
+ for (let tx = 0; tx < targetWidth; tx++) {
346
+ const nx = x0 + (tx + 0.5) / targetWidth * bw;
347
+ const sx = Math.max(0, Math.min(imgWidth - 1, Math.floor(nx * imgWidth)));
348
+ const srcIdx = (rowBase + sx) * 3;
349
+ const r = srcIdx + 2 < bytes.byteLength ? bytes[srcIdx] : 127.5;
350
+ const g = srcIdx + 2 < bytes.byteLength ? bytes[srcIdx + 1] : 127.5;
351
+ const b = srcIdx + 2 < bytes.byteLength ? bytes[srcIdx + 2] : 127.5;
352
+ out[dstIdx++] = (r - 127.5) / 128.0;
353
+ out[dstIdx++] = (g - 127.5) / 128.0;
354
+ out[dstIdx++] = (b - 127.5) / 128.0;
355
+ }
356
+ }
357
+ return out.buffer;
358
+ }
359
+
360
+ /**
361
+ * Expands a normalized face bounding box by a padding factor around its center,
362
+ * clamped to [0, 1], for feeding into the 468-point MediaPipe Face Mesh model.
363
+ */
364
+ function expandFaceRoiBox(box, scaleFactor = 1.28) {
365
+ 'worklet';
366
+
367
+ const cx = box.x + box.width / 2;
368
+ const cy = box.y + box.height / 2;
369
+ const newW = Math.min(1, box.width * scaleFactor);
370
+ const newH = Math.min(1, box.height * scaleFactor);
371
+ const x = Math.max(0, Math.min(1 - newW, cx - newW / 2));
372
+ const y = Math.max(0, Math.min(1 - newH, cy - newH / 2));
373
+ return {
374
+ x,
375
+ y,
376
+ width: Math.max(0.05, Math.min(1 - x, newW)),
377
+ height: Math.max(0.05, Math.min(1 - y, newH))
378
+ };
379
+ }
380
+
381
+ /**
382
+ * Crops a face ROI from an RGB uint8 buffer and resizes it to a [0.0, 1.0] Float32Array
383
+ * buffer ([1, 192, 192, 3]) expected by MediaPipe face_landmark.tflite.
384
+ */
385
+ function cropAndResizeFaceToNormalized01Float32Buffer(rgbBuffer, imgWidth, imgHeight, roiBox, targetWidth = 192, targetHeight = 192) {
386
+ 'worklet';
387
+
388
+ const bytes = new Uint8Array(rgbBuffer);
389
+ const out = new Float32Array(targetWidth * targetHeight * 3);
390
+ const x0 = Math.max(0, Math.min(1, roiBox.x));
391
+ const y0 = Math.max(0, Math.min(1, roiBox.y));
392
+ const bw = Math.max(0.05, Math.min(1 - x0, roiBox.width));
393
+ const bh = Math.max(0.05, Math.min(1 - y0, roiBox.height));
394
+ let dstIdx = 0;
395
+ for (let ty = 0; ty < targetHeight; ty++) {
396
+ const ny = y0 + (ty + 0.5) / targetHeight * bh;
397
+ const sy = Math.max(0, Math.min(imgHeight - 1, Math.floor(ny * imgHeight)));
398
+ const rowBase = sy * imgWidth;
399
+ for (let tx = 0; tx < targetWidth; tx++) {
400
+ const nx = x0 + (tx + 0.5) / targetWidth * bw;
401
+ const sx = Math.max(0, Math.min(imgWidth - 1, Math.floor(nx * imgWidth)));
402
+ const srcIdx = (rowBase + sx) * 3;
403
+ const r = srcIdx + 2 < bytes.byteLength ? bytes[srcIdx] : 128;
404
+ const g = srcIdx + 2 < bytes.byteLength ? bytes[srcIdx + 1] : 128;
405
+ const b = srcIdx + 2 < bytes.byteLength ? bytes[srcIdx + 2] : 128;
406
+ out[dstIdx++] = r / 255.0;
407
+ out[dstIdx++] = g / 255.0;
408
+ out[dstIdx++] = b / 255.0;
409
+ }
410
+ }
411
+ return out.buffer;
412
+ }
413
+
414
+ /**
415
+ * Decodes the 1,404-float output tensor ([1, 1, 1, 1404] = 468 x (x, y, z)) from MediaPipe
416
+ * face_landmark.tflite into 468 normalized full-frame FaceLandmark points and computes
417
+ * the exact anatomical face bounding box from the 468-point mesh envelope.
418
+ */
419
+ function decodeFaceMeshOutputs(rawMeshOutputs, roiBox, meshInputSize = 192) {
420
+ 'worklet';
421
+
422
+ if (!rawMeshOutputs || !Array.isArray(rawMeshOutputs) || rawMeshOutputs.length === 0) {
423
+ return null;
424
+ }
425
+ let meshFloats = null;
426
+ for (let i = 0; i < rawMeshOutputs.length; i++) {
427
+ const arr = extractFloatArray(rawMeshOutputs[i]);
428
+ if (arr && (arr.length === 1404 || arr.length === 1434)) {
429
+ meshFloats = arr;
430
+ break;
431
+ }
432
+ }
433
+ if (!meshFloats) {
434
+ return null;
435
+ }
436
+ const landmarks = new Array(468);
437
+ let minX = 1;
438
+ let minY = 1;
439
+ let maxX = 0;
440
+ let maxY = 0;
441
+ for (let v = 0; v < 468; v++) {
442
+ const rawX = meshFloats[v * 3];
443
+ const rawY = meshFloats[v * 3 + 1];
444
+ const rawZ = meshFloats[v * 3 + 2];
445
+ const normInRoiX = Number.isFinite(rawX) ? rawX / meshInputSize : 0.5;
446
+ const normInRoiY = Number.isFinite(rawY) ? rawY / meshInputSize : 0.5;
447
+ const normInRoiZ = Number.isFinite(rawZ) ? rawZ / meshInputSize : 0;
448
+ const fullX = Math.max(0, Math.min(1, roiBox.x + normInRoiX * roiBox.width));
449
+ const fullY = Math.max(0, Math.min(1, roiBox.y + normInRoiY * roiBox.height));
450
+ const fullZ = normInRoiZ * roiBox.width;
451
+ if (fullX < minX) minX = fullX;
452
+ if (fullY < minY) minY = fullY;
453
+ if (fullX > maxX) maxX = fullX;
454
+ if (fullY > maxY) maxY = fullY;
455
+ landmarks[v] = {
456
+ x: fullX,
457
+ y: fullY,
458
+ z: fullZ
459
+ };
460
+ }
461
+ const meshW = Math.max(0.04, maxX - minX);
462
+ const meshH = Math.max(0.04, maxY - minY);
463
+ const padX = meshW * 0.05;
464
+ const padTop = meshH * 0.08;
465
+ const padBottom = meshH * 0.04;
466
+ const bx = Math.max(0, minX - padX);
467
+ const by = Math.max(0, minY - padTop);
468
+ const bxMax = Math.min(1, maxX + padX);
469
+ const byMax = Math.min(1, maxY + padBottom);
470
+ return {
471
+ landmarks,
472
+ tightBox: {
473
+ x: bx,
474
+ y: by,
475
+ width: Math.max(0.04, bxMax - bx),
476
+ height: Math.max(0.04, byMax - by)
477
+ }
478
+ };
479
+ }
480
+
481
+ /**
482
+ * Extracts a 128-D L2-normalized illumination-invariant face signature combining
483
+ * aligned facial ROI grid luminance/chrominance cells and Procrustes-normalized landmark geometry.
484
+ */
485
+ function extractFaceDescriptorFromRgbAndLandmarks(rgbBuffer, imgWidth, imgHeight, box, landmarks) {
486
+ 'worklet';
487
+
488
+ const bytes = new Uint8Array(rgbBuffer);
489
+ const descriptor = [];
490
+
491
+ // 1. Sample 8x8 = 64 aligned facial appearance cells (luminance + R-G chrominance = 96 dims)
492
+ const grid = 8;
493
+ const x0 = Math.max(0, Math.min(1, box.x));
494
+ const y0 = Math.max(0, Math.min(1, box.y));
495
+ const bw = Math.max(0.05, Math.min(1 - x0, box.width));
496
+ const bh = Math.max(0.05, Math.min(1 - y0, box.height));
497
+ const lumValues = [];
498
+ const rgValues = [];
499
+ for (let gy = 0; gy < grid; gy++) {
500
+ const ny = y0 + (gy + 0.5) / grid * bh;
501
+ const py = Math.max(0, Math.min(imgHeight - 1, Math.floor(ny * imgHeight)));
502
+ for (let gx = 0; gx < grid; gx++) {
503
+ const nx = x0 + (gx + 0.5) / grid * bw;
504
+ const px = Math.max(0, Math.min(imgWidth - 1, Math.floor(nx * imgWidth)));
505
+ const idx = (py * imgWidth + px) * 3;
506
+ const r = idx + 2 < bytes.byteLength ? bytes[idx] : 128;
507
+ const g = idx + 2 < bytes.byteLength ? bytes[idx + 1] : 128;
508
+ const b = idx + 2 < bytes.byteLength ? bytes[idx + 2] : 128;
509
+ const lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
510
+ lumValues.push(lum);
511
+ if ((gy + gx) % 2 === 0) {
512
+ rgValues.push((r - g) / 255);
513
+ }
514
+ }
515
+ }
516
+
517
+ // Zero-mean normalize luminance for illumination invariance
518
+ let meanLum = 0;
519
+ for (let i = 0; i < lumValues.length; i++) {
520
+ meanLum += lumValues[i];
521
+ }
522
+ meanLum /= Math.max(1, lumValues.length);
523
+ for (let i = 0; i < lumValues.length; i++) {
524
+ descriptor.push(lumValues[i] - meanLum);
525
+ }
526
+ for (let i = 0; i < rgValues.length; i++) {
527
+ descriptor.push(rgValues[i]);
528
+ }
529
+
530
+ // 2. Procrustes-normalized 6-landmark relative geometry & pairwise ratios (32 dims)
531
+ if (landmarks && landmarks.length >= 6) {
532
+ for (let i = 0; i < 6; i++) {
533
+ const relX = (landmarks[i].x - x0) / bw - 0.5;
534
+ const relY = (landmarks[i].y - y0) / bh - 0.5;
535
+ descriptor.push(relX * 2);
536
+ descriptor.push(relY * 2);
537
+ }
538
+ for (let i = 0; i < 6; i++) {
539
+ for (let j = i + 1; j < 6; j++) {
540
+ const dx = (landmarks[i].x - landmarks[j].x) / bw;
541
+ const dy = (landmarks[i].y - landmarks[j].y) / bh;
542
+ descriptor.push(Math.sqrt(dx * dx + dy * dy));
543
+ }
544
+ }
545
+ }
546
+ while (descriptor.length < 128) {
547
+ descriptor.push(box.width / Math.max(0.05, box.height) * 0.25);
548
+ }
549
+ return l2NormalizeEmbedding(descriptor.slice(0, 128));
550
+ }
551
+ function pointDistance2D(a, b) {
552
+ 'worklet';
553
+
554
+ const dx = a.x - b.x;
555
+ const dy = a.y - b.y;
556
+ return Math.sqrt(dx * dx + dy * dy);
557
+ }
558
+
559
+ /**
560
+ * Computes hybrid Active (Eye Blink EAR, Mouth/Smile MAR, 3D Head Pose Yaw/Pitch/Roll)
561
+ * and Passive (3D Z-Depth Relief + RGB Surface Texture / Anti-Moiré / Glare + Optional Neural Score)
562
+ * face liveness telemetry on the background camera worklet thread.
563
+ */
564
+ function computeFaceLivenessMetrics(rgbBuffer, imgWidth, imgHeight, box, landmarks, livenessThreshold = 0.62, externalAntiSpoofScore) {
565
+ 'worklet';
566
+
567
+ let leftEyeEAR = 0.28;
568
+ let rightEyeEAR = 0.28;
569
+ let mouthAspectRatio = 0.08;
570
+ let smileRatio = 0.36;
571
+ let yawDeg = 0;
572
+ let pitchDeg = 0;
573
+ let rollDeg = 0;
574
+ let depthReliefScore = 0.72;
575
+ if (landmarks && landmarks.length >= 468) {
576
+ // 1. Left Eye EAR (#33, #160, #158, #133, #153, #144)
577
+ const l1 = landmarks[33];
578
+ const l2 = landmarks[160];
579
+ const l3 = landmarks[158];
580
+ const l4 = landmarks[133];
581
+ const l5 = landmarks[153];
582
+ const l6 = landmarks[144];
583
+ const leftHoriz = Math.max(1e-5, pointDistance2D(l1, l4));
584
+ leftEyeEAR = (pointDistance2D(l2, l6) + pointDistance2D(l3, l5)) / (2 * leftHoriz);
585
+
586
+ // 2. Right Eye EAR (#362, #385, #387, #263, #373, #380)
587
+ const r1 = landmarks[362];
588
+ const r2 = landmarks[385];
589
+ const r3 = landmarks[387];
590
+ const r4 = landmarks[263];
591
+ const r5 = landmarks[373];
592
+ const r6 = landmarks[380];
593
+ const rightHoriz = Math.max(1e-5, pointDistance2D(r1, r4));
594
+ rightEyeEAR = (pointDistance2D(r2, r6) + pointDistance2D(r3, r5)) / (2 * rightHoriz);
595
+
596
+ // 3. Mouth Aspect Ratio (MAR) & Smile Ratio (#13, #14, #78, #308, #61, #291, #234, #454)
597
+ const upperInnerLip = landmarks[13];
598
+ const lowerInnerLip = landmarks[14];
599
+ const leftInnerCorner = landmarks[78];
600
+ const rightInnerCorner = landmarks[308];
601
+ const innerMouthWidth = Math.max(1e-5, pointDistance2D(leftInnerCorner, rightInnerCorner));
602
+ mouthAspectRatio = pointDistance2D(upperInnerLip, lowerInnerLip) / innerMouthWidth;
603
+ const leftOuterLip = landmarks[61];
604
+ const rightOuterLip = landmarks[291];
605
+ const leftCheek = landmarks[234];
606
+ const rightCheek = landmarks[454];
607
+ const jawWidth = Math.max(1e-5, pointDistance2D(leftCheek, rightCheek));
608
+ const outerMouthWidth = pointDistance2D(leftOuterLip, rightOuterLip);
609
+ const lipCenterY = (upperInnerLip.y + lowerInnerLip.y) * 0.5;
610
+ const cornerMeanY = (leftOuterLip.y + rightOuterLip.y) * 0.5;
611
+ const cornerLift = Math.max(-0.08, Math.min(0.12, (lipCenterY - cornerMeanY) / Math.max(0.05, box.height)));
612
+ smileRatio = outerMouthWidth / jawWidth + cornerLift * 1.4;
613
+
614
+ // 4. 3D Head Pose Estimation (Yaw, Pitch, Roll)
615
+ const noseTip = landmarks[1];
616
+ const forehead = landmarks[10];
617
+ const chin = landmarks[152];
618
+ const distLeftCheek = Math.max(1e-5, Math.abs(noseTip.x - leftCheek.x));
619
+ const distRightCheek = Math.max(1e-5, Math.abs(rightCheek.x - noseTip.x));
620
+ const yawAsymmetry = (distRightCheek - distLeftCheek) / (distRightCheek + distLeftCheek);
621
+ yawDeg = Math.round(Math.max(-45, Math.min(45, yawAsymmetry * 68)));
622
+ const distForehead = Math.max(1e-5, Math.abs(noseTip.y - forehead.y));
623
+ const distChin = Math.max(1e-5, Math.abs(chin.y - noseTip.y));
624
+ const pitchAsymmetry = (distChin - distForehead * 0.88) / (distChin + distForehead);
625
+ pitchDeg = Math.round(Math.max(-35, Math.min(35, pitchAsymmetry * 65)));
626
+ const eyeDy = r4.y - l1.y;
627
+ const eyeDx = Math.max(1e-5, r4.x - l1.x);
628
+ rollDeg = Math.round(Math.max(-45, Math.min(45, Math.atan2(eyeDy, eyeDx) * (180 / Math.PI))));
629
+
630
+ // 5. 3D Z-Coordinate Depth Relief Score (Nose Tip #1/#4 vs Cheeks #234/#454 & Eyes #33/#263)
631
+ const noseZ = (landmarks[1].z ?? 0) * 0.6 + (landmarks[4].z ?? 0) * 0.4;
632
+ const cheekMeanZ = ((leftCheek.z ?? 0) + (rightCheek.z ?? 0)) * 0.5;
633
+ const eyeMeanZ = ((l1.z ?? 0) + (r4.z ?? 0)) * 0.5;
634
+ const zDeltaNoseCheek = Math.abs(cheekMeanZ - noseZ);
635
+ const zDeltaNoseEye = Math.abs(eyeMeanZ - noseZ);
636
+ const normalizedRelief = (zDeltaNoseCheek * 0.65 + zDeltaNoseEye * 0.35) / Math.max(0.04, box.width);
637
+ if (normalizedRelief > 0.01) {
638
+ depthReliefScore = Math.max(0.25, Math.min(0.98, 0.55 + normalizedRelief * 3.8));
639
+ } else {
640
+ // Fallback when Z is flat (0): indicates planar/2D surface or uncalibrated depth
641
+ depthReliefScore = 0.35;
642
+ }
643
+ } else if (landmarks && landmarks.length >= 6) {
644
+ // 6-keypoint BlazeFace fallback (rightEye=0, leftEye=1, noseTip=2, mouth=3, rightEar=4, leftEar=5)
645
+ const rightEye = landmarks[0];
646
+ const leftEye = landmarks[1];
647
+ const noseTip = landmarks[2];
648
+ const rightEar = landmarks[4];
649
+ const leftEar = landmarks[5];
650
+ const distR = Math.max(1e-5, Math.abs(noseTip.x - rightEar.x));
651
+ const distL = Math.max(1e-5, Math.abs(leftEar.x - noseTip.x));
652
+ const yawAsym = (distL - distR) / (distL + distR);
653
+ yawDeg = Math.round(Math.max(-45, Math.min(45, yawAsym * 65)));
654
+ const eyeMidY = (rightEye.y + leftEye.y) * 0.5;
655
+ const mouth = landmarks[3];
656
+ const dEyeNose = Math.max(1e-5, noseTip.y - eyeMidY);
657
+ const dNoseMouth = Math.max(1e-5, mouth.y - noseTip.y);
658
+ const pitchAsym = (dNoseMouth - dEyeNose * 0.85) / (dNoseMouth + dEyeNose);
659
+ pitchDeg = Math.round(Math.max(-35, Math.min(35, pitchAsym * 62)));
660
+ const eyeDy = leftEye.y - rightEye.y;
661
+ const eyeDx = Math.max(1e-5, leftEye.x - rightEye.x);
662
+ rollDeg = Math.round(Math.max(-45, Math.min(45, Math.atan2(eyeDy, eyeDx) * (180 / Math.PI))));
663
+ }
664
+
665
+ // Passive RGB Surface Texture, Specular Glare & Screen-Grid Moiré Analysis
666
+ let textureScore = 0.82;
667
+ if (rgbBuffer && rgbBuffer.byteLength >= imgWidth * imgHeight * 3 && imgWidth > 8 && imgHeight > 8) {
668
+ const bytes = new Uint8Array(rgbBuffer);
669
+ const x0 = Math.max(0, Math.min(1, box.x));
670
+ const y0 = Math.max(0, Math.min(1, box.y));
671
+ const bw = Math.max(0.05, Math.min(1 - x0, box.width));
672
+ const bh = Math.max(0.05, Math.min(1 - y0, box.height));
673
+ const steps = 12;
674
+ let glareCount = 0;
675
+ let totalSamples = 0;
676
+ let lumSum = 0;
677
+ let lumSqSum = 0;
678
+ let highFreqOscillations = 0;
679
+ let prevDiff = 0;
680
+ for (let gy = 0; gy < steps; gy++) {
681
+ const ny = y0 + (gy + 0.5) / steps * bh;
682
+ const py = Math.max(0, Math.min(imgHeight - 1, Math.floor(ny * imgHeight)));
683
+ prevDiff = 0;
684
+ let prevLum = -1;
685
+ for (let gx = 0; gx < steps; gx++) {
686
+ const nx = x0 + (gx + 0.5) / steps * bw;
687
+ const px = Math.max(0, Math.min(imgWidth - 1, Math.floor(nx * imgWidth)));
688
+ const idx = (py * imgWidth + px) * 3;
689
+ if (idx + 2 < bytes.byteLength) {
690
+ const r = bytes[idx];
691
+ const g = bytes[idx + 1];
692
+ const b = bytes[idx + 2];
693
+ const lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
694
+ if (r > 246 && g > 246 && b > 246) {
695
+ glareCount++;
696
+ }
697
+ lumSum += lum;
698
+ lumSqSum += lum * lum;
699
+ totalSamples++;
700
+ if (prevLum >= 0) {
701
+ const diff = lum - prevLum;
702
+ if (prevDiff !== 0 && diff * prevDiff < -0.0018) {
703
+ highFreqOscillations++;
704
+ }
705
+ prevDiff = diff;
706
+ }
707
+ prevLum = lum;
708
+ }
709
+ }
710
+ }
711
+ if (totalSamples > 0) {
712
+ const meanLum = lumSum / totalSamples;
713
+ const variance = Math.max(0, lumSqSum / totalSamples - meanLum * meanLum);
714
+ const stdDev = Math.sqrt(variance);
715
+ const glareRatio = glareCount / totalSamples;
716
+ const moireRatio = highFreqOscillations / totalSamples;
717
+
718
+ // Natural 3D skin exhibits moderate tonal contrast (stdDev ~0.06..0.24), low glare, and low Moiré oscillation
719
+ const contrastScore = stdDev < 0.015 ? 0.35 : Math.min(0.96, 0.58 + stdDev * 2.2);
720
+ const glarePenalty = glareRatio * 0.65;
721
+ const moirePenalty = Math.max(0, moireRatio - 0.35) * 0.8;
722
+ textureScore = Math.max(0.15, Math.min(0.98, contrastScore - glarePenalty - moirePenalty));
723
+ }
724
+ }
725
+ let passiveScore = depthReliefScore * 0.58 + textureScore * 0.42;
726
+ if (typeof externalAntiSpoofScore === 'number' && Number.isFinite(externalAntiSpoofScore)) {
727
+ const clampedExt = Math.max(0, Math.min(1, externalAntiSpoofScore));
728
+ passiveScore = passiveScore * 0.45 + clampedExt * 0.55;
729
+ }
730
+ passiveScore = Math.max(0, Math.min(1, Number(passiveScore.toFixed(3))));
731
+ const eyeAspectRatio = Number(((leftEyeEAR + rightEyeEAR) * 0.5).toFixed(3));
732
+ const isBlinking = eyeAspectRatio < 0.195;
733
+ const isMouthOpen = mouthAspectRatio >= 0.30;
734
+ const isSmiling = smileRatio >= 0.44;
735
+ let headDirection = 'center';
736
+ if (yawDeg <= -14) {
737
+ headDirection = 'left';
738
+ } else if (yawDeg >= 14) {
739
+ headDirection = 'right';
740
+ } else if (pitchDeg >= 13) {
741
+ headDirection = 'up';
742
+ } else if (pitchDeg <= -13) {
743
+ headDirection = 'down';
744
+ }
745
+ let spoofRisk = 'low';
746
+ if (passiveScore < livenessThreshold * 0.82) {
747
+ spoofRisk = 'high';
748
+ } else if (passiveScore < livenessThreshold) {
749
+ spoofRisk = 'medium';
750
+ }
751
+ return {
752
+ isLive: passiveScore >= livenessThreshold,
753
+ passiveScore,
754
+ spoofRisk,
755
+ depthReliefScore: Number(depthReliefScore.toFixed(3)),
756
+ textureScore: Number(textureScore.toFixed(3)),
757
+ eyeAspectRatio,
758
+ leftEyeEAR: Number(leftEyeEAR.toFixed(3)),
759
+ rightEyeEAR: Number(rightEyeEAR.toFixed(3)),
760
+ isBlinking,
761
+ mouthAspectRatio: Number(mouthAspectRatio.toFixed(3)),
762
+ isMouthOpen,
763
+ smileRatio: Number(smileRatio.toFixed(3)),
764
+ isSmiling,
765
+ yawDeg,
766
+ pitchDeg,
767
+ rollDeg,
768
+ headDirection
769
+ };
770
+ }
771
+ //# sourceMappingURL=blazeFaceParser.js.map