@idscan/idvc2
Version:
component for the capturing documents
1 lines • 8 kB
JavaScript
(self.webpackChunk_idscan_idvc2=self.webpackChunk_idscan_idvc2||[]).push([[9],{7358:(e,t,n)=>{n.r(t),n.d(t,{default:()=>C});var r=n(4554),i=n(813),o=n(4328),c=n(7286),u=n(8417),a=n(6955),l=n(528),s=n(683),f=n(6960);function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t,n,r,i,o,c){try{var u=e[o](c),a=u.value}catch(e){return void n(e)}u.done?t(a):Promise.resolve(a).then(r,i)}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function v(e,t){return!t||"object"!=((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)&&"function"!=typeof t?d(e):t;var n}function g(e,t){return g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},g(e,t)}function m(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(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}}();return function(){var n,r=y(e);if(t){var i=y(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return v(this,n)}}function w(e,t){var n,r,i,o,c={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,r=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(i=c.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){c.label=o[1];break}if(6===o[0]&&c.label<i[1]){c.label=i[1],i=o;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(o);break}i[2]&&c.ops.pop(),c.trys.pop();continue}o=t.call(e,c)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}var P={confidence:.5,predictConfidence:.8,classes:["BACKS_MRZ","BACKS_MRZPDF","BACKS_NO","BACKS_PDF","BCC","CAC","DLIC","EA","GC","IID","MID_NEW","MID_OLD","PASSP","PC","VA","VHC","FACE"],inputImageWidth:320,inputImageHeight:224,inputTensorSize:[1,224,320,3],inputTensorName:"image_input",outputTensorSize:[1,21,1470],outputTensorName:"yolov10",predictLength:6,padding:0,documentFramePadding:10},x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new 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)}(c,e);var t,n,r,o=m(c);function c(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.z.WASM,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),b(d(e=o.call(this,t,n,r)),"canvasSize",{width:1,height:1}),b(d(e),"documentPredictLabelIndex",5),b(d(e),"documentPredictConfidenceIndex",4),e}return t=c,n=[{key:"setSizes",value:function(e){var t=e.height,n=e.width;this.canvasSize.width=n,this.canvasSize.height=t}},{key:"findHighestConfidencePredict",value:function(e,t){var n=this,r=Array.from({length:e.length/t.predictLength},(function(n,r){return e.slice(r*t.predictLength,(r+1)*t.predictLength)})).filter((function(e){return e[n.documentPredictConfidenceIndex]>t.predictConfidence})).slice(0,2);return{documentPredict:r.find((function(e){return t.classes[e[n.documentPredictLabelIndex]]!==t.classes[16]})),facePredict:r.find((function(e){return t.classes[e[n.documentPredictLabelIndex]]===t.classes[16]}))}}},{key:"predictFromImage",value:function(e,t,n){var r,i=this;return(r=function(){var r,o,c,u,a,f,d,h;return w(this,(function(p){switch(p.label){case 0:return i.loading?[2,{}]:(i.loading=!0,r=n?function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){b(e,t,n[t])}))}return e}({},P,n):P,o=i.createSrc(e,"angles-input-canvas"),c=t||(0,l.vL)("general-type-canvas",{width:r.inputImageWidth,height:r.inputImageHeight}),u=(0,l.RT)({width:c.width,height:c.height},{width:o.width,height:o.height},r.padding),(a=c.getContext("2d")).fillStyle="rgb(114, 114, 114)",a.fillRect(0,0,c.width,c.width),a.drawImage(o,u.x,u.y,u.width,u.height),f=(0,s.vG)(a.getImageData(0,0,c.width,c.height),s.eQ.WITHOUT),[4,i.predict(f,r)]);case 1:return d=p.sent(),h=i.findHighestConfidencePredict(d.Identity.cpuData,r),i.setSizes(c),[2,i.interpret(h,u,r.documentFramePadding,r)]}}))},function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function c(e){h(o,n,i,c,u,"next",e)}function u(e){h(o,n,i,c,u,"throw",e)}c(void 0)}))})()}},{key:"interpret",value:function(e,t,n,r){var i=e.documentPredict,o=e.facePredict,c={side:"None",bbox:{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},perimeterInPercents:{width:0,height:0},isDocumentInsideFrame:!1,isHasFaceOnDocument:!1};if(i){c.side=r.classes[i[5]];var u=i.slice(0,4);c.bbox.topLeft.x=u[0],c.bbox.topLeft.y=u[1],c.bbox.bottomRight.x=u[2],c.bbox.bottomRight.y=u[3];var a=(0,f.Bo)(c.bbox,t,n);c.isDocumentInsideFrame=a.isInside,c.perimeterInPercents.width=+((u[2]-u[0])/t.width*100).toFixed(3),c.perimeterInPercents.height=+((u[3]-u[1])/t.height*100).toFixed(),o&&(c.isHasFaceOnDocument=!0)}return this.loading=!1,c}},{key:"predict",value:function(e,t){var n=new u.es("uint8",e,t.inputTensorSize),r=b({},t.inputTensorName,n);return this.session.run(r)}}],n&&p(t.prototype,n),r&&p(t,r),c}(a.Z);function S(e,t,n,r,i,o,c){try{var u=e[o](c),a=u.value}catch(e){return void n(e)}u.done?t(a):Promise.resolve(a).then(r,i)}function I(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function c(e){S(o,r,i,c,u,"next",e)}function u(e){S(o,r,i,c,u,"throw",e)}c(void 0)}))}}function O(e,t){var n,r,i,o,c={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,r=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(i=c.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){c.label=o[1];break}if(6===o[0]&&c.label<i[1]){c.label=i[1],i=o;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(o);break}i[2]&&c.ops.pop(),c.trys.pop();continue}o=t.call(e,c)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}const C=I((function(){var e;return O(this,(function(t){return e=new x("".concat(r.t.JZ),i.z.WASM,o.Z.networkUrl),c.Z.setModule("model","generalTypeDetectionYolo",e),[2,[e.initialize.bind(e)]]}))}))}}]);