idmission-web-sdk 1.0.174 → 1.0.175
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/sdk2.cjs.development.js +30 -19
- 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 +30 -19
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +30 -19
- 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
|
@@ -48,7 +48,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
|
|
|
48
48
|
var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
49
49
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
50
50
|
|
|
51
|
-
var webSdkVersion = '1.0.
|
|
51
|
+
var webSdkVersion = '1.0.175';
|
|
52
52
|
|
|
53
53
|
function getPlatform() {
|
|
54
54
|
if (typeof window === 'undefined') return;
|
|
@@ -8698,6 +8698,8 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8698
8698
|
setThresholds = _d[1];
|
|
8699
8699
|
var working = React.useRef(false);
|
|
8700
8700
|
var onPredictionHandler = React.useRef();
|
|
8701
|
+
var cropCanvas = React.useRef(null);
|
|
8702
|
+
var rotateCanvas = React.useRef(null);
|
|
8701
8703
|
var lastPredictionCanvas = React.useRef(null);
|
|
8702
8704
|
var _e = React.useState(0),
|
|
8703
8705
|
detectionTime = _e[0],
|
|
@@ -8787,13 +8789,18 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8787
8789
|
working.current = true;
|
|
8788
8790
|
(function () {
|
|
8789
8791
|
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
8790
|
-
var prediction;
|
|
8792
|
+
var canvases, prediction;
|
|
8791
8793
|
var _a, _b, _c;
|
|
8792
8794
|
return tslib.__generator(this, function (_d) {
|
|
8793
8795
|
switch (_d.label) {
|
|
8794
8796
|
case 0:
|
|
8795
|
-
if (!documentDetectionModel || !focusModel || !lastPredictionCanvas.current) return [2 /*return*/];
|
|
8796
|
-
|
|
8797
|
+
if (!documentDetectionModel || !focusModel || !lastPredictionCanvas.current || !cropCanvas.current || !rotateCanvas.current) return [2 /*return*/];
|
|
8798
|
+
canvases = {
|
|
8799
|
+
lastPredictionCanvas: lastPredictionCanvas.current,
|
|
8800
|
+
cropCanvas: cropCanvas.current,
|
|
8801
|
+
rotateCanvas: rotateCanvas.current
|
|
8802
|
+
};
|
|
8803
|
+
return [4 /*yield*/, makePredictions(frame, thresholds, canvases, logPredictions)];
|
|
8797
8804
|
case 1:
|
|
8798
8805
|
prediction = _d.sent();
|
|
8799
8806
|
setDetectionTime(prediction.detectionTime);
|
|
@@ -8864,25 +8871,29 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8864
8871
|
ref: lastPredictionCanvas
|
|
8865
8872
|
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
8866
8873
|
ref: bestPredictionCanvas
|
|
8874
|
+
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
8875
|
+
ref: cropCanvas
|
|
8876
|
+
}), /*#__PURE__*/React__default['default'].createElement(InvisibleCanvas, {
|
|
8877
|
+
ref: rotateCanvas
|
|
8867
8878
|
}));
|
|
8868
8879
|
};
|
|
8869
8880
|
var onMobile = isMobile();
|
|
8870
|
-
function makePredictions(frame,
|
|
8881
|
+
function makePredictions(frame, thresholds, canvases, logPredictions) {
|
|
8871
8882
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
8872
8883
|
if (logPredictions === void 0) {
|
|
8873
8884
|
logPredictions = false;
|
|
8874
8885
|
}
|
|
8875
8886
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
8876
|
-
var _o, frameWidth, frameHeight,
|
|
8877
|
-
var
|
|
8878
|
-
return tslib.__generator(this, function (
|
|
8879
|
-
switch (
|
|
8887
|
+
var _o, frameWidth, frameHeight, _p, boxes, scores, labels, time, allZero, detectedObjects, bestDocument, bestPassportPage, bestDocumentScore, passportDetectionScore, passportDetectionThresholdMet, bestDocumentOrPassport, detectionScore, detectionThresholdMet, detectedDocumentType, bestMrz, mrzDetectionScore, mrzDetectionThresholdMet, bestPdf417, pdf417DetectionScore, pdf417DetectionThresholdMet, documentInBounds, boundaryPx, _q, boundaryX, boundaryY, boundaryWidth, boundaryHeight, documentTooClose, _r, docWidth, docHeight, focusPrediction, focusPredictionTime, focusScore, focusThresholdMet, focusThreshold;
|
|
8888
|
+
var _s;
|
|
8889
|
+
return tslib.__generator(this, function (_t) {
|
|
8890
|
+
switch (_t.label) {
|
|
8880
8891
|
case 0:
|
|
8881
8892
|
_o = getFrameDimensions(frame), frameWidth = _o[0], frameHeight = _o[1];
|
|
8882
|
-
drawToCanvas(lastPredictionCanvas, frame);
|
|
8893
|
+
drawToCanvas(canvases.lastPredictionCanvas, frame);
|
|
8883
8894
|
return [4 /*yield*/, makeDocumentDetectionPredictions(frame, logPredictions)];
|
|
8884
8895
|
case 1:
|
|
8885
|
-
|
|
8896
|
+
_p = _t.sent(), boxes = _p.boxes, scores = _p.scores, labels = _p.labels, time = _p.time;
|
|
8886
8897
|
allZero = boxes.length > 0 && !boxes.some(function (box) {
|
|
8887
8898
|
return box.some(function (n) {
|
|
8888
8899
|
return n > 0;
|
|
@@ -8922,7 +8933,7 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
8922
8933
|
documentInBounds = false;
|
|
8923
8934
|
if (bestDocumentOrPassport) {
|
|
8924
8935
|
boundaryPx = 20;
|
|
8925
|
-
|
|
8936
|
+
_q = bestDocumentOrPassport.bbox, boundaryX = _q[0], boundaryY = _q[1], boundaryWidth = _q[2], boundaryHeight = _q[3];
|
|
8926
8937
|
boundaryX *= frameWidth;
|
|
8927
8938
|
boundaryWidth *= frameWidth;
|
|
8928
8939
|
boundaryY *= frameHeight;
|
|
@@ -8937,18 +8948,18 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
8937
8948
|
}
|
|
8938
8949
|
documentTooClose = false;
|
|
8939
8950
|
if (bestDocumentOrPassport) {
|
|
8940
|
-
|
|
8951
|
+
_r = [bestDocumentOrPassport.bbox[2], bestDocumentOrPassport.bbox[3]], docWidth = _r[0], docHeight = _r[1];
|
|
8941
8952
|
documentTooClose = docWidth > 0.85 || docHeight > 0.85;
|
|
8942
8953
|
}
|
|
8943
8954
|
focusPrediction = null, focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
|
|
8944
8955
|
if (!(detectionThresholdMet && documentInBounds && !documentTooClose)) return [3 /*break*/, 3];
|
|
8945
|
-
return [4 /*yield*/, makeFocusPrediction(frame, bestDocumentOrPassport === null || bestDocumentOrPassport === void 0 ? void 0 : bestDocumentOrPassport.bbox, logPredictions)];
|
|
8956
|
+
return [4 /*yield*/, makeFocusPrediction(frame, canvases, bestDocumentOrPassport === null || bestDocumentOrPassport === void 0 ? void 0 : bestDocumentOrPassport.bbox, logPredictions)];
|
|
8946
8957
|
case 2:
|
|
8947
|
-
|
|
8958
|
+
_s = _t.sent(), focusPrediction = _s[0], focusPredictionTime = _s[1];
|
|
8948
8959
|
focusScore = (_j = focusPrediction === null || focusPrediction === void 0 ? void 0 : focusPrediction[1]) !== null && _j !== void 0 ? _j : 0;
|
|
8949
8960
|
focusThreshold = (_m = onMobile ? (_k = thresholds.focus) === null || _k === void 0 ? void 0 : _k.mobile : (_l = thresholds.focus) === null || _l === void 0 ? void 0 : _l.desktop) !== null && _m !== void 0 ? _m : 0;
|
|
8950
8961
|
focusThresholdMet = focusScore >= focusThreshold;
|
|
8951
|
-
|
|
8962
|
+
_t.label = 3;
|
|
8952
8963
|
case 3:
|
|
8953
8964
|
return [2 /*return*/, {
|
|
8954
8965
|
detectedObjects: detectedObjects,
|
|
@@ -9058,7 +9069,7 @@ function makeDocumentDetectionPredictions(image, logPredictions) {
|
|
|
9058
9069
|
});
|
|
9059
9070
|
});
|
|
9060
9071
|
}
|
|
9061
|
-
function makeFocusPrediction(imageData, bbox, logPredictions) {
|
|
9072
|
+
function makeFocusPrediction(imageData, canvases, bbox, logPredictions) {
|
|
9062
9073
|
if (logPredictions === void 0) {
|
|
9063
9074
|
logPredictions = false;
|
|
9064
9075
|
}
|
|
@@ -9076,11 +9087,11 @@ function makeFocusPrediction(imageData, bbox, logPredictions) {
|
|
|
9076
9087
|
_g.trys.push([1, 5,, 6]);
|
|
9077
9088
|
tfImg = void 0;
|
|
9078
9089
|
if (bbox) {
|
|
9079
|
-
cropped = cropToBoundingBox(imageData, bbox);
|
|
9090
|
+
cropped = cropToBoundingBox(imageData, bbox, canvases.cropCanvas);
|
|
9080
9091
|
_a = getFrameDimensions(imageData), fw = _a[0], fh = _a[1];
|
|
9081
9092
|
_b = [bbox[2] * fw, bbox[3] * fh], bw = _b[0], bh = _b[1];
|
|
9082
9093
|
if (bh > bw) {
|
|
9083
|
-
rotated =
|
|
9094
|
+
rotated = canvases.rotateCanvas;
|
|
9084
9095
|
ctx = rotated.getContext('2d');
|
|
9085
9096
|
if (ctx) {
|
|
9086
9097
|
rotated.width = bh;
|