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