idmission-web-sdk 0.0.19 → 0.0.21
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 +44 -0
- package/dist/components/common/GuidanceMessage.d.ts +264 -0
- package/dist/components/common/debug.d.ts +321 -0
- package/dist/components/common/signature.d.ts +1041 -0
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +15 -6
- package/dist/components/selfie_capture/HighPerformanceSelfieGuidanceModelsProvider.d.ts +6 -5
- package/dist/components/signature_capture/SignatureCapture.d.ts +1 -1
- package/dist/sdk2.cjs.development.js +474 -425
- 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 +475 -426
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +502 -453
- 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/package.json +1 -1
package/dist/sdk2.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter, __generator, __makeTemplateObject, __spreadArray, __assign } from 'tslib';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { createContext, forwardRef, useEffect, useContext, useRef, useState, useCallback,
|
|
4
|
+
import React__default, { createContext, forwardRef, useEffect, useContext, useRef, useState, useCallback, useMemo, useReducer } from 'react';
|
|
5
5
|
import * as Sentry from '@sentry/react';
|
|
6
6
|
import i18n from 'i18next';
|
|
7
7
|
import { useTranslation, initReactI18next } from 'react-i18next';
|
|
@@ -155,7 +155,7 @@ function contentDispositionFromDataUrl(url) {
|
|
|
155
155
|
return (_b = (_a = url.match(/^(data:.*;base64),/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
var PageContainerDiv = styled.div(templateObject_1$
|
|
158
|
+
var PageContainerDiv = styled.div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n left: 0;\n width: var(--app-width);\n height: calc(\n var(--app-height) - ", "px\n );\n overflow-x: hidden;\n overflow-y: auto;\n font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,\n Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;\n\n &.flex {\n display: flex;\n }\n\n &.padded {\n box-sizing: border-box;\n padding: 16px 24px;\n }\n"], ["\n position: fixed;\n top: 0;\n left: 0;\n width: var(--app-width);\n height: calc(\n var(--app-height) - ", "px\n );\n overflow-x: hidden;\n overflow-y: auto;\n font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,\n Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;\n\n &.flex {\n display: flex;\n }\n\n &.padded {\n box-sizing: border-box;\n padding: 16px 24px;\n }\n"])), function (_a) {
|
|
159
159
|
var $heightOffset = _a.$heightOffset;
|
|
160
160
|
return $heightOffset !== null && $heightOffset !== void 0 ? $heightOffset : 0;
|
|
161
161
|
});
|
|
@@ -187,13 +187,13 @@ var PageContainer = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
187
187
|
}, children);
|
|
188
188
|
});
|
|
189
189
|
PageContainer.displayName = 'PageContainer';
|
|
190
|
-
var templateObject_1$
|
|
190
|
+
var templateObject_1$7;
|
|
191
191
|
|
|
192
|
-
var OverlayContainer = styled(PageContainer)(templateObject_1$
|
|
193
|
-
var OverlayInner = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n text-align: center;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n padding: 25px;\n max-height: var(--app-height);\n height: 100%;\n box-sizing: border-box;\n"], ["\n text-align: center;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n padding: 25px;\n max-height: var(--app-height);\n height: 100%;\n box-sizing: border-box;\n"])));
|
|
194
|
-
var OverlayImageWrapper = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-grow: 1;\n padding-bottom: 25px;\n max-width: var(--app-width);\n max-height: var(--app-height);\n overflow: hidden;\n\n & > img {\n margin: 0 auto;\n width: max-content;\n max-width: 100%;\n max-height: 100%;\n aspect-ratio: initial;\n object-fit: contain;\n display: block;\n }\n"], ["\n position: relative;\n display: flex;\n flex-grow: 1;\n padding-bottom: 25px;\n max-width: var(--app-width);\n max-height: var(--app-height);\n overflow: hidden;\n\n & > img {\n margin: 0 auto;\n width: max-content;\n max-width: 100%;\n max-height: 100%;\n aspect-ratio: initial;\n object-fit: contain;\n display: block;\n }\n"])));
|
|
195
|
-
var OverlayImageMultiContainer = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100vh - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"], ["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100vh - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"])));
|
|
196
|
-
var templateObject_1$
|
|
192
|
+
var OverlayContainer = styled(PageContainer)(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n background: white;\n z-index: 10000;\n"], ["\n background: white;\n z-index: 10000;\n"])));
|
|
193
|
+
var OverlayInner = styled.div(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n text-align: center;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n padding: 25px;\n max-height: var(--app-height);\n height: 100%;\n box-sizing: border-box;\n"], ["\n text-align: center;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n padding: 25px;\n max-height: var(--app-height);\n height: 100%;\n box-sizing: border-box;\n"])));
|
|
194
|
+
var OverlayImageWrapper = styled.div(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-grow: 1;\n padding-bottom: 25px;\n max-width: var(--app-width);\n max-height: var(--app-height);\n overflow: hidden;\n\n & > img {\n margin: 0 auto;\n width: max-content;\n max-width: 100%;\n max-height: 100%;\n aspect-ratio: initial;\n object-fit: contain;\n display: block;\n }\n"], ["\n position: relative;\n display: flex;\n flex-grow: 1;\n padding-bottom: 25px;\n max-width: var(--app-width);\n max-height: var(--app-height);\n overflow: hidden;\n\n & > img {\n margin: 0 auto;\n width: max-content;\n max-width: 100%;\n max-height: 100%;\n aspect-ratio: initial;\n object-fit: contain;\n display: block;\n }\n"])));
|
|
195
|
+
var OverlayImageMultiContainer = styled.div(templateObject_4$2 || (templateObject_4$2 = __makeTemplateObject(["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100vh - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"], ["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100vh - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"])));
|
|
196
|
+
var templateObject_1$6, templateObject_2$3, templateObject_3$2, templateObject_4$2;
|
|
197
197
|
|
|
198
198
|
var GeolocationAccessDeniedOverlay = function GeolocationAccessDeniedOverlay(_a) {
|
|
199
199
|
var accessBlockedImageUrl = _a.accessBlockedImageUrl;
|
|
@@ -7614,16 +7614,8 @@ var IdCaptureModelsContext = /*#__PURE__*/createContext({
|
|
|
7614
7614
|
working: {
|
|
7615
7615
|
current: false
|
|
7616
7616
|
},
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
return null;
|
|
7620
|
-
},
|
|
7621
|
-
passportDetectionThreshold: 1,
|
|
7622
|
-
setPassportDetectionThreshold: function setPassportDetectionThreshold() {
|
|
7623
|
-
return null;
|
|
7624
|
-
},
|
|
7625
|
-
focusThreshold: 1,
|
|
7626
|
-
setFocusThreshold: function setFocusThreshold() {
|
|
7617
|
+
thresholds: {},
|
|
7618
|
+
setThresholds: function setThresholds() {
|
|
7627
7619
|
return null;
|
|
7628
7620
|
},
|
|
7629
7621
|
makePrediction: function makePrediction() {
|
|
@@ -7641,6 +7633,8 @@ var IdCaptureModelsContext = /*#__PURE__*/createContext({
|
|
|
7641
7633
|
return null;
|
|
7642
7634
|
}
|
|
7643
7635
|
});
|
|
7636
|
+
var defaultDocumentDetectionModelUrl = "".concat(DEFAULT_CDN_URL, "/models/documentdetection448/model.json");
|
|
7637
|
+
var defaultFocusModelUrl = "".concat(DEFAULT_CDN_URL, "/models/focus/model.json");
|
|
7644
7638
|
var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
7645
7639
|
var children = _a.children,
|
|
7646
7640
|
documentDetectionModelUrl = _a.documentDetectionModelUrl,
|
|
@@ -7648,35 +7642,39 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
7648
7642
|
var _b = useState(false),
|
|
7649
7643
|
ready = _b[0],
|
|
7650
7644
|
setReady = _b[1];
|
|
7651
|
-
var _c = useState(
|
|
7645
|
+
var _c = useState(0),
|
|
7652
7646
|
documentDetectionThreshold = _c[0],
|
|
7653
7647
|
setDocumentDetectionThreshold = _c[1];
|
|
7654
|
-
var _d = useState(
|
|
7648
|
+
var _d = useState(0),
|
|
7655
7649
|
passportDetectionThreshold = _d[0],
|
|
7656
7650
|
setPassportDetectionThreshold = _d[1];
|
|
7657
|
-
var _e = useState(
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
var working = useRef(false);
|
|
7661
|
-
var onPredictionHandler = useRef();
|
|
7662
|
-
var canvas2d = useRef(null);
|
|
7663
|
-
var canvasGl = useRef(null);
|
|
7651
|
+
var _e = useState(0),
|
|
7652
|
+
mrzDetectionThreshold = _e[0],
|
|
7653
|
+
setMrzDetectionThreshold = _e[1];
|
|
7664
7654
|
var _f = useState(0),
|
|
7665
|
-
|
|
7666
|
-
|
|
7655
|
+
pdf417DetectionThreshold = _f[0],
|
|
7656
|
+
setPdf417DetectionThreshold = _f[1];
|
|
7667
7657
|
var _g = useState(0),
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7658
|
+
focusThreshold = _g[0],
|
|
7659
|
+
setFocusThreshold = _g[1];
|
|
7660
|
+
var working = useRef(false);
|
|
7661
|
+
var onPredictionHandler = useRef();
|
|
7662
|
+
var lastPredictionCanvas = useRef(null);
|
|
7663
|
+
var _h = useState(0),
|
|
7664
|
+
detectionTime = _h[0],
|
|
7665
|
+
setDetectionTime = _h[1];
|
|
7666
|
+
var _j = useState(0),
|
|
7667
|
+
focusPredictionTime = _j[0],
|
|
7668
|
+
setFocusPredictionTime = _j[1];
|
|
7672
7669
|
useEffect(function () {
|
|
7673
|
-
(
|
|
7674
|
-
|
|
7670
|
+
setReady(false);
|
|
7671
|
+
var ddmUrl = documentDetectionModelUrl || defaultDocumentDetectionModelUrl;
|
|
7672
|
+
var fmUrl = focusModelUrl || defaultFocusModelUrl;
|
|
7673
|
+
function loadModels() {
|
|
7674
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7675
7675
|
return __generator(this, function (_a) {
|
|
7676
7676
|
switch (_a.label) {
|
|
7677
7677
|
case 0:
|
|
7678
|
-
if (!documentDetectionModelUrl || !focusModelUrl) return [2];
|
|
7679
|
-
setReady(false);
|
|
7680
7678
|
tf.ENV.set('WEBGL_DELETE_TEXTURE_THRESHOLD', 50 * 1024 * 1024);
|
|
7681
7679
|
return [4, tf.setBackend('webgl')];
|
|
7682
7680
|
case 1:
|
|
@@ -7684,54 +7682,67 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
7684
7682
|
return [4, tf.ready()];
|
|
7685
7683
|
case 2:
|
|
7686
7684
|
_a.sent();
|
|
7687
|
-
return [4, Promise.all([loadDocumentDetectionModel(
|
|
7685
|
+
return [4, Promise.all([loadDocumentDetectionModel(ddmUrl), loadFocusModel(fmUrl)])];
|
|
7688
7686
|
case 3:
|
|
7689
7687
|
_a.sent();
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
return [4, tf.ready()];
|
|
7713
|
-
case 2:
|
|
7714
|
-
_b.sent();
|
|
7715
|
-
return [4, Promise.all([loadDocumentDetectionModel(documentDetectionModelUrl), loadFocusModel(focusModelUrl)])];
|
|
7716
|
-
case 3:
|
|
7717
|
-
_b.sent();
|
|
7718
|
-
setReady(true);
|
|
7719
|
-
_b.label = 4;
|
|
7720
|
-
case 4:
|
|
7721
|
-
return [2];
|
|
7722
|
-
}
|
|
7723
|
-
});
|
|
7724
|
-
});
|
|
7725
|
-
});
|
|
7688
|
+
return [2];
|
|
7689
|
+
}
|
|
7690
|
+
});
|
|
7691
|
+
});
|
|
7692
|
+
}
|
|
7693
|
+
function reloadModels() {
|
|
7694
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7695
|
+
var ctx;
|
|
7696
|
+
return __generator(this, function (_a) {
|
|
7697
|
+
switch (_a.label) {
|
|
7698
|
+
case 0:
|
|
7699
|
+
setReady(false);
|
|
7700
|
+
unloadDocumentDetectionModel();
|
|
7701
|
+
unloadFocusModel();
|
|
7702
|
+
clearWebGLContext(2);
|
|
7703
|
+
ctx = document.createElement('canvas').getContext('webgl2');
|
|
7704
|
+
if (!(ctx && ddmUrl && fmUrl)) return [3, 2];
|
|
7705
|
+
setWebGLContext(2, ctx);
|
|
7706
|
+
disposeTfBackend();
|
|
7707
|
+
return [4, loadModels()];
|
|
7708
|
+
case 1:
|
|
7709
|
+
_a.sent();
|
|
7726
7710
|
setReady(true);
|
|
7711
|
+
_a.label = 2;
|
|
7712
|
+
case 2:
|
|
7727
7713
|
return [2];
|
|
7728
7714
|
}
|
|
7729
7715
|
});
|
|
7730
7716
|
});
|
|
7731
|
-
}
|
|
7717
|
+
}
|
|
7718
|
+
loadModels().then(function () {
|
|
7719
|
+
setReady(true);
|
|
7720
|
+
});
|
|
7721
|
+
var webGLCanvas = getWebGLContext(2).canvas;
|
|
7722
|
+
webGLCanvas.addEventListener('webglcontextlost', reloadModels);
|
|
7723
|
+
return function () {
|
|
7724
|
+
var _a;
|
|
7725
|
+
(_a = webGLCanvas.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(webGLCanvas, 'webglcontextlost', reloadModels);
|
|
7726
|
+
};
|
|
7732
7727
|
}, [documentDetectionModelUrl, focusModelUrl]);
|
|
7728
|
+
var thresholds = useMemo(function () {
|
|
7729
|
+
return {
|
|
7730
|
+
document: documentDetectionThreshold,
|
|
7731
|
+
passport: passportDetectionThreshold,
|
|
7732
|
+
mrz: mrzDetectionThreshold,
|
|
7733
|
+
pdf417: pdf417DetectionThreshold,
|
|
7734
|
+
focus: focusThreshold
|
|
7735
|
+
};
|
|
7736
|
+
}, [documentDetectionThreshold, focusThreshold, mrzDetectionThreshold, passportDetectionThreshold, pdf417DetectionThreshold]);
|
|
7737
|
+
var setThresholds = useCallback(function (thresholds) {
|
|
7738
|
+
if (thresholds.document) setDocumentDetectionThreshold(thresholds.document);
|
|
7739
|
+
if (thresholds.passport) setPassportDetectionThreshold(thresholds.passport);
|
|
7740
|
+
if (thresholds.mrz) setMrzDetectionThreshold(thresholds.mrz);
|
|
7741
|
+
if (thresholds.pdf417) setPdf417DetectionThreshold(thresholds.pdf417);
|
|
7742
|
+
if (thresholds.focus) setFocusThreshold(thresholds.focus);
|
|
7743
|
+
}, []);
|
|
7733
7744
|
var bestPredictionCanvas = useRef(null);
|
|
7734
|
-
var
|
|
7745
|
+
var bestFocusScore = useRef(0);
|
|
7735
7746
|
var makePrediction = useCallback(function (frame) {
|
|
7736
7747
|
working.current = true;
|
|
7737
7748
|
(function () {
|
|
@@ -7741,14 +7752,14 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
7741
7752
|
return __generator(this, function (_b) {
|
|
7742
7753
|
switch (_b.label) {
|
|
7743
7754
|
case 0:
|
|
7744
|
-
if (!documentDetectionModel || !focusModel || !
|
|
7745
|
-
return [4, makePredictions(frame,
|
|
7755
|
+
if (!documentDetectionModel || !focusModel || !lastPredictionCanvas.current) return [2];
|
|
7756
|
+
return [4, makePredictions(frame, lastPredictionCanvas.current, thresholds)];
|
|
7746
7757
|
case 1:
|
|
7747
7758
|
prediction = _b.sent();
|
|
7748
7759
|
setDetectionTime(prediction.detectionTime);
|
|
7749
7760
|
setFocusPredictionTime(prediction.focusPredictionTime);
|
|
7750
|
-
if (
|
|
7751
|
-
|
|
7761
|
+
if (bestFocusScore.current <= prediction.focusScore) {
|
|
7762
|
+
bestFocusScore.current = prediction.focusScore;
|
|
7752
7763
|
drawToCanvas(bestPredictionCanvas.current, frame);
|
|
7753
7764
|
}
|
|
7754
7765
|
(_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, prediction);
|
|
@@ -7758,7 +7769,7 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
7758
7769
|
});
|
|
7759
7770
|
});
|
|
7760
7771
|
})();
|
|
7761
|
-
}, [
|
|
7772
|
+
}, [thresholds]);
|
|
7762
7773
|
var onPredictionMade = useCallback(function (handler) {
|
|
7763
7774
|
onPredictionHandler.current = handler;
|
|
7764
7775
|
}, []);
|
|
@@ -7781,54 +7792,45 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
7781
7792
|
});
|
|
7782
7793
|
}, []);
|
|
7783
7794
|
var resetBestFrame = useCallback(function () {
|
|
7784
|
-
|
|
7795
|
+
bestFocusScore.current = 0;
|
|
7785
7796
|
clearCanvas(bestPredictionCanvas.current);
|
|
7786
7797
|
}, []);
|
|
7787
|
-
var value = {
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
resetBestFrame: resetBestFrame
|
|
7802
|
-
};
|
|
7798
|
+
var value = useMemo(function () {
|
|
7799
|
+
return {
|
|
7800
|
+
ready: ready,
|
|
7801
|
+
working: working,
|
|
7802
|
+
thresholds: thresholds,
|
|
7803
|
+
setThresholds: setThresholds,
|
|
7804
|
+
makePrediction: makePrediction,
|
|
7805
|
+
onPredictionMade: onPredictionMade,
|
|
7806
|
+
detectionTime: detectionTime,
|
|
7807
|
+
focusPredictionTime: focusPredictionTime,
|
|
7808
|
+
getBestFrame: getBestFrame,
|
|
7809
|
+
resetBestFrame: resetBestFrame
|
|
7810
|
+
};
|
|
7811
|
+
}, [detectionTime, focusPredictionTime, getBestFrame, makePrediction, onPredictionMade, ready, resetBestFrame, setThresholds, thresholds]);
|
|
7803
7812
|
return /*#__PURE__*/React__default.createElement(IdCaptureModelsContext.Provider, {
|
|
7804
7813
|
value: value
|
|
7805
|
-
}, children, /*#__PURE__*/React__default.createElement(
|
|
7806
|
-
ref:
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
}
|
|
7810
|
-
}), /*#__PURE__*/React__default.createElement("canvas", {
|
|
7811
|
-
ref: canvasGl,
|
|
7812
|
-
style: {
|
|
7813
|
-
display: 'none'
|
|
7814
|
-
}
|
|
7815
|
-
}), /*#__PURE__*/React__default.createElement("canvas", {
|
|
7816
|
-
ref: bestPredictionCanvas,
|
|
7817
|
-
style: {
|
|
7818
|
-
display: 'none'
|
|
7819
|
-
}
|
|
7814
|
+
}, children, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
7815
|
+
ref: lastPredictionCanvas
|
|
7816
|
+
}), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
|
|
7817
|
+
ref: bestPredictionCanvas
|
|
7820
7818
|
}));
|
|
7821
7819
|
};
|
|
7822
|
-
function drawToCanvas(canvas, frame) {
|
|
7820
|
+
function drawToCanvas(canvas, frame, width, height) {
|
|
7823
7821
|
if (!canvas) return;
|
|
7824
7822
|
var ctx = canvas.getContext('2d');
|
|
7825
7823
|
if (!ctx) return;
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7824
|
+
if (!width || !height) {
|
|
7825
|
+
var _a = getFrameDimensions(frame),
|
|
7826
|
+
frameWidth = _a[0],
|
|
7827
|
+
frameHeight = _a[1];
|
|
7828
|
+
width || (width = frameWidth);
|
|
7829
|
+
height || (height = frameHeight);
|
|
7830
|
+
}
|
|
7831
|
+
canvas.width = width;
|
|
7832
|
+
canvas.height = height;
|
|
7833
|
+
ctx.drawImage(frame, 0, 0, width, height);
|
|
7832
7834
|
}
|
|
7833
7835
|
function clearCanvas(canvas) {
|
|
7834
7836
|
if (!canvas) return;
|
|
@@ -7836,21 +7838,19 @@ function clearCanvas(canvas) {
|
|
|
7836
7838
|
if (!ctx) return;
|
|
7837
7839
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
7838
7840
|
}
|
|
7839
|
-
function makePredictions(frame,
|
|
7840
|
-
var _a, _b, _c, _d;
|
|
7841
|
+
function makePredictions(frame, lastPredictionCanvas, thresholds) {
|
|
7842
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
7841
7843
|
return __awaiter(this, void 0, void 0, function () {
|
|
7842
|
-
var
|
|
7843
|
-
var
|
|
7844
|
-
return __generator(this, function (
|
|
7845
|
-
switch (
|
|
7844
|
+
var _l, frameWidth, frameHeight, _o, boxes, scores, labels, time, detectedObjects, bestDocument, bestPassportPage, bestDocumentScore, passportDetectionScore, passportDetectionThresholdMet, bestDocumentOrPassport, detectionScore, detectionThresholdMet, bestMrz, mrzDetectionScore, mrzDetectionThresholdMet, bestPdf417, pdf417DetectionScore, pdf417DetectionThresholdMet, focusPrediction, focusPredictionTime, focusScore, focusThresholdMet;
|
|
7845
|
+
var _p;
|
|
7846
|
+
return __generator(this, function (_q) {
|
|
7847
|
+
switch (_q.label) {
|
|
7846
7848
|
case 0:
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
drawToCanvas(canvas, frame);
|
|
7850
|
-
}
|
|
7849
|
+
_l = getFrameDimensions(frame), frameWidth = _l[0], frameHeight = _l[1];
|
|
7850
|
+
drawToCanvas(lastPredictionCanvas, frame);
|
|
7851
7851
|
return [4, makeDocumentDetectionPredictions(frame)];
|
|
7852
7852
|
case 1:
|
|
7853
|
-
|
|
7853
|
+
_o = _q.sent(), boxes = _o.boxes, scores = _o.scores, labels = _o.labels, time = _o.time;
|
|
7854
7854
|
detectedObjects = applyNonMaxSuppression(boxes.map(function (box, i) {
|
|
7855
7855
|
return bboxToDetectedObjectUnscaled(box, scores[i], labels[i]);
|
|
7856
7856
|
}));
|
|
@@ -7862,18 +7862,28 @@ function makePredictions(frame, canvas, documentDetectionThreshold, passportDete
|
|
|
7862
7862
|
});
|
|
7863
7863
|
bestDocumentScore = (_a = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _a !== void 0 ? _a : 0;
|
|
7864
7864
|
passportDetectionScore = (_b = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _b !== void 0 ? _b : 0;
|
|
7865
|
-
passportDetectionThresholdMet = passportDetectionScore >=
|
|
7865
|
+
passportDetectionThresholdMet = passportDetectionScore >= ((_c = thresholds.passport) !== null && _c !== void 0 ? _c : 0);
|
|
7866
7866
|
bestDocumentOrPassport = bestDocumentScore > passportDetectionScore ? bestDocument : bestPassportPage;
|
|
7867
|
-
detectionScore = passportDetectionThresholdMet ? passportDetectionScore :
|
|
7868
|
-
detectionThresholdMet = detectionScore >=
|
|
7867
|
+
detectionScore = passportDetectionThresholdMet ? passportDetectionScore : bestDocumentScore;
|
|
7868
|
+
detectionThresholdMet = detectionScore >= ((_d = thresholds.document) !== null && _d !== void 0 ? _d : 0);
|
|
7869
|
+
bestMrz = detectedObjects.find(function (obj) {
|
|
7870
|
+
return obj.label === 'MRZ';
|
|
7871
|
+
});
|
|
7872
|
+
mrzDetectionScore = (_e = bestMrz === null || bestMrz === void 0 ? void 0 : bestMrz.score) !== null && _e !== void 0 ? _e : 0;
|
|
7873
|
+
mrzDetectionThresholdMet = mrzDetectionScore >= ((_f = thresholds.mrz) !== null && _f !== void 0 ? _f : 0);
|
|
7874
|
+
bestPdf417 = detectedObjects.find(function (obj) {
|
|
7875
|
+
return obj.label === 'PDF417';
|
|
7876
|
+
});
|
|
7877
|
+
pdf417DetectionScore = (_g = bestPdf417 === null || bestPdf417 === void 0 ? void 0 : bestPdf417.score) !== null && _g !== void 0 ? _g : 0;
|
|
7878
|
+
pdf417DetectionThresholdMet = pdf417DetectionScore >= ((_h = thresholds.pdf417) !== null && _h !== void 0 ? _h : 0);
|
|
7869
7879
|
focusPrediction = null, focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
|
|
7870
7880
|
if (!detectionThresholdMet) return [3, 3];
|
|
7871
7881
|
return [4, makeFocusPrediction(frame, bestDocumentOrPassport === null || bestDocumentOrPassport === void 0 ? void 0 : bestDocumentOrPassport.bbox)];
|
|
7872
7882
|
case 2:
|
|
7873
|
-
|
|
7874
|
-
focusScore = (
|
|
7875
|
-
focusThresholdMet = focusScore >=
|
|
7876
|
-
|
|
7883
|
+
_p = _q.sent(), focusPrediction = _p[0], focusPredictionTime = _p[1];
|
|
7884
|
+
focusScore = (_j = focusPrediction === null || focusPrediction === void 0 ? void 0 : focusPrediction[1]) !== null && _j !== void 0 ? _j : 0;
|
|
7885
|
+
focusThresholdMet = focusScore >= ((_k = thresholds.focus) !== null && _k !== void 0 ? _k : 0);
|
|
7886
|
+
_q.label = 3;
|
|
7877
7887
|
case 3:
|
|
7878
7888
|
return [2, {
|
|
7879
7889
|
detectedObjects: detectedObjects,
|
|
@@ -7881,11 +7891,17 @@ function makePredictions(frame, canvas, documentDetectionThreshold, passportDete
|
|
|
7881
7891
|
detectionThresholdMet: detectionThresholdMet,
|
|
7882
7892
|
passportDetectionScore: passportDetectionScore,
|
|
7883
7893
|
passportDetectionThresholdMet: passportDetectionThresholdMet,
|
|
7884
|
-
|
|
7894
|
+
mrzDetectionScore: mrzDetectionScore,
|
|
7895
|
+
mrzDetectionThresholdMet: mrzDetectionThresholdMet,
|
|
7896
|
+
pdf417DetectionScore: pdf417DetectionScore,
|
|
7897
|
+
pdf417DetectionThresholdMet: pdf417DetectionThresholdMet,
|
|
7898
|
+
detectionTime: time,
|
|
7885
7899
|
bestDocumentOrPassport: bestDocumentOrPassport,
|
|
7886
|
-
|
|
7900
|
+
bestMrz: bestMrz,
|
|
7901
|
+
bestPdf417: bestPdf417,
|
|
7887
7902
|
focusScore: focusScore,
|
|
7888
7903
|
focusThresholdMet: focusThresholdMet,
|
|
7904
|
+
focusPredictionTime: focusPredictionTime,
|
|
7889
7905
|
frameWidth: frameWidth,
|
|
7890
7906
|
frameHeight: frameHeight
|
|
7891
7907
|
}];
|
|
@@ -7895,7 +7911,7 @@ function makePredictions(frame, canvas, documentDetectionThreshold, passportDete
|
|
|
7895
7911
|
}
|
|
7896
7912
|
function makeDocumentDetectionPredictions(image) {
|
|
7897
7913
|
return __awaiter(this, void 0, void 0, function () {
|
|
7898
|
-
var startedAt, tfImg, tfResize, tfInt32, tf4d_, _a, _b, _c, _d, tf4d, result, predictions, boxes, scores, labels,
|
|
7914
|
+
var startedAt, tfImg, tfResize, tfInt32, tf4d_, _a, _b, _c, _d, tf4d, result, predictions, boxes, scores, labels, time, e_1;
|
|
7899
7915
|
return __generator(this, function (_e) {
|
|
7900
7916
|
switch (_e.label) {
|
|
7901
7917
|
case 0:
|
|
@@ -7937,20 +7953,22 @@ function makeDocumentDetectionPredictions(image) {
|
|
|
7937
7953
|
return Math.round(l);
|
|
7938
7954
|
});
|
|
7939
7955
|
tf.dispose(result);
|
|
7940
|
-
|
|
7941
|
-
return [2,
|
|
7956
|
+
time = new Date().getTime() - startedAt.getTime();
|
|
7957
|
+
return [2, {
|
|
7942
7958
|
boxes: boxes,
|
|
7943
7959
|
scores: scores,
|
|
7944
|
-
labels: labels
|
|
7945
|
-
|
|
7960
|
+
labels: labels,
|
|
7961
|
+
time: time
|
|
7962
|
+
}];
|
|
7946
7963
|
case 7:
|
|
7947
7964
|
e_1 = _e.sent();
|
|
7948
7965
|
console.error('caught error in makeDocumentDetectionPredictions', e_1);
|
|
7949
|
-
return [2,
|
|
7966
|
+
return [2, {
|
|
7950
7967
|
boxes: [],
|
|
7951
7968
|
scores: [],
|
|
7952
|
-
labels: []
|
|
7953
|
-
|
|
7969
|
+
labels: [],
|
|
7970
|
+
time: 0
|
|
7971
|
+
}];
|
|
7954
7972
|
case 8:
|
|
7955
7973
|
return [2];
|
|
7956
7974
|
}
|
|
@@ -8021,29 +8039,229 @@ function applyNonMaxSuppression(detectedObjects) {
|
|
|
8021
8039
|
return !!obj;
|
|
8022
8040
|
});
|
|
8023
8041
|
}
|
|
8042
|
+
function disposeTfBackend() {
|
|
8043
|
+
try {
|
|
8044
|
+
tf.backend().dispose();
|
|
8045
|
+
} catch (e) {
|
|
8046
|
+
console.error('failed to dispose backend', e);
|
|
8047
|
+
}
|
|
8048
|
+
}
|
|
8049
|
+
var InvisibleCanvas = styled.canvas(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
8050
|
+
var templateObject_1$5;
|
|
8051
|
+
|
|
8052
|
+
var DebugStatsPane = styled.span(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n font-size: 16px;\n font-family: monospace;\n position: absolute;\n left: 20px;\n bottom: 20px;\n color: limegreen;\n background: rgba(0, 0, 0, 0.5);\n z-index: 1001;\n"], ["\n font-size: 16px;\n font-family: monospace;\n position: absolute;\n left: 20px;\n bottom: 20px;\n color: limegreen;\n background: rgba(0, 0, 0, 0.5);\n z-index: 1001;\n"])));
|
|
8053
|
+
var ObjectDetectionDebugOverlay = styled.div(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["\n position: absolute;\n z-index: 1001;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n ", "\n"], ["\n position: absolute;\n z-index: 1001;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n ", "\n"])), function (_a) {
|
|
8054
|
+
var $flipX = _a.$flipX;
|
|
8055
|
+
return $flipX ? 'transform: scaleX(-1);' : '';
|
|
8056
|
+
});
|
|
8057
|
+
var ObjectDetectionDebugBox = styled.div(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n font: 10px monospace;\n position: absolute;\n top: ", "px;\n left: ", "px;\n width: ", "px;\n height: ", "px;\n border: 3px solid ", ";\n color: ", ";\n ", "\n"], ["\n font: 10px monospace;\n position: absolute;\n top: ", "px;\n left: ", "px;\n width: ", "px;\n height: ", "px;\n border: 3px solid ", ";\n color: ", ";\n ", "\n"])), function (_a) {
|
|
8058
|
+
var $top = _a.$top;
|
|
8059
|
+
return $top;
|
|
8060
|
+
}, function (_a) {
|
|
8061
|
+
var $left = _a.$left;
|
|
8062
|
+
return $left;
|
|
8063
|
+
}, function (_a) {
|
|
8064
|
+
var $width = _a.$width;
|
|
8065
|
+
return $width;
|
|
8066
|
+
}, function (_a) {
|
|
8067
|
+
var $height = _a.$height;
|
|
8068
|
+
return $height;
|
|
8069
|
+
}, function (_a) {
|
|
8070
|
+
var $color = _a.$color;
|
|
8071
|
+
return $color !== null && $color !== void 0 ? $color : 'green';
|
|
8072
|
+
}, function (_a) {
|
|
8073
|
+
var $color = _a.$color;
|
|
8074
|
+
return $color !== null && $color !== void 0 ? $color : 'green';
|
|
8075
|
+
}, function (_a) {
|
|
8076
|
+
var $flipX = _a.$flipX;
|
|
8077
|
+
return $flipX ? 'transform: scaleX(-1);' : '';
|
|
8078
|
+
});
|
|
8079
|
+
var FaceDetectionKeypointMarker = styled.div(templateObject_4$1 || (templateObject_4$1 = __makeTemplateObject(["\n position: absolute;\n top: ", "px;\n left: ", "px;\n width: ", "px;\n height: ", "px;\n border: ", "px solid\n ", ";\n font: 10px monospace;\n color: ", ";\n border-radius: 50%;\n ", "\n"], ["\n position: absolute;\n top: ", "px;\n left: ", "px;\n width: ", "px;\n height: ", "px;\n border: ", "px solid\n ", ";\n font: 10px monospace;\n color: ", ";\n border-radius: 50%;\n ", "\n"])), function (_a) {
|
|
8080
|
+
var $top = _a.$top,
|
|
8081
|
+
$height = _a.$height;
|
|
8082
|
+
return $top - $height / 2;
|
|
8083
|
+
}, function (_a) {
|
|
8084
|
+
var $left = _a.$left,
|
|
8085
|
+
$width = _a.$width;
|
|
8086
|
+
return $left - $width / 2;
|
|
8087
|
+
}, function (_a) {
|
|
8088
|
+
var $width = _a.$width;
|
|
8089
|
+
return $width;
|
|
8090
|
+
}, function (_a) {
|
|
8091
|
+
var $height = _a.$height;
|
|
8092
|
+
return $height;
|
|
8093
|
+
}, function (_a) {
|
|
8094
|
+
var $width = _a.$width;
|
|
8095
|
+
return $width / 2;
|
|
8096
|
+
}, function (_a) {
|
|
8097
|
+
var $color = _a.$color;
|
|
8098
|
+
return $color !== null && $color !== void 0 ? $color : 'red';
|
|
8099
|
+
}, function (_a) {
|
|
8100
|
+
var $color = _a.$color;
|
|
8101
|
+
return $color !== null && $color !== void 0 ? $color : 'red';
|
|
8102
|
+
}, function (_a) {
|
|
8103
|
+
var $flipX = _a.$flipX;
|
|
8104
|
+
return $flipX ? 'transform: scaleX(-1);' : '';
|
|
8105
|
+
});
|
|
8106
|
+
function useDebugScalingDetails(_a) {
|
|
8107
|
+
var _b = _a.enabled,
|
|
8108
|
+
enabled = _b === void 0 ? true : _b,
|
|
8109
|
+
pageWidth = _a.pageWidth,
|
|
8110
|
+
pageHeight = _a.pageHeight,
|
|
8111
|
+
videoWidth = _a.videoWidth,
|
|
8112
|
+
videoHeight = _a.videoHeight;
|
|
8113
|
+
return useMemo(function () {
|
|
8114
|
+
var horizontal = false,
|
|
8115
|
+
scaledWidth = 0,
|
|
8116
|
+
scaledHeight = 0,
|
|
8117
|
+
xOffset = 0,
|
|
8118
|
+
yOffset = 0;
|
|
8119
|
+
if (enabled) {
|
|
8120
|
+
horizontal = pageWidth / pageHeight < videoWidth / videoHeight;
|
|
8121
|
+
if (horizontal) {
|
|
8122
|
+
scaledWidth = videoWidth * (pageHeight / videoHeight);
|
|
8123
|
+
xOffset = (scaledWidth - pageWidth) / 2;
|
|
8124
|
+
} else {
|
|
8125
|
+
scaledHeight = videoHeight * (pageWidth / videoWidth);
|
|
8126
|
+
yOffset = (scaledHeight - pageHeight) / 2;
|
|
8127
|
+
}
|
|
8128
|
+
}
|
|
8129
|
+
return {
|
|
8130
|
+
horizontal: horizontal,
|
|
8131
|
+
pageWidth: pageWidth,
|
|
8132
|
+
pageHeight: pageHeight,
|
|
8133
|
+
videoWidth: videoWidth,
|
|
8134
|
+
videoHeight: videoHeight,
|
|
8135
|
+
scaledWidth: scaledWidth,
|
|
8136
|
+
scaledHeight: scaledHeight,
|
|
8137
|
+
xOffset: xOffset,
|
|
8138
|
+
yOffset: yOffset
|
|
8139
|
+
};
|
|
8140
|
+
}, [enabled, pageHeight, pageWidth, videoHeight, videoWidth]);
|
|
8141
|
+
}
|
|
8142
|
+
function IdCaptureDetectedObjectDebugBox(_a) {
|
|
8143
|
+
var obj = _a.obj,
|
|
8144
|
+
flipX = _a.flipX,
|
|
8145
|
+
_b = _a.scaling,
|
|
8146
|
+
horizontal = _b.horizontal,
|
|
8147
|
+
pageWidth = _b.pageWidth,
|
|
8148
|
+
pageHeight = _b.pageHeight,
|
|
8149
|
+
scaledWidth = _b.scaledWidth,
|
|
8150
|
+
scaledHeight = _b.scaledHeight,
|
|
8151
|
+
xOffset = _b.xOffset,
|
|
8152
|
+
yOffset = _b.yOffset;
|
|
8153
|
+
var top = obj.bbox[1] * (horizontal ? pageHeight : scaledHeight - yOffset);
|
|
8154
|
+
var left = obj.bbox[0] * (horizontal ? scaledWidth - xOffset : pageWidth);
|
|
8155
|
+
var width = obj.bbox[2] * (horizontal ? scaledWidth : pageWidth);
|
|
8156
|
+
var height = obj.bbox[3] * (horizontal ? pageHeight : scaledHeight);
|
|
8157
|
+
return /*#__PURE__*/React__default.createElement(ObjectDetectionDebugBox, {
|
|
8158
|
+
"$top": top,
|
|
8159
|
+
"$left": left,
|
|
8160
|
+
"$width": width,
|
|
8161
|
+
"$height": height,
|
|
8162
|
+
"$flipX": flipX
|
|
8163
|
+
}, obj.label, " (", obj.score.toFixed(3), ")");
|
|
8164
|
+
}
|
|
8165
|
+
function SelfieCaptureFaceDebugBox(_a) {
|
|
8166
|
+
var face = _a.face,
|
|
8167
|
+
flipX = _a.flipX,
|
|
8168
|
+
_b = _a.color,
|
|
8169
|
+
color = _b === void 0 ? 'green' : _b,
|
|
8170
|
+
scaling = _a.scaling;
|
|
8171
|
+
var horizontal = scaling.horizontal,
|
|
8172
|
+
pageWidth = scaling.pageWidth,
|
|
8173
|
+
pageHeight = scaling.pageHeight,
|
|
8174
|
+
videoWidth = scaling.videoWidth,
|
|
8175
|
+
videoHeight = scaling.videoHeight,
|
|
8176
|
+
scaledWidth = scaling.scaledWidth,
|
|
8177
|
+
scaledHeight = scaling.scaledHeight,
|
|
8178
|
+
xOffset = scaling.xOffset,
|
|
8179
|
+
yOffset = scaling.yOffset;
|
|
8180
|
+
var top;
|
|
8181
|
+
var left;
|
|
8182
|
+
var width;
|
|
8183
|
+
var height;
|
|
8184
|
+
if (horizontal) {
|
|
8185
|
+
top = face.box.yMin / videoHeight * pageHeight;
|
|
8186
|
+
left = face.box.xMin / videoWidth * scaledWidth - xOffset;
|
|
8187
|
+
width = face.box.width / videoWidth * scaledWidth;
|
|
8188
|
+
height = face.box.height / videoHeight * pageHeight;
|
|
8189
|
+
} else {
|
|
8190
|
+
top = face.box.yMin / videoHeight * scaledHeight - yOffset;
|
|
8191
|
+
left = face.box.xMin / videoWidth * pageWidth;
|
|
8192
|
+
width = face.box.width / videoWidth * pageWidth;
|
|
8193
|
+
height = face.box.height / videoHeight * scaledHeight;
|
|
8194
|
+
}
|
|
8195
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ObjectDetectionDebugBox, {
|
|
8196
|
+
"$top": top,
|
|
8197
|
+
"$left": left,
|
|
8198
|
+
"$width": width,
|
|
8199
|
+
"$height": height,
|
|
8200
|
+
"$flipX": flipX,
|
|
8201
|
+
"$color": color
|
|
8202
|
+
}), face.keypoints.map(function (point, ii) {
|
|
8203
|
+
return /*#__PURE__*/React__default.createElement(SelfieCaptureFaceKeypoint, {
|
|
8204
|
+
key: ii,
|
|
8205
|
+
point: point,
|
|
8206
|
+
scaling: scaling,
|
|
8207
|
+
flipX: flipX
|
|
8208
|
+
});
|
|
8209
|
+
}));
|
|
8210
|
+
}
|
|
8211
|
+
function SelfieCaptureFaceKeypoint(_a) {
|
|
8212
|
+
var point = _a.point,
|
|
8213
|
+
flipX = _a.flipX,
|
|
8214
|
+
_b = _a.color,
|
|
8215
|
+
color = _b === void 0 ? 'red' : _b,
|
|
8216
|
+
_c = _a.scaling,
|
|
8217
|
+
horizontal = _c.horizontal,
|
|
8218
|
+
pageWidth = _c.pageWidth,
|
|
8219
|
+
pageHeight = _c.pageHeight,
|
|
8220
|
+
videoWidth = _c.videoWidth,
|
|
8221
|
+
videoHeight = _c.videoHeight,
|
|
8222
|
+
scaledWidth = _c.scaledWidth,
|
|
8223
|
+
scaledHeight = _c.scaledHeight,
|
|
8224
|
+
xOffset = _c.xOffset,
|
|
8225
|
+
yOffset = _c.yOffset;
|
|
8226
|
+
var left, top;
|
|
8227
|
+
if (horizontal) {
|
|
8228
|
+
left = point.x / videoWidth * scaledWidth - xOffset;
|
|
8229
|
+
top = point.y / videoHeight * pageHeight;
|
|
8230
|
+
} else {
|
|
8231
|
+
left = point.x / videoWidth * pageWidth;
|
|
8232
|
+
top = point.y / videoHeight * scaledHeight - yOffset;
|
|
8233
|
+
}
|
|
8234
|
+
return /*#__PURE__*/React__default.createElement(FaceDetectionKeypointMarker, {
|
|
8235
|
+
"$top": top,
|
|
8236
|
+
"$left": left,
|
|
8237
|
+
"$width": 4,
|
|
8238
|
+
"$height": 4,
|
|
8239
|
+
"$flipX": flipX,
|
|
8240
|
+
"$color": color
|
|
8241
|
+
});
|
|
8242
|
+
}
|
|
8243
|
+
var templateObject_1$4, templateObject_2$2, templateObject_3$1, templateObject_4$1;
|
|
8024
8244
|
|
|
8025
8245
|
var initialState$5 = {
|
|
8026
8246
|
videoWidth: 0,
|
|
8027
8247
|
videoHeight: 0,
|
|
8028
8248
|
captureStartedAt: null,
|
|
8029
8249
|
detectedObjects: [],
|
|
8030
|
-
bestDocument:
|
|
8031
|
-
bestMrz:
|
|
8032
|
-
bestPdf417:
|
|
8250
|
+
bestDocument: undefined,
|
|
8251
|
+
bestMrz: undefined,
|
|
8252
|
+
bestPdf417: undefined,
|
|
8033
8253
|
documentType: DocumentType.NONE,
|
|
8034
8254
|
documentInBounds: false,
|
|
8035
8255
|
documentDetectionScore: 0,
|
|
8036
8256
|
documentDetectionThresholdMet: false,
|
|
8037
|
-
mrzDetectionScore: 0,
|
|
8038
|
-
mrzDetectionThreshold: 0.5,
|
|
8039
|
-
mrzDetectionThresholdMet: false,
|
|
8040
|
-
focusScore: 0,
|
|
8041
|
-
focusThresholdMet: false,
|
|
8042
8257
|
passportPageDetectionScore: 0,
|
|
8043
8258
|
passportPageDetectionThresholdMet: false,
|
|
8259
|
+
mrzDetectionScore: 0,
|
|
8260
|
+
mrzDetectionThresholdMet: false,
|
|
8044
8261
|
pdf417DetectionScore: 0,
|
|
8045
|
-
pdf417DetectionThreshold: 0.15,
|
|
8046
8262
|
pdf417DetectionThresholdMet: false,
|
|
8263
|
+
focusScore: 0,
|
|
8264
|
+
focusThresholdMet: false,
|
|
8047
8265
|
barcodeScanningEnabled: false,
|
|
8048
8266
|
barcodeResult: null,
|
|
8049
8267
|
waitingForBarcodeScan: false,
|
|
@@ -8062,7 +8280,6 @@ var initialState$5 = {
|
|
|
8062
8280
|
captureFailed: false
|
|
8063
8281
|
};
|
|
8064
8282
|
var reducer$5 = function reducer(state, action) {
|
|
8065
|
-
var _a, _b, _c, _d;
|
|
8066
8283
|
switch (action.type) {
|
|
8067
8284
|
case 'configure':
|
|
8068
8285
|
return __assign(__assign(__assign({}, state), action.payload), {
|
|
@@ -8073,17 +8290,23 @@ var reducer$5 = function reducer(state, action) {
|
|
|
8073
8290
|
captureFailed: false
|
|
8074
8291
|
});
|
|
8075
8292
|
case 'objectsDetected':
|
|
8076
|
-
var
|
|
8077
|
-
detectedObjects =
|
|
8078
|
-
detectionScore =
|
|
8079
|
-
detectionThresholdMet =
|
|
8080
|
-
passportDetectionScore =
|
|
8081
|
-
passportDetectionThresholdMet =
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8293
|
+
var _a = action.payload.prediction,
|
|
8294
|
+
detectedObjects = _a.detectedObjects,
|
|
8295
|
+
detectionScore = _a.detectionScore,
|
|
8296
|
+
detectionThresholdMet = _a.detectionThresholdMet,
|
|
8297
|
+
passportDetectionScore = _a.passportDetectionScore,
|
|
8298
|
+
passportDetectionThresholdMet = _a.passportDetectionThresholdMet,
|
|
8299
|
+
mrzDetectionScore = _a.mrzDetectionScore,
|
|
8300
|
+
mrzDetectionThresholdMet = _a.mrzDetectionThresholdMet,
|
|
8301
|
+
pdf417DetectionScore = _a.pdf417DetectionScore,
|
|
8302
|
+
pdf417DetectionThresholdMet = _a.pdf417DetectionThresholdMet,
|
|
8303
|
+
bestDocumentOrPassport = _a.bestDocumentOrPassport,
|
|
8304
|
+
bestMrz = _a.bestMrz,
|
|
8305
|
+
bestPdf417 = _a.bestPdf417,
|
|
8306
|
+
focusScore = _a.focusScore,
|
|
8307
|
+
focusThresholdMet = _a.focusThresholdMet,
|
|
8308
|
+
frameWidth = _a.frameWidth,
|
|
8309
|
+
frameHeight = _a.frameHeight;
|
|
8087
8310
|
var frameCapturedAt = new Date();
|
|
8088
8311
|
var frameCaptureRate = 0;
|
|
8089
8312
|
var goodFramesThreshold = state.goodFramesThreshold;
|
|
@@ -8093,16 +8316,6 @@ var reducer$5 = function reducer(state, action) {
|
|
|
8093
8316
|
goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
|
|
8094
8317
|
}
|
|
8095
8318
|
}
|
|
8096
|
-
var bestMrz = (_a = detectedObjects.find(function (obj) {
|
|
8097
|
-
return obj.label === 'MRZ';
|
|
8098
|
-
})) !== null && _a !== void 0 ? _a : null;
|
|
8099
|
-
var mrzDetectionScore = (_b = bestMrz === null || bestMrz === void 0 ? void 0 : bestMrz.score) !== null && _b !== void 0 ? _b : 0;
|
|
8100
|
-
var mrzDetectionThresholdMet = mrzDetectionScore >= state.mrzDetectionThreshold;
|
|
8101
|
-
var bestPdf417 = (_c = detectedObjects.find(function (obj) {
|
|
8102
|
-
return obj.label === 'PDF417';
|
|
8103
|
-
})) !== null && _c !== void 0 ? _c : null;
|
|
8104
|
-
var pdf417DetectionScore = (_d = bestPdf417 === null || bestPdf417 === void 0 ? void 0 : bestPdf417.score) !== null && _d !== void 0 ? _d : 0;
|
|
8105
|
-
var pdf417DetectionThresholdMet = pdf417DetectionScore >= state.pdf417DetectionThreshold;
|
|
8106
8319
|
var documentType = DocumentType.NONE;
|
|
8107
8320
|
if (passportDetectionThresholdMet) {
|
|
8108
8321
|
documentType = DocumentType.PASSPORT;
|
|
@@ -8111,11 +8324,11 @@ var reducer$5 = function reducer(state, action) {
|
|
|
8111
8324
|
}
|
|
8112
8325
|
var documentInBounds = false;
|
|
8113
8326
|
if (bestDocumentOrPassport) {
|
|
8114
|
-
var
|
|
8115
|
-
boundaryX =
|
|
8116
|
-
boundaryY =
|
|
8117
|
-
boundaryWidth =
|
|
8118
|
-
boundaryHeight =
|
|
8327
|
+
var _b = bestDocumentOrPassport.bbox,
|
|
8328
|
+
boundaryX = _b[0],
|
|
8329
|
+
boundaryY = _b[1],
|
|
8330
|
+
boundaryWidth = _b[2],
|
|
8331
|
+
boundaryHeight = _b[3];
|
|
8119
8332
|
boundaryX *= frameWidth;
|
|
8120
8333
|
boundaryWidth *= frameWidth;
|
|
8121
8334
|
boundaryY *= frameHeight;
|
|
@@ -8134,7 +8347,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
8134
8347
|
videoWidth: frameWidth,
|
|
8135
8348
|
videoHeight: frameHeight,
|
|
8136
8349
|
detectedObjects: detectedObjects,
|
|
8137
|
-
bestDocument: bestDocumentOrPassport
|
|
8350
|
+
bestDocument: bestDocumentOrPassport,
|
|
8138
8351
|
bestMrz: bestMrz,
|
|
8139
8352
|
bestPdf417: bestPdf417,
|
|
8140
8353
|
documentType: documentType,
|
|
@@ -8259,9 +8472,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
8259
8472
|
var _3 = useContext(IdCaptureModelsContext),
|
|
8260
8473
|
modelsReady = _3.ready,
|
|
8261
8474
|
modelsWorking = _3.working,
|
|
8262
|
-
|
|
8263
|
-
setPassportDetectionThreshold = _3.setPassportDetectionThreshold,
|
|
8264
|
-
setFocusThreshold = _3.setFocusThreshold,
|
|
8475
|
+
setThresholds = _3.setThresholds,
|
|
8265
8476
|
makePrediction = _3.makePrediction,
|
|
8266
8477
|
onPredictionMade = _3.onPredictionMade,
|
|
8267
8478
|
detectionTime = _3.detectionTime,
|
|
@@ -8276,19 +8487,21 @@ var IdCapture = function IdCapture(_a) {
|
|
|
8276
8487
|
type: 'configure',
|
|
8277
8488
|
payload: {
|
|
8278
8489
|
requiredDocumentType: requiredDocumentType,
|
|
8279
|
-
mrzDetectionThreshold: mrzDetectionScoreThreshold,
|
|
8280
8490
|
goodFramesThreshold: autoCaptureGoodFramesRequired,
|
|
8281
8491
|
autoCaptureBarcodeRequired: autoCaptureBarcodeRequired,
|
|
8282
8492
|
barcodeScanningEnabled: barcodeScanningEnabled,
|
|
8283
|
-
maxBarcodeScanAttempts: maxBarcodeScanAttempts
|
|
8284
|
-
pdf417DetectionThreshold: pdf417DetectionThreshold
|
|
8493
|
+
maxBarcodeScanAttempts: maxBarcodeScanAttempts
|
|
8285
8494
|
}
|
|
8286
8495
|
});
|
|
8287
8496
|
resetBestFrame();
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8497
|
+
setThresholds({
|
|
8498
|
+
document: autoCaptureScoreThreshold,
|
|
8499
|
+
passport: passportPageDetectionThreshold,
|
|
8500
|
+
mrz: mrzDetectionScoreThreshold,
|
|
8501
|
+
pdf417: pdf417DetectionThreshold,
|
|
8502
|
+
focus: focusScoreThreshold
|
|
8503
|
+
});
|
|
8504
|
+
}, [requiredDocumentType, autoCaptureScoreThreshold, focusScoreThreshold, mrzDetectionScoreThreshold, autoCaptureGoodFramesRequired, autoCaptureBarcodeRequired, barcodeScanningEnabled, maxBarcodeScanAttempts, passportPageDetectionThreshold, pdf417DetectionThreshold, resetBestFrame, setThresholds]);
|
|
8292
8505
|
var animationFrame = useRef(0);
|
|
8293
8506
|
var shouldCaptureFrames = useRef(false);
|
|
8294
8507
|
useEffect(function () {
|
|
@@ -8461,6 +8674,13 @@ var IdCapture = function IdCapture(_a) {
|
|
|
8461
8674
|
});
|
|
8462
8675
|
})();
|
|
8463
8676
|
}, [getBestFrame, onCapture, processingDelay, shouldCapture, state.barcodeResult]);
|
|
8677
|
+
var debugScalingDetails = useDebugScalingDetails({
|
|
8678
|
+
enabled: debugMode,
|
|
8679
|
+
pageWidth: width,
|
|
8680
|
+
pageHeight: height,
|
|
8681
|
+
videoWidth: state.videoWidth,
|
|
8682
|
+
videoHeight: state.videoHeight
|
|
8683
|
+
});
|
|
8464
8684
|
if (processingFrame) {
|
|
8465
8685
|
return processingScreen || /*#__PURE__*/React__default.createElement("div", null, "Processing...");
|
|
8466
8686
|
}
|
|
@@ -8488,64 +8708,17 @@ var IdCapture = function IdCapture(_a) {
|
|
|
8488
8708
|
landscapeGuidesImageUrl: assets.landscapeGuidesImageUrl,
|
|
8489
8709
|
isMirrored: !((_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.isRearFacing),
|
|
8490
8710
|
borderColor: state.isGoodFrame ? 'green' : 'white'
|
|
8491
|
-
}), debugMode && state.detectedObjects.length > 0 && /*#__PURE__*/React__default.createElement(
|
|
8492
|
-
|
|
8493
|
-
position: 'absolute',
|
|
8494
|
-
zIndex: 1001,
|
|
8495
|
-
width: '100%',
|
|
8496
|
-
height: '100%',
|
|
8497
|
-
maxWidth: '100%',
|
|
8498
|
-
maxHeight: '100%',
|
|
8499
|
-
transform: ((_d = cameraRef.current) === null || _d === void 0 ? void 0 : _d.isRearFacing) ? '' : 'scaleX(-1)',
|
|
8500
|
-
overflow: 'hidden'
|
|
8501
|
-
}
|
|
8711
|
+
}), debugMode && state.detectedObjects.length > 0 && /*#__PURE__*/React__default.createElement(ObjectDetectionDebugOverlay, {
|
|
8712
|
+
"$flipX": !((_d = cameraRef.current) === null || _d === void 0 ? void 0 : _d.isRearFacing)
|
|
8502
8713
|
}, state.detectedObjects.map(function (obj, i) {
|
|
8503
8714
|
var _a;
|
|
8504
|
-
|
|
8505
|
-
var videoAspectRatio = state.videoWidth / state.videoHeight;
|
|
8506
|
-
var left = obj.bbox[0] * width;
|
|
8507
|
-
var top = obj.bbox[1] * height;
|
|
8508
|
-
var boxWidth = obj.bbox[2] * width;
|
|
8509
|
-
var boxHeight = obj.bbox[3] * height;
|
|
8510
|
-
if (wrapperAspectRatio < videoAspectRatio) {
|
|
8511
|
-
var xScalar = height / state.videoHeight;
|
|
8512
|
-
var scaledWidth = state.videoWidth * xScalar;
|
|
8513
|
-
var xOffset = (scaledWidth - width) / 2;
|
|
8514
|
-
left = obj.bbox[0] * scaledWidth - xOffset;
|
|
8515
|
-
boxWidth = obj.bbox[2] * scaledWidth;
|
|
8516
|
-
} else {
|
|
8517
|
-
var yScalar = width / state.videoWidth;
|
|
8518
|
-
var scaledHeight = state.videoHeight * yScalar;
|
|
8519
|
-
var yOffset = (scaledHeight - height) / 2;
|
|
8520
|
-
top = obj.bbox[1] * scaledHeight - yOffset;
|
|
8521
|
-
boxHeight = obj.bbox[3] * scaledHeight;
|
|
8522
|
-
}
|
|
8523
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
8715
|
+
return /*#__PURE__*/React__default.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
8524
8716
|
key: i,
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
height: boxHeight,
|
|
8531
|
-
border: '3px solid green',
|
|
8532
|
-
font: '10px monospace',
|
|
8533
|
-
color: 'green',
|
|
8534
|
-
transform: ((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing) ? '' : 'scaleX(-1)'
|
|
8535
|
-
}
|
|
8536
|
-
}, obj.label, " (", obj.score.toFixed(3), ")");
|
|
8537
|
-
})), debugMode && /*#__PURE__*/React__default.createElement("span", {
|
|
8538
|
-
style: {
|
|
8539
|
-
fontSize: 16,
|
|
8540
|
-
fontFamily: 'monospace',
|
|
8541
|
-
position: 'absolute',
|
|
8542
|
-
left: 20,
|
|
8543
|
-
bottom: 20,
|
|
8544
|
-
color: 'limegreen',
|
|
8545
|
-
background: 'rgba(0,0,0,0.5)',
|
|
8546
|
-
zIndex: 1001
|
|
8547
|
-
}
|
|
8548
|
-
}, cameraRef.current ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", (_e = cameraRef.current) === null || _e === void 0 ? void 0 : _e.width, "x", (_f = cameraRef.current) === null || _f === void 0 ? void 0 : _f.height) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__default.createElement("br", null), modelsReady ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.documentDetectionThresholdMet ? '✅' : '❌', " Document Score: ", state.documentDetectionScore, " (", state.documentType, ")", /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore, /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold, barcodeScanningEnabled && state.autoCaptureBarcodeRequired ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("br", null), state.barcodeResult ? '✅' : '❌', " Barcode Scanned (", supportsNativeBarcodeScanning() ? 'Native' : 'ZXing', ",", ' ', state.barcodeScanFailedAttempts, "/", state.maxBarcodeScanAttempts, " failed attempts)") : null) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")));
|
|
8717
|
+
obj: obj,
|
|
8718
|
+
scaling: debugScalingDetails,
|
|
8719
|
+
flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
|
|
8720
|
+
});
|
|
8721
|
+
})), debugMode && /*#__PURE__*/React__default.createElement(DebugStatsPane, null, cameraRef.current ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", (_e = cameraRef.current) === null || _e === void 0 ? void 0 : _e.width, "x", (_f = cameraRef.current) === null || _f === void 0 ? void 0 : _f.height) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__default.createElement("br", null), modelsReady ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.documentDetectionThresholdMet ? '✅' : '❌', " Document Score: ", state.documentDetectionScore, " (", state.documentType, ")", /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore, /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold, barcodeScanningEnabled && state.autoCaptureBarcodeRequired ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("br", null), state.barcodeResult ? '✅' : '❌', " Barcode Scanned (", supportsNativeBarcodeScanning() ? 'Native' : 'ZXing', ",", ' ', state.barcodeScanFailedAttempts, "/", state.maxBarcodeScanAttempts, " failed attempts)") : null) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")));
|
|
8549
8722
|
};
|
|
8550
8723
|
var timeSince = function timeSince(t) {
|
|
8551
8724
|
if (!t) return 0;
|
|
@@ -9043,10 +9216,10 @@ var CameraVideoTag = function CameraVideoTag() {
|
|
|
9043
9216
|
"$isRearFacing": (_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing
|
|
9044
9217
|
});
|
|
9045
9218
|
};
|
|
9046
|
-
var FullscreenVideoTag = styled.video(templateObject_1$
|
|
9219
|
+
var FullscreenVideoTag = styled.video(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n transform: ", ";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n"], ["\n transform: ", ";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n"])), function (props) {
|
|
9047
9220
|
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
9048
9221
|
});
|
|
9049
|
-
var templateObject_1$
|
|
9222
|
+
var templateObject_1$3;
|
|
9050
9223
|
|
|
9051
9224
|
var CaptureState;
|
|
9052
9225
|
(function (CaptureState) {
|
|
@@ -9713,11 +9886,6 @@ var reducer$3 = function reducer(state, action) {
|
|
|
9713
9886
|
var isMobile = state.videoWidth < state.videoHeight;
|
|
9714
9887
|
var tooCloseMultiple = isMobile ? 2 : 4.5;
|
|
9715
9888
|
var tooFarMultiple = isMobile ? 6 : 7;
|
|
9716
|
-
console.log({
|
|
9717
|
-
faceBoxWidth: face.box.width,
|
|
9718
|
-
videoWidth: state.videoWidth,
|
|
9719
|
-
tooCloseMultiple: tooCloseMultiple
|
|
9720
|
-
});
|
|
9721
9889
|
faceTooClose = face.box.width > state.videoWidth / tooCloseMultiple;
|
|
9722
9890
|
faceTooFar = face.box.width < state.videoWidth / tooFarMultiple;
|
|
9723
9891
|
}
|
|
@@ -9855,6 +10023,13 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9855
10023
|
useEffect(function () {
|
|
9856
10024
|
if (timedOut) onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout();
|
|
9857
10025
|
}, [onTimeout, timedOut]);
|
|
10026
|
+
var debugScalingDetails = useDebugScalingDetails({
|
|
10027
|
+
enabled: debugMode,
|
|
10028
|
+
pageWidth: width,
|
|
10029
|
+
pageHeight: height,
|
|
10030
|
+
videoWidth: state.videoWidth,
|
|
10031
|
+
videoHeight: state.videoHeight
|
|
10032
|
+
});
|
|
9858
10033
|
if (!guidanceMessage) {
|
|
9859
10034
|
verbiage.guidanceHoldStillText = verbiage.guidanceHoldStillText || t('Hold still for a few seconds...');
|
|
9860
10035
|
verbiage.guidanceLookStraightText = verbiage.guidanceLookStraightText || t('Look straight into the camera...');
|
|
@@ -9885,100 +10060,18 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9885
10060
|
padding: '10px 12px 8px',
|
|
9886
10061
|
borderRadius: 8
|
|
9887
10062
|
}
|
|
9888
|
-
}, guidanceMessage)), debugMode && state.faces.length > 0 && /*#__PURE__*/React__default.createElement(
|
|
9889
|
-
|
|
9890
|
-
position: 'absolute',
|
|
9891
|
-
zIndex: 1001,
|
|
9892
|
-
width: '100%',
|
|
9893
|
-
height: '100%',
|
|
9894
|
-
maxWidth: '100%',
|
|
9895
|
-
maxHeight: '100%',
|
|
9896
|
-
transform: ((_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing) ? '' : 'scaleX(-1)',
|
|
9897
|
-
overflow: 'hidden'
|
|
9898
|
-
}
|
|
10063
|
+
}, guidanceMessage)), debugMode && state.faces.length > 0 && /*#__PURE__*/React__default.createElement(ObjectDetectionDebugOverlay, {
|
|
10064
|
+
"$flipX": !((_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing)
|
|
9899
10065
|
}, state.faces.map(function (face, i) {
|
|
9900
10066
|
var _a;
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
var scaledWidth = state.videoWidth * xScalar;
|
|
9910
|
-
var xOffset = (scaledWidth - width) / 2;
|
|
9911
|
-
left = left * scaledWidth - xOffset;
|
|
9912
|
-
top *= height;
|
|
9913
|
-
boxWidth *= scaledWidth;
|
|
9914
|
-
boxHeight *= height;
|
|
9915
|
-
} else {
|
|
9916
|
-
var yScalar = width / state.videoWidth;
|
|
9917
|
-
var scaledHeight = state.videoHeight * yScalar;
|
|
9918
|
-
var yOffset = (scaledHeight - height) / 2;
|
|
9919
|
-
left *= width;
|
|
9920
|
-
top = top * scaledHeight - yOffset;
|
|
9921
|
-
boxWidth *= width;
|
|
9922
|
-
boxHeight *= scaledHeight;
|
|
9923
|
-
}
|
|
9924
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
9925
|
-
key: i
|
|
9926
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
9927
|
-
style: {
|
|
9928
|
-
position: 'absolute',
|
|
9929
|
-
left: left,
|
|
9930
|
-
top: top,
|
|
9931
|
-
width: boxWidth,
|
|
9932
|
-
height: boxHeight,
|
|
9933
|
-
border: "3px solid ".concat(state.faceReady ? 'green' : 'red'),
|
|
9934
|
-
font: '10px monospace',
|
|
9935
|
-
transform: ((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing) ? '' : 'scaleX(-1)'
|
|
9936
|
-
}
|
|
9937
|
-
}), face.keypoints.map(function (point, ii) {
|
|
9938
|
-
var _a;
|
|
9939
|
-
var left = point.x / state.videoWidth;
|
|
9940
|
-
var top = point.y / state.videoHeight;
|
|
9941
|
-
if (wrapperAspectRatio < videoAspectRatio) {
|
|
9942
|
-
var xScalar = height / state.videoHeight;
|
|
9943
|
-
var scaledWidth = state.videoWidth * xScalar;
|
|
9944
|
-
var xOffset = (scaledWidth - width) / 2;
|
|
9945
|
-
left = left * scaledWidth - xOffset;
|
|
9946
|
-
top *= height;
|
|
9947
|
-
} else {
|
|
9948
|
-
var yScalar = width / state.videoWidth;
|
|
9949
|
-
var scaledHeight = state.videoHeight * yScalar;
|
|
9950
|
-
var yOffset = (scaledHeight - height) / 2;
|
|
9951
|
-
left *= width;
|
|
9952
|
-
top = top * scaledHeight - yOffset;
|
|
9953
|
-
}
|
|
9954
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
9955
|
-
key: ii,
|
|
9956
|
-
style: {
|
|
9957
|
-
position: 'absolute',
|
|
9958
|
-
left: left - 2,
|
|
9959
|
-
top: top - 2,
|
|
9960
|
-
width: 4,
|
|
9961
|
-
height: 4,
|
|
9962
|
-
border: '2px solid red',
|
|
9963
|
-
font: '10px monospace',
|
|
9964
|
-
color: 'green',
|
|
9965
|
-
transform: ((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing) ? '' : 'scaleX(-1)',
|
|
9966
|
-
borderRadius: '50%'
|
|
9967
|
-
}
|
|
9968
|
-
}, ii);
|
|
9969
|
-
}));
|
|
9970
|
-
})), debugMode && /*#__PURE__*/React__default.createElement("span", {
|
|
9971
|
-
style: {
|
|
9972
|
-
fontSize: 16,
|
|
9973
|
-
fontFamily: 'monospace',
|
|
9974
|
-
position: 'absolute',
|
|
9975
|
-
left: 20,
|
|
9976
|
-
bottom: 20,
|
|
9977
|
-
color: 'limegreen',
|
|
9978
|
-
background: 'rgba(0,0,0,0.5)',
|
|
9979
|
-
zIndex: 1001
|
|
9980
|
-
}
|
|
9981
|
-
}, cameraRef.current ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", (_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.width, "x", (_d = cameraRef.current) === null || _d === void 0 ? void 0 : _d.height) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default.createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default.createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " ", state.goodFramesCount, ' ', "Good Frames", /*#__PURE__*/React__default.createElement("br", null), !timedOut ? '✅' : '❌', " Time Remaining:", ' ', Math.max(0, timeoutDurationMs - (new Date().getTime() - (timeoutStartedAt !== null && timeoutStartedAt !== void 0 ? timeoutStartedAt : new Date()).getTime())), "ms"));
|
|
10067
|
+
return /*#__PURE__*/React__default.createElement(SelfieCaptureFaceDebugBox, {
|
|
10068
|
+
key: i,
|
|
10069
|
+
face: face,
|
|
10070
|
+
scaling: debugScalingDetails,
|
|
10071
|
+
flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing),
|
|
10072
|
+
color: state.faceReady ? 'green' : 'red'
|
|
10073
|
+
});
|
|
10074
|
+
})), debugMode && /*#__PURE__*/React__default.createElement(DebugStatsPane, null, cameraRef.current ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", (_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.width, "x", (_d = cameraRef.current) === null || _d === void 0 ? void 0 : _d.height) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default.createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default.createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " ", state.goodFramesCount, ' ', "Good Frames", /*#__PURE__*/React__default.createElement("br", null), !timedOut ? '✅' : '❌', " Time Remaining:", ' ', Math.max(0, timeoutDurationMs - (new Date().getTime() - (timeoutStartedAt !== null && timeoutStartedAt !== void 0 ? timeoutStartedAt : new Date()).getTime())), "ms"));
|
|
9982
10075
|
};
|
|
9983
10076
|
|
|
9984
10077
|
var initialState$2 = {
|
|
@@ -11051,8 +11144,8 @@ function truncate(str, max_chars) {
|
|
|
11051
11144
|
return truncated;
|
|
11052
11145
|
}
|
|
11053
11146
|
|
|
11054
|
-
var Spinner = styled.div(templateObject_1$
|
|
11055
|
-
var templateObject_1$
|
|
11147
|
+
var Spinner = styled.div(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n display: inline-block;\n width: 80px;\n height: 80px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #888;\n border-color: #888 transparent #888 transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n }\n\n @keyframes lds-dual-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n"], ["\n display: inline-block;\n width: 80px;\n height: 80px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #888;\n border-color: #888 transparent #888 transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n }\n\n @keyframes lds-dual-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n"])));
|
|
11148
|
+
var templateObject_1$2;
|
|
11056
11149
|
|
|
11057
11150
|
var AdditionalDocumentCapture = function AdditionalDocumentCapture(_a) {
|
|
11058
11151
|
var document = _a.document,
|
|
@@ -11198,55 +11291,43 @@ function signatureDataToIdmissionFormat(signatureCanvas) {
|
|
|
11198
11291
|
return signatureData;
|
|
11199
11292
|
}
|
|
11200
11293
|
|
|
11294
|
+
var SignatureCanvasContainer = styled.div(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n position: absolute;\n top: 25%;\n left: 15%;\n width: 70%;\n height: 50%;\n\n @media (max-width: 800px) {\n top: 15%;\n left: 2%;\n width: 96%;\n height: 70%;\n }\n"], ["\n position: absolute;\n top: 25%;\n left: 15%;\n width: 70%;\n height: 50%;\n\n @media (max-width: 800px) {\n top: 15%;\n left: 2%;\n width: 96%;\n height: 70%;\n }\n"])));
|
|
11295
|
+
var SignaturePad = styled.div(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n position: relative;\n background: rgba(255, 255, 255, 0.5);\n border-radius: 16px;\n flex-grow: 1;\n z-index: 100;\n height: 100%;\n"], ["\n position: relative;\n background: rgba(255, 255, 255, 0.5);\n border-radius: 16px;\n flex-grow: 1;\n z-index: 100;\n height: 100%;\n"])));
|
|
11296
|
+
var SignatureButtonsContainer = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n flex-grow: 0;\n padding-top: 12px;\n display: flex;\n z-index: 1000;\n position: relative;\n"], ["\n flex-grow: 0;\n padding-top: 12px;\n display: flex;\n z-index: 1000;\n position: relative;\n"])));
|
|
11297
|
+
var SignaturePaperBacking = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background-color: #e5e5f7;\n opacity: 0.8;\n background-image: radial-gradient(#444cf7 0.5px, transparent 0.5px),\n radial-gradient(#444cf7 0.5px, #e5e5f7 0.5px);\n background-size: 20px 20px;\n background-position: 0 0, 10px 10px;\n"], ["\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n background-color: #e5e5f7;\n opacity: 0.8;\n background-image: radial-gradient(#444cf7 0.5px, transparent 0.5px),\n radial-gradient(#444cf7 0.5px, #e5e5f7 0.5px);\n background-size: 20px 20px;\n background-position: 0 0, 10px 10px;\n"])));
|
|
11298
|
+
var templateObject_1$1, templateObject_2$1, templateObject_3, templateObject_4;
|
|
11299
|
+
|
|
11300
|
+
var GuidanceMessageContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: calc(", ");\n font-weight: bold;\n width: 100%;\n display: flex;\n"], ["\n position: absolute;\n top: calc(", ");\n font-weight: bold;\n width: 100%;\n display: flex;\n"])), function (_a) {
|
|
11301
|
+
var $top = _a.$top;
|
|
11302
|
+
return $top !== null && $top !== void 0 ? $top : '10vh';
|
|
11303
|
+
});
|
|
11304
|
+
var GuidanceMessage = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: auto;\n margin-right: auto;\n background: #ccc;\n padding: 10px 12px 8px;\n border-radius: 8px;\n"], ["\n margin-left: auto;\n margin-right: auto;\n background: #ccc;\n padding: 10px 12px 8px;\n border-radius: 8px;\n"])));
|
|
11305
|
+
var templateObject_1, templateObject_2;
|
|
11306
|
+
|
|
11201
11307
|
var SignatureCapture = function SignatureCapture(_a) {
|
|
11202
11308
|
var onAccept = _a.onAccept,
|
|
11203
|
-
_b = _a.
|
|
11204
|
-
|
|
11205
|
-
_c = _a.verbiage,
|
|
11206
|
-
verbiage = _c === void 0 ? {} : _c;
|
|
11309
|
+
_b = _a.verbiage,
|
|
11310
|
+
verbiage = _b === void 0 ? {} : _b;
|
|
11207
11311
|
var t = useTranslation().t;
|
|
11208
|
-
var
|
|
11209
|
-
ref =
|
|
11210
|
-
width =
|
|
11211
|
-
height =
|
|
11312
|
+
var _c = useResizeObserver(),
|
|
11313
|
+
ref = _c.ref,
|
|
11314
|
+
width = _c.width,
|
|
11315
|
+
height = _c.height;
|
|
11212
11316
|
var signaturePad = useRef(null);
|
|
11213
11317
|
verbiage.headingText = verbiage.headingText || t('Please sign the box below');
|
|
11214
11318
|
verbiage.acceptBtnText = verbiage.acceptBtnText || t('Accept');
|
|
11215
11319
|
verbiage.clearBtnText = verbiage.clearBtnText || t('Clear');
|
|
11216
|
-
return /*#__PURE__*/React__default.createElement(
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
}, /*#__PURE__*/React__default.createElement(OverlayInner, null, /*#__PURE__*/React__default.createElement("div", {
|
|
11221
|
-
style: {
|
|
11222
|
-
flexGrow: 0,
|
|
11223
|
-
paddingBottom: 12
|
|
11224
|
-
}
|
|
11225
|
-
}, /*#__PURE__*/React__default.createElement("h3", {
|
|
11226
|
-
style: {
|
|
11227
|
-
margin: 0
|
|
11228
|
-
}
|
|
11229
|
-
}, verbiage.headingText)), /*#__PURE__*/React__default.createElement("div", {
|
|
11230
|
-
ref: ref,
|
|
11231
|
-
style: {
|
|
11232
|
-
position: 'relative',
|
|
11233
|
-
border: '3px solid #888',
|
|
11234
|
-
flexGrow: 1,
|
|
11235
|
-
zIndex: '100'
|
|
11236
|
-
}
|
|
11320
|
+
return /*#__PURE__*/React__default.createElement(PageContainer, null, /*#__PURE__*/React__default.createElement(SignaturePaperBacking, null, /*#__PURE__*/React__default.createElement(GuidanceMessageContainer, {
|
|
11321
|
+
"$top": "5vh"
|
|
11322
|
+
}, /*#__PURE__*/React__default.createElement(GuidanceMessage, null, verbiage.headingText)), /*#__PURE__*/React__default.createElement(SignatureCanvasContainer, null, /*#__PURE__*/React__default.createElement(SignaturePad, {
|
|
11323
|
+
ref: ref
|
|
11237
11324
|
}, /*#__PURE__*/React__default.createElement(SignatureCanvas, {
|
|
11238
11325
|
ref: signaturePad,
|
|
11239
11326
|
canvasProps: {
|
|
11240
11327
|
width: width,
|
|
11241
|
-
height:
|
|
11242
|
-
}
|
|
11243
|
-
})), /*#__PURE__*/React__default.createElement("div", {
|
|
11244
|
-
style: {
|
|
11245
|
-
flexGrow: 0,
|
|
11246
|
-
paddingTop: 12,
|
|
11247
|
-
display: 'flex'
|
|
11328
|
+
height: height
|
|
11248
11329
|
}
|
|
11249
|
-
}, /*#__PURE__*/React__default.createElement("button", {
|
|
11330
|
+
})), /*#__PURE__*/React__default.createElement(SignatureButtonsContainer, null, /*#__PURE__*/React__default.createElement("button", {
|
|
11250
11331
|
onClick: function onClick(e) {
|
|
11251
11332
|
var _a;
|
|
11252
11333
|
e.preventDefault();
|
|
@@ -11262,7 +11343,7 @@ var SignatureCapture = function SignatureCapture(_a) {
|
|
|
11262
11343
|
var signatureData = signatureDataToIdmissionFormat(signaturePad.current);
|
|
11263
11344
|
onAccept === null || onAccept === void 0 ? void 0 : onAccept(signatureData, signaturePad.current.toDataURL());
|
|
11264
11345
|
}
|
|
11265
|
-
}, verbiage.acceptBtnText))));
|
|
11346
|
+
}, verbiage.acceptBtnText)))));
|
|
11266
11347
|
};
|
|
11267
11348
|
|
|
11268
11349
|
var useVideoRecorder = function useVideoRecorder(camera) {
|
|
@@ -11306,7 +11387,6 @@ var useVideoRecorder = function useVideoRecorder(camera) {
|
|
|
11306
11387
|
};
|
|
11307
11388
|
};
|
|
11308
11389
|
|
|
11309
|
-
var SignatureCanvasContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 25%;\n left: 15%;\n width: 70%;\n height: 50%;\n\n @media (max-width: 800px) {\n top: 15%;\n left: 2%;\n width: 96%;\n height: 70%;\n }\n"], ["\n position: absolute;\n top: 25%;\n left: 15%;\n width: 70%;\n height: 50%;\n\n @media (max-width: 800px) {\n top: 15%;\n left: 2%;\n width: 96%;\n height: 70%;\n }\n"])));
|
|
11310
11390
|
var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
11311
11391
|
var _b, _c;
|
|
11312
11392
|
var onComplete = _a.onComplete,
|
|
@@ -11449,47 +11529,17 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
11449
11529
|
var guidanceMessage = t('Please sign the box below');
|
|
11450
11530
|
return /*#__PURE__*/React__default.createElement(PageContainer, {
|
|
11451
11531
|
className: "flex"
|
|
11452
|
-
}, /*#__PURE__*/React__default.createElement(CameraVideoTag, null), guidanceMessage !== '' && /*#__PURE__*/React__default.createElement(
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
fontWeight: 'bold',
|
|
11457
|
-
width: '100%',
|
|
11458
|
-
display: 'flex'
|
|
11459
|
-
}
|
|
11460
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
11461
|
-
style: {
|
|
11462
|
-
marginLeft: 'auto',
|
|
11463
|
-
marginRight: 'auto',
|
|
11464
|
-
background: '#ccc',
|
|
11465
|
-
padding: '10px 12px 8px',
|
|
11466
|
-
borderRadius: 8
|
|
11467
|
-
}
|
|
11468
|
-
}, guidanceMessage)), /*#__PURE__*/React__default.createElement(SignatureCanvasContainer, null, /*#__PURE__*/React__default.createElement("div", {
|
|
11469
|
-
ref: ref,
|
|
11470
|
-
style: {
|
|
11471
|
-
position: 'relative',
|
|
11472
|
-
background: 'rgba(255,255,255,0.5)',
|
|
11473
|
-
borderRadius: 16,
|
|
11474
|
-
flexGrow: 1,
|
|
11475
|
-
zIndex: '100',
|
|
11476
|
-
height: '100%'
|
|
11477
|
-
}
|
|
11532
|
+
}, /*#__PURE__*/React__default.createElement(CameraVideoTag, null), guidanceMessage !== '' && /*#__PURE__*/React__default.createElement(GuidanceMessageContainer, {
|
|
11533
|
+
"$top": "5vh"
|
|
11534
|
+
}, /*#__PURE__*/React__default.createElement(GuidanceMessage, null, guidanceMessage)), /*#__PURE__*/React__default.createElement(SignatureCanvasContainer, null, /*#__PURE__*/React__default.createElement(SignaturePad, {
|
|
11535
|
+
ref: ref
|
|
11478
11536
|
}, /*#__PURE__*/React__default.createElement(SignatureCanvas, {
|
|
11479
11537
|
ref: signaturePad,
|
|
11480
11538
|
canvasProps: {
|
|
11481
11539
|
width: width,
|
|
11482
11540
|
height: height
|
|
11483
11541
|
}
|
|
11484
|
-
})), /*#__PURE__*/React__default.createElement("
|
|
11485
|
-
style: {
|
|
11486
|
-
flexGrow: 0,
|
|
11487
|
-
paddingTop: 12,
|
|
11488
|
-
display: 'flex',
|
|
11489
|
-
zIndex: 1000,
|
|
11490
|
-
position: 'relative'
|
|
11491
|
-
}
|
|
11492
|
-
}, /*#__PURE__*/React__default.createElement("button", {
|
|
11542
|
+
})), /*#__PURE__*/React__default.createElement(SignatureButtonsContainer, null, /*#__PURE__*/React__default.createElement("button", {
|
|
11493
11543
|
onClick: function onClick(e) {
|
|
11494
11544
|
var _a;
|
|
11495
11545
|
e.preventDefault();
|
|
@@ -11521,7 +11571,6 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
11521
11571
|
}
|
|
11522
11572
|
})));
|
|
11523
11573
|
};
|
|
11524
|
-
var templateObject_1;
|
|
11525
11574
|
|
|
11526
11575
|
var SignatureKYCLoadingOverlay = function SignatureKYCLoadingOverlay(_a) {
|
|
11527
11576
|
var headingText = _a.headingText,
|