dynamsoft-barcode-reader-bundle 10.4.3100 → 10.5.1000-iv-singlewasm

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.
Files changed (66) hide show
  1. package/dynamsoft-barcode-reader@10.4.31/dist/DBR-PresetTemplates.json +628 -0
  2. package/dynamsoft-barcode-reader@10.4.31/dist/dbr.d.ts +383 -0
  3. package/dynamsoft-barcode-reader@10.4.31/dist/dbr.esm.js +11 -0
  4. package/dynamsoft-barcode-reader@10.4.31/dist/dbr.js +11 -0
  5. package/dynamsoft-barcode-reader@10.4.31/dist/dbr.mjs +11 -0
  6. package/dynamsoft-camera-enhancer@4.1.1/dist/dce.d.ts +1877 -0
  7. package/dynamsoft-camera-enhancer@4.1.1/dist/dce.esm.js +11 -0
  8. package/dynamsoft-camera-enhancer@4.1.1/dist/dce.js +11 -0
  9. package/dynamsoft-camera-enhancer@4.1.1/dist/dce.mjs +11 -0
  10. package/dynamsoft-camera-enhancer@4.1.1/dist/dce.mobile-native.ui.html +222 -0
  11. package/dynamsoft-camera-enhancer@4.1.1/dist/dce.ui.html +115 -0
  12. package/dynamsoft-capture-vision-router@2.4.33/dist/cvr.d.ts +663 -0
  13. package/dynamsoft-capture-vision-router@2.4.33/dist/cvr.esm.js +2121 -0
  14. package/dynamsoft-capture-vision-router@2.4.33/dist/cvr.js +11 -0
  15. package/dynamsoft-capture-vision-router@2.4.33/dist/cvr.mjs +2121 -0
  16. package/dynamsoft-capture-vision-router@2.4.33/dist/cvr.worker.js +21 -0
  17. package/dynamsoft-capture-vision-std@1.4.21/dist/std.js +1 -0
  18. package/dynamsoft-capture-vision-std@1.4.21/dist/std.wasm +0 -0
  19. package/dynamsoft-code-parser@2.4.32/dist/dcp.d.ts +90 -0
  20. package/dynamsoft-code-parser@2.4.32/dist/dcp.esm.js +11 -0
  21. package/dynamsoft-code-parser@2.4.32/dist/dcp.js +11 -0
  22. package/dynamsoft-code-parser@2.4.32/dist/dcp.worker.js +21 -0
  23. package/dynamsoft-code-parser@2.4.32/dist/specification/AADHAAR.data +0 -0
  24. package/dynamsoft-code-parser@2.4.32/dist/specification/AADHAAR_Map.txt +3 -0
  25. package/dynamsoft-code-parser@2.4.32/dist/specification/AAMVA_DL_ID.data +0 -0
  26. package/dynamsoft-code-parser@2.4.32/dist/specification/AAMVA_DL_ID_WITH_MAG_STRIPE.data +0 -0
  27. package/dynamsoft-code-parser@2.4.32/dist/specification/AAMVA_Map.txt +70 -0
  28. package/dynamsoft-code-parser@2.4.32/dist/specification/MRTD_Map.txt +255 -0
  29. package/dynamsoft-code-parser@2.4.32/dist/specification/MRTD_TD1_ID.data +0 -0
  30. package/dynamsoft-code-parser@2.4.32/dist/specification/MRTD_TD2_FRENCH_ID.data +0 -0
  31. package/dynamsoft-code-parser@2.4.32/dist/specification/MRTD_TD2_ID.data +0 -0
  32. package/dynamsoft-code-parser@2.4.32/dist/specification/MRTD_TD2_VISA.data +0 -0
  33. package/dynamsoft-code-parser@2.4.32/dist/specification/MRTD_TD3_PASSPORT.data +0 -0
  34. package/dynamsoft-code-parser@2.4.32/dist/specification/MRTD_TD3_VISA.data +0 -0
  35. package/dynamsoft-code-parser@2.4.32/dist/specification/SOUTH_AFRICA_DL.data +0 -0
  36. package/dynamsoft-code-parser@2.4.32/dist/specification/SouthAfricaDL_Map.txt +3 -0
  37. package/dynamsoft-code-parser@2.4.32/dist/specification/VIN.data +0 -0
  38. package/dynamsoft-code-parser@2.4.32/dist/specification/VIN_Map.txt +150 -0
  39. package/dynamsoft-core@3.4.31/dist/core.d.ts +1019 -0
  40. package/dynamsoft-core@3.4.31/dist/core.esm.js +11 -0
  41. package/dynamsoft-core@3.4.31/dist/core.js +11 -0
  42. package/dynamsoft-core@3.4.31/dist/core.mjs +11 -0
  43. package/dynamsoft-core@3.4.31/dist/core.worker.js +11 -0
  44. package/dynamsoft-license@3.4.31/dist/dls.license.dialog.html +20 -0
  45. package/dynamsoft-license@3.4.31/dist/license.d.ts +40 -0
  46. package/dynamsoft-license@3.4.31/dist/license.esm.js +11 -0
  47. package/dynamsoft-license@3.4.31/dist/license.js +11 -0
  48. package/dynamsoft-license@3.4.31/dist/license.mjs +11 -0
  49. package/dynamsoft-license@3.4.31/dist/license.worker.js +11 -0
  50. package/dynamsoft-utility@1.4.32/dist/utility.d.ts +118 -0
  51. package/dynamsoft-utility@1.4.32/dist/utility.esm.js +11 -0
  52. package/dynamsoft-utility@1.4.32/dist/utility.js +11 -0
  53. package/dynamsoft-utility@1.4.32/dist/utility.mjs +11 -0
  54. package/dynamsoft-utility@1.4.32/dist/utility.worker.js +11 -0
  55. package/package.json +9 -82
  56. package/API Reference.url +0 -2
  57. package/LEGAL.txt +0 -353
  58. package/LICENSE +0 -4
  59. package/README.html +0 -836
  60. package/README.md +0 -735
  61. package/samples.url +0 -2
  62. /package/{dist → dynamsoft-barcode-reader-bundle@10.4.3100/dist}/dbr.bundle.d.ts +0 -0
  63. /package/{dist → dynamsoft-barcode-reader-bundle@10.4.3100/dist}/dbr.bundle.esm.d.ts +0 -0
  64. /package/{dist → dynamsoft-barcode-reader-bundle@10.4.3100/dist}/dbr.bundle.js +0 -0
  65. /package/{dist → dynamsoft-barcode-reader-bundle@10.4.3100/dist}/dbr.bundle.mjs +0 -0
  66. /package/{dist → dynamsoft-barcode-reader-bundle@10.4.3100/dist}/dbr.no-content-bundle.esm.js +0 -0
