idmission-web-sdk 1.0.172 → 1.0.174

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.
@@ -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.172';
51
+ var webSdkVersion = '1.0.174';
52
52
 
53
53
  function getPlatform() {
54
54
  if (typeof window === 'undefined') return;
@@ -8938,7 +8938,7 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
8938
8938
  documentTooClose = false;
8939
8939
  if (bestDocumentOrPassport) {
8940
8940
  _s = [bestDocumentOrPassport.bbox[2], bestDocumentOrPassport.bbox[3]], docWidth = _s[0], docHeight = _s[1];
8941
- documentTooClose = docWidth > 0.8 || docHeight > 0.8;
8941
+ documentTooClose = docWidth > 0.85 || docHeight > 0.85;
8942
8942
  }
8943
8943
  focusPrediction = null, focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
8944
8944
  if (!(detectionThresholdMet && documentInBounds && !documentTooClose)) return [3 /*break*/, 3];
@@ -9063,20 +9063,36 @@ function makeFocusPrediction(imageData, bbox, logPredictions) {
9063
9063
  logPredictions = false;
9064
9064
  }
9065
9065
  return tslib.__awaiter(this, void 0, void 0, function () {
9066
- var startedAt, tfImg, tfResize, tfInt32, tf4d_, _a, _b, _c, _d, tf4d, predictions, focusPrediction, predictionTime;
9067
- return tslib.__generator(this, function (_e) {
9068
- switch (_e.label) {
9066
+ var startedAt, tfImg, cropped, _a, fw, fh, _b, bw, bh, rotated, ctx, tfResize, tfInt32, tf4d_, _c, _d, _e, _f, tf4d, predictions, focusPrediction, predictionTime;
9067
+ return tslib.__generator(this, function (_g) {
9068
+ switch (_g.label) {
9069
9069
  case 0:
9070
9070
  if (!focusModel) {
9071
9071
  throw new Error('focus model is not loaded');
9072
9072
  }
9073
9073
  startedAt = new Date();
9074
- _e.label = 1;
9074
+ _g.label = 1;
9075
9075
  case 1:
9076
- _e.trys.push([1, 5,, 6]);
9076
+ _g.trys.push([1, 5,, 6]);
9077
9077
  tfImg = void 0;
9078
9078
  if (bbox) {
9079
- tfImg = tf__namespace.browser.fromPixels(cropToBoundingBox(imageData, bbox));
9079
+ cropped = cropToBoundingBox(imageData, bbox);
9080
+ _a = getFrameDimensions(imageData), fw = _a[0], fh = _a[1];
9081
+ _b = [bbox[2] * fw, bbox[3] * fh], bw = _b[0], bh = _b[1];
9082
+ if (bh > bw) {
9083
+ rotated = document.createElement('canvas');
9084
+ ctx = rotated.getContext('2d');
9085
+ if (ctx) {
9086
+ rotated.width = bh;
9087
+ rotated.height = bw;
9088
+ ctx.clearRect(0, 0, rotated.width, rotated.height);
9089
+ ctx.translate(rotated.height / 2, rotated.width / 2);
9090
+ ctx.rotate(1.5708); // 90 deg in radians
9091
+ ctx.drawImage(cropped, -rotated.width / 2, -rotated.height / 2);
9092
+ cropped = rotated;
9093
+ }
9094
+ }
9095
+ tfImg = tf__namespace.browser.fromPixels(cropped);
9080
9096
  } else {
9081
9097
  tfImg = tf__namespace.browser.fromPixels(imageData);
9082
9098
  }
@@ -9084,28 +9100,28 @@ function makeFocusPrediction(imageData, bbox, logPredictions) {
9084
9100
  tfImg.dispose();
9085
9101
  tfInt32 = tf__namespace.cast(tfResize, 'float32');
9086
9102
  tfResize.dispose();
9087
- _b = (_a = tf__namespace).tensor4d;
9088
- _d = (_c = Array).from;
9103
+ _d = (_c = tf__namespace).tensor4d;
9104
+ _f = (_e = Array).from;
9089
9105
  return [4 /*yield*/, tfInt32.data()];
9090
9106
  case 2:
9091
- tf4d_ = _b.apply(_a, [_d.apply(_c, [_e.sent()]), [1, 448, 448, 3]]);
9107
+ tf4d_ = _d.apply(_c, [_f.apply(_e, [_g.sent()]), [1, 448, 448, 3]]);
9092
9108
  tfInt32.dispose();
9093
9109
  tf4d = tf__namespace.cast(tf4d_, 'float32');
9094
9110
  tf4d_.dispose();
9095
9111
  if (logPredictions) console.time('focus prediction');
9096
9112
  return [4 /*yield*/, focusModel.predict(tf4d)];
9097
9113
  case 3:
9098
- predictions = _e.sent();
9114
+ predictions = _g.sent();
9099
9115
  tf4d.dispose();
9100
9116
  return [4 /*yield*/, predictions.array()];
9101
9117
  case 4:
9102
- focusPrediction = _e.sent()[0];
9118
+ focusPrediction = _g.sent()[0];
9103
9119
  if (logPredictions) console.timeEnd('focus prediction');
9104
9120
  tf__namespace.dispose(predictions);
9105
9121
  predictionTime = new Date().getTime() - startedAt.getTime();
9106
9122
  return [2 /*return*/, [focusPrediction, predictionTime]];
9107
9123
  case 5:
9108
- _e.sent();
9124
+ _g.sent();
9109
9125
  return [2 /*return*/, [[0, 0], 0]];
9110
9126
  case 6:
9111
9127
  return [2 /*return*/];
@@ -14765,7 +14781,7 @@ var defaultTheme = {
14765
14781
  borderWidth: 4,
14766
14782
  desktopPadding: 50,
14767
14783
  mobilePadding: 0,
14768
- imagePadding: 50
14784
+ imagePadding: 25
14769
14785
  }
14770
14786
  },
14771
14787
  selfieCapture: {