@idmission/websdk-core 0.2.0 → 0.5.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.
- package/README.md +19 -0
- package/dist/attestation/clientAttestation.d.ts +5 -0
- package/dist/attestation/clientAttestation.d.ts.map +1 -1
- package/dist/attestation/clientAttestation.js +4 -4
- package/dist/attestation/collectClientAttestation.d.ts +3 -1
- package/dist/attestation/collectClientAttestation.d.ts.map +1 -1
- package/dist/attestation/collectClientAttestation.js +4 -3
- package/dist/camera/acquireCamera.d.ts +5 -0
- package/dist/camera/acquireCamera.d.ts.map +1 -1
- package/dist/camera/acquireCamera.js +25 -5
- package/dist/captureProgress/actor.d.ts +30 -0
- package/dist/captureProgress/actor.d.ts.map +1 -0
- package/dist/captureProgress/actor.js +754 -0
- package/dist/captureProgress/encoder.d.ts +7 -0
- package/dist/captureProgress/encoder.d.ts.map +1 -0
- package/dist/captureProgress/encoder.js +195 -0
- package/dist/captureProgress/index.d.ts +4 -0
- package/dist/captureProgress/index.d.ts.map +1 -0
- package/dist/captureProgress/index.js +45 -0
- package/dist/captureProgress/internal.d.ts +3 -0
- package/dist/captureProgress/internal.d.ts.map +1 -0
- package/dist/captureProgress/internal.js +1 -0
- package/dist/captureProgress/protocol.d.ts +224 -0
- package/dist/captureProgress/protocol.d.ts.map +1 -0
- package/dist/captureProgress/protocol.js +106 -0
- package/dist/captureProgress/recorder.d.ts +32 -0
- package/dist/captureProgress/recorder.d.ts.map +1 -0
- package/dist/captureProgress/recorder.js +554 -0
- package/dist/captureProgress/transport.d.ts +33 -0
- package/dist/captureProgress/transport.d.ts.map +1 -0
- package/dist/captureProgress/transport.js +109 -0
- package/dist/captureProgress/types.d.ts +35 -0
- package/dist/captureProgress/types.d.ts.map +1 -0
- package/dist/captureProgress/types.js +27 -0
- package/dist/client/IdmissionClient.d.ts +6 -1
- package/dist/client/IdmissionClient.d.ts.map +1 -1
- package/dist/client/IdmissionClient.js +93 -27
- package/dist/client/approval.d.ts +15 -0
- package/dist/client/approval.d.ts.map +1 -0
- package/dist/client/approval.js +19 -0
- package/dist/client/documentFileMetadata.d.ts +13 -0
- package/dist/client/documentFileMetadata.d.ts.map +1 -0
- package/dist/client/documentFileMetadata.js +51 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -0
- package/dist/client/payload.d.ts +3 -0
- package/dist/client/payload.d.ts.map +1 -1
- package/dist/client/payload.js +1 -0
- package/dist/client/submissionMetadata.d.ts +4 -1
- package/dist/client/submissionMetadata.d.ts.map +1 -1
- package/dist/client/submissionMetadata.js +13 -8
- package/dist/client/types.d.ts +6 -0
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/validateSession.d.ts +2 -0
- package/dist/client/validateSession.d.ts.map +1 -1
- package/dist/client/validateSession.js +53 -24
- package/dist/documentCapture/autoCaptureEngine.d.ts.map +1 -1
- package/dist/documentCapture/autoCaptureEngine.js +27 -8
- package/dist/documentCapture/autoCaptureGeometry.d.ts +97 -7
- package/dist/documentCapture/autoCaptureGeometry.d.ts.map +1 -1
- package/dist/documentCapture/autoCaptureGeometry.js +87 -6
- package/dist/documentCapture/autoCaptureMetadata.d.ts +12 -4
- package/dist/documentCapture/autoCaptureMetadata.d.ts.map +1 -1
- package/dist/documentCapture/autoCaptureMetadata.js +8 -5
- package/dist/documentCapture/autoCaptureOptions.d.ts +4 -5
- package/dist/documentCapture/autoCaptureOptions.d.ts.map +1 -1
- package/dist/documentCapture/autoCaptureOptions.js +4 -5
- package/dist/documentCapture/controller.d.ts +5 -0
- package/dist/documentCapture/controller.d.ts.map +1 -1
- package/dist/documentCapture/controller.js +37 -21
- package/dist/documentCapture/index.d.ts +1 -1
- package/dist/documentCapture/index.d.ts.map +1 -1
- package/dist/documentCapture/index.js +1 -1
- package/dist/idCapture/controller.d.ts +4 -1
- package/dist/idCapture/controller.d.ts.map +1 -1
- package/dist/idCapture/controller.js +69 -10
- package/dist/idCapture/state.d.ts +1 -3
- package/dist/idCapture/state.d.ts.map +1 -1
- package/dist/idCapture/submit.d.ts.map +1 -1
- package/dist/idCapture/submit.js +35 -1
- package/dist/idCapture/types.d.ts +2 -0
- package/dist/idCapture/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/liveness/challengeGeometry.d.ts +48 -17
- package/dist/liveness/challengeGeometry.d.ts.map +1 -1
- package/dist/liveness/challengeGeometry.js +101 -54
- package/dist/models/DocumentDetection.d.ts.map +1 -1
- package/dist/models/DocumentDetection.js +38 -2
- package/dist/models/defaults/DocumentDetectorLiteRT.d.ts +2 -2
- package/dist/models/defaults/DocumentDetectorLiteRT.d.ts.map +1 -1
- package/dist/models/defaults/DocumentDetectorLiteRT.js +27 -2
- package/dist/models/defaults/HandLandmarkLiteRT.d.ts +3 -0
- package/dist/models/defaults/HandLandmarkLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/HandLandmarkLiteRT.js +5 -0
- package/dist/models/defaults/IrisLandmarkLiteRT.d.ts +3 -0
- package/dist/models/defaults/IrisLandmarkLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/IrisLandmarkLiteRT.js +5 -0
- package/dist/models/defaults/PalmDetectionLiteRT.d.ts +3 -0
- package/dist/models/defaults/PalmDetectionLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/PalmDetectionLiteRT.js +5 -0
- package/dist/models/defaults/PoaDocumentDetectorLiteRT.d.ts +2 -2
- package/dist/models/defaults/PoaDocumentDetectorLiteRT.d.ts.map +1 -1
- package/dist/models/defaults/PoaDocumentDetectorLiteRT.js +12 -8
- package/dist/models/defaults/index.d.ts +10 -1
- package/dist/models/defaults/index.d.ts.map +1 -1
- package/dist/models/defaults/index.js +12 -0
- package/dist/models/preloadModels.d.ts +4 -3
- package/dist/models/preloadModels.d.ts.map +1 -1
- package/dist/models/preloadModels.js +23 -3
- package/dist/models/providers/litert/FaceLandmarker.d.ts +8 -1
- package/dist/models/providers/litert/FaceLandmarker.d.ts.map +1 -1
- package/dist/models/providers/litert/FaceLandmarker.js +95 -3
- package/dist/models/providers/litert/HandOverFaceDetector.d.ts +27 -0
- package/dist/models/providers/litert/HandOverFaceDetector.d.ts.map +1 -0
- package/dist/models/providers/litert/HandOverFaceDetector.js +162 -0
- package/dist/models/providers/litert/blazeFacePrePost.js +4 -2
- package/dist/models/providers/litert/docDetectPrePost.d.ts.map +1 -1
- package/dist/models/providers/litert/docDetectPrePost.js +17 -5
- package/dist/models/providers/litert/handLandmarkPrePost.d.ts +20 -0
- package/dist/models/providers/litert/handLandmarkPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/handLandmarkPrePost.js +72 -0
- package/dist/models/providers/litert/handOverFace.d.ts +44 -0
- package/dist/models/providers/litert/handOverFace.d.ts.map +1 -0
- package/dist/models/providers/litert/handOverFace.js +139 -0
- package/dist/models/providers/litert/irisPrePost.d.ts +38 -0
- package/dist/models/providers/litert/irisPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/irisPrePost.js +101 -0
- package/dist/models/providers/litert/palmPrePost.d.ts +55 -0
- package/dist/models/providers/litert/palmPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/palmPrePost.js +151 -0
- package/dist/sdkVersions.d.ts +18 -0
- package/dist/sdkVersions.d.ts.map +1 -0
- package/dist/sdkVersions.js +8 -0
- package/dist/selfieCapture/captureQuality.d.ts +43 -0
- package/dist/selfieCapture/captureQuality.d.ts.map +1 -0
- package/dist/selfieCapture/captureQuality.js +87 -0
- package/dist/selfieCapture/challengeRunner.d.ts +9 -2
- package/dist/selfieCapture/challengeRunner.d.ts.map +1 -1
- package/dist/selfieCapture/challengeRunner.js +2 -5
- package/dist/selfieCapture/controller.d.ts +62 -1
- package/dist/selfieCapture/controller.d.ts.map +1 -1
- package/dist/selfieCapture/controller.js +470 -105
- package/dist/selfieCapture/faceTracking.d.ts +69 -1
- package/dist/selfieCapture/faceTracking.d.ts.map +1 -1
- package/dist/selfieCapture/faceTracking.js +134 -6
- package/dist/selfieCapture/guidance.d.ts +15 -0
- package/dist/selfieCapture/guidance.d.ts.map +1 -1
- package/dist/selfieCapture/guidance.js +23 -0
- package/dist/selfieCapture/index.d.ts +3 -2
- package/dist/selfieCapture/index.d.ts.map +1 -1
- package/dist/selfieCapture/index.js +1 -1
- package/dist/selfieCapture/livenessMachine.d.ts +2 -0
- package/dist/selfieCapture/livenessMachine.d.ts.map +1 -1
- package/dist/selfieCapture/livenessMachine.js +8 -0
- package/dist/selfieCapture/pipeline.d.ts +8 -0
- package/dist/selfieCapture/pipeline.d.ts.map +1 -1
- package/dist/selfieCapture/pipeline.js +2 -2
- package/dist/selfieCapture/reducer.d.ts +7 -0
- package/dist/selfieCapture/reducer.d.ts.map +1 -1
- package/dist/selfieCapture/reducer.js +45 -4
- package/dist/selfieCapture/state.d.ts +6 -0
- package/dist/selfieCapture/state.d.ts.map +1 -1
- package/dist/selfieCapture/state.js +1 -0
- package/dist/signature/frameDecode.d.ts.map +1 -1
- package/dist/signature/frameDecode.js +29 -0
- package/dist/signature/metadata.d.ts +10 -1
- package/dist/signature/metadata.d.ts.map +1 -1
- package/dist/signature/quality.d.ts +14 -6
- package/dist/signature/quality.d.ts.map +1 -1
- package/dist/signature/quality.js +13 -4
- package/dist/signatureCapture/controller.d.ts +2 -1
- package/dist/signatureCapture/controller.d.ts.map +1 -1
- package/dist/signatureCapture/controller.js +47 -2
- package/dist/signatureCapture/pipeline.d.ts.map +1 -1
- package/dist/signatureCapture/pipeline.js +6 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CaptureAttemptMetadata } from '../client/types';
|
|
1
2
|
import type { DetectedObjectBox } from '../models/DocumentDetection';
|
|
2
3
|
export declare const CapturedDocumentTypeValues: readonly ["idCardFront", "idCardBack", "passport", "singlePage", "selfie", "idFrontIrImage", "idBackIrImage", "idFrontUvImage", "idBackUvImage", "idBarcodeImage"];
|
|
3
4
|
export type CapturedDocumentType = (typeof CapturedDocumentTypeValues)[number];
|
|
@@ -13,6 +14,7 @@ export type CapturedDocument = {
|
|
|
13
14
|
maxHologramScore?: number;
|
|
14
15
|
barcodeReadabilityScore?: number;
|
|
15
16
|
capturedAt?: string;
|
|
17
|
+
captureAttempt?: CaptureAttemptMetadata;
|
|
16
18
|
};
|
|
17
19
|
export type CapturedDocuments = {
|
|
18
20
|
[k in CapturedDocumentType]?: CapturedDocument;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/idCapture/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,eAAO,MAAM,0BAA0B,oKAW7B,CAAA;AAEV,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,YAAY,EAAE,oBAAoB,CAAA;IAClC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IAInB,aAAa,CAAC,EAAE,MAAM,CAAA;IAGtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,UAAU,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/idCapture/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,eAAO,MAAM,0BAA0B,oKAW7B,CAAA;AAEV,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,YAAY,EAAE,oBAAoB,CAAA;IAClC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IAInB,aAAa,CAAC,EAAE,MAAM,CAAA;IAGtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,UAAU,CAAC,EAAE,MAAM,CAAA;IAInB,cAAc,CAAC,EAAE,sBAAsB,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;KAC7B,CAAC,IAAI,oBAAoB,CAAC,CAAC,EAAE,gBAAgB;CAC/C,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export { DEFAULT_CDN_URL } from './config/cdn';
|
|
|
3
3
|
export { LogLevel, setLogLevel, getLogLevel } from './utils/logger';
|
|
4
4
|
export { createSignatureCaptureController, type SignatureCaptureController, type SignatureCaptureControllerConfig, type SignatureCaptureControllerState, type SignatureStroke, type SignatureCaptureError, type SignatureCaptureArtifact, } from './signatureCapture';
|
|
5
5
|
export { createVideoIdCaptureController, defaultVideoIdCaptureThresholds, VideoIdCaptureGuidanceCode, type VideoIdCaptureController, type VideoIdCaptureControllerConfig, type VideoIdCaptureControllerState, type VideoIdCaptureError, type VideoIdCaptureThresholds, } from './videoIdCapture';
|
|
6
|
+
export { createCaptureProgress } from './captureProgress';
|
|
7
|
+
export type { CaptureProgressOptions, CaptureProgressSession, CaptureProgressTask, WorkflowObservation, WorkflowPhase } from './captureProgress';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EACL,gCAAgC,EAChC,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,GAC9B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EACL,gCAAgC,EAChC,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,GAC9B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,0BAA0B,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACzD,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { DEFAULT_CDN_URL } from './config/cdn';
|
|
|
3
3
|
export { LogLevel, setLogLevel, getLogLevel } from './utils/logger';
|
|
4
4
|
export { createSignatureCaptureController, } from './signatureCapture';
|
|
5
5
|
export { createVideoIdCaptureController, defaultVideoIdCaptureThresholds, VideoIdCaptureGuidanceCode, } from './videoIdCapture';
|
|
6
|
+
export { createCaptureProgress } from './captureProgress';
|
|
@@ -2,6 +2,17 @@ type Point = {
|
|
|
2
2
|
x: number;
|
|
3
3
|
y: number;
|
|
4
4
|
};
|
|
5
|
+
/** One value per eye; `null` for an eye that could not be measured. */
|
|
6
|
+
export type EarPair = {
|
|
7
|
+
left: number | null;
|
|
8
|
+
right: number | null;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Per-eye eye-aspect-ratio, or null if the mesh is unusable (absent, or not
|
|
12
|
+
* the 468-point mesh). An eye with degenerate landmarks reads null on its own
|
|
13
|
+
* without discarding the other.
|
|
14
|
+
*/
|
|
15
|
+
export declare function computeEARPerEye(mesh: Point[] | undefined): EarPair | null;
|
|
5
16
|
/** Average eye-aspect-ratio over both eyes, or null if the mesh is unusable. */
|
|
6
17
|
export declare function computeEAR(mesh: Point[]): number | null;
|
|
7
18
|
type Keypoint = {
|
|
@@ -22,42 +33,62 @@ export type DetectorFrame = {
|
|
|
22
33
|
mesh?: Point[];
|
|
23
34
|
keypoints: Keypoint[];
|
|
24
35
|
};
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
export declare const BLINK_OPEN_FRACTION = 0.8;
|
|
37
|
+
/** A baseline that has seen no frames yet: every gate uses its absolute fallback. */
|
|
38
|
+
export declare const NO_EAR_BASELINE: EarPair;
|
|
39
|
+
/**
|
|
40
|
+
* Whether one eye's sample moves its baseline: a usable reading at or above
|
|
41
|
+
* the eye's close gate (the absolute EAR_CLOSED until it has bootstrapped).
|
|
42
|
+
*
|
|
43
|
+
* A closed sample freezes the baseline: letting it feed the estimate is how a
|
|
44
|
+
* closed-from-the-start face calibrated itself open, and how a held closure
|
|
45
|
+
* decayed the baseline until closed read open — in 1–2 s at 60 fps.
|
|
46
|
+
* Narrow-but-open eyes stay above the close gate.
|
|
47
|
+
*/
|
|
48
|
+
export declare function feedsEarBaseline(baseline: number | null, ear: number | null): ear is number;
|
|
49
|
+
/**
|
|
50
|
+
* Advances the per-eye estimate of the user's open-eye EAR by one frame
|
|
51
|
+
* (null/non-finite/<=0 samples are ignored, closed ones freeze it — see
|
|
52
|
+
* stepEye). Pure, so it can live on the selfie capture's immutable tracking
|
|
53
|
+
* state: fed every frame the capture loop tracks, it accumulates across
|
|
54
|
+
* framing, head-turns, settling and the gaps between blinks, and each eye
|
|
55
|
+
* calibrates to its own open value. Returns `prev` by identity when neither
|
|
56
|
+
* eye moved.
|
|
57
|
+
*/
|
|
58
|
+
export declare function stepEarBaseline(prev: EarPair, ear: EarPair): EarPair;
|
|
32
59
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* fresh one per blink in a "blink twice" step), so a per-detector baseline would
|
|
37
|
-
* reset constantly and never calibrate.
|
|
60
|
+
* True when every measurable eye is above its own open gate — the min of the
|
|
61
|
+
* two, so a wink or one half-closed eye is not open (an averaged EAR let that
|
|
62
|
+
* pass). False when neither eye can be measured.
|
|
38
63
|
*/
|
|
39
|
-
export declare function
|
|
64
|
+
export declare function eyesOpen(ear: EarPair, baseline: EarPair, fraction?: number): boolean;
|
|
65
|
+
export declare const FORWARD_YAW = 0.25;
|
|
40
66
|
/**
|
|
41
67
|
* Stateful, debounced detector for one challenge kind. A blink requires the
|
|
42
68
|
* eyes to reach a sustained closed state then return to open; a turn requires
|
|
43
69
|
* the yaw proxy to reach a sustained directional extreme then return toward
|
|
44
70
|
* center. `detected` latches true once the full gesture completes.
|
|
71
|
+
*
|
|
72
|
+
* `baseline` reads the caller's per-eye open-eye estimate on every frame (it
|
|
73
|
+
* is a getter because the owner replaces that estimate each frame). Omitted,
|
|
74
|
+
* the blink gates stay on their absolute cold-start fallbacks.
|
|
45
75
|
*/
|
|
46
|
-
export declare function createEventDetector(kind: ChallengeKind, baseline?:
|
|
76
|
+
export declare function createEventDetector(kind: ChallengeKind, baseline?: () => EarPair): {
|
|
47
77
|
push(frame: DetectorFrame): void;
|
|
48
78
|
readonly detected: boolean;
|
|
49
79
|
readonly extremeReached: boolean;
|
|
50
80
|
reset(): void;
|
|
51
81
|
};
|
|
52
82
|
/**
|
|
53
|
-
* Latches `settled` once the face is post-gesture "ready": eyes open
|
|
54
|
-
*
|
|
83
|
+
* Latches `settled` once the face is post-gesture "ready": both eyes open
|
|
84
|
+
* (`eyesOpen` against the per-eye baseline — the same gate the selfie capture
|
|
85
|
+
* uses) AND roughly forward (|yaw| < FORWARD_YAW), sustained for
|
|
55
86
|
* SETTLE_SUSTAIN_FRAMES consecutive frames. Used after the challenge sequence
|
|
56
87
|
* passes so capture doesn't fire mid-blink or mid-turn. Yaw that can't be
|
|
57
88
|
* computed doesn't block (eyes-open is the primary gate; head-forward is also
|
|
58
89
|
* enforced by the capture guidance).
|
|
59
90
|
*/
|
|
60
|
-
export declare function createSettleDetector(baseline?:
|
|
91
|
+
export declare function createSettleDetector(baseline?: () => EarPair): {
|
|
61
92
|
push(frame: DetectorFrame): void;
|
|
62
93
|
readonly settled: boolean;
|
|
63
94
|
reset(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"challengeGeometry.d.ts","sourceRoot":"","sources":["../../src/liveness/challengeGeometry.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAmBrC,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"challengeGeometry.d.ts","sourceRoot":"","sources":["../../src/liveness/challengeGeometry.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAmBrC,uEAAuE;AACvE,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAA;AAEnE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAG1E;AAQD,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,GAAG,IAAI,CAGvD;AAED,KAAK,QAAQ,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAA;AAE7D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,GAAG,IAAI,CAS/D;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAA;AAEhE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,KAAK,EAAE,CAAA;IACd,SAAS,EAAE,QAAQ,EAAE,CAAA;CACtB,CAAA;AAiBD,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAQtC,qFAAqF;AACrF,eAAO,MAAM,eAAe,EAAE,OAAqC,CAAA;AAEnE;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,GAAG,EAAE,MAAM,GAAG,IAAI,GACjB,GAAG,IAAI,MAAM,CAKf;AASD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAIpE;AAkBD;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,OAAO,EACjB,QAAQ,SAAsB,GAC7B,OAAO,CAKT;AAeD,eAAO,MAAM,WAAW,OAAO,CAAA;AAc/B;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,aAAa,EACnB,QAAQ,GAAE,MAAM,OAA+B;gBA8CjC,aAAa;;;;EAY5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,GAAE,MAAM,OAA+B;gBAKjC,aAAa;;;EAgB5B"}
|
|
@@ -14,19 +14,27 @@ function earForEye(mesh, idx) {
|
|
|
14
14
|
return null;
|
|
15
15
|
return (dist(p2, p6) + dist(p3, p5)) / (2 * horizontal);
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Per-eye eye-aspect-ratio, or null if the mesh is unusable (absent, or not
|
|
19
|
+
* the 468-point mesh). An eye with degenerate landmarks reads null on its own
|
|
20
|
+
* without discarding the other.
|
|
21
|
+
*/
|
|
22
|
+
export function computeEARPerEye(mesh) {
|
|
19
23
|
if (!Array.isArray(mesh) || mesh.length < 468)
|
|
20
24
|
return null;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
return { left: earForEye(mesh, LEFT_EYE), right: earForEye(mesh, RIGHT_EYE) };
|
|
26
|
+
}
|
|
27
|
+
function averageOfPair({ left, right }) {
|
|
28
|
+
if (left === null)
|
|
29
|
+
return right;
|
|
30
|
+
if (right === null)
|
|
31
|
+
return left;
|
|
32
|
+
return (left + right) / 2;
|
|
33
|
+
}
|
|
34
|
+
/** Average eye-aspect-ratio over both eyes, or null if the mesh is unusable. */
|
|
35
|
+
export function computeEAR(mesh) {
|
|
36
|
+
const ear = computeEARPerEye(mesh);
|
|
37
|
+
return ear ? averageOfPair(ear) : null;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* 2D yaw proxy in roughly [-1, 1]: normalized horizontal offset of the nose tip
|
|
@@ -49,7 +57,7 @@ export function computeYaw(keypoints) {
|
|
|
49
57
|
}
|
|
50
58
|
// Tuning constants (seeded from the prototype; debounce kills jitter).
|
|
51
59
|
// Absolute EAR gates, used only as a cold-start fallback before the per-user
|
|
52
|
-
// baseline is calibrated (see
|
|
60
|
+
// baseline is calibrated (see stepEarBaseline). Fixed gates underserve users
|
|
53
61
|
// with naturally low open-eye EAR (monolid / epicanthic / narrow eyes), which is
|
|
54
62
|
// exactly why the live decision is made relative to the baseline below.
|
|
55
63
|
const EAR_CLOSED = 0.18;
|
|
@@ -58,36 +66,72 @@ const EAR_OPEN = 0.28;
|
|
|
58
66
|
// a blink must drop to <= CLOSE fraction of baseline, then return above OPEN
|
|
59
67
|
// fraction. CLOSE < OPEN preserves the hysteresis band. Eye-shape-agnostic by
|
|
60
68
|
// construction (measures change in the user's own eyes, not a global constant).
|
|
69
|
+
// OPEN is also the one definition of "open" the settle detector and the
|
|
70
|
+
// selfie capture gate (faceTracking's eyesClosed) share.
|
|
61
71
|
const BLINK_CLOSE_FRACTION = 0.6;
|
|
62
|
-
const BLINK_OPEN_FRACTION = 0.8;
|
|
72
|
+
export const BLINK_OPEN_FRACTION = 0.8;
|
|
63
73
|
// Asymmetric EMA for the open-eye baseline: rise fast toward wider openings,
|
|
64
|
-
//
|
|
65
|
-
//
|
|
74
|
+
// drift slowly down toward narrower-but-open ones. Closed samples never reach
|
|
75
|
+
// it at all (see stepEye). Cheap, bufferless, self-correcting.
|
|
66
76
|
const BASELINE_UP_ALPHA = 0.25;
|
|
67
77
|
const BASELINE_DOWN_ALPHA = 0.02;
|
|
78
|
+
/** A baseline that has seen no frames yet: every gate uses its absolute fallback. */
|
|
79
|
+
export const NO_EAR_BASELINE = { left: null, right: null };
|
|
68
80
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
81
|
+
* Whether one eye's sample moves its baseline: a usable reading at or above
|
|
82
|
+
* the eye's close gate (the absolute EAR_CLOSED until it has bootstrapped).
|
|
83
|
+
*
|
|
84
|
+
* A closed sample freezes the baseline: letting it feed the estimate is how a
|
|
85
|
+
* closed-from-the-start face calibrated itself open, and how a held closure
|
|
86
|
+
* decayed the baseline until closed read open — in 1–2 s at 60 fps.
|
|
87
|
+
* Narrow-but-open eyes stay above the close gate.
|
|
74
88
|
*/
|
|
75
|
-
export function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
export function feedsEarBaseline(baseline, ear) {
|
|
90
|
+
if (ear === null || !Number.isFinite(ear) || ear <= 0)
|
|
91
|
+
return false;
|
|
92
|
+
const closeGate = baseline === null ? EAR_CLOSED : baseline * BLINK_CLOSE_FRACTION;
|
|
93
|
+
return ear >= closeGate;
|
|
94
|
+
}
|
|
95
|
+
function stepEye(baseline, ear) {
|
|
96
|
+
if (!feedsEarBaseline(baseline, ear))
|
|
97
|
+
return baseline;
|
|
98
|
+
if (baseline === null)
|
|
99
|
+
return ear;
|
|
100
|
+
const alpha = ear >= baseline ? BASELINE_UP_ALPHA : BASELINE_DOWN_ALPHA;
|
|
101
|
+
return baseline + alpha * (ear - baseline);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Advances the per-eye estimate of the user's open-eye EAR by one frame
|
|
105
|
+
* (null/non-finite/<=0 samples are ignored, closed ones freeze it — see
|
|
106
|
+
* stepEye). Pure, so it can live on the selfie capture's immutable tracking
|
|
107
|
+
* state: fed every frame the capture loop tracks, it accumulates across
|
|
108
|
+
* framing, head-turns, settling and the gaps between blinks, and each eye
|
|
109
|
+
* calibrates to its own open value. Returns `prev` by identity when neither
|
|
110
|
+
* eye moved.
|
|
111
|
+
*/
|
|
112
|
+
export function stepEarBaseline(prev, ear) {
|
|
113
|
+
const left = stepEye(prev.left, ear.left);
|
|
114
|
+
const right = stepEye(prev.right, ear.right);
|
|
115
|
+
return left === prev.left && right === prev.right ? prev : { left, right };
|
|
116
|
+
}
|
|
117
|
+
/** One eye's open gate: a fraction of its own baseline, or EAR_OPEN until calibrated. */
|
|
118
|
+
function openGateFor(baseline, fraction = BLINK_OPEN_FRACTION) {
|
|
119
|
+
return baseline !== null && baseline > 0 ? baseline * fraction : EAR_OPEN;
|
|
120
|
+
}
|
|
121
|
+
function eyeOpen(ear, baseline, fraction) {
|
|
122
|
+
return ear === null ? null : ear > openGateFor(baseline, fraction);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* True when every measurable eye is above its own open gate — the min of the
|
|
126
|
+
* two, so a wink or one half-closed eye is not open (an averaged EAR let that
|
|
127
|
+
* pass). False when neither eye can be measured.
|
|
128
|
+
*/
|
|
129
|
+
export function eyesOpen(ear, baseline, fraction = BLINK_OPEN_FRACTION) {
|
|
130
|
+
const left = eyeOpen(ear.left, baseline.left, fraction);
|
|
131
|
+
const right = eyeOpen(ear.right, baseline.right, fraction);
|
|
132
|
+
if (left === null && right === null)
|
|
133
|
+
return false;
|
|
134
|
+
return left !== false && right !== false;
|
|
91
135
|
}
|
|
92
136
|
// |yaw proxy| past this = a clear turn. Tuned down to 0.30: the 2D proxy
|
|
93
137
|
// underestimates real rotation, and — critically — the face landmarker loses
|
|
@@ -98,10 +142,11 @@ export function createEarBaseline() {
|
|
|
98
142
|
// jitter and unreachable by a held-still photo. Tune on-device.
|
|
99
143
|
const YAW_TURN = 0.3;
|
|
100
144
|
// |yaw| below this completes a turn (returned toward center) and counts as
|
|
101
|
-
// "facing forward" for settling
|
|
102
|
-
//
|
|
145
|
+
// "facing forward" for settling — and for calibrating the eyes-open baseline
|
|
146
|
+
// (faceTracking.ts). Absolute values independent of YAW_TURN so the turn
|
|
147
|
+
// extreme can be lowered without tightening the return/settle gate.
|
|
103
148
|
const YAW_RETURN = 0.2;
|
|
104
|
-
const FORWARD_YAW = 0.25;
|
|
149
|
+
export const FORWARD_YAW = 0.25;
|
|
105
150
|
const SUSTAIN_FRAMES = 2; // an extreme state must persist this many frames
|
|
106
151
|
const SETTLE_SUSTAIN_FRAMES = 3; // settled state must persist this many frames
|
|
107
152
|
// Maps a requested user-facing turn to the sign of the raw-image yaw proxy.
|
|
@@ -118,8 +163,12 @@ const TURN_SIGN = {
|
|
|
118
163
|
* eyes to reach a sustained closed state then return to open; a turn requires
|
|
119
164
|
* the yaw proxy to reach a sustained directional extreme then return toward
|
|
120
165
|
* center. `detected` latches true once the full gesture completes.
|
|
166
|
+
*
|
|
167
|
+
* `baseline` reads the caller's per-eye open-eye estimate on every frame (it
|
|
168
|
+
* is a getter because the owner replaces that estimate each frame). Omitted,
|
|
169
|
+
* the blink gates stay on their absolute cold-start fallbacks.
|
|
121
170
|
*/
|
|
122
|
-
export function createEventDetector(kind, baseline) {
|
|
171
|
+
export function createEventDetector(kind, baseline = () => NO_EAR_BASELINE) {
|
|
123
172
|
let detected = false;
|
|
124
173
|
// phase 0 = waiting for extreme; phase 1 = extreme reached, waiting for return
|
|
125
174
|
let phase = 0;
|
|
@@ -128,11 +177,12 @@ export function createEventDetector(kind, baseline) {
|
|
|
128
177
|
const ear = frame.mesh ? computeEAR(frame.mesh) : null;
|
|
129
178
|
if (ear === null)
|
|
130
179
|
return;
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
|
|
180
|
+
// A blink is a gesture, measured on the averaged EAR (more robust to one
|
|
181
|
+
// eye's landmark jitter mid-blink) against the mean of the two per-eye
|
|
182
|
+
// baselines; absolute gates only until the baseline has bootstrapped.
|
|
183
|
+
const b = averageOfPair(baseline());
|
|
134
184
|
const closeGate = b !== null && b > 0 ? b * BLINK_CLOSE_FRACTION : EAR_CLOSED;
|
|
135
|
-
const openGate = b
|
|
185
|
+
const openGate = openGateFor(b);
|
|
136
186
|
if (phase === 0) {
|
|
137
187
|
if (ear < closeGate) {
|
|
138
188
|
extremeRun++;
|
|
@@ -189,29 +239,26 @@ export function createEventDetector(kind, baseline) {
|
|
|
189
239
|
};
|
|
190
240
|
}
|
|
191
241
|
/**
|
|
192
|
-
* Latches `settled` once the face is post-gesture "ready": eyes open
|
|
193
|
-
*
|
|
242
|
+
* Latches `settled` once the face is post-gesture "ready": both eyes open
|
|
243
|
+
* (`eyesOpen` against the per-eye baseline — the same gate the selfie capture
|
|
244
|
+
* uses) AND roughly forward (|yaw| < FORWARD_YAW), sustained for
|
|
194
245
|
* SETTLE_SUSTAIN_FRAMES consecutive frames. Used after the challenge sequence
|
|
195
246
|
* passes so capture doesn't fire mid-blink or mid-turn. Yaw that can't be
|
|
196
247
|
* computed doesn't block (eyes-open is the primary gate; head-forward is also
|
|
197
248
|
* enforced by the capture guidance).
|
|
198
249
|
*/
|
|
199
|
-
export function createSettleDetector(baseline) {
|
|
250
|
+
export function createSettleDetector(baseline = () => NO_EAR_BASELINE) {
|
|
200
251
|
let settled = false;
|
|
201
252
|
let run = 0;
|
|
202
253
|
return {
|
|
203
254
|
push(frame) {
|
|
204
255
|
if (settled)
|
|
205
256
|
return;
|
|
206
|
-
const ear = frame.mesh ?
|
|
257
|
+
const ear = frame.mesh ? computeEARPerEye(frame.mesh) : null;
|
|
207
258
|
const yaw = computeYaw(frame.keypoints);
|
|
208
|
-
|
|
209
|
-
// for low-baseline users; absolute fallback until the baseline calibrates.
|
|
210
|
-
const b = baseline?.value ?? null;
|
|
211
|
-
const openGate = b !== null && b > 0 ? b * BLINK_OPEN_FRACTION : EAR_OPEN;
|
|
212
|
-
const eyesOpen = ear !== null && ear > openGate;
|
|
259
|
+
const open = ear !== null && eyesOpen(ear, baseline());
|
|
213
260
|
const forward = yaw === null || Math.abs(yaw) < FORWARD_YAW;
|
|
214
|
-
if (
|
|
261
|
+
if (open && forward) {
|
|
215
262
|
run++;
|
|
216
263
|
if (run >= SETTLE_SUSTAIN_FRAMES)
|
|
217
264
|
settled = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentDetection.d.ts","sourceRoot":"","sources":["../../src/models/DocumentDetection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAYnE,cAAc,6BAA6B,CAAA;AAC3C,eAAO,MAAM,sCAAsC,MAAM,CAAA;AACzD,eAAO,MAAM,0CAA0C,QAAQ,CAAA;AAC/D,eAAO,MAAM,kCAAkC,EAAE,2BAWhD,CAAA;AAED,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,aAAa,GACb,YAAY,GACZ,UAAU,GACV,YAAY,CAAA;AAEhB,eAAO,MAAM,wBAAwB;;;;;;CAMpC,CAAA;AAQD,MAAM,MAAM,KAAK,GAEb,UAAU,GACV,eAAe,GACf,KAAK,GACL,QAAQ,GACR,cAAc,GACd,gBAAgB,GAChB,OAAO,GACP,YAAY,GACZ,eAAe,
|
|
1
|
+
{"version":3,"file":"DocumentDetection.d.ts","sourceRoot":"","sources":["../../src/models/DocumentDetection.ts"],"names":[],"mappings":"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"}
|
|
@@ -62,6 +62,30 @@ export async function loadDocumentDetector(modelAssetPath, scoreThreshold = defa
|
|
|
62
62
|
throw new Error('enableHologramOcclusionGuidance requires documentDetectorRuntime="litert". ' +
|
|
63
63
|
'Either switch runtimes or set enableHologramOcclusionGuidance={false}.');
|
|
64
64
|
}
|
|
65
|
+
// The inverse of the three guards above: 'Single page' is a class the
|
|
66
|
+
// MEDIAPIPE model carries and the shared litert export does not. It was
|
|
67
|
+
// briefly available on both — the 20260602 export added it as class 22 — but
|
|
68
|
+
// the 20260904 export dropped that column, so under litert the label never
|
|
69
|
+
// arrives and `detectedDocumentType` can never resolve to 'singlePage'.
|
|
70
|
+
//
|
|
71
|
+
// This throws rather than warns because the failure is otherwise invisible:
|
|
72
|
+
// a narrower model decodes perfectly and simply never emits the label, so
|
|
73
|
+
// the flag reads as enabled while single-page documents are silently never
|
|
74
|
+
// accepted. A capture flow that refuses to start beats one that quietly
|
|
75
|
+
// never succeeds.
|
|
76
|
+
//
|
|
77
|
+
// Scoped to the artifact THIS SDK ships. A caller supplying `modelAssetPath`
|
|
78
|
+
// may be pointing at an export that does carry the class, and there is no
|
|
79
|
+
// way to know from here, so the override is left alone.
|
|
80
|
+
if (opts.allowSinglePageIdCapture &&
|
|
81
|
+
runtime === 'litert' &&
|
|
82
|
+
modelAssetPath === undefined) {
|
|
83
|
+
throw new Error('allowSinglePageIdCapture requires documentDetectorRuntime="mediapipe". ' +
|
|
84
|
+
"The shared litert detector does not carry the 'Single page' class, so " +
|
|
85
|
+
'single-page documents would never be accepted. Either switch runtimes, ' +
|
|
86
|
+
'set allowSinglePageIdCapture={false}, or pass a documentDetector ' +
|
|
87
|
+
'modelAssetPath for an export that carries the class.');
|
|
88
|
+
}
|
|
65
89
|
const artifact = opts.artifact ?? 'shared';
|
|
66
90
|
if (artifact === 'poa' && runtime !== 'litert') {
|
|
67
91
|
throw new Error("The POA document detector requires documentDetectorRuntime=\"litert\": " +
|
|
@@ -97,7 +121,13 @@ export async function makeDocumentDetectorPrediction(frame) {
|
|
|
97
121
|
export let lastDetectionAt = 0;
|
|
98
122
|
export let lastDetectionTime = 0;
|
|
99
123
|
export function setLastDetectionAt(time) {
|
|
100
|
-
|
|
124
|
+
// The first detection has no predecessor to measure against. Subtracting a
|
|
125
|
+
// zeroed `lastDetectionAt` would yield the epoch itself (~1.7e12 ms), whose
|
|
126
|
+
// reciprocal is a ~0 frames-needed sample — that floors `framesNeeded` to 0,
|
|
127
|
+
// leaves `lastNPairs` empty, and makes `documentIsStable` vacuously true on
|
|
128
|
+
// the very first detected frames. Report no interval instead; callers skip
|
|
129
|
+
// it. (sdk2/src/lib/models/DocumentDetection.ts:381-389)
|
|
130
|
+
lastDetectionTime = lastDetectionAt === 0 ? 0 : time - lastDetectionAt;
|
|
101
131
|
lastDetectionAt = time;
|
|
102
132
|
}
|
|
103
133
|
const framesNeededSamples = [];
|
|
@@ -237,10 +267,16 @@ export function processDocumentDetectorPrediction(prediction, thresholds, bounda
|
|
|
237
267
|
const thresholdSet = (thresholds.stability ??
|
|
238
268
|
defaultDocumentDetectionThresholds.stability);
|
|
239
269
|
const threshold = thresholdSet[detectedDocumentType];
|
|
240
|
-
|
|
270
|
+
// Floor at 2: below that no pairs are ever recorded, so the `!some(...)`
|
|
271
|
+
// below is vacuously true and any single frame reads as stable.
|
|
272
|
+
// Requiring the pair buffer to be full as well means stability always
|
|
273
|
+
// rests on at least one measured frame-to-frame IoU.
|
|
274
|
+
// (sdk2/src/lib/models/DocumentDetection.ts:592-602)
|
|
275
|
+
const framesNeeded = Math.max(2, Math.ceil(average(framesNeededSamples)));
|
|
241
276
|
trackBox(bestDocument.box, framesNeeded);
|
|
242
277
|
documentIsStable =
|
|
243
278
|
lastNBoxes.length >= framesNeeded &&
|
|
279
|
+
lastNPairs.length >= framesNeeded - 1 &&
|
|
244
280
|
!lastNPairs.some((pair) => pair.iou < threshold);
|
|
245
281
|
}
|
|
246
282
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const defaultDocumentDetectorLiteRTModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/DocumentDetectorLiteRT/DocumentDetectorLiteRT-
|
|
2
|
-
export declare const defaultDocumentDetectorLiteRTModelHash = "
|
|
1
|
+
export declare const defaultDocumentDetectorLiteRTModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/DocumentDetectorLiteRT/DocumentDetectorLiteRT-20261019_085208.tflite";
|
|
2
|
+
export declare const defaultDocumentDetectorLiteRTModelHash = "DrcT5Sn3q6JeMGwY0cYoyra+djgpM3oVsPi+hy1ihUvscL/YeFvOUeRe3sgi/7vP";
|
|
3
3
|
//# sourceMappingURL=DocumentDetectorLiteRT.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentDetectorLiteRT.d.ts","sourceRoot":"","sources":["../../../src/models/defaults/DocumentDetectorLiteRT.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DocumentDetectorLiteRT.d.ts","sourceRoot":"","sources":["../../../src/models/defaults/DocumentDetectorLiteRT.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,sCAAsC,4HAAmG,CAAA;AAItJ,eAAO,MAAM,sCAAsC,qEACiB,CAAA"}
|
|
@@ -1,3 +1,28 @@
|
|
|
1
1
|
import { DEFAULT_CDN_URL } from '../../config/cdn';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// The shared document detector — idCapture, passport and selfie docdetect all
|
|
3
|
+
// gate on this one. Separate from the POA detector, which documentCapture
|
|
4
|
+
// loads alongside it (#355) and which is a different export with a different
|
|
5
|
+
// class count; see PoaDocumentDetectorLiteRT.ts.
|
|
6
|
+
//
|
|
7
|
+
// Runtime contract, measured on the 20261019 export and unchanged since
|
|
8
|
+
// 20260904: uint8 [1, 300, 300, 3] input (scale 0.00784, zero_point 127), batch
|
|
9
|
+
// fixed at 1, three float32 outputs identified by shape — [1, 1917, 4] box
|
|
10
|
+
// encodings, [1, 1917, 22] class scores, [1917, 4] anchors. Scores are
|
|
11
|
+
// post-sigmoid in [0, 1]. New weights, same class order: every class column
|
|
12
|
+
// correlates best with its own index in the 20260925 export it replaces.
|
|
13
|
+
//
|
|
14
|
+
// Must be the full ("et-al") multi-class model. The ML team's trainer also
|
|
15
|
+
// produces a document-edges-only variant with [1, 1917, 2] class scores
|
|
16
|
+
// (background + Document); it decodes without error, and silently removes
|
|
17
|
+
// every other label — faces, glare, MRZ, barcodes, Document back, Passport
|
|
18
|
+
// page. That variant is ~5.20 MB; the full one is ~5.55 MB.
|
|
19
|
+
//
|
|
20
|
+
// ⚠️ 22 classes: no "Single page" column. 20260602 carried it as index 22 and
|
|
21
|
+
// 20260904 dropped it; no export since has restored it. `detectedDocumentType`
|
|
22
|
+
// cannot resolve to 'singlePage' under the litert runtime — see the note on
|
|
23
|
+
// 'Single page' in models/DocumentDetection.ts. The mediapipe runtime is
|
|
24
|
+
// unaffected; it carries its own labels.
|
|
25
|
+
export const defaultDocumentDetectorLiteRTModelPath = `${DEFAULT_CDN_URL}/models/DocumentDetectorLiteRT/DocumentDetectorLiteRT-20261019_085208.tflite`;
|
|
26
|
+
// BARE base64 SHA-384 — no `sha384-` prefix. `verifySRI` compares against the
|
|
27
|
+
// raw digest and strips no prefix, so a prefixed value rejects every session.
|
|
28
|
+
export const defaultDocumentDetectorLiteRTModelHash = 'DrcT5Sn3q6JeMGwY0cYoyra+djgpM3oVsPi+hy1ihUvscL/YeFvOUeRe3sgi/7vP';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const defaultHandLandmarkLiteRTModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/HandLandmarkLiteRT/HandLandmarkLiteRT-20260915_161935.tflite";
|
|
2
|
+
export declare const defaultHandLandmarkLiteRTModelHash = "gtJSQzOWy/5NVcMDY+UeZvfjrZzQwAKBqAExfq/jncvTkIwQ8026kGmNvCDZymBM";
|
|
3
|
+
//# sourceMappingURL=HandLandmarkLiteRT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandLandmarkLiteRT.d.ts","sourceRoot":"","sources":["../../../src/models/defaults/HandLandmarkLiteRT.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kCAAkC,oHAA2F,CAAA;AAG1I,eAAO,MAAM,kCAAkC,qEACqB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DEFAULT_CDN_URL } from '../../config/cdn';
|
|
2
|
+
export const defaultHandLandmarkLiteRTModelPath = `${DEFAULT_CDN_URL}/models/HandLandmarkLiteRT/HandLandmarkLiteRT-20260915_161935.tflite`;
|
|
3
|
+
// BARE base64 SHA-384 — no `sha384-` prefix. `verifySRI` compares against the
|
|
4
|
+
// raw digest and strips no prefix, so a prefixed value rejects every session.
|
|
5
|
+
export const defaultHandLandmarkLiteRTModelHash = 'gtJSQzOWy/5NVcMDY+UeZvfjrZzQwAKBqAExfq/jncvTkIwQ8026kGmNvCDZymBM';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const defaultIrisLandmarkLiteRTModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/IrisLandmarkLiteRT/IrisLandmarkLiteRT-20260914_133218.tflite";
|
|
2
|
+
export declare const defaultIrisLandmarkLiteRTModelHash = "B8EJfxDZJqDEAcQskF1ZTMJ+17pBjKEDrrwlL5JWYSGM3JFA1zauDMMj1DoWMFW+";
|
|
3
|
+
//# sourceMappingURL=IrisLandmarkLiteRT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IrisLandmarkLiteRT.d.ts","sourceRoot":"","sources":["../../../src/models/defaults/IrisLandmarkLiteRT.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kCAAkC,oHAA2F,CAAA;AAG1I,eAAO,MAAM,kCAAkC,qEACqB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DEFAULT_CDN_URL } from '../../config/cdn';
|
|
2
|
+
export const defaultIrisLandmarkLiteRTModelPath = `${DEFAULT_CDN_URL}/models/IrisLandmarkLiteRT/IrisLandmarkLiteRT-20260914_133218.tflite`;
|
|
3
|
+
// BARE base64 SHA-384 — no `sha384-` prefix. `verifySRI` compares against the
|
|
4
|
+
// raw digest and strips no prefix, so a prefixed value rejects every session.
|
|
5
|
+
export const defaultIrisLandmarkLiteRTModelHash = 'B8EJfxDZJqDEAcQskF1ZTMJ+17pBjKEDrrwlL5JWYSGM3JFA1zauDMMj1DoWMFW+';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const defaultPalmDetectionLiteRTModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/PalmDetectionLiteRT/PalmDetectionLiteRT-20260915_161928.tflite";
|
|
2
|
+
export declare const defaultPalmDetectionLiteRTModelHash = "2zWhCQzYfkTW2BIuGWxd0Q8I/b4NYzoXK6qxQ5mPN41/OhEUInq9cooM6iokzqIM";
|
|
3
|
+
//# sourceMappingURL=PalmDetectionLiteRT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PalmDetectionLiteRT.d.ts","sourceRoot":"","sources":["../../../src/models/defaults/PalmDetectionLiteRT.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mCAAmC,sHAA6F,CAAA;AAG7I,eAAO,MAAM,mCAAmC,qEACoB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DEFAULT_CDN_URL } from '../../config/cdn';
|
|
2
|
+
export const defaultPalmDetectionLiteRTModelPath = `${DEFAULT_CDN_URL}/models/PalmDetectionLiteRT/PalmDetectionLiteRT-20260915_161928.tflite`;
|
|
3
|
+
// BARE base64 SHA-384 — no `sha384-` prefix. `verifySRI` compares against the
|
|
4
|
+
// raw digest and strips no prefix, so a prefixed value rejects every session.
|
|
5
|
+
export const defaultPalmDetectionLiteRTModelHash = '2zWhCQzYfkTW2BIuGWxd0Q8I/b4NYzoXK6qxQ5mPN41/OhEUInq9cooM6iokzqIM';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const defaultPoaDocumentDetectorLiteRTModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/DocumentDetectorLiteRT/DocumentDetectorLiteRT-
|
|
2
|
-
export declare const defaultPoaDocumentDetectorLiteRTModelHash = "
|
|
1
|
+
export declare const defaultPoaDocumentDetectorLiteRTModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/DocumentDetectorLiteRT/DocumentDetectorLiteRT-20260903_093709.tflite";
|
|
2
|
+
export declare const defaultPoaDocumentDetectorLiteRTModelHash = "3IZMOUX8XXiEpfAWtZYPCvoViSJKJGVC8c3AKiputJMI2QLeWtp4icAcaXRoVX5z";
|
|
3
3
|
//# sourceMappingURL=PoaDocumentDetectorLiteRT.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoaDocumentDetectorLiteRT.d.ts","sourceRoot":"","sources":["../../../src/models/defaults/PoaDocumentDetectorLiteRT.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PoaDocumentDetectorLiteRT.d.ts","sourceRoot":"","sources":["../../../src/models/defaults/PoaDocumentDetectorLiteRT.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,yCAAyC,4HAAmG,CAAA;AAMzJ,eAAO,MAAM,yCAAyC,qEACc,CAAA"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { DEFAULT_CDN_URL } from '../../config/cdn';
|
|
2
2
|
// The POA-class document detector, loaded ALONGSIDE the shared detector rather
|
|
3
|
-
// than replacing it (#355).
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// than replacing it (#355). The two are genuinely different exports from the
|
|
4
|
+
// same delivery round and are NOT interchangeable: this one has 24 class
|
|
5
|
+
// columns (POA at index 23), the shared one has 22 (no POA, and no "Single
|
|
6
|
+
// page" either). Pointing either constant at the other's artifact silently
|
|
7
|
+
// changes what every flow on that side detects.
|
|
7
8
|
//
|
|
8
|
-
// Runtime contract, measured
|
|
9
|
-
//
|
|
10
|
-
|
|
9
|
+
// Runtime contract, measured on the 20260903 export and unchanged from the
|
|
10
|
+
// 20260820 one it replaces: uint8 [1, 300, 300, 3] input (scale 0.00784,
|
|
11
|
+
// zero_point 127), batch fixed at 1, three float32 outputs identified by shape
|
|
12
|
+
// — [1, 1917, 4] box encodings, [1, 1917, 24] class scores, [1917, 4] anchors.
|
|
13
|
+
// POA is classId 23. Same contract as its predecessor, different weights.
|
|
14
|
+
export const defaultPoaDocumentDetectorLiteRTModelPath = `${DEFAULT_CDN_URL}/models/DocumentDetectorLiteRT/DocumentDetectorLiteRT-20260903_093709.tflite`;
|
|
11
15
|
// BARE base64 SHA-384 — no `sha384-` prefix. `verifySRI` does string equality
|
|
12
16
|
// against the raw digest and strips no prefix, so a prefixed value here makes
|
|
13
17
|
// `preloadDependency` reject with `SRI mismatch` on every session and the
|
|
14
18
|
// detector never loads. The sibling constants are bare for the same reason.
|
|
15
|
-
export const defaultPoaDocumentDetectorLiteRTModelHash = '
|
|
19
|
+
export const defaultPoaDocumentDetectorLiteRTModelHash = '3IZMOUX8XXiEpfAWtZYPCvoViSJKJGVC8c3AKiputJMI2QLeWtp4icAcaXRoVX5z';
|