You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[1.2. Retrieve the original image](#12-retrieve-the-original-image)
55
+
-[1.3. Change reading frequency to save power](#13-change-reading-frequency-to-save-power)
56
+
-[1.4. Specify a scan region](#14-specify-a-scan-region)
57
+
-[2. Edit the preset templates directly](#2-edit-the-preset-templates-directly)
58
+
-[3. \[Important\] Filter the results](#3-important-filter-the-results)
59
+
-[Method 1: Verify results across multiple frames](#method-1-verify-results-across-multiple-frames)
60
+
-[Method 2: Eliminate redundant results detected within a short time frame](#method-2-eliminate-redundant-results-detected-within-a-short-time-frame)
61
+
-[4. Add feedback](#4-add-feedback)
62
+
-[Customizing the UI](#customizing-the-ui)
63
+
-[Documentation](#documentation)
64
+
-[API Reference](#api-reference)
65
+
-[How to Upgrade](#how-to-upgrade)
66
+
-[Release Notes](#release-notes)
66
67
-[Next Steps](#next-steps)
67
68
68
69
**Popular Examples**
@@ -211,11 +212,11 @@ Alternatively, you can test locally by copying and pasting the code shown above
211
212
>
212
213
> If the test doesn't go as expected, you can [contact us](https://www.dynamsoft.com/company/contact/?ver=10.4.20&utm_source=guide&product=dbr&package=js).
213
214
214
-
## Building your own page
215
+
## Preparing the SDK
215
216
216
-
### Include the SDK
217
+
### Step 1: Include the SDK
217
218
218
-
#### Use a public CDN
219
+
#### Option 1: Use a public CDN
219
220
220
221
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**.
221
222
@@ -249,7 +250,7 @@ The simplest way to include the SDK is to use either the [jsDelivr](https://jsde
249
250
250
251
NOTE that in frameworks, you need to [specify the engineResourcePaths](#specify-the-location-of-the-engine-files-optional).
251
252
252
-
#### Host the SDK yourself (optional)
253
+
#### Option 2: Host the SDK yourself (optional)
253
254
254
255
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.
255
256
@@ -290,11 +291,11 @@ You can typically include SDK like this:
Before using the SDK, you need to configure a few things.
296
297
297
-
#### Specify the license
298
+
#### 1. Specify the license
298
299
299
300
To enable the SDK's functionality, you must provide a valid license. Utilize the APIfunction initLicense to set your license key.
300
301
@@ -306,7 +307,7 @@ As previously stated, the key "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" serves
306
307
307
308
> 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.
308
309
309
-
#### Specify the location of the "engine" files (optional)
310
+
#### 2. [Optiona] Specify the location of the "engine" files
310
311
311
312
This is usually only required with frameworks like Angular, React or Vue.
These code uses the jsDelivr CDN as an example, feel free to change it to your own location.
325
326
326
-
### Set up and start image processing
327
+
## Using the SDK
327
328
328
-
#### Preload the module
329
+
### Step 1: Preload the module
329
330
330
331
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.
331
332
@@ -334,7 +335,7 @@ The image processing logic is encapsulated within .wasm library files, and these
334
335
awaitDynamsoft.Core.CoreModule.loadWasm(["dbr"]);
335
336
```
336
337
337
-
#### Create a CaptureVisionRouter object
338
+
### Step 2: Create a CaptureVisionRouter object
338
339
339
340
To use the SDK, we first create a `CaptureVisionRouter` object.
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`.
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 `onCapturedResultReceived`:
391
392
<!--In our particular case, our focus is on identifying barcodes within the images, so it's sufficient to define the callback function `onDecodedBarcodesReceived`:-->
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.
424
425
425
-
#### Start the process
426
+
### Step 5: Start process video frames
426
427
427
428
With the setup now complete, we can proceed to process the images in two straightforward steps:
Read more on the [preset CaptureVisionTemplates](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/preset-templates.html).
453
454
454
-
### Customize the process
455
+
## Customizing the process
455
456
456
-
#### Adjust the preset template settings
457
+
### 1. Adjust the preset template settings
457
458
458
459
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).
459
460
460
-
##### Change barcode settings
461
+
#### 1.1. Change barcode settings
461
462
462
463
The preset templates can be updated to meet different requirements. For example, the following code limits the barcode format to QR code.
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).
473
474
474
-
##### Retrieve the original image
475
+
#### 1.2. Retrieve the original image
475
476
476
477
Additionally, we have the option to modify the template to retrieve the original image containing the barcode.
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:
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.
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
586
587
@@ -593,11 +594,11 @@ await cvRouter.initSettings("PATH-TO-THE-FILE"); // E.g. "https://your-website/R
593
594
awaitcvRouter.startCapturing("ReadSingleBarcode"); // Make sure the name matches one of the CaptureVisionTemplates in the template JSON file.
594
595
```
595
596
596
-
#### Filter the results (Important)
597
+
### 3. [Important] Filter the results
597
598
598
-
While processing video frames, it's common for the same barcode to be detected multiple times. To enhance the user experience, we can use [MultiFrameResultCrossFilter](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/utility/multi-frame-result-cross-filter.html) object, having two options currently at our disposal:
599
+
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:
599
600
600
-
##### Option 1: Verify results across multiple frames
601
+
#### Method 1: Verify results across multiple frames
601
602
602
603
```js
603
604
let filter =newDynamsoft.Utility.MultiFrameResultCrossFilter();
* `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.
611
612
612
-
##### Option 2: Eliminate redundant results detected within a short time frame
613
+
#### Method 2: Eliminate redundant results detected within a short time frame
613
614
614
615
```js
615
616
let filter =newDynamsoft.Utility.MultiFrameResultCrossFilter();
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".
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).
683
684
684
-
## API Documentation
685
+
## Documentation
686
+
687
+
### API Reference
685
688
686
689
You can check out the detailed documentation about the APIs of the SDK at
@@ -728,11 +731,11 @@ Apart from the browsers, the operating systems may impose some limitations of th
728
731
729
732
-->
730
733
731
-
## How to Upgrade
734
+
### How to Upgrade
732
735
733
736
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.2002&utm_source=guide).
734
737
735
-
## Release Notes
738
+
### Release Notes
736
739
737
740
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=guide).
0 commit comments