@idmission/websdk-core 0.2.0-rc.2 → 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 (82) hide show
  1. package/README.md +8 -1
  2. package/dist/client/IdmissionClient.d.ts +2 -0
  3. package/dist/client/IdmissionClient.d.ts.map +1 -1
  4. package/dist/client/IdmissionClient.js +3 -0
  5. package/dist/client/artifacts.d.ts +2 -0
  6. package/dist/client/artifacts.d.ts.map +1 -1
  7. package/dist/client/payload.d.ts.map +1 -1
  8. package/dist/client/payload.js +2 -1
  9. package/dist/client/types.d.ts +2 -0
  10. package/dist/client/types.d.ts.map +1 -1
  11. package/dist/documentCapture/autoCaptureEngine.d.ts +106 -0
  12. package/dist/documentCapture/autoCaptureEngine.d.ts.map +1 -0
  13. package/dist/documentCapture/autoCaptureEngine.js +456 -0
  14. package/dist/documentCapture/autoCaptureGeometry.d.ts +424 -0
  15. package/dist/documentCapture/autoCaptureGeometry.d.ts.map +1 -0
  16. package/dist/documentCapture/autoCaptureGeometry.js +394 -0
  17. package/dist/documentCapture/autoCaptureGuidance.d.ts +61 -0
  18. package/dist/documentCapture/autoCaptureGuidance.d.ts.map +1 -0
  19. package/dist/documentCapture/autoCaptureGuidance.js +73 -0
  20. package/dist/documentCapture/autoCaptureMetadata.d.ts +185 -0
  21. package/dist/documentCapture/autoCaptureMetadata.d.ts.map +1 -0
  22. package/dist/documentCapture/autoCaptureMetadata.js +197 -0
  23. package/dist/documentCapture/autoCaptureOptions.d.ts +212 -0
  24. package/dist/documentCapture/autoCaptureOptions.d.ts.map +1 -0
  25. package/dist/documentCapture/autoCaptureOptions.js +178 -0
  26. package/dist/documentCapture/autoCaptureShutter.d.ts +162 -0
  27. package/dist/documentCapture/autoCaptureShutter.d.ts.map +1 -0
  28. package/dist/documentCapture/autoCaptureShutter.js +183 -0
  29. package/dist/documentCapture/controller.d.ts +33 -1
  30. package/dist/documentCapture/controller.d.ts.map +1 -1
  31. package/dist/documentCapture/controller.js +604 -40
  32. package/dist/documentCapture/index.d.ts +8 -2
  33. package/dist/documentCapture/index.d.ts.map +1 -1
  34. package/dist/documentCapture/index.js +6 -0
  35. package/dist/documentCapture/reducer.d.ts +26 -1
  36. package/dist/documentCapture/reducer.d.ts.map +1 -1
  37. package/dist/documentCapture/reducer.js +43 -0
  38. package/dist/documentCapture/state.d.ts +118 -0
  39. package/dist/documentCapture/state.d.ts.map +1 -1
  40. package/dist/documentCapture/state.js +24 -0
  41. package/dist/idCapture/controller.d.ts +20 -0
  42. package/dist/idCapture/controller.d.ts.map +1 -1
  43. package/dist/idCapture/controller.js +42 -3
  44. package/dist/idCapture/index.d.ts +1 -1
  45. package/dist/idCapture/index.d.ts.map +1 -1
  46. package/dist/idCapture/index.js +12 -1
  47. package/dist/idCapture/pipeline.d.ts +30 -0
  48. package/dist/idCapture/pipeline.d.ts.map +1 -1
  49. package/dist/idCapture/pipeline.js +33 -10
  50. package/dist/models/DocumentDetection.d.ts +29 -1
  51. package/dist/models/DocumentDetection.d.ts.map +1 -1
  52. package/dist/models/DocumentDetection.js +37 -5
  53. package/dist/models/defaults/PoaDocumentDetectorLiteRT.d.ts +3 -0
  54. package/dist/models/defaults/PoaDocumentDetectorLiteRT.d.ts.map +1 -0
  55. package/dist/models/defaults/PoaDocumentDetectorLiteRT.js +15 -0
  56. package/dist/models/defaults/index.d.ts +4 -1
  57. package/dist/models/defaults/index.d.ts.map +1 -1
  58. package/dist/models/defaults/index.js +4 -0
  59. package/dist/models/preloadModels.d.ts +21 -14
  60. package/dist/models/preloadModels.d.ts.map +1 -1
  61. package/dist/models/preloadModels.js +10 -0
  62. package/dist/models/providers/litert/docDetectPrePost.d.ts.map +1 -1
  63. package/dist/models/providers/litert/docDetectPrePost.js +5 -0
  64. package/dist/selfieCapture/guidance.d.ts +49 -0
  65. package/dist/selfieCapture/guidance.d.ts.map +1 -1
  66. package/dist/selfieCapture/guidance.js +51 -0
  67. package/dist/selfieCapture/index.d.ts +1 -1
  68. package/dist/selfieCapture/index.d.ts.map +1 -1
  69. package/dist/selfieCapture/index.js +1 -1
  70. package/dist/signatureCapture/controller.d.ts.map +1 -1
  71. package/dist/signatureCapture/controller.js +71 -21
  72. package/dist/signatureCapture/pipeline.d.ts +14 -2
  73. package/dist/signatureCapture/pipeline.d.ts.map +1 -1
  74. package/dist/signatureCapture/pipeline.js +30 -7
  75. package/dist/signatureCapture/state.d.ts +15 -0
  76. package/dist/signatureCapture/state.d.ts.map +1 -1
  77. package/dist/version.d.ts +1 -1
  78. package/dist/version.d.ts.map +1 -1
  79. package/dist/version.js +1 -1
  80. package/dist/videoIdCapture/controller.d.ts.map +1 -1
  81. package/dist/videoIdCapture/controller.js +64 -3
  82. package/package.json +1 -1
