idmission-web-sdk 1.0.143 → 1.0.144

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.
@@ -34,11 +34,6 @@ export type IdCaptureThresholds = {
34
34
  mobile?: number;
35
35
  };
36
36
  };
37
- export declare const PREDICTION_POSITIONS: {
38
- boxes: number;
39
- scores: number;
40
- labels: number;
41
- };
42
37
  export type BestFrame = {
43
38
  canvas: HTMLCanvasElement;
44
39
  boundingBox?: number[];
@@ -1,7 +1,14 @@
1
1
  import * as tf from '@tensorflow/tfjs';
2
2
  export type DocumentType = 'none' | 'idCard' | 'passport';
3
- export declare let documentDetectionModel: tf.GraphModel | null;
4
- export declare function loadDocumentDetectionModel(url: string): Promise<tf.GraphModel>;
3
+ export interface DocumentDetectionModel extends tf.GraphModel {
4
+ outputPositions: {
5
+ boxes: number;
6
+ scores: number;
7
+ labels: number;
8
+ };
9
+ }
10
+ export declare let documentDetectionModel: DocumentDetectionModel | null;
11
+ export declare function loadDocumentDetectionModel(url: string): Promise<DocumentDetectionModel>;
5
12
  export declare function unloadDocumentDetectionModel(): void;
6
13
  export type RawEdgeDetectionResult = tf.Tensor<tf.Rank>[];
7
14
  export declare function makeDocumentDetectionPredictions(model: tf.GraphModel, image: ImageBitmap | ImageData | HTMLImageElement): Promise<[RawEdgeDetectionResult, () => void]>;
@@ -47,7 +47,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
47
47
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
48
48
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
49
49
 
50
- var webSdkVersion = '1.0.143';
50
+ var webSdkVersion = '1.0.144';
51
51
 
52
52
  function getPlatform() {
53
53
  if (typeof window === 'undefined') return;
@@ -1903,7 +1903,7 @@ var CameraProvider = function CameraProvider(_a) {
1903
1903
  var documentDetectionModel;
1904
1904
  function loadDocumentDetectionModel(url) {
1905
1905
  return tslib.__awaiter(this, void 0, void 0, function () {
1906
- var zeroes, tfInt32, tf4d_, tf4d, _a, _b;
1906
+ var zeroes, tfInt32, tf4d_, tf4d, _a, _b, outputKeys;
1907
1907
  return tslib.__generator(this, function (_c) {
1908
1908
  switch (_c.label) {
1909
1909
  case 0:
@@ -1928,6 +1928,14 @@ function loadDocumentDetectionModel(url) {
1928
1928
  tf4d.dispose();
1929
1929
  tf4d_.dispose();
1930
1930
  tf__namespace.dispose(zeroes);
1931
+ outputKeys = documentDetectionModel.outputs.map(function (o) {
1932
+ return o.name;
1933
+ });
1934
+ documentDetectionModel.outputPositions = {
1935
+ boxes: outputKeys.indexOf('Identity_1'),
1936
+ scores: outputKeys.indexOf('Identity_4'),
1937
+ labels: outputKeys.indexOf('Identity_2')
1938
+ };
1931
1939
  return [2 /*return*/, documentDetectionModel];
1932
1940
  }
1933
1941
  });
@@ -8646,12 +8654,6 @@ function cropToBoundingBox(frame, bbox, canvas) {
8646
8654
  return canvas;
8647
8655
  }
8648
8656
 
8649
- // export const PREDICTION_POSITIONS = { boxes: 1, scores: 4, labels: 2 } // for docdetectuint8
8650
- var PREDICTION_POSITIONS = {
8651
- boxes: 0,
8652
- scores: 7,
8653
- labels: 4
8654
- }; // for documentdetectionquantized
8655
8657
  var IdCaptureModelsContext = /*#__PURE__*/React.createContext({
8656
8658
  ready: false,
8657
8659
  working: {
@@ -8679,7 +8681,7 @@ var IdCaptureModelsContext = /*#__PURE__*/React.createContext({
8679
8681
  bestFrameDetectionScore: 0,
8680
8682
  bestFrameFocusScore: 0
8681
8683
  });
8682
- var defaultDocumentDetectionModelUrl = "".concat(DEFAULT_CDN_URL, "/models/documentdetection448/model.json");
8684
+ var defaultDocumentDetectionModelUrl = "".concat(DEFAULT_CDN_URL, "/models/docdetect20240125/model.json");
8683
8685
  var defaultFocusModelUrl = "".concat(DEFAULT_CDN_URL, "/models/focus/model.json");
8684
8686
  var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
8685
8687
  var children = _a.children,
@@ -9014,13 +9016,13 @@ function makeDocumentDetectionPredictions(image, logPredictions) {
9014
9016
  return r.arraySync();
9015
9017
  }));
9016
9018
  }
9017
- return [4 /*yield*/, predictions[PREDICTION_POSITIONS.boxes].array()];
9019
+ return [4 /*yield*/, predictions[documentDetectionModel.outputPositions.boxes].array()];
9018
9020
  case 4:
9019
9021
  boxes = _e.sent()[0];
9020
- return [4 /*yield*/, predictions[PREDICTION_POSITIONS.scores].array()];
9022
+ return [4 /*yield*/, predictions[documentDetectionModel.outputPositions.scores].array()];
9021
9023
  case 5:
9022
9024
  scores = _e.sent()[0];
9023
- return [4 /*yield*/, predictions[PREDICTION_POSITIONS.labels].array()];
9025
+ return [4 /*yield*/, predictions[documentDetectionModel.outputPositions.labels].array()];
9024
9026
  case 6:
9025
9027
  labels = _e.sent()[0];
9026
9028
  labels = labels.map(function (l) {