dynamsoft-barcode-reader-bundle 11.2.4000 → 11.4.2000-beta-202604162228

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 (58) hide show
  1. package/LEGAL.txt +8 -1
  2. package/LICENSE +1 -1
  3. package/README.html +541 -115
  4. package/README.md +628 -125
  5. package/dist/dbr.bundle.d.ts +1577 -2689
  6. package/dist/dbr.bundle.esm.js +3 -3
  7. package/dist/dbr.bundle.js +3 -3
  8. package/dist/dbr.bundle.mjs +3 -3
  9. package/dist/dbr.bundle.worker.js +3 -3
  10. package/dist/dynamsoft-barcode-reader-bundle-ml-simd-pthread.js +1 -1
  11. package/dist/dynamsoft-barcode-reader-bundle-ml-simd-pthread.wasm +0 -0
  12. package/dist/dynamsoft-barcode-reader-bundle-ml-simd.js +1 -1
  13. package/dist/dynamsoft-barcode-reader-bundle-ml-simd.wasm +0 -0
  14. package/dist/dynamsoft-barcode-reader-bundle.js +1 -1
  15. package/dist/dynamsoft-barcode-reader-bundle.wasm +0 -0
  16. package/dist/models/Code128Decoder.data +0 -0
  17. package/dist/models/Code39ITFDecoder.data +0 -0
  18. package/dist/models/DataMatrixQRCodeDeblur.data +0 -0
  19. package/dist/models/DataMatrixQRCodeLocalization.data +0 -0
  20. package/dist/models/EAN13Decoder.data +0 -0
  21. package/dist/models/OneDDeblur.data +0 -0
  22. package/dist/models/OneDLocalization.data +0 -0
  23. package/dist/models/PDF417Deblur.data +0 -0
  24. package/dist/models/PDF417Localization.data +0 -0
  25. package/dist/parser-resources/AADHAAR.data +0 -0
  26. package/dist/parser-resources/AAMVA_DL_ID.data +1 -0
  27. package/dist/parser-resources/GS1_AI.data +66 -0
  28. package/dist/parser-resources/MRTD.data +1 -0
  29. package/dist/parser-resources/SOUTH_AFRICA_DL.data +1 -0
  30. package/dist/parser-resources/VIN.data +0 -0
  31. package/dist/templates/DBR-PresetTemplates.json +9 -22
  32. package/dist/ui/barcode-scanner.ui.xml +271 -108
  33. package/dist/ui/dce.rtu.ui.xml +431 -0
  34. package/dist/ui/dce.ui.v5.xml +470 -0
  35. package/dist/ui/dce.ui.xml +138 -114
  36. package/dist/ui/dls.license.dialog.html +1 -1
  37. package/package.json +16 -15
  38. package/samples.url +1 -1
  39. package/API_Reference_BarcodeScanner.url +0 -2
  40. package/API_Reference_Foundational.url +0 -2
  41. package/dist/parser-resources/AADHAAR.dcpres +0 -1
  42. package/dist/parser-resources/AADHAAR_Map.txt +0 -3
  43. package/dist/parser-resources/AAMVA_DL_ID.dcpres +0 -1
  44. package/dist/parser-resources/AAMVA_DL_ID_WITH_MAG_STRIPE.dcpres +0 -1
  45. package/dist/parser-resources/AAMVA_Map.txt +0 -70
  46. package/dist/parser-resources/GS1_AI.dcpres +0 -1
  47. package/dist/parser-resources/GS1_AI_Map.txt +0 -643
  48. package/dist/parser-resources/MRTD_Map.txt +0 -255
  49. package/dist/parser-resources/MRTD_TD1_ID.dcpres +0 -1
  50. package/dist/parser-resources/MRTD_TD2_FRENCH_ID.dcpres +0 -1
  51. package/dist/parser-resources/MRTD_TD2_ID.dcpres +0 -1
  52. package/dist/parser-resources/MRTD_TD2_VISA.dcpres +0 -1
  53. package/dist/parser-resources/MRTD_TD3_PASSPORT.dcpres +0 -1
  54. package/dist/parser-resources/MRTD_TD3_VISA.dcpres +0 -1
  55. package/dist/parser-resources/SOUTH_AFRICA_DL.dcpres +0 -1
  56. package/dist/parser-resources/SOUTH_AFRICA_DL_Map.txt +0 -3
  57. package/dist/parser-resources/VIN.dcpres +0 -1
  58. package/dist/parser-resources/VIN_Map.txt +0 -150
