@idscan/idvc2 2.5.1 → 2.5.2
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/README.md +4 -1
- package/dist/idvc.js +26249 -1615
- package/dist/js/environment/langs.js +228 -1
- package/dist/networks/156-6146-chunk.js +216 -0
- package/dist/networks/190-200f-chunk.js +559 -0
- package/dist/networks/77-eca7-chunk.js +282 -0
- package/dist/networks/Face-578d-chunk.js +2272 -0
- package/dist/networks/MRZ-4756-chunk.js +1708 -0
- package/dist/networks/PDF-8ef7-chunk.js +565 -0
- package/dist/networks/ZXing-e864-chunk.js +351 -0
- package/package.json +11 -17
- package/dist/networks/156-9239-chunk.js +0 -1
- package/dist/networks/190-77ed-chunk.js +0 -1
- package/dist/networks/77-9e2f-chunk.js +0 -1
- package/dist/networks/Face-e375-chunk.js +0 -1
- package/dist/networks/MRZ-d498-chunk.js +0 -1
- package/dist/networks/PDF-78d2-chunk.js +0 -1
- package/dist/networks/ZXing-5410-chunk.js +0 -1
|
@@ -0,0 +1,1708 @@
|
|
|
1
|
+
(self["webpackChunk_idscan_idvc2"] = self["webpackChunk_idscan_idvc2"] || []).push([[343],{
|
|
2
|
+
|
|
3
|
+
/***/ 2093:
|
|
4
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
5
|
+
|
|
6
|
+
// ESM COMPAT FLAG
|
|
7
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8
|
+
|
|
9
|
+
// EXPORTS
|
|
10
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
"default": () => (/* binding */ loaderClassLocal)
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// EXTERNAL MODULE: ./src/context.ts + 6 modules
|
|
15
|
+
var context = __webpack_require__(814);
|
|
16
|
+
// EXTERNAL MODULE: ./src/environment/networkNames.json
|
|
17
|
+
var networkNames = __webpack_require__(4554);
|
|
18
|
+
// EXTERNAL MODULE: ./src/controllers/ModuleController.js + 2 modules
|
|
19
|
+
var ModuleController = __webpack_require__(1263);
|
|
20
|
+
// EXTERNAL MODULE: ./node_modules/onnxruntime-web/dist/ort-web.min.js
|
|
21
|
+
var ort_web_min = __webpack_require__(8736);
|
|
22
|
+
// EXTERNAL MODULE: ./src/neural models/neuralModel.ts
|
|
23
|
+
var neuralModel = __webpack_require__(6955);
|
|
24
|
+
// EXTERNAL MODULE: ./src/neural models/Provider.ts
|
|
25
|
+
var Provider = __webpack_require__(813);
|
|
26
|
+
// EXTERNAL MODULE: ./src/helpers/canvas.ts
|
|
27
|
+
var canvas = __webpack_require__(528);
|
|
28
|
+
// EXTERNAL MODULE: ./src/helpers/color.ts
|
|
29
|
+
var color = __webpack_require__(683);
|
|
30
|
+
;// CONCATENATED MODULE: ./src/neural models/classLocal/exits.ts
|
|
31
|
+
var exits = [
|
|
32
|
+
'Back',
|
|
33
|
+
'BackWithoutBarcode',
|
|
34
|
+
'Front',
|
|
35
|
+
'None'
|
|
36
|
+
];
|
|
37
|
+
/* harmony default export */ const classLocal_exits = ((/* unused pure expression or super */ null && (exits)));
|
|
38
|
+
|
|
39
|
+
;// CONCATENATED MODULE: ./src/neural models/classLocalModel.ts
|
|
40
|
+
function _assert_this_initialized(self) {
|
|
41
|
+
if (self === void 0) {
|
|
42
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
43
|
+
}
|
|
44
|
+
return self;
|
|
45
|
+
}
|
|
46
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
47
|
+
try {
|
|
48
|
+
var info = gen[key](arg);
|
|
49
|
+
var value = info.value;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
reject(error);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (info.done) {
|
|
55
|
+
resolve(value);
|
|
56
|
+
} else {
|
|
57
|
+
Promise.resolve(value).then(_next, _throw);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function _async_to_generator(fn) {
|
|
61
|
+
return function() {
|
|
62
|
+
var self = this, args = arguments;
|
|
63
|
+
return new Promise(function(resolve, reject) {
|
|
64
|
+
var gen = fn.apply(self, args);
|
|
65
|
+
function _next(value) {
|
|
66
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
67
|
+
}
|
|
68
|
+
function _throw(err) {
|
|
69
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
70
|
+
}
|
|
71
|
+
_next(undefined);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function _class_call_check(instance, Constructor) {
|
|
76
|
+
if (!(instance instanceof Constructor)) {
|
|
77
|
+
throw new TypeError("Cannot call a class as a function");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function _defineProperties(target, props) {
|
|
81
|
+
for(var i = 0; i < props.length; i++){
|
|
82
|
+
var descriptor = props[i];
|
|
83
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
84
|
+
descriptor.configurable = true;
|
|
85
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
86
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
90
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
91
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
92
|
+
return Constructor;
|
|
93
|
+
}
|
|
94
|
+
function _define_property(obj, key, value) {
|
|
95
|
+
if (key in obj) {
|
|
96
|
+
Object.defineProperty(obj, key, {
|
|
97
|
+
value: value,
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
obj[key] = value;
|
|
104
|
+
}
|
|
105
|
+
return obj;
|
|
106
|
+
}
|
|
107
|
+
function _get_prototype_of(o) {
|
|
108
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
109
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
110
|
+
};
|
|
111
|
+
return _get_prototype_of(o);
|
|
112
|
+
}
|
|
113
|
+
function _inherits(subClass, superClass) {
|
|
114
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
115
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
116
|
+
}
|
|
117
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
118
|
+
constructor: {
|
|
119
|
+
value: subClass,
|
|
120
|
+
writable: true,
|
|
121
|
+
configurable: true
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
125
|
+
}
|
|
126
|
+
function _possible_constructor_return(self, call) {
|
|
127
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
128
|
+
return call;
|
|
129
|
+
}
|
|
130
|
+
return _assert_this_initialized(self);
|
|
131
|
+
}
|
|
132
|
+
function _set_prototype_of(o, p) {
|
|
133
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
134
|
+
o.__proto__ = p;
|
|
135
|
+
return o;
|
|
136
|
+
};
|
|
137
|
+
return _set_prototype_of(o, p);
|
|
138
|
+
}
|
|
139
|
+
function _type_of(obj) {
|
|
140
|
+
"@swc/helpers - typeof";
|
|
141
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
142
|
+
}
|
|
143
|
+
function _is_native_reflect_construct() {
|
|
144
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
145
|
+
if (Reflect.construct.sham) return false;
|
|
146
|
+
if (typeof Proxy === "function") return true;
|
|
147
|
+
try {
|
|
148
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
149
|
+
return true;
|
|
150
|
+
} catch (e) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function _create_super(Derived) {
|
|
155
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
156
|
+
return function _createSuperInternal() {
|
|
157
|
+
var Super = _get_prototype_of(Derived), result;
|
|
158
|
+
if (hasNativeReflectConstruct) {
|
|
159
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
160
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
161
|
+
} else {
|
|
162
|
+
result = Super.apply(this, arguments);
|
|
163
|
+
}
|
|
164
|
+
return _possible_constructor_return(this, result);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function _ts_generator(thisArg, body) {
|
|
168
|
+
var f, y, t, g, _ = {
|
|
169
|
+
label: 0,
|
|
170
|
+
sent: function() {
|
|
171
|
+
if (t[0] & 1) throw t[1];
|
|
172
|
+
return t[1];
|
|
173
|
+
},
|
|
174
|
+
trys: [],
|
|
175
|
+
ops: []
|
|
176
|
+
};
|
|
177
|
+
return g = {
|
|
178
|
+
next: verb(0),
|
|
179
|
+
"throw": verb(1),
|
|
180
|
+
"return": verb(2)
|
|
181
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
182
|
+
return this;
|
|
183
|
+
}), g;
|
|
184
|
+
function verb(n) {
|
|
185
|
+
return function(v) {
|
|
186
|
+
return step([
|
|
187
|
+
n,
|
|
188
|
+
v
|
|
189
|
+
]);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function step(op) {
|
|
193
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
194
|
+
while(_)try {
|
|
195
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
196
|
+
if (y = 0, t) op = [
|
|
197
|
+
op[0] & 2,
|
|
198
|
+
t.value
|
|
199
|
+
];
|
|
200
|
+
switch(op[0]){
|
|
201
|
+
case 0:
|
|
202
|
+
case 1:
|
|
203
|
+
t = op;
|
|
204
|
+
break;
|
|
205
|
+
case 4:
|
|
206
|
+
_.label++;
|
|
207
|
+
return {
|
|
208
|
+
value: op[1],
|
|
209
|
+
done: false
|
|
210
|
+
};
|
|
211
|
+
case 5:
|
|
212
|
+
_.label++;
|
|
213
|
+
y = op[1];
|
|
214
|
+
op = [
|
|
215
|
+
0
|
|
216
|
+
];
|
|
217
|
+
continue;
|
|
218
|
+
case 7:
|
|
219
|
+
op = _.ops.pop();
|
|
220
|
+
_.trys.pop();
|
|
221
|
+
continue;
|
|
222
|
+
default:
|
|
223
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
224
|
+
_ = 0;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
228
|
+
_.label = op[1];
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
232
|
+
_.label = t[1];
|
|
233
|
+
t = op;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
if (t && _.label < t[2]) {
|
|
237
|
+
_.label = t[2];
|
|
238
|
+
_.ops.push(op);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
if (t[2]) _.ops.pop();
|
|
242
|
+
_.trys.pop();
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
op = body.call(thisArg, _);
|
|
246
|
+
} catch (e) {
|
|
247
|
+
op = [
|
|
248
|
+
6,
|
|
249
|
+
e
|
|
250
|
+
];
|
|
251
|
+
y = 0;
|
|
252
|
+
} finally{
|
|
253
|
+
f = t = 0;
|
|
254
|
+
}
|
|
255
|
+
if (op[0] & 5) throw op[1];
|
|
256
|
+
return {
|
|
257
|
+
value: op[0] ? op[1] : void 0,
|
|
258
|
+
done: true
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
var BATCH = 1;
|
|
269
|
+
var WIDTH = 320;
|
|
270
|
+
var HEIGHT = 320;
|
|
271
|
+
var COLOR_COUNT = 3;
|
|
272
|
+
var INPUT_TENSOR_DIMS = [
|
|
273
|
+
BATCH,
|
|
274
|
+
HEIGHT,
|
|
275
|
+
WIDTH,
|
|
276
|
+
COLOR_COUNT
|
|
277
|
+
];
|
|
278
|
+
// const OUTPUT_TENSOR = [1, 8] as const;
|
|
279
|
+
var INPUT_TENSOR_NAME = 'serving_default_input_2:0';
|
|
280
|
+
var OUTPUT_TENSOR_NAME_BBOX = 'StatefulPartitionedCall:0';
|
|
281
|
+
var OUTPUT_TENSOR_NAME_CLASSIFIER = 'StatefulPartitionedCall:1';
|
|
282
|
+
var ClassLocalModel = /*#__PURE__*/ function(NeuralModel) {
|
|
283
|
+
"use strict";
|
|
284
|
+
_inherits(ClassLocalModel, NeuralModel);
|
|
285
|
+
var _super = _create_super(ClassLocalModel);
|
|
286
|
+
function ClassLocalModel() {
|
|
287
|
+
var url = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '', provider = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Provider/* Provider.WASM */.z.WASM, wasmPaths = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : '';
|
|
288
|
+
_class_call_check(this, ClassLocalModel);
|
|
289
|
+
var _this;
|
|
290
|
+
_this = _super.call(this, url, provider, wasmPaths);
|
|
291
|
+
_define_property(_assert_this_initialized(_this), "canvasSize", {
|
|
292
|
+
width: 1,
|
|
293
|
+
height: 1
|
|
294
|
+
});
|
|
295
|
+
return _this;
|
|
296
|
+
}
|
|
297
|
+
_create_class(ClassLocalModel, [
|
|
298
|
+
{
|
|
299
|
+
key: "setSizes",
|
|
300
|
+
value: function setSizes(param) {
|
|
301
|
+
var height = param.height, width = param.width;
|
|
302
|
+
this.canvasSize.width = width;
|
|
303
|
+
this.canvasSize.height = height;
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
key: "predict",
|
|
308
|
+
value: function predict(rgb) {
|
|
309
|
+
var inputTensor = new ort_web_min.Tensor('float32', rgb, INPUT_TENSOR_DIMS);
|
|
310
|
+
var feeds = _define_property({}, INPUT_TENSOR_NAME, inputTensor);
|
|
311
|
+
return this.session.run(feeds);
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
key: "predictFromImage",
|
|
316
|
+
value: function predictFromImage(input, dstCanvas) {
|
|
317
|
+
var _this = this;
|
|
318
|
+
return _async_to_generator(function() {
|
|
319
|
+
var src, dst, resized, buf, predicted;
|
|
320
|
+
return _ts_generator(this, function(_state) {
|
|
321
|
+
switch(_state.label){
|
|
322
|
+
case 0:
|
|
323
|
+
if (_this.loading) {
|
|
324
|
+
return [
|
|
325
|
+
2,
|
|
326
|
+
[]
|
|
327
|
+
];
|
|
328
|
+
}
|
|
329
|
+
src = input instanceof HTMLCanvasElement ? input : (0,canvas/* createCanvasFromImage */.DN)('angles-input-canvas', input);
|
|
330
|
+
dst = dstCanvas || (0,canvas/* createCanvas */.vL)('angles-canvas', {
|
|
331
|
+
width: WIDTH,
|
|
332
|
+
height: HEIGHT
|
|
333
|
+
});
|
|
334
|
+
resized = (0,canvas/* resize */.SI)(src, dst);
|
|
335
|
+
buf = (0,color/* rgbaToRgb */.Di)(resized, color/* Normalization.WITHOUT */.eQ.WITHOUT);
|
|
336
|
+
return [
|
|
337
|
+
4,
|
|
338
|
+
_this.predict(buf)
|
|
339
|
+
];
|
|
340
|
+
case 1:
|
|
341
|
+
predicted = _state.sent();
|
|
342
|
+
_this.setSizes(src);
|
|
343
|
+
return [
|
|
344
|
+
2,
|
|
345
|
+
_this.interpret(predicted[OUTPUT_TENSOR_NAME_CLASSIFIER].data, predicted[OUTPUT_TENSOR_NAME_BBOX].data)
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
})();
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
key: "interpret",
|
|
354
|
+
value: function interpret(classifierData, bboxData) {
|
|
355
|
+
var res = {
|
|
356
|
+
side: 'None',
|
|
357
|
+
bbox: {
|
|
358
|
+
topLeft: {
|
|
359
|
+
x: 0,
|
|
360
|
+
y: 0
|
|
361
|
+
},
|
|
362
|
+
bottomRight: {
|
|
363
|
+
x: 1,
|
|
364
|
+
y: 1
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
var predictionList = [];
|
|
369
|
+
classifierData.forEach(function(val, idx) {
|
|
370
|
+
return predictionList.push({
|
|
371
|
+
label: exits[idx],
|
|
372
|
+
score: val
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
res.side = predictionList.sort(function(a, b) {
|
|
376
|
+
return b.score - a.score;
|
|
377
|
+
})[0].label;
|
|
378
|
+
res.bbox.topLeft.x = ~~(bboxData[0] * this.canvasSize.width);
|
|
379
|
+
res.bbox.topLeft.y = ~~(bboxData[1] * this.canvasSize.height);
|
|
380
|
+
res.bbox.bottomRight.x = ~~(bboxData[2] * this.canvasSize.width);
|
|
381
|
+
res.bbox.bottomRight.y = ~~(bboxData[3] * this.canvasSize.height);
|
|
382
|
+
return res;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
]);
|
|
386
|
+
return ClassLocalModel;
|
|
387
|
+
}(neuralModel/* default */.Z);
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
;// CONCATENATED MODULE: ./src/loader/loaderClassLocal.ts
|
|
391
|
+
function loaderClassLocal_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
392
|
+
try {
|
|
393
|
+
var info = gen[key](arg);
|
|
394
|
+
var value = info.value;
|
|
395
|
+
} catch (error) {
|
|
396
|
+
reject(error);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (info.done) {
|
|
400
|
+
resolve(value);
|
|
401
|
+
} else {
|
|
402
|
+
Promise.resolve(value).then(_next, _throw);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function loaderClassLocal_async_to_generator(fn) {
|
|
406
|
+
return function() {
|
|
407
|
+
var self = this, args = arguments;
|
|
408
|
+
return new Promise(function(resolve, reject) {
|
|
409
|
+
var gen = fn.apply(self, args);
|
|
410
|
+
function _next(value) {
|
|
411
|
+
loaderClassLocal_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
412
|
+
}
|
|
413
|
+
function _throw(err) {
|
|
414
|
+
loaderClassLocal_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
415
|
+
}
|
|
416
|
+
_next(undefined);
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function loaderClassLocal_ts_generator(thisArg, body) {
|
|
421
|
+
var f, y, t, g, _ = {
|
|
422
|
+
label: 0,
|
|
423
|
+
sent: function() {
|
|
424
|
+
if (t[0] & 1) throw t[1];
|
|
425
|
+
return t[1];
|
|
426
|
+
},
|
|
427
|
+
trys: [],
|
|
428
|
+
ops: []
|
|
429
|
+
};
|
|
430
|
+
return g = {
|
|
431
|
+
next: verb(0),
|
|
432
|
+
"throw": verb(1),
|
|
433
|
+
"return": verb(2)
|
|
434
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
435
|
+
return this;
|
|
436
|
+
}), g;
|
|
437
|
+
function verb(n) {
|
|
438
|
+
return function(v) {
|
|
439
|
+
return step([
|
|
440
|
+
n,
|
|
441
|
+
v
|
|
442
|
+
]);
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function step(op) {
|
|
446
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
447
|
+
while(_)try {
|
|
448
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
449
|
+
if (y = 0, t) op = [
|
|
450
|
+
op[0] & 2,
|
|
451
|
+
t.value
|
|
452
|
+
];
|
|
453
|
+
switch(op[0]){
|
|
454
|
+
case 0:
|
|
455
|
+
case 1:
|
|
456
|
+
t = op;
|
|
457
|
+
break;
|
|
458
|
+
case 4:
|
|
459
|
+
_.label++;
|
|
460
|
+
return {
|
|
461
|
+
value: op[1],
|
|
462
|
+
done: false
|
|
463
|
+
};
|
|
464
|
+
case 5:
|
|
465
|
+
_.label++;
|
|
466
|
+
y = op[1];
|
|
467
|
+
op = [
|
|
468
|
+
0
|
|
469
|
+
];
|
|
470
|
+
continue;
|
|
471
|
+
case 7:
|
|
472
|
+
op = _.ops.pop();
|
|
473
|
+
_.trys.pop();
|
|
474
|
+
continue;
|
|
475
|
+
default:
|
|
476
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
477
|
+
_ = 0;
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
481
|
+
_.label = op[1];
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
485
|
+
_.label = t[1];
|
|
486
|
+
t = op;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
if (t && _.label < t[2]) {
|
|
490
|
+
_.label = t[2];
|
|
491
|
+
_.ops.push(op);
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
if (t[2]) _.ops.pop();
|
|
495
|
+
_.trys.pop();
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
op = body.call(thisArg, _);
|
|
499
|
+
} catch (e) {
|
|
500
|
+
op = [
|
|
501
|
+
6,
|
|
502
|
+
e
|
|
503
|
+
];
|
|
504
|
+
y = 0;
|
|
505
|
+
} finally{
|
|
506
|
+
f = t = 0;
|
|
507
|
+
}
|
|
508
|
+
if (op[0] & 5) throw op[1];
|
|
509
|
+
return {
|
|
510
|
+
value: op[0] ? op[1] : void 0,
|
|
511
|
+
done: true
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
/* harmony default export */ const loaderClassLocal = (/*#__PURE__*/loaderClassLocal_async_to_generator(function() {
|
|
521
|
+
var classLocalModel;
|
|
522
|
+
return loaderClassLocal_ts_generator(this, function(_state) {
|
|
523
|
+
classLocalModel = new ClassLocalModel("".concat(networkNames/* neurons.classLocalModel */.t.cK), Provider/* Provider.WASM */.z.WASM, context/* default.networkUrl */.Z.networkUrl);
|
|
524
|
+
ModuleController/* default.setModule */.Z.setModule('model', 'classLocal', classLocalModel);
|
|
525
|
+
return [
|
|
526
|
+
2
|
|
527
|
+
];
|
|
528
|
+
});
|
|
529
|
+
}));
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
/***/ }),
|
|
533
|
+
|
|
534
|
+
/***/ 5470:
|
|
535
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
536
|
+
|
|
537
|
+
// ESM COMPAT FLAG
|
|
538
|
+
__webpack_require__.r(__webpack_exports__);
|
|
539
|
+
|
|
540
|
+
// EXPORTS
|
|
541
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
542
|
+
"default": () => (/* binding */ loaderMRZ)
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
// EXTERNAL MODULE: ./src/context.ts + 6 modules
|
|
546
|
+
var context = __webpack_require__(814);
|
|
547
|
+
// EXTERNAL MODULE: ./src/controllers/ModuleController.js + 2 modules
|
|
548
|
+
var ModuleController = __webpack_require__(1263);
|
|
549
|
+
// EXTERNAL MODULE: ./node_modules/onnxruntime-web/dist/ort-web.min.js
|
|
550
|
+
var ort_web_min = __webpack_require__(8736);
|
|
551
|
+
// EXTERNAL MODULE: ./src/neural models/neuralModel.ts
|
|
552
|
+
var neuralModel = __webpack_require__(6955);
|
|
553
|
+
// EXTERNAL MODULE: ./src/neural models/Provider.ts
|
|
554
|
+
var Provider = __webpack_require__(813);
|
|
555
|
+
// EXTERNAL MODULE: ./src/helpers/color.ts
|
|
556
|
+
var color = __webpack_require__(683);
|
|
557
|
+
;// CONCATENATED MODULE: ./src/neural models/mrz/exits.js
|
|
558
|
+
var exits = [
|
|
559
|
+
'0',
|
|
560
|
+
'1',
|
|
561
|
+
'2',
|
|
562
|
+
'3',
|
|
563
|
+
'4',
|
|
564
|
+
'*',
|
|
565
|
+
'5',
|
|
566
|
+
'6',
|
|
567
|
+
'7',
|
|
568
|
+
'*',
|
|
569
|
+
'8',
|
|
570
|
+
'9',
|
|
571
|
+
'A',
|
|
572
|
+
'*',
|
|
573
|
+
'B',
|
|
574
|
+
'C',
|
|
575
|
+
'*',
|
|
576
|
+
'D',
|
|
577
|
+
'*',
|
|
578
|
+
'E',
|
|
579
|
+
'*',
|
|
580
|
+
'F',
|
|
581
|
+
'*',
|
|
582
|
+
'G',
|
|
583
|
+
'*',
|
|
584
|
+
'H',
|
|
585
|
+
'I',
|
|
586
|
+
'J',
|
|
587
|
+
'*',
|
|
588
|
+
'K',
|
|
589
|
+
'*',
|
|
590
|
+
'L',
|
|
591
|
+
'*',
|
|
592
|
+
'M',
|
|
593
|
+
'N',
|
|
594
|
+
'O',
|
|
595
|
+
'P',
|
|
596
|
+
'*',
|
|
597
|
+
'Q',
|
|
598
|
+
'R',
|
|
599
|
+
'*',
|
|
600
|
+
'S',
|
|
601
|
+
'T',
|
|
602
|
+
'*',
|
|
603
|
+
'U',
|
|
604
|
+
'*',
|
|
605
|
+
'V',
|
|
606
|
+
'*',
|
|
607
|
+
'W',
|
|
608
|
+
'X',
|
|
609
|
+
'Y',
|
|
610
|
+
'*',
|
|
611
|
+
'Z',
|
|
612
|
+
'<',
|
|
613
|
+
'*'
|
|
614
|
+
];
|
|
615
|
+
/* harmony default export */ const mrz_exits = ((/* unused pure expression or super */ null && (exits)));
|
|
616
|
+
|
|
617
|
+
;// CONCATENATED MODULE: ./src/neural models/mrzModel.ts
|
|
618
|
+
function _assert_this_initialized(self) {
|
|
619
|
+
if (self === void 0) {
|
|
620
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
621
|
+
}
|
|
622
|
+
return self;
|
|
623
|
+
}
|
|
624
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
625
|
+
try {
|
|
626
|
+
var info = gen[key](arg);
|
|
627
|
+
var value = info.value;
|
|
628
|
+
} catch (error) {
|
|
629
|
+
reject(error);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (info.done) {
|
|
633
|
+
resolve(value);
|
|
634
|
+
} else {
|
|
635
|
+
Promise.resolve(value).then(_next, _throw);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
function _async_to_generator(fn) {
|
|
639
|
+
return function() {
|
|
640
|
+
var self = this, args = arguments;
|
|
641
|
+
return new Promise(function(resolve, reject) {
|
|
642
|
+
var gen = fn.apply(self, args);
|
|
643
|
+
function _next(value) {
|
|
644
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
645
|
+
}
|
|
646
|
+
function _throw(err) {
|
|
647
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
648
|
+
}
|
|
649
|
+
_next(undefined);
|
|
650
|
+
});
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
function _class_call_check(instance, Constructor) {
|
|
654
|
+
if (!(instance instanceof Constructor)) {
|
|
655
|
+
throw new TypeError("Cannot call a class as a function");
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
function _defineProperties(target, props) {
|
|
659
|
+
for(var i = 0; i < props.length; i++){
|
|
660
|
+
var descriptor = props[i];
|
|
661
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
662
|
+
descriptor.configurable = true;
|
|
663
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
664
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
668
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
669
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
670
|
+
return Constructor;
|
|
671
|
+
}
|
|
672
|
+
function _define_property(obj, key, value) {
|
|
673
|
+
if (key in obj) {
|
|
674
|
+
Object.defineProperty(obj, key, {
|
|
675
|
+
value: value,
|
|
676
|
+
enumerable: true,
|
|
677
|
+
configurable: true,
|
|
678
|
+
writable: true
|
|
679
|
+
});
|
|
680
|
+
} else {
|
|
681
|
+
obj[key] = value;
|
|
682
|
+
}
|
|
683
|
+
return obj;
|
|
684
|
+
}
|
|
685
|
+
function _get_prototype_of(o) {
|
|
686
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
687
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
688
|
+
};
|
|
689
|
+
return _get_prototype_of(o);
|
|
690
|
+
}
|
|
691
|
+
function _inherits(subClass, superClass) {
|
|
692
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
693
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
694
|
+
}
|
|
695
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
696
|
+
constructor: {
|
|
697
|
+
value: subClass,
|
|
698
|
+
writable: true,
|
|
699
|
+
configurable: true
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
703
|
+
}
|
|
704
|
+
function _possible_constructor_return(self, call) {
|
|
705
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
706
|
+
return call;
|
|
707
|
+
}
|
|
708
|
+
return _assert_this_initialized(self);
|
|
709
|
+
}
|
|
710
|
+
function _set_prototype_of(o, p) {
|
|
711
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
712
|
+
o.__proto__ = p;
|
|
713
|
+
return o;
|
|
714
|
+
};
|
|
715
|
+
return _set_prototype_of(o, p);
|
|
716
|
+
}
|
|
717
|
+
function _type_of(obj) {
|
|
718
|
+
"@swc/helpers - typeof";
|
|
719
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
720
|
+
}
|
|
721
|
+
function _is_native_reflect_construct() {
|
|
722
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
723
|
+
if (Reflect.construct.sham) return false;
|
|
724
|
+
if (typeof Proxy === "function") return true;
|
|
725
|
+
try {
|
|
726
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
727
|
+
return true;
|
|
728
|
+
} catch (e) {
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
function _create_super(Derived) {
|
|
733
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
734
|
+
return function _createSuperInternal() {
|
|
735
|
+
var Super = _get_prototype_of(Derived), result;
|
|
736
|
+
if (hasNativeReflectConstruct) {
|
|
737
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
738
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
739
|
+
} else {
|
|
740
|
+
result = Super.apply(this, arguments);
|
|
741
|
+
}
|
|
742
|
+
return _possible_constructor_return(this, result);
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function _ts_generator(thisArg, body) {
|
|
746
|
+
var f, y, t, g, _ = {
|
|
747
|
+
label: 0,
|
|
748
|
+
sent: function() {
|
|
749
|
+
if (t[0] & 1) throw t[1];
|
|
750
|
+
return t[1];
|
|
751
|
+
},
|
|
752
|
+
trys: [],
|
|
753
|
+
ops: []
|
|
754
|
+
};
|
|
755
|
+
return g = {
|
|
756
|
+
next: verb(0),
|
|
757
|
+
"throw": verb(1),
|
|
758
|
+
"return": verb(2)
|
|
759
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
760
|
+
return this;
|
|
761
|
+
}), g;
|
|
762
|
+
function verb(n) {
|
|
763
|
+
return function(v) {
|
|
764
|
+
return step([
|
|
765
|
+
n,
|
|
766
|
+
v
|
|
767
|
+
]);
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function step(op) {
|
|
771
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
772
|
+
while(_)try {
|
|
773
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
774
|
+
if (y = 0, t) op = [
|
|
775
|
+
op[0] & 2,
|
|
776
|
+
t.value
|
|
777
|
+
];
|
|
778
|
+
switch(op[0]){
|
|
779
|
+
case 0:
|
|
780
|
+
case 1:
|
|
781
|
+
t = op;
|
|
782
|
+
break;
|
|
783
|
+
case 4:
|
|
784
|
+
_.label++;
|
|
785
|
+
return {
|
|
786
|
+
value: op[1],
|
|
787
|
+
done: false
|
|
788
|
+
};
|
|
789
|
+
case 5:
|
|
790
|
+
_.label++;
|
|
791
|
+
y = op[1];
|
|
792
|
+
op = [
|
|
793
|
+
0
|
|
794
|
+
];
|
|
795
|
+
continue;
|
|
796
|
+
case 7:
|
|
797
|
+
op = _.ops.pop();
|
|
798
|
+
_.trys.pop();
|
|
799
|
+
continue;
|
|
800
|
+
default:
|
|
801
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
802
|
+
_ = 0;
|
|
803
|
+
continue;
|
|
804
|
+
}
|
|
805
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
806
|
+
_.label = op[1];
|
|
807
|
+
break;
|
|
808
|
+
}
|
|
809
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
810
|
+
_.label = t[1];
|
|
811
|
+
t = op;
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
814
|
+
if (t && _.label < t[2]) {
|
|
815
|
+
_.label = t[2];
|
|
816
|
+
_.ops.push(op);
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
if (t[2]) _.ops.pop();
|
|
820
|
+
_.trys.pop();
|
|
821
|
+
continue;
|
|
822
|
+
}
|
|
823
|
+
op = body.call(thisArg, _);
|
|
824
|
+
} catch (e) {
|
|
825
|
+
op = [
|
|
826
|
+
6,
|
|
827
|
+
e
|
|
828
|
+
];
|
|
829
|
+
y = 0;
|
|
830
|
+
} finally{
|
|
831
|
+
f = t = 0;
|
|
832
|
+
}
|
|
833
|
+
if (op[0] & 5) throw op[1];
|
|
834
|
+
return {
|
|
835
|
+
value: op[0] ? op[1] : void 0,
|
|
836
|
+
done: true
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
var ONE_LETTER_SIZE = 784;
|
|
846
|
+
var HEIGHT = 28;
|
|
847
|
+
var WIDTH = 28;
|
|
848
|
+
var COLOR_COUNT = 1;
|
|
849
|
+
var INPUT_TENSOR_DIMS = [
|
|
850
|
+
1,
|
|
851
|
+
HEIGHT,
|
|
852
|
+
WIDTH,
|
|
853
|
+
COLOR_COUNT
|
|
854
|
+
];
|
|
855
|
+
var INPUT_TENSOR_NAME = 'input_1';
|
|
856
|
+
var OUTPUT_TENSOR_NAME = 'dense';
|
|
857
|
+
var MrzModel = /*#__PURE__*/ function(NeuralModel) {
|
|
858
|
+
"use strict";
|
|
859
|
+
_inherits(MrzModel, NeuralModel);
|
|
860
|
+
var _super = _create_super(MrzModel);
|
|
861
|
+
function MrzModel() {
|
|
862
|
+
var url = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '', provider = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Provider/* Provider.WASM */.z.WASM, wasmPaths = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : '';
|
|
863
|
+
_class_call_check(this, MrzModel);
|
|
864
|
+
var _this;
|
|
865
|
+
_this = _super.call(this, url, provider, wasmPaths);
|
|
866
|
+
_define_property(_assert_this_initialized(_this), "promiseList", void 0);
|
|
867
|
+
_define_property(_assert_this_initialized(_this), "predictionList", void 0);
|
|
868
|
+
return _this;
|
|
869
|
+
}
|
|
870
|
+
_create_class(MrzModel, [
|
|
871
|
+
{
|
|
872
|
+
key: "predict",
|
|
873
|
+
value: function predict(rgb) {
|
|
874
|
+
var inputTensor = new ort_web_min.Tensor('float32', rgb, INPUT_TENSOR_DIMS);
|
|
875
|
+
var feeds = _define_property({}, INPUT_TENSOR_NAME, inputTensor);
|
|
876
|
+
return this.session.run(feeds);
|
|
877
|
+
}
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
key: "predictFromArray",
|
|
881
|
+
value: function predictFromArray(input, batchSize) {
|
|
882
|
+
var _this = this;
|
|
883
|
+
return _async_to_generator(function() {
|
|
884
|
+
var buf, i;
|
|
885
|
+
return _ts_generator(this, function(_state) {
|
|
886
|
+
switch(_state.label){
|
|
887
|
+
case 0:
|
|
888
|
+
if (!_this.promiseList) {
|
|
889
|
+
_this.promiseList = new Array(batchSize).fill(0);
|
|
890
|
+
}
|
|
891
|
+
if (!_this.predictionList) {
|
|
892
|
+
_this.predictionList = new Array(batchSize).fill(0);
|
|
893
|
+
}
|
|
894
|
+
if (_this.loading) {
|
|
895
|
+
return [
|
|
896
|
+
2,
|
|
897
|
+
[]
|
|
898
|
+
];
|
|
899
|
+
}
|
|
900
|
+
buf = (0,color/* normalize */.Fv)(input, color/* Normalization.STANDART */.eQ.STANDART);
|
|
901
|
+
for(i = 0; i < batchSize; i += 1){
|
|
902
|
+
_this.promiseList[i] = _this.predict(buf.subarray(ONE_LETTER_SIZE * i, ONE_LETTER_SIZE * (i + 1)));
|
|
903
|
+
}
|
|
904
|
+
return [
|
|
905
|
+
4,
|
|
906
|
+
Promise.all(_this.promiseList)
|
|
907
|
+
];
|
|
908
|
+
case 1:
|
|
909
|
+
_state.sent().forEach(function(prediction, i) {
|
|
910
|
+
_this.predictionList[i] = _this.interpret(prediction[OUTPUT_TENSOR_NAME].data);
|
|
911
|
+
});
|
|
912
|
+
return [
|
|
913
|
+
2,
|
|
914
|
+
_this.predictionList
|
|
915
|
+
];
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
})();
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
key: "interpret",
|
|
923
|
+
value: function interpret(data) {
|
|
924
|
+
return Array.from(data).map(function(val, idx) {
|
|
925
|
+
return {
|
|
926
|
+
value: exits[idx],
|
|
927
|
+
confidence: val
|
|
928
|
+
};
|
|
929
|
+
}).sort(function(a, b) {
|
|
930
|
+
return a.confidence - b.confidence;
|
|
931
|
+
}).slice(-3).reverse();
|
|
932
|
+
}
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
key: "isLoading",
|
|
936
|
+
get: function get() {
|
|
937
|
+
return this.loading;
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
key: "predictFromImage",
|
|
942
|
+
value: function predictFromImage(input, dstCanvas) {}
|
|
943
|
+
}
|
|
944
|
+
]);
|
|
945
|
+
return MrzModel;
|
|
946
|
+
}(neuralModel/* default */.Z);
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
// EXTERNAL MODULE: ./src/environment/networkNames.json
|
|
950
|
+
var networkNames = __webpack_require__(4554);
|
|
951
|
+
;// CONCATENATED MODULE: ./src/modules/MrzModule.ts
|
|
952
|
+
function _array_like_to_array(arr, len) {
|
|
953
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
954
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
955
|
+
return arr2;
|
|
956
|
+
}
|
|
957
|
+
function _array_with_holes(arr) {
|
|
958
|
+
if (Array.isArray(arr)) return arr;
|
|
959
|
+
}
|
|
960
|
+
function MrzModule_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
961
|
+
try {
|
|
962
|
+
var info = gen[key](arg);
|
|
963
|
+
var value = info.value;
|
|
964
|
+
} catch (error) {
|
|
965
|
+
reject(error);
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
if (info.done) {
|
|
969
|
+
resolve(value);
|
|
970
|
+
} else {
|
|
971
|
+
Promise.resolve(value).then(_next, _throw);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
function MrzModule_async_to_generator(fn) {
|
|
975
|
+
return function() {
|
|
976
|
+
var self = this, args = arguments;
|
|
977
|
+
return new Promise(function(resolve, reject) {
|
|
978
|
+
var gen = fn.apply(self, args);
|
|
979
|
+
function _next(value) {
|
|
980
|
+
MrzModule_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
981
|
+
}
|
|
982
|
+
function _throw(err) {
|
|
983
|
+
MrzModule_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
984
|
+
}
|
|
985
|
+
_next(undefined);
|
|
986
|
+
});
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
function MrzModule_class_call_check(instance, Constructor) {
|
|
990
|
+
if (!(instance instanceof Constructor)) {
|
|
991
|
+
throw new TypeError("Cannot call a class as a function");
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
function MrzModule_defineProperties(target, props) {
|
|
995
|
+
for(var i = 0; i < props.length; i++){
|
|
996
|
+
var descriptor = props[i];
|
|
997
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
998
|
+
descriptor.configurable = true;
|
|
999
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1000
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
function MrzModule_create_class(Constructor, protoProps, staticProps) {
|
|
1004
|
+
if (protoProps) MrzModule_defineProperties(Constructor.prototype, protoProps);
|
|
1005
|
+
if (staticProps) MrzModule_defineProperties(Constructor, staticProps);
|
|
1006
|
+
return Constructor;
|
|
1007
|
+
}
|
|
1008
|
+
function MrzModule_define_property(obj, key, value) {
|
|
1009
|
+
if (key in obj) {
|
|
1010
|
+
Object.defineProperty(obj, key, {
|
|
1011
|
+
value: value,
|
|
1012
|
+
enumerable: true,
|
|
1013
|
+
configurable: true,
|
|
1014
|
+
writable: true
|
|
1015
|
+
});
|
|
1016
|
+
} else {
|
|
1017
|
+
obj[key] = value;
|
|
1018
|
+
}
|
|
1019
|
+
return obj;
|
|
1020
|
+
}
|
|
1021
|
+
function _iterable_to_array_limit(arr, i) {
|
|
1022
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1023
|
+
if (_i == null) return;
|
|
1024
|
+
var _arr = [];
|
|
1025
|
+
var _n = true;
|
|
1026
|
+
var _d = false;
|
|
1027
|
+
var _s, _e;
|
|
1028
|
+
try {
|
|
1029
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1030
|
+
_arr.push(_s.value);
|
|
1031
|
+
if (i && _arr.length === i) break;
|
|
1032
|
+
}
|
|
1033
|
+
} catch (err) {
|
|
1034
|
+
_d = true;
|
|
1035
|
+
_e = err;
|
|
1036
|
+
} finally{
|
|
1037
|
+
try {
|
|
1038
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1039
|
+
} finally{
|
|
1040
|
+
if (_d) throw _e;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
return _arr;
|
|
1044
|
+
}
|
|
1045
|
+
function _non_iterable_rest() {
|
|
1046
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1047
|
+
}
|
|
1048
|
+
function _object_spread(target) {
|
|
1049
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1050
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
1051
|
+
var ownKeys = Object.keys(source);
|
|
1052
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
1053
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1054
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1055
|
+
}));
|
|
1056
|
+
}
|
|
1057
|
+
ownKeys.forEach(function(key) {
|
|
1058
|
+
MrzModule_define_property(target, key, source[key]);
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
return target;
|
|
1062
|
+
}
|
|
1063
|
+
function ownKeys(object, enumerableOnly) {
|
|
1064
|
+
var keys = Object.keys(object);
|
|
1065
|
+
if (Object.getOwnPropertySymbols) {
|
|
1066
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
1067
|
+
if (enumerableOnly) {
|
|
1068
|
+
symbols = symbols.filter(function(sym) {
|
|
1069
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
keys.push.apply(keys, symbols);
|
|
1073
|
+
}
|
|
1074
|
+
return keys;
|
|
1075
|
+
}
|
|
1076
|
+
function _object_spread_props(target, source) {
|
|
1077
|
+
source = source != null ? source : {};
|
|
1078
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
1079
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1080
|
+
} else {
|
|
1081
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
1082
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
return target;
|
|
1086
|
+
}
|
|
1087
|
+
function _sliced_to_array(arr, i) {
|
|
1088
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
1089
|
+
}
|
|
1090
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
1091
|
+
if (!o) return;
|
|
1092
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1093
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1094
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1095
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1096
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1097
|
+
}
|
|
1098
|
+
function MrzModule_ts_generator(thisArg, body) {
|
|
1099
|
+
var f, y, t, g, _ = {
|
|
1100
|
+
label: 0,
|
|
1101
|
+
sent: function() {
|
|
1102
|
+
if (t[0] & 1) throw t[1];
|
|
1103
|
+
return t[1];
|
|
1104
|
+
},
|
|
1105
|
+
trys: [],
|
|
1106
|
+
ops: []
|
|
1107
|
+
};
|
|
1108
|
+
return(g = {
|
|
1109
|
+
next: verb(0),
|
|
1110
|
+
"throw": verb(1),
|
|
1111
|
+
"return": verb(2)
|
|
1112
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1113
|
+
return this;
|
|
1114
|
+
}), g);
|
|
1115
|
+
function verb(n) {
|
|
1116
|
+
return function(v) {
|
|
1117
|
+
return step([
|
|
1118
|
+
n,
|
|
1119
|
+
v
|
|
1120
|
+
]);
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
function step(op) {
|
|
1124
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1125
|
+
while(_)try {
|
|
1126
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1127
|
+
if (y = 0, t) op = [
|
|
1128
|
+
op[0] & 2,
|
|
1129
|
+
t.value
|
|
1130
|
+
];
|
|
1131
|
+
switch(op[0]){
|
|
1132
|
+
case 0:
|
|
1133
|
+
case 1:
|
|
1134
|
+
t = op;
|
|
1135
|
+
break;
|
|
1136
|
+
case 4:
|
|
1137
|
+
_.label++;
|
|
1138
|
+
return {
|
|
1139
|
+
value: op[1],
|
|
1140
|
+
done: false
|
|
1141
|
+
};
|
|
1142
|
+
case 5:
|
|
1143
|
+
_.label++;
|
|
1144
|
+
y = op[1];
|
|
1145
|
+
op = [
|
|
1146
|
+
0
|
|
1147
|
+
];
|
|
1148
|
+
continue;
|
|
1149
|
+
case 7:
|
|
1150
|
+
op = _.ops.pop();
|
|
1151
|
+
_.trys.pop();
|
|
1152
|
+
continue;
|
|
1153
|
+
default:
|
|
1154
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1155
|
+
_ = 0;
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1159
|
+
_.label = op[1];
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1163
|
+
_.label = t[1];
|
|
1164
|
+
t = op;
|
|
1165
|
+
break;
|
|
1166
|
+
}
|
|
1167
|
+
if (t && _.label < t[2]) {
|
|
1168
|
+
_.label = t[2];
|
|
1169
|
+
_.ops.push(op);
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
if (t[2]) _.ops.pop();
|
|
1173
|
+
_.trys.pop();
|
|
1174
|
+
continue;
|
|
1175
|
+
}
|
|
1176
|
+
op = body.call(thisArg, _);
|
|
1177
|
+
} catch (e) {
|
|
1178
|
+
op = [
|
|
1179
|
+
6,
|
|
1180
|
+
e
|
|
1181
|
+
];
|
|
1182
|
+
y = 0;
|
|
1183
|
+
} finally{
|
|
1184
|
+
f = t = 0;
|
|
1185
|
+
}
|
|
1186
|
+
if (op[0] & 5) throw op[1];
|
|
1187
|
+
return {
|
|
1188
|
+
value: op[0] ? op[1] : void 0,
|
|
1189
|
+
done: true
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
/* eslint-disable no-underscore-dangle */ var MrzModule = /*#__PURE__*/ function() {
|
|
1197
|
+
"use strict";
|
|
1198
|
+
function MrzModule(worker, key, networkUrl) {
|
|
1199
|
+
var _this = this;
|
|
1200
|
+
MrzModule_class_call_check(this, MrzModule);
|
|
1201
|
+
MrzModule_define_property(this, "w", 0);
|
|
1202
|
+
MrzModule_define_property(this, "h", 0);
|
|
1203
|
+
MrzModule_define_property(this, "successCount", 0);
|
|
1204
|
+
MrzModule_define_property(this, "worker", void 0);
|
|
1205
|
+
MrzModule_define_property(this, "model", void 0);
|
|
1206
|
+
MrzModule_define_property(this, "isInitialized", false);
|
|
1207
|
+
MrzModule_define_property(this, "isProcessing", false);
|
|
1208
|
+
this.model = new MrzModel("".concat(networkNames/* neurons.mrz */.t.$I), Provider/* Provider.WASM */.z.WASM, networkUrl);
|
|
1209
|
+
this.worker = worker;
|
|
1210
|
+
this.worker.postMessage({
|
|
1211
|
+
fn: 'init',
|
|
1212
|
+
initData: {
|
|
1213
|
+
key: key,
|
|
1214
|
+
networkUrl: networkUrl
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
this.worker.onmessage = function(param) {
|
|
1218
|
+
var _param_data = param.data, name = _param_data.name, data = _param_data.data;
|
|
1219
|
+
if (name === 'initialization') {
|
|
1220
|
+
_this.isInitialized = data;
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
MrzModule_create_class(MrzModule, [
|
|
1225
|
+
{
|
|
1226
|
+
key: "getErrorVal",
|
|
1227
|
+
value: function getErrorVal(errorId) {
|
|
1228
|
+
var errorVal;
|
|
1229
|
+
if (errorId === -3) {
|
|
1230
|
+
errorVal = 0; // 'License Key has expired'
|
|
1231
|
+
}
|
|
1232
|
+
if (errorId === -2) {
|
|
1233
|
+
errorVal = 1; // 'Invalid License Key'
|
|
1234
|
+
}
|
|
1235
|
+
return errorVal;
|
|
1236
|
+
}
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
/**
|
|
1240
|
+
* returns error Object
|
|
1241
|
+
* @return {ILicenceError}
|
|
1242
|
+
*/ key: "licenseError",
|
|
1243
|
+
value: function licenseError(errorId) {
|
|
1244
|
+
return {
|
|
1245
|
+
error: true,
|
|
1246
|
+
errorType: 'licenceKeyError',
|
|
1247
|
+
errorVal: this.getErrorVal(errorId)
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
key: "yComparator",
|
|
1253
|
+
value: function yComparator(point1, point2) {
|
|
1254
|
+
return point1.y < point2.y ? [
|
|
1255
|
+
point1,
|
|
1256
|
+
point2
|
|
1257
|
+
] : [
|
|
1258
|
+
point2,
|
|
1259
|
+
point1
|
|
1260
|
+
];
|
|
1261
|
+
}
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
key: "allocate",
|
|
1265
|
+
value: function allocate() {}
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1269
|
+
key: "prepareMRZlocation",
|
|
1270
|
+
value: function prepareMRZlocation(locations) {
|
|
1271
|
+
var leftTop = locations.leftTop, rightTop = locations.rightTop, rightBottom = locations.rightBottom, leftBottom = locations.leftBottom;
|
|
1272
|
+
var points = [
|
|
1273
|
+
leftTop,
|
|
1274
|
+
rightTop,
|
|
1275
|
+
rightBottom,
|
|
1276
|
+
leftBottom
|
|
1277
|
+
].sort(function(a, b) {
|
|
1278
|
+
return a.x - b.x;
|
|
1279
|
+
});
|
|
1280
|
+
var _this_yComparator = _sliced_to_array(this.yComparator(points[0], points[1]), 2), tl = _this_yComparator[0], bl = _this_yComparator[1];
|
|
1281
|
+
var _this_yComparator1 = _sliced_to_array(this.yComparator(points[2], points[3]), 2), tr = _this_yComparator1[0], br = _this_yComparator1[1];
|
|
1282
|
+
var factor = 0.03;
|
|
1283
|
+
return {
|
|
1284
|
+
leftTop: {
|
|
1285
|
+
x: tl.x - factor,
|
|
1286
|
+
y: tl.y - factor
|
|
1287
|
+
},
|
|
1288
|
+
rightTop: {
|
|
1289
|
+
x: tr.x + factor,
|
|
1290
|
+
y: tr.y - factor
|
|
1291
|
+
},
|
|
1292
|
+
rightBottom: {
|
|
1293
|
+
x: br.x + factor,
|
|
1294
|
+
y: br.y + factor
|
|
1295
|
+
},
|
|
1296
|
+
leftBottom: {
|
|
1297
|
+
x: bl.x - factor,
|
|
1298
|
+
y: bl.y + factor
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1305
|
+
key: "writeResults",
|
|
1306
|
+
value: function writeResults(mrzResults) {
|
|
1307
|
+
var res = {
|
|
1308
|
+
mrzText: ''
|
|
1309
|
+
};
|
|
1310
|
+
var lines = mrzResults.fields.filter(function(field) {
|
|
1311
|
+
return field.name.indexOf('Line') !== -1 && field.value.length > 0;
|
|
1312
|
+
}).map(function(field) {
|
|
1313
|
+
return field.value;
|
|
1314
|
+
}).join('\n');
|
|
1315
|
+
if (lines.length > 0) {
|
|
1316
|
+
res.mrzText = window.btoa(lines);
|
|
1317
|
+
}
|
|
1318
|
+
return res;
|
|
1319
|
+
}
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
key: "predict",
|
|
1323
|
+
value: function predict(batchArr, batchSize) {
|
|
1324
|
+
var _this = this;
|
|
1325
|
+
return MrzModule_async_to_generator(function() {
|
|
1326
|
+
var result;
|
|
1327
|
+
return MrzModule_ts_generator(this, function(_state) {
|
|
1328
|
+
switch(_state.label){
|
|
1329
|
+
case 0:
|
|
1330
|
+
return [
|
|
1331
|
+
4,
|
|
1332
|
+
_this.model.predictFromArray(batchArr, batchSize)
|
|
1333
|
+
];
|
|
1334
|
+
case 1:
|
|
1335
|
+
result = _state.sent();
|
|
1336
|
+
if (!(result.filter(function(param) {
|
|
1337
|
+
var _param = _sliced_to_array(param, 1), value = _param[0].value;
|
|
1338
|
+
return value === '*';
|
|
1339
|
+
}).length > 3)) return [
|
|
1340
|
+
3,
|
|
1341
|
+
3
|
|
1342
|
+
];
|
|
1343
|
+
return [
|
|
1344
|
+
4,
|
|
1345
|
+
_this.model.predictFromArray(batchArr.reverse(), batchSize)
|
|
1346
|
+
];
|
|
1347
|
+
case 2:
|
|
1348
|
+
result = _state.sent();
|
|
1349
|
+
_state.label = 3;
|
|
1350
|
+
case 3:
|
|
1351
|
+
return [
|
|
1352
|
+
2,
|
|
1353
|
+
result
|
|
1354
|
+
];
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
})();
|
|
1358
|
+
}
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
key: "scan",
|
|
1362
|
+
value: function scan(iData) {
|
|
1363
|
+
var _this = this;
|
|
1364
|
+
return new Promise(function(resolve) {
|
|
1365
|
+
_this.worker.postMessage({
|
|
1366
|
+
fn: 'prepare',
|
|
1367
|
+
iData: iData
|
|
1368
|
+
});
|
|
1369
|
+
var _this1 = _this;
|
|
1370
|
+
_this.worker.onmessage = function() {
|
|
1371
|
+
var _ref = MrzModule_async_to_generator(function(param) {
|
|
1372
|
+
var _param_data, name, data, predictions;
|
|
1373
|
+
return MrzModule_ts_generator(this, function(_state) {
|
|
1374
|
+
switch(_state.label){
|
|
1375
|
+
case 0:
|
|
1376
|
+
_param_data = param.data, name = _param_data.name, data = _param_data.data;
|
|
1377
|
+
if (!(name === 'batchArr')) return [
|
|
1378
|
+
3,
|
|
1379
|
+
2
|
|
1380
|
+
];
|
|
1381
|
+
return [
|
|
1382
|
+
4,
|
|
1383
|
+
_this1.predict(data.batchArr, data.batchSize)
|
|
1384
|
+
];
|
|
1385
|
+
case 1:
|
|
1386
|
+
predictions = _state.sent();
|
|
1387
|
+
_this1.worker.postMessage({
|
|
1388
|
+
fn: 'process',
|
|
1389
|
+
predictions: predictions
|
|
1390
|
+
});
|
|
1391
|
+
return [
|
|
1392
|
+
2
|
|
1393
|
+
];
|
|
1394
|
+
case 2:
|
|
1395
|
+
if (name === 'result') {
|
|
1396
|
+
resolve(data);
|
|
1397
|
+
}
|
|
1398
|
+
resolve(data);
|
|
1399
|
+
return [
|
|
1400
|
+
2
|
|
1401
|
+
];
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
});
|
|
1405
|
+
return function(_) {
|
|
1406
|
+
return _ref.apply(this, arguments);
|
|
1407
|
+
};
|
|
1408
|
+
}();
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
key: "processMRZ",
|
|
1414
|
+
value: /**
|
|
1415
|
+
* process frame for MRZ
|
|
1416
|
+
* @param data
|
|
1417
|
+
*/ function processMRZ(data) {
|
|
1418
|
+
var _this = this;
|
|
1419
|
+
return MrzModule_async_to_generator(function() {
|
|
1420
|
+
var _r_status, res, r, rating, color, isTrusted, isValidRating;
|
|
1421
|
+
return MrzModule_ts_generator(this, function(_state) {
|
|
1422
|
+
switch(_state.label){
|
|
1423
|
+
case 0:
|
|
1424
|
+
res = {
|
|
1425
|
+
status: false,
|
|
1426
|
+
cancel: false,
|
|
1427
|
+
touch: false,
|
|
1428
|
+
image: null,
|
|
1429
|
+
type: 'mrz'
|
|
1430
|
+
};
|
|
1431
|
+
if (_this.isProcessing) {
|
|
1432
|
+
return [
|
|
1433
|
+
2,
|
|
1434
|
+
res
|
|
1435
|
+
];
|
|
1436
|
+
}
|
|
1437
|
+
if (!_this.isInitialized) {
|
|
1438
|
+
return [
|
|
1439
|
+
2,
|
|
1440
|
+
res
|
|
1441
|
+
];
|
|
1442
|
+
}
|
|
1443
|
+
_this.isProcessing = true;
|
|
1444
|
+
return [
|
|
1445
|
+
4,
|
|
1446
|
+
_this.scan(data)
|
|
1447
|
+
];
|
|
1448
|
+
case 1:
|
|
1449
|
+
r = _state.sent();
|
|
1450
|
+
if (r === null || r === void 0 ? void 0 : r.errorId) {
|
|
1451
|
+
_this.isProcessing = false;
|
|
1452
|
+
return [
|
|
1453
|
+
2,
|
|
1454
|
+
_object_spread_props(_object_spread({}, r), {
|
|
1455
|
+
error: _this.licenseError(r.errorId)
|
|
1456
|
+
})
|
|
1457
|
+
];
|
|
1458
|
+
}
|
|
1459
|
+
if (r && (r === null || r === void 0 ? void 0 : (_r_status = r.status) === null || _r_status === void 0 ? void 0 : _r_status.value) === 0 && (r === null || r === void 0 ? void 0 : r.count) > 0) {
|
|
1460
|
+
rating = _this.estimateResults(r);
|
|
1461
|
+
color = rating === r.count && r.symbolsConf > 0.95 ? 'green' : 'yellow';
|
|
1462
|
+
res.coords = {
|
|
1463
|
+
locations: _this.prepareMRZlocation(r.location),
|
|
1464
|
+
color: color
|
|
1465
|
+
};
|
|
1466
|
+
isTrusted = rating === r.count && r.symbolsConf > 0.85;
|
|
1467
|
+
isValidRating = rating >= r.count - 2;
|
|
1468
|
+
if (isTrusted || isValidRating) {
|
|
1469
|
+
_this.successCount += 1;
|
|
1470
|
+
if (_this.successCount >= 3) {
|
|
1471
|
+
res.status = true;
|
|
1472
|
+
res.needToCut = true;
|
|
1473
|
+
res.image = data;
|
|
1474
|
+
res.results = _this.writeResults(r);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
} else {
|
|
1478
|
+
res.coords = null;
|
|
1479
|
+
_this.successCount = 0;
|
|
1480
|
+
}
|
|
1481
|
+
_this.isProcessing = false;
|
|
1482
|
+
return [
|
|
1483
|
+
2,
|
|
1484
|
+
res
|
|
1485
|
+
];
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
})();
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1491
|
+
{
|
|
1492
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1493
|
+
key: "estimateResults",
|
|
1494
|
+
value: function estimateResults(data) {
|
|
1495
|
+
return data.count === 0 ? 0 : data.fields.reduce(function(sum, param) {
|
|
1496
|
+
var status = param.status;
|
|
1497
|
+
return status === 'Valid' ? sum + 1 : sum;
|
|
1498
|
+
}, 0);
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
{
|
|
1502
|
+
key: "detectMrz",
|
|
1503
|
+
value: /**
|
|
1504
|
+
* detects MRZ on ImageData
|
|
1505
|
+
* @param {ImageData} imageData
|
|
1506
|
+
* @return {Promise<>}
|
|
1507
|
+
*/ function detectMrz(imageData) {
|
|
1508
|
+
var _this = this;
|
|
1509
|
+
return MrzModule_async_to_generator(function() {
|
|
1510
|
+
var mrzResults, locations, results, res;
|
|
1511
|
+
return MrzModule_ts_generator(this, function(_state) {
|
|
1512
|
+
switch(_state.label){
|
|
1513
|
+
case 0:
|
|
1514
|
+
return [
|
|
1515
|
+
4,
|
|
1516
|
+
_this.scan(imageData)
|
|
1517
|
+
];
|
|
1518
|
+
case 1:
|
|
1519
|
+
mrzResults = _state.sent();
|
|
1520
|
+
if (mrzResults && mrzResults.count > 0 && mrzResults.symbolsConf > 0.80) {
|
|
1521
|
+
locations = _this.prepareMRZlocation(mrzResults.location);
|
|
1522
|
+
results = _this.writeResults(mrzResults);
|
|
1523
|
+
return [
|
|
1524
|
+
2,
|
|
1525
|
+
{
|
|
1526
|
+
status: true,
|
|
1527
|
+
locations: locations,
|
|
1528
|
+
results: results
|
|
1529
|
+
}
|
|
1530
|
+
];
|
|
1531
|
+
}
|
|
1532
|
+
res = {
|
|
1533
|
+
status: false
|
|
1534
|
+
};
|
|
1535
|
+
if (mrzResults === null || mrzResults === void 0 ? void 0 : mrzResults.errorId) {
|
|
1536
|
+
res.error = _this.licenseError(mrzResults.errorId);
|
|
1537
|
+
}
|
|
1538
|
+
return [
|
|
1539
|
+
2,
|
|
1540
|
+
res
|
|
1541
|
+
];
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
})();
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
]);
|
|
1548
|
+
return MrzModule;
|
|
1549
|
+
}();
|
|
1550
|
+
/* harmony default export */ const modules_MrzModule = (MrzModule);
|
|
1551
|
+
|
|
1552
|
+
// EXTERNAL MODULE: ./src/helpers/licenceKeyError.ts
|
|
1553
|
+
var licenceKeyError = __webpack_require__(4295);
|
|
1554
|
+
;// CONCATENATED MODULE: ./src/loader/loaderMRZ.ts
|
|
1555
|
+
function loaderMRZ_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1556
|
+
try {
|
|
1557
|
+
var info = gen[key](arg);
|
|
1558
|
+
var value = info.value;
|
|
1559
|
+
} catch (error) {
|
|
1560
|
+
reject(error);
|
|
1561
|
+
return;
|
|
1562
|
+
}
|
|
1563
|
+
if (info.done) {
|
|
1564
|
+
resolve(value);
|
|
1565
|
+
} else {
|
|
1566
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
function loaderMRZ_async_to_generator(fn) {
|
|
1570
|
+
return function() {
|
|
1571
|
+
var self = this, args = arguments;
|
|
1572
|
+
return new Promise(function(resolve, reject) {
|
|
1573
|
+
var gen = fn.apply(self, args);
|
|
1574
|
+
function _next(value) {
|
|
1575
|
+
loaderMRZ_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
1576
|
+
}
|
|
1577
|
+
function _throw(err) {
|
|
1578
|
+
loaderMRZ_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1579
|
+
}
|
|
1580
|
+
_next(undefined);
|
|
1581
|
+
});
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
function loaderMRZ_ts_generator(thisArg, body) {
|
|
1585
|
+
var f, y, t, g, _ = {
|
|
1586
|
+
label: 0,
|
|
1587
|
+
sent: function() {
|
|
1588
|
+
if (t[0] & 1) throw t[1];
|
|
1589
|
+
return t[1];
|
|
1590
|
+
},
|
|
1591
|
+
trys: [],
|
|
1592
|
+
ops: []
|
|
1593
|
+
};
|
|
1594
|
+
return(g = {
|
|
1595
|
+
next: verb(0),
|
|
1596
|
+
"throw": verb(1),
|
|
1597
|
+
"return": verb(2)
|
|
1598
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1599
|
+
return this;
|
|
1600
|
+
}), g);
|
|
1601
|
+
function verb(n) {
|
|
1602
|
+
return function(v) {
|
|
1603
|
+
return step([
|
|
1604
|
+
n,
|
|
1605
|
+
v
|
|
1606
|
+
]);
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
function step(op) {
|
|
1610
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1611
|
+
while(_)try {
|
|
1612
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1613
|
+
if (y = 0, t) op = [
|
|
1614
|
+
op[0] & 2,
|
|
1615
|
+
t.value
|
|
1616
|
+
];
|
|
1617
|
+
switch(op[0]){
|
|
1618
|
+
case 0:
|
|
1619
|
+
case 1:
|
|
1620
|
+
t = op;
|
|
1621
|
+
break;
|
|
1622
|
+
case 4:
|
|
1623
|
+
_.label++;
|
|
1624
|
+
return {
|
|
1625
|
+
value: op[1],
|
|
1626
|
+
done: false
|
|
1627
|
+
};
|
|
1628
|
+
case 5:
|
|
1629
|
+
_.label++;
|
|
1630
|
+
y = op[1];
|
|
1631
|
+
op = [
|
|
1632
|
+
0
|
|
1633
|
+
];
|
|
1634
|
+
continue;
|
|
1635
|
+
case 7:
|
|
1636
|
+
op = _.ops.pop();
|
|
1637
|
+
_.trys.pop();
|
|
1638
|
+
continue;
|
|
1639
|
+
default:
|
|
1640
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1641
|
+
_ = 0;
|
|
1642
|
+
continue;
|
|
1643
|
+
}
|
|
1644
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1645
|
+
_.label = op[1];
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1649
|
+
_.label = t[1];
|
|
1650
|
+
t = op;
|
|
1651
|
+
break;
|
|
1652
|
+
}
|
|
1653
|
+
if (t && _.label < t[2]) {
|
|
1654
|
+
_.label = t[2];
|
|
1655
|
+
_.ops.push(op);
|
|
1656
|
+
break;
|
|
1657
|
+
}
|
|
1658
|
+
if (t[2]) _.ops.pop();
|
|
1659
|
+
_.trys.pop();
|
|
1660
|
+
continue;
|
|
1661
|
+
}
|
|
1662
|
+
op = body.call(thisArg, _);
|
|
1663
|
+
} catch (e) {
|
|
1664
|
+
op = [
|
|
1665
|
+
6,
|
|
1666
|
+
e
|
|
1667
|
+
];
|
|
1668
|
+
y = 0;
|
|
1669
|
+
} finally{
|
|
1670
|
+
f = t = 0;
|
|
1671
|
+
}
|
|
1672
|
+
if (op[0] & 5) throw op[1];
|
|
1673
|
+
return {
|
|
1674
|
+
value: op[0] ? op[1] : void 0,
|
|
1675
|
+
done: true
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
|
|
1683
|
+
/* harmony default export */ const loaderMRZ = ((function() {
|
|
1684
|
+
var _ref = loaderMRZ_async_to_generator(function(param) {
|
|
1685
|
+
var commonLicenseKey, worker, mrzMod;
|
|
1686
|
+
return loaderMRZ_ts_generator(this, function(_state) {
|
|
1687
|
+
commonLicenseKey = param.commonLicenseKey;
|
|
1688
|
+
if (!commonLicenseKey) {
|
|
1689
|
+
(0,licenceKeyError/* default */.Z)();
|
|
1690
|
+
} else {
|
|
1691
|
+
worker = new Worker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u(190), __webpack_require__.b), { type: "module" });
|
|
1692
|
+
mrzMod = new modules_MrzModule(worker, commonLicenseKey, context/* default.networkUrl */.Z.networkUrl);
|
|
1693
|
+
ModuleController/* default.setModule */.Z.setModule('module', 'mrz', mrzMod);
|
|
1694
|
+
}
|
|
1695
|
+
return [
|
|
1696
|
+
2
|
|
1697
|
+
];
|
|
1698
|
+
});
|
|
1699
|
+
});
|
|
1700
|
+
return function(_) {
|
|
1701
|
+
return _ref.apply(this, arguments);
|
|
1702
|
+
};
|
|
1703
|
+
})());
|
|
1704
|
+
|
|
1705
|
+
|
|
1706
|
+
/***/ })
|
|
1707
|
+
|
|
1708
|
+
}])
|