dynamsoft-document-normalizer
Version:
Dynamsoft Document Normalizer (DDN) is an SDK designed to detect quadrilaterals (quads for short) such as document/table boundaries and more from images, then perform document normalization on the images in the detected quads.
12 lines (11 loc) • 2.61 kB
JavaScript
/*!
* Dynamsoft JavaScript Library
* @product Dynamsoft Document Normalizer JS Edition
* @website http://www.dynamsoft.com
* @copyright Copyright 2024, Dynamsoft Corporation
* @author Dynamsoft
* @version 2.6.11
* @fileoverview Dynamsoft JavaScript Library for Document Normalizer
* More info on ddn JS: https://www.dynamsoft.com/document-normalizer/docs/web/programming/javascript/
*/
import{_getNorImageData as e,_toCanvas as t,_toImage as n,_toBlob as s,_saveToFile as r,CoreModule as i,workerAutoResources as o,mapPackageRegister as a,compareVersion as d,innerVersions as c,loadWasm as u,getNextTaskID as l,mapTaskCallBack as f,worker as p}from"dynamsoft-core";const m="undefined"==typeof self,g="function"==typeof importScripts,h=(()=>{if(!g){if(!m&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"}})(),I=e=>{if(null==e&&(e="./"),m||g);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e};i.engineResourcePaths.ddn={version:"2.6.11",path:h,isInternal:!0},o.ddn={js:!0,wasm:!0,deps:["license","dip"]},a.ddn={handleNormalizedImageResultItem:function(i){let o=i,a=e(o.imageData);o.toCanvas=()=>t(a),o.toImage=e=>n(e,a),o.toBlob=e=>s(e,a),o.saveToFile=async(e,t)=>{if(!e)return null;if("string"!=typeof e)throw new TypeError("FileName must be of type string.");return r(a,e,t)}}};const y="1.4.21";"string"!=typeof i.engineResourcePaths.std&&d(i.engineResourcePaths.std.version,y)<0&&(i.engineResourcePaths.std={version:y,path:I(h+`../../dynamsoft-capture-vision-std@${y}/dist/`),isInternal:!0});const R="2.4.31";(!i.engineResourcePaths.dip||"string"!=typeof i.engineResourcePaths.dip&&d(i.engineResourcePaths.dip.version,R)<0)&&(i.engineResourcePaths.dip={version:R,path:I(h+`../../dynamsoft-image-processing@${R}/dist/`),isInternal:!0});class C{static getVersion(){const e=c.ddn&&c.ddn.wasm,t=c.ddn&&c.ddn.worker;return`2.6.11(Worker: ${t||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}async setThresholdValue(e,t,n,s){return await u("ddn"),await new Promise(((r,i)=>{let o=l();f[o]=async e=>{if(e.success)return r();{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},p.postMessage({type:"ddn_setThresholdValue",id:o,instanceID:e._instanceID,body:{threshold:t,leftLimit:n,rightLimit:s}})}))}}var v;!function(e){e[e.ICM_COLOUR=0]="ICM_COLOUR",e[e.ICM_GRAYSCALE=1]="ICM_GRAYSCALE",e[e.ICM_BINARY=2]="ICM_BINARY"}(v||(v={}));export{C as DocumentNormalizerModule,v as EnumImageColourMode};