@@ -0,0 +1,424 @@
1
+ import type { DetectedObject, DetectedObjectBox } from '../models/DocumentDetection';
2
+ import type { PoaGuidanceDiagnostics } from './autoCaptureGuidance';
3
+ /**
4
+ * The two-sided window on `fill`, seeded by #343 and fixed by #380 on real
5
+ * frames.
6
+ *
7
+ * `FILL_MAX` is the anti-crop gate: a capture zoomed into the address block has
8
+ * paper edge to edge, so its fill runs to ~1.0 while a complete sheet on
9
+ * #343's ground truth reads 0.720-0.974. `FILL_MAX` also has to absorb the skew
10
+ * budget (~0.03-0.05 at 10°), which #343 chose to spend here rather than gate
11
+ * or de-skew.
12
+ *
13
+ * `FILL_MIN` is the only thing between an applicant and a sharp unreadable
14
+ * capture — #344 found focus stays flat at 0.86-0.93 on a sheet shrunk to 0.4
15
+ * linear, because the crop IS the box, so focus can never catch "too far".
16
+ *
17
+ * **Fixed by #380** on 4 real handheld recordings (1079x1920 iPhone, printed
18
+ * Carta invoice, 17.5 fps, ~1000 frames), measured on frames that also pass
19
+ * stability — the only population the gate ever acts on:
20
+ *
21
+ * FILL_MAX 0.99 complete sheets reach p95 0.987 / max 0.996, a held capture
22
+ * cropped to the address block reads min 0.994 with 64 of 77
23
+ * frames pinned at exactly 1.0000. At 0.99, 0% of the crop
24
+ * passes and 3.7% of complete frames are rejected. #343's seed
25
+ * survived contact with a phone.
26
+ * FILL_MIN 0.70 the seed of 0.55 accepted **100%** of the too-far frames.
27
+ * A sheet held at a distance where its address is unreadable
28
+ * reads 0.574-0.593; readable framings bottom out at 0.710.
29
+ * At 0.70: 0% of readable rejected, 7.9% of too-far accepted
30
+ * (all of them transition frames, none from the held segment).
31
+ *
32
+ * Both distributions OVERLAP — complete max 0.996 against crop min 0.994,
33
+ * readable min 0.710 against too-far max 0.721. These are operating points in
34
+ * a ~0.01-wide gap, not separators, and that is the honest description of what
35
+ * this quantity can do. #380's simulation is what makes them defensible: over
36
+ * all four recordings the gate fires within a second on a good frame and never
37
+ * fires while the sheet is cropped.
38
+ *
39
+ * Measured on ONE phone, ONE sheet, Carta only (no A4 was available) — and the
40
+ * skew budget #343 estimated at 0.03-0.05 is still UNMEASURED, which matters
41
+ * because FILL_MAX has only 3.7% margin and tilt eats exactly that.
42
+ */
43
+ export declare const POA_FILL_MAX = 0.99;
44
+ export declare const POA_FILL_MIN = 0.7;
45
+ /**
46
+ * Focus floor, seeded by #344 in a POA-SPECIFIC slot rather than reusing
47
+ * `defaultFocusThresholds.singlePage` — that slot is keyed by
48
+ * `detectedDocumentType` and #361 established class 22 still owns paper IDs,
49
+ * and its 0.3 mobile value was a verbatim copy of the idCard entry (`55e1d527`,
50
+ * 2024-12-12) that was never tuned: it passes 5 of 11 visibly-blurred frames.
51
+ * 11 real POA captures score 0.871-0.921, so 0.6 left 1.45x headroom.
52
+ *
53
+ * **#380 took the fallback.** #344's corpus is stills an applicant chose to
54
+ * send; live handheld frames sit lower. On the 272 frames of #380's recordings
55
+ * that would have captured but for focus, 0.6 rejects 4.8% and 0.5 rejects
56
+ * 1.8%, with p05 at 0.670 — 0.6 is biting into the live tail. The distribution
57
+ * is bimodal (motion-blurred frames land at 0.29-0.50), so 0.5 still catches
58
+ * everything genuinely blurred.
59
+ */
60
+ export declare const POA_FOCUS_THRESHOLDS: {
61
+ readonly desktop: 0;
62
+ readonly mobile: 0.5;
63
+ };
64
+ /**
65
+ * Confidence floor before a box is trusted for geometry at all. Mirrors
66
+ * `passportBooklet.ts`'s MIN_BOOKLET_SCORE: the detector emits low-score false
67
+ * positives that would otherwise corrupt every margin below.
68
+ *
69
+ * **Raised from 0.3 to 0.55 by #380, and this is the single most consequential
70
+ * constant on this page.** At 0.3 a box scoring 0.31 is trusted exactly as much
71
+ * as one scoring 0.85 — and the low-scoring boxes are the SPILLED ones, which
72
+ * #343 established are geometrically indistinguishable from a correct box
73
+ * (both are large, both have small margins) and cannot be told apart by any
74
+ * fill threshold. #380 watched that leak: on a recording of a sheet held too
75
+ * far away to read, the fill window alone still let 6 frames through to
76
+ * capture, every one of them on a POA box scoring under 0.50.
77
+ *
78
+ * 0.55 closes that leak completely at zero cost — across #380's four
79
+ * recordings the two well-framed ones still fire at 0.0s and 0.8s, unchanged.
80
+ * The margin is thin (readable holds have a p05 of 0.563), so this is an
81
+ * operating point on one device; the DIRECTION — that 0.3 is far too low to
82
+ * gate a capture on — is the durable part.
83
+ */
84
+ export declare const POA_MIN_SCORE = 0.55;
85
+ /**
86
+ * Labels the framing geometry may be measured on, in priority order.
87
+ *
88
+ * `POA` (LiteRT class 23) is the specialized class, but #342 established that
89
+ * the class is only a "there is paper here" trigger — it holds ~0.81-0.83 on a
90
+ * sheet cropped to a quarter of its area — so the anti-crop guarantee rests
91
+ * entirely on the geometry below. The fallbacks let the same instrument run
92
+ * against the SHIPPING detector, which has no POA class, so the overlay is
93
+ * useful before #354 lands the official export.
94
+ *
95
+ * `Document back` is in the list because real POA sheets read as one. On a
96
+ * printed utility bill the detector routinely scores it ABOVE the POA class
97
+ * (0.73 vs 0.59 on the sheet that prompted this), which is unsurprising: a
98
+ * dense page of text and a card back look alike to a detector trained mostly
99
+ * on IDs. Without it, a frame where POA dipped under `POA_MIN_SCORE` fell all
100
+ * the way through to "no document detected" while the model was confidently
101
+ * looking straight at the page.
102
+ *
103
+ * It does NOT widen what an applicant can submit, which is the objection to
104
+ * check before extending this list: `Document` is already the last fallback,
105
+ * so a generic ID document has always qualified. Excluding only the BACK of
106
+ * one was an asymmetry, not a guard. Nothing here classifies the document —
107
+ * that is the backend's job — and auto-capture is assistance, not enforcement
108
+ * (#345): the cost of a wrong label is a well-framed photo of the wrong page,
109
+ * which is exactly what the manual shutter produces today.
110
+ *
111
+ * Order matters and this goes LAST: priority is by label, so `POA` still wins
112
+ * whenever it clears the floor, and this only decides frames that would
113
+ * otherwise have had no target at all.
114
+ */
115
+ export declare const POA_TARGET_LABELS: readonly string[];
116
+ /** Structural input (matches `passportBooklet.ts`): fixtures pass plain strings. */
117
+ type DetectedObjectLike = {
118
+ box: DetectedObjectBox;
119
+ label: string;
120
+ score: number;
121
+ };
122
+ /**
123
+ * Every gate the loop can fail, in the provisional precedence order the
124
+ * overlay renders them in.
125
+ *
126
+ * `tooClose` and `tooFar` are the two sides of #343's one window and cannot
127
+ * both fire; `tooClose` leads because "move back" is what the AMEX failure
128
+ * needs. Stability and focus sit last because they are meaningless until the
129
+ * sheet is framed — and #344 made `outOfFocus`-last a REQUIREMENT rather than
130
+ * a preference: focus is only computed on a frame that already has a box, and
131
+ * the score is non-monotonic, recovering at severe blur.
132
+ *
133
+ * Ruled by #345. `notStable` sits ABOVE `outOfFocus`, reversing the earlier
134
+ * provisional order, on #383's finding that sub-0.5 focus frames carry REAL
135
+ * motion (box IoU 0.910 vs 0.967, detection 0.664 vs 0.738): on paper a focus
136
+ * failure IS a motion failure, so "hold still" is the instruction that fixes
137
+ * it and "out of focus" is a paraphrase the applicant cannot act on
138
+ * differently. It also matches `idCapture`, which ends NOT_STABLE ->
139
+ * OUT_OF_FOCUS.
140
+ *
141
+ * `outOfFocus`-last is additionally STRUCTURAL, not a preference:
142
+ * `focusThresholdMet` initialises `false` and is only assigned inside the
143
+ * good-frame branch, so promoting focus up the ladder would report "out of
144
+ * focus" on frames where focus was never measured.
145
+ *
146
+ * `noDocument` and `tooFar` stay separate codes even though they always
147
+ * co-fire — an empty fill window returns `tooFar: true` by design, because the
148
+ * hard detection floor makes "no box" the far end of the range rather than an
149
+ * error. Distinct codes cost nothing and give the capture metadata a real
150
+ * distinction; they deliberately do NOT share a string (#346).
151
+ */
152
+ export declare const POA_GATE_ORDER: readonly ["noDocument", "tooClose", "tooFar", "notStable", "outOfFocus"];
153
+ export type PoaGate = (typeof POA_GATE_ORDER)[number];
154
+ /**
155
+ * Raw framing geometry for ONE frame. No verdicts and no thresholds: after
156
+ * #343 there is exactly one gated quantity (`fill`) and it is gated on an
157
+ * aggregate, so a per-frame boolean here would be a second, disagreeing source
158
+ * of truth. See `computePoaFillWindow`.
159
+ *
160
+ * Margins are signed fractions of the frame dimension — negative means the box
161
+ * runs off that edge. They are READINGS: #343 deleted the margin gate, and
162
+ * they survive only so #345 can say WHICH WAY to move once `fill` says the
163
+ * framing is wrong. Reported unrounded because the differences that matter are
164
+ * ~1% of frame.
165
+ */
166
+ export type PoaFraming = {
167
+ leftMargin: number;
168
+ rightMargin: number;
169
+ topMargin: number;
170
+ bottomMargin: number;
171
+ /**
172
+ * The binding edge. Gates NOTHING — kept because #342, #343 and #353's
173
+ * device pass are all recorded in this quantity, so dropping it would
174
+ * silently break comparability with every number already on the map.
175
+ */
176
+ minMargin: number;
177
+ /** The gated quantity: the LARGER of the two components (#343). */
178
+ fill: number;
179
+ fillWidth: number;
180
+ fillHeight: number;
181
+ };
182
+ /**
183
+ * Measure one detected box against the frame. Pure, and verdict-free.
184
+ */
185
+ /** A rectangle in camera-frame pixels. */
186
+ export type FrameRect = {
187
+ x: number;
188
+ y: number;
189
+ width: number;
190
+ height: number;
191
+ };
192
+ /**
193
+ * The rectangle the applicant is actually asked to fill.
194
+ *
195
+ * This is the largest CENTRED sub-rect of the camera frame matching the guide
196
+ * box's aspect ratio, and gating on it rather than on the raw frame is the
197
+ * whole point:
198
+ *
199
+ * - Under `snapToGuides` (the default) the feed is sized to the guide rect
200
+ * under `object-fit: cover`, so this IS the pixels on screen. On a 9:16
201
+ * phone at A4 that is 100% of frame width by 79.5% of height; on a 16:9
202
+ * webcam it is 39.8% of WIDTH by 100% of height.
203
+ * - Under `fullscreen` the guide box is drawn inside a full-bleed feed, so
204
+ * this is a close approximation of it rather than exactly it — still far
205
+ * better than grading the whole frame.
206
+ *
207
+ * Grading the raw frame instead made `max(fillWidth, fillHeight)` pick the
208
+ * axis the applicant does not control on any landscape camera: a sheet filling
209
+ * a portrait guide box read `fillHeight ≈ 0.98` and passed, while
210
+ * `fillWidth ≈ 0.49` — half the capture being background — was never looked at.
211
+ * It also meant the submitted image contained pixels the applicant never saw.
212
+ *
213
+ * With no `aspectRatio` there is no guide to fill, so the frame is the rect.
214
+ */
215
+ export declare function computeGuideRect(frameWidth: number, frameHeight: number, aspectRatio?: number): FrameRect;
216
+ /**
217
+ * Measure a detection box against the guide rect.
218
+ *
219
+ * Margins and fills are fractions OF THE GUIDE RECT, so a sheet wider than the
220
+ * guide reads `fill > 1` and a sheet spilling past an edge reads a NEGATIVE
221
+ * margin. Both are wanted: they are what makes "it does not fit in the box"
222
+ * trip `FILL_MAX` instead of quietly passing.
223
+ */
224
+ export declare function computePoaFraming(box: DetectedObjectBox, rect: FrameRect): PoaFraming;
225
+ /**
226
+ * #343's gate: one two-sided window on `fill`, read on an AGGREGATE rather
227
+ * than on the instantaneous frame.
228
+ *
229
+ * Aggregation is not smoothing for its own sake. Every int8 export's box
230
+ * encodings sit on a grid (official POA 0.16679), so handheld tremor dithers
231
+ * `fill` across 2-3 grid cells and a bare threshold re-crosses on a sheet that
232
+ * is not moving. #343 measured a 12-frame mean cutting that spread ~3.5x, and
233
+ * ruled that aggregating the QUANTITY beats N-of-M on the verdict, which only
234
+ * slows the oscillation down. The window is the same length as the IoU
235
+ * stability window the engine already keeps.
236
+ *
237
+ * `spread` is the deliverable, not decoration: whether hysteresis is owed ON
238
+ * TOP of aggregation is #380's open question, and it is answerable only from
239
+ * how far `instant` actually roams on real handheld video.
240
+ */
241
+ export type PoaFillWindow = {
242
+ /** The quantity the verdict is taken on: mean `fill` across the window. */
243
+ mean: number;
244
+ /** This frame's `fill`, before aggregation. */
245
+ instant: number;
246
+ min: number;
247
+ max: number;
248
+ /** Peak-to-peak across the window — the dither #380 has to measure. */
249
+ spread: number;
250
+ framesTracked: number;
251
+ framesNeeded: number;
252
+ /** In-force constants, carried so the overlay never has to guess them. */
253
+ fillMin: number;
254
+ fillMax: number;
255
+ /** Cropped in / zoomed too close — the AMEX failure. Move back. */
256
+ tooClose: boolean;
257
+ /** Too far away, or below the detection floor. Move closer. */
258
+ tooFar: boolean;
259
+ };
260
+ /**
261
+ * `fillMin` / `fillMax` are REQUIRED so this function reads no constant of its
262
+ * own. `resolveAutoCapture` is the single place the defaults are applied
263
+ * (#340); a `?? POA_FILL_MIN` here would be a second one, free to drift.
264
+ */
265
+ export type PoaFillWindowOptions = {
266
+ fillMin: number;
267
+ fillMax: number;
268
+ framesNeeded?: number;
269
+ };
270
+ /**
271
+ * Aggregate a window of `fill` readings, newest first, and take the verdict.
272
+ *
273
+ * The verdict is taken on however many frames are present rather than waiting
274
+ * for a full window: the window fills in under a second, and `notStable`
275
+ * already holds the capture until the IoU window is complete, so a second
276
+ * "not enough frames" state would only be a way for the two to disagree.
277
+ */
278
+ export declare function computePoaFillWindow(fills: readonly number[], options: PoaFillWindowOptions): PoaFillWindow;
279
+ /**
280
+ * Peak score per emitted label.
281
+ *
282
+ * Keyed by the label STRING the model emitted rather than by a fixed set of
283
+ * per-class fields (IdCapture's `idCardFrontDetectionScore` &c.), so a class
284
+ * the map has not learned yet still shows up — as `class_23` if #354's export
285
+ * lands before the label map does. #341: this is why the still-open class
286
+ * question (#339) cannot ripple into the overlay's field list.
287
+ */
288
+ export declare function peakScoresByLabel(detectedObjects: readonly DetectedObjectLike[]): Record<string, number>;
289
+ export type PoaTarget = {
290
+ label: string;
291
+ score: number;
292
+ box: DetectedObjectBox;
293
+ };
294
+ /**
295
+ * Pick the box the framing geometry is measured on: the highest-scoring box
296
+ * carrying the first label in `labels` that has any candidate above
297
+ * `minScore`. Priority is by LABEL, not by score, so a stray high-confidence
298
+ * `Document` on a POA sheet cannot displace the POA box.
299
+ */
300
+ export declare function selectPoaTarget(detectedObjects: readonly DetectedObjectLike[], labels?: readonly string[], minScore?: number): PoaTarget | null;
301
+ export type PoaGateInputs = {
302
+ framing: PoaFraming | null;
303
+ fillWindow: PoaFillWindow;
304
+ focusThresholdMet: boolean | null;
305
+ isStable: boolean;
306
+ };
307
+ /**
308
+ * Every failing gate, in `POA_GATE_ORDER`. All of them, not just the winner:
309
+ * a one-message ladder is what #345 decides, and the operator needs to see
310
+ * what else was true when it decided.
311
+ *
312
+ * A `null` focus verdict means the focus model is not loaded (or #344 rules it
313
+ * out as a gate) — an absent signal is not a failing one.
314
+ */
315
+ /**
316
+ * The winning guidance code for this frame, or null when every gate passes.
317
+ *
318
+ * Exactly one code wins, and it is the first failure in `POA_GATE_ORDER`.
319
+ */
320
+ export declare function winningPoaGate(inputs: PoaGateInputs): PoaGate | null;
321
+ /**
322
+ * Whether this frame satisfies every gate — the shutter's whole condition.
323
+ *
324
+ * Derived from `failingPoaGates` rather than re-tested, so the thing the
325
+ * shutter fires on and the thing the overlay renders cannot disagree (#345).
326
+ *
327
+ * Thin only on its face: a satisfied frame already implies `stabilityFrames`
328
+ * consecutive frames of IoU >= the stability threshold PLUS a `stabilityFrames`
329
+ * mean of `fill` — roughly 0.7 s of evidence at 17.3 fps. The gates' own
330
+ * windows ARE the accumulator, which is why no second integrator is stacked on
331
+ * top of them.
332
+ */
333
+ export declare function isAutoCaptureSatisfied(inputs: PoaGateInputs): boolean;
334
+ export declare function failingPoaGates(inputs: PoaGateInputs): PoaGate[];
335
+ /**
336
+ * Focus, with everything needed to argue about it. #344 asks whether the
337
+ * ID-card focus model separates a sharp sheet of paper from a blurry one at
338
+ * all; a bare score cannot answer that, so the in-force threshold and the
339
+ * platform branch that supplied it travel with it. #344 answered the question
340
+ * — paper is the STRONGEST substrate measured — and reseeded the threshold in
341
+ * `POA_FOCUS_THRESHOLDS`, where desktop is 0 and therefore passes
342
+ * unconditionally: invisible without `branch` on screen.
343
+ */
344
+ export type AutoCaptureFocusDiagnostics = {
345
+ score: number;
346
+ threshold: number;
347
+ branch: 'desktop' | 'mobile';
348
+ thresholdMet: boolean;
349
+ predictionTimeMs: number;
350
+ };
351
+ /**
352
+ * Stability, as the IoU tracker sees it. `iou` is the WORST pair in the
353
+ * window, which is the value the verdict is actually taken on; `framesTracked`
354
+ * vs `framesNeeded` is what distinguishes "moving" from "not enough frames
355
+ * yet", which look identical from the verdict alone.
356
+ */
357
+ export type AutoCaptureStabilityDiagnostics = {
358
+ worstIou: number | null;
359
+ threshold: number;
360
+ framesTracked: number;
361
+ framesNeeded: number;
362
+ isStable: boolean;
363
+ };
364
+ /**
365
+ * One frame's worth of instrument reading — the engine's entire public state
366
+ * surface.
367
+ *
368
+ * #341's governing constraint: `debug.tsx` only ever reads public controller
369
+ * state, so THIS TYPE IS the surface. Anything the overlay must show has to be
370
+ * here, and anything here is public API the spec (#347) has to keep.
371
+ */
372
+ export type AutoCaptureDiagnostics = {
373
+ /** `FrameLoop`'s frameId — the last rAF handle, not a counter (see FrameLoop.ts). */
374
+ frameId: number;
375
+ /** ms since the loop started, from `FrameLoop`'s `timeRunning`. */
376
+ timeRunning: number;
377
+ /** Every box above the model's score threshold, for the overlay's rectangles. */
378
+ detectedObjects: DetectedObject[];
379
+ /** Peak score per emitted label. */
380
+ scores: Record<string, number>;
381
+ /** The box framing was measured on, or null when nothing qualified. */
382
+ target: PoaTarget | null;
383
+ /** Confidence floor `target` had to clear. */
384
+ targetMinScore: number;
385
+ framing: PoaFraming | null;
386
+ /**
387
+ * #343's gate. Present on every frame, including frames with no box — an
388
+ * empty window is the far end of the range, not a missing reading.
389
+ */
390
+ fillWindow: PoaFillWindow;
391
+ /** null when the focus model is not loaded. */
392
+ focus: AutoCaptureFocusDiagnostics | null;
393
+ stability: AutoCaptureStabilityDiagnostics;
394
+ /** Every failing gate, in `POA_GATE_ORDER`. Empty means all gates pass. */
395
+ failingGates: PoaGate[];
396
+ /**
397
+ * `failingGates.length === 0` — the shutter's whole condition, carried here
398
+ * so a consumer never re-derives it and gets a different answer.
399
+ */
400
+ satisfied: boolean;
401
+ /**
402
+ * The message triple. With a 250 ms debounce and an 1800 ms hold, "wrong
403
+ * threshold" and "stuck message" are indistinguishable on glass without it.
404
+ */
405
+ guidance: PoaGuidanceDiagnostics;
406
+ /** Detector inference time for this frame, ms. */
407
+ detectionTimeMs: number;
408
+ /** Detections/second over the recent window — the honest loop rate. */
409
+ frameRate: number;
410
+ /** Dimensions of the canvas the detector actually ran on. */
411
+ frameWidth: number;
412
+ frameHeight: number;
413
+ /** The camera's decoded resolution. Differs from frame* if the loop downscales. */
414
+ videoWidth: number;
415
+ videoHeight: number;
416
+ /**
417
+ * The rectangle framing was measured against, in frame pixels — the guide
418
+ * box, not the frame, unless no `aspectRatio` was supplied. Reported so the
419
+ * overlay can draw the rectangle the numbers actually refer to.
420
+ */
421
+ guideRect: FrameRect;
422
+ };
423
+ export {};
424
+ //# sourceMappingURL=autoCaptureGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoCaptureGeometry.d.ts","sourceRoot":"","sources":["../../src/documentCapture/autoCaptureGeometry.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAClB,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,YAAY,OAAO,CAAA;AAChC,eAAO,MAAM,YAAY,MAAM,CAAA;AAC/B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB;;;CAAuC,CAAA;AACxE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,e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