idmission-web-sdk 2.2.30 → 2.2.31
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.map +1 -1
- package/dist/components/id_capture/FocusModelProvider.d.ts.map +1 -1
- package/dist/components/selfie_capture/SelfieGuidanceModelsProvider.d.ts.map +1 -1
- package/dist/lib/models/DocumentDetection.d.ts +2 -3
- package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
- package/dist/lib/models/FaceDetection.d.ts +3 -4
- package/dist/lib/models/FaceDetection.d.ts.map +1 -1
- package/dist/lib/models/Focus.d.ts +2 -3
- package/dist/lib/models/Focus.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +91 -110
- 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 +91 -110
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +91 -110
- 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
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
var webSdkVersion = '2.2.
|
|
214
|
+
var webSdkVersion = '2.2.31';
|
|
215
215
|
|
|
216
216
|
function getPlatform() {
|
|
217
217
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -8858,30 +8858,29 @@
|
|
|
8858
8858
|
mobile: 0.3
|
|
8859
8859
|
}
|
|
8860
8860
|
};
|
|
8861
|
-
var
|
|
8861
|
+
var classifier = null;
|
|
8862
|
+
var classifierSettings = null;
|
|
8862
8863
|
function loadFocusModel() {
|
|
8863
8864
|
return __awaiter(this, arguments, void 0, function (modelAssetPath) {
|
|
8864
|
-
var
|
|
8865
|
+
var _a, _b;
|
|
8865
8866
|
if (modelAssetPath === void 0) {
|
|
8866
8867
|
modelAssetPath = defaultFocusModelPath;
|
|
8867
8868
|
}
|
|
8868
|
-
return __generator(this, function (
|
|
8869
|
-
switch (
|
|
8869
|
+
return __generator(this, function (_c) {
|
|
8870
|
+
switch (_c.label) {
|
|
8870
8871
|
case 0:
|
|
8871
|
-
|
|
8872
|
-
|
|
8872
|
+
if (classifier && (classifierSettings === null || classifierSettings === void 0 ? void 0 : classifierSettings.modelAssetPath) === modelAssetPath) return [2 /*return*/, classifier];
|
|
8873
|
+
closeFocusModel();
|
|
8873
8874
|
return [4 /*yield*/, preloadFocusModelDependencies()];
|
|
8874
8875
|
case 1:
|
|
8875
|
-
|
|
8876
|
+
_c.sent();
|
|
8876
8877
|
if (modelCapabilities.delegate === 'NONE') {
|
|
8877
8878
|
throw new Error('No available delegate for focus detector.');
|
|
8878
8879
|
}
|
|
8879
|
-
_a =
|
|
8880
|
-
_b = id;
|
|
8881
|
-
_d = (_c = Ua).createFromOptions;
|
|
8880
|
+
_b = (_a = Ua).createFromOptions;
|
|
8882
8881
|
return [4 /*yield*/, ao.forVisionTasks(visionTasksBasePath)];
|
|
8883
8882
|
case 2:
|
|
8884
|
-
return [4 /*yield*/,
|
|
8883
|
+
return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
|
|
8885
8884
|
baseOptions: {
|
|
8886
8885
|
modelAssetPath: modelAssetPath,
|
|
8887
8886
|
delegate: modelCapabilities.delegate
|
|
@@ -8890,20 +8889,19 @@
|
|
|
8890
8889
|
runningMode: 'VIDEO'
|
|
8891
8890
|
}])];
|
|
8892
8891
|
case 3:
|
|
8893
|
-
|
|
8894
|
-
|
|
8892
|
+
classifier = _c.sent();
|
|
8893
|
+
classifierSettings = {
|
|
8894
|
+
modelAssetPath: modelAssetPath
|
|
8895
|
+
};
|
|
8896
|
+
return [2 /*return*/, classifier];
|
|
8895
8897
|
}
|
|
8896
8898
|
});
|
|
8897
8899
|
});
|
|
8898
8900
|
}
|
|
8899
|
-
function closeFocusModel(
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
var id = "".concat(modelAssetPath);
|
|
8904
|
-
if (!models[id]) return;
|
|
8905
|
-
models[id].close();
|
|
8906
|
-
delete models[id];
|
|
8901
|
+
function closeFocusModel() {
|
|
8902
|
+
classifier === null || classifier === void 0 ? void 0 : classifier.close();
|
|
8903
|
+
classifier = null;
|
|
8904
|
+
classifierSettings = null;
|
|
8907
8905
|
}
|
|
8908
8906
|
function useLoadFocusModel(_a) {
|
|
8909
8907
|
var _b = _a.modelPath,
|
|
@@ -8911,7 +8909,6 @@
|
|
|
8911
8909
|
_c = _a.modelLoadTimeoutMs,
|
|
8912
8910
|
modelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
|
|
8913
8911
|
onModelError = _a.onModelError;
|
|
8914
|
-
var model = React.useRef(null);
|
|
8915
8912
|
var _d = React.useState(false),
|
|
8916
8913
|
ready = _d[0],
|
|
8917
8914
|
setReady = _d[1];
|
|
@@ -8937,7 +8934,6 @@
|
|
|
8937
8934
|
return __generator(this, function (_a) {
|
|
8938
8935
|
switch (_a.label) {
|
|
8939
8936
|
case 0:
|
|
8940
|
-
model.current = loadedModel;
|
|
8941
8937
|
setModelDownloadProgress(100);
|
|
8942
8938
|
clearTimeout(modelLoadTimeout);
|
|
8943
8939
|
return [4 /*yield*/, waitForVideoReady(videoRef)];
|
|
@@ -8957,9 +8953,8 @@
|
|
|
8957
8953
|
clearTimeout(modelLoadTimeout);
|
|
8958
8954
|
});
|
|
8959
8955
|
return function () {
|
|
8960
|
-
log('unloading focus model'
|
|
8961
|
-
|
|
8962
|
-
closeFocusModel(modelPath);
|
|
8956
|
+
log('unloading focus model');
|
|
8957
|
+
closeFocusModel();
|
|
8963
8958
|
clearTimeout(modelLoadTimeout);
|
|
8964
8959
|
document.removeEventListener('idmission.preloadProgress.focus', handleDownloadProgress);
|
|
8965
8960
|
};
|
|
@@ -8968,7 +8963,6 @@
|
|
|
8968
8963
|
modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
|
|
8969
8964
|
}, [modelError, onModelError]);
|
|
8970
8965
|
return {
|
|
8971
|
-
model: model,
|
|
8972
8966
|
ready: ready,
|
|
8973
8967
|
modelDownloadProgress: modelDownloadProgress,
|
|
8974
8968
|
modelError: modelError
|
|
@@ -8980,11 +8974,12 @@
|
|
|
8980
8974
|
lastFocusPredictionTime = time - lastFocusPredictionAt;
|
|
8981
8975
|
lastFocusPredictionAt = time;
|
|
8982
8976
|
}
|
|
8983
|
-
function makeFocusModelPrediction(
|
|
8977
|
+
function makeFocusModelPrediction(imageData, cropCanvas, rotateCanvas, box) {
|
|
8984
8978
|
var _a, _b, _c, _d, _e;
|
|
8979
|
+
if (!classifier) return null;
|
|
8985
8980
|
var startedAt = new Date();
|
|
8986
8981
|
var image = cropIfNecessary(imageData, cropCanvas, rotateCanvas, box);
|
|
8987
|
-
var result =
|
|
8982
|
+
var result = classifier.classifyForVideo(image, performance.now());
|
|
8988
8983
|
var score = (_e = (_d = (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.classifications) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.categories) === null || _c === void 0 ? void 0 : _c.find(function (c) {
|
|
8989
8984
|
return c.categoryName === 'focused';
|
|
8990
8985
|
})) === null || _d === void 0 ? void 0 : _d.score) !== null && _e !== void 0 ? _e : 0;
|
|
@@ -9013,30 +9008,29 @@
|
|
|
9013
9008
|
}
|
|
9014
9009
|
|
|
9015
9010
|
var defaultSelfieCaptureModelLoadTimeoutMs = 45000;
|
|
9016
|
-
var
|
|
9011
|
+
var detector$1 = null;
|
|
9012
|
+
var detectorSettings$1 = null;
|
|
9017
9013
|
function loadFaceDetector() {
|
|
9018
9014
|
return __awaiter(this, arguments, void 0, function (modelAssetPath) {
|
|
9019
|
-
var
|
|
9015
|
+
var _a, _b;
|
|
9020
9016
|
if (modelAssetPath === void 0) {
|
|
9021
9017
|
modelAssetPath = defaultFaceDetectorModelPath;
|
|
9022
9018
|
}
|
|
9023
|
-
return __generator(this, function (
|
|
9024
|
-
switch (
|
|
9019
|
+
return __generator(this, function (_c) {
|
|
9020
|
+
switch (_c.label) {
|
|
9025
9021
|
case 0:
|
|
9026
|
-
|
|
9027
|
-
|
|
9022
|
+
if (detector$1 && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.modelAssetPath) === modelAssetPath) return [2 /*return*/, detector$1];
|
|
9023
|
+
closeFaceDetector();
|
|
9028
9024
|
return [4 /*yield*/, preloadFaceDetectorDependencies()];
|
|
9029
9025
|
case 1:
|
|
9030
|
-
|
|
9026
|
+
_c.sent();
|
|
9031
9027
|
if (modelCapabilities.delegate === 'NONE') {
|
|
9032
9028
|
throw new Error('No available delegate for face detector.');
|
|
9033
9029
|
}
|
|
9034
|
-
_a =
|
|
9035
|
-
_b = id;
|
|
9036
|
-
_d = (_c = ya).createFromOptions;
|
|
9030
|
+
_b = (_a = ya).createFromOptions;
|
|
9037
9031
|
return [4 /*yield*/, ao.forVisionTasks(visionTasksBasePath)];
|
|
9038
9032
|
case 2:
|
|
9039
|
-
return [4 /*yield*/,
|
|
9033
|
+
return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
|
|
9040
9034
|
// canvas: document.createElement('canvas'),
|
|
9041
9035
|
baseOptions: {
|
|
9042
9036
|
modelAssetPath: modelAssetPath,
|
|
@@ -9045,26 +9039,24 @@
|
|
|
9045
9039
|
runningMode: 'VIDEO'
|
|
9046
9040
|
}])];
|
|
9047
9041
|
case 3:
|
|
9048
|
-
|
|
9049
|
-
|
|
9042
|
+
detector$1 = _c.sent();
|
|
9043
|
+
detectorSettings$1 = {
|
|
9044
|
+
modelAssetPath: modelAssetPath
|
|
9045
|
+
};
|
|
9046
|
+
return [2 /*return*/, detector$1];
|
|
9050
9047
|
}
|
|
9051
9048
|
});
|
|
9052
9049
|
});
|
|
9053
9050
|
}
|
|
9054
|
-
function closeFaceDetector(
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
var id = "".concat(modelAssetPath);
|
|
9059
|
-
if (!detectors$1[id]) return;
|
|
9060
|
-
detectors$1[id].close();
|
|
9061
|
-
delete detectors$1[id];
|
|
9051
|
+
function closeFaceDetector() {
|
|
9052
|
+
detector$1 === null || detector$1 === void 0 ? void 0 : detector$1.close();
|
|
9053
|
+
detector$1 = null;
|
|
9054
|
+
detectorSettings$1 = null;
|
|
9062
9055
|
}
|
|
9063
9056
|
function useLoadFaceDetector(_a) {
|
|
9064
9057
|
var onModelError = _a.onModelError,
|
|
9065
9058
|
_b = _a.modelLoadTimeoutMs,
|
|
9066
9059
|
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b;
|
|
9067
|
-
var detector = React.useRef(null);
|
|
9068
9060
|
var _c = React.useState(false),
|
|
9069
9061
|
ready = _c[0],
|
|
9070
9062
|
setReady = _c[1];
|
|
@@ -9090,7 +9082,6 @@
|
|
|
9090
9082
|
return __generator(this, function (_a) {
|
|
9091
9083
|
switch (_a.label) {
|
|
9092
9084
|
case 0:
|
|
9093
|
-
detector.current = model;
|
|
9094
9085
|
setModelDownloadProgress(100);
|
|
9095
9086
|
clearTimeout(modelLoadTimeout);
|
|
9096
9087
|
return [4 /*yield*/, waitForVideoReady(videoRef)];
|
|
@@ -9108,8 +9099,7 @@
|
|
|
9108
9099
|
clearTimeout(modelLoadTimeout);
|
|
9109
9100
|
});
|
|
9110
9101
|
return function () {
|
|
9111
|
-
log('unloading face detection model'
|
|
9112
|
-
detector.current = null;
|
|
9102
|
+
log('unloading face detection model');
|
|
9113
9103
|
closeFaceDetector();
|
|
9114
9104
|
clearTimeout(modelLoadTimeout);
|
|
9115
9105
|
document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
|
|
@@ -9119,7 +9109,6 @@
|
|
|
9119
9109
|
modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
|
|
9120
9110
|
}, [modelError, onModelError]);
|
|
9121
9111
|
return {
|
|
9122
|
-
detector: detector,
|
|
9123
9112
|
ready: ready,
|
|
9124
9113
|
modelDownloadProgress: modelDownloadProgress,
|
|
9125
9114
|
modelError: modelError
|
|
@@ -9158,8 +9147,9 @@
|
|
|
9158
9147
|
if (lastNPairs$1.length > framesNeeded - 1) lastNPairs$1.length = framesNeeded - 1;
|
|
9159
9148
|
}
|
|
9160
9149
|
}
|
|
9161
|
-
function makeFaceDetectorPrediction(
|
|
9162
|
-
|
|
9150
|
+
function makeFaceDetectorPrediction(imageData) {
|
|
9151
|
+
if (!detector$1) return null;
|
|
9152
|
+
var prediction = detector$1.detectForVideo(imageData, performance.now());
|
|
9163
9153
|
var faces = prediction.detections.map(function (d) {
|
|
9164
9154
|
return {
|
|
9165
9155
|
box: convertBoundingBox(d.boundingBox),
|
|
@@ -9491,33 +9481,32 @@
|
|
|
9491
9481
|
passport: 'Passport',
|
|
9492
9482
|
none: 'None'
|
|
9493
9483
|
};
|
|
9494
|
-
var
|
|
9484
|
+
var detector = null;
|
|
9485
|
+
var detectorSettings = null;
|
|
9495
9486
|
function loadDocumentDetector() {
|
|
9496
9487
|
return __awaiter(this, arguments, void 0, function (modelAssetPath, scoreThreshold) {
|
|
9497
|
-
var
|
|
9488
|
+
var _a, _b;
|
|
9498
9489
|
if (modelAssetPath === void 0) {
|
|
9499
9490
|
modelAssetPath = defaultDocumentDetectorModelPath;
|
|
9500
9491
|
}
|
|
9501
9492
|
if (scoreThreshold === void 0) {
|
|
9502
9493
|
scoreThreshold = defaultDocumentDetectionScoreThreshold;
|
|
9503
9494
|
}
|
|
9504
|
-
return __generator(this, function (
|
|
9505
|
-
switch (
|
|
9495
|
+
return __generator(this, function (_c) {
|
|
9496
|
+
switch (_c.label) {
|
|
9506
9497
|
case 0:
|
|
9507
|
-
|
|
9508
|
-
|
|
9498
|
+
if (detector && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.modelAssetPath) === modelAssetPath && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.scoreThreshold) === scoreThreshold) return [2 /*return*/, detector];
|
|
9499
|
+
closeDocumentDetector();
|
|
9509
9500
|
return [4 /*yield*/, preloadDocumentDetectorDependencies()];
|
|
9510
9501
|
case 1:
|
|
9511
|
-
|
|
9502
|
+
_c.sent();
|
|
9512
9503
|
if (modelCapabilities.delegate === 'NONE') {
|
|
9513
9504
|
throw new Error('No available delegate for document detector.');
|
|
9514
9505
|
}
|
|
9515
|
-
_a =
|
|
9516
|
-
_b = id;
|
|
9517
|
-
_d = (_c = lh).createFromOptions;
|
|
9506
|
+
_b = (_a = lh).createFromOptions;
|
|
9518
9507
|
return [4 /*yield*/, ao.forVisionTasks(visionTasksBasePath)];
|
|
9519
9508
|
case 2:
|
|
9520
|
-
return [4 /*yield*/,
|
|
9509
|
+
return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
|
|
9521
9510
|
baseOptions: {
|
|
9522
9511
|
modelAssetPath: modelAssetPath,
|
|
9523
9512
|
delegate: modelCapabilities.delegate
|
|
@@ -9527,23 +9516,20 @@
|
|
|
9527
9516
|
runningMode: 'VIDEO'
|
|
9528
9517
|
}])];
|
|
9529
9518
|
case 3:
|
|
9530
|
-
|
|
9531
|
-
|
|
9519
|
+
detector = _c.sent();
|
|
9520
|
+
detectorSettings = {
|
|
9521
|
+
modelAssetPath: modelAssetPath,
|
|
9522
|
+
scoreThreshold: scoreThreshold
|
|
9523
|
+
};
|
|
9524
|
+
return [2 /*return*/, detector];
|
|
9532
9525
|
}
|
|
9533
9526
|
});
|
|
9534
9527
|
});
|
|
9535
9528
|
}
|
|
9536
|
-
function closeDocumentDetector(
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
if (scoreThreshold === void 0) {
|
|
9541
|
-
scoreThreshold = defaultDocumentDetectionScoreThreshold;
|
|
9542
|
-
}
|
|
9543
|
-
var id = "".concat(modelAssetPath, ":").concat(scoreThreshold);
|
|
9544
|
-
if (!detectors[id]) return;
|
|
9545
|
-
detectors[id].close();
|
|
9546
|
-
delete detectors[id];
|
|
9529
|
+
function closeDocumentDetector() {
|
|
9530
|
+
detector === null || detector === void 0 ? void 0 : detector.close();
|
|
9531
|
+
detector = null;
|
|
9532
|
+
detectorSettings = null;
|
|
9547
9533
|
}
|
|
9548
9534
|
function useLoadDocumentDetector(_a) {
|
|
9549
9535
|
var _b = _a.modelPath,
|
|
@@ -9553,7 +9539,6 @@
|
|
|
9553
9539
|
_d = _a.scoreThreshold,
|
|
9554
9540
|
scoreThreshold = _d === void 0 ? defaultDocumentDetectionScoreThreshold : _d,
|
|
9555
9541
|
onModelError = _a.onModelError;
|
|
9556
|
-
var detector = React.useRef(null);
|
|
9557
9542
|
var _e = React.useState(false),
|
|
9558
9543
|
ready = _e[0],
|
|
9559
9544
|
setReady = _e[1];
|
|
@@ -9579,7 +9564,6 @@
|
|
|
9579
9564
|
return __generator(this, function (_a) {
|
|
9580
9565
|
switch (_a.label) {
|
|
9581
9566
|
case 0:
|
|
9582
|
-
detector.current = model;
|
|
9583
9567
|
setModelDownloadProgress(100);
|
|
9584
9568
|
clearTimeout(modelLoadTimeout);
|
|
9585
9569
|
return [4 /*yield*/, waitForVideoReady(videoRef)];
|
|
@@ -9600,8 +9584,7 @@
|
|
|
9600
9584
|
});
|
|
9601
9585
|
return function () {
|
|
9602
9586
|
log('unloading document detection model');
|
|
9603
|
-
|
|
9604
|
-
closeDocumentDetector(modelPath, scoreThreshold);
|
|
9587
|
+
closeDocumentDetector();
|
|
9605
9588
|
clearTimeout(modelLoadTimeout);
|
|
9606
9589
|
document.removeEventListener('idmission.preloadProgress.documentDetection', handleDownloadProgress);
|
|
9607
9590
|
};
|
|
@@ -9610,17 +9593,17 @@
|
|
|
9610
9593
|
modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
|
|
9611
9594
|
}, [modelError, onModelError]);
|
|
9612
9595
|
return {
|
|
9613
|
-
detector: detector,
|
|
9614
9596
|
ready: ready,
|
|
9615
9597
|
modelDownloadProgress: modelDownloadProgress,
|
|
9616
9598
|
modelError: modelError,
|
|
9617
9599
|
setModelError: setModelError
|
|
9618
9600
|
};
|
|
9619
9601
|
}
|
|
9620
|
-
function makeDocumentDetectorPrediction(
|
|
9602
|
+
function makeDocumentDetectorPrediction(frame) {
|
|
9621
9603
|
return __awaiter(this, void 0, void 0, function () {
|
|
9622
9604
|
var startedAt, prediction, time, frameWidth, frameHeight;
|
|
9623
9605
|
return __generator(this, function (_a) {
|
|
9606
|
+
if (!detector) return [2 /*return*/, null];
|
|
9624
9607
|
startedAt = new Date();
|
|
9625
9608
|
// Detectors can throw errors, for example when using custom URLs that
|
|
9626
9609
|
// contain a model that doesn't provide the expected output.
|
|
@@ -9944,7 +9927,6 @@
|
|
|
9944
9927
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
9945
9928
|
onModelError: onDocumentDetectionModelError
|
|
9946
9929
|
}),
|
|
9947
|
-
detector = _o.detector,
|
|
9948
9930
|
ready = _o.ready,
|
|
9949
9931
|
modelDownloadProgress = _o.modelDownloadProgress,
|
|
9950
9932
|
modelError = _o.modelError,
|
|
@@ -9956,7 +9938,7 @@
|
|
|
9956
9938
|
return __generator(this, function (_b) {
|
|
9957
9939
|
switch (_b.label) {
|
|
9958
9940
|
case 0:
|
|
9959
|
-
if (!videoLoaded || !cameraReady || !ready || !videoRef.current || !
|
|
9941
|
+
if (!videoLoaded || !cameraReady || !ready || !videoRef.current || !lastPredictionCanvas.current) return [2 /*return*/];
|
|
9960
9942
|
stopDetectionAtStart = stopDetection.current;
|
|
9961
9943
|
vw = videoRef.current.videoWidth;
|
|
9962
9944
|
vh = videoRef.current.videoHeight;
|
|
@@ -9966,7 +9948,7 @@
|
|
|
9966
9948
|
if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 3];
|
|
9967
9949
|
if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
|
|
9968
9950
|
ctx.drawImage(videoRef.current, 0, 0, vw, vh);
|
|
9969
|
-
return [4 /*yield*/, makeDocumentDetectorPrediction(
|
|
9951
|
+
return [4 /*yield*/, makeDocumentDetectorPrediction(lastPredictionCanvas.current)];
|
|
9970
9952
|
case 1:
|
|
9971
9953
|
prediction = _b.sent();
|
|
9972
9954
|
if (!prediction) return [3 /*break*/, 3];
|
|
@@ -9988,7 +9970,7 @@
|
|
|
9988
9970
|
}
|
|
9989
9971
|
});
|
|
9990
9972
|
});
|
|
9991
|
-
}, [cameraReady, delayAfterStartMs,
|
|
9973
|
+
}, [cameraReady, delayAfterStartMs, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
|
|
9992
9974
|
throttleMs: throttleMs,
|
|
9993
9975
|
autoStart: autoStart
|
|
9994
9976
|
}),
|
|
@@ -10065,16 +10047,16 @@
|
|
|
10065
10047
|
modelLoadTimeoutMs: focusModelLoadTimeoutMs,
|
|
10066
10048
|
onModelError: onFocusModelError
|
|
10067
10049
|
}),
|
|
10068
|
-
model = _f.model,
|
|
10069
10050
|
ready = _f.ready,
|
|
10070
10051
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
10071
10052
|
modelError = _f.modelError;
|
|
10072
10053
|
var makeFocusPrediction = React.useCallback(function (imageData, box) {
|
|
10073
|
-
if (!
|
|
10074
|
-
var prediction = makeFocusModelPrediction(
|
|
10054
|
+
if (!ready) return null;
|
|
10055
|
+
var prediction = makeFocusModelPrediction(imageData, cropCanvas.current, rotateCanvas.current, box);
|
|
10056
|
+
if (!prediction) return null;
|
|
10075
10057
|
setLastFocusPredictionAt(prediction.predictionTime);
|
|
10076
10058
|
return prediction;
|
|
10077
|
-
}, [
|
|
10059
|
+
}, [ready]);
|
|
10078
10060
|
var value = React.useMemo(function () {
|
|
10079
10061
|
return {
|
|
10080
10062
|
focusModelReady: ready,
|
|
@@ -18170,18 +18152,17 @@
|
|
|
18170
18152
|
onModelError: onModelError,
|
|
18171
18153
|
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
18172
18154
|
}),
|
|
18173
|
-
detector = _f.detector,
|
|
18174
18155
|
ready = _f.ready,
|
|
18175
18156
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
18176
18157
|
modelError = _f.modelError;
|
|
18177
18158
|
var _g = useFrameLoop(React.useCallback(function () {
|
|
18178
18159
|
return __awaiter(_this, void 0, void 0, function () {
|
|
18179
|
-
var vw, vh, ctx,
|
|
18180
|
-
var _a;
|
|
18181
|
-
return __generator(this, function (
|
|
18182
|
-
switch (
|
|
18160
|
+
var vw, vh, ctx, prediction, processed, e_1;
|
|
18161
|
+
var _a, _b;
|
|
18162
|
+
return __generator(this, function (_c) {
|
|
18163
|
+
switch (_c.label) {
|
|
18183
18164
|
case 0:
|
|
18184
|
-
if (!videoLoaded || !cameraReady || !ready || modelError || !videoRef.current || !
|
|
18165
|
+
if (!videoLoaded || !cameraReady || !ready || modelError || !videoRef.current || !canvasRef.current) return [2 /*return*/];
|
|
18185
18166
|
vw = videoRef.current.videoWidth;
|
|
18186
18167
|
vh = videoRef.current.videoHeight;
|
|
18187
18168
|
ctx = canvasRef.current.getContext('2d');
|
|
@@ -18191,23 +18172,23 @@
|
|
|
18191
18172
|
ctx.translate(vw, 0);
|
|
18192
18173
|
ctx.scale(-1, 1);
|
|
18193
18174
|
ctx.drawImage(videoRef.current, 0, 0, vw, vh);
|
|
18194
|
-
|
|
18175
|
+
_c.label = 1;
|
|
18195
18176
|
case 1:
|
|
18196
|
-
|
|
18197
|
-
|
|
18177
|
+
_c.trys.push([1, 3,, 4]);
|
|
18178
|
+
prediction = makeFaceDetectorPrediction(canvasRef.current);
|
|
18198
18179
|
processed = processFaceDetectorPrediction({
|
|
18199
|
-
faces: faces,
|
|
18180
|
+
faces: (_a = prediction === null || prediction === void 0 ? void 0 : prediction.faces) !== null && _a !== void 0 ? _a : [],
|
|
18200
18181
|
videoWidth: vw,
|
|
18201
18182
|
videoHeight: vh,
|
|
18202
18183
|
requireVerticalFaceCentering: requireVerticalFaceCentering
|
|
18203
18184
|
});
|
|
18204
18185
|
setLastFaceDetectionAt(new Date().getTime());
|
|
18205
|
-
return [4 /*yield*/, (
|
|
18186
|
+
return [4 /*yield*/, (_b = onPredictionHandler.current) === null || _b === void 0 ? void 0 : _b.call(onPredictionHandler, processed)];
|
|
18206
18187
|
case 2:
|
|
18207
|
-
|
|
18188
|
+
_c.sent();
|
|
18208
18189
|
return [3 /*break*/, 4];
|
|
18209
18190
|
case 3:
|
|
18210
|
-
e_1 =
|
|
18191
|
+
e_1 = _c.sent();
|
|
18211
18192
|
error('caught face detection error', e_1);
|
|
18212
18193
|
return [3 /*break*/, 4];
|
|
18213
18194
|
case 4:
|
|
@@ -18215,7 +18196,7 @@
|
|
|
18215
18196
|
}
|
|
18216
18197
|
});
|
|
18217
18198
|
});
|
|
18218
|
-
}, [cameraReady,
|
|
18199
|
+
}, [cameraReady, modelError, ready, requireVerticalFaceCentering, videoLoaded, videoRef]), {
|
|
18219
18200
|
throttleMs: throttleMs,
|
|
18220
18201
|
autoStart: autoStart
|
|
18221
18202
|
}),
|