@idmission/websdk-core 0.1.0-rc.1
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 +66 -0
- package/dist/attestation/attestationState.d.ts +24 -0
- package/dist/attestation/attestationState.d.ts.map +1 -0
- package/dist/attestation/attestationState.js +57 -0
- package/dist/attestation/clientAttestation.d.ts +40 -0
- package/dist/attestation/clientAttestation.d.ts.map +1 -0
- package/dist/attestation/clientAttestation.js +19 -0
- package/dist/attestation/collectClientAttestation.d.ts +10 -0
- package/dist/attestation/collectClientAttestation.d.ts.map +1 -0
- package/dist/attestation/collectClientAttestation.js +18 -0
- package/dist/attestation/index.d.ts +5 -0
- package/dist/attestation/index.d.ts.map +1 -0
- package/dist/attestation/index.js +4 -0
- package/dist/attestation/nativeAttestationBridge.d.ts +3 -0
- package/dist/attestation/nativeAttestationBridge.d.ts.map +1 -0
- package/dist/attestation/nativeAttestationBridge.js +38 -0
- package/dist/barcode/AAMVAParser.d.ts +77 -0
- package/dist/barcode/AAMVAParser.d.ts.map +1 -0
- package/dist/barcode/AAMVAParser.js +422 -0
- package/dist/barcode/NativeBarcodeDecoder.d.ts +157 -0
- package/dist/barcode/NativeBarcodeDecoder.d.ts.map +1 -0
- package/dist/barcode/NativeBarcodeDecoder.js +832 -0
- package/dist/barcode/Parse.d.ts +6 -0
- package/dist/barcode/Parse.d.ts.map +1 -0
- package/dist/barcode/Parse.js +148 -0
- package/dist/barcode/decodeSummary.d.ts +45 -0
- package/dist/barcode/decodeSummary.d.ts.map +1 -0
- package/dist/barcode/decodeSummary.js +23 -0
- package/dist/barcode/index.d.ts +5 -0
- package/dist/barcode/index.d.ts.map +1 -0
- package/dist/barcode/index.js +4 -0
- package/dist/camera/Camera.d.ts +37 -0
- package/dist/camera/Camera.d.ts.map +1 -0
- package/dist/camera/Camera.js +453 -0
- package/dist/camera/acquireCamera.d.ts +29 -0
- package/dist/camera/acquireCamera.d.ts.map +1 -0
- package/dist/camera/acquireCamera.js +224 -0
- package/dist/camera/cameraSignals.d.ts +23 -0
- package/dist/camera/cameraSignals.d.ts.map +1 -0
- package/dist/camera/cameraSignals.js +32 -0
- package/dist/camera/getUserMediaIntegrity.d.ts +72 -0
- package/dist/camera/getUserMediaIntegrity.d.ts.map +1 -0
- package/dist/camera/getUserMediaIntegrity.js +256 -0
- package/dist/camera/index.d.ts +6 -0
- package/dist/camera/index.d.ts.map +1 -0
- package/dist/camera/index.js +5 -0
- package/dist/camera/isVirtualCamera.d.ts +10 -0
- package/dist/camera/isVirtualCamera.d.ts.map +1 -0
- package/dist/camera/isVirtualCamera.js +11 -0
- package/dist/client/IdmissionClient.d.ts +151 -0
- package/dist/client/IdmissionClient.d.ts.map +1 -0
- package/dist/client/IdmissionClient.js +638 -0
- package/dist/client/additionalDocument.d.ts +14 -0
- package/dist/client/additionalDocument.d.ts.map +1 -0
- package/dist/client/additionalDocument.js +24 -0
- package/dist/client/artifacts.d.ts +146 -0
- package/dist/client/artifacts.d.ts.map +1 -0
- package/dist/client/artifacts.js +1 -0
- package/dist/client/blobToB64.d.ts +2 -0
- package/dist/client/blobToB64.d.ts.map +1 -0
- package/dist/client/blobToB64.js +17 -0
- package/dist/client/endpoints.d.ts +7 -0
- package/dist/client/endpoints.d.ts.map +1 -0
- package/dist/client/endpoints.js +59 -0
- package/dist/client/errors.d.ts +20 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +45 -0
- package/dist/client/index.d.ts +23 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +38 -0
- package/dist/client/payload.d.ts +36 -0
- package/dist/client/payload.d.ts.map +1 -0
- package/dist/client/payload.js +397 -0
- package/dist/client/sessionMachine.d.ts +26 -0
- package/dist/client/sessionMachine.d.ts.map +1 -0
- package/dist/client/sessionMachine.js +23 -0
- package/dist/client/submissionMetadata.d.ts +31 -0
- package/dist/client/submissionMetadata.d.ts.map +1 -0
- package/dist/client/submissionMetadata.js +90 -0
- package/dist/client/timings.d.ts +49 -0
- package/dist/client/timings.d.ts.map +1 -0
- package/dist/client/timings.js +32 -0
- package/dist/client/types.d.ts +305 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +18 -0
- package/dist/client/upload.d.ts +60 -0
- package/dist/client/upload.d.ts.map +1 -0
- package/dist/client/upload.js +313 -0
- package/dist/client/uploadedDocument.d.ts +7 -0
- package/dist/client/uploadedDocument.d.ts.map +1 -0
- package/dist/client/uploadedDocument.js +4 -0
- package/dist/client/urls.d.ts +30 -0
- package/dist/client/urls.d.ts.map +1 -0
- package/dist/client/urls.js +73 -0
- package/dist/client/validateSession.d.ts +7 -0
- package/dist/client/validateSession.d.ts.map +1 -0
- package/dist/client/validateSession.js +63 -0
- package/dist/config/cdn.d.ts +2 -0
- package/dist/config/cdn.d.ts.map +1 -0
- package/dist/config/cdn.js +1 -0
- package/dist/diagnostics/buffer.d.ts +8 -0
- package/dist/diagnostics/buffer.d.ts.map +1 -0
- package/dist/diagnostics/buffer.js +25 -0
- package/dist/diagnostics/envCapability.d.ts +3 -0
- package/dist/diagnostics/envCapability.d.ts.map +1 -0
- package/dist/diagnostics/envCapability.js +40 -0
- package/dist/diagnostics/floodControl.d.ts +6 -0
- package/dist/diagnostics/floodControl.d.ts.map +1 -0
- package/dist/diagnostics/floodControl.js +29 -0
- package/dist/diagnostics/index.d.ts +8 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +17 -0
- package/dist/diagnostics/install.d.ts +20 -0
- package/dist/diagnostics/install.d.ts.map +1 -0
- package/dist/diagnostics/install.js +159 -0
- package/dist/diagnostics/redaction.d.ts +7 -0
- package/dist/diagnostics/redaction.d.ts.map +1 -0
- package/dist/diagnostics/redaction.js +73 -0
- package/dist/diagnostics/transport.d.ts +15 -0
- package/dist/diagnostics/transport.d.ts.map +1 -0
- package/dist/diagnostics/transport.js +35 -0
- package/dist/diagnostics/types.d.ts +59 -0
- package/dist/diagnostics/types.d.ts.map +1 -0
- package/dist/diagnostics/types.js +1 -0
- package/dist/documentCapture/controller.d.ts +35 -0
- package/dist/documentCapture/controller.d.ts.map +1 -0
- package/dist/documentCapture/controller.js +254 -0
- package/dist/documentCapture/index.d.ts +4 -0
- package/dist/documentCapture/index.d.ts.map +1 -0
- package/dist/documentCapture/index.js +8 -0
- package/dist/documentCapture/reducer.d.ts +31 -0
- package/dist/documentCapture/reducer.d.ts.map +1 -0
- package/dist/documentCapture/reducer.js +87 -0
- package/dist/documentCapture/state.d.ts +49 -0
- package/dist/documentCapture/state.d.ts.map +1 -0
- package/dist/documentCapture/state.js +36 -0
- package/dist/idCapture/controller.d.ts +228 -0
- package/dist/idCapture/controller.d.ts.map +1 -0
- package/dist/idCapture/controller.js +1453 -0
- package/dist/idCapture/errors.d.ts +36 -0
- package/dist/idCapture/errors.d.ts.map +1 -0
- package/dist/idCapture/errors.js +18 -0
- package/dist/idCapture/guidance.d.ts +80 -0
- package/dist/idCapture/guidance.d.ts.map +1 -0
- package/dist/idCapture/guidance.js +143 -0
- package/dist/idCapture/index.d.ts +22 -0
- package/dist/idCapture/index.d.ts.map +1 -0
- package/dist/idCapture/index.js +46 -0
- package/dist/idCapture/phase.d.ts +10 -0
- package/dist/idCapture/phase.d.ts.map +1 -0
- package/dist/idCapture/phase.js +28 -0
- package/dist/idCapture/pipeline.d.ts +176 -0
- package/dist/idCapture/pipeline.d.ts.map +1 -0
- package/dist/idCapture/pipeline.js +1028 -0
- package/dist/idCapture/reducer.d.ts +3 -0
- package/dist/idCapture/reducer.d.ts.map +1 -0
- package/dist/idCapture/reducer.js +661 -0
- package/dist/idCapture/requirements.d.ts +10 -0
- package/dist/idCapture/requirements.d.ts.map +1 -0
- package/dist/idCapture/requirements.js +43 -0
- package/dist/idCapture/stabilizer.d.ts +2 -0
- package/dist/idCapture/stabilizer.d.ts.map +1 -0
- package/dist/idCapture/stabilizer.js +4 -0
- package/dist/idCapture/state.d.ts +426 -0
- package/dist/idCapture/state.d.ts.map +1 -0
- package/dist/idCapture/state.js +91 -0
- package/dist/idCapture/submit.d.ts +33 -0
- package/dist/idCapture/submit.d.ts.map +1 -0
- package/dist/idCapture/submit.js +105 -0
- package/dist/idCapture/types.d.ts +20 -0
- package/dist/idCapture/types.d.ts.map +1 -0
- package/dist/idCapture/types.js +12 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/liveness/challengeGeometry.d.ts +66 -0
- package/dist/liveness/challengeGeometry.d.ts.map +1 -0
- package/dist/liveness/challengeGeometry.js +226 -0
- package/dist/liveness/challengeSequence.d.ts +49 -0
- package/dist/liveness/challengeSequence.d.ts.map +1 -0
- package/dist/liveness/challengeSequence.js +71 -0
- package/dist/liveness/index.d.ts +4 -0
- package/dist/liveness/index.d.ts.map +1 -0
- package/dist/liveness/index.js +3 -0
- package/dist/liveness/livenessResult.d.ts +11 -0
- package/dist/liveness/livenessResult.d.ts.map +1 -0
- package/dist/liveness/livenessResult.js +16 -0
- package/dist/models/BarcodeReadability.d.ts +36 -0
- package/dist/models/BarcodeReadability.d.ts.map +1 -0
- package/dist/models/BarcodeReadability.js +71 -0
- package/dist/models/CapabilityProbing.d.ts +25 -0
- package/dist/models/CapabilityProbing.d.ts.map +1 -0
- package/dist/models/CapabilityProbing.js +172 -0
- package/dist/models/DocumentDetection.d.ts +96 -0
- package/dist/models/DocumentDetection.d.ts.map +1 -0
- package/dist/models/DocumentDetection.js +257 -0
- package/dist/models/FaceDetection.d.ts +21 -0
- package/dist/models/FaceDetection.d.ts.map +1 -0
- package/dist/models/FaceDetection.js +4 -0
- package/dist/models/Focus.d.ts +36 -0
- package/dist/models/Focus.d.ts.map +1 -0
- package/dist/models/Focus.js +69 -0
- package/dist/models/FrameLoop.d.ts +13 -0
- package/dist/models/FrameLoop.d.ts.map +1 -0
- package/dist/models/FrameLoop.js +56 -0
- package/dist/models/VisionRuntime.d.ts +18 -0
- package/dist/models/VisionRuntime.d.ts.map +1 -0
- package/dist/models/VisionRuntime.js +158 -0
- package/dist/models/defaults/BarcodeReadability.d.ts +3 -0
- package/dist/models/defaults/BarcodeReadability.d.ts.map +1 -0
- package/dist/models/defaults/BarcodeReadability.js +3 -0
- package/dist/models/defaults/BarcodeReadabilityLiteRT.d.ts +3 -0
- package/dist/models/defaults/BarcodeReadabilityLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/BarcodeReadabilityLiteRT.js +3 -0
- package/dist/models/defaults/DocumentDetector.d.ts +3 -0
- package/dist/models/defaults/DocumentDetector.d.ts.map +1 -0
- package/dist/models/defaults/DocumentDetector.js +3 -0
- package/dist/models/defaults/DocumentDetectorLiteRT.d.ts +3 -0
- package/dist/models/defaults/DocumentDetectorLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/DocumentDetectorLiteRT.js +3 -0
- package/dist/models/defaults/FaceDetector.d.ts +3 -0
- package/dist/models/defaults/FaceDetector.d.ts.map +1 -0
- package/dist/models/defaults/FaceDetector.js +3 -0
- package/dist/models/defaults/FaceLandmarker.d.ts +3 -0
- package/dist/models/defaults/FaceLandmarker.d.ts.map +1 -0
- package/dist/models/defaults/FaceLandmarker.js +8 -0
- package/dist/models/defaults/FaceLandmarkerLiteRT.d.ts +3 -0
- package/dist/models/defaults/FaceLandmarkerLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/FaceLandmarkerLiteRT.js +3 -0
- package/dist/models/defaults/Focus.d.ts +3 -0
- package/dist/models/defaults/Focus.d.ts.map +1 -0
- package/dist/models/defaults/Focus.js +3 -0
- package/dist/models/defaults/FocusLiteRT.d.ts +3 -0
- package/dist/models/defaults/FocusLiteRT.d.ts.map +1 -0
- package/dist/models/defaults/FocusLiteRT.js +3 -0
- package/dist/models/defaults/index.d.ts +31 -0
- package/dist/models/defaults/index.d.ts.map +1 -0
- package/dist/models/defaults/index.js +38 -0
- package/dist/models/helpers.d.ts +25 -0
- package/dist/models/helpers.d.ts.map +1 -0
- package/dist/models/helpers.js +98 -0
- package/dist/models/index.d.ts +15 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +14 -0
- package/dist/models/modelLifecycle.d.ts +26 -0
- package/dist/models/modelLifecycle.d.ts.map +1 -0
- package/dist/models/modelLifecycle.js +137 -0
- package/dist/models/occlusion.d.ts +20 -0
- package/dist/models/occlusion.d.ts.map +1 -0
- package/dist/models/occlusion.js +109 -0
- package/dist/models/passportBooklet.d.ts +34 -0
- package/dist/models/passportBooklet.d.ts.map +1 -0
- package/dist/models/passportBooklet.js +152 -0
- package/dist/models/preloadModels.d.ts +42 -0
- package/dist/models/preloadModels.d.ts.map +1 -0
- package/dist/models/preloadModels.js +204 -0
- package/dist/models/providers/litert/BarcodeReadability.d.ts +11 -0
- package/dist/models/providers/litert/BarcodeReadability.d.ts.map +1 -0
- package/dist/models/providers/litert/BarcodeReadability.js +135 -0
- package/dist/models/providers/litert/CapabilityProbe.d.ts +3 -0
- package/dist/models/providers/litert/CapabilityProbe.d.ts.map +1 -0
- package/dist/models/providers/litert/CapabilityProbe.js +44 -0
- package/dist/models/providers/litert/DocumentDetection.d.ts +18 -0
- package/dist/models/providers/litert/DocumentDetection.d.ts.map +1 -0
- package/dist/models/providers/litert/DocumentDetection.js +194 -0
- package/dist/models/providers/litert/FaceDetection.d.ts +11 -0
- package/dist/models/providers/litert/FaceDetection.d.ts.map +1 -0
- package/dist/models/providers/litert/FaceDetection.js +204 -0
- package/dist/models/providers/litert/FaceLandmarker.d.ts +11 -0
- package/dist/models/providers/litert/FaceLandmarker.d.ts.map +1 -0
- package/dist/models/providers/litert/FaceLandmarker.js +199 -0
- package/dist/models/providers/litert/Focus.d.ts +11 -0
- package/dist/models/providers/litert/Focus.d.ts.map +1 -0
- package/dist/models/providers/litert/Focus.js +141 -0
- package/dist/models/providers/litert/barcodeReadabilityPrePost.d.ts +6 -0
- package/dist/models/providers/litert/barcodeReadabilityPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/barcodeReadabilityPrePost.js +68 -0
- package/dist/models/providers/litert/blazeFacePrePost.d.ts +30 -0
- package/dist/models/providers/litert/blazeFacePrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/blazeFacePrePost.js +206 -0
- package/dist/models/providers/litert/docDetectPrePost.d.ts +25 -0
- package/dist/models/providers/litert/docDetectPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/docDetectPrePost.js +197 -0
- package/dist/models/providers/litert/faceMeshPrePost.d.ts +23 -0
- package/dist/models/providers/litert/faceMeshPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/faceMeshPrePost.js +86 -0
- package/dist/models/providers/litert/focusPrePost.d.ts +6 -0
- package/dist/models/providers/litert/focusPrePost.d.ts.map +1 -0
- package/dist/models/providers/litert/focusPrePost.js +67 -0
- package/dist/models/providers/litert/runtime.d.ts +14 -0
- package/dist/models/providers/litert/runtime.d.ts.map +1 -0
- package/dist/models/providers/litert/runtime.js +83 -0
- package/dist/models/providers/mediapipe/BarcodeReadability.d.ts +11 -0
- package/dist/models/providers/mediapipe/BarcodeReadability.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/BarcodeReadability.js +68 -0
- package/dist/models/providers/mediapipe/CapabilityProbe.d.ts +2 -0
- package/dist/models/providers/mediapipe/CapabilityProbe.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/CapabilityProbe.js +14 -0
- package/dist/models/providers/mediapipe/DocumentDetection.d.ts +12 -0
- package/dist/models/providers/mediapipe/DocumentDetection.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/DocumentDetection.js +90 -0
- package/dist/models/providers/mediapipe/FaceDetection.d.ts +11 -0
- package/dist/models/providers/mediapipe/FaceDetection.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/FaceDetection.js +93 -0
- package/dist/models/providers/mediapipe/FaceLandmarker.d.ts +46 -0
- package/dist/models/providers/mediapipe/FaceLandmarker.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/FaceLandmarker.js +166 -0
- package/dist/models/providers/mediapipe/Focus.d.ts +11 -0
- package/dist/models/providers/mediapipe/Focus.d.ts.map +1 -0
- package/dist/models/providers/mediapipe/Focus.js +51 -0
- package/dist/models/runtimeSelection.d.ts +5 -0
- package/dist/models/runtimeSelection.d.ts.map +1 -0
- package/dist/models/runtimeSelection.js +21 -0
- package/dist/selfieCapture/challengeRunner.d.ts +38 -0
- package/dist/selfieCapture/challengeRunner.d.ts.map +1 -0
- package/dist/selfieCapture/challengeRunner.js +181 -0
- package/dist/selfieCapture/controller.d.ts +166 -0
- package/dist/selfieCapture/controller.d.ts.map +1 -0
- package/dist/selfieCapture/controller.js +1253 -0
- package/dist/selfieCapture/faceTracking.d.ts +67 -0
- package/dist/selfieCapture/faceTracking.d.ts.map +1 -0
- package/dist/selfieCapture/faceTracking.js +158 -0
- package/dist/selfieCapture/guidance.d.ts +24 -0
- package/dist/selfieCapture/guidance.d.ts.map +1 -0
- package/dist/selfieCapture/guidance.js +41 -0
- package/dist/selfieCapture/index.d.ts +18 -0
- package/dist/selfieCapture/index.d.ts.map +1 -0
- package/dist/selfieCapture/index.js +11 -0
- package/dist/selfieCapture/lighting.d.ts +36 -0
- package/dist/selfieCapture/lighting.d.ts.map +1 -0
- package/dist/selfieCapture/lighting.js +95 -0
- package/dist/selfieCapture/livenessMachine.d.ts +66 -0
- package/dist/selfieCapture/livenessMachine.d.ts.map +1 -0
- package/dist/selfieCapture/livenessMachine.js +137 -0
- package/dist/selfieCapture/pipeline.d.ts +42 -0
- package/dist/selfieCapture/pipeline.d.ts.map +1 -0
- package/dist/selfieCapture/pipeline.js +282 -0
- package/dist/selfieCapture/reducer.d.ts +35 -0
- package/dist/selfieCapture/reducer.d.ts.map +1 -0
- package/dist/selfieCapture/reducer.js +143 -0
- package/dist/selfieCapture/state.d.ts +40 -0
- package/dist/selfieCapture/state.d.ts.map +1 -0
- package/dist/selfieCapture/state.js +36 -0
- package/dist/selfieCapture/testing/challengeFixtures.d.ts +43 -0
- package/dist/selfieCapture/testing/challengeFixtures.d.ts.map +1 -0
- package/dist/selfieCapture/testing/challengeFixtures.js +43 -0
- package/dist/signature/frameDecode.d.ts +48 -0
- package/dist/signature/frameDecode.d.ts.map +1 -0
- package/dist/signature/frameDecode.js +491 -0
- package/dist/signature/index.d.ts +5 -0
- package/dist/signature/index.d.ts.map +1 -0
- package/dist/signature/index.js +4 -0
- package/dist/signature/metadata.d.ts +63 -0
- package/dist/signature/metadata.d.ts.map +1 -0
- package/dist/signature/metadata.js +1 -0
- package/dist/signature/quality.d.ts +169 -0
- package/dist/signature/quality.d.ts.map +1 -0
- package/dist/signature/quality.js +186 -0
- package/dist/signature/signatureValidity.d.ts +149 -0
- package/dist/signature/signatureValidity.d.ts.map +1 -0
- package/dist/signature/signatureValidity.js +305 -0
- package/dist/signatureCapture/controller.d.ts +67 -0
- package/dist/signatureCapture/controller.d.ts.map +1 -0
- package/dist/signatureCapture/controller.js +534 -0
- package/dist/signatureCapture/guidance.d.ts +9 -0
- package/dist/signatureCapture/guidance.d.ts.map +1 -0
- package/dist/signatureCapture/guidance.js +7 -0
- package/dist/signatureCapture/index.d.ts +6 -0
- package/dist/signatureCapture/index.d.ts.map +1 -0
- package/dist/signatureCapture/index.js +5 -0
- package/dist/signatureCapture/pipeline.d.ts +111 -0
- package/dist/signatureCapture/pipeline.d.ts.map +1 -0
- package/dist/signatureCapture/pipeline.js +680 -0
- package/dist/signatureCapture/reducer.d.ts +42 -0
- package/dist/signatureCapture/reducer.d.ts.map +1 -0
- package/dist/signatureCapture/reducer.js +159 -0
- package/dist/signatureCapture/state.d.ts +92 -0
- package/dist/signatureCapture/state.d.ts.map +1 -0
- package/dist/signatureCapture/state.js +24 -0
- package/dist/utils/canvas.d.ts +4 -0
- package/dist/utils/canvas.d.ts.map +1 -0
- package/dist/utils/canvas.js +21 -0
- package/dist/utils/cropping.d.ts +8 -0
- package/dist/utils/cropping.d.ts.map +1 -0
- package/dist/utils/cropping.js +85 -0
- package/dist/utils/dataUrlToBase64.d.ts +7 -0
- package/dist/utils/dataUrlToBase64.d.ts.map +1 -0
- package/dist/utils/dataUrlToBase64.js +67 -0
- package/dist/utils/getFrameDimensions.d.ts +3 -0
- package/dist/utils/getFrameDimensions.d.ts.map +1 -0
- package/dist/utils/getFrameDimensions.js +12 -0
- package/dist/utils/isMobile.d.ts +3 -0
- package/dist/utils/isMobile.d.ts.map +1 -0
- package/dist/utils/isMobile.js +36 -0
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +25 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +11 -0
- package/dist/utils/stabilizer.d.ts +26 -0
- package/dist/utils/stabilizer.d.ts.map +1 -0
- package/dist/utils/stabilizer.js +65 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1 -0
- package/dist/videoIdCapture/controller.d.ts +108 -0
- package/dist/videoIdCapture/controller.d.ts.map +1 -0
- package/dist/videoIdCapture/controller.js +833 -0
- package/dist/videoIdCapture/index.d.ts +5 -0
- package/dist/videoIdCapture/index.d.ts.map +1 -0
- package/dist/videoIdCapture/index.js +2 -0
- package/dist/videoIdCapture/state.d.ts +88 -0
- package/dist/videoIdCapture/state.d.ts.map +1 -0
- package/dist/videoIdCapture/state.js +67 -0
- package/package.json +111 -0
|
@@ -0,0 +1,1028 @@
|
|
|
1
|
+
// Framework-free port of sdk2's ID-capture model provider stack:
|
|
2
|
+
// - sdk2/src/components/id_capture/IdCaptureModelsProvider.tsx — the
|
|
3
|
+
// module-level helpers (analyzeBarcodeReadability :83-199,
|
|
4
|
+
// calculateBarcodeReadabilityThreshold :207-225), the shared types
|
|
5
|
+
// (:285-330), the giant detection handler (:578-1032), best-frame /
|
|
6
|
+
// best-barcode tracking, recapture phases, aggressive decode, the reset
|
|
7
|
+
// functions (:1150-1177) and the load + readiness aggregation
|
|
8
|
+
// (:1183-1244).
|
|
9
|
+
// - sdk2/src/components/id_capture/DocumentDetectionModelProvider.tsx — the
|
|
10
|
+
// frame-loop body (:154-216) and the all-zero self-heal (:209-216).
|
|
11
|
+
// - sdk2/src/components/id_capture/FocusModelProvider.tsx /
|
|
12
|
+
// BarcodeReadabilityModelProvider.tsx — the makeXPrediction wrappers
|
|
13
|
+
// (readiness gate + scratch canvases).
|
|
14
|
+
//
|
|
15
|
+
// React mechanics translate as: refs -> instance fields (closure variables),
|
|
16
|
+
// useState + context -> fields + accessor methods, <InvisibleCanvas> mounts ->
|
|
17
|
+
// deps.createCanvas() (a canvas-key remount becomes a fresh createCanvas()
|
|
18
|
+
// call), useEffect wiring -> direct calls. All I/O-adjacent collaborators are
|
|
19
|
+
// injectable through `deps` so the whole pipeline runs in plain Node tests.
|
|
20
|
+
import { closeDocumentDetector, defaultDocumentDetectionBoundaries, defaultDocumentDetectionModelLoadTimeoutMs, defaultDocumentDetectionScoreThreshold, defaultDocumentDetectionThresholds, lastDetectionTime, loadDocumentDetector, makeDocumentDetectorPrediction, processDocumentDetectorPrediction, setLastDetectionAt, testDocumentDetectorAgainstKnownImage, } from '../models/DocumentDetection';
|
|
21
|
+
import { classifyFocusModelForVideo, closeFocusModel, defaultFocusThresholds, lastFocusPredictionTime, loadFocusModel, makeFocusModelPrediction, setLastFocusPredictionAt, } from '../models/Focus';
|
|
22
|
+
import { classifyBarcodeReadabilityModelForVideo, closeBarcodeReadabilityModel, lastBarcodeReadabilityPredictionTime, loadBarcodeReadabilityModel, makeBarcodeReadabilityModelPrediction, setLastBarcodeReadabilityPredictionAt, } from '../models/BarcodeReadability';
|
|
23
|
+
import { waitForVideoReady } from '../models/helpers';
|
|
24
|
+
import { runModelLoadLifecycle, } from '../models/modelLifecycle';
|
|
25
|
+
import { createFrameLoop } from '../models/FrameLoop';
|
|
26
|
+
import { resolveRuntime } from '../models/runtimeSelection';
|
|
27
|
+
import { computeFingerOcclusion, computeGlareOcclusion, computeHologramOcclusion, resolveFingerOcclusionThresholds, } from '../models/occlusion';
|
|
28
|
+
import { cropToDetectedObjectBox } from '../utils/cropping';
|
|
29
|
+
import { clearCanvas, drawToCanvas } from '../utils/canvas';
|
|
30
|
+
import { debug, error, log } from '../utils/logger';
|
|
31
|
+
import { isMobile } from '../utils/isMobile';
|
|
32
|
+
import { decodePDF417, } from '../barcode/NativeBarcodeDecoder';
|
|
33
|
+
import { CaptureAttachError } from './errors';
|
|
34
|
+
/**
|
|
35
|
+
* Analyzes barcode readability for a detected document
|
|
36
|
+
* (IdCaptureModelsProvider.tsx:83-199, ported verbatim; the last two
|
|
37
|
+
* parameters are a headless-port addition — sdk2 called the module-level
|
|
38
|
+
* detector functions directly, while the pipeline injects its `deps` so
|
|
39
|
+
* tests can fake the crop re-detection).
|
|
40
|
+
* @param prediction The document detection prediction
|
|
41
|
+
* @param lastPredictionCanvas The canvas containing the original frame
|
|
42
|
+
* @param croppedDocumentCanvas Canvas for storing cropped document
|
|
43
|
+
* @param bestBarcodeCanvas Canvas for storing best barcode crop
|
|
44
|
+
* @param currentBestBarcodeScore Current best barcode score
|
|
45
|
+
* @param documentDetectionThresholds Thresholds for document detection
|
|
46
|
+
* @param makeBarcodeReadabilityPrediction Function to make barcode readability predictions
|
|
47
|
+
* @param barcodeReadabilityThreshold Threshold for barcode readability
|
|
48
|
+
* @returns Object containing barcode analysis results
|
|
49
|
+
*/
|
|
50
|
+
export async function analyzeBarcodeReadability(prediction, lastPredictionCanvas, croppedDocumentCanvas, bestBarcodeCanvas, currentBestBarcodeScore, documentDetectionThresholds, makeBarcodeReadabilityPrediction, barcodeReadabilityThreshold, makeDocumentDetectorPredictionFn = makeDocumentDetectorPrediction, processDocumentDetectorPredictionFn = processDocumentDetectorPrediction) {
|
|
51
|
+
let pdf417PredictionTime = 0;
|
|
52
|
+
let pdf417PredictionScore = 0;
|
|
53
|
+
let pdf417PredictionThresholdMet = false;
|
|
54
|
+
let newBestBarcodeScore;
|
|
55
|
+
let newBestBarcodeDetails;
|
|
56
|
+
if (!prediction.bestDocument ||
|
|
57
|
+
!prediction.bestPDF417?.box ||
|
|
58
|
+
!bestBarcodeCanvas) {
|
|
59
|
+
return {
|
|
60
|
+
pdf417PredictionTime,
|
|
61
|
+
pdf417PredictionScore,
|
|
62
|
+
pdf417PredictionThresholdMet,
|
|
63
|
+
newBestBarcodeScore,
|
|
64
|
+
newBestBarcodeDetails,
|
|
65
|
+
processedBarcodeBoundingBox: undefined,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Step 1: Crop the full frame to just the document area
|
|
70
|
+
* This removes background noise and focuses analysis on the document
|
|
71
|
+
*/
|
|
72
|
+
cropToDetectedObjectBox(lastPredictionCanvas, prediction.bestDocument.box, croppedDocumentCanvas);
|
|
73
|
+
/**
|
|
74
|
+
* Step 2: Re-run document detection on the cropped document
|
|
75
|
+
*/
|
|
76
|
+
const documentCroppedPrediction = await makeDocumentDetectorPredictionFn(croppedDocumentCanvas);
|
|
77
|
+
if (!documentCroppedPrediction) {
|
|
78
|
+
// error occurred during prediction (error logged by callee)
|
|
79
|
+
// (IdCaptureModelsProvider.tsx:132-142)
|
|
80
|
+
return {
|
|
81
|
+
pdf417PredictionTime,
|
|
82
|
+
pdf417PredictionScore,
|
|
83
|
+
pdf417PredictionThresholdMet,
|
|
84
|
+
newBestBarcodeScore,
|
|
85
|
+
newBestBarcodeDetails,
|
|
86
|
+
processedBarcodeBoundingBox: undefined,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Step 3: Process the cropped prediction to extract barcode
|
|
91
|
+
*/
|
|
92
|
+
const processedCroppedPrediction = processDocumentDetectorPredictionFn(documentCroppedPrediction, documentDetectionThresholds);
|
|
93
|
+
if (processedCroppedPrediction.bestPDF417) {
|
|
94
|
+
/**
|
|
95
|
+
* Step 4: Run barcode readability analysis on the re-detected barcode area
|
|
96
|
+
*/
|
|
97
|
+
const pdf417Prediction = await makeBarcodeReadabilityPrediction(croppedDocumentCanvas, processedCroppedPrediction.bestPDF417.box);
|
|
98
|
+
if (pdf417Prediction) {
|
|
99
|
+
pdf417PredictionTime = pdf417Prediction.predictionTime;
|
|
100
|
+
pdf417PredictionScore = pdf417Prediction.score;
|
|
101
|
+
if (pdf417Prediction.score > currentBestBarcodeScore) {
|
|
102
|
+
/**
|
|
103
|
+
* Step 5: Update best barcode
|
|
104
|
+
*/
|
|
105
|
+
newBestBarcodeScore = pdf417Prediction.score;
|
|
106
|
+
newBestBarcodeDetails = {
|
|
107
|
+
boundingBox: prediction.bestPDF417.box,
|
|
108
|
+
score: pdf417Prediction.score,
|
|
109
|
+
};
|
|
110
|
+
if (pdf417PredictionScore >= barcodeReadabilityThreshold) {
|
|
111
|
+
pdf417PredictionThresholdMet = true;
|
|
112
|
+
}
|
|
113
|
+
cropToDetectedObjectBox(croppedDocumentCanvas, processedCroppedPrediction.bestPDF417.box, bestBarcodeCanvas, 16);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
pdf417PredictionTime,
|
|
119
|
+
pdf417PredictionScore,
|
|
120
|
+
pdf417PredictionThresholdMet,
|
|
121
|
+
newBestBarcodeScore,
|
|
122
|
+
newBestBarcodeDetails,
|
|
123
|
+
// Return processed barcode bounding box for recapture tracking (valid even when not a new best)
|
|
124
|
+
processedBarcodeBoundingBox: processedCroppedPrediction?.bestPDF417?.box,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Calculates the barcode readability threshold for a given document type
|
|
129
|
+
* (IdCaptureModelsProvider.tsx:207-225 — `onMobile` was captured at module
|
|
130
|
+
* load there; here it is an explicit parameter so the pipeline can inject
|
|
131
|
+
* `deps.isMobile()`).
|
|
132
|
+
* @param detectedDocumentType The type of document detected
|
|
133
|
+
* @param barcodeReadabilityThresholds The threshold configuration object
|
|
134
|
+
* @param onMobile Whether the current platform is mobile
|
|
135
|
+
* @returns The appropriate threshold value for the current platform (mobile/desktop)
|
|
136
|
+
*/
|
|
137
|
+
export function calculateBarcodeReadabilityThreshold(detectedDocumentType, barcodeReadabilityThresholds, onMobile) {
|
|
138
|
+
const barcodeReadabilityThresholdSet = detectedDocumentType in barcodeReadabilityThresholds
|
|
139
|
+
? barcodeReadabilityThresholds[detectedDocumentType]
|
|
140
|
+
: undefined;
|
|
141
|
+
if (barcodeReadabilityThresholdSet) {
|
|
142
|
+
return onMobile
|
|
143
|
+
? barcodeReadabilityThresholdSet.mobile || 0
|
|
144
|
+
: barcodeReadabilityThresholdSet.desktop || 0;
|
|
145
|
+
}
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
// IdCaptureModelsProvider.tsx:301-304
|
|
149
|
+
export const defaultIdCaptureThresholds = {
|
|
150
|
+
detection: defaultDocumentDetectionThresholds,
|
|
151
|
+
focus: defaultFocusThresholds,
|
|
152
|
+
};
|
|
153
|
+
const initialSnapshot = () => ({
|
|
154
|
+
// Matches the hooks' initial useState('not-started')
|
|
155
|
+
// (e.g. sdk2/src/lib/models/DocumentDetection.ts:214-215).
|
|
156
|
+
state: 'not-started',
|
|
157
|
+
downloadProgress: 0,
|
|
158
|
+
warmingStartedAt: null,
|
|
159
|
+
error: null,
|
|
160
|
+
});
|
|
161
|
+
export function createDetectionPipeline(opts) {
|
|
162
|
+
// Prop defaults: IdCaptureModelsProvider.tsx:453-467 +
|
|
163
|
+
// DocumentDetectionModelProvider.tsx:102-117.
|
|
164
|
+
const { video, allowSinglePageIdCapture = false, enableFingerOcclusionGuidance = false, fingerOcclusionThresholds, enableGlareOcclusionGuidance = false, enableHologramOcclusionGuidance = false, requireFullPassportBooklet = false, enableBarcodeReadabilityModel = true, aggressiveModeEnabled = false, aggressiveModeDecodeThreshold = 0.3, aggressiveModeDecodeIntervalMs = 500, onAggressiveDecodeSuccess, onIdCaptureAction, throttleMs = 16, delayAfterStartMs = 0, modelAssetPaths, scoreThreshold = defaultDocumentDetectionScoreThreshold, modelLoadTimeoutMs = defaultDocumentDetectionModelLoadTimeoutMs, onModelStateChange, } = opts;
|
|
165
|
+
// Per-model runtime resolution (IdCaptureModelsProvider.tsx:1335-1343).
|
|
166
|
+
// NOTE: no default on the specific operand — `perModel ?? runtime ?? DEFAULT`
|
|
167
|
+
// must cascade (see resolveRuntime).
|
|
168
|
+
const documentDetectorRuntime = resolveRuntime(opts.documentDetectorRuntime, opts.runtime);
|
|
169
|
+
const focusRuntime = resolveRuntime(opts.focusRuntime, opts.runtime);
|
|
170
|
+
const barcodeReadabilityRuntime = resolveRuntime(opts.barcodeReadabilityRuntime, opts.runtime);
|
|
171
|
+
// Resolve the per-doc-type thresholds once. Used to gate best-frame
|
|
172
|
+
// updates so a finger-occluded frame can't be saved as the captured
|
|
173
|
+
// image just because its focus peaked at that moment. (:473-476)
|
|
174
|
+
const resolvedFingerOcclusionThresholds = resolveFingerOcclusionThresholds(fingerOcclusionThresholds);
|
|
175
|
+
// Per-model load lifecycle snapshots. Each replaces one useLoadX hook's
|
|
176
|
+
// state cluster (modelLoadState/downloadProgress/warmingStartedAt/error).
|
|
177
|
+
const records = {
|
|
178
|
+
documentDetector: initialSnapshot(),
|
|
179
|
+
focus: initialSnapshot(),
|
|
180
|
+
barcodeReadability: initialSnapshot(),
|
|
181
|
+
};
|
|
182
|
+
// The all-zero self-heal error is stored separately from the lifecycle
|
|
183
|
+
// snapshot, mirroring how sdk2's setModelError overwrote the doc-detector
|
|
184
|
+
// hook's error state without touching its load state
|
|
185
|
+
// (DocumentDetectionModelProvider.tsx:209-216).
|
|
186
|
+
let documentDetectorAllZeroError = null;
|
|
187
|
+
const createCanvas = opts.deps?.createCanvas ?? (() => document.createElement('canvas'));
|
|
188
|
+
// ---------------------------------------------------------------------
|
|
189
|
+
// Canvases. sdk2 mounts these as <InvisibleCanvas> elements:
|
|
190
|
+
// - lastPredictionCanvas: DocumentDetectionModelProvider.tsx:119/:262
|
|
191
|
+
// (owned by the frame loop; holds the current full video frame)
|
|
192
|
+
// - bestPrediction/bestBarcode/croppedDocument/initialCaptureBarcode/
|
|
193
|
+
// recaptureBarcode: IdCaptureModelsProvider.tsx:1311-1323
|
|
194
|
+
// - focus crop/rotate: FocusModelProvider.tsx:79-80
|
|
195
|
+
// - barcode crop/rotate/resize: BarcodeReadabilityModelProvider.tsx:81-83
|
|
196
|
+
// ---------------------------------------------------------------------
|
|
197
|
+
let lastPredictionCanvas = createCanvas();
|
|
198
|
+
let bestPredictionCanvas = createCanvas();
|
|
199
|
+
let bestBarcodeCanvas = createCanvas();
|
|
200
|
+
let croppedDocumentCanvas = createCanvas();
|
|
201
|
+
let initialCaptureBarcodeCanvas = createCanvas();
|
|
202
|
+
let recaptureBarcodeCanvas = createCanvas();
|
|
203
|
+
const focusCropCanvas = createCanvas();
|
|
204
|
+
const focusRotateCanvas = createCanvas();
|
|
205
|
+
const barcodeCropCanvas = createCanvas();
|
|
206
|
+
const barcodeRotateCanvas = createCanvas();
|
|
207
|
+
const barcodeResizeCanvas = createCanvas();
|
|
208
|
+
// Port of FocusModelProvider.tsx:102-121 — readiness gate + scratch
|
|
209
|
+
// canvases + prediction-time bookkeeping.
|
|
210
|
+
async function defaultMakeFocusPrediction(imageData, box) {
|
|
211
|
+
if (records.focus.state !== 'ready')
|
|
212
|
+
return null;
|
|
213
|
+
const prediction = await makeFocusModelPrediction(imageData, focusCropCanvas, focusRotateCanvas, box);
|
|
214
|
+
if (!prediction)
|
|
215
|
+
return null;
|
|
216
|
+
setLastFocusPredictionAt(prediction.predictionTime);
|
|
217
|
+
return prediction;
|
|
218
|
+
}
|
|
219
|
+
// Port of BarcodeReadabilityModelProvider.tsx:106-126.
|
|
220
|
+
async function defaultMakeBarcodeReadabilityPrediction(imageData, box) {
|
|
221
|
+
if (records.barcodeReadability.state !== 'ready')
|
|
222
|
+
return null;
|
|
223
|
+
const prediction = await makeBarcodeReadabilityModelPrediction(imageData, barcodeCropCanvas, barcodeRotateCanvas, barcodeResizeCanvas, box);
|
|
224
|
+
if (!prediction)
|
|
225
|
+
return null;
|
|
226
|
+
setLastBarcodeReadabilityPredictionAt(prediction.predictionTime);
|
|
227
|
+
return prediction;
|
|
228
|
+
}
|
|
229
|
+
const deps = {
|
|
230
|
+
makeDocumentDetectorPrediction,
|
|
231
|
+
processDocumentDetectorPrediction,
|
|
232
|
+
makeFocusPrediction: defaultMakeFocusPrediction,
|
|
233
|
+
makeBarcodeReadabilityPrediction: defaultMakeBarcodeReadabilityPrediction,
|
|
234
|
+
decodePDF417,
|
|
235
|
+
createCanvas,
|
|
236
|
+
createFrameLoop,
|
|
237
|
+
now: () => performance.now(),
|
|
238
|
+
// isMobile()'s userAgentData fallback can yield undefined (kept verbatim
|
|
239
|
+
// from sdk2's isMobile.ts) — coerce to the boolean this surface promises.
|
|
240
|
+
isMobile: () => isMobile() === true,
|
|
241
|
+
runModelLoadLifecycle,
|
|
242
|
+
...opts.deps,
|
|
243
|
+
};
|
|
244
|
+
// sdk2 captured `onMobile = isMobile()` at module load
|
|
245
|
+
// (IdCaptureModelsProvider.tsx:69); the port captures it per pipeline
|
|
246
|
+
// instance from the injectable dep instead.
|
|
247
|
+
const onMobile = deps.isMobile();
|
|
248
|
+
// ---------------------------------------------------------------------
|
|
249
|
+
// Instance fields (formerly refs / state, IdCaptureModelsProvider.tsx:
|
|
250
|
+
// 516-546 and DocumentDetectionModelProvider.tsx:119-127).
|
|
251
|
+
// ---------------------------------------------------------------------
|
|
252
|
+
let onPredictionHandler;
|
|
253
|
+
let bestFrameDetails = null;
|
|
254
|
+
let bestBarcodeDetails = null;
|
|
255
|
+
let bestFocusScore = 0;
|
|
256
|
+
let bestBarcodeScore = 0;
|
|
257
|
+
// One counter stands in for both sdk2 stopDetection refs: the provider's
|
|
258
|
+
// (IdCaptureModelsProvider.tsx:526, bumped at :1164) and the loop's
|
|
259
|
+
// (DocumentDetectionModelProvider.tsx:127, bumped at :223). resetBestFrame
|
|
260
|
+
// was the only place that bumped either, and it bumped both together.
|
|
261
|
+
let stopDetection = 0;
|
|
262
|
+
// Aggressive mode decode tracking (:529-532)
|
|
263
|
+
let lastAggressiveDecodeAttempt = { score: 0, time: 0 };
|
|
264
|
+
let aggressiveDecodeComplete = false;
|
|
265
|
+
let captureGeneration = 0;
|
|
266
|
+
// Barcode recapture tracking - separate canvases for initial and recapture
|
|
267
|
+
// sequences (:534-541). NOTE: sdk2 also keeps an initialCaptureBarcodeScore
|
|
268
|
+
// ref (:537, written at :1112/:1173) that is never read anywhere; the port
|
|
269
|
+
// omits the dead field (noUnusedLocals).
|
|
270
|
+
let initialCaptureBarcodeDetails = null;
|
|
271
|
+
let recaptureBarcodeDetails = null;
|
|
272
|
+
let recaptureBarcodeScore = 0;
|
|
273
|
+
let isRecapturePhase = false;
|
|
274
|
+
let requiredDocumentType = 'none'; // (:542-544)
|
|
275
|
+
// Live threshold/boundary state. Initial values match the providers'
|
|
276
|
+
// useState initializers: detection {} (DocumentDetectionModelProvider.tsx:
|
|
277
|
+
// 121-122), boundaries default (:123-124), focus {} (FocusModelProvider.tsx:
|
|
278
|
+
// 81), barcodeReadability {} (BarcodeReadabilityModelProvider.tsx:84-85).
|
|
279
|
+
let documentDetectionThresholds = {};
|
|
280
|
+
let documentDetectionBoundaries = defaultDocumentDetectionBoundaries;
|
|
281
|
+
let focusThresholds = {};
|
|
282
|
+
let barcodeReadabilityThresholds = {};
|
|
283
|
+
let timesAllZero = 0; // DocumentDetectionModelProvider.tsx:125
|
|
284
|
+
// ---------------------------------------------------------------------
|
|
285
|
+
// Model load + readiness aggregation (IdCaptureModelsProvider.tsx:
|
|
286
|
+
// 1183-1244 and :1034-1037).
|
|
287
|
+
// ---------------------------------------------------------------------
|
|
288
|
+
const modelNames = enableBarcodeReadabilityModel
|
|
289
|
+
? ['documentDetector', 'focus', 'barcodeReadability']
|
|
290
|
+
: ['documentDetector', 'focus'];
|
|
291
|
+
function computeAggregate() {
|
|
292
|
+
const snapshots = modelNames.map((name) => records[name]);
|
|
293
|
+
const modelStates = snapshots.map((snapshot) => snapshot.state);
|
|
294
|
+
const modelWarmingStartedAts = snapshots.map((snapshot) => snapshot.warmingStartedAt);
|
|
295
|
+
const modelDownloadProgresses = snapshots.map((snapshot) => snapshot.downloadProgress);
|
|
296
|
+
const ready = modelStates.every((state) => state === 'ready');
|
|
297
|
+
// modelError precedence: documentDetector ?? focus ?? barcodeReadability
|
|
298
|
+
// (:1034-1037), with the loop's all-zero self-heal error standing in for
|
|
299
|
+
// the doc hook's setModelError.
|
|
300
|
+
const erroredEntry = modelNames
|
|
301
|
+
.map((name) => ({
|
|
302
|
+
name,
|
|
303
|
+
error: name === 'documentDetector'
|
|
304
|
+
? (documentDetectorAllZeroError ?? records[name].error)
|
|
305
|
+
: records[name].error,
|
|
306
|
+
}))
|
|
307
|
+
.find((entry) => entry.error);
|
|
308
|
+
return {
|
|
309
|
+
ready,
|
|
310
|
+
// 'downloading' outranks 'warming' (sdk2 PR #239): while ANY model is
|
|
311
|
+
// still downloading the aggregate stays 'downloading' — reporting
|
|
312
|
+
// 'warming' early made the UI's warming progress animation start (and
|
|
313
|
+
// stall) while slower models were still fetching.
|
|
314
|
+
modelLoadState: ready
|
|
315
|
+
? 'ready'
|
|
316
|
+
: erroredEntry
|
|
317
|
+
? // Iteration-4 backfill (spec-named divergence): surface model
|
|
318
|
+
// failure in the load-state ladder so overlays' failure branch
|
|
319
|
+
// and onLoadingFailed are reachable. Same condition that
|
|
320
|
+
// populates modelError below.
|
|
321
|
+
'error'
|
|
322
|
+
: modelStates.some((state) => state === 'downloading')
|
|
323
|
+
? 'downloading'
|
|
324
|
+
: modelStates.some((state) => state === 'warming')
|
|
325
|
+
? 'warming'
|
|
326
|
+
: 'not-started',
|
|
327
|
+
modelWarmingStartedAt: modelWarmingStartedAts.every((v) => v === null)
|
|
328
|
+
? null
|
|
329
|
+
: Math.min(...modelWarmingStartedAts.filter((v) => v !== null)),
|
|
330
|
+
// Rounded (sdk2 PR #238): the per-model percentages are integers, but
|
|
331
|
+
// averaging them yields layout-shifting decimals in progress copy.
|
|
332
|
+
modelDownloadProgress: Math.round(modelDownloadProgresses.reduce((a, b) => a + b, 0) /
|
|
333
|
+
modelDownloadProgresses.length),
|
|
334
|
+
modelError: erroredEntry?.error ?? null,
|
|
335
|
+
failedModel: erroredEntry ? erroredEntry.name : null,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function emitAggregate() {
|
|
339
|
+
onModelStateChange?.(computeAggregate());
|
|
340
|
+
}
|
|
341
|
+
let loadPromise = null;
|
|
342
|
+
let resolveLoad = () => { };
|
|
343
|
+
let rejectLoad = () => { };
|
|
344
|
+
let loadSettled = false;
|
|
345
|
+
let lifecyclesCreated = false;
|
|
346
|
+
const lifecycleHandles = [];
|
|
347
|
+
// Settle load() once: first model error rejects with a typed error naming
|
|
348
|
+
// the model AND cancels every lifecycle (carry-forward from
|
|
349
|
+
// modelLifecycle.ts — its timeout does not abort in-flight loads, so
|
|
350
|
+
// without the cancel a late success could emit ready-after-error);
|
|
351
|
+
// all-ready resolves.
|
|
352
|
+
function maybeSettleLoad() {
|
|
353
|
+
if (loadSettled || !lifecyclesCreated)
|
|
354
|
+
return;
|
|
355
|
+
const failed = modelNames.find((name) => records[name].state === 'error');
|
|
356
|
+
if (failed) {
|
|
357
|
+
loadSettled = true;
|
|
358
|
+
for (const handle of lifecycleHandles)
|
|
359
|
+
handle.cancel();
|
|
360
|
+
rejectLoad(new CaptureAttachError({
|
|
361
|
+
code: 'MODEL_LOAD_FAILED',
|
|
362
|
+
recoverable: true,
|
|
363
|
+
model: failed,
|
|
364
|
+
cause: records[failed].error,
|
|
365
|
+
}));
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (modelNames.every((name) => records[name].state === 'ready')) {
|
|
369
|
+
loadSettled = true;
|
|
370
|
+
resolveLoad();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function onLifecycleChange(name, snapshot) {
|
|
374
|
+
const wasErrored = records[name].state === 'error';
|
|
375
|
+
records[name] = snapshot;
|
|
376
|
+
// The ONLY place a model failure is written down. Everything downstream
|
|
377
|
+
// (the aggregate, MODEL_LOAD_FAILED, `onModelError`, fallback mode) either
|
|
378
|
+
// keeps the cause on an object nobody prints or reduces it to the model
|
|
379
|
+
// name, so an integrator saw a flow drop into fallback with no way to tell
|
|
380
|
+
// a blocked model fetch from a camera that never produced a frame — the
|
|
381
|
+
// three causes below are not even the same class of problem:
|
|
382
|
+
//
|
|
383
|
+
// 'Model loading time limit exceeded.' <- modelLoadTimeoutMs
|
|
384
|
+
// 'Camera did not become ready in time.' <- not a model failure at all
|
|
385
|
+
// anything else <- the real load rejection
|
|
386
|
+
//
|
|
387
|
+
// Logged once per transition INTO 'error' (this fires on every snapshot,
|
|
388
|
+
// including progress ticks), at error level so it survives the LiteRT
|
|
389
|
+
// console filter, which only ever diverts INFO/WARNING lines.
|
|
390
|
+
if (!wasErrored && snapshot.state === 'error') {
|
|
391
|
+
error(`[IdCapture] model "${name}" failed to load:`, snapshot.error);
|
|
392
|
+
}
|
|
393
|
+
emitAggregate();
|
|
394
|
+
maybeSettleLoad();
|
|
395
|
+
}
|
|
396
|
+
// `{ current }` view over the video supplier so the shared
|
|
397
|
+
// waitForVideoReady helper (models/helpers.ts:35) polls the live element.
|
|
398
|
+
const videoRef = {
|
|
399
|
+
get current() {
|
|
400
|
+
return video();
|
|
401
|
+
},
|
|
402
|
+
};
|
|
403
|
+
function load() {
|
|
404
|
+
if (loadPromise)
|
|
405
|
+
return loadPromise;
|
|
406
|
+
loadPromise = new Promise((resolve, reject) => {
|
|
407
|
+
resolveLoad = resolve;
|
|
408
|
+
rejectLoad = reject;
|
|
409
|
+
});
|
|
410
|
+
// Load order documentDetector -> focus -> barcodeReadability, with the
|
|
411
|
+
// barcode model skipped when disabled (IdCaptureModelsProvider.tsx:
|
|
412
|
+
// 1183-1187).
|
|
413
|
+
lifecycleHandles.push(deps.runModelLoadLifecycle({
|
|
414
|
+
load: () => loadDocumentDetector(modelAssetPaths?.documentDetector, scoreThreshold, documentDetectorRuntime, {
|
|
415
|
+
allowSinglePageIdCapture,
|
|
416
|
+
enableFingerOcclusionGuidance,
|
|
417
|
+
enableGlareOcclusionGuidance,
|
|
418
|
+
enableHologramOcclusionGuidance,
|
|
419
|
+
}),
|
|
420
|
+
testAgainstKnownImage: () => testDocumentDetectorAgainstKnownImage(),
|
|
421
|
+
warmUp: () => {
|
|
422
|
+
// Warm up against a live frame so the next prediction is fast
|
|
423
|
+
// (sdk2/src/lib/models/DocumentDetection.ts:272-279). sdk2 assumed
|
|
424
|
+
// videoRef.current non-null here; the supplier may legitimately
|
|
425
|
+
// return null (camera detached), so guard instead of throwing.
|
|
426
|
+
const v = video();
|
|
427
|
+
if (!v)
|
|
428
|
+
return;
|
|
429
|
+
const canvas = deps.createCanvas();
|
|
430
|
+
canvas.width = v.videoWidth;
|
|
431
|
+
canvas.height = v.videoHeight;
|
|
432
|
+
const ctx = canvas.getContext('2d');
|
|
433
|
+
ctx?.drawImage(v, 0, 0);
|
|
434
|
+
void deps.makeDocumentDetectorPrediction(canvas);
|
|
435
|
+
},
|
|
436
|
+
// Exact event names from sdk2/src/lib/models/DocumentDetection.ts:235-238
|
|
437
|
+
progressEventName: documentDetectorRuntime === 'litert'
|
|
438
|
+
? 'idmission.preloadProgress.documentDetectorLiteRT'
|
|
439
|
+
: 'idmission.preloadProgress.documentDetector',
|
|
440
|
+
timeoutMs: modelLoadTimeoutMs,
|
|
441
|
+
videoReady: () => waitForVideoReady(videoRef),
|
|
442
|
+
onChange: (snapshot) => onLifecycleChange('documentDetector', snapshot),
|
|
443
|
+
onCleanup: closeDocumentDetector,
|
|
444
|
+
}));
|
|
445
|
+
lifecycleHandles.push(deps.runModelLoadLifecycle({
|
|
446
|
+
load: () => loadFocusModel(modelAssetPaths?.focus, focusRuntime),
|
|
447
|
+
warmUp: () => {
|
|
448
|
+
// sdk2/src/lib/models/Focus.ts:190 (classifyForVideo warm call)
|
|
449
|
+
const v = video();
|
|
450
|
+
if (v)
|
|
451
|
+
classifyFocusModelForVideo(v);
|
|
452
|
+
},
|
|
453
|
+
// Exact event names from sdk2/src/lib/models/Focus.ts:153-155
|
|
454
|
+
progressEventName: focusRuntime === 'litert'
|
|
455
|
+
? 'idmission.preloadProgress.focusLiteRT'
|
|
456
|
+
: 'idmission.preloadProgress.focus',
|
|
457
|
+
timeoutMs: modelLoadTimeoutMs,
|
|
458
|
+
videoReady: () => waitForVideoReady(videoRef),
|
|
459
|
+
onChange: (snapshot) => onLifecycleChange('focus', snapshot),
|
|
460
|
+
onCleanup: closeFocusModel,
|
|
461
|
+
}));
|
|
462
|
+
if (enableBarcodeReadabilityModel) {
|
|
463
|
+
lifecycleHandles.push(deps.runModelLoadLifecycle({
|
|
464
|
+
load: () => loadBarcodeReadabilityModel(undefined, barcodeReadabilityRuntime),
|
|
465
|
+
warmUp: () => {
|
|
466
|
+
// sdk2/src/lib/models/BarcodeReadability.ts:188
|
|
467
|
+
const v = video();
|
|
468
|
+
if (v)
|
|
469
|
+
classifyBarcodeReadabilityModelForVideo(v);
|
|
470
|
+
},
|
|
471
|
+
// Exact event names from sdk2/src/lib/models/BarcodeReadability.ts:160-162
|
|
472
|
+
progressEventName: barcodeReadabilityRuntime === 'litert'
|
|
473
|
+
? 'idmission.preloadProgress.barcodeReadabilityLiteRT'
|
|
474
|
+
: 'idmission.preloadProgress.barcodeReadability',
|
|
475
|
+
timeoutMs: modelLoadTimeoutMs,
|
|
476
|
+
videoReady: () => waitForVideoReady(videoRef),
|
|
477
|
+
onChange: (snapshot) => onLifecycleChange('barcodeReadability', snapshot),
|
|
478
|
+
onCleanup: closeBarcodeReadabilityModel,
|
|
479
|
+
}));
|
|
480
|
+
}
|
|
481
|
+
lifecyclesCreated = true;
|
|
482
|
+
maybeSettleLoad();
|
|
483
|
+
return loadPromise;
|
|
484
|
+
}
|
|
485
|
+
// Wrapper mirroring useBarcodeReadabilityAnalysis
|
|
486
|
+
// (IdCaptureModelsProvider.tsx:244-283): resolves the per-doc-type
|
|
487
|
+
// threshold, then delegates to the module-level analyzer.
|
|
488
|
+
function runBarcodeReadabilityAnalysis(prediction, lastCanvas, croppedCanvas, bestCanvas, currentBestBarcodeScore) {
|
|
489
|
+
const barcodeReadabilityThreshold = calculateBarcodeReadabilityThreshold(prediction.detectedDocumentType, barcodeReadabilityThresholds, onMobile);
|
|
490
|
+
return analyzeBarcodeReadability(prediction, lastCanvas, croppedCanvas, bestCanvas, currentBestBarcodeScore, documentDetectionThresholds, deps.makeBarcodeReadabilityPrediction, barcodeReadabilityThreshold, deps.makeDocumentDetectorPrediction, deps.processDocumentDetectorPrediction);
|
|
491
|
+
}
|
|
492
|
+
// ---------------------------------------------------------------------
|
|
493
|
+
// The detection handler — verbatim port of the handleDetections effect
|
|
494
|
+
// body (IdCaptureModelsProvider.tsx:578-1032). Refs become the fields
|
|
495
|
+
// above; guard placements against stopDetection/captureGeneration are kept
|
|
496
|
+
// exactly where sdk2 has them.
|
|
497
|
+
// ---------------------------------------------------------------------
|
|
498
|
+
async function handleDetection(prediction) {
|
|
499
|
+
// (:581) — a React-ref-null guard in sdk2; the port's canvas always
|
|
500
|
+
// exists, but the early return is kept so behavior matches if a caller
|
|
501
|
+
// ever nulls it out via close().
|
|
502
|
+
if (!lastPredictionCanvas)
|
|
503
|
+
return;
|
|
504
|
+
const stopDetectionAtStart = stopDetection;
|
|
505
|
+
let focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false, pdf417PredictionTime = 0, pdf417PredictionScore = 0, pdf417PredictionThresholdMet = false;
|
|
506
|
+
// (:591-600) single-page -> passport remap
|
|
507
|
+
const isSinglePage = prediction.detectedDocumentType === 'singlePage';
|
|
508
|
+
if (!allowSinglePageIdCapture && isSinglePage) {
|
|
509
|
+
prediction.detectedDocumentType = 'passport';
|
|
510
|
+
prediction.passportDetectionScore = prediction.singlePageDetectionScore;
|
|
511
|
+
prediction.passportDetectionThresholdMet =
|
|
512
|
+
prediction.singlePageDetectionThresholdMet;
|
|
513
|
+
prediction.singlePageDetectionScore = 0;
|
|
514
|
+
prediction.singlePageDetectionThresholdMet = false;
|
|
515
|
+
}
|
|
516
|
+
// (:602-609) required-type gate. sdk2 calls `reqDocType.includes?.()` on
|
|
517
|
+
// the string form too (substring match). For the detected-type clause
|
|
518
|
+
// (:606) the string case is redundant with the equality check above it
|
|
519
|
+
// (no valid DocumentType is a proper substring of another), but for the
|
|
520
|
+
// singlePage-as-idCardFront clause (:607-609) the string case is
|
|
521
|
+
// load-bearing: 'idCardFront'.includes('idCardFront') is TRUE, so a
|
|
522
|
+
// required type of the plain STRING 'idCardFront' must admit a detected
|
|
523
|
+
// singlePage when allowSinglePageIdCapture is on. Among the remaining
|
|
524
|
+
// string values ('idCardBack'/'passport'/'singlePage'; 'none' returns at
|
|
525
|
+
// the first clause) the substring test is false, so the string arm
|
|
526
|
+
// reduces to an equality check.
|
|
527
|
+
const reqDocType = requiredDocumentType;
|
|
528
|
+
const isRequiredDocumentType = reqDocType === 'none' ||
|
|
529
|
+
prediction.detectedDocumentType === reqDocType ||
|
|
530
|
+
(Array.isArray(reqDocType) &&
|
|
531
|
+
reqDocType.includes(prediction.detectedDocumentType)) ||
|
|
532
|
+
(allowSinglePageIdCapture &&
|
|
533
|
+
isSinglePage &&
|
|
534
|
+
(reqDocType === 'idCardFront' ||
|
|
535
|
+
(Array.isArray(reqDocType) && reqDocType.includes('idCardFront'))));
|
|
536
|
+
// During recapture phase, run barcode analysis with relaxed conditions
|
|
537
|
+
// (don't require document to be in bounds or stable since user is zooming in)
|
|
538
|
+
const isInRecapturePhase = isRecapturePhase;
|
|
539
|
+
const shouldRunBarcodeAnalysisDuringRecapture = isInRecapturePhase &&
|
|
540
|
+
isRequiredDocumentType &&
|
|
541
|
+
prediction.detectedDocumentType !== 'none' &&
|
|
542
|
+
prediction.detectionThresholdMet &&
|
|
543
|
+
prediction.bestDocument &&
|
|
544
|
+
prediction.bestPDF417;
|
|
545
|
+
// During recapture, allow barcode analysis even without document detection
|
|
546
|
+
// (user zoomed in so close that only the barcode is visible)
|
|
547
|
+
const shouldRunBarcodeOnlyAnalysisDuringRecapture = isInRecapturePhase && !prediction.bestDocument && prediction.bestPDF417?.box;
|
|
548
|
+
// Debug logging for recapture conditions (:630-634)
|
|
549
|
+
if (isInRecapturePhase && prediction.bestPDF417?.box) {
|
|
550
|
+
log(`[IdCaptureModelsProvider] Recapture debug: isRecapture=${isInRecapturePhase}, bestDocument=${!!prediction.bestDocument}, bestPDF417=${!!prediction.bestPDF417?.box}, shouldRunBarcodeOnly=${shouldRunBarcodeOnlyAnalysisDuringRecapture}, shouldRunRelaxed=${shouldRunBarcodeAnalysisDuringRecapture}`);
|
|
551
|
+
}
|
|
552
|
+
// (:636-643) main good-frame branch gates
|
|
553
|
+
if (isRequiredDocumentType &&
|
|
554
|
+
prediction.detectedDocumentType !== 'none' &&
|
|
555
|
+
prediction.detectionThresholdMet &&
|
|
556
|
+
prediction.documentInBounds &&
|
|
557
|
+
!prediction.documentTooClose &&
|
|
558
|
+
prediction.documentIsStable) {
|
|
559
|
+
// (:644-651)
|
|
560
|
+
const focusPrediction = await deps.makeFocusPrediction(lastPredictionCanvas, prediction.bestDocument?.box);
|
|
561
|
+
if (focusPrediction) {
|
|
562
|
+
focusScore = focusPrediction.score;
|
|
563
|
+
focusPredictionTime = focusPrediction.predictionTime;
|
|
564
|
+
}
|
|
565
|
+
// (:653-659)
|
|
566
|
+
const focusThresholdSet = focusThresholds[prediction.detectedDocumentType];
|
|
567
|
+
const focusThreshold = (onMobile ? focusThresholdSet?.mobile : focusThresholdSet?.desktop) ?? 0;
|
|
568
|
+
focusThresholdMet = focusScore >= focusThreshold;
|
|
569
|
+
// Don't save a finger-occluded frame as the captured "best
|
|
570
|
+
// frame" even if its focus happens to peak this tick. The
|
|
571
|
+
// isGoodFrame gate in the state provider already blocks the
|
|
572
|
+
// capture *trigger* on occlusion, but best-frame tracking is
|
|
573
|
+
// independent — without this guard a flickered-off finger
|
|
574
|
+
// detection at the moment of peak focus produces a saved
|
|
575
|
+
// image with the finger plainly visible. (:661-689)
|
|
576
|
+
const fingersOccludingDocument = enableFingerOcclusionGuidance
|
|
577
|
+
? computeFingerOcclusion(prediction.bestDocument, prediction.detectedObjects, prediction.detectedDocumentType, resolvedFingerOcclusionThresholds)
|
|
578
|
+
: false;
|
|
579
|
+
const glareOccludingDocument = enableGlareOcclusionGuidance
|
|
580
|
+
? computeGlareOcclusion(prediction.bestDocument, prediction.detectedObjects)
|
|
581
|
+
: false;
|
|
582
|
+
const hologramOccludingDocument = enableHologramOcclusionGuidance
|
|
583
|
+
? computeHologramOcclusion(prediction.bestDocument, prediction.detectedObjects)
|
|
584
|
+
: false;
|
|
585
|
+
// (:691) stale-generation guard around all tracking work
|
|
586
|
+
if (stopDetectionAtStart === stopDetection) {
|
|
587
|
+
// (:692-738) best-frame tracking
|
|
588
|
+
if (!fingersOccludingDocument &&
|
|
589
|
+
!glareOccludingDocument &&
|
|
590
|
+
!hologramOccludingDocument &&
|
|
591
|
+
bestFocusScore <= focusScore) {
|
|
592
|
+
bestFocusScore = focusScore;
|
|
593
|
+
drawToCanvas(bestPredictionCanvas, lastPredictionCanvas);
|
|
594
|
+
const maxGlareScore = enableGlareOcclusionGuidance
|
|
595
|
+
? Math.max(0, ...prediction.detectedObjects
|
|
596
|
+
.filter((o) => o.label === 'Glare')
|
|
597
|
+
.map((o) => o.score))
|
|
598
|
+
: undefined;
|
|
599
|
+
const maxHologramScore = enableHologramOcclusionGuidance
|
|
600
|
+
? Math.max(0, ...prediction.detectedObjects
|
|
601
|
+
.filter((o) => o.label === 'Hologram')
|
|
602
|
+
.map((o) => o.score))
|
|
603
|
+
: undefined;
|
|
604
|
+
// For a passport, prediction.bestDocument is the *Passport page*
|
|
605
|
+
// (the data-page leaf). When full-booklet capture is required we
|
|
606
|
+
// want the whole spread, so crop to the enclosing 'Document' box
|
|
607
|
+
// instead (falling back to bestDocument if it isn't present).
|
|
608
|
+
// (:719-729)
|
|
609
|
+
const captureBox = requireFullPassportBooklet &&
|
|
610
|
+
prediction.detectedDocumentType === 'passport'
|
|
611
|
+
? (prediction.detectedObjects.find((o) => o.label === 'Document')
|
|
612
|
+
?.box ?? prediction.bestDocument?.box)
|
|
613
|
+
: prediction.bestDocument?.box;
|
|
614
|
+
bestFrameDetails = {
|
|
615
|
+
boundingBox: captureBox,
|
|
616
|
+
documentType: prediction.detectedDocumentType,
|
|
617
|
+
detectionScore: prediction.detectionScore,
|
|
618
|
+
focusScore,
|
|
619
|
+
maxGlareScore,
|
|
620
|
+
maxHologramScore,
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Barcode Readability Analysis (:740-878)
|
|
625
|
+
*/
|
|
626
|
+
if (enableBarcodeReadabilityModel &&
|
|
627
|
+
prediction.bestDocument &&
|
|
628
|
+
prediction.bestPDF417 &&
|
|
629
|
+
croppedDocumentCanvas) {
|
|
630
|
+
const barcodeAnalysisResult = await runBarcodeReadabilityAnalysis(prediction, lastPredictionCanvas, croppedDocumentCanvas, bestBarcodeCanvas, bestBarcodeScore);
|
|
631
|
+
pdf417PredictionTime = barcodeAnalysisResult.pdf417PredictionTime;
|
|
632
|
+
pdf417PredictionScore = barcodeAnalysisResult.pdf417PredictionScore;
|
|
633
|
+
pdf417PredictionThresholdMet =
|
|
634
|
+
barcodeAnalysisResult.pdf417PredictionThresholdMet;
|
|
635
|
+
// Increment PDF417 detection counters (:763-769). sdk2 dispatched
|
|
636
|
+
// straight to the global store; the port surfaces the same actions
|
|
637
|
+
// through onIdCaptureAction.
|
|
638
|
+
if (barcodeAnalysisResult.pdf417PredictionThresholdMet) {
|
|
639
|
+
onIdCaptureAction?.({ type: 'incrementPdf417DetectionCount' });
|
|
640
|
+
}
|
|
641
|
+
else if (barcodeAnalysisResult.pdf417PredictionScore > 0) {
|
|
642
|
+
// PDF417 was detected but score was too low for parsing
|
|
643
|
+
onIdCaptureAction?.({ type: 'incrementPdf417LowScoreCount' });
|
|
644
|
+
}
|
|
645
|
+
if (barcodeAnalysisResult.newBestBarcodeScore) {
|
|
646
|
+
bestBarcodeScore = barcodeAnalysisResult.newBestBarcodeScore;
|
|
647
|
+
}
|
|
648
|
+
if (barcodeAnalysisResult.newBestBarcodeDetails) {
|
|
649
|
+
bestBarcodeDetails = barcodeAnalysisResult.newBestBarcodeDetails;
|
|
650
|
+
}
|
|
651
|
+
// Aggressive mode: attempt decode during capture when score exceeds
|
|
652
|
+
// threshold (:780-841)
|
|
653
|
+
if (aggressiveModeEnabled &&
|
|
654
|
+
!aggressiveDecodeComplete &&
|
|
655
|
+
bestBarcodeCanvas &&
|
|
656
|
+
pdf417PredictionScore >= aggressiveModeDecodeThreshold) {
|
|
657
|
+
// sdk2 uses Date.now() here (:787); deps.now (performance.now by
|
|
658
|
+
// default) is equivalent for the relative interval math and keeps
|
|
659
|
+
// the throttle testable.
|
|
660
|
+
const now = deps.now();
|
|
661
|
+
const timeSinceLastAttempt = now - lastAggressiveDecodeAttempt.time;
|
|
662
|
+
const scoreImproved = pdf417PredictionScore > lastAggressiveDecodeAttempt.score;
|
|
663
|
+
if (timeSinceLastAttempt >= aggressiveModeDecodeIntervalMs ||
|
|
664
|
+
scoreImproved) {
|
|
665
|
+
lastAggressiveDecodeAttempt = {
|
|
666
|
+
score: pdf417PredictionScore,
|
|
667
|
+
time: now,
|
|
668
|
+
};
|
|
669
|
+
log(`[IdCaptureModelsProvider] Aggressive mode: attempting decode (score: ${pdf417PredictionScore.toFixed(3)}, interval: ${timeSinceLastAttempt}ms, improved: ${scoreImproved})`);
|
|
670
|
+
// Attempt decode asynchronously (non-blocking) (:807-839)
|
|
671
|
+
const canvas = bestBarcodeCanvas;
|
|
672
|
+
const generation = captureGeneration;
|
|
673
|
+
canvas.toBlob((blob) => {
|
|
674
|
+
if (!blob ||
|
|
675
|
+
aggressiveDecodeComplete ||
|
|
676
|
+
generation !== captureGeneration)
|
|
677
|
+
return;
|
|
678
|
+
deps
|
|
679
|
+
.decodePDF417(blob, { tryRotations: true })
|
|
680
|
+
.then((result) => {
|
|
681
|
+
if (result &&
|
|
682
|
+
!aggressiveDecodeComplete &&
|
|
683
|
+
generation === captureGeneration) {
|
|
684
|
+
aggressiveDecodeComplete = true;
|
|
685
|
+
log(`[IdCaptureModelsProvider] Aggressive mode: decode SUCCESS via ${result.method}`);
|
|
686
|
+
onAggressiveDecodeSuccess?.(result);
|
|
687
|
+
}
|
|
688
|
+
})
|
|
689
|
+
.catch(() => {
|
|
690
|
+
// Silently ignore decode failures (quiet catch kept
|
|
691
|
+
// verbatim from IdCaptureModelsProvider.tsx:833-835)
|
|
692
|
+
});
|
|
693
|
+
}, 'image/jpeg', 0.95);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
// During recapture phase, also track best barcode separately for
|
|
697
|
+
// recapture sequence (:843-877)
|
|
698
|
+
if (isRecapturePhase &&
|
|
699
|
+
recaptureBarcodeCanvas &&
|
|
700
|
+
pdf417PredictionScore > recaptureBarcodeScore) {
|
|
701
|
+
log(`[IdCaptureModelsProvider] Recapture tracking: new best score ${pdf417PredictionScore} (was ${recaptureBarcodeScore})`);
|
|
702
|
+
recaptureBarcodeScore = pdf417PredictionScore;
|
|
703
|
+
// Create details directly from current prediction (not newBestBarcodeDetails which
|
|
704
|
+
// is only set when score beats overall best, not just recapture best)
|
|
705
|
+
recaptureBarcodeDetails = {
|
|
706
|
+
boundingBox: prediction.bestPDF417.box,
|
|
707
|
+
score: pdf417PredictionScore,
|
|
708
|
+
};
|
|
709
|
+
// Crop barcode from croppedDocumentCanvas using the processed bounding box
|
|
710
|
+
// (can't use bestBarcodeCanvas since it's only updated for overall best)
|
|
711
|
+
if (croppedDocumentCanvas &&
|
|
712
|
+
barcodeAnalysisResult.processedBarcodeBoundingBox) {
|
|
713
|
+
cropToDetectedObjectBox(croppedDocumentCanvas, barcodeAnalysisResult.processedBarcodeBoundingBox, recaptureBarcodeCanvas, 16);
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
log(`[IdCaptureModelsProvider] Recapture tracking: could not crop barcode - croppedDocumentCanvas=${!!croppedDocumentCanvas}, processedBarcodeBoundingBox=${!!barcodeAnalysisResult.processedBarcodeBoundingBox}`);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
else if (shouldRunBarcodeAnalysisDuringRecapture) {
|
|
723
|
+
// During recapture, run barcode analysis even if document is out of
|
|
724
|
+
// bounds or unstable (user is zooming in, which may go beyond
|
|
725
|
+
// boundaries and cause instability) (:880-944)
|
|
726
|
+
if (enableBarcodeReadabilityModel &&
|
|
727
|
+
croppedDocumentCanvas &&
|
|
728
|
+
stopDetectionAtStart === stopDetection) {
|
|
729
|
+
const barcodeAnalysisResult = await runBarcodeReadabilityAnalysis(prediction, lastPredictionCanvas, croppedDocumentCanvas, bestBarcodeCanvas, bestBarcodeScore);
|
|
730
|
+
pdf417PredictionTime = barcodeAnalysisResult.pdf417PredictionTime;
|
|
731
|
+
pdf417PredictionScore = barcodeAnalysisResult.pdf417PredictionScore;
|
|
732
|
+
pdf417PredictionThresholdMet =
|
|
733
|
+
barcodeAnalysisResult.pdf417PredictionThresholdMet;
|
|
734
|
+
if (barcodeAnalysisResult.newBestBarcodeScore) {
|
|
735
|
+
bestBarcodeScore = barcodeAnalysisResult.newBestBarcodeScore;
|
|
736
|
+
}
|
|
737
|
+
if (barcodeAnalysisResult.newBestBarcodeDetails) {
|
|
738
|
+
bestBarcodeDetails = barcodeAnalysisResult.newBestBarcodeDetails;
|
|
739
|
+
}
|
|
740
|
+
// Track best barcode separately for recapture sequence (:910-943)
|
|
741
|
+
if (recaptureBarcodeCanvas &&
|
|
742
|
+
pdf417PredictionScore > recaptureBarcodeScore) {
|
|
743
|
+
log(`[IdCaptureModelsProvider] Recapture tracking (relaxed): new best score ${pdf417PredictionScore} (was ${recaptureBarcodeScore})`);
|
|
744
|
+
recaptureBarcodeScore = pdf417PredictionScore;
|
|
745
|
+
// Create details directly from current prediction (not newBestBarcodeDetails which
|
|
746
|
+
// is only set when score beats overall best, not just recapture best)
|
|
747
|
+
recaptureBarcodeDetails = {
|
|
748
|
+
boundingBox: prediction.bestPDF417.box,
|
|
749
|
+
score: pdf417PredictionScore,
|
|
750
|
+
};
|
|
751
|
+
// Crop barcode from croppedDocumentCanvas using the processed bounding box
|
|
752
|
+
// (can't use bestBarcodeCanvas since it's only updated for overall best)
|
|
753
|
+
if (croppedDocumentCanvas &&
|
|
754
|
+
barcodeAnalysisResult.processedBarcodeBoundingBox) {
|
|
755
|
+
cropToDetectedObjectBox(croppedDocumentCanvas, barcodeAnalysisResult.processedBarcodeBoundingBox, recaptureBarcodeCanvas, 16);
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
log(`[IdCaptureModelsProvider] Recapture tracking (relaxed): could not crop barcode - croppedDocumentCanvas=${!!croppedDocumentCanvas}, processedBarcodeBoundingBox=${!!barcodeAnalysisResult.processedBarcodeBoundingBox}`);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
else if (shouldRunBarcodeOnlyAnalysisDuringRecapture) {
|
|
764
|
+
// During recapture when only PDF417 is detected (no document),
|
|
765
|
+
// run barcode readability directly on the PDF417 box from the full
|
|
766
|
+
// frame (:945-993)
|
|
767
|
+
log(`[IdCaptureModelsProvider] Barcode-only recapture path: enableBarcodeReadabilityModel=${enableBarcodeReadabilityModel}, hasCanvas=${!!lastPredictionCanvas}, stopMatch=${stopDetectionAtStart === stopDetection}`);
|
|
768
|
+
if (enableBarcodeReadabilityModel &&
|
|
769
|
+
lastPredictionCanvas &&
|
|
770
|
+
stopDetectionAtStart === stopDetection) {
|
|
771
|
+
const startTime = deps.now(); // sdk2: performance.now() (:956)
|
|
772
|
+
const barcodeReadabilityResult = await deps.makeBarcodeReadabilityPrediction(lastPredictionCanvas, prediction.bestPDF417.box);
|
|
773
|
+
log(`[IdCaptureModelsProvider] Barcode-only readability result: ${barcodeReadabilityResult?.score ?? 'null'}`);
|
|
774
|
+
if (barcodeReadabilityResult) {
|
|
775
|
+
pdf417PredictionTime = deps.now() - startTime;
|
|
776
|
+
pdf417PredictionScore = barcodeReadabilityResult.score;
|
|
777
|
+
// Track best barcode for recapture sequence (:969-990)
|
|
778
|
+
if (recaptureBarcodeCanvas &&
|
|
779
|
+
pdf417PredictionScore > recaptureBarcodeScore) {
|
|
780
|
+
log(`[IdCaptureModelsProvider] Recapture tracking (barcode-only): new best score ${pdf417PredictionScore} (was ${recaptureBarcodeScore})`);
|
|
781
|
+
recaptureBarcodeScore = pdf417PredictionScore;
|
|
782
|
+
recaptureBarcodeDetails = {
|
|
783
|
+
boundingBox: prediction.bestPDF417.box,
|
|
784
|
+
score: pdf417PredictionScore,
|
|
785
|
+
};
|
|
786
|
+
// Crop barcode directly from full frame
|
|
787
|
+
cropToDetectedObjectBox(lastPredictionCanvas, prediction.bestPDF417.box, recaptureBarcodeCanvas, 16);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* @note
|
|
794
|
+
* This should ALWAYS be called. (:995-1009)
|
|
795
|
+
* Do not return early from this function unless
|
|
796
|
+
* lastPredictionCanvas is not set
|
|
797
|
+
*/
|
|
798
|
+
void onPredictionHandler?.({
|
|
799
|
+
...prediction,
|
|
800
|
+
focusScore,
|
|
801
|
+
focusPredictionTime,
|
|
802
|
+
focusThresholdMet,
|
|
803
|
+
pdf417PredictionTime,
|
|
804
|
+
pdf417PredictionScore,
|
|
805
|
+
pdf417PredictionThresholdMet,
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
// ---------------------------------------------------------------------
|
|
809
|
+
// Frame loop — verbatim port of the useFrameLoop body
|
|
810
|
+
// (DocumentDetectionModelProvider.tsx:154-216). sdk2's videoLoaded /
|
|
811
|
+
// cameraReady / videoRef.current guards collapse into the video supplier
|
|
812
|
+
// returning null until the camera is live.
|
|
813
|
+
// ---------------------------------------------------------------------
|
|
814
|
+
const frameLoop = deps.createFrameLoop(async (frameId, timeRunning) => {
|
|
815
|
+
const videoEl = video();
|
|
816
|
+
if (records.documentDetector.state !== 'ready' || // (:156-159) `!ready`
|
|
817
|
+
!videoEl ||
|
|
818
|
+
!lastPredictionCanvas)
|
|
819
|
+
return;
|
|
820
|
+
const stopDetectionAtStart = stopDetection;
|
|
821
|
+
const vw = videoEl.videoWidth;
|
|
822
|
+
const vh = videoEl.videoHeight;
|
|
823
|
+
lastPredictionCanvas.width = vw;
|
|
824
|
+
lastPredictionCanvas.height = vh;
|
|
825
|
+
const ctx = lastPredictionCanvas.getContext('2d');
|
|
826
|
+
if (ctx && videoEl.readyState === 4) {
|
|
827
|
+
if (stopDetectionAtStart !== stopDetection)
|
|
828
|
+
return;
|
|
829
|
+
ctx.drawImage(videoEl, 0, 0, vw, vh);
|
|
830
|
+
const prediction = await deps.makeDocumentDetectorPrediction(lastPredictionCanvas);
|
|
831
|
+
if (prediction) {
|
|
832
|
+
const processedPrediction = deps.processDocumentDetectorPrediction(prediction, documentDetectionThresholds, documentDetectionBoundaries);
|
|
833
|
+
processedPrediction.frameId = frameId;
|
|
834
|
+
setLastDetectionAt(new Date().getTime());
|
|
835
|
+
debug(processedPrediction);
|
|
836
|
+
if (processedPrediction.allZero) {
|
|
837
|
+
// All-zero self-heal: two all-zero raw predictions surface a
|
|
838
|
+
// model error (DocumentDetectionModelProvider.tsx:188 counts,
|
|
839
|
+
// :209-216 sets the error; the error then flows into the
|
|
840
|
+
// aggregate exactly like the doc hook's modelError).
|
|
841
|
+
timesAllZero += 1;
|
|
842
|
+
if (timesAllZero >= 2) {
|
|
843
|
+
documentDetectorAllZeroError = new Error('model is returning all zeroes');
|
|
844
|
+
emitAggregate();
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (stopDetectionAtStart !== stopDetection)
|
|
848
|
+
return;
|
|
849
|
+
if (timeRunning < delayAfterStartMs)
|
|
850
|
+
return;
|
|
851
|
+
await handleDetection(processedPrediction);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}, { throttleMs });
|
|
855
|
+
// ---------------------------------------------------------------------
|
|
856
|
+
// Public surface
|
|
857
|
+
// ---------------------------------------------------------------------
|
|
858
|
+
// (:1052-1055)
|
|
859
|
+
function getBestFrame() {
|
|
860
|
+
if (!bestFrameDetails || !bestPredictionCanvas)
|
|
861
|
+
return null;
|
|
862
|
+
return { ...bestFrameDetails, canvas: bestPredictionCanvas };
|
|
863
|
+
}
|
|
864
|
+
// (:1057-1060)
|
|
865
|
+
function getBestBarcode() {
|
|
866
|
+
if (!bestBarcodeDetails || !bestBarcodeCanvas)
|
|
867
|
+
return null;
|
|
868
|
+
return { ...bestBarcodeDetails, canvas: bestBarcodeCanvas };
|
|
869
|
+
}
|
|
870
|
+
// (:1062-1092)
|
|
871
|
+
function resetBestBarcode() {
|
|
872
|
+
// Light-weight reset that only clears barcode tracking without disrupting detection
|
|
873
|
+
bestBarcodeScore = 0;
|
|
874
|
+
bestBarcodeDetails = null;
|
|
875
|
+
// Also reset recapture tracking so early frames during move-closer window are ignored
|
|
876
|
+
recaptureBarcodeScore = 0;
|
|
877
|
+
recaptureBarcodeDetails = null;
|
|
878
|
+
// Clear the canvas content but don't recreate it (:1070-1091, via the
|
|
879
|
+
// shared clearCanvas util — identical getContext('2d').clearRect calls)
|
|
880
|
+
clearCanvas(bestBarcodeCanvas);
|
|
881
|
+
clearCanvas(recaptureBarcodeCanvas);
|
|
882
|
+
}
|
|
883
|
+
// (:1094-1120)
|
|
884
|
+
function startBarcodeRecapturePhase() {
|
|
885
|
+
log(`[IdCaptureModelsProvider] Starting barcode recapture phase. Initial best score: ${bestBarcodeScore}`);
|
|
886
|
+
// Snapshot current best barcode to initial capture canvas
|
|
887
|
+
if (bestBarcodeCanvas && initialCaptureBarcodeCanvas) {
|
|
888
|
+
const ctx = initialCaptureBarcodeCanvas.getContext('2d');
|
|
889
|
+
if (ctx) {
|
|
890
|
+
initialCaptureBarcodeCanvas.width = bestBarcodeCanvas.width;
|
|
891
|
+
initialCaptureBarcodeCanvas.height = bestBarcodeCanvas.height;
|
|
892
|
+
ctx.drawImage(bestBarcodeCanvas, 0, 0);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
initialCaptureBarcodeDetails = bestBarcodeDetails
|
|
896
|
+
? { ...bestBarcodeDetails }
|
|
897
|
+
: null;
|
|
898
|
+
// Reset recapture tracking
|
|
899
|
+
recaptureBarcodeScore = 0;
|
|
900
|
+
recaptureBarcodeDetails = null;
|
|
901
|
+
// Enter recapture phase
|
|
902
|
+
isRecapturePhase = true;
|
|
903
|
+
}
|
|
904
|
+
// (:1122-1127)
|
|
905
|
+
function endBarcodeRecapturePhase() {
|
|
906
|
+
log(`[IdCaptureModelsProvider] Ending barcode recapture phase. isRecapturePhase was: ${isRecapturePhase}`);
|
|
907
|
+
isRecapturePhase = false;
|
|
908
|
+
}
|
|
909
|
+
// (:1129-1139)
|
|
910
|
+
function getInitialCaptureBestBarcode() {
|
|
911
|
+
if (!initialCaptureBarcodeDetails || !initialCaptureBarcodeCanvas)
|
|
912
|
+
return null;
|
|
913
|
+
return {
|
|
914
|
+
...initialCaptureBarcodeDetails,
|
|
915
|
+
canvas: initialCaptureBarcodeCanvas,
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
// (:1141-1148)
|
|
919
|
+
function getRecaptureBestBarcode() {
|
|
920
|
+
if (!recaptureBarcodeDetails || !recaptureBarcodeCanvas)
|
|
921
|
+
return null;
|
|
922
|
+
return {
|
|
923
|
+
...recaptureBarcodeDetails,
|
|
924
|
+
canvas: recaptureBarcodeCanvas,
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
// (:1150-1154)
|
|
928
|
+
function resetAggressiveDecode() {
|
|
929
|
+
aggressiveDecodeComplete = false;
|
|
930
|
+
lastAggressiveDecodeAttempt = { score: 0, time: 0 };
|
|
931
|
+
captureGeneration += 1;
|
|
932
|
+
}
|
|
933
|
+
// (:1156-1177). sdk2's setCanvasKey(n => n + 1) remounts the five provider
|
|
934
|
+
// canvases and clearDocumentDetectionLastPredictionCanvas remounts the
|
|
935
|
+
// loop's frame canvas (DocumentDetectionModelProvider.tsx:222-225); a
|
|
936
|
+
// remount is a brand-new element, so the port recreates each via
|
|
937
|
+
// deps.createCanvas.
|
|
938
|
+
function resetBestFrame() {
|
|
939
|
+
// During recapture phase, preserve all canvas state to avoid race conditions
|
|
940
|
+
// that could result in black/empty barcode images on slow devices
|
|
941
|
+
if (isRecapturePhase) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
stopDetection += 1;
|
|
945
|
+
captureGeneration += 1;
|
|
946
|
+
// clearDocumentDetectionLastPredictionCanvas (:1166): bumps the loop's
|
|
947
|
+
// stop counter (folded into stopDetection above) and remounts the frame
|
|
948
|
+
// canvas.
|
|
949
|
+
lastPredictionCanvas = deps.createCanvas();
|
|
950
|
+
bestFrameDetails = null;
|
|
951
|
+
bestFocusScore = 0;
|
|
952
|
+
bestBarcodeScore = 0;
|
|
953
|
+
bestBarcodeDetails = null;
|
|
954
|
+
// setCanvasKey remount (:1172 -> :1311-1323)
|
|
955
|
+
bestPredictionCanvas = deps.createCanvas();
|
|
956
|
+
bestBarcodeCanvas = deps.createCanvas();
|
|
957
|
+
croppedDocumentCanvas = deps.createCanvas();
|
|
958
|
+
initialCaptureBarcodeCanvas = deps.createCanvas();
|
|
959
|
+
recaptureBarcodeCanvas = deps.createCanvas();
|
|
960
|
+
initialCaptureBarcodeDetails = null;
|
|
961
|
+
recaptureBarcodeScore = 0;
|
|
962
|
+
recaptureBarcodeDetails = null;
|
|
963
|
+
}
|
|
964
|
+
// setRequiredDocumentType triggered resetBestFrame via an effect in sdk2
|
|
965
|
+
// (:1179-1181); requiredDocumentType is always truthy there, so the port
|
|
966
|
+
// resets unconditionally on set.
|
|
967
|
+
function setRequiredDocumentType(value) {
|
|
968
|
+
requiredDocumentType = value;
|
|
969
|
+
resetBestFrame();
|
|
970
|
+
}
|
|
971
|
+
// (:559-576)
|
|
972
|
+
function setThresholds(thresholds) {
|
|
973
|
+
if (thresholds.detection) {
|
|
974
|
+
documentDetectionThresholds = thresholds.detection;
|
|
975
|
+
}
|
|
976
|
+
if (thresholds.focus) {
|
|
977
|
+
focusThresholds = thresholds.focus;
|
|
978
|
+
}
|
|
979
|
+
if (thresholds.barcodeReadability) {
|
|
980
|
+
barcodeReadabilityThresholds = thresholds.barcodeReadability;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
function setBoundaries(boundaries) {
|
|
984
|
+
documentDetectionBoundaries = boundaries;
|
|
985
|
+
}
|
|
986
|
+
return {
|
|
987
|
+
load,
|
|
988
|
+
start: () => frameLoop.start(),
|
|
989
|
+
stop: () => frameLoop.stop(),
|
|
990
|
+
close() {
|
|
991
|
+
frameLoop.stop();
|
|
992
|
+
// Invalidate any in-flight frame handling / pending decodes...
|
|
993
|
+
stopDetection += 1;
|
|
994
|
+
captureGeneration += 1;
|
|
995
|
+
// ...and tear down the model providers. Each lifecycle's cancel()
|
|
996
|
+
// runs its onCleanup (closeDocumentDetector / closeFocusModel /
|
|
997
|
+
// closeBarcodeReadabilityModel), mirroring the hooks' effect cleanup
|
|
998
|
+
// (e.g. sdk2/src/lib/models/DocumentDetection.ts:291-297).
|
|
999
|
+
for (const handle of lifecycleHandles)
|
|
1000
|
+
handle.cancel();
|
|
1001
|
+
onPredictionHandler = undefined;
|
|
1002
|
+
},
|
|
1003
|
+
// (:1045-1050)
|
|
1004
|
+
onPredictionMade(handler) {
|
|
1005
|
+
onPredictionHandler = handler;
|
|
1006
|
+
},
|
|
1007
|
+
getBestFrame,
|
|
1008
|
+
resetBestFrame,
|
|
1009
|
+
getBestBarcode,
|
|
1010
|
+
resetBestBarcode,
|
|
1011
|
+
startBarcodeRecapturePhase,
|
|
1012
|
+
endBarcodeRecapturePhase,
|
|
1013
|
+
getInitialCaptureBestBarcode,
|
|
1014
|
+
getRecaptureBestBarcode,
|
|
1015
|
+
setRequiredDocumentType,
|
|
1016
|
+
setThresholds,
|
|
1017
|
+
setBoundaries,
|
|
1018
|
+
resetAggressiveDecode,
|
|
1019
|
+
// Live prediction timings, matching the context fields detectionTime /
|
|
1020
|
+
// focusPredictionTime / barcodeReadabilityPredictionTime (:1262-1264) —
|
|
1021
|
+
// read from the same live module bindings the providers exposed.
|
|
1022
|
+
timings: () => ({
|
|
1023
|
+
detectionTime: lastDetectionTime,
|
|
1024
|
+
focusPredictionTime: lastFocusPredictionTime,
|
|
1025
|
+
barcodeReadabilityPredictionTime: lastBarcodeReadabilityPredictionTime,
|
|
1026
|
+
}),
|
|
1027
|
+
};
|
|
1028
|
+
}
|