idmission-web-sdk 1.0.373 → 1.0.374
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 +1 -1
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +1 -1
- package/dist/lib/models/CapabilityProbing.d.ts +5 -2
- package/dist/lib/models/DocumentDetection.d.ts +1 -1
- package/dist/sdk2.cjs.development.js +57 -36
- 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 +57 -36
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +57 -36
- 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/stories/Experiments/SpeedTest.stories.d.ts +7 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ export type DocumentDetectionPrediction = {
|
|
|
37
37
|
mrzDetectionThresholdMet: boolean;
|
|
38
38
|
pdf417DetectionScore: number;
|
|
39
39
|
pdf417DetectionThresholdMet: boolean;
|
|
40
|
-
|
|
40
|
+
bestDocument: DetectedObject | undefined;
|
|
41
41
|
bestMrz: DetectedObject | undefined;
|
|
42
42
|
bestPdf417: DetectedObject | undefined;
|
|
43
43
|
documentInBounds: boolean;
|
|
@@ -15,7 +15,7 @@ export type IdCapturePrediction = {
|
|
|
15
15
|
mrzDetectionThresholdMet: boolean;
|
|
16
16
|
pdf417DetectionScore: number;
|
|
17
17
|
pdf417DetectionThresholdMet: boolean;
|
|
18
|
-
|
|
18
|
+
bestDocument: DetectedObject | undefined;
|
|
19
19
|
bestMrz: DetectedObject | undefined;
|
|
20
20
|
bestPdf417: DetectedObject | undefined;
|
|
21
21
|
documentInBounds: boolean;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
type ProbeState = 'notProbed' | 'probing' | 'probed';
|
|
2
|
+
export type NetworkTier = 'untested' | 'unusable' | 'slow' | 'medium' | 'fast';
|
|
2
3
|
type ModelCapabilities = {
|
|
3
4
|
probeState: ProbeState;
|
|
4
5
|
delegate: 'GPU' | 'CPU' | 'NONE';
|
|
6
|
+
networkTier: NetworkTier;
|
|
5
7
|
networkSpeed: number;
|
|
6
|
-
|
|
8
|
+
networkTestTime: number;
|
|
7
9
|
};
|
|
8
10
|
export declare const defaultImageSegmenterModelPath = "https://websdk-cdn-dev.idmission.com/assets/models/selfiesegmenter20240524/selfie_segmenter.tflite";
|
|
9
|
-
export declare
|
|
11
|
+
export declare let modelCapabilities: ModelCapabilities;
|
|
10
12
|
export declare function probeModelCapabilities(): Promise<void>;
|
|
13
|
+
export declare function resetModelCapabilityProbe(): void;
|
|
11
14
|
export {};
|
|
@@ -49,7 +49,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
|
|
|
49
49
|
var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
50
50
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
51
51
|
|
|
52
|
-
var webSdkVersion = '1.0.
|
|
52
|
+
var webSdkVersion = '1.0.374';
|
|
53
53
|
|
|
54
54
|
function getPlatform() {
|
|
55
55
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -2137,12 +2137,14 @@ var imageSegmenterModelSizeInBytes = 256440.32;
|
|
|
2137
2137
|
// The idea here is that we globally set a cache key based on the time at page load. That way our built-in speed test
|
|
2138
2138
|
// isn't fooled by cache times, but subsequent downloads of the vision runtime still do load from the cache.
|
|
2139
2139
|
var tinyModelCacheKey = new Date().getTime();
|
|
2140
|
-
var
|
|
2140
|
+
var initialModelCapabilities = {
|
|
2141
2141
|
probeState: 'notProbed',
|
|
2142
2142
|
delegate: 'GPU',
|
|
2143
|
+
networkTier: 'untested',
|
|
2143
2144
|
networkSpeed: 0,
|
|
2144
|
-
|
|
2145
|
+
networkTestTime: 0 // represented in seconds.
|
|
2145
2146
|
};
|
|
2147
|
+
var modelCapabilities = tslib.__assign({}, initialModelCapabilities);
|
|
2146
2148
|
function probeModelCapabilities() {
|
|
2147
2149
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2148
2150
|
var error_1, error_2;
|
|
@@ -2197,37 +2199,55 @@ function probeModelCapabilities() {
|
|
|
2197
2199
|
});
|
|
2198
2200
|
});
|
|
2199
2201
|
}
|
|
2200
|
-
function loadTinyModel(delegate) {
|
|
2202
|
+
function loadTinyModel(delegate, maxTime) {
|
|
2201
2203
|
if (delegate === void 0) {
|
|
2202
2204
|
delegate = 'GPU';
|
|
2203
2205
|
}
|
|
2206
|
+
if (maxTime === void 0) {
|
|
2207
|
+
maxTime = 10000;
|
|
2208
|
+
}
|
|
2204
2209
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2205
|
-
var modelAssetPath, startedAt, time, speedMbps, model, _a, _b, emptyFrame;
|
|
2210
|
+
var modelAssetPath, startedAt, e_1, time, speedMbps, model, _a, _b, emptyFrame;
|
|
2206
2211
|
return tslib.__generator(this, function (_c) {
|
|
2207
2212
|
switch (_c.label) {
|
|
2208
2213
|
case 0:
|
|
2209
2214
|
modelAssetPath = "".concat(defaultImageSegmenterModelPath, "?_=").concat(tinyModelCacheKey);
|
|
2210
2215
|
startedAt = new Date();
|
|
2211
|
-
|
|
2216
|
+
_c.label = 1;
|
|
2212
2217
|
case 1:
|
|
2218
|
+
_c.trys.push([1, 3,, 4]);
|
|
2219
|
+
return [4 /*yield*/, Promise.race([preloadDependency(modelAssetPath), new Promise(function (_resolve, reject) {
|
|
2220
|
+
setTimeout(function () {
|
|
2221
|
+
reject(new Error('gave up after reaching maximum time allowed'));
|
|
2222
|
+
}, maxTime);
|
|
2223
|
+
})])];
|
|
2224
|
+
case 2:
|
|
2213
2225
|
_c.sent();
|
|
2226
|
+
return [3 /*break*/, 4];
|
|
2227
|
+
case 3:
|
|
2228
|
+
e_1 = _c.sent();
|
|
2229
|
+
error('speed test failed', e_1);
|
|
2230
|
+
modelCapabilities.networkTier = 'unusable';
|
|
2231
|
+
return [2 /*return*/];
|
|
2232
|
+
case 4:
|
|
2214
2233
|
time = (new Date().getTime() - startedAt.getTime()) / 1000.0;
|
|
2234
|
+
modelCapabilities.networkTestTime || (modelCapabilities.networkTestTime = time);
|
|
2215
2235
|
modelCapabilities.networkSpeed || (modelCapabilities.networkSpeed = imageSegmenterModelSizeInBytes / time);
|
|
2216
|
-
modelCapabilities.networkTier = time <
|
|
2236
|
+
modelCapabilities.networkTier = time < 0.5 ? 'fast' : time < 2 ? 'medium' : 'slow';
|
|
2217
2237
|
speedMbps = modelCapabilities.networkSpeed / 1024 / 1024;
|
|
2218
2238
|
log('Model Probing: network speed', speedMbps.toFixed(3), 'Mbps');
|
|
2219
2239
|
log('Model Probing: network test took', time);
|
|
2220
2240
|
log('Model Probing: network tier', modelCapabilities.networkTier);
|
|
2221
2241
|
_b = (_a = tasksVision.ImageSegmenter).createFromOptions;
|
|
2222
2242
|
return [4 /*yield*/, tasksVision.FilesetResolver.forVisionTasks(visionTasksBasePath)];
|
|
2223
|
-
case
|
|
2243
|
+
case 5:
|
|
2224
2244
|
return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
|
|
2225
2245
|
baseOptions: {
|
|
2226
2246
|
modelAssetPath: modelAssetPath,
|
|
2227
2247
|
delegate: delegate
|
|
2228
2248
|
}
|
|
2229
2249
|
}])];
|
|
2230
|
-
case
|
|
2250
|
+
case 6:
|
|
2231
2251
|
model = _c.sent();
|
|
2232
2252
|
emptyFrame = document.createElement('canvas');
|
|
2233
2253
|
model.segment(emptyFrame);
|
|
@@ -2952,7 +2972,7 @@ function makePrediction(detector, frame) {
|
|
|
2952
2972
|
});
|
|
2953
2973
|
}
|
|
2954
2974
|
function processPrediction(prediction, thresholds) {
|
|
2955
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
2975
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2956
2976
|
var detections = prediction.detections,
|
|
2957
2977
|
frameWidth = prediction.frameWidth,
|
|
2958
2978
|
frameHeight = prediction.frameHeight,
|
|
@@ -2980,18 +3000,19 @@ function processPrediction(prediction, thresholds) {
|
|
|
2980
3000
|
return n > 0;
|
|
2981
3001
|
});
|
|
2982
3002
|
});
|
|
2983
|
-
var
|
|
3003
|
+
var bestIdCard = detectedObjects.find(function (obj) {
|
|
2984
3004
|
return obj.label === 'Document';
|
|
2985
3005
|
});
|
|
2986
3006
|
var bestPassportPage = detectedObjects.find(function (obj) {
|
|
2987
3007
|
return obj.label === 'Passport page';
|
|
2988
3008
|
});
|
|
2989
|
-
var
|
|
3009
|
+
var idCardScore = (_a = bestIdCard === null || bestIdCard === void 0 ? void 0 : bestIdCard.score) !== null && _a !== void 0 ? _a : 0;
|
|
2990
3010
|
var passportDetectionScore = (_b = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _b !== void 0 ? _b : 0;
|
|
2991
3011
|
var passportDetectionThresholdMet = passportDetectionScore >= ((_c = thresholds.passport) !== null && _c !== void 0 ? _c : 0);
|
|
2992
|
-
var
|
|
2993
|
-
var detectionScore = passportDetectionThresholdMet ? passportDetectionScore :
|
|
2994
|
-
var
|
|
3012
|
+
var bestDocument = idCardScore > passportDetectionScore ? bestIdCard : bestPassportPage;
|
|
3013
|
+
var detectionScore = passportDetectionThresholdMet ? passportDetectionScore : idCardScore;
|
|
3014
|
+
var detectionThreshold = passportDetectionThresholdMet ? thresholds.passport : thresholds.idCard;
|
|
3015
|
+
var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
|
|
2995
3016
|
var detectedDocumentType = 'none';
|
|
2996
3017
|
if (passportDetectionThresholdMet) {
|
|
2997
3018
|
detectedDocumentType = 'passport';
|
|
@@ -3001,21 +3022,21 @@ function processPrediction(prediction, thresholds) {
|
|
|
3001
3022
|
var bestMrz = detectedObjects.find(function (obj) {
|
|
3002
3023
|
return obj.label === 'MRZ';
|
|
3003
3024
|
});
|
|
3004
|
-
var mrzDetectionScore = (
|
|
3005
|
-
var mrzDetectionThresholdMet = mrzDetectionScore >= ((
|
|
3025
|
+
var mrzDetectionScore = (_d = bestMrz === null || bestMrz === void 0 ? void 0 : bestMrz.score) !== null && _d !== void 0 ? _d : 0;
|
|
3026
|
+
var mrzDetectionThresholdMet = mrzDetectionScore >= ((_e = thresholds.mrz) !== null && _e !== void 0 ? _e : 0);
|
|
3006
3027
|
var bestPdf417 = detectedObjects.find(function (obj) {
|
|
3007
3028
|
return obj.label === 'PDF417';
|
|
3008
3029
|
});
|
|
3009
|
-
var pdf417DetectionScore = (
|
|
3010
|
-
var pdf417DetectionThresholdMet = pdf417DetectionScore >= ((
|
|
3030
|
+
var pdf417DetectionScore = (_f = bestPdf417 === null || bestPdf417 === void 0 ? void 0 : bestPdf417.score) !== null && _f !== void 0 ? _f : 0;
|
|
3031
|
+
var pdf417DetectionThresholdMet = pdf417DetectionScore >= ((_g = thresholds.pdf417) !== null && _g !== void 0 ? _g : 0);
|
|
3011
3032
|
var documentInBounds = false;
|
|
3012
|
-
if (
|
|
3033
|
+
if (bestDocument) {
|
|
3013
3034
|
var boundaryPx = 20;
|
|
3014
|
-
var
|
|
3015
|
-
boundaryX =
|
|
3016
|
-
boundaryY =
|
|
3017
|
-
boundaryWidth =
|
|
3018
|
-
boundaryHeight =
|
|
3035
|
+
var _h = bestDocument.box,
|
|
3036
|
+
boundaryX = _h.xMin,
|
|
3037
|
+
boundaryY = _h.yMin,
|
|
3038
|
+
boundaryWidth = _h.width,
|
|
3039
|
+
boundaryHeight = _h.height;
|
|
3019
3040
|
documentInBounds = boundaryY > boundaryPx &&
|
|
3020
3041
|
// Is it valid top edge of ID detected?
|
|
3021
3042
|
boundaryY + boundaryHeight + boundaryPx < frameHeight && (
|
|
@@ -3025,10 +3046,10 @@ function processPrediction(prediction, thresholds) {
|
|
|
3025
3046
|
boundaryX + boundaryWidth + boundaryPx < frameWidth; // Valid right edge if it's less than video width.
|
|
3026
3047
|
}
|
|
3027
3048
|
var documentTooClose = false;
|
|
3028
|
-
if (
|
|
3029
|
-
var
|
|
3030
|
-
docWidth =
|
|
3031
|
-
docHeight =
|
|
3049
|
+
if (bestDocument) {
|
|
3050
|
+
var _j = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
|
|
3051
|
+
docWidth = _j[0],
|
|
3052
|
+
docHeight = _j[1];
|
|
3032
3053
|
documentTooClose = docWidth > 0.85 || docHeight > 0.85;
|
|
3033
3054
|
}
|
|
3034
3055
|
return {
|
|
@@ -3043,7 +3064,7 @@ function processPrediction(prediction, thresholds) {
|
|
|
3043
3064
|
mrzDetectionThresholdMet: mrzDetectionThresholdMet,
|
|
3044
3065
|
pdf417DetectionScore: pdf417DetectionScore,
|
|
3045
3066
|
pdf417DetectionThresholdMet: pdf417DetectionThresholdMet,
|
|
3046
|
-
|
|
3067
|
+
bestDocument: bestDocument,
|
|
3047
3068
|
bestMrz: bestMrz,
|
|
3048
3069
|
bestPdf417: bestPdf417,
|
|
3049
3070
|
documentInBounds: documentInBounds,
|
|
@@ -3354,7 +3375,7 @@ function IdCaptureModelsProviderInner(_a) {
|
|
|
3354
3375
|
if (!lastPredictionCanvas.current) return [2 /*return*/];
|
|
3355
3376
|
focusPrediction = null, focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
|
|
3356
3377
|
if (!(prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose)) return [3 /*break*/, 2];
|
|
3357
|
-
return [4 /*yield*/, makeFocusPrediction(lastPredictionCanvas.current, (_a = prediction.
|
|
3378
|
+
return [4 /*yield*/, makeFocusPrediction(lastPredictionCanvas.current, (_a = prediction.bestDocument) === null || _a === void 0 ? void 0 : _a.box)];
|
|
3358
3379
|
case 1:
|
|
3359
3380
|
focusPrediction = _g.sent();
|
|
3360
3381
|
if (focusPrediction) {
|
|
@@ -3367,7 +3388,7 @@ function IdCaptureModelsProviderInner(_a) {
|
|
|
3367
3388
|
case 2:
|
|
3368
3389
|
if (bestFocusScore.current <= focusScore) {
|
|
3369
3390
|
bestFocusScore.current = focusScore;
|
|
3370
|
-
setBestFrameBoundingBox((_e = prediction.
|
|
3391
|
+
setBestFrameBoundingBox((_e = prediction.bestDocument) === null || _e === void 0 ? void 0 : _e.box);
|
|
3371
3392
|
setBestFrameDetectionScore(prediction.detectionScore);
|
|
3372
3393
|
setBestFrameFocusScore(focusScore);
|
|
3373
3394
|
drawToCanvas(bestPredictionCanvas.current, lastPredictionCanvas.current);
|
|
@@ -3590,7 +3611,7 @@ var reducer$4 = function reducer(state, action) {
|
|
|
3590
3611
|
mrzDetectionThresholdMet = _d.mrzDetectionThresholdMet,
|
|
3591
3612
|
pdf417DetectionScore = _d.pdf417DetectionScore,
|
|
3592
3613
|
pdf417DetectionThresholdMet = _d.pdf417DetectionThresholdMet,
|
|
3593
|
-
|
|
3614
|
+
bestDocument = _d.bestDocument,
|
|
3594
3615
|
bestMrz = _d.bestMrz,
|
|
3595
3616
|
bestPdf417 = _d.bestPdf417,
|
|
3596
3617
|
documentInBounds = _d.documentInBounds,
|
|
@@ -3620,7 +3641,7 @@ var reducer$4 = function reducer(state, action) {
|
|
|
3620
3641
|
videoWidth: frameWidth,
|
|
3621
3642
|
videoHeight: frameHeight,
|
|
3622
3643
|
detectedObjects: detectedObjects,
|
|
3623
|
-
bestDocument:
|
|
3644
|
+
bestDocument: bestDocument,
|
|
3624
3645
|
bestMrz: bestMrz,
|
|
3625
3646
|
bestPdf417: bestPdf417,
|
|
3626
3647
|
documentType: detectedDocumentType,
|
|
@@ -4283,7 +4304,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
4283
4304
|
});
|
|
4284
4305
|
resetBestFrame();
|
|
4285
4306
|
setThresholds({
|
|
4286
|
-
|
|
4307
|
+
idCard: autoCaptureScoreThreshold,
|
|
4287
4308
|
passport: passportPageDetectionThreshold,
|
|
4288
4309
|
mrz: mrzDetectionScoreThreshold,
|
|
4289
4310
|
pdf417: pdf417DetectionThreshold,
|
|
@@ -10354,7 +10375,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
10354
10375
|
}, [requestedAction, startIdModels, stopIdModels]);
|
|
10355
10376
|
React.useEffect(function () {
|
|
10356
10377
|
setThresholds({
|
|
10357
|
-
|
|
10378
|
+
idCard: requestedAction === 'SHOW_ID_FRONT' ? idCardFrontDetectionThreshold : requestedAction === 'SHOW_ID_BACK' ? idCardBackDetectionThreshold : 1,
|
|
10358
10379
|
passport: 1,
|
|
10359
10380
|
focus: {
|
|
10360
10381
|
mobile: requestedAction === 'SHOW_ID_FRONT' ? idCardFrontFocusThreshold : requestedAction === 'SHOW_ID_BACK' ? idCardBackFocusThreshold : 0
|