@@ -0,0 +1,118 @@
1
+ import { DSImageData, Quadrilateral, LineSegment, Contour, Corner, Edge, EnumCapturedResultItemType, OriginalImageResultItem } from 'dynamsoft-core';
2
+
3
+ declare class ImageManager {
4
+ /**
5
+ * This method saves an image in either PNG or JPG format. The desired file format is inferred from the file extension provided in the 'name' parameter. Should the specified file format be omitted or unsupported, the data will default to being exported in PNG format.
6
+ *
7
+ * @param image The image to be saved, of type `DSImageData`.
8
+ * @param name The name of the file, as a string, under which the image will be saved.
9
+ * @param download An optional boolean flag that, when set to true, triggers the download of the file.
10
+ *
11
+ * @returns A promise that resolves with the saved File object.
12
+ */
13
+ saveToFile(image: DSImageData, name: string, download?: boolean): Promise<File>;
14
+ drawOnImage(image: Blob | string, drawingItem: Array<Quadrilateral> | Quadrilateral | Array<LineSegment> | LineSegment | Array<Contour> | Contour | Array<Corner> | Corner | Array<Edge> | Edge, type: "quads" | "lines" | "contours" | "corners" | "edges", color?: number, thickness?: number, download?: boolean): Promise<DSImageData>;
15
+ }
16
+
17
+ declare class UtilityModule {
18
+ static getVersion(): string;
19
+ }
20
+
21
+ type resultItemTypesString = "barcode" | "text_line" | "detected_quad" | "normalized_image";
22
+ interface CapturedResultFilter {
23
+ onOriginalImageResultReceived?: (result: OriginalImageResultItem) => void;
24
+ onDecodedBarcodesReceived?: (result: any) => void;
25
+ onRecognizedTextLinesReceived?: (result: any) => void;
26
+ onDetectedQuadsReceived?: (result: any) => void;
27
+ onNormalizedImagesReceived?: (result: any) => void;
28
+ onParsedResultsReceived?: (result: any) => void;
29
+ }
30
+ declare class MultiFrameResultCrossFilter implements CapturedResultFilter {
31
+ #private;
32
+ verificationEnabled: {
33
+ [key: number]: boolean;
34
+ };
35
+ duplicateFilterEnabled: {
36
+ [key: number]: boolean;
37
+ };
38
+ duplicateForgetTime: {
39
+ [key: number]: number;
40
+ };
41
+ private latestOverlappingEnabled;
42
+ private maxOverlappingFrames;
43
+ private overlapSet;
44
+ private stabilityCount;
45
+ private crossVerificationFrames;
46
+ _dynamsoft(): void;
47
+ /**
48
+ * Enables or disables the verification of one or multiple specific result item types.
49
+ * @param resultItemTypes Specifies one or multiple specific result item types, which can be defined using EnumCapturedResultItemType or a string. If using a string, only one type can be specified, and valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
50
+ * @param enabled Boolean to toggle verification on or off.
51
+ */
52
+ enableResultCrossVerification(resultItemTypes: EnumCapturedResultItemType | resultItemTypesString, enabled: boolean): void;
53
+ /**
54
+ * Checks if verification is active for a given result item type.
55
+ * @param resultItemType Specifies the result item type, either with EnumCapturedResultItemType or a string. When using a string, the valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
56
+ * @returns Boolean indicating the status of verification for the specified type.
57
+ */
58
+ isResultCrossVerificationEnabled(resultItemTypes: EnumCapturedResultItemType | resultItemTypesString): boolean;
59
+ /**
60
+ * Enables or disables the deduplication process for one or multiple specific result item types.
61
+ * @param resultItemTypes Specifies one or multiple specific result item types, which can be defined using EnumCapturedResultItemType or a string. If using a string, only one type can be specified, and valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
62
+ * @param enabled Boolean to toggle deduplication on or off.
63
+ */
64
+ enableResultDeduplication(resultItemTypes: EnumCapturedResultItemType | resultItemTypesString, enabled: boolean): void;
65
+ /**
66
+ * Checks if deduplication is active for a given result item type.
67
+ * @param resultItemType Specifies the result item type, either with EnumCapturedResultItemType or a string. When using a string, the valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
68
+ * @returns Boolean indicating the deduplication status for the specified type.
69
+ */
70
+ isResultDeduplicationEnabled(resultItemTypes: EnumCapturedResultItemType | resultItemTypesString): boolean;
71
+ /**
72
+ * Sets the interval during which duplicates are disregarded for specific result item types.
73
+ * @param resultItemTypes Specifies one or multiple specific result item types, which can be defined using EnumCapturedResultItemType or a string. If using a string, only one type can be specified, and valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
74
+ * @param time Time in milliseconds during which duplicates are disregarded.
75
+ */
76
+ setDuplicateForgetTime(resultItemTypes: EnumCapturedResultItemType | resultItemTypesString, time: number): void;
77
+ /**
78
+ * Retrieves the interval during which duplicates are disregarded for a given result item type.
79
+ * @param resultItemType Specifies the result item type, either with EnumCapturedResultItemType or a string. When using a string, the valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
80
+ * @returns The set interval for the specified item type.
81
+ */
82
+ getDuplicateForgetTime(resultItemTypes: EnumCapturedResultItemType | resultItemTypesString): number;
83
+ /**
84
+ * Set the max referencing frames count for the to-the-latest overlapping feature.
85
+ *
86
+ * @param resultItemTypes Specifies the result item type, either with EnumCapturedResultItemType or a string. When using a string, the valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
87
+ * @param maxOverlappingFrames The max referencing frames count for the to-the-latest overlapping feature.
88
+ */
89
+ setMaxOverlappingFrames(resultItemTypes: EnumCapturedResultItemType | resultItemTypesString, maxOverlappingFrames: number): void;
90
+ /**
91
+ * Get the max referencing frames count for the to-the-latest overlapping feature.
92
+ * @param resultItemTypes Specifies the result item type, either with EnumCapturedResultItemType or a string. When using a string, the valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
93
+ * @return Returns the max referencing frames count for the to-the-latest overlapping feature.
94
+ */
95
+ getMaxOverlappingFrames(resultItemType: EnumCapturedResultItemType): number;
96
+ /**
97
+ * Enables or disables the deduplication process for one or multiple specific result item types.
98
+ * @param resultItemTypes Specifies one or multiple specific result item types, which can be defined using EnumCapturedResultItemType or a string. If using a string, only one type can be specified, and valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
99
+ * @param enabled Boolean to toggle deduplication on or off.
100
+ */
101
+ enableLatestOverlapping(resultItemTypes: EnumCapturedResultItemType | resultItemTypesString, enabled: boolean): void;
102
+ /**
103
+ * Checks if deduplication is active for a given result item type.
104
+ * @param resultItemType Specifies the result item type, either with EnumCapturedResultItemType or a string. When using a string, the valid values include "barcode", "text_line", "detected_quad", and "normalized_image".
105
+ *
106
+ * @returns Boolean indicating the deduplication status for the specified type.
107
+ */
108
+ isLatestOverlappingEnabled(resultItemType: EnumCapturedResultItemType | resultItemTypesString): boolean;
109
+ getFilteredResultItemTypes(): number;
110
+ onOriginalImageResultReceived(result: OriginalImageResultItem): void;
111
+ latestOverlappingFilter(result: any): void;
112
+ onDecodedBarcodesReceived(result: any): void;
113
+ onRecognizedTextLinesReceived(result: any): void;
114
+ onDetectedQuadsReceived(result: any): void;
115
+ onNormalizedImagesReceived(result: any): void;
116
+ }
117
+
118
+ export { ImageManager, MultiFrameResultCrossFilter, UtilityModule };
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Dynamsoft JavaScript Library
3
+ * @product Dynamsoft Utility JS Edition
4
+ * @website https://www.dynamsoft.com
5
+ * @copyright Copyright 2024, Dynamsoft Corporation
6
+ * @author Dynamsoft
7
+ * @version 1.4.32
8
+ * @fileoverview Dynamsoft JavaScript Library for Utility
9
+ * More info DU JS: https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/utility/utility-module.html
10
+ */
11
+ import{_getNorImageData as t,_saveToFile as e,requestResource as i,getNextTaskID as n,mapTaskCallBack as o,worker as s,CoreModule as a,workerAutoResources as r,compareVersion as l,innerVersions as c,EnumCapturedResultItemType as h}from"dynamsoft-core";const f=async t=>{let e;await new Promise(((i,n)=>{e=new Image,e.onload=()=>i(e),e.onerror=n,e.src=URL.createObjectURL(t)}));const i=document.createElement("canvas"),n=i.getContext("2d");i.width=e.width,i.height=e.height,n.drawImage(e,0,0);return{bytes:Uint8Array.from(n.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:10}};class p{async saveToFile(i,n,o){if(!i||!n)return null;if("string"!=typeof n)throw new TypeError("FileName must be of type string.");const s=t(i);return e(s,n,o)}async drawOnImage(t,e,a,r=4294901760,l=1,c){let h;if(t instanceof Blob)h=await f(t);else if("string"==typeof t){let e=await i(t,"blob");h=await f(e)}return await new Promise(((t,i)=>{let f=n();o[f]=async e=>{if(e.success)return c&&this.saveToFile(e.image,"test.png",c),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},s.postMessage({type:"utility_drawOnImage",id:f,body:{dsImage:h,drawingItem:e instanceof Array?e:[e],color:r,thickness:l,type:a}})}))}}const u="undefined"==typeof self,g="function"==typeof importScripts,d=(()=>{if(!g){if(!u&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),y=t=>{if(null==t&&(t="./"),u||g);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};a.engineResourcePaths.utility={version:"1.4.32",path:d,isInternal:!0},r.utility={js:!0,wasm:!0};const m="1.4.21";"string"!=typeof a.engineResourcePaths.std&&l(a.engineResourcePaths.std.version,m)<0&&(a.engineResourcePaths.std={version:m,path:y(d+`../../dynamsoft-capture-vision-std@${m}/dist/`),isInternal:!0});const v="2.4.31";(!a.engineResourcePaths.dip||"string"!=typeof a.engineResourcePaths.dip&&l(a.engineResourcePaths.dip.version,v)<0)&&(a.engineResourcePaths.dip={version:v,path:y(d+`../../dynamsoft-image-processing@${v}/dist/`),isInternal:!0});class x{static getVersion(){return`1.4.32(Worker: ${c.utility&&c.utility.worker||"Not Loaded"}, Wasm: ${c.utility&&c.utility.wasm||"Not Loaded"})`}}function I(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}var E,b,R,T,_;function C(t,e){let i=!0;for(let a=0;a<t.length;a++){const r=(a+1)%t.length;if((n=t[a],o=t[r],s=e,(o.x-n.x)*(s.y-n.y)-(o.y-n.y)*(s.x-n.x))<0){i=!1;break}}var n,o,s;return i}function O(t,e){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function B(t,e){const[i,n]=t,o=i.x,s=i.y,a=n.x,r=n.y,l=e.x,c=e.y,h=(a-o)**2+(r-s)**2;if(0===h)return Math.sqrt((l-o)**2+(c-s)**2);const f=((l-o)*(a-o)+(c-s)*(r-s))/h;if(f<0)return Math.sqrt((l-o)**2+(c-s)**2);if(f>1)return Math.sqrt((l-a)**2+(c-r)**2);{const t=o+f*(a-o),e=s+f*(r-s);return Math.sqrt((l-t)**2+(c-e)**2)}}function M(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i],o=t[(i+1)%t.length];e.push([n,o])}return e}function A(t){const[e,i]=t;return{x:(e.x+i.x)/2,y:(e.y+i.y)/2}}function D(t,e){const i=[];for(let n=0;n<4;n++)for(let o=0;o<4;o++){const s=S(t[n],t[(n+1)%4],e[o],e[(o+1)%4]);s&&i.push(s)}t.forEach((t=>{C(e,t)&&i.push(t)})),e.forEach((e=>{C(t,e)&&i.push(e)}));return w(function(t){if(t.length<=1)return t;t.sort(((t,e)=>t.x-e.x||t.y-e.y));const e=t.shift();return t.sort(((t,i)=>Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x))),[e,...t]}(i))}function S(t,e,i,n){const o=e.x-t.x,s=e.y-t.y,a=n.x-i.x,r=n.y-i.y,l=(-s*(t.x-i.x)+o*(t.y-i.y))/(-a*s+o*r),c=(a*(t.y-i.y)-r*(t.x-i.x))/(-a*s+o*r);return l>=0&&l<=1&&c>=0&&c<=1?{x:t.x+c*o,y:t.y+c*s}:null}function w(t){let e=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;e+=t[i].x*t[n].y,e-=t[n].x*t[i].y}return Math.abs(e/2)}function F(t,e,i){let n=e.x-t.x,o=e.y-t.y,s=i.x-t.x;return n*(i.y-t.y)-o*s>0}function L(t,e){for(let i=0;i<4;i++)if(!F(t.points[i],t.points[(i+1)%4],e))return!1;return!0}"function"==typeof SuppressedError&&SuppressedError;const N=3,k=1,P=1,W=2,G=3,j=5,V=15,U=5;function Q(t,e,i,n){const o=t.points,s=e.points;let a=8*i;a=Math.max(a,5);const r=M(o)[3],l=M(o)[1],c=M(s)[3],h=M(s)[1];let f,p=0;if(f=Math.max(Math.abs(B(r,e.points[0])),Math.abs(B(r,e.points[3]))),f>p&&(p=f),f=Math.max(Math.abs(B(l,e.points[1])),Math.abs(B(l,e.points[2]))),f>p&&(p=f),f=Math.max(Math.abs(B(c,t.points[0])),Math.abs(B(c,t.points[3]))),f>p&&(p=f),f=Math.max(Math.abs(B(h,t.points[1])),Math.abs(B(h,t.points[2]))),f>p&&(p=f),p>a)return!1;const u=A(M(o)[0]),g=A(M(o)[2]),d=A(M(s)[0]),y=A(M(s)[2]),m=O(u,y),v=O(d,g),x=m>v,I=Math.min(m,v),E=O(u,g),b=O(d,y);let R=12*i;R=Math.max(R,5),R=Math.min(R,E),R=Math.min(R,b);return!!(I<R||C(o,x?d:y)||C(s,x?g:u))&&(x?(n.points[0]=t.points[0],n.points[1]=t.points[1],n.points[2]=e.points[2],n.points[3]=e.points[3]):(n.points[0]=e.points[0],n.points[1]=e.points[1],n.points[2]=t.points[2],n.points[3]=t.points[3]),n.area=w(n.points),!0)}class X{constructor(t,e,i,n){this.overlapCount=t,this.verificationCount=e,this.crossVerificationFrame=5,this.location=n.location,this.locationArea=n.location.area,this.locationAngle=n.angle,this.format=n.format,this.text=n.text,this.isOneD=i,this.item=n;this.locationThreshold=n.moduleSize*j,this.strictLimit=Math.max(this.locationThreshold,1),this.strictLimit=Math.min(this.strictLimit,15)}getCenterPoint(t){const e={x:0,y:0};return t.forEach((({x:t,y:i})=>{e.x+=t,e.y+=i})),e.x/=t.length,e.y/=t.length,e}isProbablySameLocationWithOffset(t,e){const i=this.item.location,n=t.location;if(i.area<=0)return!1;if(Math.abs(i.area-n.area)>.4*i.area)return!1;let o=new Array(4).fill(0),s=new Array(4).fill(0),a=0,r=0;for(let t=0;t<4;++t)o[t]=Math.round(100*(n.points[t].x-i.points[t].x))/100,a+=o[t],s[t]=Math.round(100*(n.points[t].y-i.points[t].y))/100,r+=s[t];a/=4,r/=4;for(let t=0;t<4;++t){if(Math.abs(o[t]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(s[t]-r)>this.strictLimit||Math.abs(r)>.8)return!1}return e.x=a,e.y=r,!0}isLocationOverlap(t,e){if(this.locationArea>e){for(let e=0;e<4;e++)if(L(this.location,t.points[e]))return!0;const e=this.getCenterPoint(t.points);if(L(this.location,e))return!0}else{for(let e=0;e<4;e++)if(L(t,this.location.points[e]))return!0;if(L(t,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(t,e={x:0,y:0}){if(this.isOneD){const i=Object.assign({},t.location);for(let t=0;t<4;t++)i.points[t].x-=e.x,i.points[t].y-=e.y;if(!this.isLocationOverlap(i,t.locationArea))return!1;const n=[this.location.points[0],this.location.points[3]],o=[this.location.points[1],this.location.points[2]];for(let t=0;t<4;t++){const e=i.points[t],s=0===t||3===t?n:o;if(Math.abs(B(s,e))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const n=t.location.points[i],o=this.location.points[i];if(!(Math.abs(o.x+e.x-n.x)<this.locationThreshold))return!1;if(Math.abs(o.y+e.y-n.y)>=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(t,e,i=!0){const n=Object.assign({},t.location);for(let t=0;t<4;t++)n.points[t].x-=e.x,n.points[t].y-=e.y;if(!this.isLocationOverlap(n,t.location.area))return!1;if(i){const t=.75;return D([...this.location.points],n.points)>this.locationArea*t}return!0}}const Z={BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096)},q={barcode:2,text_line:4,detected_quad:8,normalized_image:16},z=t=>Object.values(q).includes(t)||q.hasOwnProperty(t),$=(t,e)=>"string"==typeof t?e[q[t]]:e[t],H=(t,e,i)=>{"string"==typeof t?e[q[t]]=i:e[t]=i},J=(t,e,i)=>{const n=[8,16].includes(i);if(!n&&t.isResultCrossVerificationEnabled(i))for(let t=0;t<e.length;t++)e[t]&&e[t].type===i&&!e[t].verified&&(e[t].isFilter=!0);if(!n&&t.isResultDeduplicationEnabled(i))for(let t=0;t<e.length;t++)e[t]&&e[t].type===i&&e[t].duplicate&&(e[t].isFilter=!0)};class K{constructor(){this.verificationEnabled={[h.CRIT_BARCODE]:!1,[h.CRIT_TEXT_LINE]:!0,[h.CRIT_DETECTED_QUAD]:!0,[h.CRIT_NORMALIZED_IMAGE]:!1},this.duplicateFilterEnabled={[h.CRIT_BARCODE]:!1,[h.CRIT_TEXT_LINE]:!1,[h.CRIT_DETECTED_QUAD]:!1,[h.CRIT_NORMALIZED_IMAGE]:!1},this.duplicateForgetTime={[h.CRIT_BARCODE]:3e3,[h.CRIT_TEXT_LINE]:3e3,[h.CRIT_DETECTED_QUAD]:3e3,[h.CRIT_NORMALIZED_IMAGE]:3e3},this.latestOverlappingEnabled={[h.CRIT_BARCODE]:!1,[h.CRIT_TEXT_LINE]:!1,[h.CRIT_DETECTED_QUAD]:!1,[h.CRIT_NORMALIZED_IMAGE]:!1},this.maxOverlappingFrames={[h.CRIT_BARCODE]:5,[h.CRIT_TEXT_LINE]:5,[h.CRIT_DETECTED_QUAD]:5,[h.CRIT_NORMALIZED_IMAGE]:5},this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,E.set(this,new Map),b.set(this,new Map),R.set(this,new Map),T.set(this,new Map),_.set(this,new Map)}_dynamsoft(){I(this,E,"f").forEach(((t,e)=>{H(e,this.verificationEnabled,t)})),I(this,b,"f").forEach(((t,e)=>{H(e,this.duplicateFilterEnabled,t)})),I(this,R,"f").forEach(((t,e)=>{H(e,this.duplicateForgetTime,t)})),I(this,T,"f").forEach(((t,e)=>{H(e,this.latestOverlappingEnabled,t)})),I(this,_,"f").forEach(((t,e)=>{H(e,this.maxOverlappingFrames,t)}))}enableResultCrossVerification(t,e){z(t)&&I(this,E,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!z(t)&&$(t,this.verificationEnabled)}enableResultDeduplication(t,e){z(t)&&(e&&this.enableLatestOverlapping(t,!1),I(this,b,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!z(t)&&$(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){z(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),I(this,R,"f").set(t,e))}getDuplicateForgetTime(t){return z(t)?$(t,this.duplicateForgetTime):-1}setMaxOverlappingFrames(t,e){z(t)&&I(this,_,"f").set(t,e)}getMaxOverlappingFrames(t){return z(t)?$(t,this.maxOverlappingFrames):-1}enableLatestOverlapping(t,e){z(t)&&(e&&this.enableResultDeduplication(t,!1),I(this,T,"f").set(t,e))}isLatestOverlappingEnabled(t){return!!z(t)&&$(t,this.latestOverlappingEnabled)}getFilteredResultItemTypes(){let t=0;const e=[h.CRIT_BARCODE,h.CRIT_TEXT_LINE,h.CRIT_DETECTED_QUAD,h.CRIT_NORMALIZED_IMAGE];for(let i=0;i<e.length;i++)(this.verificationEnabled[e[i]]||this.duplicateFilterEnabled[e[i]])&&(t|=e[i]);return t}onOriginalImageResultReceived(t){}latestOverlappingFilter(t){var e,i,n;const o=this.isResultCrossVerificationEnabled(h.CRIT_BARCODE),s=this.isLatestOverlappingEnabled(h.CRIT_BARCODE);if(s){const a=5,r=60,l=s?this.getMaxOverlappingFrames(h.CRIT_BARCODE):5,c=t.items.length,f=null===(n=null===(i=null===(e=null==t?void 0:t.intermediateResult)||void 0===e?void 0:e[0])||void 0===i?void 0:i.intermediateResultUnits)||void 0===n?void 0:n[1].localizedBarcodes,p=f?f.length:0;let u=[];const g=[],d={x:0,y:0};let y=new Array(c).fill(-1),m=0;const v=t.items.map((t=>{if(1!==t.type){const e=(BigInt(t.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0);return new X(l,e?1:2,e,t)}})).filter(Boolean);if(this.overlapSet.length>0){const t=new Array(c).fill(new Array(this.overlapSet.length).fill(1));let e=0;for(;e<c;){const i={x:0,y:0},n=new Array(c).fill(-1);let o=!1;for(;e<c;e++){if(!v[e])continue;const s=v[e].item;for(let a=0;a<this.overlapSet.length;a++){if(t[e][a]<1)continue;const r=this.overlapSet[a],l=r.item;if(s.format===l.format&&s.text===l.text){if(o=r.isProbablySameLocationWithOffset(v[e],i),o){n[e]=a,t[e][a]=0;break}}else t[e][a]=0}if(o)break}if(o){for(let o=0;o<c;o++){if(o===e||!v[o])continue;const s=v[o].item;for(let e=0;e<this.overlapSet.length;e++){if(t[o][e]<1)continue;if(n.includes(e))continue;const a=this.overlapSet[e],r=a.item;if(s.format===r.format&&s.text===r.text){if(a.isMatchedLocationWithOffset(v[o],i)){n[o]=e,t[o][e]=0;break}}else t[o][e]=0}}const o=n.filter((t=>-1!==t)).length;o>m&&(m=o,y=n,d.x=i.x,d.y=i.y)}}if(0===m){for(let e=0;e<c;e++){const i=v[e].item;for(let n=0;n<this.overlapSet.length;n++){if(t[e][n]<1)continue;if(y.includes(n))continue;const o=this.overlapSet[n],s=o.item;if(i.format===s.format&&i.text===s.text){if(o.isMatchedLocationWithOffset(v[e])){y[e]=n,t[e][n]=0;break}}else t[e][n]=0}}m+=y.filter((t=>-1!=t)).length}let i=this.overlapSet.length<=N?m>=k:m>=W;if(!i&&s&&p>0){let t=0;for(let e=0;e<this.overlapSet.length;e++){const i=this.overlapSet[e];for(let e=0;e<p;e++){if(i.isOverlappedLocationWithOffset(f[e],d)){t++;break}}}i=this.overlapSet.length<=N?t>=P:t>=G}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,t.items.forEach(((t,e)=>{if(1!==t.type){const i=Object.assign({},t),n=(BigInt(t.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),s=t.confidence<r,a=new X(l,n?1:2,n,i);o&&n&&s&&g.push(e),this.overlapSet.push(a)}}));else{let e=!0;s?(Math.abs(d.x)>U||Math.abs(d.y)>U)&&(e=!1):e=!1;for(let i=0;i<t.items.length;i++){const t=y[i];if(t<0&&v[i]){const t=v[i].item;let n={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let i=0;i<4;i++)n.points[i].x=e?t.location.points[i].x-d.x:t.location.points[i].x,n.points[i].y=e?t.location.points[i].y-d.y:t.location.points[i].y;for(let o=0;o<this.overlapSet.length;o++){if(y.includes(o))continue;const s=this.overlapSet[o].item.text,a=this.overlapSet[o].item.format;if(t.format===a&&t.text===s){if(this.overlapSet[o].isOverlappedLocationWithOffset(t,d,!1)){const e=Object.assign({},t),n=(BigInt(e.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),s=n?1:2;this.overlapSet[o]=new X(l,s,n,e),y[i]=o;break}if(v[i].isOneD){let s={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let t=0;t<4;t++)s.points[t].x=e?this.overlapSet[o].location.points[t].x:this.overlapSet[o].location.points[t].x+d.x,s.points[t].y=e?this.overlapSet[o].location.points[t].y:this.overlapSet[o].location.points[t].y+d.y;let a={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(Q(n,s,t.moduleSize,a)){t.location=a;const e=Object.assign({},t),n=(BigInt(e.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),s=n?1:2;this.overlapSet[o]=new X(l,s,n,e),y[i]=o;break}}}}}else{if(e){if(v[i]){v[i].item.location=this.overlapSet[t].location}}else{const e=Object.assign({},v[i].item),n=(BigInt(e.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),o=n?1:2;this.overlapSet[t]=new X(l,o,n,e)}this.overlapSet[t]&&(this.overlapSet[t].overlapCount=l,this.overlapSet[t].verificationCount=2,this.overlapSet[t].crossVerificationFrame=a)}}e?this.stabilityCount<V&&this.stabilityCount++:this.stabilityCount=0;let i=!0;for(let t=0;t<this.overlapSet.length;t++){if(y.includes(t))continue;const n=this.overlapSet[t];n.overlapCount--,n.crossVerificationFrame--;const o=n.overlapCount+this.stabilityCount;if(s&&o>0){for(let t=0;t<c;t++){if(n.isOverlappedLocationWithOffset(v[t],d,!1)){i=!1;break}}if(!i)break;const t=n.item;if(!e){for(let t=0;t<4;t++)n.location.points[t].x+=d.x,n.location.points[t].y+=d.y;t.location=n.location}2===n.verificationCount&&u.push(t)}}if(s&&!i){u=[];for(let t=0;t<this.overlapSet.length;t++){if(y.includes(t))continue;const e=this.overlapSet[t];e.overlapCount=0-this.stabilityCount,e.crossVerificationFrame=0,e.verificationCount=0}}for(let t=0;t<c;t++){if(-1!==y[t]||!v[t])continue;const i=v[t].item;if(e){for(let e=0;e<4;e++)v[t].location.points[e].x-=d.x,v[t].location.points[e].y-=d.y;i.location=v[t].location}let n=!1;for(let e of this.overlapSet)if(!(e.crossVerificationFrame<=0&&e.verificationCount<=0)&&(n=e.isLocationOverlap(v[t].location,v[t].locationArea),n))break;if(n){g.push(t);continue}const s=Object.assign({},i),a=(BigInt(i.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),c=i.confidence<r,h=new X(l,a?1:2,a,s);o&&a&&c?g.push(t):h.verificationCount=2,this.overlapSet.push(h)}this.overlapSet=this.overlapSet.filter((t=>!(t.overlapCount+this.stabilityCount<=0&&t.crossVerificationFrame<=0)))}g.sort(((t,e)=>e-t)).forEach(((e,i)=>{t.items.splice(e,1)})),u.forEach((e=>{t.items.push(Object.assign(Object.assign({},e),{overlapped:!0}))}))}}onDecodedBarcodesReceived(t){this.latestOverlappingFilter(t),J(this,t.items,h.CRIT_BARCODE)}onRecognizedTextLinesReceived(t){J(this,t.items,h.CRIT_TEXT_LINE)}onDetectedQuadsReceived(t){J(this,t.items,h.CRIT_DETECTED_QUAD)}onNormalizedImagesReceived(t){J(this,t.items,h.CRIT_NORMALIZED_IMAGE)}}E=new WeakMap,b=new WeakMap,R=new WeakMap,T=new WeakMap,_=new WeakMap;export{p as ImageManager,K as MultiFrameResultCrossFilter,x as UtilityModule};
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Dynamsoft JavaScript Library
3
+ * @product Dynamsoft Utility JS Edition
4
+ * @website https://www.dynamsoft.com
5
+ * @copyright Copyright 2024, Dynamsoft Corporation
6
+ * @author Dynamsoft
7
+ * @version 1.4.32
8
+ * @fileoverview Dynamsoft JavaScript Library for Utility
9
+ * More info DU JS: https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/utility/utility-module.html
10
+ */
11
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("dynamsoft-core")):"function"==typeof define&&define.amd?define(["exports","dynamsoft-core"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Dynamsoft=t.Dynamsoft||{},t.Dynamsoft.Utility={}),t.Dynamsoft.Core)}(this,(function(t,e){"use strict";const i=async t=>{let e;await new Promise(((i,n)=>{e=new Image,e.onload=()=>i(e),e.onerror=n,e.src=URL.createObjectURL(t)}));const i=document.createElement("canvas"),n=i.getContext("2d");i.width=e.width,i.height=e.height,n.drawImage(e,0,0);return{bytes:Uint8Array.from(n.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:10}};const n="undefined"==typeof self,s="function"==typeof importScripts,o=(()=>{if(!s){if(!n&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),a=t=>{if(null==t&&(t="./"),n||s);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};e.CoreModule.engineResourcePaths.utility={version:"1.4.32",path:o,isInternal:!0},e.workerAutoResources.utility={js:!0,wasm:!0};const r="1.4.21";"string"!=typeof e.CoreModule.engineResourcePaths.std&&e.compareVersion(e.CoreModule.engineResourcePaths.std.version,r)<0&&(e.CoreModule.engineResourcePaths.std={version:r,path:a(o+`../../dynamsoft-capture-vision-std@${r}/dist/`),isInternal:!0});const l="2.4.31";(!e.CoreModule.engineResourcePaths.dip||"string"!=typeof e.CoreModule.engineResourcePaths.dip&&e.compareVersion(e.CoreModule.engineResourcePaths.dip.version,l)<0)&&(e.CoreModule.engineResourcePaths.dip={version:l,path:a(o+`../../dynamsoft-image-processing@${l}/dist/`),isInternal:!0});function c(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}var u,p,h,f,m;function d(t,e){let i=!0;for(let a=0;a<t.length;a++){const r=(a+1)%t.length;if((n=t[a],s=t[r],o=e,(s.x-n.x)*(o.y-n.y)-(s.y-n.y)*(o.x-n.x))<0){i=!1;break}}var n,s,o;return i}function y(t,e){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function g(t,e){const[i,n]=t,s=i.x,o=i.y,a=n.x,r=n.y,l=e.x,c=e.y,u=(a-s)**2+(r-o)**2;if(0===u)return Math.sqrt((l-s)**2+(c-o)**2);const p=((l-s)*(a-s)+(c-o)*(r-o))/u;if(p<0)return Math.sqrt((l-s)**2+(c-o)**2);if(p>1)return Math.sqrt((l-a)**2+(c-r)**2);{const t=s+p*(a-s),e=o+p*(r-o);return Math.sqrt((l-t)**2+(c-e)**2)}}function I(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i],s=t[(i+1)%t.length];e.push([n,s])}return e}function E(t){const[e,i]=t;return{x:(e.x+i.x)/2,y:(e.y+i.y)/2}}function C(t,e){const i=[];for(let n=0;n<4;n++)for(let s=0;s<4;s++){const o=T(t[n],t[(n+1)%4],e[s],e[(s+1)%4]);o&&i.push(o)}t.forEach((t=>{d(e,t)&&i.push(t)})),e.forEach((e=>{d(t,e)&&i.push(e)}));return R(function(t){if(t.length<=1)return t;t.sort(((t,e)=>t.x-e.x||t.y-e.y));const e=t.shift();return t.sort(((t,i)=>Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x))),[e,...t]}(i))}function T(t,e,i,n){const s=e.x-t.x,o=e.y-t.y,a=n.x-i.x,r=n.y-i.y,l=(-o*(t.x-i.x)+s*(t.y-i.y))/(-a*o+s*r),c=(a*(t.y-i.y)-r*(t.x-i.x))/(-a*o+s*r);return l>=0&&l<=1&&c>=0&&c<=1?{x:t.x+c*s,y:t.y+c*o}:null}function R(t){let e=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;e+=t[i].x*t[n].y,e-=t[n].x*t[i].y}return Math.abs(e/2)}function x(t,e,i){let n=e.x-t.x,s=e.y-t.y,o=i.x-t.x;return n*(i.y-t.y)-s*o>0}function v(t,e){for(let i=0;i<4;i++)if(!x(t.points[i],t.points[(i+1)%4],e))return!1;return!0}"function"==typeof SuppressedError&&SuppressedError;const b=3,M=1,_=1,O=2,B=3,D=5,A=15,w=5;function S(t,e,i,n){const s=t.points,o=e.points;let a=8*i;a=Math.max(a,5);const r=I(s)[3],l=I(s)[1],c=I(o)[3],u=I(o)[1];let p,h=0;if(p=Math.max(Math.abs(g(r,e.points[0])),Math.abs(g(r,e.points[3]))),p>h&&(h=p),p=Math.max(Math.abs(g(l,e.points[1])),Math.abs(g(l,e.points[2]))),p>h&&(h=p),p=Math.max(Math.abs(g(c,t.points[0])),Math.abs(g(c,t.points[3]))),p>h&&(h=p),p=Math.max(Math.abs(g(u,t.points[1])),Math.abs(g(u,t.points[2]))),p>h&&(h=p),h>a)return!1;const f=E(I(s)[0]),m=E(I(s)[2]),C=E(I(o)[0]),T=E(I(o)[2]),x=y(f,T),v=y(C,m),b=x>v,M=Math.min(x,v),_=y(f,m),O=y(C,T);let B=12*i;B=Math.max(B,5),B=Math.min(B,_),B=Math.min(B,O);return!!(M<B||d(s,b?C:T)||d(o,b?m:f))&&(b?(n.points[0]=t.points[0],n.points[1]=t.points[1],n.points[2]=e.points[2],n.points[3]=e.points[3]):(n.points[0]=e.points[0],n.points[1]=e.points[1],n.points[2]=t.points[2],n.points[3]=t.points[3]),n.area=R(n.points),!0)}class F{constructor(t,e,i,n){this.overlapCount=t,this.verificationCount=e,this.crossVerificationFrame=5,this.location=n.location,this.locationArea=n.location.area,this.locationAngle=n.angle,this.format=n.format,this.text=n.text,this.isOneD=i,this.item=n;this.locationThreshold=n.moduleSize*D,this.strictLimit=Math.max(this.locationThreshold,1),this.strictLimit=Math.min(this.strictLimit,15)}getCenterPoint(t){const e={x:0,y:0};return t.forEach((({x:t,y:i})=>{e.x+=t,e.y+=i})),e.x/=t.length,e.y/=t.length,e}isProbablySameLocationWithOffset(t,e){const i=this.item.location,n=t.location;if(i.area<=0)return!1;if(Math.abs(i.area-n.area)>.4*i.area)return!1;let s=new Array(4).fill(0),o=new Array(4).fill(0),a=0,r=0;for(let t=0;t<4;++t)s[t]=Math.round(100*(n.points[t].x-i.points[t].x))/100,a+=s[t],o[t]=Math.round(100*(n.points[t].y-i.points[t].y))/100,r+=o[t];a/=4,r/=4;for(let t=0;t<4;++t){if(Math.abs(s[t]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(o[t]-r)>this.strictLimit||Math.abs(r)>.8)return!1}return e.x=a,e.y=r,!0}isLocationOverlap(t,e){if(this.locationArea>e){for(let e=0;e<4;e++)if(v(this.location,t.points[e]))return!0;const e=this.getCenterPoint(t.points);if(v(this.location,e))return!0}else{for(let e=0;e<4;e++)if(v(t,this.location.points[e]))return!0;if(v(t,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(t,e={x:0,y:0}){if(this.isOneD){const i=Object.assign({},t.location);for(let t=0;t<4;t++)i.points[t].x-=e.x,i.points[t].y-=e.y;if(!this.isLocationOverlap(i,t.locationArea))return!1;const n=[this.location.points[0],this.location.points[3]],s=[this.location.points[1],this.location.points[2]];for(let t=0;t<4;t++){const e=i.points[t],o=0===t||3===t?n:s;if(Math.abs(g(o,e))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const n=t.location.points[i],s=this.location.points[i];if(!(Math.abs(s.x+e.x-n.x)<this.locationThreshold))return!1;if(Math.abs(s.y+e.y-n.y)>=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(t,e,i=!0){const n=Object.assign({},t.location);for(let t=0;t<4;t++)n.points[t].x-=e.x,n.points[t].y-=e.y;if(!this.isLocationOverlap(n,t.location.area))return!1;if(i){const t=.75;return C([...this.location.points],n.points)>this.locationArea*t}return!0}}const L={BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096)},k={barcode:2,text_line:4,detected_quad:8,normalized_image:16},N=t=>Object.values(k).includes(t)||k.hasOwnProperty(t),V=(t,e)=>"string"==typeof t?e[k[t]]:e[t],P=(t,e,i)=>{"string"==typeof t?e[k[t]]=i:e[t]=i},W=(t,e,i)=>{const n=[8,16].includes(i);if(!n&&t.isResultCrossVerificationEnabled(i))for(let t=0;t<e.length;t++)e[t]&&e[t].type===i&&!e[t].verified&&(e[t].isFilter=!0);if(!n&&t.isResultDeduplicationEnabled(i))for(let t=0;t<e.length;t++)e[t]&&e[t].type===i&&e[t].duplicate&&(e[t].isFilter=!0)};u=new WeakMap,p=new WeakMap,h=new WeakMap,f=new WeakMap,m=new WeakMap,t.ImageManager=class{async saveToFile(t,i,n){if(!t||!i)return null;if("string"!=typeof i)throw new TypeError("FileName must be of type string.");const s=e._getNorImageData(t);return e._saveToFile(s,i,n)}async drawOnImage(t,n,s,o=4294901760,a=1,r){let l;if(t instanceof Blob)l=await i(t);else if("string"==typeof t){let n=await e.requestResource(t,"blob");l=await i(n)}return await new Promise(((t,i)=>{let c=e.getNextTaskID();e.mapTaskCallBack[c]=async e=>{if(e.success)return r&&this.saveToFile(e.image,"test.png",r),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},e.worker.postMessage({type:"utility_drawOnImage",id:c,body:{dsImage:l,drawingItem:n instanceof Array?n:[n],color:o,thickness:a,type:s}})}))}},t.MultiFrameResultCrossFilter=class{constructor(){this.verificationEnabled={[e.EnumCapturedResultItemType.CRIT_BARCODE]:!1,[e.EnumCapturedResultItemType.CRIT_TEXT_LINE]:!0,[e.EnumCapturedResultItemType.CRIT_DETECTED_QUAD]:!0,[e.EnumCapturedResultItemType.CRIT_NORMALIZED_IMAGE]:!1},this.duplicateFilterEnabled={[e.EnumCapturedResultItemType.CRIT_BARCODE]:!1,[e.EnumCapturedResultItemType.CRIT_TEXT_LINE]:!1,[e.EnumCapturedResultItemType.CRIT_DETECTED_QUAD]:!1,[e.EnumCapturedResultItemType.CRIT_NORMALIZED_IMAGE]:!1},this.duplicateForgetTime={[e.EnumCapturedResultItemType.CRIT_BARCODE]:3e3,[e.EnumCapturedResultItemType.CRIT_TEXT_LINE]:3e3,[e.EnumCapturedResultItemType.CRIT_DETECTED_QUAD]:3e3,[e.EnumCapturedResultItemType.CRIT_NORMALIZED_IMAGE]:3e3},this.latestOverlappingEnabled={[e.EnumCapturedResultItemType.CRIT_BARCODE]:!1,[e.EnumCapturedResultItemType.CRIT_TEXT_LINE]:!1,[e.EnumCapturedResultItemType.CRIT_DETECTED_QUAD]:!1,[e.EnumCapturedResultItemType.CRIT_NORMALIZED_IMAGE]:!1},this.maxOverlappingFrames={[e.EnumCapturedResultItemType.CRIT_BARCODE]:5,[e.EnumCapturedResultItemType.CRIT_TEXT_LINE]:5,[e.EnumCapturedResultItemType.CRIT_DETECTED_QUAD]:5,[e.EnumCapturedResultItemType.CRIT_NORMALIZED_IMAGE]:5},this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,u.set(this,new Map),p.set(this,new Map),h.set(this,new Map),f.set(this,new Map),m.set(this,new Map)}_dynamsoft(){c(this,u,"f").forEach(((t,e)=>{P(e,this.verificationEnabled,t)})),c(this,p,"f").forEach(((t,e)=>{P(e,this.duplicateFilterEnabled,t)})),c(this,h,"f").forEach(((t,e)=>{P(e,this.duplicateForgetTime,t)})),c(this,f,"f").forEach(((t,e)=>{P(e,this.latestOverlappingEnabled,t)})),c(this,m,"f").forEach(((t,e)=>{P(e,this.maxOverlappingFrames,t)}))}enableResultCrossVerification(t,e){N(t)&&c(this,u,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!N(t)&&V(t,this.verificationEnabled)}enableResultDeduplication(t,e){N(t)&&(e&&this.enableLatestOverlapping(t,!1),c(this,p,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!N(t)&&V(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){N(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),c(this,h,"f").set(t,e))}getDuplicateForgetTime(t){return N(t)?V(t,this.duplicateForgetTime):-1}setMaxOverlappingFrames(t,e){N(t)&&c(this,m,"f").set(t,e)}getMaxOverlappingFrames(t){return N(t)?V(t,this.maxOverlappingFrames):-1}enableLatestOverlapping(t,e){N(t)&&(e&&this.enableResultDeduplication(t,!1),c(this,f,"f").set(t,e))}isLatestOverlappingEnabled(t){return!!N(t)&&V(t,this.latestOverlappingEnabled)}getFilteredResultItemTypes(){let t=0;const i=[e.EnumCapturedResultItemType.CRIT_BARCODE,e.EnumCapturedResultItemType.CRIT_TEXT_LINE,e.EnumCapturedResultItemType.CRIT_DETECTED_QUAD,e.EnumCapturedResultItemType.CRIT_NORMALIZED_IMAGE];for(let e=0;e<i.length;e++)(this.verificationEnabled[i[e]]||this.duplicateFilterEnabled[i[e]])&&(t|=i[e]);return t}onOriginalImageResultReceived(t){}latestOverlappingFilter(t){var i,n,s;const o=this.isResultCrossVerificationEnabled(e.EnumCapturedResultItemType.CRIT_BARCODE),a=this.isLatestOverlappingEnabled(e.EnumCapturedResultItemType.CRIT_BARCODE);if(a){const r=5,l=60,c=a?this.getMaxOverlappingFrames(e.EnumCapturedResultItemType.CRIT_BARCODE):5,u=t.items.length,p=null===(s=null===(n=null===(i=null==t?void 0:t.intermediateResult)||void 0===i?void 0:i[0])||void 0===n?void 0:n.intermediateResultUnits)||void 0===s?void 0:s[1].localizedBarcodes,h=p?p.length:0;let f=[];const m=[],d={x:0,y:0};let y=new Array(u).fill(-1),g=0;const I=t.items.map((t=>{if(1!==t.type){const e=(BigInt(t.format)&BigInt(L.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(L.BF_GS1_DATABAR))!=BigInt(0);return new F(c,e?1:2,e,t)}})).filter(Boolean);if(this.overlapSet.length>0){const t=new Array(u).fill(new Array(this.overlapSet.length).fill(1));let e=0;for(;e<u;){const i={x:0,y:0},n=new Array(u).fill(-1);let s=!1;for(;e<u;e++){if(!I[e])continue;const o=I[e].item;for(let a=0;a<this.overlapSet.length;a++){if(t[e][a]<1)continue;const r=this.overlapSet[a],l=r.item;if(o.format===l.format&&o.text===l.text){if(s=r.isProbablySameLocationWithOffset(I[e],i),s){n[e]=a,t[e][a]=0;break}}else t[e][a]=0}if(s)break}if(s){for(let s=0;s<u;s++){if(s===e||!I[s])continue;const o=I[s].item;for(let e=0;e<this.overlapSet.length;e++){if(t[s][e]<1)continue;if(n.includes(e))continue;const a=this.overlapSet[e],r=a.item;if(o.format===r.format&&o.text===r.text){if(a.isMatchedLocationWithOffset(I[s],i)){n[s]=e,t[s][e]=0;break}}else t[s][e]=0}}const s=n.filter((t=>-1!==t)).length;s>g&&(g=s,y=n,d.x=i.x,d.y=i.y)}}if(0===g){for(let e=0;e<u;e++){const i=I[e].item;for(let n=0;n<this.overlapSet.length;n++){if(t[e][n]<1)continue;if(y.includes(n))continue;const s=this.overlapSet[n],o=s.item;if(i.format===o.format&&i.text===o.text){if(s.isMatchedLocationWithOffset(I[e])){y[e]=n,t[e][n]=0;break}}else t[e][n]=0}}g+=y.filter((t=>-1!=t)).length}let i=this.overlapSet.length<=b?g>=M:g>=O;if(!i&&a&&h>0){let t=0;for(let e=0;e<this.overlapSet.length;e++){const i=this.overlapSet[e];for(let e=0;e<h;e++){if(i.isOverlappedLocationWithOffset(p[e],d)){t++;break}}}i=this.overlapSet.length<=b?t>=_:t>=B}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,t.items.forEach(((t,e)=>{if(1!==t.type){const i=Object.assign({},t),n=(BigInt(t.format)&BigInt(L.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(L.BF_GS1_DATABAR))!=BigInt(0),s=t.confidence<l,a=new F(c,n?1:2,n,i);o&&n&&s&&m.push(e),this.overlapSet.push(a)}}));else{let e=!0;a?(Math.abs(d.x)>w||Math.abs(d.y)>w)&&(e=!1):e=!1;for(let i=0;i<t.items.length;i++){const t=y[i];if(t<0&&I[i]){const t=I[i].item;let n={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let i=0;i<4;i++)n.points[i].x=e?t.location.points[i].x-d.x:t.location.points[i].x,n.points[i].y=e?t.location.points[i].y-d.y:t.location.points[i].y;for(let s=0;s<this.overlapSet.length;s++){if(y.includes(s))continue;const o=this.overlapSet[s].item.text,a=this.overlapSet[s].item.format;if(t.format===a&&t.text===o){if(this.overlapSet[s].isOverlappedLocationWithOffset(t,d,!1)){const e=Object.assign({},t),n=(BigInt(e.format)&BigInt(L.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(L.BF_GS1_DATABAR))!=BigInt(0),o=n?1:2;this.overlapSet[s]=new F(c,o,n,e),y[i]=s;break}if(I[i].isOneD){let o={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let t=0;t<4;t++)o.points[t].x=e?this.overlapSet[s].location.points[t].x:this.overlapSet[s].location.points[t].x+d.x,o.points[t].y=e?this.overlapSet[s].location.points[t].y:this.overlapSet[s].location.points[t].y+d.y;let a={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(S(n,o,t.moduleSize,a)){t.location=a;const e=Object.assign({},t),n=(BigInt(e.format)&BigInt(L.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(L.BF_GS1_DATABAR))!=BigInt(0),o=n?1:2;this.overlapSet[s]=new F(c,o,n,e),y[i]=s;break}}}}}else{if(e){if(I[i]){I[i].item.location=this.overlapSet[t].location}}else{const e=Object.assign({},I[i].item),n=(BigInt(e.format)&BigInt(L.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(L.BF_GS1_DATABAR))!=BigInt(0),s=n?1:2;this.overlapSet[t]=new F(c,s,n,e)}this.overlapSet[t]&&(this.overlapSet[t].overlapCount=c,this.overlapSet[t].verificationCount=2,this.overlapSet[t].crossVerificationFrame=r)}}e?this.stabilityCount<A&&this.stabilityCount++:this.stabilityCount=0;let i=!0;for(let t=0;t<this.overlapSet.length;t++){if(y.includes(t))continue;const n=this.overlapSet[t];n.overlapCount--,n.crossVerificationFrame--;const s=n.overlapCount+this.stabilityCount;if(a&&s>0){for(let t=0;t<u;t++){if(n.isOverlappedLocationWithOffset(I[t],d,!1)){i=!1;break}}if(!i)break;const t=n.item;if(!e){for(let t=0;t<4;t++)n.location.points[t].x+=d.x,n.location.points[t].y+=d.y;t.location=n.location}2===n.verificationCount&&f.push(t)}}if(a&&!i){f=[];for(let t=0;t<this.overlapSet.length;t++){if(y.includes(t))continue;const e=this.overlapSet[t];e.overlapCount=0-this.stabilityCount,e.crossVerificationFrame=0,e.verificationCount=0}}for(let t=0;t<u;t++){if(-1!==y[t]||!I[t])continue;const i=I[t].item;if(e){for(let e=0;e<4;e++)I[t].location.points[e].x-=d.x,I[t].location.points[e].y-=d.y;i.location=I[t].location}let n=!1;for(let e of this.overlapSet)if(!(e.crossVerificationFrame<=0&&e.verificationCount<=0)&&(n=e.isLocationOverlap(I[t].location,I[t].locationArea),n))break;if(n){m.push(t);continue}const s=Object.assign({},i),a=(BigInt(i.format)&BigInt(L.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(L.BF_GS1_DATABAR))!=BigInt(0),r=i.confidence<l,u=new F(c,a?1:2,a,s);o&&a&&r?m.push(t):u.verificationCount=2,this.overlapSet.push(u)}this.overlapSet=this.overlapSet.filter((t=>!(t.overlapCount+this.stabilityCount<=0&&t.crossVerificationFrame<=0)))}m.sort(((t,e)=>e-t)).forEach(((e,i)=>{t.items.splice(e,1)})),f.forEach((e=>{t.items.push(Object.assign(Object.assign({},e),{overlapped:!0}))}))}}onDecodedBarcodesReceived(t){this.latestOverlappingFilter(t),W(this,t.items,e.EnumCapturedResultItemType.CRIT_BARCODE)}onRecognizedTextLinesReceived(t){W(this,t.items,e.EnumCapturedResultItemType.CRIT_TEXT_LINE)}onDetectedQuadsReceived(t){W(this,t.items,e.EnumCapturedResultItemType.CRIT_DETECTED_QUAD)}onNormalizedImagesReceived(t){W(this,t.items,e.EnumCapturedResultItemType.CRIT_NORMALIZED_IMAGE)}},t.UtilityModule=class{static getVersion(){return`1.4.32(Worker: ${e.innerVersions.utility&&e.innerVersions.utility.worker||"Not Loaded"}, Wasm: ${e.innerVersions.utility&&e.innerVersions.utility.wasm||"Not Loaded"})`}}}));
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Dynamsoft JavaScript Library
3
+ * @product Dynamsoft Utility JS Edition
4
+ * @website https://www.dynamsoft.com
5
+ * @copyright Copyright 2024, Dynamsoft Corporation
6
+ * @author Dynamsoft
7
+ * @version 1.4.32
8
+ * @fileoverview Dynamsoft JavaScript Library for Utility
9
+ * More info DU JS: https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/utility/utility-module.html
10
+ */
11
+ import{_getNorImageData as t,_saveToFile as e,requestResource as i,getNextTaskID as n,mapTaskCallBack as o,worker as s,CoreModule as a,workerAutoResources as r,compareVersion as l,innerVersions as c,EnumCapturedResultItemType as h}from"dynamsoft-core";const f=async t=>{let e;await new Promise(((i,n)=>{e=new Image,e.onload=()=>i(e),e.onerror=n,e.src=URL.createObjectURL(t)}));const i=document.createElement("canvas"),n=i.getContext("2d");i.width=e.width,i.height=e.height,n.drawImage(e,0,0);return{bytes:Uint8Array.from(n.getImageData(0,0,i.width,i.height).data),width:i.width,height:i.height,stride:4*i.width,format:10}};class p{async saveToFile(i,n,o){if(!i||!n)return null;if("string"!=typeof n)throw new TypeError("FileName must be of type string.");const s=t(i);return e(s,n,o)}async drawOnImage(t,e,a,r=4294901760,l=1,c){let h;if(t instanceof Blob)h=await f(t);else if("string"==typeof t){let e=await i(t,"blob");h=await f(e)}return await new Promise(((t,i)=>{let f=n();o[f]=async e=>{if(e.success)return c&&this.saveToFile(e.image,"test.png",c),t(e.image);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}},s.postMessage({type:"utility_drawOnImage",id:f,body:{dsImage:h,drawingItem:e instanceof Array?e:[e],color:r,thickness:l,type:a}})}))}}const u="undefined"==typeof self,g="function"==typeof importScripts,d=(()=>{if(!g){if(!u&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"}})(),y=t=>{if(null==t&&(t="./"),u||g);else{let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t};a.engineResourcePaths.utility={version:"1.4.32",path:d,isInternal:!0},r.utility={js:!0,wasm:!0};const m="1.4.21";"string"!=typeof a.engineResourcePaths.std&&l(a.engineResourcePaths.std.version,m)<0&&(a.engineResourcePaths.std={version:m,path:y(d+`../../dynamsoft-capture-vision-std@${m}/dist/`),isInternal:!0});const v="2.4.31";(!a.engineResourcePaths.dip||"string"!=typeof a.engineResourcePaths.dip&&l(a.engineResourcePaths.dip.version,v)<0)&&(a.engineResourcePaths.dip={version:v,path:y(d+`../../dynamsoft-image-processing@${v}/dist/`),isInternal:!0});class x{static getVersion(){return`1.4.32(Worker: ${c.utility&&c.utility.worker||"Not Loaded"}, Wasm: ${c.utility&&c.utility.wasm||"Not Loaded"})`}}function I(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}var E,b,R,T,_;function C(t,e){let i=!0;for(let a=0;a<t.length;a++){const r=(a+1)%t.length;if((n=t[a],o=t[r],s=e,(o.x-n.x)*(s.y-n.y)-(o.y-n.y)*(s.x-n.x))<0){i=!1;break}}var n,o,s;return i}function O(t,e){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function B(t,e){const[i,n]=t,o=i.x,s=i.y,a=n.x,r=n.y,l=e.x,c=e.y,h=(a-o)**2+(r-s)**2;if(0===h)return Math.sqrt((l-o)**2+(c-s)**2);const f=((l-o)*(a-o)+(c-s)*(r-s))/h;if(f<0)return Math.sqrt((l-o)**2+(c-s)**2);if(f>1)return Math.sqrt((l-a)**2+(c-r)**2);{const t=o+f*(a-o),e=s+f*(r-s);return Math.sqrt((l-t)**2+(c-e)**2)}}function M(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i],o=t[(i+1)%t.length];e.push([n,o])}return e}function A(t){const[e,i]=t;return{x:(e.x+i.x)/2,y:(e.y+i.y)/2}}function D(t,e){const i=[];for(let n=0;n<4;n++)for(let o=0;o<4;o++){const s=S(t[n],t[(n+1)%4],e[o],e[(o+1)%4]);s&&i.push(s)}t.forEach((t=>{C(e,t)&&i.push(t)})),e.forEach((e=>{C(t,e)&&i.push(e)}));return w(function(t){if(t.length<=1)return t;t.sort(((t,e)=>t.x-e.x||t.y-e.y));const e=t.shift();return t.sort(((t,i)=>Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(i.y-e.y,i.x-e.x))),[e,...t]}(i))}function S(t,e,i,n){const o=e.x-t.x,s=e.y-t.y,a=n.x-i.x,r=n.y-i.y,l=(-s*(t.x-i.x)+o*(t.y-i.y))/(-a*s+o*r),c=(a*(t.y-i.y)-r*(t.x-i.x))/(-a*s+o*r);return l>=0&&l<=1&&c>=0&&c<=1?{x:t.x+c*o,y:t.y+c*s}:null}function w(t){let e=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;e+=t[i].x*t[n].y,e-=t[n].x*t[i].y}return Math.abs(e/2)}function F(t,e,i){let n=e.x-t.x,o=e.y-t.y,s=i.x-t.x;return n*(i.y-t.y)-o*s>0}function L(t,e){for(let i=0;i<4;i++)if(!F(t.points[i],t.points[(i+1)%4],e))return!1;return!0}"function"==typeof SuppressedError&&SuppressedError;const N=3,k=1,P=1,W=2,G=3,j=5,V=15,U=5;function Q(t,e,i,n){const o=t.points,s=e.points;let a=8*i;a=Math.max(a,5);const r=M(o)[3],l=M(o)[1],c=M(s)[3],h=M(s)[1];let f,p=0;if(f=Math.max(Math.abs(B(r,e.points[0])),Math.abs(B(r,e.points[3]))),f>p&&(p=f),f=Math.max(Math.abs(B(l,e.points[1])),Math.abs(B(l,e.points[2]))),f>p&&(p=f),f=Math.max(Math.abs(B(c,t.points[0])),Math.abs(B(c,t.points[3]))),f>p&&(p=f),f=Math.max(Math.abs(B(h,t.points[1])),Math.abs(B(h,t.points[2]))),f>p&&(p=f),p>a)return!1;const u=A(M(o)[0]),g=A(M(o)[2]),d=A(M(s)[0]),y=A(M(s)[2]),m=O(u,y),v=O(d,g),x=m>v,I=Math.min(m,v),E=O(u,g),b=O(d,y);let R=12*i;R=Math.max(R,5),R=Math.min(R,E),R=Math.min(R,b);return!!(I<R||C(o,x?d:y)||C(s,x?g:u))&&(x?(n.points[0]=t.points[0],n.points[1]=t.points[1],n.points[2]=e.points[2],n.points[3]=e.points[3]):(n.points[0]=e.points[0],n.points[1]=e.points[1],n.points[2]=t.points[2],n.points[3]=t.points[3]),n.area=w(n.points),!0)}class X{constructor(t,e,i,n){this.overlapCount=t,this.verificationCount=e,this.crossVerificationFrame=5,this.location=n.location,this.locationArea=n.location.area,this.locationAngle=n.angle,this.format=n.format,this.text=n.text,this.isOneD=i,this.item=n;this.locationThreshold=n.moduleSize*j,this.strictLimit=Math.max(this.locationThreshold,1),this.strictLimit=Math.min(this.strictLimit,15)}getCenterPoint(t){const e={x:0,y:0};return t.forEach((({x:t,y:i})=>{e.x+=t,e.y+=i})),e.x/=t.length,e.y/=t.length,e}isProbablySameLocationWithOffset(t,e){const i=this.item.location,n=t.location;if(i.area<=0)return!1;if(Math.abs(i.area-n.area)>.4*i.area)return!1;let o=new Array(4).fill(0),s=new Array(4).fill(0),a=0,r=0;for(let t=0;t<4;++t)o[t]=Math.round(100*(n.points[t].x-i.points[t].x))/100,a+=o[t],s[t]=Math.round(100*(n.points[t].y-i.points[t].y))/100,r+=s[t];a/=4,r/=4;for(let t=0;t<4;++t){if(Math.abs(o[t]-a)>this.strictLimit||Math.abs(a)>.8)return!1;if(Math.abs(s[t]-r)>this.strictLimit||Math.abs(r)>.8)return!1}return e.x=a,e.y=r,!0}isLocationOverlap(t,e){if(this.locationArea>e){for(let e=0;e<4;e++)if(L(this.location,t.points[e]))return!0;const e=this.getCenterPoint(t.points);if(L(this.location,e))return!0}else{for(let e=0;e<4;e++)if(L(t,this.location.points[e]))return!0;if(L(t,this.getCenterPoint(this.location.points)))return!0}return!1}isMatchedLocationWithOffset(t,e={x:0,y:0}){if(this.isOneD){const i=Object.assign({},t.location);for(let t=0;t<4;t++)i.points[t].x-=e.x,i.points[t].y-=e.y;if(!this.isLocationOverlap(i,t.locationArea))return!1;const n=[this.location.points[0],this.location.points[3]],o=[this.location.points[1],this.location.points[2]];for(let t=0;t<4;t++){const e=i.points[t],s=0===t||3===t?n:o;if(Math.abs(B(s,e))>this.locationThreshold)return!1}}else for(let i=0;i<4;i++){const n=t.location.points[i],o=this.location.points[i];if(!(Math.abs(o.x+e.x-n.x)<this.locationThreshold))return!1;if(Math.abs(o.y+e.y-n.y)>=this.locationThreshold)return!1}return!0}isOverlappedLocationWithOffset(t,e,i=!0){const n=Object.assign({},t.location);for(let t=0;t<4;t++)n.points[t].x-=e.x,n.points[t].y-=e.y;if(!this.isLocationOverlap(n,t.location.area))return!1;if(i){const t=.75;return D([...this.location.points],n.points)>this.locationArea*t}return!0}}const Z={BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096)},q={barcode:2,text_line:4,detected_quad:8,normalized_image:16},z=t=>Object.values(q).includes(t)||q.hasOwnProperty(t),$=(t,e)=>"string"==typeof t?e[q[t]]:e[t],H=(t,e,i)=>{"string"==typeof t?e[q[t]]=i:e[t]=i},J=(t,e,i)=>{const n=[8,16].includes(i);if(!n&&t.isResultCrossVerificationEnabled(i))for(let t=0;t<e.length;t++)e[t]&&e[t].type===i&&!e[t].verified&&(e[t].isFilter=!0);if(!n&&t.isResultDeduplicationEnabled(i))for(let t=0;t<e.length;t++)e[t]&&e[t].type===i&&e[t].duplicate&&(e[t].isFilter=!0)};class K{constructor(){this.verificationEnabled={[h.CRIT_BARCODE]:!1,[h.CRIT_TEXT_LINE]:!0,[h.CRIT_DETECTED_QUAD]:!0,[h.CRIT_NORMALIZED_IMAGE]:!1},this.duplicateFilterEnabled={[h.CRIT_BARCODE]:!1,[h.CRIT_TEXT_LINE]:!1,[h.CRIT_DETECTED_QUAD]:!1,[h.CRIT_NORMALIZED_IMAGE]:!1},this.duplicateForgetTime={[h.CRIT_BARCODE]:3e3,[h.CRIT_TEXT_LINE]:3e3,[h.CRIT_DETECTED_QUAD]:3e3,[h.CRIT_NORMALIZED_IMAGE]:3e3},this.latestOverlappingEnabled={[h.CRIT_BARCODE]:!1,[h.CRIT_TEXT_LINE]:!1,[h.CRIT_DETECTED_QUAD]:!1,[h.CRIT_NORMALIZED_IMAGE]:!1},this.maxOverlappingFrames={[h.CRIT_BARCODE]:5,[h.CRIT_TEXT_LINE]:5,[h.CRIT_DETECTED_QUAD]:5,[h.CRIT_NORMALIZED_IMAGE]:5},this.overlapSet=[],this.stabilityCount=0,this.crossVerificationFrames=5,E.set(this,new Map),b.set(this,new Map),R.set(this,new Map),T.set(this,new Map),_.set(this,new Map)}_dynamsoft(){I(this,E,"f").forEach(((t,e)=>{H(e,this.verificationEnabled,t)})),I(this,b,"f").forEach(((t,e)=>{H(e,this.duplicateFilterEnabled,t)})),I(this,R,"f").forEach(((t,e)=>{H(e,this.duplicateForgetTime,t)})),I(this,T,"f").forEach(((t,e)=>{H(e,this.latestOverlappingEnabled,t)})),I(this,_,"f").forEach(((t,e)=>{H(e,this.maxOverlappingFrames,t)}))}enableResultCrossVerification(t,e){z(t)&&I(this,E,"f").set(t,e)}isResultCrossVerificationEnabled(t){return!!z(t)&&$(t,this.verificationEnabled)}enableResultDeduplication(t,e){z(t)&&(e&&this.enableLatestOverlapping(t,!1),I(this,b,"f").set(t,e))}isResultDeduplicationEnabled(t){return!!z(t)&&$(t,this.duplicateFilterEnabled)}setDuplicateForgetTime(t,e){z(t)&&(e>18e4&&(e=18e4),e<0&&(e=0),I(this,R,"f").set(t,e))}getDuplicateForgetTime(t){return z(t)?$(t,this.duplicateForgetTime):-1}setMaxOverlappingFrames(t,e){z(t)&&I(this,_,"f").set(t,e)}getMaxOverlappingFrames(t){return z(t)?$(t,this.maxOverlappingFrames):-1}enableLatestOverlapping(t,e){z(t)&&(e&&this.enableResultDeduplication(t,!1),I(this,T,"f").set(t,e))}isLatestOverlappingEnabled(t){return!!z(t)&&$(t,this.latestOverlappingEnabled)}getFilteredResultItemTypes(){let t=0;const e=[h.CRIT_BARCODE,h.CRIT_TEXT_LINE,h.CRIT_DETECTED_QUAD,h.CRIT_NORMALIZED_IMAGE];for(let i=0;i<e.length;i++)(this.verificationEnabled[e[i]]||this.duplicateFilterEnabled[e[i]])&&(t|=e[i]);return t}onOriginalImageResultReceived(t){}latestOverlappingFilter(t){var e,i,n;const o=this.isResultCrossVerificationEnabled(h.CRIT_BARCODE),s=this.isLatestOverlappingEnabled(h.CRIT_BARCODE);if(s){const a=5,r=60,l=s?this.getMaxOverlappingFrames(h.CRIT_BARCODE):5,c=t.items.length,f=null===(n=null===(i=null===(e=null==t?void 0:t.intermediateResult)||void 0===e?void 0:e[0])||void 0===i?void 0:i.intermediateResultUnits)||void 0===n?void 0:n[1].localizedBarcodes,p=f?f.length:0;let u=[];const g=[],d={x:0,y:0};let y=new Array(c).fill(-1),m=0;const v=t.items.map((t=>{if(1!==t.type){const e=(BigInt(t.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0);return new X(l,e?1:2,e,t)}})).filter(Boolean);if(this.overlapSet.length>0){const t=new Array(c).fill(new Array(this.overlapSet.length).fill(1));let e=0;for(;e<c;){const i={x:0,y:0},n=new Array(c).fill(-1);let o=!1;for(;e<c;e++){if(!v[e])continue;const s=v[e].item;for(let a=0;a<this.overlapSet.length;a++){if(t[e][a]<1)continue;const r=this.overlapSet[a],l=r.item;if(s.format===l.format&&s.text===l.text){if(o=r.isProbablySameLocationWithOffset(v[e],i),o){n[e]=a,t[e][a]=0;break}}else t[e][a]=0}if(o)break}if(o){for(let o=0;o<c;o++){if(o===e||!v[o])continue;const s=v[o].item;for(let e=0;e<this.overlapSet.length;e++){if(t[o][e]<1)continue;if(n.includes(e))continue;const a=this.overlapSet[e],r=a.item;if(s.format===r.format&&s.text===r.text){if(a.isMatchedLocationWithOffset(v[o],i)){n[o]=e,t[o][e]=0;break}}else t[o][e]=0}}const o=n.filter((t=>-1!==t)).length;o>m&&(m=o,y=n,d.x=i.x,d.y=i.y)}}if(0===m){for(let e=0;e<c;e++){const i=v[e].item;for(let n=0;n<this.overlapSet.length;n++){if(t[e][n]<1)continue;if(y.includes(n))continue;const o=this.overlapSet[n],s=o.item;if(i.format===s.format&&i.text===s.text){if(o.isMatchedLocationWithOffset(v[e])){y[e]=n,t[e][n]=0;break}}else t[e][n]=0}}m+=y.filter((t=>-1!=t)).length}let i=this.overlapSet.length<=N?m>=k:m>=W;if(!i&&s&&p>0){let t=0;for(let e=0;e<this.overlapSet.length;e++){const i=this.overlapSet[e];for(let e=0;e<p;e++){if(i.isOverlappedLocationWithOffset(f[e],d)){t++;break}}}i=this.overlapSet.length<=N?t>=P:t>=G}i||(this.overlapSet=[])}if(0===this.overlapSet.length)this.stabilityCount=0,t.items.forEach(((t,e)=>{if(1!==t.type){const i=Object.assign({},t),n=(BigInt(t.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(t.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),s=t.confidence<r,a=new X(l,n?1:2,n,i);o&&n&&s&&g.push(e),this.overlapSet.push(a)}}));else{let e=!0;s?(Math.abs(d.x)>U||Math.abs(d.y)>U)&&(e=!1):e=!1;for(let i=0;i<t.items.length;i++){const t=y[i];if(t<0&&v[i]){const t=v[i].item;let n={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let i=0;i<4;i++)n.points[i].x=e?t.location.points[i].x-d.x:t.location.points[i].x,n.points[i].y=e?t.location.points[i].y-d.y:t.location.points[i].y;for(let o=0;o<this.overlapSet.length;o++){if(y.includes(o))continue;const s=this.overlapSet[o].item.text,a=this.overlapSet[o].item.format;if(t.format===a&&t.text===s){if(this.overlapSet[o].isOverlappedLocationWithOffset(t,d,!1)){const e=Object.assign({},t),n=(BigInt(e.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),s=n?1:2;this.overlapSet[o]=new X(l,s,n,e),y[i]=o;break}if(v[i].isOneD){let s={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};for(let t=0;t<4;t++)s.points[t].x=e?this.overlapSet[o].location.points[t].x:this.overlapSet[o].location.points[t].x+d.x,s.points[t].y=e?this.overlapSet[o].location.points[t].y:this.overlapSet[o].location.points[t].y+d.y;let a={points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],area:0};if(Q(n,s,t.moduleSize,a)){t.location=a;const e=Object.assign({},t),n=(BigInt(e.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),s=n?1:2;this.overlapSet[o]=new X(l,s,n,e),y[i]=o;break}}}}}else{if(e){if(v[i]){v[i].item.location=this.overlapSet[t].location}}else{const e=Object.assign({},v[i].item),n=(BigInt(e.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(e.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),o=n?1:2;this.overlapSet[t]=new X(l,o,n,e)}this.overlapSet[t]&&(this.overlapSet[t].overlapCount=l,this.overlapSet[t].verificationCount=2,this.overlapSet[t].crossVerificationFrame=a)}}e?this.stabilityCount<V&&this.stabilityCount++:this.stabilityCount=0;let i=!0;for(let t=0;t<this.overlapSet.length;t++){if(y.includes(t))continue;const n=this.overlapSet[t];n.overlapCount--,n.crossVerificationFrame--;const o=n.overlapCount+this.stabilityCount;if(s&&o>0){for(let t=0;t<c;t++){if(n.isOverlappedLocationWithOffset(v[t],d,!1)){i=!1;break}}if(!i)break;const t=n.item;if(!e){for(let t=0;t<4;t++)n.location.points[t].x+=d.x,n.location.points[t].y+=d.y;t.location=n.location}2===n.verificationCount&&u.push(t)}}if(s&&!i){u=[];for(let t=0;t<this.overlapSet.length;t++){if(y.includes(t))continue;const e=this.overlapSet[t];e.overlapCount=0-this.stabilityCount,e.crossVerificationFrame=0,e.verificationCount=0}}for(let t=0;t<c;t++){if(-1!==y[t]||!v[t])continue;const i=v[t].item;if(e){for(let e=0;e<4;e++)v[t].location.points[e].x-=d.x,v[t].location.points[e].y-=d.y;i.location=v[t].location}let n=!1;for(let e of this.overlapSet)if(!(e.crossVerificationFrame<=0&&e.verificationCount<=0)&&(n=e.isLocationOverlap(v[t].location,v[t].locationArea),n))break;if(n){g.push(t);continue}const s=Object.assign({},i),a=(BigInt(i.format)&BigInt(Z.BF_ONED))!=BigInt(0)||(BigInt(i.format)&BigInt(Z.BF_GS1_DATABAR))!=BigInt(0),c=i.confidence<r,h=new X(l,a?1:2,a,s);o&&a&&c?g.push(t):h.verificationCount=2,this.overlapSet.push(h)}this.overlapSet=this.overlapSet.filter((t=>!(t.overlapCount+this.stabilityCount<=0&&t.crossVerificationFrame<=0)))}g.sort(((t,e)=>e-t)).forEach(((e,i)=>{t.items.splice(e,1)})),u.forEach((e=>{t.items.push(Object.assign(Object.assign({},e),{overlapped:!0}))}))}}onDecodedBarcodesReceived(t){this.latestOverlappingFilter(t),J(this,t.items,h.CRIT_BARCODE)}onRecognizedTextLinesReceived(t){J(this,t.items,h.CRIT_TEXT_LINE)}onDetectedQuadsReceived(t){J(this,t.items,h.CRIT_DETECTED_QUAD)}onNormalizedImagesReceived(t){J(this,t.items,h.CRIT_NORMALIZED_IMAGE)}}E=new WeakMap,b=new WeakMap,R=new WeakMap,T=new WeakMap,_=new WeakMap;export{p as ImageManager,K as MultiFrameResultCrossFilter,x as UtilityModule};
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Dynamsoft JavaScript Library
3
+ * @product Dynamsoft Utility JS Edition
4
+ * @website https://www.dynamsoft.com
5
+ * @copyright Copyright 2024, Dynamsoft Corporation
6
+ * @author Dynamsoft
7
+ * @version 1.4.32
8
+ * @fileoverview Dynamsoft JavaScript Library for Utility
9
+ * More info DU JS: https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/utility/utility-module.html
10
+ */
11
+ !function(){"use strict";self.utilityWorkerVersion="1.4.32",Object.assign(mapController,{utility_drawOnImage:async(e,t)=>{let s;try{let a=wasmImports.emscripten_bind_Create_CImageData(e.dsImage.bytes.length,setBufferIntoWasm(e.dsImage.bytes,0),e.dsImage.width,e.dsImage.height,e.dsImage.stride,e.dsImage.format,0);const r=e.type.charAt(0).toUpperCase()+e.type.slice(1);ep(),s=JSON.parse(UTF8ToString(wasmImports[`emscripten_bind_UtilityWasm_DrawOnImage${r}_5`](a,es(JSON.stringify(e.drawingItem)),e.drawingItem.length,e.color,e.thickness)));let n=s.bytes;n&&(n=new Uint8Array(new Uint8Array(HEAP8.buffer,n.ptr,n.length)),s.bytes=n),wasmImports.emscripten_bind_Destory_CImageData(a),handleTaskRes(t,{success:!0,image:s})}catch(e){return console.log(e),void handleTaskErr(t,e)}}})}();
package/package.json CHANGED
@@ -1,88 +1,15 @@
1
1
  {
2
2
  "name": "dynamsoft-barcode-reader-bundle",
3
- "version": "10.4.3100",
4
- "description": "Dynamsoft Barcode Reader JS is a recognition SDK which enables you to embed barcode reading functionality in your web, desktop, and mobile applications. With a few lines of JavaScript code, you can develop a robust application to scan a linear barcode, QR Code, DaraMatrix, PDF417, and Aztec Code.",
5
- "main": "dist/dbr.bundle.js",
6
- "module": "dist/dbr.no-content-bundle.esm.js",
7
- "exports": {
8
- "import": {
9
- "types": "./dist/dbr.bundle.esm.d.ts",
10
- "default": "./dist/dbr.no-content-bundle.esm.js"
11
- },
12
- "require": {
13
- "types": "./dist/dbr.bundle.d.ts",
14
- "default": "./dist/dbr.bundle.js"
15
- }
16
- },
17
- "sideEffects": true,
18
- "types": "dist/dbr.bundle.esm.d.ts",
19
- "type": "module",
20
- "files": [
21
- "/dist",
22
- "LEGAL.txt",
23
- "LICENSE",
24
- "samples.url",
25
- "API Reference.url"
26
- ],
27
- "scripts": {
28
- "build": "rollup -c --environment BUILD:production",
29
- "test": "echo \"Error: no test specified\" && exit 1",
30
- "update:readme": "updateReadme --package=dynamsoft-barcode-reader-bundle --version=latest --branch=preview --html",
31
- "updateLink:npm": "updateLink --source=npm",
32
- "updateLink:zip": "updateLink --source=zip",
33
- "updateLink:github": "updateLink --source=github",
34
- "update:prod": "updatePackage --package=dynamsoft-barcode-reader-bundle --version=auto --env=production --tag=latest",
35
- "update:beta": "updatePackage --package=dynamsoft-barcode-reader-bundle --version=auto --env=beta --tag=beta",
36
- "update:iv": "updatePackage --package=dynamsoft-barcode-reader-bundle --version=auto --env=internalVersion --tag=iv",
37
- "update:dev": "updatePackage --package=dynamsoft-barcode-reader-bundle --version=auto --env=development --tag=latest",
38
- "makeZip": "makeZip --package=dynamsoft-barcode-reader-bundle --version=auto --sampleBranch=_dev --structure=new --otherPkgs=dynamsoft-capture-vision-std dynamsoft-image-processing dynamsoft-core dynamsoft-license dynamsoft-capture-vision-router dynamsoft-utility dynamsoft-camera-enhancer dynamsoft-barcode-reader",
39
- "easyPublish": "npm run update:dev && npm run build && npm publish"
40
- },
41
- "keywords": [
42
- "HTML5 barcode",
43
- "JavaScript barcode",
44
- "Web barcode",
45
- "barcode",
46
- "PDF417",
47
- "QRCode",
48
- "Aztec Code",
49
- "WebAssembly",
50
- "SDK",
51
- "Linear barcode",
52
- "1D barcode"
53
- ],
3
+ "version": "10.5.1000-iv-singlewasm",
4
+ "sideEffects": false,
54
5
  "author": {
55
6
  "name": "Dynamsoft",
56
- "url": "https://www.dynamsoft.com",
57
- "email": "support@dynamsoft.com"
58
- },
59
- "license": "SEE LICENSE IN LICENSE",
60
- "repository": {
61
- "type": "git",
62
- "url": "https://github.com/dynamsoft/barcode-reader-javascript.git"
7
+ "url": "https://www.dynamsoft.com"
63
8
  },
64
- "publishConfig": {
65
- "registry": "https://registry.npmjs.org/",
66
- "tag": "latest"
67
- },
68
- "devDependencies": {
69
- "@dynamsoft/rd2-scripts": "^0.1.36",
70
- "@rollup/plugin-node-resolve": "^15.2.3",
71
- "@rollup/plugin-replace": "^5.0.5",
72
- "@rollup/plugin-terser": "^0.4.4",
73
- "@rollup/plugin-typescript": "^11.1.6",
74
- "@scannerproxy/curscript-path": "^2.0.1",
75
- "rollup": "^3.29.3",
76
- "rollup-plugin-dts": "^6.1.0",
77
- "tslib": "^2.6.2",
78
- "typescript": "^4.9.5"
79
- },
80
- "dependencies": {
81
- "dynamsoft-barcode-reader": "10.4.31",
82
- "dynamsoft-camera-enhancer": "4.1.1",
83
- "dynamsoft-capture-vision-router": "2.4.33",
84
- "dynamsoft-core": "3.4.31",
85
- "dynamsoft-license": "3.4.31",
86
- "dynamsoft-utility": "1.4.32"
87
- }
9
+ "maintainers": [
10
+ {
11
+ "name": "Dynamsoft",
12
+ "email": "support@dynamsoft.com"
13
+ }
14
+ ]
88
15
  }
@@ -1,2 +0,0 @@
1
- [InternetShortcut]
2
- URL=https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/index.html