idmission-web-sdk 2.1.101 → 2.1.103

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.101';
237
+ var webSdkVersion = '2.1.103';
238
238
 
239
239
  function getPlatform() {
240
240
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -5748,6 +5748,11 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
5748
5748
  frameWidth = prediction.frameWidth,
5749
5749
  frameHeight = prediction.frameHeight,
5750
5750
  time = prediction.time;
5751
+ var boundaryTop = (_a = boundaries.top) !== null && _a !== void 0 ? _a : 20;
5752
+ var boundaryLeft = (_b = boundaries.left) !== null && _b !== void 0 ? _b : 20;
5753
+ var boundaryRight = (_c = boundaries.right) !== null && _c !== void 0 ? _c : 20;
5754
+ var boundaryBottom = (_d = boundaries.bottom) !== null && _d !== void 0 ? _d : 20;
5755
+ var frameWidth80Pct = frameWidth * 0.8;
5751
5756
  var detectedObjects = applyNonMaxSuppression(detections.map(function (d) {
5752
5757
  var _a;
5753
5758
  var category = (_a = d.categories) === null || _a === void 0 ? void 0 : _a[0];
@@ -5756,7 +5761,21 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
5756
5761
  score: category === null || category === void 0 ? void 0 : category.score,
5757
5762
  box: convertBoundingBox(d.boundingBox)
5758
5763
  };
5759
- }));
5764
+ }), function (obj) {
5765
+ var _a = obj.box,
5766
+ xMin = _a.xMin,
5767
+ yMin = _a.yMin,
5768
+ width = _a.width,
5769
+ height = _a.height;
5770
+ return yMin > boundaryTop &&
5771
+ // Is it valid top edge of ID detected?
5772
+ yMin + height + boundaryBottom < frameHeight && (
5773
+ // Is it valid bottom edge less than max video height
5774
+ xMin > boundaryLeft || xMin + width > frameWidth80Pct) &&
5775
+ // If either the left side visible or if not, right edge of ID should be more than 80% of width.
5776
+ xMin + width + boundaryRight < frameWidth // Valid right edge if it's less than video width.
5777
+ ;
5778
+ });
5760
5779
  var allZero = detections.length > 0 && !detections.some(function (_a) {
5761
5780
  var boundingBox = _a.boundingBox;
5762
5781
  return Object.values(boundingBox !== null && boundingBox !== void 0 ? boundingBox : {}).some(function (n) {
@@ -5772,15 +5791,15 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
5772
5791
  var bestPassportPage = detectedObjects.find(function (obj) {
5773
5792
  return obj.label === 'Passport page';
5774
5793
  });
5775
- var idCardFrontDetectionScore = (_a = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _a !== void 0 ? _a : 0;
5776
- var idCardBackDetectionScore = (_b = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _b !== void 0 ? _b : 0;
5777
- var passportDetectionScore = (_c = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _c !== void 0 ? _c : 0;
5778
- var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_d = thresholds.idCardFront) !== null && _d !== void 0 ? _d : 0);
5779
- var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_e = thresholds.idCardBack) !== null && _e !== void 0 ? _e : 0);
5780
- var passportDetectionThresholdMet = passportDetectionScore >= ((_f = thresholds.passport) !== null && _f !== void 0 ? _f : 0);
5794
+ var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
5795
+ var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
5796
+ var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 0;
5797
+ var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_h = thresholds.idCardFront) !== null && _h !== void 0 ? _h : 0);
5798
+ var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_j = thresholds.idCardBack) !== null && _j !== void 0 ? _j : 0);
5799
+ var passportDetectionThresholdMet = passportDetectionScore >= ((_k = thresholds.passport) !== null && _k !== void 0 ? _k : 0);
5781
5800
  var bestDocument = passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
5782
5801
  var detectionThreshold = passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
