dynamsoft-barcode-reader-bundle 10.2.1000 → 10.4.2000-beta-202409252259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.html +110 -108
- package/README.md +118 -106
- package/dist/dbr.bundle.js +2 -2
- package/dist/dbr.bundle.mjs +2 -2
- package/dist/dbr.no-content-bundle.esm.js +2 -2
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -54,21 +54,21 @@ In this guide, you will learn step by step on how to integrate the DBR-JS SDK in
|
|
|
54
54
|
|
|
55
55
|
**Popular Examples**
|
|
56
56
|
|
|
57
|
-
- Hello World - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
58
|
-
- Angular App - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
59
|
-
- React App - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
60
|
-
- Vue App - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
61
|
-
- PWA App - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
62
|
-
- WebView in Android and iOS - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/v10.
|
|
63
|
-
- Read Driver Licenses - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
64
|
-
- Fill A Form - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
65
|
-
- Show result information on the video - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
66
|
-
- Debug Camera and Collect Video Frame - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
57
|
+
- Hello World - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/hello-world/hello-world.html) \| [Run](https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.4.20&utm_source=npm)
|
|
58
|
+
- Angular App - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/hello-world/angular) \| [Run](https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/angular/dist/dbrjs-sample-angular/browser/?ver=10.4.20&utm_source=npm)
|
|
59
|
+
- React App - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/hello-world/react) \| [Run](https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/react/build/?ver=10.4.20&utm_source=npm)
|
|
60
|
+
- Vue App - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/hello-world/vue) \| [Run](https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/vue/dist/?ver=10.4.20&utm_source=npm)
|
|
61
|
+
- PWA App - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/hello-world/pwa) \| [Run](https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/pwa/helloworld-pwa.html?ver=10.4.20&utm_source=npm)
|
|
62
|
+
- WebView in Android and iOS - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/v10.4.20/hello-world/webview)
|
|
63
|
+
- Read Driver Licenses - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/use-case/read-a-drivers-license/index.html) \| [Run](https://demo.dynamsoft.com/samples/dbr/js/use-case/read-a-drivers-license/index.html?ver=10.4.20&utm_source=npm)
|
|
64
|
+
- Fill A Form - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/use-case/fill-a-form-with-barcode-reading.html) \| [Run](https://demo.dynamsoft.com/samples/dbr/js/use-case/fill-a-form-with-barcode-reading.html?ver=10.4.20&utm_source=npm)
|
|
65
|
+
- Show result information on the video - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/use-case/show-result-texts-on-the-video.html) \| [Run](https://demo.dynamsoft.com/Samples/DBR/JS/use-case/show-result-texts-on-the-video.html?ver=10.4.20&utm_source=npm)
|
|
66
|
+
- Debug Camera and Collect Video Frame - [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/others/debug)
|
|
67
67
|
|
|
68
68
|
You can also:
|
|
69
69
|
|
|
70
|
-
- Try the Official Demo - [Run](https://demo.dynamsoft.com/barcode-reader-js/?ver=10.
|
|
71
|
-
- Try Online Examples - [Run](https://demo.dynamsoft.com/Samples/DBR/JS/index.html?ver=10.
|
|
70
|
+
- Try the Official Demo - [Run](https://demo.dynamsoft.com/barcode-reader-js/?ver=10.4.20&utm_source=npm) \| [Github](https://github.com/Dynamsoft/barcode-reader-javascript-demo/)
|
|
71
|
+
- Try Online Examples - [Run](https://demo.dynamsoft.com/Samples/DBR/JS/index.html?ver=10.4.20&utm_source=npm) \| [Github](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/v10.4.20/)
|
|
72
72
|
|
|
73
73
|
## Hello World - Simplest Implementation
|
|
74
74
|
|
|
@@ -87,18 +87,18 @@ The complete code of the "Hello World" example is shown below
|
|
|
87
87
|
<!DOCTYPE html>
|
|
88
88
|
<html>
|
|
89
89
|
<body>
|
|
90
|
-
<div id="
|
|
90
|
+
<div id="camera-view-container" style="width: 100%; height: 60vh"></div>
|
|
91
91
|
<textarea id="results" style="width: 100%; min-height: 10vh; font-size: 3vmin; overflow: auto" disabled></textarea>
|
|
92
|
-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.
|
|
92
|
+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.4.2000/dist/dbr.bundle.js"></script>
|
|
93
93
|
<script>
|
|
94
94
|
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
|
|
95
95
|
Dynamsoft.Core.CoreModule.loadWasm(["dbr"]);
|
|
96
96
|
(async () => {
|
|
97
97
|
let cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance();
|
|
98
98
|
|
|
99
|
-
let
|
|
100
|
-
let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(
|
|
101
|
-
document.querySelector("#
|
|
99
|
+
let cameraView = await Dynamsoft.DCE.CameraView.createInstance();
|
|
100
|
+
let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
|
|
101
|
+
document.querySelector("#camera-view-container").append(cameraView.getUIElement());
|
|
102
102
|
cvRouter.setInput(cameraEnhancer);
|
|
103
103
|
|
|
104
104
|
const resultsContainer = document.querySelector("#results");
|
|
@@ -127,7 +127,7 @@ The complete code of the "Hello World" example is shown below
|
|
|
127
127
|
<!--TOM: Update the code links-->
|
|
128
128
|
|
|
129
129
|
<p align="center" style="text-align:center; white-space: normal; ">
|
|
130
|
-
<a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.
|
|
130
|
+
<a target="_blank" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/v10.4.20/hello-world/hello-world.html" title="Code in Github" style="text-decoration:none;">
|
|
131
131
|
<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;">
|
|
132
132
|
</a>
|
|
133
133
|
|
|
@@ -135,11 +135,19 @@ The complete code of the "Hello World" example is shown below
|
|
|
135
135
|
<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;" >
|
|
136
136
|
</a>
|
|
137
137
|
|
|
138
|
-
<a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.
|
|
138
|
+
<a target="_blank" href="https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.4.20&utm_source=npm" title="Run in Dynamsoft" style="text-decoration:none;">
|
|
139
139
|
<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;">
|
|
140
140
|
</a>
|
|
141
141
|
</p>
|
|
142
142
|
|
|
143
|
+
> Don't want to deal with too many details? We also have an **out-of-the-box** version:
|
|
144
|
+
>
|
|
145
|
+
> [Easy Barcode Scanner >>](https://github.com/Dynamsoft/easy-barcode-scanner) available for your reference.
|
|
146
|
+
> ```js
|
|
147
|
+
> // Scan instantly with a single function!
|
|
148
|
+
> let txt = await EasyBarcodeScanner.scan();
|
|
149
|
+
> ```
|
|
150
|
+
|
|
143
151
|
-----
|
|
144
152
|
|
|
145
153
|
#### About the code
|
|
@@ -154,7 +162,7 @@ The complete code of the "Hello World" example is shown below
|
|
|
154
162
|
```js
|
|
155
163
|
cvRouter.setInput(cameraEnhancer);
|
|
156
164
|
```
|
|
157
|
-
> 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(
|
|
165
|
+
> 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)`
|
|
158
166
|
- **Coordinate Image-Processing Tasks**
|
|
159
167
|
- The coordination happens behind the scenes. `cvRouter` starts the process by specifying a preset template "ReadSingleBarcode" in the method `startCapturing()`.
|
|
160
168
|
```js
|
|
@@ -174,7 +182,7 @@ The complete code of the "Hello World" example is shown below
|
|
|
174
182
|
|
|
175
183
|
### Run the example
|
|
176
184
|
|
|
177
|
-
You can run the example deployed to [the Dynamsoft Demo Server](https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.
|
|
185
|
+
You can run the example deployed to [the Dynamsoft Demo Server](https://demo.dynamsoft.com/Samples/DBR/JS/hello-world/hello-world.html?ver=10.4.20&utm_source=npm) or test it with [JSFiddle code editor](https://jsfiddle.net/DynamsoftTeam/csm2f9wb/).
|
|
178
186
|
|
|
179
187
|
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.
|
|
180
188
|
|
|
@@ -193,7 +201,7 @@ To make sure your web application can access the camera, please configure your w
|
|
|
193
201
|
3. Tomcat: [Setting Up SSL on Tomcat in 5 minutes](https://dzone.com/articles/setting-ssl-tomcat-5-minutes)
|
|
194
202
|
4. Node.js: [npm tls](https://nodejs.org/docs/v0.4.1/api/tls.html)
|
|
195
203
|
|
|
196
|
-
If the test doesn't go as expected, you can [contact us](https://www.dynamsoft.com/company/contact/?ver=10.
|
|
204
|
+
If the test doesn't go as expected, you can [contact us](https://www.dynamsoft.com/company/contact/?ver=10.4.20&utm_source=npm&product=dbr&package=js).
|
|
197
205
|
|
|
198
206
|
## Building your own page
|
|
199
207
|
|
|
@@ -201,26 +209,14 @@ If the test doesn't go as expected, you can [contact us](https://www.dynamsoft.c
|
|
|
201
209
|
|
|
202
210
|
To utilize the SDK, the initial step involves including the corresponding resource files:
|
|
203
211
|
|
|
204
|
-
* `core.js` encompasses common classes, interfaces, and enumerations
|
|
212
|
+
* `core.js` encompasses common classes, interfaces, and enumerations shared across all Dynamsoft SDKs.
|
|
205
213
|
* `license.js` introduces the `LicenseManager` class, which manages the licensing for all Dynamsoft SDKs.
|
|
206
|
-
* `utility.js` encompasses auxiliary classes
|
|
207
|
-
* `dbr.js` defines interfaces and enumerations
|
|
214
|
+
* `utility.js` encompasses auxiliary classes shared among all Dynamsoft SDKs.
|
|
215
|
+
* `dbr.js` defines interfaces and enumerations tailored to the barcode reader module.
|
|
208
216
|
* `cvr.js` introduces the `CaptureVisionRouter` class, which governs the entire image processing workflow.
|
|
209
217
|
* `dce.js` comprises classes that offer camera support and basic user interface functionalities.
|
|
210
218
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
* dynamsoft-core@3.2.30/dist/core.js
|
|
214
|
-
* dynamsoft-license@3.2.21/dist/license.js
|
|
215
|
-
* dynamsoft-utility@1.2.20/dist/utility.js
|
|
216
|
-
* dynamsoft-barcode-reader@10.2.10/dist/dbr.js
|
|
217
|
-
* dynamsoft-capture-vision-router@2.2.30/dist/cvr.js
|
|
218
|
-
* dynamsoft-camera-enhancer@4.0.3/dist/dce.js
|
|
219
|
-
|
|
220
|
-
Equivalent to
|
|
221
|
-
* dynamsoft-barcode-reader-bundle@10.2.1000/dist/dbr.bundle.js
|
|
222
|
-
|
|
223
|
-
In the following chapters, we will use `dbr.bundle.js`.
|
|
219
|
+
To simplify things, starting from version 10.0.21, we introduced `dbr.bundle.js`, which combines all six of the above files. In the following chapters, we will use `dbr.bundle.js`.
|
|
224
220
|
|
|
225
221
|
#### Use a public CDN
|
|
226
222
|
|
|
@@ -229,62 +225,67 @@ The simplest way to include the SDK is to use either the [jsDelivr](https://jsde
|
|
|
229
225
|
- jsDelivr
|
|
230
226
|
|
|
231
227
|
```html
|
|
232
|
-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.
|
|
228
|
+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.4.2000/dist/dbr.bundle.js"></script>
|
|
233
229
|
```
|
|
234
230
|
|
|
235
231
|
- UNPKG
|
|
236
232
|
|
|
237
233
|
```html
|
|
238
|
-
<script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@10.
|
|
234
|
+
<script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@10.4.2000/dist/dbr.bundle.js"></script>
|
|
239
235
|
```
|
|
240
236
|
|
|
241
237
|
- 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.
|
|
242
238
|
|
|
243
239
|
```html
|
|
244
|
-
<script src="https://download2.dynamsoft.com/packages/dynamsoft-barcode-reader-bundle@10.
|
|
240
|
+
<script src="https://download2.dynamsoft.com/packages/dynamsoft-barcode-reader-bundle@10.4.2000/dist/dbr.bundle.js"></script>
|
|
245
241
|
```
|
|
246
242
|
|
|
247
243
|
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.
|
|
248
244
|
|
|
245
|
+
- In frameworks like React and Vue, you may want to add the package as a dependency.
|
|
246
|
+
|
|
247
|
+
```sh
|
|
248
|
+
npm i dynamsoft-barcode-reader-bundle@10.4.2000 -E
|
|
249
|
+
# or
|
|
250
|
+
yarn add dynamsoft-barcode-reader-bundle@10.4.2000 -E
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
NOTE that in frameworks, you need to [specify the engineResourcePaths](#specify-the-location-of-the-engine-files-optional).
|
|
254
|
+
|
|
249
255
|
#### Host the SDK yourself (optional)
|
|
250
256
|
|
|
251
257
|
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.
|
|
252
258
|
|
|
253
|
-
|
|
259
|
+
There are two options for downloading the SDK, and the usage for each is slightly different
|
|
254
260
|
|
|
255
261
|
- From the website
|
|
256
262
|
|
|
257
|
-
[Download Dynamsoft Barcode Reader JavaScript Package](https://www.dynamsoft.com/barcode-reader/downloads/?ver=10.
|
|
263
|
+
[Download Dynamsoft Barcode Reader JavaScript Package](https://www.dynamsoft.com/barcode-reader/downloads/?ver=10.4.20&utm_source=npm&product=dbr&package=js)
|
|
258
264
|
|
|
259
|
-
|
|
265
|
+
The resources are located at path `dynamsoft/distributables/<pkg>@<version>`, you can typically include it like this:
|
|
260
266
|
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
npm i dynamsoft-capture-vision-std@1.2.0 -E
|
|
264
|
-
npm i dynamsoft-image-processing@2.2.10 -E
|
|
267
|
+
```html
|
|
268
|
+
<script src="dynamsoft/distributables/dynamsoft-barcode-reader-bundle@10.4.2000/dist/dbr.bundle.js"></script>
|
|
265
269
|
```
|
|
266
270
|
|
|
267
|
-
-
|
|
271
|
+
- npm
|
|
268
272
|
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
+
```sh
|
|
274
|
+
npm i dynamsoft-barcode-reader-bundle@10.4.2000 -E
|
|
275
|
+
# Compared with using CDN, you need to set up more resources.
|
|
276
|
+
npm i dynamsoft-capture-vision-std@1.2.10 -E
|
|
277
|
+
npm i dynamsoft-image-processing@2.2.30 -E
|
|
273
278
|
```
|
|
274
279
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
- From the website
|
|
280
|
+
The resources are located at the path `node_modules/<pkg>`, without `@<version>`, so the script would be like:
|
|
278
281
|
|
|
279
282
|
```html
|
|
280
|
-
<script src="
|
|
283
|
+
<script src="node_modules/dynamsoft-barcode-reader-bundle/dist/dbr.bundle.js"></script>
|
|
281
284
|
```
|
|
285
|
+
|
|
286
|
+
Since the version tags (`@<version>`) are missing, you need to [specify the engineResourcePaths](#specify-the-location-of-the-engine-files-optional) so that the SDK can find the resources correctly.
|
|
282
287
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
```html
|
|
286
|
-
<script src="/node_modules/dynamsoft-barcode-reader-bundle@10.2.1000/dist/dbr.bundle.js"></script>
|
|
287
|
-
```
|
|
288
|
+
> To avoid confusion, we suggest renaming "node_modules" or moving "dynamsoft-" packages elsewhere for self-hosting, as "node_modules" is reserved for Node.js dependencies.
|
|
288
289
|
|
|
289
290
|
*Note*:
|
|
290
291
|
|
|
@@ -315,7 +316,7 @@ To enable the SDK's functionality, you must provide a valid license. Utilize the
|
|
|
315
316
|
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
|
|
316
317
|
```
|
|
317
318
|
|
|
318
|
-
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
|
|
319
|
+
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=10.4.20&utm_source=npm&product=dbr&package=js" target="_blank">Request a Trial License</a> link.
|
|
319
320
|
|
|
320
321
|
> 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.
|
|
321
322
|
|
|
@@ -328,13 +329,13 @@ The purpose is to tell the SDK where to find the engine files (\*.worker.js, \*.
|
|
|
328
329
|
```javascript
|
|
329
330
|
//The following code uses the jsDelivr CDN, feel free to change it to your own location of these files
|
|
330
331
|
Object.assign(Dynamsoft.Core.CoreModule.engineResourcePaths, {
|
|
331
|
-
std: "https://cdn.jsdelivr.net/npm/dynamsoft-capture-vision-std@1.
|
|
332
|
-
dip: "https://cdn.jsdelivr.net/npm/dynamsoft-image-processing@2.
|
|
333
|
-
core: "https://cdn.jsdelivr.net/npm/dynamsoft-core@3.
|
|
334
|
-
license: "https://cdn.jsdelivr.net/npm/dynamsoft-license@3.
|
|
335
|
-
cvr: "https://cdn.jsdelivr.net/npm/dynamsoft-capture-vision-router@2.
|
|
336
|
-
dbr: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader@10.
|
|
337
|
-
dce: "https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@4.0
|
|
332
|
+
std: "https://cdn.jsdelivr.net/npm/dynamsoft-capture-vision-std@1.4.10/dist/",
|
|
333
|
+
dip: "https://cdn.jsdelivr.net/npm/dynamsoft-image-processing@2.4.20/dist/",
|
|
334
|
+
core: "https://cdn.jsdelivr.net/npm/dynamsoft-core@3.4.20/dist/",
|
|
335
|
+
license: "https://cdn.jsdelivr.net/npm/dynamsoft-license@3.4.20/dist/",
|
|
336
|
+
cvr: "https://cdn.jsdelivr.net/npm/dynamsoft-capture-vision-router@2.4.20/dist/",
|
|
337
|
+
dbr: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader@10.4.20/dist/",
|
|
338
|
+
dce: "https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@4.1.0/dist/"
|
|
338
339
|
});
|
|
339
340
|
```
|
|
340
341
|
|
|
@@ -366,12 +367,12 @@ try {
|
|
|
366
367
|
|
|
367
368
|
*Tip*:
|
|
368
369
|
|
|
369
|
-
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 `
|
|
370
|
+
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:
|
|
370
371
|
|
|
371
372
|
```javascript
|
|
372
373
|
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
|
|
373
374
|
|
|
374
|
-
let pCvRouter = null; // promise of cvRouter
|
|
375
|
+
let pCvRouter = null; // The helper variable which is a promise of cvRouter
|
|
375
376
|
let cvRouter = null;
|
|
376
377
|
|
|
377
378
|
document.getElementById('btn-scan').addEventListener('click', async () => {
|
|
@@ -387,16 +388,16 @@ document.getElementById('btn-scan').addEventListener('click', async () => {
|
|
|
387
388
|
|
|
388
389
|
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`.
|
|
389
390
|
|
|
390
|
-
To enable video streaming on the webpage, we create a `CameraView` object referred to as `
|
|
391
|
+
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.
|
|
391
392
|
|
|
392
393
|
```html
|
|
393
|
-
<div id="
|
|
394
|
+
<div id="camera-view-container" style="width: 100%; height: 100vh"></div>
|
|
394
395
|
```
|
|
395
396
|
|
|
396
397
|
```javascript
|
|
397
|
-
let
|
|
398
|
-
let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(
|
|
399
|
-
document.querySelector("#
|
|
398
|
+
let cameraView = await Dynamsoft.DCE.CameraView.createInstance();
|
|
399
|
+
let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
|
|
400
|
+
document.querySelector("#camera-view-container").append(cameraView.getUIElement());
|
|
400
401
|
cvRouter.setInput(cameraEnhancer);
|
|
401
402
|
```
|
|
402
403
|
|
|
@@ -455,7 +456,7 @@ await cvRouter.startCapturing("ReadSingleBarcode");
|
|
|
455
456
|
|
|
456
457
|
| Template Name | Function Description |
|
|
457
458
|
| ------------------------------ | -------------------------------------------------------------- |
|
|
458
|
-
| **ReadBarcodes_Default** | Scans
|
|
459
|
+
| **ReadBarcodes_Default** | Scans barcodes. |
|
|
459
460
|
| **ReadSingleBarcode** | Quickly scans a single barcode. |
|
|
460
461
|
| **ReadBarcodes_SpeedFirst** | Prioritizes speed in scanning multiple barcodes. |
|
|
461
462
|
| **ReadBarcodes_ReadRateFirst** | Maximizes the number of barcodes read. |
|
|
@@ -515,10 +516,10 @@ const EnumCRIT = Dynamsoft.Core.EnumCapturedResultItemType;
|
|
|
515
516
|
resultReceiver.onCapturedResultReceived = (result) => {
|
|
516
517
|
let barcodes = result.items.filter(item => item.type === EnumCRIT.CRIT_BARCODE);
|
|
517
518
|
if (barcodes.length > 0) {
|
|
519
|
+
// Use a filter to get the image on which barcodes are found.
|
|
518
520
|
let image = result.items.filter(
|
|
519
521
|
item => item.type === EnumCRIT.CRIT_ORIGINAL_IMAGE
|
|
520
522
|
)[0].imageData;
|
|
521
|
-
// The image that we found the barcode(s) on.
|
|
522
523
|
}
|
|
523
524
|
};
|
|
524
525
|
```
|
|
@@ -538,6 +539,32 @@ await cvRouter.startCapturing("ReadSingleBarcode");
|
|
|
538
539
|
|
|
539
540
|
##### Specify a scan region
|
|
540
541
|
|
|
542
|
+
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.
|
|
543
|
+
|
|
544
|
+
```javascript
|
|
545
|
+
cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(cameraView);
|
|
546
|
+
// In this example, we set the scan region to cover the central 25% of the image.
|
|
547
|
+
cameraEnhancer.setScanRegion({
|
|
548
|
+
x: 25,
|
|
549
|
+
y: 25,
|
|
550
|
+
width: 50,
|
|
551
|
+
height: 50,
|
|
552
|
+
isMeasuredInPercentage: true,
|
|
553
|
+
});
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
*Note*:
|
|
557
|
+
|
|
558
|
+
1. By configuring the region at the image source, images are cropped before processing, removing the need to adjust any further processing settings.
|
|
559
|
+
2. `cameraEnhancer` enhances interactivity by overlaying a mask on the video, clearly marking the scanning region.
|
|
560
|
+
|
|
561
|
+
*See Also*:
|
|
562
|
+
|
|
563
|
+
[CameraEnhancer::setScanRegion](https://www.dynamsoft.com/camera-enhancer/docs/web/programming/javascript/api-reference/acquisition.html#setscanregion)
|
|
564
|
+
|
|
565
|
+
<!-- Since DCE is always used, no need to use this approach
|
|
566
|
+
|
|
567
|
+
|
|
541
568
|
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:
|
|
542
569
|
|
|
543
570
|
```javascript
|
|
@@ -551,24 +578,8 @@ settings.roi.points = [
|
|
|
551
578
|
];
|
|
552
579
|
await cvRouter.updateSettings("ReadSingleBarcode", settings);
|
|
553
580
|
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
554
|
-
```
|
|
555
|
-
|
|
556
|
-
While the code above accomplishes the task, a more effective approach is to restrict the scan region directly at the image source, as demonstrated in the following code snippet.
|
|
557
|
-
|
|
558
|
-
> * With the region configured at the image source, the images are cropped right before they are gathered for processing, eliminating the necessity to modify the processing settings further.
|
|
559
|
-
> * `cameraEnhancer` elevates interactivity by overlaying a mask on the video, providing a clear delineation of the scanning region.
|
|
560
|
-
> * See also: [CameraEnhancer::setScanRegion](https://www.dynamsoft.com/camera-enhancer/docs/web/programming/javascript/api-reference/acquisition.html#setscanregion)
|
|
581
|
+
``` -->
|
|
561
582
|
|
|
562
|
-
```javascript
|
|
563
|
-
cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(view);
|
|
564
|
-
cameraEnhancer.setScanRegion({
|
|
565
|
-
x: 25,
|
|
566
|
-
y: 25,
|
|
567
|
-
width: 50,
|
|
568
|
-
height: 50,
|
|
569
|
-
isMeasuredInPercentage: true,
|
|
570
|
-
});
|
|
571
|
-
```
|
|
572
583
|
|
|
573
584
|
<!--
|
|
574
585
|
* Specify the maximum time allowed for processing each image
|
|
@@ -587,15 +598,15 @@ await cvRouter.startCapturing("ReadSingleBarcode");
|
|
|
587
598
|
|
|
588
599
|
#### Edit the preset templates directly
|
|
589
600
|
|
|
590
|
-
The preset templates have
|
|
601
|
+
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
|
|
591
602
|
|
|
592
|
-
* "/dynamsoft-barcode-reader-js-10.
|
|
603
|
+
* "/dynamsoft-barcode-reader-js-10.4.2000/dynamsoft/templates/"
|
|
593
604
|
|
|
594
605
|
Upon completing the template editing, you can invoke the `initSettings` method and provide it with the template path as an argument.
|
|
595
606
|
|
|
596
607
|
```javascript
|
|
597
|
-
await cvRouter.initSettings("PATH-TO-THE-FILE"); //
|
|
598
|
-
await cvRouter.startCapturing("ReadSingleBarcode"); // Make sure the name matches one of the CaptureVisionTemplates in the
|
|
608
|
+
await cvRouter.initSettings("PATH-TO-THE-FILE"); // E.g. "https://your-website/ReadSingleBarcode.json")
|
|
609
|
+
await cvRouter.startCapturing("ReadSingleBarcode"); // Make sure the name matches one of the CaptureVisionTemplates in the template JSON file.
|
|
599
610
|
```
|
|
600
611
|
|
|
601
612
|
#### Filter the results (Important)
|
|
@@ -671,7 +682,7 @@ The UI is part of the auxiliary SDK "Dynamsoft Camera Enhancer", read more on ho
|
|
|
671
682
|
## API Documentation
|
|
672
683
|
|
|
673
684
|
You can check out the detailed documentation about the APIs of the SDK at
|
|
674
|
-
[https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.
|
|
685
|
+
[https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.4.2000](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.4.2000).
|
|
675
686
|
|
|
676
687
|
## System Requirements
|
|
677
688
|
|
|
@@ -703,7 +714,7 @@ The following table is a list of supported browsers based on the above requireme
|
|
|
703
714
|
| Browser Name | Version |
|
|
704
715
|
| :----------: | :--------------: |
|
|
705
716
|
| Chrome | v78+<sup>1</sup> |
|
|
706
|
-
| Firefox |
|
|
717
|
+
| Firefox | v68+<sup>1</sup> |
|
|
707
718
|
| Edge | v79+ |
|
|
708
719
|
| Safari | v14+ |
|
|
709
720
|
|
|
@@ -713,15 +724,16 @@ Apart from the browsers, the operating systems may impose some limitations of th
|
|
|
713
724
|
|
|
714
725
|
## How to Upgrade
|
|
715
726
|
|
|
716
|
-
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/upgrade-guide/index.html?ver=10.
|
|
727
|
+
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/upgrade-guide/index.html?ver=10.4.2000&utm_source=npm).
|
|
717
728
|
|
|
718
729
|
## Release Notes
|
|
719
730
|
|
|
720
|
-
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?ver=10.
|
|
731
|
+
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?ver=10.4.20&utm_source=npm).
|
|
721
732
|
|
|
722
733
|
## Next Steps
|
|
723
734
|
|
|
724
735
|
Now that you have got the SDK integrated, you can choose to move forward in the following directions
|
|
725
736
|
|
|
726
|
-
1.
|
|
727
|
-
2.
|
|
737
|
+
1. Learn how to [Use in Framework](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/use-in-framework.html)
|
|
738
|
+
2. Check out the [Official Samples and Demo](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index.html?ver=10.4.20)
|
|
739
|
+
3. Learn about the [APIs of the SDK](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/index.html?ver=10.4.2000)
|