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
package/dist/sdk2.esm.js
CHANGED
|
@@ -204,7 +204,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
204
204
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
var webSdkVersion = '2.1.
|
|
207
|
+
var webSdkVersion = '2.1.87';
|
|
208
208
|
|
|
209
209
|
function getPlatform() {
|
|
210
210
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -5565,6 +5565,7 @@ function setLastDetectionAt(time) {
|
|
|
5565
5565
|
lastDetectionTime = time - lastDetectionAt;
|
|
5566
5566
|
lastDetectionAt = time;
|
|
5567
5567
|
}
|
|
5568
|
+
var framesNeededSamples = [];
|
|
5568
5569
|
var defaultDocumentDetectionBoundaries = {
|
|
5569
5570
|
top: 20,
|
|
5570
5571
|
bottom: 20,
|
|
@@ -5648,11 +5649,16 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
|
|
|
5648
5649
|
docWidth = _p[0],
|
|
5649
5650
|
docHeight = _p[1];
|
|
5650
5651
|
documentTooClose = docWidth > 0.85 || docHeight > 0.85;
|
|
5651
|
-
if (detectionThresholdMet) {
|
|
5652
|
+
if (detectionThresholdMet && documentInBounds && !documentTooClose) {
|
|
5652
5653
|
var threshold_1 = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5654
|
+
framesNeededSamples.unshift(1000 / lastDetectionTime);
|
|
5655
|
+
framesNeededSamples = framesNeededSamples.slice(0, 10);
|
|
5656
|
+
var framesNeeded = Math.ceil(average(framesNeededSamples));
|
|
5657
|
+
lastNBoxes.unshift(bestDocument.box);
|
|
5658
|
+
lastNBoxes = lastNBoxes.slice(0, framesNeeded);
|
|
5659
|
+
var numFramesToConsider = Math.min(framesNeeded, 12);
|
|
5660
|
+
var framesToConsider = lastNBoxes.slice(0, numFramesToConsider);
|
|
5661
|
+
documentIsStable = lastNBoxes.length >= framesNeeded - 1 && !createPairs(framesToConsider).some(function (_a) {
|
|
5656
5662
|
var a = _a[0],
|
|
5657
5663
|
b = _a[1];
|
|
5658
5664
|
return calculateIoU(a, b) < threshold_1;
|
|
@@ -5715,6 +5721,12 @@ function calculateIoU(boxA, boxB) {
|
|
|
5715
5721
|
if (unionArea === 0) return 0;
|
|
5716
5722
|
return intersectionArea / unionArea;
|
|
5717
5723
|
}
|
|
5724
|
+
function average(arr) {
|
|
5725
|
+
var len = arr.length;
|
|
5726
|
+
var sum = 0;
|
|
5727
|
+
for (var i = 0; i < len; i++) sum += arr[i];
|
|
5728
|
+
return sum / len;
|
|
5729
|
+
}
|
|
5718
5730
|
|
|
5719
5731
|
function useFrameLoop(fn, _a) {
|
|
5720
5732
|
var _b = _a.throttleMs,
|
|
@@ -5724,6 +5736,7 @@ function useFrameLoop(fn, _a) {
|
|
|
5724
5736
|
var _d = useState(false),
|
|
5725
5737
|
running = _d[0],
|
|
5726
5738
|
setRunning = _d[1];
|
|
5739
|
+
var startedAtRef = useRef(null);
|
|
5727
5740
|
var loopId = useRef(0);
|
|
5728
5741
|
var frameId = useRef(0);
|
|
5729
5742
|
useEffect(function runFrameLoop() {
|
|
@@ -5732,15 +5745,17 @@ function useFrameLoop(fn, _a) {
|
|
|
5732
5745
|
var currentLoopId = loopId.current;
|
|
5733
5746
|
function renderPrediction() {
|
|
5734
5747
|
return __awaiter(this, void 0, void 0, function () {
|
|
5735
|
-
var start, took, amountToThrottle;
|
|
5736
|
-
|
|
5737
|
-
|
|
5748
|
+
var start, timeRunning, took, amountToThrottle;
|
|
5749
|
+
var _a, _b;
|
|
5750
|
+
return __generator(this, function (_c) {
|
|
5751
|
+
switch (_c.label) {
|
|
5738
5752
|
case 0:
|
|
5739
5753
|
if (currentLoopId !== loopId.current) return [2 /*return*/];
|
|
5740
5754
|
start = new Date().getTime();
|
|
5741
|
-
|
|
5755
|
+
timeRunning = start - ((_b = (_a = startedAtRef.current) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0);
|
|
5756
|
+
return [4 /*yield*/, fn(frameId.current, timeRunning)];
|
|
5742
5757
|
case 1:
|
|
5743
|
-
|
|
5758
|
+
_c.sent();
|
|
5744
5759
|
took = new Date().getTime() - start;
|
|
5745
5760
|
amountToThrottle = Math.max((throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0) - took, 0);
|
|
5746
5761
|
timer = setTimeout(function () {
|
|
@@ -5759,11 +5774,13 @@ function useFrameLoop(fn, _a) {
|
|
|
5759
5774
|
};
|
|
5760
5775
|
}, [fn, running, throttleMs]);
|
|
5761
5776
|
var start = useCallback(function () {
|
|
5777
|
+
startedAtRef.current = new Date();
|
|
5762
5778
|
setRunning(true);
|
|
5763
5779
|
}, []);
|
|
5764
5780
|
var stop = useCallback(function () {
|
|
5765
5781
|
loopId.current += 1; // force the loop to stop immediately.
|
|
5766
5782
|
setRunning(false);
|
|
5783
|
+
startedAtRef.current = null;
|
|
5767
5784
|
}, []);
|
|
5768
5785
|
useEffect(function startAutomatically() {
|
|
5769
5786
|
if (autoStart) start();
|
|
@@ -5813,44 +5830,46 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
5813
5830
|
children = _a.children,
|
|
5814
5831
|
_c = _a.throttleMs,
|
|
5815
5832
|
throttleMs = _c === void 0 ? 16 : _c,
|
|
5816
|
-
_d = _a.
|
|
5817
|
-
|
|
5818
|
-
_e = _a.
|
|
5819
|
-
|
|
5820
|
-
_f = _a.
|
|
5821
|
-
|
|
5833
|
+
_d = _a.delayAfterStartMs,
|
|
5834
|
+
delayAfterStartMs = _d === void 0 ? 0 : _d,
|
|
5835
|
+
_e = _a.documentDetectionModelPath,
|
|
5836
|
+
documentDetectionModelPath = _e === void 0 ? defaultDocumentDetectorModelPath : _e,
|
|
5837
|
+
_f = _a.documentDetectionModelScoreThreshold,
|
|
5838
|
+
documentDetectionModelScoreThreshold = _f === void 0 ? defaultDocumentDetectionScoreThreshold : _f,
|
|
5839
|
+
_g = _a.documentDetectionModelLoadTimeoutMs,
|
|
5840
|
+
documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
|
|
5822
5841
|
onDocumentDetectionModelError = _a.onDocumentDetectionModelError;
|
|
5823
|
-
var
|
|
5824
|
-
videoRef =
|
|
5825
|
-
videoLoaded =
|
|
5826
|
-
cameraReady =
|
|
5842
|
+
var _h = useContext(CameraStateContext),
|
|
5843
|
+
videoRef = _h.videoRef,
|
|
5844
|
+
videoLoaded = _h.videoLoaded,
|
|
5845
|
+
cameraReady = _h.cameraReady;
|
|
5827
5846
|
var lastPredictionCanvas = useRef(null);
|
|
5828
5847
|
var onPredictionHandler = useRef();
|
|
5829
|
-
var
|
|
5830
|
-
documentDetectionThresholds =
|
|
5831
|
-
setDocumentDetectionThresholds =
|
|
5832
|
-
var
|
|
5833
|
-
documentDetectionBoundaries =
|
|
5834
|
-
setDocumentDetectionBoundaries =
|
|
5835
|
-
var _k = useState(0),
|
|
5836
|
-
timesAllZero = _k[0],
|
|
5837
|
-
setTimesAllZero = _k[1];
|
|
5848
|
+
var _j = useState({}),
|
|
5849
|
+
documentDetectionThresholds = _j[0],
|
|
5850
|
+
setDocumentDetectionThresholds = _j[1];
|
|
5851
|
+
var _k = useState(defaultDocumentDetectionBoundaries),
|
|
5852
|
+
documentDetectionBoundaries = _k[0],
|
|
5853
|
+
setDocumentDetectionBoundaries = _k[1];
|
|
5838
5854
|
var _l = useState(0),
|
|
5839
|
-
|
|
5840
|
-
|
|
5855
|
+
timesAllZero = _l[0],
|
|
5856
|
+
setTimesAllZero = _l[1];
|
|
5857
|
+
var _m = useState(0),
|
|
5858
|
+
canvasKey = _m[0],
|
|
5859
|
+
setCanvasKey = _m[1];
|
|
5841
5860
|
var stopDetection = useRef(0);
|
|
5842
|
-
var
|
|
5861
|
+
var _o = useLoadDocumentDetector({
|
|
5843
5862
|
modelPath: documentDetectionModelPath,
|
|
5844
5863
|
modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
|
|
5845
5864
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
5846
5865
|
onModelError: onDocumentDetectionModelError
|
|
5847
5866
|
}),
|
|
5848
|
-
detector =
|
|
5849
|
-
ready =
|
|
5850
|
-
modelDownloadProgress =
|
|
5851
|
-
modelError =
|
|
5852
|
-
setModelError =
|
|
5853
|
-
var
|
|
5867
|
+
detector = _o.detector,
|
|
5868
|
+
ready = _o.ready,
|
|
5869
|
+
modelDownloadProgress = _o.modelDownloadProgress,
|
|
5870
|
+
modelError = _o.modelError,
|
|
5871
|
+
setModelError = _o.setModelError;
|
|
5872
|
+
var _p = useFrameLoop(useCallback(function (frameId, timeRunning) {
|
|
5854
5873
|
return __awaiter(_this, void 0, void 0, function () {
|
|
5855
5874
|
var stopDetectionAtStart, vw, vh, ctx, prediction, processedPrediction;
|
|
5856
5875
|
var _a;
|
|
@@ -5879,6 +5898,7 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
5879
5898
|
return n + 1;
|
|
5880
5899
|
});
|
|
5881
5900
|
if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
|
|
5901
|
+
if (timeRunning < delayAfterStartMs) return [2 /*return*/];
|
|
5882
5902
|
return [4 /*yield*/, (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, processedPrediction)];
|
|
5883
5903
|
case 2:
|
|
5884
5904
|
_b.sent();
|
|
@@ -5888,12 +5908,12 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
5888
5908
|
}
|
|
5889
5909
|
});
|
|
5890
5910
|
});
|
|
5891
|
-
}, [cameraReady, detector, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
|
|
5911
|
+
}, [cameraReady, delayAfterStartMs, detector, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
|
|
5892
5912
|
throttleMs: throttleMs,
|
|
5893
5913
|
autoStart: autoStart
|
|
5894
5914
|
}),
|
|
5895
|
-
start =
|
|
5896
|
-
stop =
|
|
5915
|
+
start = _p.start,
|
|
5916
|
+
stop = _p.stop;
|
|
5897
5917
|
useEffect(function setErrorIfAllZero() {
|
|
5898
5918
|
if (timesAllZero >= 2) {
|
|
5899
5919
|
setModelError(new Error('model is returning all zeroes'));
|
|
@@ -8535,7 +8555,7 @@ var defaultIdCaptureGuideImages = {
|
|
|
8535
8555
|
height: 573
|
|
8536
8556
|
},
|
|
8537
8557
|
SHOW_PASSPORT: {
|
|
8538
|
-
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Portrait-
|
|
8558
|
+
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Portrait-2.svg"),
|
|
8539
8559
|
width: 386,
|
|
8540
8560
|
height: 573
|
|
8541
8561
|
}
|
|
@@ -8552,7 +8572,7 @@ var defaultIdCaptureGuideImages = {
|
|
|
8552
8572
|
height: 386
|
|
8553
8573
|
},
|
|
8554
8574
|
SHOW_PASSPORT: {
|
|
8555
|
-
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Landscape-
|
|
8575
|
+
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Landscape-2.svg"),
|
|
8556
8576
|
width: 573,
|
|
8557
8577
|
height: 386
|
|
8558
8578
|
}
|