idmission-web-sdk 2.1.85 → 2.1.87
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/dist/components/id_capture/DocumentDetectionModelProvider.d.ts +2 -1
- package/dist/lib/models/FrameLoop.d.ts +1 -1
- package/dist/sdk2.cjs.development.js +63 -43
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.cjs.production.js.map +1 -1
- package/dist/sdk2.esm.js +63 -43
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +63 -43
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
-
var webSdkVersion = '2.1.
|
|
218
|
+
var webSdkVersion = '2.1.87';
|
|
219
219
|
|
|
220
220
|
function getPlatform() {
|
|
221
221
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -11556,6 +11556,7 @@
|
|
|
11556
11556
|
lastDetectionTime = time - lastDetectionAt;
|
|
11557
11557
|
lastDetectionAt = time;
|
|
11558
11558
|
}
|
|
11559
|
+
var framesNeededSamples = [];
|
|
11559
11560
|
var defaultDocumentDetectionBoundaries = {
|
|
11560
11561
|
top: 20,
|
|
11561
11562
|
bottom: 20,
|
|
@@ -11639,11 +11640,16 @@
|
|
|
11639
11640
|
docWidth = _p[0],
|
|
11640
11641
|
docHeight = _p[1];
|
|
11641
11642
|
documentTooClose = docWidth > 0.85 || docHeight > 0.85;
|
|
11642
|
-
if (detectionThresholdMet) {
|
|
11643
|
+
if (detectionThresholdMet && documentInBounds && !documentTooClose) {
|
|
11643
11644
|
var threshold_1 = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11645
|
+
framesNeededSamples.unshift(1000 / lastDetectionTime);
|
|
11646
|
+
framesNeededSamples = framesNeededSamples.slice(0, 10);
|
|
11647
|
+
var framesNeeded = Math.ceil(average(framesNeededSamples));
|
|
11648
|
+
lastNBoxes.unshift(bestDocument.box);
|
|
11649
|
+
lastNBoxes = lastNBoxes.slice(0, framesNeeded);
|
|
11650
|
+
var numFramesToConsider = Math.min(framesNeeded, 12);
|
|
11651
|
+
var framesToConsider = lastNBoxes.slice(0, numFramesToConsider);
|
|
11652
|
+
documentIsStable = lastNBoxes.length >= framesNeeded - 1 && !createPairs(framesToConsider).some(function (_a) {
|
|
11647
11653
|
var a = _a[0],
|
|
11648
11654
|
b = _a[1];
|
|
11649
11655
|
return calculateIoU(a, b) < threshold_1;
|
|
@@ -11706,6 +11712,12 @@
|
|
|
11706
11712
|
if (unionArea === 0) return 0;
|
|
11707
11713
|
return intersectionArea / unionArea;
|
|
11708
11714
|
}
|
|
11715
|
+
function average(arr) {
|
|
11716
|
+
var len = arr.length;
|
|
11717
|
+
var sum = 0;
|
|
11718
|
+
for (var i = 0; i < len; i++) sum += arr[i];
|
|
11719
|
+
return sum / len;
|
|
11720
|
+
}
|
|
11709
11721
|
|
|
11710
11722
|
function useFrameLoop(fn, _a) {
|
|
11711
11723
|
var _b = _a.throttleMs,
|
|
@@ -11715,6 +11727,7 @@
|
|
|
11715
11727
|
var _d = React.useState(false),
|
|
11716
11728
|
running = _d[0],
|
|
11717
11729
|
setRunning = _d[1];
|
|
11730
|
+
var startedAtRef = React.useRef(null);
|
|
11718
11731
|
var loopId = React.useRef(0);
|
|
11719
11732
|
var frameId = React.useRef(0);
|
|
11720
11733
|
React.useEffect(function runFrameLoop() {
|
|
@@ -11723,15 +11736,17 @@
|
|
|
11723
11736
|
var currentLoopId = loopId.current;
|
|
11724
11737
|
function renderPrediction() {
|
|
11725
11738
|
return __awaiter(this, void 0, void 0, function () {
|
|
11726
|
-
var start, took, amountToThrottle;
|
|
11727
|
-
|
|
11728
|
-
|
|
11739
|
+
var start, timeRunning, took, amountToThrottle;
|
|
11740
|
+
var _a, _b;
|
|
11741
|
+
return __generator(this, function (_c) {
|
|
11742
|
+
switch (_c.label) {
|
|
11729
11743
|
case 0:
|
|
11730
11744
|
if (currentLoopId !== loopId.current) return [2 /*return*/];
|
|
11731
11745
|
start = new Date().getTime();
|
|
11732
|
-
|
|
11746
|
+
timeRunning = start - ((_b = (_a = startedAtRef.current) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0);
|
|
11747
|
+
return [4 /*yield*/, fn(frameId.current, timeRunning)];
|
|
11733
11748
|
case 1:
|
|
11734
|
-
|
|
11749
|
+
_c.sent();
|
|
11735
11750
|
took = new Date().getTime() - start;
|
|
11736
11751
|
amountToThrottle = Math.max((throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0) - took, 0);
|
|
11737
11752
|
timer = setTimeout(function () {
|
|
@@ -11750,11 +11765,13 @@
|
|
|
11750
11765
|
};
|
|
11751
11766
|
}, [fn, running, throttleMs]);
|
|
11752
11767
|
var start = React.useCallback(function () {
|
|
11768
|
+
startedAtRef.current = new Date();
|
|
11753
11769
|
setRunning(true);
|
|
11754
11770
|
}, []);
|
|
11755
11771
|
var stop = React.useCallback(function () {
|
|
11756
11772
|
loopId.current += 1; // force the loop to stop immediately.
|
|
11757
11773
|
setRunning(false);
|
|
11774
|
+
startedAtRef.current = null;
|
|
11758
11775
|
}, []);
|
|
11759
11776
|
React.useEffect(function startAutomatically() {
|
|
11760
11777
|
if (autoStart) start();
|
|
@@ -11804,44 +11821,46 @@
|
|
|
11804
11821
|
children = _a.children,
|
|
11805
11822
|
_c = _a.throttleMs,
|
|
11806
11823
|
throttleMs = _c === void 0 ? 16 : _c,
|
|
11807
|
-
_d = _a.
|
|
11808
|
-
|
|
11809
|
-
_e = _a.
|
|
11810
|
-
|
|
11811
|
-
_f = _a.
|
|
11812
|
-
|
|
11824
|
+
_d = _a.delayAfterStartMs,
|
|
11825
|
+
delayAfterStartMs = _d === void 0 ? 0 : _d,
|
|
11826
|
+
_e = _a.documentDetectionModelPath,
|
|
11827
|
+
documentDetectionModelPath = _e === void 0 ? defaultDocumentDetectorModelPath : _e,
|
|
11828
|
+
_f = _a.documentDetectionModelScoreThreshold,
|
|
11829
|
+
documentDetectionModelScoreThreshold = _f === void 0 ? defaultDocumentDetectionScoreThreshold : _f,
|
|
11830
|
+
_g = _a.documentDetectionModelLoadTimeoutMs,
|
|
11831
|
+
documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
|
|
11813
11832
|
onDocumentDetectionModelError = _a.onDocumentDetectionModelError;
|
|
11814
|
-
var
|
|
11815
|
-
videoRef =
|
|
11816
|
-
videoLoaded =
|
|
11817
|
-
cameraReady =
|
|
11833
|
+
var _h = React.useContext(CameraStateContext),
|
|
11834
|
+
videoRef = _h.videoRef,
|
|
11835
|
+
videoLoaded = _h.videoLoaded,
|
|
11836
|
+
cameraReady = _h.cameraReady;
|
|
11818
11837
|
var lastPredictionCanvas = React.useRef(null);
|
|
11819
11838
|
var onPredictionHandler = React.useRef();
|
|
11820
|
-
var
|
|
11821
|
-
documentDetectionThresholds =
|
|
11822
|
-
setDocumentDetectionThresholds =
|
|
11823
|
-
var
|
|
11824
|
-
documentDetectionBoundaries =
|
|
11825
|
-
setDocumentDetectionBoundaries =
|
|
11826
|
-
var _k = React.useState(0),
|
|
11827
|
-
timesAllZero = _k[0],
|
|
11828
|
-
setTimesAllZero = _k[1];
|
|
11839
|
+
var _j = React.useState({}),
|
|
11840
|
+
documentDetectionThresholds = _j[0],
|
|
11841
|
+
setDocumentDetectionThresholds = _j[1];
|
|
11842
|
+
var _k = React.useState(defaultDocumentDetectionBoundaries),
|
|
11843
|
+
documentDetectionBoundaries = _k[0],
|
|
11844
|
+
setDocumentDetectionBoundaries = _k[1];
|
|
11829
11845
|
var _l = React.useState(0),
|
|
11830
|
-
|
|
11831
|
-
|
|
11846
|
+
timesAllZero = _l[0],
|
|
11847
|
+
setTimesAllZero = _l[1];
|
|
11848
|
+
var _m = React.useState(0),
|
|
11849
|
+
canvasKey = _m[0],
|
|
11850
|
+
setCanvasKey = _m[1];
|
|
11832
11851
|
var stopDetection = React.useRef(0);
|
|
11833
|
-
var
|
|
11852
|
+
var _o = useLoadDocumentDetector({
|
|
11834
11853
|
modelPath: documentDetectionModelPath,
|
|
11835
11854
|
modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
|
|
11836
11855
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
11837
11856
|
onModelError: onDocumentDetectionModelError
|
|
11838
11857
|
}),
|
|
11839
|
-
detector =
|
|
11840
|
-
ready =
|
|
11841
|
-
modelDownloadProgress =
|
|
11842
|
-
modelError =
|
|
11843
|
-
setModelError =
|
|
11844
|
-
var
|
|
11858
|
+
detector = _o.detector,
|
|
11859
|
+
ready = _o.ready,
|
|
11860
|
+
modelDownloadProgress = _o.modelDownloadProgress,
|
|
11861
|
+
modelError = _o.modelError,
|
|
11862
|
+
setModelError = _o.setModelError;
|
|
11863
|
+
var _p = useFrameLoop(React.useCallback(function (frameId, timeRunning) {
|
|
11845
11864
|
return __awaiter(_this, void 0, void 0, function () {
|
|
11846
11865
|
var stopDetectionAtStart, vw, vh, ctx, prediction, processedPrediction;
|
|
11847
11866
|
var _a;
|
|
@@ -11870,6 +11889,7 @@
|
|
|
11870
11889
|
return n + 1;
|
|
11871
11890
|
});
|
|
11872
11891
|
if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
|
|
11892
|
+
if (timeRunning < delayAfterStartMs) return [2 /*return*/];
|
|
11873
11893
|
return [4 /*yield*/, (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, processedPrediction)];
|
|
11874
11894
|
case 2:
|
|
11875
11895
|
_b.sent();
|
|
@@ -11879,12 +11899,12 @@
|
|
|
11879
11899
|
}
|
|
11880
11900
|
});
|
|
11881
11901
|
});
|
|
11882
|
-
}, [cameraReady, detector, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
|
|
11902
|
+
}, [cameraReady, delayAfterStartMs, detector, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
|
|
11883
11903
|
throttleMs: throttleMs,
|
|
11884
11904
|
autoStart: autoStart
|
|
11885
11905
|
}),
|
|
11886
|
-
start =
|
|
11887
|
-
stop =
|
|
11906
|
+
start = _p.start,
|
|
11907
|
+
stop = _p.stop;
|
|
11888
11908
|
React.useEffect(function setErrorIfAllZero() {
|
|
11889
11909
|
if (timesAllZero >= 2) {
|
|
11890
11910
|
setModelError(new Error('model is returning all zeroes'));
|
|
@@ -17399,7 +17419,7 @@
|
|
|
17399
17419
|
height: 573
|
|
17400
17420
|
},
|
|
17401
17421
|
SHOW_PASSPORT: {
|
|
17402
|
-
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Portrait-
|
|
17422
|
+
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Portrait-2.svg"),
|
|
17403
17423
|
width: 386,
|
|
17404
17424
|
height: 573
|
|
17405
17425
|
}
|
|
@@ -17416,7 +17436,7 @@
|
|
|
17416
17436
|
height: 386
|
|
17417
17437
|
},
|
|
17418
17438
|
SHOW_PASSPORT: {
|
|
17419
|
-
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Landscape-
|
|
17439
|
+
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Landscape-2.svg"),
|
|
17420
17440
|
width: 573,
|
|
17421
17441
|
height: 386
|
|
17422
17442
|
}
|