5783
- var detectionScore = (_g = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _g !== void 0 ? _g : 0;
5802
+ var detectionScore = (_l = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _l !== void 0 ? _l : 0;
5784
5803
  var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
5785
5804
  var detectedDocumentType = 'none';
5786
5805
  if (passportDetectionThresholdMet) {
@@ -5790,34 +5809,16 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
5790
5809
  } else if (detectionThresholdMet) {
5791
5810
  detectedDocumentType = 'idCardFront';
5792
5811
  }
5793
- var documentInBounds = false;
5794
- if (bestDocument) {
5795
- var boundaryTop = (_h = boundaries.top) !== null && _h !== void 0 ? _h : 20;
5796
- var boundaryLeft = (_j = boundaries.left) !== null && _j !== void 0 ? _j : 20;
5797
- var boundaryRight = (_k = boundaries.right) !== null && _k !== void 0 ? _k : 20;
5798
- var boundaryBottom = (_l = boundaries.bottom) !== null && _l !== void 0 ? _l : 20;
5799
- var _o = bestDocument.box,
5800
- xMin = _o.xMin,
5801
- yMin = _o.yMin,
5802
- width = _o.width,
5803
- height = _o.height;
5804
- documentInBounds = yMin > boundaryTop &&
5805
- // Is it valid top edge of ID detected?
5806
- yMin + height + boundaryBottom < frameHeight && (
5807
- // Is it valid bottom edge less than max video height
5808
- xMin > boundaryLeft || xMin < boundaryLeft && xMin + width > frameWidth * 0.8) &&
5809
- // If either the left side visible or if not, right edge of ID should be more than 80% of width.
5810
- xMin + width + boundaryRight < frameWidth; // Valid right edge if it's less than video width.
5811
- }
5812
+ var documentInBounds = !!bestDocument;
5812
5813
  if (lastDetectionTime > 0) {
5813
5814
  trackFramesNeeded(1000 / lastDetectionTime);
5814
5815
  }
5815
5816
  var documentIsStable = false;
5816
5817
  var documentTooClose = false;
5817
5818
  if (bestDocument) {
5818
- var _p = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
5819
- docWidth = _p[0],
5820
- docHeight = _p[1];
5819
+ var _o = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
5820
+ docWidth = _o[0],
5821
+ docHeight = _o[1];
5821
5822
  documentTooClose = docWidth > 0.85 || docHeight > 0.85;
5822
5823
  if (detectionThresholdMet && documentInBounds && !documentTooClose) {
5823
5824
  var threshold_1 = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
@@ -5851,12 +5852,12 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
5851
5852
  allZero: allZero
5852
5853
  };
5853
5854
  }
5854
- function applyNonMaxSuppression(detectedObjects) {
5855
+ function applyNonMaxSuppression(detectedObjects, isGoodBox) {
5855
5856
  var maxes = {};
5856
5857
  detectedObjects.forEach(function (obj, i) {
5857
5858
  if (obj) {
5858
5859
  if (!maxes[obj.label]) maxes[obj.label] = [0, -1];
5859
- if (obj.score > maxes[obj.label][0]) maxes[obj.label] = [obj.score, i];
5860
+ if (obj.score > maxes[obj.label][0] && (isGoodBox === null || isGoodBox === void 0 ? void 0 : isGoodBox(obj))) maxes[obj.label] = [obj.score, i];
5860
5861
  }
5861
5862
  });
5862
5863
  return Object.keys(maxes).map(function (label) {
@@ -11394,7 +11395,7 @@ function SelfieGuidanceModelsProvider(_a) {
11394
11395
  }
11395
11396
  });
11396
11397
  });
11397
- }, [cameraReady, detector, modelError, ready, videoLoaded, videoRef]), {
11398
+ }, [cameraReady, detector, modelError, ready, requireVerticalFaceCentering, videoLoaded, videoRef]), {
11398
11399
  throttleMs: throttleMs,
11399
11400
  autoStart: autoStart
11400
11401
  }),