dynamsoft-barcode-reader-bundle 10.2.1000-beta-202405192313 → 10.2.1000
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 +81 -118
- package/README.md +79 -128
- 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 +2 -2
package/README.md
CHANGED
|
@@ -89,20 +89,20 @@ The complete code of the "Hello World" example is shown below
|
|
|
89
89
|
<body>
|
|
90
90
|
<div id="cameraViewContainer" 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@10.2.
|
|
92
|
+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.2.1000/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
|
-
let
|
|
97
|
+
let cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance();
|
|
98
98
|
|
|
99
99
|
let view = await Dynamsoft.DCE.CameraView.createInstance();
|
|
100
100
|
let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(view);
|
|
101
101
|
document.querySelector("#cameraViewContainer").append(view.getUIElement());
|
|
102
|
-
|
|
102
|
+
cvRouter.setInput(cameraEnhancer);
|
|
103
103
|
|
|
104
104
|
const resultsContainer = document.querySelector("#results");
|
|
105
|
-
|
|
105
|
+
cvRouter.addResultReceiver({ onDecodedBarcodesReceived: (result) => {
|
|
106
106
|
if (result.barcodeResultItems.length > 0) {
|
|
107
107
|
resultsContainer.textContent = '';
|
|
108
108
|
for (let item of result.barcodeResultItems) {
|
|
@@ -114,10 +114,10 @@ The complete code of the "Hello World" example is shown below
|
|
|
114
114
|
let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
|
|
115
115
|
filter.enableResultCrossVerification("barcode", true);
|
|
116
116
|
filter.enableResultDeduplication("barcode", true);
|
|
117
|
-
await
|
|
117
|
+
await cvRouter.addResultFilter(filter);
|
|
118
118
|
|
|
119
119
|
await cameraEnhancer.open();
|
|
120
|
-
await
|
|
120
|
+
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
121
121
|
})();
|
|
122
122
|
</script>
|
|
123
123
|
</body>
|
|
@@ -148,26 +148,26 @@ The complete code of the "Hello World" example is shown below
|
|
|
148
148
|
|
|
149
149
|
- `Dynamsoft.Core.CoreModule.loadWasm(["dbr"])`: This is an optional code. Used to load wasm resources in advance, reducing latency between video playing and barcode decoding.
|
|
150
150
|
|
|
151
|
-
- `Dynamsoft.CVR.CaptureVisionRouter.createInstance()`: This method creates a `CaptureVisionRouter` object `
|
|
151
|
+
- `Dynamsoft.CVR.CaptureVisionRouter.createInstance()`: This method creates a `CaptureVisionRouter` object `cvRouter` which controls the entire process in three steps:
|
|
152
152
|
- **Retrieve Images from the Image Source**
|
|
153
|
-
- `
|
|
153
|
+
- `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()`.
|
|
154
154
|
```js
|
|
155
|
-
|
|
155
|
+
cvRouter.setInput(cameraEnhancer);
|
|
156
156
|
```
|
|
157
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(view)`
|
|
158
158
|
- **Coordinate Image-Processing Tasks**
|
|
159
|
-
- The coordination happens behind the scenes. `
|
|
159
|
+
- The coordination happens behind the scenes. `cvRouter` starts the process by specifying a preset template "ReadSingleBarcode" in the method `startCapturing()`.
|
|
160
160
|
```js
|
|
161
|
-
|
|
161
|
+
cvRouter.startCapturing("ReadSingleBarcode");
|
|
162
162
|
```
|
|
163
163
|
- **Dispatch Results to Listening Objects**
|
|
164
|
-
- 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 `
|
|
164
|
+
- 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](#register-a-result-receiver).
|
|
165
165
|
```js
|
|
166
|
-
|
|
166
|
+
cvRouter.addResultReceiver({/*The-CapturedResultReceiver-Object"*/});
|
|
167
167
|
```
|
|
168
|
-
- Also note that reading from video is extremely fast and there could be many duplicate results. We can use a [filter](#filter-the-results-important) with result deduplication enabled to filter out the duplicate results. The object is registered to `
|
|
168
|
+
- Also note that reading from video is extremely fast and there could be many duplicate results. We can use a [filter](#filter-the-results-important) with result deduplication enabled to filter out the duplicate results. The object is registered to `cvRouter` via the method `addResultFilter()`.
|
|
169
169
|
```js
|
|
170
|
-
|
|
170
|
+
cvRouter.addResultFilter(filter);
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
> Read more on [Capture Vision Router](https://www.dynamsoft.com/capture-vision/docs/core/architecture/#capture-vision-router).
|
|
@@ -210,6 +210,18 @@ To utilize the SDK, the initial step involves including the corresponding resour
|
|
|
210
210
|
|
|
211
211
|
For simplification, starting from version 10.0.21, we introduced `dbr.bundle.js`. Including this file is equivalent to incorporating all six packages.
|
|
212
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`.
|
|
224
|
+
|
|
213
225
|
#### Use a public CDN
|
|
214
226
|
|
|
215
227
|
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**.
|
|
@@ -217,48 +229,22 @@ The simplest way to include the SDK is to use either the [jsDelivr](https://jsde
|
|
|
217
229
|
- jsDelivr
|
|
218
230
|
|
|
219
231
|
```html
|
|
220
|
-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-
|
|
221
|
-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-license@3.2.10/dist/license.js"></script>
|
|
222
|
-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-utility@1.2.10/dist/utility.js"></script>
|
|
223
|
-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader@10.2.10/dist/dbr.js"></script>
|
|
224
|
-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-capture-vision-router@2.2.10/dist/cvr.js"></script>
|
|
225
|
-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-camera-enhancer@4.0.2/dist/dce.js"></script>
|
|
232
|
+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@10.2.1000/dist/dbr.bundle.js"></script>
|
|
226
233
|
```
|
|
227
234
|
|
|
228
|
-
|
|
235
|
+
- UNPKG
|
|
229
236
|
|
|
230
237
|
```html
|
|
231
|
-
<script src="https://
|
|
238
|
+
<script src="https://unpkg.com/dynamsoft-barcode-reader-bundle@10.2.1000/dist/dbr.bundle.js"></script>
|
|
232
239
|
```
|
|
233
240
|
|
|
234
|
-
-
|
|
241
|
+
- 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.
|
|
235
242
|
|
|
236
243
|
```html
|
|
237
|
-
<script src="https://
|
|
238
|
-
<script src="https://unpkg.com/dynamsoft-license@3.2.10/dist/license.js"></script>
|
|
239
|
-
<script src="https://unpkg.com/dynamsoft-utility@1.2.10/dist/utility.js"></script>
|
|
240
|
-
<script src="https://unpkg.com/dynamsoft-barcode-reader@10.2.10/dist/dbr.js"></script>
|
|
241
|
-
<script src="https://unpkg.com/dynamsoft-capture-vision-router@2.2.10/dist/cvr.js"></script>
|
|
242
|
-
<script src="https://unpkg.com/dynamsoft-camera-enhancer@4.0.2/dist/dce.js"></script>
|
|
244
|
+
<script src="https://download2.dynamsoft.com/packages/dynamsoft-barcode-reader-bundle@10.2.1000/dist/dbr.bundle.js"></script>
|
|
243
245
|
```
|
|
244
246
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
```html
|
|
248
|
-
<script src="https://unpkg.com/dynamsoft-barcode-reader@10.2.10/dist/dbr.bundle.js"></script>
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
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.
|
|
252
|
-
|
|
253
|
-
- https://download2.dynamsoft.com/packages/dynamsoft-core@3.2.10/dist/core.js
|
|
254
|
-
- https://download2.dynamsoft.com/packages/dynamsoft-license@3.2.10/dist/license.js
|
|
255
|
-
- https://download2.dynamsoft.com/packages/dynamsoft-utility@1.2.10/dist/utility.js
|
|
256
|
-
- https://download2.dynamsoft.com/packages/dynamsoft-barcode-reader@10.2.10/dist/dbr.js
|
|
257
|
-
- https://download2.dynamsoft.com/packages/dynamsoft-capture-vision-router@2.2.10/dist/cvr.js
|
|
258
|
-
- https://download2.dynamsoft.com/packages/dynamsoft-camera-enhancer@4.0.2/dist/dce.js
|
|
259
|
-
- or bundle: https://download2.dynamsoft.com/packages/dynamsoft-barcode-reader@10.2.10/dist/dbr.bundle.js
|
|
260
|
-
|
|
261
|
-
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.
|
|
247
|
+
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.
|
|
262
248
|
|
|
263
249
|
#### Host the SDK yourself (optional)
|
|
264
250
|
|
|
@@ -273,12 +259,7 @@ Options to download the SDK:
|
|
|
273
259
|
- npm
|
|
274
260
|
|
|
275
261
|
```cmd
|
|
276
|
-
npm i dynamsoft-
|
|
277
|
-
npm i dynamsoft-license@3.2.10 -E
|
|
278
|
-
npm i dynamsoft-utility@1.2.10 -E
|
|
279
|
-
npm i dynamsoft-barcode-reader@10.2.10 -E
|
|
280
|
-
npm i dynamsoft-capture-vision-router@2.2.10 -E
|
|
281
|
-
npm i dynamsoft-camera-enhancer@4.0.2 -E
|
|
262
|
+
npm i dynamsoft-barcode-reader-bundle@10.2.1000 -E
|
|
282
263
|
npm i dynamsoft-capture-vision-std@1.2.0 -E
|
|
283
264
|
npm i dynamsoft-image-processing@2.2.10 -E
|
|
284
265
|
```
|
|
@@ -286,12 +267,7 @@ Options to download the SDK:
|
|
|
286
267
|
- yarn
|
|
287
268
|
|
|
288
269
|
```cmd
|
|
289
|
-
yarn add dynamsoft-
|
|
290
|
-
yarn add dynamsoft-license@3.2.10 -E
|
|
291
|
-
yarn add dynamsoft-utility@1.2.10 -E
|
|
292
|
-
yarn add dynamsoft-barcode-reader@10.2.10 -E
|
|
293
|
-
yarn add dynamsoft-capture-vision-router@2.2.10 -E
|
|
294
|
-
yarn add dynamsoft-camera-enhancer@4.0.2 -E
|
|
270
|
+
yarn add dynamsoft-barcode-reader-bundle@10.2.1000 -E
|
|
295
271
|
yarn add dynamsoft-capture-vision-std@1.2.0 -E
|
|
296
272
|
yarn add dynamsoft-image-processing@2.2.10 -E
|
|
297
273
|
```
|
|
@@ -301,35 +277,13 @@ Depending on how you downloaded the SDK and how you intend to use it, you can ty
|
|
|
301
277
|
- From the website
|
|
302
278
|
|
|
303
279
|
```html
|
|
304
|
-
<script src="./dynamsoft/distributables/dynamsoft-
|
|
305
|
-
<script src="./dynamsoft/distributables/dynamsoft-license@3.2.10/dist/license.js"></script>
|
|
306
|
-
<script src="./dynamsoft/distributables/dynamsoft-utility@1.2.10/dist/utility.js"></script>
|
|
307
|
-
<script src="./dynamsoft/distributables/dynamsoft-barcode-reader@10.2.10/dist/dbr.js"></script>
|
|
308
|
-
<script src="./dynamsoft/distributables/dynamsoft-capture-vision-router@2.2.10/dist/cvr.js"></script>
|
|
309
|
-
<script src="./dynamsoft/distributables/dynamsoft-camera-enhancer@4.0.2/dist/dce.js"></script>
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
Or just
|
|
313
|
-
|
|
314
|
-
```html
|
|
315
|
-
<script src="./dynamsoft/distributables/dynamsoft-barcode-reader@10.2.10/dist/dbr.bundle.js"></script>
|
|
280
|
+
<script src="./dynamsoft/distributables/dynamsoft-barcode-reader-bundle@10.2.1000/dist/dbr.bundle.js"></script>
|
|
316
281
|
```
|
|
317
282
|
|
|
318
283
|
- yarn or npm
|
|
319
284
|
|
|
320
285
|
```html
|
|
321
|
-
<script src="/node_modules/dynamsoft-
|
|
322
|
-
<script src="/node_modules/dynamsoft-license/dist/license.js"></script>
|
|
323
|
-
<script src="/node_modules/dynamsoft-utility/dist/utility.js"></script>
|
|
324
|
-
<script src="/node_modules/dynamsoft-barcode-reader/dist/dbr.js"></script>
|
|
325
|
-
<script src="/node_modules/dynamsoft-capture-vision-router/dist/cvr.js"></script>
|
|
326
|
-
<script src="/node_modules/dynamsoft-camera-enhancer/dist/dce.js"></script>
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
Or just
|
|
330
|
-
|
|
331
|
-
```html
|
|
332
|
-
<script src="/node_modules/dynamsoft-barcode-reader/dist/dbr.bundle.js"></script>
|
|
286
|
+
<script src="/node_modules/dynamsoft-barcode-reader-bundle@10.2.1000/dist/dbr.bundle.js"></script>
|
|
333
287
|
```
|
|
334
288
|
|
|
335
289
|
*Note*:
|
|
@@ -402,9 +356,9 @@ To use the SDK, we first create a `CaptureVisionRouter` object.
|
|
|
402
356
|
```javascript
|
|
403
357
|
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
|
|
404
358
|
|
|
405
|
-
let
|
|
359
|
+
let cvRouter = null;
|
|
406
360
|
try {
|
|
407
|
-
|
|
361
|
+
cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance();
|
|
408
362
|
} catch (ex) {
|
|
409
363
|
console.error(ex);
|
|
410
364
|
}
|
|
@@ -417,12 +371,12 @@ When creating a `CaptureVisionRouter` object within a function which may be call
|
|
|
417
371
|
```javascript
|
|
418
372
|
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
|
|
419
373
|
|
|
420
|
-
let
|
|
421
|
-
let
|
|
374
|
+
let pCvRouter = null; // promise of cvRouter
|
|
375
|
+
let cvRouter = null;
|
|
422
376
|
|
|
423
377
|
document.getElementById('btn-scan').addEventListener('click', async () => {
|
|
424
378
|
try {
|
|
425
|
-
|
|
379
|
+
cvRouter = await (pCvRouter = pCvRouter || Dynamsoft.CVR.CaptureVisionRouter.createInstance());
|
|
426
380
|
} catch (ex) {
|
|
427
381
|
console.error(ex);
|
|
428
382
|
}
|
|
@@ -431,7 +385,7 @@ document.getElementById('btn-scan').addEventListener('click', async () => {
|
|
|
431
385
|
|
|
432
386
|
#### Connect an image source
|
|
433
387
|
|
|
434
|
-
The `CaptureVisionRouter` object, denoted as `
|
|
388
|
+
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`.
|
|
435
389
|
|
|
436
390
|
To enable video streaming on the webpage, we create a `CameraView` object referred to as `view`, which is then passed to `cameraEnhancer`, and its content is displayed on the webpage.
|
|
437
391
|
|
|
@@ -443,7 +397,7 @@ To enable video streaming on the webpage, we create a `CameraView` object referr
|
|
|
443
397
|
let view = await Dynamsoft.DCE.CameraView.createInstance();
|
|
444
398
|
let cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(view);
|
|
445
399
|
document.querySelector("#cameraViewContainer").append(view.getUIElement());
|
|
446
|
-
|
|
400
|
+
cvRouter.setInput(cameraEnhancer);
|
|
447
401
|
```
|
|
448
402
|
|
|
449
403
|
#### Register a result receiver
|
|
@@ -457,23 +411,23 @@ resultReceiver.onDecodedBarcodesReceived = (result) => {
|
|
|
457
411
|
if (result.barcodeResultItems.length > 0) {
|
|
458
412
|
resultsContainer.textContent = '';
|
|
459
413
|
for (let item of result.barcodeResultItems) {
|
|
460
|
-
// In this example, the barcode
|
|
414
|
+
// In this example, the barcode results are displayed on the page below the video.
|
|
461
415
|
resultsContainer.textContent += `${item.formatString}: ${item.text}\n\n`;
|
|
462
416
|
}
|
|
463
417
|
}
|
|
464
418
|
};
|
|
465
|
-
|
|
419
|
+
cvRouter.addResultReceiver(resultReceiver);
|
|
466
420
|
```
|
|
467
421
|
|
|
468
422
|
You can also write code like this. It is the same.
|
|
469
423
|
|
|
470
424
|
```javascript
|
|
471
425
|
const resultsContainer = document.querySelector("#results");
|
|
472
|
-
|
|
426
|
+
cvRouter.addResultReceiver({ onDecodedBarcodesReceived: (result) => {
|
|
473
427
|
if (result.barcodeResultItems.length > 0) {
|
|
474
428
|
resultsContainer.textContent = '';
|
|
475
429
|
for (let item of result.barcodeResultItems) {
|
|
476
|
-
// In this example, the barcode
|
|
430
|
+
// In this example, the barcode results are displayed on the page below the video.
|
|
477
431
|
resultsContainer.textContent += `${item.formatString}: ${item.text}\n\n`;
|
|
478
432
|
}
|
|
479
433
|
}
|
|
@@ -486,17 +440,17 @@ Check out [CapturedResultReceiver](https://www.dynamsoft.com/capture-vision/docs
|
|
|
486
440
|
|
|
487
441
|
With the setup now complete, we can proceed to process the images in two straightforward steps:
|
|
488
442
|
|
|
489
|
-
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 `
|
|
443
|
+
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.
|
|
490
444
|
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.
|
|
491
445
|
|
|
492
446
|
```javascript
|
|
493
447
|
await cameraEnhancer.open();
|
|
494
|
-
await
|
|
448
|
+
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
495
449
|
```
|
|
496
450
|
|
|
497
451
|
*Note*:
|
|
498
452
|
|
|
499
|
-
* `
|
|
453
|
+
* `cvRouter` is engineered to consistently request images from the image source.
|
|
500
454
|
* Various preset templates are at your disposal for barcode reading:
|
|
501
455
|
|
|
502
456
|
| Template Name | Function Description |
|
|
@@ -522,11 +476,11 @@ When making adjustments to some basic tasks, we often only need to modify [Simpl
|
|
|
522
476
|
The preset templates can be updated to meet different requirements. For example, the following code limits the barcode format to QR code.
|
|
523
477
|
|
|
524
478
|
```javascript
|
|
525
|
-
let settings = await
|
|
479
|
+
let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
|
|
526
480
|
settings.barcodeSettings.barcodeFormatIds =
|
|
527
481
|
Dynamsoft.DBR.EnumBarcodeFormat.BF_QR_CODE;
|
|
528
|
-
await
|
|
529
|
-
await
|
|
482
|
+
await cvRouter.updateSettings("ReadSingleBarcode", settings);
|
|
483
|
+
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
530
484
|
```
|
|
531
485
|
|
|
532
486
|
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).
|
|
@@ -536,36 +490,33 @@ For a list of adjustable barcode settings, check out [SimplifiedBarcodeReaderSet
|
|
|
536
490
|
Additionally, we have the option to modify the template to retrieve the original image containing the barcode.
|
|
537
491
|
|
|
538
492
|
```javascript
|
|
539
|
-
let settings = await
|
|
493
|
+
let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
|
|
540
494
|
settings.capturedResultItemTypes |=
|
|
541
495
|
Dynamsoft.Core.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE;
|
|
542
|
-
await
|
|
543
|
-
await
|
|
496
|
+
await cvRouter.updateSettings("ReadSingleBarcode", settings);
|
|
497
|
+
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
544
498
|
```
|
|
545
499
|
|
|
546
500
|
Limit the barcode format to QR code, and retrieve the original image containing the barcode, at the same time.
|
|
547
501
|
|
|
548
502
|
```javascript
|
|
549
|
-
let settings = await
|
|
503
|
+
let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
|
|
550
504
|
settings.capturedResultItemTypes =
|
|
551
505
|
Dynamsoft.DBR.EnumBarcodeFormat.BF_QR_CODE |
|
|
552
506
|
Dynamsoft.Core.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE;
|
|
553
|
-
await
|
|
554
|
-
await
|
|
507
|
+
await cvRouter.updateSettings("ReadSingleBarcode", settings);
|
|
508
|
+
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
555
509
|
```
|
|
556
510
|
|
|
557
511
|
Please be aware that it is necessary to update the `CapturedResultReceiver` object to obtain the original image. For instance:
|
|
558
512
|
|
|
559
513
|
```javascript
|
|
514
|
+
const EnumCRIT = Dynamsoft.Core.EnumCapturedResultItemType;
|
|
560
515
|
resultReceiver.onCapturedResultReceived = (result) => {
|
|
561
|
-
let barcodes = result.items.filter(
|
|
562
|
-
item.type === Dynamsoft.Core.EnumCapturedResultItemType.CRIT_BARCODE
|
|
563
|
-
);
|
|
516
|
+
let barcodes = result.items.filter(item => item.type === EnumCRIT.CRIT_BARCODE);
|
|
564
517
|
if (barcodes.length > 0) {
|
|
565
518
|
let image = result.items.filter(
|
|
566
|
-
|
|
567
|
-
item.type ===
|
|
568
|
-
Dynamsoft.Core.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE
|
|
519
|
+
item => item.type === EnumCRIT.CRIT_ORIGINAL_IMAGE
|
|
569
520
|
)[0].imageData;
|
|
570
521
|
// The image that we found the barcode(s) on.
|
|
571
522
|
}
|
|
@@ -579,10 +530,10 @@ The SDK is initially configured to process images sequentially without any break
|
|
|
579
530
|
> 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.
|
|
580
531
|
|
|
581
532
|
```javascript
|
|
582
|
-
let settings = await
|
|
533
|
+
let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
|
|
583
534
|
settings.minImageCaptureInterval = 500;
|
|
584
|
-
await
|
|
585
|
-
await
|
|
535
|
+
await cvRouter.updateSettings("ReadSingleBarcode", settings);
|
|
536
|
+
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
586
537
|
```
|
|
587
538
|
|
|
588
539
|
##### Specify a scan region
|
|
@@ -590,7 +541,7 @@ await router.startCapturing("ReadSingleBarcode");
|
|
|
590
541
|
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:
|
|
591
542
|
|
|
592
543
|
```javascript
|
|
593
|
-
let settings = await
|
|
544
|
+
let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
|
|
594
545
|
settings.roiMeasuredInPercentage = true;
|
|
595
546
|
settings.roi.points = [
|
|
596
547
|
{ x: 25, y: 25 },
|
|
@@ -598,8 +549,8 @@ settings.roi.points = [
|
|
|
598
549
|
{ x: 75, y: 75 },
|
|
599
550
|
{ x: 25, y: 75 },
|
|
600
551
|
];
|
|
601
|
-
await
|
|
602
|
-
await
|
|
552
|
+
await cvRouter.updateSettings("ReadSingleBarcode", settings);
|
|
553
|
+
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
603
554
|
```
|
|
604
555
|
|
|
605
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.
|
|
@@ -627,10 +578,10 @@ You can set the maximum time allowed for processing a single image with the prop
|
|
|
627
578
|
> 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`.
|
|
628
579
|
|
|
629
580
|
```javascript
|
|
630
|
-
let settings = await
|
|
581
|
+
let settings = await cvRouter.getSimplifiedSettings("ReadSingleBarcode");
|
|
631
582
|
settings.timeout = 500;
|
|
632
|
-
await
|
|
633
|
-
await
|
|
583
|
+
await cvRouter.updateSettings("ReadSingleBarcode", settings);
|
|
584
|
+
await cvRouter.startCapturing("ReadSingleBarcode");
|
|
634
585
|
```
|
|
635
586
|
-->
|
|
636
587
|
|
|
@@ -643,8 +594,8 @@ The preset templates have a lot more settings that can be customized to best sui
|
|
|
643
594
|
Upon completing the template editing, you can invoke the `initSettings` method and provide it with the template path as an argument.
|
|
644
595
|
|
|
645
596
|
```javascript
|
|
646
|
-
await
|
|
647
|
-
await
|
|
597
|
+
await cvRouter.initSettings("PATH-TO-THE-FILE"); //e.g. "https://your-website/ReadSingleBarcode.json")
|
|
598
|
+
await cvRouter.startCapturing("ReadSingleBarcode"); // Make sure the name matches one of the CaptureVisionTemplates in the json file.
|
|
648
599
|
```
|
|
649
600
|
|
|
650
601
|
#### Filter the results (Important)
|
|
@@ -656,7 +607,7 @@ While processing video frames, it's common for the same barcode to be detected m
|
|
|
656
607
|
```js
|
|
657
608
|
let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
|
|
658
609
|
filter.enableResultCrossVerification("barcode", true);
|
|
659
|
-
await
|
|
610
|
+
await cvRouter.addResultFilter(filter);
|
|
660
611
|
```
|
|
661
612
|
|
|
662
613
|
*Note*:
|
|
@@ -668,7 +619,7 @@ await router.addResultFilter(filter);
|
|
|
668
619
|
```js
|
|
669
620
|
let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
|
|
670
621
|
filter.enableResultDeduplication("barcode", true);
|
|
671
|
-
await
|
|
622
|
+
await cvRouter.addResultFilter(filter);
|
|
672
623
|
```
|
|
673
624
|
|
|
674
625
|
*Note*:
|
|
@@ -684,7 +635,7 @@ Under certain circumstances, this duration can be extended with the method `setD
|
|
|
684
635
|
```js
|
|
685
636
|
let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
|
|
686
637
|
filter.setDuplicateForgetTime(5000); // Extend the duration to 5 seconds.
|
|
687
|
-
await
|
|
638
|
+
await cvRouter.addResultFilter(filter);
|
|
688
639
|
```
|
|
689
640
|
|
|
690
641
|
You can also enable both options at the same time:
|
|
@@ -694,7 +645,7 @@ let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
|
|
|
694
645
|
filter.enableResultCrossVerification("barcode", true);
|
|
695
646
|
filter.enableResultDeduplication("barcode", true);
|
|
696
647
|
filter.setDuplicateForgetTime(5000);
|
|
697
|
-
await
|
|
648
|
+
await cvRouter.addResultFilter(filter);
|
|
698
649
|
```
|
|
699
650
|
|
|
700
651
|
#### Add feedback
|
|
@@ -710,7 +661,7 @@ resultReceiver.onDecodedBarcodesReceived = (result) => {
|
|
|
710
661
|
Dynamsoft.DCE.Feedback.beep();
|
|
711
662
|
}
|
|
712
663
|
};
|
|
713
|
-
|
|
664
|
+
cvRouter.addResultReceiver(resultReceiver);
|
|
714
665
|
```
|
|
715
666
|
|
|
716
667
|
### Customize the UI
|