idmission-web-sdk 2.1.103 → 2.1.105

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.
@@ -234,7 +234,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
234
234
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
235
235
  };
236
236
 
237
- var webSdkVersion = '2.1.103';
237
+ var webSdkVersion = '2.1.105';
238
238
 
239
239
  function getPlatform() {
240
240
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2754,15 +2754,6 @@ function waitForVideoReady(videoRef, checkEveryMs) {
2754
2754
  }, checkEveryMs);
2755
2755
  });
2756
2756
  }
2757
- function createPairs(arr, maxPairs) {
2758
- var pairs = [];
2759
- var len = arr.length - 1;
2760
- var end = Math.min(maxPairs , len);
2761
- for (var i = 0; i < end; i++) {
2762
- pairs.push([arr[i], arr[i + 1]]);
2763
- }
2764
- return pairs;
2765
- }
2766
2757
  function calculateIoU(boxA, boxB) {
2767
2758
  var xA = Math.max(boxA.xMin, boxB.xMin);
2768
2759
  var yA = Math.max(boxA.yMin, boxB.yMin);
@@ -5239,12 +5230,23 @@ function trackFramesNeeded$1(value, bufferLength) {
5239
5230
  if (framesNeededSamples$1.length > bufferLength) framesNeededSamples$1.length = bufferLength;
5240
5231
  }
5241
5232
  var lastNFaces = [];
5233
+ var lastNPairs$1 = [];
5242
5234
  function trackFace(face, framesNeeded) {
5243
5235
  if (framesNeeded === void 0) {
5244
5236
  framesNeeded = 12;
5245
5237
  }
5246
5238
  lastNFaces.unshift(face);
5247
5239
  if (lastNFaces.length > framesNeeded) lastNFaces.length = framesNeeded;
5240
+ if (lastNFaces.length > 1) {
5241
+ var lastFace = lastNFaces[1];
5242
+ var iou = calculateIoU(face.box, lastFace.box);
5243
+ lastNPairs$1.unshift({
5244
+ a: face,
5245
+ b: lastFace,
5246
+ iou: iou
5247
+ });
5248
+ if (lastNPairs$1.length > framesNeeded - 1) lastNPairs$1.length = framesNeeded - 1;
5249
+ }
5248
5250
  }
5249
5251
  function makeFaceDetectorPrediction(model, imageData) {
5250
5252
  var prediction = model.detectForVideo(imageData, performance.now());
@@ -5311,10 +5313,8 @@ function processFaceDetectorPrediction(_a) {
5311
5313
  if (faceInGuides) {
5312
5314
  var framesNeeded = Math.ceil(average(framesNeededSamples$1));
5313
5315
  trackFace(face, framesNeeded);
5314
- faceIsStable = lastNFaces.length >= framesNeeded && !createPairs(lastNFaces, 12).some(function (_a) {
5315
- var a = _a[0],
5316
- b = _a[1];
5317
- return calculateIoU(a.box, b.box) < stabilityThreshold;
5316
+ faceIsStable = lastNFaces.length >= framesNeeded && !lastNPairs$1.some(function (pair) {
5317
+ return pair.iou < stabilityThreshold;
5318
5318
  });
5319
5319
  }
5320
5320
  var faceReady = faceInGuides && faceIsStable;
@@ -5726,12 +5726,23 @@ function trackFramesNeeded(value, bufferLength) {
5726
5726
  if (framesNeededSamples.length > bufferLength) framesNeededSamples.length = bufferLength;
5727
5727
  }
5728
5728
  var lastNBoxes = [];
5729
+ var lastNPairs = [];
5729
5730
  function trackBox(box, framesNeeded) {
5730
5731
  if (framesNeeded === void 0) {
5731
5732
  framesNeeded = 12;
5732
5733
  }
5733
5734
  lastNBoxes.unshift(box);
5734
5735
  if (lastNBoxes.length > framesNeeded) lastNBoxes.length = framesNeeded;
5736
+ if (lastNBoxes.length > 1) {
5737
+ var lastBox = lastNBoxes[1];
5738
+ var iou = calculateIoU(box, lastBox);
5739
+ lastNPairs.unshift({
5740
+ a: box,
5741
+ b: lastBox,
5742
+ iou: iou
5743
+ });
5744
+ if (lastNPairs.length > framesNeeded - 1) lastNPairs.length = framesNeeded - 1;
5745
+ }
5735
5746
  }
5736
5747
  var defaultDocumentDetectionBoundaries = {
5737
5748
  top: 20,
@@ -5824,10 +5835,8 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
5824
5835
  var threshold_1 = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
5825
5836
  var framesNeeded = Math.ceil(average(framesNeededSamples));
5826
5837
  trackBox(bestDocument.box, framesNeeded);
5827
- documentIsStable = lastNBoxes.length >= framesNeeded && !createPairs(lastNBoxes, 12).some(function (_a) {
5828
- var a = _a[0],
5829
- b = _a[1];
5830
- return calculateIoU(a, b) < threshold_1;
5838
+ documentIsStable = lastNBoxes.length >= framesNeeded && !lastNPairs.some(function (pair) {
5839
+ return pair.iou < threshold_1;
5831
5840
  });
5832
5841
  }
5833
5842
  }
@@ -6287,7 +6296,7 @@ function IdCaptureModelsProviderInner(_a) {
6287
6296
  stopDetectionAtStart = stopDetection.current;
6288
6297
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
6289
6298
  isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType));
6290
- if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose) {
6299
+ if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
6291
6300
  focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
6292
6301
  if (focusPrediction) {
6293
6302
  focusScore = focusPrediction.score;
@@ -7357,7 +7366,7 @@ var IdCapture = function IdCapture(_a) {
7357
7366
  });
7358
7367
  var satisfied = state.isGoodFrame;
7359
7368
  if (typeof guidanceSatisfied === 'boolean') satisfied = guidanceSatisfied;
7360
- guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceSatisfiedText : !state.detectionThresholdMet ? verbiage.guidanceNotDetectedText : state.backDetectedFirst ? verbiage.guidanceBackDetectedFirstText : state.flipRequired ? verbiage.guidancePleaseFlipText : state.idCardDetectedButNotAllowed ? verbiage.guidanceIdCardNotAllowedText : state.passportDetectedButNotAllowed ? verbiage.guidancePassportNotAllowedText : !state.documentInBounds ? verbiage.guidanceNotCenteredText : state.documentTooClose ? verbiage.guidanceTooCloseText : !state.focusThresholdMet ? verbiage.guidanceTooBlurryText : !state.documentIsStable ? verbiage.guidanceNotStableText : '');
7369
+ guidanceMessage || (guidanceMessage = satisfied ? verbiage.guidanceSatisfiedText : !state.detectionThresholdMet ? verbiage.guidanceNotDetectedText : state.backDetectedFirst ? verbiage.guidanceBackDetectedFirstText : state.flipRequired ? verbiage.guidancePleaseFlipText : state.idCardDetectedButNotAllowed ? verbiage.guidanceIdCardNotAllowedText : state.passportDetectedButNotAllowed ? verbiage.guidancePassportNotAllowedText : !state.documentInBounds ? verbiage.guidanceNotCenteredText : state.documentTooClose ? verbiage.guidanceTooCloseText : !state.documentIsStable ? verbiage.guidanceNotStableText : !state.focusThresholdMet ? verbiage.guidanceTooBlurryText : '');
7361
7370
  return /*#__PURE__*/React__namespace.default.createElement(PageContainer, {
7362
7371
  ref: ref,
7363
7372
  className: "flex ".concat((_h = classNames.container) !== null && _h !== void 0 ? _h : '')