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
|
@@ -22,10 +22,11 @@ export type DocumentDetectionModelProviderProps = {
|
|
|
22
22
|
autoStart?: boolean;
|
|
23
23
|
children: ReactNode;
|
|
24
24
|
throttleMs?: number;
|
|
25
|
+
delayAfterStartMs?: number;
|
|
25
26
|
documentDetectionModelPath?: string;
|
|
26
27
|
documentDetectionModelScoreThreshold?: number;
|
|
27
28
|
documentDetectionModelLoadTimeoutMs?: number;
|
|
28
29
|
onDocumentDetectionModelError?: (error: Error) => void;
|
|
29
30
|
};
|
|
30
|
-
export declare function DocumentDetectionModelProvider({ autoStart, children, throttleMs, documentDetectionModelPath, documentDetectionModelScoreThreshold, documentDetectionModelLoadTimeoutMs, onDocumentDetectionModelError, }: DocumentDetectionModelProviderProps): ReactElement;
|
|
31
|
+
export declare function DocumentDetectionModelProvider({ autoStart, children, throttleMs, delayAfterStartMs, documentDetectionModelPath, documentDetectionModelScoreThreshold, documentDetectionModelLoadTimeoutMs, onDocumentDetectionModelError, }: DocumentDetectionModelProviderProps): ReactElement;
|
|
31
32
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function useFrameLoop(fn: (frameId: number) => Promise<void>, { throttleMs, autoStart }: {
|
|
1
|
+
export declare function useFrameLoop(fn: (frameId: number, timeRunning: number) => Promise<void>, { throttleMs, autoStart }: {
|
|
2
2
|
throttleMs?: number | undefined;
|
|
3
3
|
autoStart?: boolean | undefined;
|
|
4
4
|
}): {
|
|
@@ -234,7 +234,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
234
234
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
235
235
|
};
|
|
236
236
|
|
|
237
|
-
var webSdkVersion = '2.1.
|
|
237
|
+
var webSdkVersion = '2.1.87';
|
|
238
238
|
|
|
239
239
|
function getPlatform() {
|
|
240
240
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -5595,6 +5595,7 @@ function setLastDetectionAt(time) {
|
|
|
5595
5595
|
lastDetectionTime = time - lastDetectionAt;
|
|
5596
5596
|
lastDetectionAt = time;
|
|
5597
5597
|
}
|
|
5598
|
+
var framesNeededSamples = [];
|
|
5598
5599
|
var defaultDocumentDetectionBoundaries = {
|
|
5599
5600
|
top: 20,
|
|
5600
5601
|
bottom: 20,
|
|
@@ -5678,11 +5679,16 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
|
|
|
5678
5679
|
docWidth = _p[0],
|
|
5679
5680
|
docHeight = _p[1];
|
|
5680
5681
|
documentTooClose = docWidth > 0.85 || docHeight > 0.85;
|
|
5681
|
-
if (detectionThresholdMet) {
|
|
5682
|
+
if (detectionThresholdMet && documentInBounds && !documentTooClose) {
|
|
5682
5683
|
var threshold_1 = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5684
|
+
framesNeededSamples.unshift(1000 / lastDetectionTime);
|
|
5685
|
+
framesNeededSamples = framesNeededSamples.slice(0, 10);
|
|
5686
|
+
var framesNeeded = Math.ceil(average(framesNeededSamples));
|
|
5687
|
+
lastNBoxes.unshift(bestDocument.box);
|
|
5688
|
+
lastNBoxes = lastNBoxes.slice(0, framesNeeded);
|
|
5689
|
+
var numFramesToConsider = Math.min(framesNeeded, 12);
|
|
5690
|
+
var framesToConsider = lastNBoxes.slice(0, numFramesToConsider);
|
|
5691
|
+
documentIsStable = lastNBoxes.length >= framesNeeded - 1 && !createPairs(framesToConsider).some(function (_a) {
|
|
5686
5692
|
var a = _a[0],
|
|
5687
5693
|
b = _a[1];
|
|
5688
5694
|
return calculateIoU(a, b) < threshold_1;
|
|
@@ -5745,6 +5751,12 @@ function calculateIoU(boxA, boxB) {
|
|
|
5745
5751
|
if (unionArea === 0) return 0;
|
|
5746
5752
|
return intersectionArea / unionArea;
|
|
5747
5753
|
}
|
|
5754
|
+
function average(arr) {
|
|
5755
|
+
var len = arr.length;
|
|
5756
|
+
var sum = 0;
|
|
5757
|
+
for (var i = 0; i < len; i++) sum += arr[i];
|
|
5758
|
+
return sum / len;
|
|
5759
|
+
}
|
|
5748
5760
|
|
|
5749
5761
|
function useFrameLoop(fn, _a) {
|
|
5750
5762
|
var _b = _a.throttleMs,
|
|
@@ -5754,6 +5766,7 @@ function useFrameLoop(fn, _a) {
|
|
|
5754
5766
|
var _d = React.useState(false),
|
|
5755
5767
|
running = _d[0],
|
|
5756
5768
|
setRunning = _d[1];
|
|
5769
|
+
var startedAtRef = React.useRef(null);
|
|
5757
5770
|
var loopId = React.useRef(0);
|
|
5758
5771
|
var frameId = React.useRef(0);
|
|
5759
5772
|
React.useEffect(function runFrameLoop() {
|
|
@@ -5762,15 +5775,17 @@ function useFrameLoop(fn, _a) {
|
|
|
5762
5775
|
var currentLoopId = loopId.current;
|
|
5763
5776
|
function renderPrediction() {
|
|
5764
5777
|
return __awaiter(this, void 0, void 0, function () {
|
|
5765
|
-
var start, took, amountToThrottle;
|
|
5766
|
-
|
|
5767
|
-
|
|
5778
|
+
var start, timeRunning, took, amountToThrottle;
|
|
5779
|
+
var _a, _b;
|
|
5780
|
+
return __generator(this, function (_c) {
|
|
5781
|
+
switch (_c.label) {
|
|
5768
5782
|
case 0:
|
|
5769
5783
|
if (currentLoopId !== loopId.current) return [2 /*return*/];
|
|
5770
5784
|
start = new Date().getTime();
|
|
5771
|
-
|
|
5785
|
+
timeRunning = start - ((_b = (_a = startedAtRef.current) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0);
|
|
5786
|
+
return [4 /*yield*/, fn(frameId.current, timeRunning)];
|
|
5772
5787
|
case 1:
|
|
5773
|
-
|
|
5788
|
+
_c.sent();
|
|
5774
5789
|
took = new Date().getTime() - start;
|
|
5775
5790
|
amountToThrottle = Math.max((throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0) - took, 0);
|
|
5776
5791
|
timer = setTimeout(function () {
|
|
@@ -5789,11 +5804,13 @@ function useFrameLoop(fn, _a) {
|
|
|
5789
5804
|
};
|
|
5790
5805
|
}, [fn, running, throttleMs]);
|
|
5791
5806
|
var start = React.useCallback(function () {
|
|
5807
|
+
startedAtRef.current = new Date();
|
|
5792
5808
|
setRunning(true);
|
|
5793
5809
|
}, []);
|
|
5794
5810
|
var stop = React.useCallback(function () {
|
|
5795
5811
|
loopId.current += 1; // force the loop to stop immediately.
|
|
5796
5812
|
setRunning(false);
|
|
5813
|
+
startedAtRef.current = null;
|
|
5797
5814
|
}, []);
|
|
5798
5815
|
React.useEffect(function startAutomatically() {
|
|
5799
5816
|
if (autoStart) start();
|
|
@@ -5843,44 +5860,46 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
5843
5860
|
children = _a.children,
|
|
5844
5861
|
_c = _a.throttleMs,
|
|
5845
5862
|
throttleMs = _c === void 0 ? 16 : _c,
|
|
5846
|
-
_d = _a.
|
|
5847
|
-
|
|
5848
|
-
_e = _a.
|
|
5849
|
-
|
|
5850
|
-
_f = _a.
|
|
5851
|
-
|
|
5863
|
+
_d = _a.delayAfterStartMs,
|
|
5864
|
+
delayAfterStartMs = _d === void 0 ? 0 : _d,
|
|
5865
|
+
_e = _a.documentDetectionModelPath,
|
|
5866
|
+
documentDetectionModelPath = _e === void 0 ? defaultDocumentDetectorModelPath : _e,
|
|
5867
|
+
_f = _a.documentDetectionModelScoreThreshold,
|
|
5868
|
+
documentDetectionModelScoreThreshold = _f === void 0 ? defaultDocumentDetectionScoreThreshold : _f,
|
|
5869
|
+
_g = _a.documentDetectionModelLoadTimeoutMs,
|
|
5870
|
+
documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
|
|
5852
5871
|
onDocumentDetectionModelError = _a.onDocumentDetectionModelError;
|
|
5853
|
-
var
|
|
5854
|
-
videoRef =
|
|
5855
|
-
videoLoaded =
|
|
5856
|
-
cameraReady =
|
|
5872
|
+
var _h = React.useContext(CameraStateContext),
|
|
5873
|
+
videoRef = _h.videoRef,
|
|
5874
|
+
videoLoaded = _h.videoLoaded,
|
|
5875
|
+
cameraReady = _h.cameraReady;
|
|
5857
5876
|
var lastPredictionCanvas = React.useRef(null);
|
|
5858
5877
|
var onPredictionHandler = React.useRef();
|
|
5859
|
-
var
|
|
5860
|
-
documentDetectionThresholds =
|
|
5861
|
-
setDocumentDetectionThresholds =
|
|
5862
|
-
var
|
|
5863
|
-
documentDetectionBoundaries =
|
|
5864
|
-
setDocumentDetectionBoundaries =
|
|
5865
|
-
var _k = React.useState(0),
|
|
5866
|
-
timesAllZero = _k[0],
|
|
5867
|
-
setTimesAllZero = _k[1];
|
|
5878
|
+
var _j = React.useState({}),
|
|
5879
|
+
documentDetectionThresholds = _j[0],
|
|
5880
|
+
setDocumentDetectionThresholds = _j[1];
|
|
5881
|
+
var _k = React.useState(defaultDocumentDetectionBoundaries),
|
|
5882
|
+
documentDetectionBoundaries = _k[0],
|
|
5883
|
+
setDocumentDetectionBoundaries = _k[1];
|
|
5868
5884
|
var _l = React.useState(0),
|
|
5869
|
-
|
|
5870
|
-
|
|
5885
|
+
timesAllZero = _l[0],
|
|
5886
|
+
setTimesAllZero = _l[1];
|
|
5887
|
+
var _m = React.useState(0),
|
|
5888
|
+
canvasKey = _m[0],
|
|
5889
|
+
setCanvasKey = _m[1];
|
|
5871
5890
|
var stopDetection = React.useRef(0);
|
|
5872
|
-
var
|
|
5891
|
+
var _o = useLoadDocumentDetector({
|
|
5873
5892
|
modelPath: documentDetectionModelPath,
|
|
5874
5893
|
modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
|
|
5875
5894
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
5876
5895
|
onModelError: onDocumentDetectionModelError
|
|
5877
5896
|
}),
|
|
5878
|
-
detector =
|
|
5879
|
-
ready =
|
|
5880
|
-
modelDownloadProgress =
|
|
5881
|
-
modelError =
|
|
5882
|
-
setModelError =
|
|
5883
|
-
var
|
|
5897
|
+
detector = _o.detector,
|
|
5898
|
+
ready = _o.ready,
|
|
5899
|
+
modelDownloadProgress = _o.modelDownloadProgress,
|
|
5900
|
+
modelError = _o.modelError,
|
|
5901
|
+
setModelError = _o.setModelError;
|
|
5902
|
+
var _p = useFrameLoop(React.useCallback(function (frameId, timeRunning) {
|
|
5884
5903
|
return __awaiter(_this, void 0, void 0, function () {
|
|
5885
5904
|
var stopDetectionAtStart, vw, vh, ctx, prediction, processedPrediction;
|
|
5886
5905
|
var _a;
|
|
@@ -5909,6 +5928,7 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
5909
5928
|
return n + 1;
|
|
5910
5929
|
});
|
|
5911
5930
|
if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
|
|
5931
|
+
if (timeRunning < delayAfterStartMs) return [2 /*return*/];
|
|
5912
5932
|
return [4 /*yield*/, (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, processedPrediction)];
|
|
5913
5933
|
case 2:
|
|
5914
5934
|
_b.sent();
|
|
@@ -5918,12 +5938,12 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
5918
5938
|
}
|
|
5919
5939
|
});
|
|
5920
5940
|
});
|
|
5921
|
-
}, [cameraReady, detector, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
|
|
5941
|
+
}, [cameraReady, delayAfterStartMs, detector, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
|
|
5922
5942
|
throttleMs: throttleMs,
|
|
5923
5943
|
autoStart: autoStart
|
|
5924
5944
|
}),
|
|
5925
|
-
start =
|
|
5926
|
-
stop =
|
|
5945
|
+
start = _p.start,
|
|
5946
|
+
stop = _p.stop;
|
|
5927
5947
|
React.useEffect(function setErrorIfAllZero() {
|
|
5928
5948
|
if (timesAllZero >= 2) {
|
|
5929
5949
|
setModelError(new Error('model is returning all zeroes'));
|
|
@@ -8565,7 +8585,7 @@ var defaultIdCaptureGuideImages = {
|
|
|
8565
8585
|
height: 573
|
|
8566
8586
|
},
|
|
8567
8587
|
SHOW_PASSPORT: {
|
|
8568
|
-
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Portrait-
|
|
8588
|
+
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Portrait-2.svg"),
|
|
8569
8589
|
width: 386,
|
|
8570
8590
|
height: 573
|
|
8571
8591
|
}
|
|
@@ -8582,7 +8602,7 @@ var defaultIdCaptureGuideImages = {
|
|
|
8582
8602
|
height: 386
|
|
8583
8603
|
},
|
|
8584
8604
|
SHOW_PASSPORT: {
|
|
8585
|
-
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Landscape-
|
|
8605
|
+
url: "".concat(DEFAULT_CDN_URL, "/Shieldout-Passport-Front-SVG-Landscape-2.svg"),
|
|
8586
8606
|
width: 573,
|
|
8587
8607
|
height: 386
|
|
8588
8608
|
}
|