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
Copy file name to clipboardExpand all lines: hello-world/README.md
+27-9Lines changed: 27 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,21 +12,39 @@ In this example, you will learn the minimum codes required to initialize and set
12
12
13
13
Let's quickly break down the methods used in order:
14
14
15
-
*`license`: This property specifies a license key.
16
-
*`createInstance()`: This method creates a `BarcodeScanner` object. This object can read barcodes directly from a video input with the help of its interactive UI (hidden by default) and the MediaDevices interface.
17
-
*`onFrameRead`: This event is triggered every time the SDK finishes scanning a video frame. The `results` object contains all the barcode results that the SDK have found on this frame. In this example, we print the results to the browser console.
18
-
*`onUniqueRead`: This event is triggered when the SDK finds a new barcode, which is unique among multiple frames. `txt` holds the barcode text value while `result` is an object that holds details of the barcode. In this example, an alert will be displayed on unique reads.
19
-
*`show()`: This method brings up the built-in UI of the `BarcodeScanner` object and starts scanning
20
-
21
-
Actually, it is not necessary to define both onFrameRead and onUniqueRead in the code. onUniqueRead is more commonly used because it is triggered only when a new barcode is detected, rather than on every frame.
15
+
-`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.
16
+
17
+
-`Dynamsoft.CVR.CaptureVisionRouter.createInstance()`: This method creates a `CaptureVisionRouter` object `router` which controls the entire process in three steps:
18
+
-**Retrieve Images from the Image Source**
19
+
-`router` connects to the image source through the [`Image Source Adapter`](https://www.dynamsoft.com/capture-vision/docs/core/architecture/input.html#image-source-adapter?lang=js) interface with the method `setInput()`.
20
+
```js
21
+
router.setInput(cameraEnhancer);
22
+
```
23
+
> The image source in our case is a CameraEnhancer object created with`Dynamsoft.DCE.CameraEnhancer.createInstance(view)`
24
+
-**Coordinate Image-Processing Tasks**
25
+
- The coordination happens behind the scenes. `router` starts the process by specifying a preset template "ReadSingleBarcode"with the method `startCapturing()`.
26
+
```js
27
+
router.startCapturing("ReadSingleBarcode");
28
+
```
29
+
-**Dispatch Results to Listening Objects**
30
+
- 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 `resultReceiver` is registered to `router` via the method `addResultReceiver()`.
31
+
```js
32
+
router.addResultReceiver(resultReceiver);
33
+
```
34
+
- Also note that reading from video is extremely fast and there could be many duplicate results. We can use a `MultiFrameResultCrossFilter` object with result deduplication enabled to filter out the duplicate results. The object is registered to `router` via the method `addResultFilter()`.
35
+
```js
36
+
router.addResultFilter(filter);
37
+
```
38
+
39
+
> Read more on [Capture Vision Router](https://www.dynamsoft.com/capture-vision/docs/core/architecture/#capture-vision-router).
22
40
23
41
## Hello World - Read Barcodes from an Image
24
42
25
-
The second sample in this set focuses on the secondary class `BarcodeReader` which is a low-level barcode reader that processes static images and returns barcode results.
43
+
The second sample processes static images and returns barcode results.
26
44
27
45
In this sample, an event listener is set up so that the SDK decodes any images that the user uploads.
28
46
29
-
When working with the BarcodeReader class, the main method to use is [`decode`](https://www.dynamsoft.com/barcode-reader/programming/javascript/api-reference/BarcodeReader.html?ver=latest#decode), although the class provides several other methods if you need to work with base64 strings or other formats. You can find the rest of the image decoding methods [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/api-reference/BarcodeReader.html?ver=latest#decode-barcodes).
47
+
When working with the CaptureVisionRouterclassfor single image processing, the main method to use is [`capture`](https://officecn.dynamsoft.com:808/capture-vision/docs/web/programming/javascript/api-reference/capture-vision-router/single-file-processing.html?product=dbr&repoType=web#capture), You can find more details about this method at the link above.
0 commit comments