package/README.md CHANGED
@@ -1,222 +1,725 @@
1
- # Build a Web-Based Barcode Scanner Using Just a Few Lines of JavaScript
2
-
3
- <!-- Don't forget to add the TOC & update license section, which is useful for npm README.-->
4
- - [Build a Web-Based Barcode Scanner Using Just a Few Lines of JavaScript](#build-a-web-based-barcode-scanner-using-just-a-few-lines-of-javascript)
5
- - [License](#license)
6
- - [Quick Start: Hello World Example](#quick-start-hello-world-example)
7
- - [Step 1: Setting up the HTML and Including the Barcode Scanner](#step-1-setting-up-the-html-and-including-the-barcode-scanner)
8
- - [Step 2: Initializing the Barcode Scanner](#step-2-initializing-the-barcode-scanner)
9
- - [Step 3: Launching the Barcode Scanner](#step-3-launching-the-barcode-scanner)
1
+ # Barcode Reader for Your Website - Foundational API Guide
2
+
3
+ [Dynamsoft Barcode Reader JavaScript Edition](https://www.dynamsoft.com/barcode-reader/sdk-javascript/) (DBR-JS) is equipped with industry-leading algorithms for exceptional speed, accuracy and read rates in barcode reading. Using its well-designed API, you can turn your web page into a barcode scanner with just a few lines of code. Once the DBR-JS SDK gets integrated into your web page, your users can access a camera via the browser and read barcodes directly from its video input.
4
+
5
+ <!-- ![version](https://img.shields.io/npm/v/dynamsoft-barcode-reader.svg)
6
+ ![downloads](https://img.shields.io/npm/dm/dynamsoft-barcode-reader.svg)
7
+ ![jsdelivr](https://img.shields.io/jsdelivr/npm/hm/dynamsoft-barcode-reader.svg)
8
+
9
+ ![version](https://img.shields.io/npm/v/dynamsoft-javascript-barcode.svg)
10
+ ![downloads](https://img.shields.io/npm/dm/dynamsoft-javascript-barcode.svg)
11
+ ![jsdelivr](https://img.shields.io/jsdelivr/npm/hm/dynamsoft-javascript-barcode.svg) -->
12
+
13
+ In this guide, you will learn step by step on how to integrate the DBR-JS SDK into your website.
14
+
15
+ <span style="font-size:20px">Table of Contents</span>
16
+
17
+ - [Barcode Reader for Your Website - Foundational API Guide](#barcode-reader-for-your-website---foundational-api-guide)
18
+ - [Hello World - Simplest Implementation](#hello-world---simplest-implementation)
19
+ - [Understand the code](#understand-the-code)
20
+ - [About the code](#about-the-code)
21
+ - [Run the example](#run-the-example)
22
+ - [Preparing the SDK](#preparing-the-sdk)
23
+ - [Step 1: Include the SDK](#step-1-include-the-sdk)
24
+ - [Step 2: Prepare the SDK](#step-2-prepare-the-sdk)
25
+ - [1. Specify the license](#1-specify-the-license)
26
+ - [2. \[Optional\] Specify the location of the "engine" files](#2-optional-specify-the-location-of-the-engine-files)
27
+ - [Using the SDK](#using-the-sdk)
28
+ - [Step 1: Preload the module](#step-1-preload-the-module)
29
+ - [Step 2: Create a CaptureVisionRouter object](#step-2-create-a-capturevisionrouter-object)
30
+ - [Step 3: Connect an image source](#step-3-connect-an-image-source)
31
+ - [Step 4: Register a result receiver](#step-4-register-a-result-receiver)
32
+ - [Step 5: Start process video frames](#step-5-start-process-video-frames)
33
+ - [Customizing the process](#customizing-the-process)
34
+ - [1. Adjust the preset template settings](#1-adjust-the-preset-template-settings)
35
+ - [1.1. Change barcode settings](#11-change-barcode-settings)
36
+ - [1.2. Retrieve the original image](#12-retrieve-the-original-image)
37
+ - [1.3. Change reading frequency to save power](#13-change-reading-frequency-to-save-power)
38
+ - [1.4. Specify a scan region](#14-specify-a-scan-region)
39
+ - [2. Edit the preset templates directly](#2-edit-the-preset-templates-directly)
40
+ - [3. \[Important\] Filter the results](#3-important-filter-the-results)
41
+ - [Method 1: Verify results across multiple frames](#method-1-verify-results-across-multiple-frames)
42
+ - [Method 2: Eliminate redundant results detected within a short time frame](#method-2-eliminate-redundant-results-detected-within-a-short-time-frame)
43
+ - [4. Add feedback](#4-add-feedback)
44
+ - [Customizing the UI](#customizing-the-ui)
45
+ - [Documentation](#documentation)
46
+ - [API Reference](#api-reference)
47
+ - [How to Upgrade](#how-to-upgrade)
48
+ - [Release Notes](#release-notes)
10
49
  - [Next Steps](#next-steps)
11
50
 
12
- This user guide provides a step-by-step walkthrough of a "Hello World" web application using the `BarcodeScanner` JavaScript Edition.
51
+ ## Hello World - Simplest Implementation
13
52
 
14
- The `BarcodeScanner` class offers the following features:
53
+ Let's start with the "Hello World" example of the DBR-JS SDK which demonstrates how to use the minimum code to enable a web page to read barcodes from a live video stream.
15
54
 
16
- - High-level APIs that deliver core functionality with a single line of code.
55
+ **Basic Requirements**
17
56
 
18
- - Pre-built UI components for fast and easy integration.
57
+ - Internet connection
58
+ - A supported browser
59
+ - Camera access
19
60
 
20
- - Intuitive configuration objects that streamline both algorithm and UI setup.
61
+ > Please refer to [system requirements](https://www.dynamsoft.com/faq/barcode-reader/web/capabilities/system-requirement.html) for more details.
21
62
 
22
- We recommend using this guide as a reference when creating your own application. If you are looking for a fully customizable barcode decoding library, you are welcome to use the [Foundational APIs](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html). Before starting, ensure the **basic requirements** are met.
63
+ ### Understand the code
23
64
 
24
- <!--
25
- Thanks to its simplified APIs and built-in UI for video streaming, you can implement basic scanning functionality with just one line of code:
26
-
27
- ```js
28
- new Dynamsoft.BarcodeScanner().launch().then(result=>alert(result.barcodeResults[0].text));
29
- ```
30
-
31
- <p align="center" style="text-align:center; white-space: normal; ">
32
- <a target="_blank" href="https://jsfiddle.net/DynamsoftTeam/csm2f9wb/" title="Run via JSFiddle" style="text-decoration:none;">
33
- <img src="https://cdn.jsdelivr.net/npm/simple-icons@3.0.1/icons/jsfiddle.svg" alt="Run via JSFiddle" width="20" height="20" style="width:20px;height:20px;" >
34
- </a>
35
- </p>
36
- -->
37
-
38
- - Internet connection
39
- - A supported browser
40
- - Camera access
41
-
42
- > [!TIP]
43
- > Please refer to [system requirements](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/faq/system-requirement.html) for more details.
44
-
45
- ## License
46
-
47
- When getting started with Barcode Scanner, we recommend [getting your own 30-day trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dbr&utm_source=npm&package=js)
48
-
49
- <!-- When getting started with Barcode Scanner, we recommend getting your own 30-day trial license.
50
-
51
- {% include trialLicense.html %} -->
52
-
53
- ## Quick Start: Hello World Example
65
+ The complete code of the "Hello World" example is shown below
54
66
 
55
67
  ```html
56
68
  <!DOCTYPE html>
57
- <html lang="en">
58
- <body>
59
- <script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
60
- <script>
61
- // Initialize the Dynamsoft Barcode Scanner
62
- const barcodeScanner = new Dynamsoft.BarcodeScanner({
63
- // Please don't forget to replace YOUR_LICENSE_KEY_HERE
64
- license: "YOUR_LICENSE_KEY_HERE",
65
- });
66
- (async () => {
67
- // Launch the scanner and wait for the result
68
- const result = await barcodeScanner.launch();
69
- // Display the first detected barcode's text in an alert
70
- if (result.barcodeResults.length) {
71
- alert(result.barcodeResults[0].text);
69
+ <html>
70
+ <body>
71
+ <div id="camera-view-container" style="width: 100%; height: 60vh"></div>
72
+ <textarea id="results" style="width: 100%; min-height: 10vh; font-size: 3vmin; overflow: auto" disabled></textarea>
73
+ <script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.4.2000/dist/dbr.bundle.js"></script>
74
+ <script>
75
+ Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
76
+ Dynamsoft.Core.CoreModule.loadWasm();
77
+ (async () => {
78
+ let cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance();
79
+
80
+ let cameraView = await Dynamsoft.DCE.CameraView.createInstance();
81
+ let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
82
+ document.querySelector("#camera-view-container").append(cameraView.getUIElement());
83
+ cvRouter.setInput(cameraEnhancer);
84
+
85
+ const resultsContainer = document.querySelector("#results");
86
+ await cvRouter.addResultReceiver({ onDecodedBarcodesReceived: (result) => {
87
+ if (result.barcodeResultItems?.length) {
88
+ resultsContainer.textContent = '';
89
+ for (let item of result.barcodeResultItems) {
90
+ resultsContainer.textContent += `${item.formatString}: ${item.text}\n\n`;
72
91
  }
73
- })();
74
- </script>
75
- </body>
92
+ }
93
+ }});
94
+
95
+ let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
96
+ filter.enableResultCrossVerification("barcode", true);
97
+ filter.enableResultDeduplication("barcode", true);
98
+ await cvRouter.addResultFilter(filter);
99
+
100
+ await cameraEnhancer.open();
101
+ await cvRouter.startCapturing("ReadSingleBarcode");
102
+ })();
103
+ </script>
104
+ </body>
76
105
  </html>
77
106
  ```
78
107
 
79
108
  <p align="center" style="text-align:center; white-space: normal; ">
80
- <a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v11.2.40/barcode-scanner-api-samples/scan-single-barcode/hello-world.html" title="Code in Github" style="text-decoration:none;">
109
+ <a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v11.4.20/hello-world.html" title="Code in Github" style="text-decoration:none;">
81
110
  <img src="https://cdn.jsdelivr.net/npm/simple-icons@3.0.1/icons/github.svg" alt="Code in Github" width="20" height="20" style="width:20px;height:20px;">
82
111
  </a>
83
112
  &nbsp;
84
- <a target="_blank" href="https://jsfiddle.net/DynamsoftTeam/gcqjf5r7/" title="Run via JSFiddle" style="text-decoration:none;">
113
+ <a target="_blank" href="https://jsfiddle.net/DynamsoftTeam/csm2f9wb/" title="Run via JSFiddle" style="text-decoration:none;">
85
114
  <img src="https://cdn.jsdelivr.net/npm/simple-icons@3.0.1/icons/jsfiddle.svg" alt="Run via JSFiddle" width="20" height="20" style="width:20px;height:20px;" >
86
115
  </a>
87
116
  &nbsp;
88
- <a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/barcode-scanner-api-samples/scan-single-barcode/hello-world.html?ver=11.2.40&utm_source=npm" title="Run in Dynamsoft" style="text-decoration:none;">
117
+ <a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world.html?ver=11.4.20&utm_source=npm" title="Run in Dynamsoft" style="text-decoration:none;">
89
118
  <img src="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.0.0/svgs/solid/circle-play.svg" alt="Run in Dynamsoft" width="20" height="20" style="width:20px;height:20px;">
90
119
  </a>
91
120
  </p>
92
121
 
93
- ### Step 1: Setting up the HTML and Including the Barcode Scanner
122
+ <!-- > Don't want to deal with too many details? You can get a quick start with the [BarcodeScanner >>](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html)
123
+ > ```js
124
+ > // Scan instantly with a single line of code!
125
+ > new Dynamsoft.BarcodeScanner().launch().then(result=>alert(result.barcodeResults[0].text));
126
+ > ``` -->
94
127
 
95
- As outlined earlier, this guide will help you create a simple Hello World barcode scanning application using vanilla JavaScript. The full sample code is also available in the [GitHub repository](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/v11.2.40).
128
+ -----
96
129
 
97
- The first step before writing the code is to include the SDK in your application. You can simply include the SDK by using the precompiled script.
130
+ #### About the code
98
131
 
99
- ```html
100
- <!DOCTYPE html>
101
- <html lang="en">
102
- <body>
103
- <script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
104
- </body>
105
- </html>
106
- ```
132
+ - `Dynamsoft.License.LicenseManager.initLicense()`: This method initializes the license for using the SDK in the application. Note that the string "**DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9**" used in this example points to an online license that requires a network connection to work. Read more on [Specify the license](#1-specify-the-license).
133
+
134
+ - `Dynamsoft.Core.CoreModule.loadWasm()`: This is an optional code. Used to load wasm resources in advance, reducing latency between video playing and barcode decoding.
135
+
136
+ - `Dynamsoft.CVR.CaptureVisionRouter.createInstance()`: This method creates a `CaptureVisionRouter` object `cvRouter` which controls the entire process in three steps:
137
+ - **Retrieve Images from the Image Source**
138
+ - `cvRouter` connects to the image source through the [ImageSourceAdapter](https://www.dynamsoft.com/capture-vision/docs/core/architecture/input.html#image-source-adapter?lang=js) interface with the method `setInput()`.
139
+ ```js
140
+ cvRouter.setInput(cameraEnhancer);
141
+ ```
142
+ > The image source in our case is a [CameraEnhancer](https://www.dynamsoft.com/camera-enhancer/docs/web/programming/javascript/user-guide/index.html) object created with `Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView)`
143
+ - **Coordinate Image-Processing Tasks**
144
+ - The coordination happens behind the scenes. `cvRouter` starts the process by specifying a preset template "ReadSingleBarcode" in the method `startCapturing()`.
145
+ ```js
146
+ cvRouter.startCapturing("ReadSingleBarcode");
147
+ ```
148
+ - **Dispatch Results to Listening Objects**
149
+ - The processing results are returned through the [CapturedResultReceiver](https://www.dynamsoft.com/capture-vision/docs/core/architecture/output.html#captured-result-receiver?lang=js) interface. The `CapturedResultReceiver` object is registered to `cvRouter` via the method `addResultReceiver()`. For more information, please check out [Register a result receiver](#step-4-register-a-result-receiver).
150
+ ```js
151
+ cvRouter.addResultReceiver({/*The-CapturedResultReceiver-Object"*/});
152
+ ```
153
+ - Also note that reading from video is extremely fast and there could be many duplicate results. We can use a [filter](#3-important-filter-the-results) with result deduplication enabled to filter out the duplicate results. The object is registered to `cvRouter` via the method `addResultFilter()`.
154
+ ```js
155
+ cvRouter.addResultFilter(filter);
156
+ ```
157
+
158
+ > Read more on [Capture Vision Router](https://www.dynamsoft.com/capture-vision/docs/core/architecture/#capture-vision-router).
107
159
 
108
- In this example, we include the precompiled Barcode Scanner SDK script via public CDN in the body.
160
+ ### Run the example
161
+
162
+ You can run the example deployed to [the Dynamsoft Demo Server](https://demo.dynamsoft.com/Samples/DBR/JS/hello-world.html?ver=11.4.20&utm_source=npm) or test it with [JSFiddle code editor](https://jsfiddle.net/DynamsoftTeam/csm2f9wb/).
163
+
164
+ You will be asked to allow access to your camera, after which the video will be displayed on the page. After that, you can point the camera at a barcode to read it.
165
+
166
+ When a barcode is decoded, you will see the result text show up under the video and the barcode location will be highlighted in the video feed.
167
+
168
+ Alternatively, you can test locally by copying and pasting the code shown above into a local file (e.g. "hello-world.html") and opening it in your browser.
169
+
170
+ > *Secure Contexts*:
171
+ >
172
+ > If you open the web page as `http://` , our SDK may not work correctly because the [MediaDevices: getUserMedia()](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) and other methods only work in [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts) (HTTPS, `localhost`, `127.0.0.1`, `file://`), in some or all supporting browsers.
173
+ >
174
+ > Regarding configuring https on your server, these guides for [nginx](https://nginx.org/en/docs/http/configuring_https_servers.html) / [IIS](https://aboutssl.org/how-to-create-a-self-signed-certificate-in-iis/) / [tomcat](https://dzone.com/articles/setting-ssl-tomcat-5-minutes) / [nodejs](https://nodejs.org/docs/v0.4.1/api/tls.html) might help.
175
+ >
176
+ > If the test doesn't go as expected, you can [contact us](https://www.dynamsoft.com/company/contact/?ver=11.4.20&utm_source=npm&product=dbr&package=js).
177
+
178
+ ## Preparing the SDK
179
+
180
+ ### Step 1: Include the SDK
109
181
 
110
182
  <div class="multi-panel-switching-prefix"></div>
183
+ <!--
184
+ - [Use a public CDN](#useapubliccdn)
185
+ - [Host the SDK yourself](#hostthesdkyourself) -->
111
186
 
112
187
  <div class="multi-panel-start"></div>
113
188
  <div class="multi-panel-title">Use a public CDN</div>
114
189
 
115
- The simplest way to include the SDK is to use either the [**jsDelivr**](https://jsdelivr.com/) or [**UNPKG**](https://unpkg.com/) CDN.
190
+ The simplest way to include the SDK is to use either the [jsDelivr](https://jsdelivr.com/) or [UNPKG](https://unpkg.com/) CDN. The "hello world" example above uses **jsDelivr**.
116
191
 
117
192
  - jsDelivr
118
193
 
119
194
  ```html
120
- <script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
195
+ <script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.4.2000/dist/dbr.bundle.js"></script>
121
196
  ```
122
197
 
123
198
  - UNPKG
124
199
 
125
200
  ```html
126
- <script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
201
+ <script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@11.4.2000/dist/dbr.bundle.js"></script>
202
+ ```
203
+
204
+ <!-- - In some rare cases (such as some restricted areas), you might not be able to access the CDN. If this happens, you can use the following files for the test.
205
+
206
+ ```html
207
+ <script src="https://download2.dynamsoft.com/packages/dynamsoft-barcode-reader-bundle@11.4.2000/dist/dbr.bundle.js"></script>
127
208
  ```
128
209
 
129
- When using a framework such as **React**, **Vue** or **Angular**, we recommend adding the package as a dependency using a package manager such as **npm** or **yarn**:
210
+ However, please **DO NOT** use `download2.dynamsoft.com` resources in a production application as they are for temporary testing purposes only. Instead, you can try hosting the SDK yourself. -->
211
+
212
+ - In frameworks like React, Vue and Angular, you may want to add the package as a dependency.
130
213
 
131
214
  ```sh
132
- npm i dynamsoft-barcode-reader-bundle@11.2.4000
215
+ npm i dynamsoft-barcode-reader-bundle@11.4.2000 -E
133
216
  # or
134
- yarn add dynamsoft-barcode-reader-bundle@11.2.4000
217
+ yarn add dynamsoft-barcode-reader-bundle@11.4.2000 -E
135
218
  ```
136
219
 
137
- When using package managers like **npm** or **yarn**, you likely need to specify the location of the engine files as a link to a CDN. Please see the [BarcodeScannerConfig API](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/barcode-scanner.html#barcodescannerconfig) for a code snippet on how to set the `engineResourcePaths`.
220
+ NOTE that in frameworks, you need to [specify the location of the engine files](#2-optional-specify-the-location-of-the-engine-files).
138
221
  <div class="multi-panel-end"></div>
139
222
 
140
223
  <div class="multi-panel-start"></div>
141
224
  <div class="multi-panel-title">Host the SDK yourself</div>
142
225
 
143
- Alternatively, you may choose to download the SDK and host the files on your own server or preferred CDN. This approach provides better control over versioning and availability.
226
+ Besides using the public CDN, you can also download the SDK and host its files on your own server or a commercial CDN before including it in your application.
144
227
 
145
228
  - From the website
146
229
 
147
- [Download Dynamsoft Barcode Reader JavaScript Package](https://www.dynamsoft.com/barcode-reader/downloads/?ver=11.2.40&utm_source=npm&product=dbr&package=js)
230
+ [Download Dynamsoft Barcode Reader JavaScript Package](https://www.dynamsoft.com/barcode-reader/downloads/?ver=11.4.20&utm_source=npm&product=dbr&package=js)
148
231
 
149
- The resources are located in the `./dist/` directory.
232
+ The resources are located at path `dynamsoft/distributables/<pkg>@<version>`.
150
233
 
151
234
  - From npm
152
235
 
153
236
  ```sh
154
- npm i dynamsoft-barcode-reader-bundle@11.2.4000
237
+ npm i dynamsoft-barcode-reader-bundle@11.4.2000 -E
155
238
  ```
156
239
 
157
- The resources are located at the path `node_modules/<pkg>`, without `@<version>`. You can copy it elsewhere and add `@<version>` tag.
158
-
159
- > [!IMPORTANT]
240
+ The resources are located at the path `node_modules/<pkg>`, without `@<version>`. You must copy "dynamsoft-xxx" packages elsewhere and add `@<version>`. The `<version>` can be obtained from `package.json` of each package. Another thing to do is to [specify the engineResourcePaths](#2-optional-specify-the-location-of-the-engine-files) so that the SDK can correctly locate the resources.
160
241
  > Since "node_modules" is reserved for Node.js dependencies, and in our case the package is used only as static resources, we recommend either renaming the "node_modules" folder or moving the "dynamsoft-" packages to a dedicated folder for static resources in your project to facilitate self-hosting.
161
242
 
162
- You can typically include the SDK like this:
243
+ You can typically include SDK like this:
163
244
 
164
245
  ```html
165
- <script src="path/to/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.js"></script>
246
+ <script src="path/to/dynamsoft-barcode-reader-bundle@11.4.2000/dist/dbr.bundle.js"></script>
166
247
  ```
167
248
  <div class="multi-panel-end"></div>
168
249
 
169
250
  <div class="multi-panel-switching-end"></div>
170
251
 
171
- Barcode Scanner comes with a **Ready-to-Use UI**. When the Barcode Scanner launches, it creates a container which it populates with the **Ready-to-Use UI**.
252
+ *Note*:
253
+
254
+ * Certain legacy web application servers may lack support for the `application/wasm` mimetype for .wasm files. To address this, you have two options:
255
+ 1. Upgrade your web application server to one that supports the `application/wasm` mimetype.
256
+ 2. Manually define the mimetype on your server. You can refer to the guides for [apache](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Apache_Configuration_htaccess#media_types_and_character_encodings) / [IIS](https://docs.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/mimemap) / [nginx](https://www.nginx.com/resources/wiki/start/topics/examples/full/#mime-types).
257
+
258
+ * To work properly, the SDK requires a few engine files, which are relatively large and may take quite a few seconds to download. We recommend that you set a longer cache time for these engine files, to maximize the performance of your web application.
259
+
260
+ ```
261
+ Cache-Control: max-age=31536000
262
+ ```
263
+
264
+ Reference: [Cache-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control).
265
+
266
+ ### Step 2: Prepare the SDK
267
+
268
+ Before using the SDK, you need to configure a few things.
269
+
270
+ #### 1. Specify the license
271
+
272
+ To enable the SDK's functionality, you must provide a valid license. Utilize the API function initLicense to set your license key.
172
273
 
173
- ### Step 2: Initializing the Barcode Scanner
274
+ ```javascript
275
+ Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
276
+ ```
277
+
278
+ As previously stated, the key "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" serves as a test license valid for 24 hours, applicable to any newly authorized browser. To test the SDK further, you can request a 30-day free trial license via the <a href="https://www.dynamsoft.com/customer/license/trialLicense?ver=11.4.20&utm_source=npm&product=dbr&package=js" target="_blank">Request a Trial License</a> link.
279
+
280
+ > Upon registering a Dynamsoft account and obtaining the SDK package from the official website, Dynamsoft will automatically create a 30-day free trial license and embed the corresponding license key into all the provided SDK samples.
281
+
282
+ #### 2. [Optional] Specify the location of the "engine" files
174
283
 
284
+ This step is generally necessary when utilizing frameworks such as Angular, React, Vue, or when managing the hosting of resource files yourself.
285
+
286
+ The purpose is to tell the SDK where to find the engine files (\*.worker.js, \*.wasm.js and \*.wasm, etc.).
287
+
288
+ ```ts
289
+ // in framework
290
+ import { CoreModule } from "dynamsoft-barcode-reader-bundle";
291
+ CoreModule.engineResourcePaths.rootDirectory = "https://cdn.jsdelivr.net/npm/";
292
+ ```
175
293
  ```js
176
- // Initialize the Dynamsoft Barcode Scanner
177
- const barcodeScanner = new Dynamsoft.BarcodeScanner({
178
- // Please don't forget to replace YOUR_LICENSE_KEY_HERE
179
- license: "YOUR_LICENSE_KEY_HERE",
180
- });
294
+ // in pure js
295
+ Dynamsoft.Core.CoreModule.engineResourcePaths.rootDirectory = "https://cdn.jsdelivr.net/npm/";
181
296
  ```
297
+ These code uses the jsDelivr CDN as an example, feel free to change it to your own location.
298
+
299
+ ## Using the SDK
182
300
 
183
- This is the **simplest** way to initialize the Barcode Scanner. The configuration object must include a valid **license** key. Without it, the scanner will fail to launch and display an error. For help obtaining a license, see the [licensing](#license) section.
301
+ ### Step 1: Preload the module
184
302
 
185
- > [!TIP]
186
- > By default, the `BarcodeScanner` scans a single barcode at a time. However, it also supports a `MULTI_UNIQUE` scanning mode, which continuously scans and accumulates unique results in real time. You can enable this mode by modifying the [`BarcodeScannerConfig`](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/barcode-scanner.html#barcodescannerconfig) as follows:
303
+ The image processing logic is encapsulated within .wasm library files, and these files may require some time for downloading. To enhance the speed, we advise utilizing the following method to preload the libraries.
187
304
 
188
305
  ```js
189
- // Initialize the Dynamsoft Barcode Scanner in MULTI_UNIQUE mode
190
- const barcodeScanner = new Dynamsoft.BarcodeScanner({
191
- license: "YOUR_LICENSE_KEY_HERE",
192
- scanMode: Dynamsoft.EnumScanMode.SM_MULTI_UNIQUE,
306
+ // Preload the .wasm files
307
+ Dynamsoft.Core.CoreModule.loadWasm();
308
+ ```
309
+
310
+ ### Step 2: Create a CaptureVisionRouter object
311
+
312
+ To use the SDK, we first create a `CaptureVisionRouter` object.
313
+
314
+ ```javascript
315
+ Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
316
+
317
+ let cvRouter = null;
318
+ try {
319
+ cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance();
320
+ } catch (ex) {
321
+ console.error(ex);
322
+ }
323
+ ```
324
+
325
+ *Tip*:
326
+
327
+ When creating a `CaptureVisionRouter` object within a function which may be called more than once, it's best to use a "helper" variable to avoid double creation such as `pCvRouter` in the following code:
328
+
329
+ ```javascript
330
+ Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
331
+
332
+ let pCvRouter = null; // The helper variable which is a promise of cvRouter
333
+ let cvRouter = null;
334
+
335
+ document.getElementById('btn-scan').addEventListener('click', async () => {
336
+ try {
337
+ cvRouter = await (pCvRouter = pCvRouter || Dynamsoft.CVR.CaptureVisionRouter.createInstance());
338
+ } catch (ex) {
339
+ console.error(ex);
340
+ }
193
341
  });
194
342
  ```
195
343
 
196
- ### Step 3: Launching the Barcode Scanner
344
+ ### Step 3: Connect an image source
345
+
346
+ The `CaptureVisionRouter` object, denoted as `cvRouter`, is responsible for handling images provided by an image source. In our scenario, we aim to detect barcodes directly from a live video stream. To facilitate this, we initialize a `CameraEnhancer` object, identified as `cameraEnhancer`, which is specifically designed to capture image frames from the video feed and subsequently forward them to `cvRouter`.
347
+
348
+ To enable video streaming on the webpage, we create a `CameraView` object referred to as `cameraView`, which is then passed to `cameraEnhancer`, and its content is displayed on the webpage.
349
+
350
+ ```html
351
+ <div id="camera-view-container" style="width: 100%; height: 100vh"></div>
352
+ ```
353
+
354
+ ```javascript
355
+ let cameraView = await Dynamsoft.DCE.CameraView.createInstance();
356
+ let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
357
+ document.querySelector("#camera-view-container").append(cameraView.getUIElement());
358
+ cvRouter.setInput(cameraEnhancer);
359
+ ```
360
+
361
+ ### Step 4: Register a result receiver
362
+
363
+ Once the image processing is complete, the results are sent to all the registered `CapturedResultReceiver` objects. Each `CapturedResultReceiver` object may encompass one or multiple callback functions associated with various result types. This time we use `onDecodedBarcodesReceived`:
364
+ <!--In our particular case, our focus is on identifying barcodes within the images, so it's sufficient to define the callback function `onDecodedBarcodesReceived`:-->
365
+
366
+ ```javascript
367
+ const resultsContainer = document.querySelector("#results");
368
+ const resultReceiver = new Dynamsoft.CVR.CapturedResultReceiver();
369
+ resultReceiver.onDecodedBarcodesReceived = (result) => {
370
+ if (result.barcodeResultItems?.length) {
371
+ resultsContainer.textContent = '';
372
+ for (let item of result.barcodeResultItems) {
373
+ // In this example, the barcode results are displayed on the page below the video.
374
+ resultsContainer.textContent += `${item.formatString}: ${item.text}\n\n`;
375
+ }
376
+ }
377
+ };
378
+ await cvRouter.addResultReceiver(resultReceiver);
379
+ ```
380
+
381
+ You can also write code like this. It is the same.
382
+
383
+ ```javascript
384
+ const resultsContainer = document.querySelector("#results");
385
+ await cvRouter.addResultReceiver({ onDecodedBarcodesReceived: (result) => {
386
+ if (result.barcodeResultItems?.length) {
387
+ resultsContainer.textContent = '';
388
+ for (let item of result.barcodeResultItems) {
389
+ // In this example, the barcode results are displayed on the page below the video.
390
+ resultsContainer.textContent += `${item.formatString}: ${item.text}\n\n`;
391
+ }
392
+ }
393
+ }});
394
+ ```
395
+
396
+ Check out [CapturedResultReceiver](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/captured-result-receiver.html) for more information.
397
+
398
+ ### Step 5: Start process video frames
399
+
400
+ With the setup now complete, we can proceed to process the images in two straightforward steps:
401
+
402
+ 1. Initiate the image source to commence image acquisition. In our scenario, we invoke the `open()` method on `cameraEnhancer` to initiate video streaming and simultaneously initiate the collection of images. These collected images will be dispatched to `cvRouter` as per its request.
403
+ 2. Define a preset template to commence image processing. In our case, we utilize the "ReadSingleBarcode" template, specifically tailored for processing images containing a single barcode.
404
+
405
+ ```javascript
406
+ await cameraEnhancer.open();
407
+ await cvRouter.startCapturing("ReadSingleBarcode");
408
+ ```
409
+
410
+ *Note*:
411
+
412
+ * `cvRouter` is engineered to consistently request images from the image source.
413
+ * Various preset templates are at your disposal for barcode reading:
414
+
415
+ | Template Name | Function Description |
416
+ | ------------------------------ | -------------------------------------------------------------- |
417
+ | **ReadBarcodes_Default** | Scans multiple barcodes by default setting. |
418
+ | **ReadSingleBarcode** | Quickly scans a single barcode. |
419
+ | **ReadBarcodes_SpeedFirst** | Prioritizes speed in scanning multiple barcodes. |
420
+ | **ReadBarcodes_ReadRateFirst** | Maximizes the number of barcodes read. |
421
+ | **ReadBarcodes_Balance** | Balances speed and quantity in reading multiple barcodes. |
422
+ | **ReadDenseBarcodes** | Specialized in reading barcodes with high information density. |
423
+ | **ReadDistantBarcodes** | Capable of reading barcodes from extended distances. |
424
+
425
+ Read more on the [preset CaptureVisionTemplates](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/preset-templates.html).
426
+
427
+ ## Customizing the process
428
+
429
+ ### 1. Adjust the preset template settings
430
+
431
+ When making adjustments to some basic tasks, we often only need to modify [SimplifiedCaptureVisionSettings](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/interfaces/simplified-capture-vision-settings.html).
432
+
433
+ #### 1.1. Change barcode settings
434
+
435
+ The preset templates can be updated to meet different requirements. For example, the following code limits the barcode format to QR code.
436
+
437
+ ```javascript
438
+ let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
439
+ settings.barcodeSettings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_QR_CODE;
440
+ await cvRouter.updateSettings("ReadSingleBarcode", settings);
441
+ await cvRouter.startCapturing("ReadSingleBarcode");
442
+ ```
443
+
444
+ For a list of adjustable barcode settings, check out [SimplifiedBarcodeReaderSettings](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/interfaces/simplified-barcode-reader-settings.html) and [EnumBarcodeFormat](https://www.dynamsoft.com/capture-vision/docs/core/enums/barcode-reader/barcode-format.html?lang=js&product=dbr).
445
+
446
+ #### 1.2. Retrieve the original image
447
+
448
+ Additionally, we have the option to modify the template to retrieve the original image containing the barcode.
449
+
450
+ ```javascript
451
+ let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
452
+ settings.outputOriginalImage = true;
453
+ await cvRouter.updateSettings("ReadSingleBarcode", settings);
454
+ await cvRouter.startCapturing("ReadSingleBarcode");
455
+ ```
456
+
457
+ Limit the barcode format to QR code, and retrieve the original image containing the barcode, at the same time.
458
+
459
+ ```javascript
460
+ let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
461
+ settings.outputOriginalImage = true;
462
+ settings.barcodeSettings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_QR_CODE;
463
+ await cvRouter.updateSettings("ReadSingleBarcode", settings);
464
+ await cvRouter.startCapturing("ReadSingleBarcode");
465
+ ```
466
+
467
+ Please be aware that it is necessary to update the `CapturedResultReceiver` object to obtain the original image. For instance:
468
+
469
+ ```javascript
470
+ const EnumCRIT = Dynamsoft.Core.EnumCapturedResultItemType; // Enum for captured result item types.
471
+ // Create a result receiver to handle the results.
472
+ await cvRouter.addResultReceiver({
473
+ // This function is called when any capture result is received.
474
+ onCapturedResultReceived: (result) => {
475
+ //Check for barcode results
476
+ let barcodeResultItems = result.items.filter((item) => item.type === EnumCRIT.CRIT_BARCODE);
477
+ if (barcodeResultItems.length > 0) {
478
+ let image = result.items.filter((item) => item.type === EnumCRIT.CRIT_ORIGINAL_IMAGE)[0]?.imageData; // Retrieve the original image.
479
+ if (image) document.body.appendChild(image.toCanvas()); // Append the image to DOM.
480
+ for (let item of barcodeResultItems) {
481
+ // Print each barcode result to the console.
482
+ console.log(`Barcode: ${item.text}, Format: ${item.formatString}`);
483
+ }
484
+ }
485
+ },
486
+ });
487
+ ```
488
+
489
+ #### 1.3. Change reading frequency to save power
490
+
491
+ The SDK is initially configured to process images sequentially without any breaks. Although this setup maximizes performance, it can lead to elevated power consumption, potentially causing the device to overheat. In many cases, it's possible to reduce the reading speed while still satisfying business requirements. The following code snippet illustrates how to adjust the SDK to process an image every 500 milliseconds:
492
+
493
+ > Please bear in mind that in the following code, if an image's processing time is shorter than 500 milliseconds, the SDK will wait for the full 500 milliseconds before proceeding to process the next image. Conversely, if an image's processing time exceeds 500 milliseconds, the subsequent image will be processed immediately upon completion.
494
+
495
+ ```javascript
496
+ let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
497
+ settings.minImageCaptureInterval = 500;
498
+ await cvRouter.updateSettings("ReadSingleBarcode", settings);
499
+ await cvRouter.startCapturing("ReadSingleBarcode");
500
+ ```
501
+
502
+ #### 1.4. Specify a scan region
503
+
504
+ We can specify a scan region to allow the SDK to process only part of the image, improving processing speed. The code snippet below demonstrates how to do this using the `cameraEnhancer` image source.
505
+
506
+ ```javascript
507
+ cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
508
+ // In this example, we set the scan region to cover the central 25% of the image.
509
+ cameraEnhancer.setScanRegion({
510
+ x: 25,
511
+ y: 25,
512
+ width: 50,
513
+ height: 50,
514
+ isMeasuredInPercentage: true,
515
+ });
516
+ ```
517
+
518
+ *Note*:
519
+
520
+ 1. By configuring the region at the image source, images are cropped before processing, removing the need to adjust any further processing settings.
521
+ 2. `cameraEnhancer` enhances interactivity by overlaying a mask on the video, clearly marking the scanning region.
522
+
523
+ *See Also*:
524
+
525
+ [CameraEnhancer::setScanRegion](https://www.dynamsoft.com/camera-enhancer/docs/web/programming/javascript/api-reference/acquisition.html#setscanregion)
526
+
527
+ <!-- Since DCE is always used, no need to use this approach
528
+
529
+
530
+ You can use the parameter `roi` (region of interest) together with the parameter `roiMeasuredInPercentage` to configure the SDK to only read a specific region on the image frames. For example, the following code limits the reading in the center 25%( = 50% * 50%) of the image frames:
531
+
532
+ ```javascript
533
+ let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
534
+ settings.roiMeasuredInPercentage = true;
535
+ settings.roi.points = [
536
+ { x: 25, y: 25 },
537
+ { x: 75, y: 25 },
538
+ { x: 75, y: 75 },
539
+ { x: 25, y: 75 },
540
+ ];
541
+ await cvRouter.updateSettings("ReadSingleBarcode", settings);
542
+ await cvRouter.startCapturing("ReadSingleBarcode");
543
+ ``` -->
544
+
545
+
546
+ <!--
547
+ * Specify the maximum time allowed for processing each image
548
+
549
+ You can set the maximum time allowed for processing a single image with the property `timeout`.
550
+
551
+ > Please be aware that the SDK will cease processing an image if its processing time exceeds the duration specified by the `timeout` parameter. It should not be confused with the previously discussed parameter, `minImageCaptureInterval`.
552
+
553
+ ```javascript
554
+ let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
555
+ settings.timeout = 500;
556
+ await cvRouter.updateSettings("ReadSingleBarcode", settings);
557
+ await cvRouter.startCapturing("ReadSingleBarcode");
558
+ ```
559
+ -->
560
+
561
+ ### 2. Edit the preset templates directly
562
+
563
+ The preset templates have many more settings that can be customized to suit your use case best. If you [download the SDK from Dynamsoft website](https://www.dynamsoft.com/barcode-reader/downloads/1000003-confirmation/), you can find the templates under
564
+
565
+ * "/dynamsoft-barcode-reader-js-11.4.2000/dist/templates/"
566
+
567
+ Upon completing the template editing, you can invoke the `initSettings` method and provide it with the template path as an argument.
568
+
569
+ ```javascript
570
+ await cvRouter.initSettings("PATH-TO-THE-FILE"); // E.g. "https://your-website/ReadSingleBarcode.json")
571
+ await cvRouter.startCapturing("ReadSingleBarcode"); // Make sure the name matches one of the CaptureVisionTemplates in the template JSON file.
572
+ ```
573
+
574
+ ### 3. [Important] Filter the results
575
+
576
+ When processing video frames, the same barcode is often detected multiple times. To improve the user experience, we can use the [MultiFrameResultCrossFilter](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/utility/multi-frame-result-cross-filter.html) object. This object provides two methods for handling duplicate detections, which can be used independently or together, depending on what best suits your application needs:
577
+
578
+ #### Method 1: Verify results across multiple frames
197
579
 
198
580
  ```js
199
- (async () => {
200
- // Launch the scanner and wait for the result
201
- const result = await barcodeScanner.launch();
202
- // Display the first detected barcode's text in an alert
203
- if (result.barcodeResults.length) {
204
- alert(result.barcodeResults[0].text);
581
+ let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
582
+ filter.enableResultCrossVerification("barcode", true);
583
+ await cvRouter.addResultFilter(filter);
584
+ ```
585
+
586
+ *Note*:
587
+
588
+ * `enableResultCrossVerification` was designed to cross-validate the outcomes across various frames in a video streaming scenario, enhancing the reliability of the final results. This validation is particularly crucial for barcodes with limited error correction capabilities, such as 1D codes.
589
+
590
+ #### Method 2: Eliminate redundant results detected within a short time frame
591
+
592
+ ```js
593
+ let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
594
+ filter.enableResultDeduplication("barcode", true);
595
+ await cvRouter.addResultFilter(filter);
596
+ ```
597
+
598
+ *Note*:
599
+
600
+ * `enableResultDeduplication` was designed to prevent high usage in video streaming scenarios, addressing the repetitive processing of the same code within a short period of time.
601
+
602
+ Initially, the filter is set to forget a result 3 seconds after it is first received. During this time frame, if an identical result appears, it is ignored.
603
+
604
+ > It's important to know that in version 9.x or earlier, the occurrence of an identical result would reset the timer, thus reinitiating the 3-second count at that point. However, in version 10.2.10 and later, an identical result no longer resets the timer but is instead disregarded, and the duration count continues uninterrupted.
605
+
606
+ Under certain circumstances, this duration can be extended with the method `setDuplicateForgetTime()`.
607
+
608
+ ```js
609
+ let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
610
+ filter.setDuplicateForgetTime("barcode", 5000); // Extend the duration to 5 seconds.
611
+ await cvRouter.addResultFilter(filter);
612
+ ```
613
+
614
+ You can also enable both options at the same time:
615
+
616
+ ```js
617
+ let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
618
+ filter.enableResultCrossVerification("barcode", true);
619
+ filter.enableResultDeduplication("barcode", true);
620
+ filter.setDuplicateForgetTime("barcode", 5000);
621
+ await cvRouter.addResultFilter(filter);
622
+ ```
623
+
624
+ ### 4. Add feedback
625
+
626
+ When a barcode is detected within the video stream, its position is immediately displayed within the video. Furthermore, utilizing the "Dynamsoft Camera Enhancer" SDK, we can introduce feedback mechanisms, such as emitting a "beep" sound or triggering a "vibration".
627
+
628
+ The following code snippet adds a "beep" sound for when a barcode is found:
629
+
630
+ ```js
631
+ const resultReceiver = new Dynamsoft.CVR.CapturedResultReceiver();
632
+ resultReceiver.onDecodedBarcodesReceived = (result) => {
633
+ if (result.barcodeResultItems.length > 0) {
634
+ Dynamsoft.DCE.Feedback.beep();
205
635
  }
206
- })();
636
+ };
637
+ await cvRouter.addResultReceiver(resultReceiver);
207
638
  ```
208
639
 
209
- Now that the Barcode Scanner has been initialized and configured, it is ready to be launched! Upon launch, the Barcode Scanner presents the main **`BarcodeScannerView`** UI in its container on the page, and is ready to start scanning. By default, we use the `SINGLE` scanning mode, which means only one decoding result will be included in the final result. In the code above, we directly alerted the successfully decoded barcode text on the page.
640
+ ## Customizing the UI
641
+
642
+ ```javascript
643
+ // Create a CameraView instance with default settings
644
+ let cameraView = await Dynamsoft.DCE.CameraView.createInstance();
645
+ // Create a CameraView instance with a specified XML file path, typically a local or remote URL
646
+ let cameraView1 = await Dynamsoft.DCE.CameraView.createInstance('@engineResourcePath/dce.ui.v5.xml');
647
+ // Create a CameraView instance within a specified DOM element
648
+ let cameraView2 = await Dynamsoft.DCE.CameraView.createInstance(document.getElementById('my-ui'));
649
+ // Create a CameraView instance using a custom UI file path
650
+ let cameraView3 = await Dynamsoft.DCE.CameraView.createInstance('url/to/my/ui.xml');
651
+
652
+ // Get the UI element associated with the cameraView instance
653
+ let uiElement = cameraView.getUIElement();
654
+ // Remove the camera selection dropdown from the CameraView's UI element
655
+ uiElement.querySelector('.dce-sel-camera').remove();
656
+ // Remove the resolution selection dropdown from the CameraView's UI element
657
+ uiElement.querySelector('.dce-sel-resolution').remove();
658
+ ```
659
+
660
+ The UI is part of the auxiliary SDK "Dynamsoft Camera Enhancer", read more on how to [customize the UI](https://www.dynamsoft.com/barcode-reader/docs/core/programming/features/ui-customization-js.html?lang=js).
661
+
662
+ ## Documentation
663
+
664
+ ### API Reference
665
+
666
+ You can check out the detailed documentation about the APIs of the SDK at
667
+ [https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=11.4.2000](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=11.4.2000).
668
+
669
+ <!-- Compatibility is basically not an issue. Pls remove to another place
670
+
671
+ ## System Requirements
672
+
673
+ DBR requires the following features to work:
674
+
675
+ - Secure context (HTTPS deployment)
676
+
677
+ When deploying your application / website for production, make sure to serve it via a secure HTTPS connection. This is required for two reasons
678
+
679
+ - Access to the camera video stream is only granted in a security context. Most browsers impose this restriction.
680
+ > Some browsers like Chrome may grant the access for `http://127.0.0.1` and `http://localhost` or even for pages opened directly from the local disk (`file:///...`). This can be helpful for temporary development and test.
681
+
682
+ - Dynamsoft License requires a secure context to work.
683
+
684
+ - `WebAssembly`, `Blob`, `URL`/`createObjectURL`, `Web Workers`
685
+
686
+ The above four features are required for the SDK to work.
687
+
688
+ - `MediaDevices`/`getUserMedia`
689
+
690
+ This API is required for in-browser video streaming.
691
+
692
+ - `getSettings`
693
+
694
+ This API inspects the video input which is a `MediaStreamTrack` object about its constrainable properties.
695
+
696
+ The following table is a list of supported browsers based on the above requirements:
697
+
698
+ | Browser Name | Version |
699
+ | :----------: | :--------------: |
700
+ | Chrome | v88+<sup>1</sup> |
701
+ | Firefox | v68+<sup>1</sup> |
702
+ | Edge | v79+ |
703
+ | Safari | v14+ |
704
+
705
+ <sup>1</sup> devices running iOS needs to be on iOS 14.3+ for camera video streaming to work in Chrome, Firefox or other Apps using webviews.
706
+
707
+ Apart from the browsers, the operating systems may impose some limitations of their own that could restrict the use of the SDK. Browser compatibility ultimately depends on whether the browser on that particular operating system supports the features listed above.
708
+
709
+ -->
710
+
711
+ ### How to Upgrade
712
+
713
+ If you want to upgrade the SDK from an old version to a newer one, please see [how to upgrade](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/migrate-from-v10/index.html).
714
+
715
+ ### Release Notes
210
716
 
211
- > [!NOTE]
212
- > In the Hello World sample, after a successful decoding process, the scanner closes and the user is met with an empty page. In order to open the scanner again, the user must refresh the page. You may choose to implement a more user-friendly behavior in a production environment, such as presenting the user with an option to re-open the Barcode Scanner upon closing it.
717
+ Learn about what are included in each release at [https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/release-notes/index.html](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/release-notes/index.html).
213
718
 
214
- > [!TIP]
215
- > When running performance benchmarks, make sure to disable the console, avoid using `console.log()`, and run in non-debug mode whenever possible. This ensures that your benchmark results reflect true performance without interference from logging or debugging overhead.
216
719
  ## Next Steps
217
720
 
218
- Now that you've implemented the basic functionality, here are some recommended next steps to further explore the capabilities of the Barcode Scanner:
721
+ Now that you have got the SDK integrated, you can choose to move forward in the following directions
219
722
 
220
- 1. Learn how to [Customize the Barcode Scanner](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html)
221
- 2. Check out the [Official Samples and Demo](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index.html?ver=11.2.4000)
222
- 3. Learn about the [APIs of BarcodeScanner](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/barcode-scanner.html?ver=11.2.4000)
723
+ 1. Learn how to [Use in Framework](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/use-in-framework.html)
724
+ 2. Check out the [Official Samples and Demo](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index.html)
725
+ 3. Learn about the [APIs of the SDK](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/index.html)