Skip to content

Commit 1cc595c

Browse files
committed
docs: updated the guide to read better -> better structured
1 parent 75cf141 commit 1cc595c

File tree

1 file changed

+60
-57
lines changed
  • programming/javascript/user-guide

1 file changed

+60
-57
lines changed

programming/javascript/user-guide/index.md

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,35 @@ In this guide, you will learn step by step on how to integrate the DBR-JS SDK in
3535
- [Understand the code](#understand-the-code)
3636
- [About the code](#about-the-code)
3737
- [Run the example](#run-the-example)
38-
- [Building your own page](#building-your-own-page)
39-
- [Include the SDK](#include-the-sdk)
40-
- [Use a public CDN](#use-a-public-cdn)
41-
- [Host the SDK yourself (optional)](#host-the-sdk-yourself-optional)
42-
- [Prepare the SDK](#prepare-the-sdk)
43-
- [Specify the license](#specify-the-license)
44-
- [Specify the location of the "engine" files (optional)](#specify-the-location-of-the-engine-files-optional)
45-
- [Set up and start image processing](#set-up-and-start-image-processing)
46-
- [Preload the module](#preload-the-module)
47-
- [Create a CaptureVisionRouter object](#create-a-capturevisionrouter-object)
48-
- [Connect an image source](#connect-an-image-source)
49-
- [Register a result receiver](#register-a-result-receiver)
50-
- [Start the process](#start-the-process)
51-
- [Customize the process](#customize-the-process)
52-
- [Adjust the preset template settings](#adjust-the-preset-template-settings)
53-
- [Change barcode settings](#change-barcode-settings)
54-
- [Retrieve the original image](#retrieve-the-original-image)
55-
- [Change reading frequency to save power](#change-reading-frequency-to-save-power)
56-
- [Specify a scan region](#specify-a-scan-region)
57-
- [Edit the preset templates directly](#edit-the-preset-templates-directly)
58-
- [Filter the results (Important)](#filter-the-results-important)
59-
- [Option 1: Verify results across multiple frames](#option-1-verify-results-across-multiple-frames)
60-
- [Option 2: Eliminate redundant results detected within a short time frame](#option-2-eliminate-redundant-results-detected-within-a-short-time-frame)
61-
- [Add feedback](#add-feedback)
62-
- [Customize the UI](#customize-the-ui)
63-
- [API Documentation](#api-documentation)
64-
- [How to Upgrade](#how-to-upgrade)
65-
- [Release Notes](#release-notes)
38+
- [Preparing the SDK](#preparing-the-sdk)
39+
- [Step 1: Include the SDK](#step-1-include-the-sdk)
40+
- [Option 1: Use a public CDN](#option-1-use-a-public-cdn)
41+
- [Option 2: Host the SDK yourself (optional)](#option-2-host-the-sdk-yourself-optional)
42+
- [Step 2: Prepare the SDK](#step-2-prepare-the-sdk)
43+
- [1. Specify the license](#1-specify-the-license)
44+
- [2. \[Optiona\] Specify the location of the "engine" files](#2-optiona-specify-the-location-of-the-engine-files)
45+
- [Using the SDK](#using-the-sdk)
46+
- [Step 1: Preload the module](#step-1-preload-the-module)
47+
- [Step 2: Create a CaptureVisionRouter object](#step-2-create-a-capturevisionrouter-object)
48+
- [Step 3: Connect an image source](#step-3-connect-an-image-source)
49+
- [Step 4: Register a result receiver](#step-4-register-a-result-receiver)
50+
- [Step 5: Start process video frames](#step-5-start-process-video-frames)
51+
- [Customizing the process](#customizing-the-process)
52+
- [1. Adjust the preset template settings](#1-adjust-the-preset-template-settings)
53+
- [1.1. Change barcode settings](#11-change-barcode-settings)
54+
- [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)
6667
- [Next Steps](#next-steps)
6768

6869
**Popular Examples**
@@ -211,11 +212,11 @@ Alternatively, you can test locally by copying and pasting the code shown above
211212
>
212213
> 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).
213214
214-
## Building your own page
215+
## Preparing the SDK
215216
216-
### Include the SDK
217+
### Step 1: Include the SDK
217218
218-
#### Use a public CDN
219+
#### Option 1: Use a public CDN
219220
220221
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**.
221222
@@ -249,7 +250,7 @@ The simplest way to include the SDK is to use either the [jsDelivr](https://jsde
249250
250251
NOTE that in frameworks, you need to [specify the engineResourcePaths](#specify-the-location-of-the-engine-files-optional).
251252
252-
#### Host the SDK yourself (optional)
253+
#### Option 2: Host the SDK yourself (optional)
253254
254255
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.
255256
@@ -290,11 +291,11 @@ You can typically include SDK like this:
290291
291292
Reference: [Cache-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control).
292293
293-
### Prepare the SDK
294+
### Step 2: Prepare the SDK
294295
295296
Before using the SDK, you need to configure a few things.
296297
297-
#### Specify the license
298+
#### 1. Specify the license
298299
299300
To enable the SDK's functionality, you must provide a valid license. Utilize the API function initLicense to set your license key.
300301
@@ -306,7 +307,7 @@ As previously stated, the key "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" serves
306307
307308
> 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.
308309
309-
#### Specify the location of the "engine" files (optional)
310+
#### 2. [Optiona] Specify the location of the "engine" files
310311
311312
This is usually only required with frameworks like Angular, React or Vue.
312313
@@ -323,9 +324,9 @@ Dynamsoft.Core.CoreModule.engineResourcePaths.rootDirectory = "https://cdn.jsdel
323324
```
324325
These code uses the jsDelivr CDN as an example, feel free to change it to your own location.
325326
326-
### Set up and start image processing
327+
## Using the SDK
327328
328-
#### Preload the module
329+
### Step 1: Preload the module
329330
330331
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.
331332
@@ -334,7 +335,7 @@ The image processing logic is encapsulated within .wasm library files, and these
334335
await Dynamsoft.Core.CoreModule.loadWasm(["dbr"]);
335336
```
336337
337-
#### Create a CaptureVisionRouter object
338+
### Step 2: Create a CaptureVisionRouter object
338339
339340
To use the SDK, we first create a `CaptureVisionRouter` object.
340341
@@ -368,7 +369,7 @@ document.getElementById('btn-scan').addEventListener('click', async () => {
368369
});
369370
```
370371
371-
#### Connect an image source
372+
### Step 3: Connect an image source
372373
373374
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`.
374375
@@ -385,7 +386,7 @@ document.querySelector("#camera-view-container").append(cameraView.getUIElement(
385386
cvRouter.setInput(cameraEnhancer);
386387
```
387388
388-
#### Register a result receiver
389+
### Step 4: Register a result receiver
389390
390391
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`:
391392
<!--In our particular case, our focus is on identifying barcodes within the images, so it's sufficient to define the callback function `onDecodedBarcodesReceived`:-->
@@ -422,7 +423,7 @@ cvRouter.addResultReceiver({ onCapturedResultReceived: (result) => {
422423
423424
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.
424425
425-
#### Start the process
426+
### Step 5: Start process video frames
426427
427428
With the setup now complete, we can proceed to process the images in two straightforward steps:
428429
@@ -451,13 +452,13 @@ await cvRouter.startCapturing("ReadSingleBarcode");
451452
452453
Read more on the [preset CaptureVisionTemplates](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/preset-templates.html).
453454
454-
### Customize the process
455+
## Customizing the process
455456
456-
#### Adjust the preset template settings
457+
### 1. Adjust the preset template settings
457458
458459
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).
459460
460-
##### Change barcode settings
461+
#### 1.1. Change barcode settings
461462
462463
The preset templates can be updated to meet different requirements. For example, the following code limits the barcode format to QR code.
463464
@@ -471,7 +472,7 @@ await cvRouter.startCapturing("ReadSingleBarcode");
471472
472473
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).
473474
474-
##### Retrieve the original image
475+
#### 1.2. Retrieve the original image
475476
476477
Additionally, we have the option to modify the template to retrieve the original image containing the barcode.
477478
@@ -508,7 +509,7 @@ resultReceiver.onCapturedResultReceived = (result) => {
508509
};
509510
```
510511
511-
##### Change reading frequency to save power
512+
#### 1.3. Change reading frequency to save power
512513
513514
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:
514515
@@ -521,7 +522,7 @@ await cvRouter.updateSettings("ReadSingleBarcode", settings);
521522
await cvRouter.startCapturing("ReadSingleBarcode");
522523
```
523524
524-
##### Specify a scan region
525+
#### 1.4. Specify a scan region
525526
526527
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.
527528
@@ -580,7 +581,7 @@ await cvRouter.startCapturing("ReadSingleBarcode");
580581
```
581582
-->
582583
583-
#### Edit the preset templates directly
584+
### 2. Edit the preset templates directly
584585
585586
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
586587
@@ -593,11 +594,11 @@ await cvRouter.initSettings("PATH-TO-THE-FILE"); // E.g. "https://your-website/R
593594
await cvRouter.startCapturing("ReadSingleBarcode"); // Make sure the name matches one of the CaptureVisionTemplates in the template JSON file.
594595
```
595596
596-
#### Filter the results (Important)
597+
### 3. [Important] Filter the results
597598
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:
599600
600-
##### Option 1: Verify results across multiple frames
601+
#### Method 1: Verify results across multiple frames
601602
602603
```js
603604
let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
@@ -609,7 +610,7 @@ await cvRouter.addResultFilter(filter);
609610
610611
* `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.
611612
612-
##### Option 2: Eliminate redundant results detected within a short time frame
613+
#### Method 2: Eliminate redundant results detected within a short time frame
613614
614615
```js
615616
let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
@@ -643,7 +644,7 @@ filter.setDuplicateForgetTime(5000);
643644
await cvRouter.addResultFilter(filter);
644645
```
645646
646-
#### Add feedback
647+
### 4. Add feedback
647648
648649
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".
649650
@@ -659,7 +660,7 @@ resultReceiver.onDecodedBarcodesReceived = (result) => {
659660
cvRouter.addResultReceiver(resultReceiver);
660661
```
661662
662-
### Customize the UI
663+
## Customizing the UI
663664
664665
```javascript
665666
// Create a CameraView instance with default settings
@@ -681,7 +682,9 @@ uiElement.shadowRoot.querySelector('.dce-sel-resolution').remove();
681682
682683
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).
683684
684-
## API Documentation
685+
## Documentation
686+
687+
### API Reference
685688
686689
You can check out the detailed documentation about the APIs of the SDK at
687690
[https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.4.2002](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/?ver=10.4.2002).
@@ -728,11 +731,11 @@ Apart from the browsers, the operating systems may impose some limitations of th
728731
729732
-->
730733
731-
## How to Upgrade
734+
### How to Upgrade
732735
733736
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).
734737
735-
## Release Notes
738+
### Release Notes
736739
737740
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).
738741

0 commit comments

Comments
 (0)