Skip to content

Commit be1ef9d

Browse files
committed
update comments; add a new sample '6.dense-barcodes.html';
1 parent e90e116 commit be1ef9d

File tree

6 files changed

+114
-10
lines changed

6 files changed

+114
-10
lines changed

1.hello-world/1.hello-world.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
try {
3232
const scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
3333
/**
34-
* onFrameRead is triggered after the library finishes reading a frame image.
34+
* 'onFrameRead' is triggered after the library finishes reading a frame image.
3535
* There can be multiple barcodes on one image.
3636
*/
3737
scanner.onFrameRead = results => {
@@ -42,18 +42,18 @@
4242
}
4343
};
4444
/**
45-
* onUniqueRead is triggered only when a 'new' barcode is found.
45+
* 'onUniqueRead' is triggered only when a 'new' barcode is found.
4646
* The amount of time that the library 'remembers' a barcode is defined by
4747
* "duplicateForgetTime" in "ScanSettings". By default it is set to 3000 ms.
4848
*/
4949
scanner.onUniqueRead = (txt, result) => {
50-
alert(txt);
51-
console.log("Unique Code Found: ", result);
52-
}
53-
/**
54-
* show() opens the camera and shows the video stream on the page.
55-
* After that, the library starts to scan the frame images continuously.
56-
*/
50+
alert(txt);
51+
console.log("Unique Code Found: ", result);
52+
}
53+
/**
54+
* 'show()' opens the camera and shows the video stream on the page.
55+
* After that, the library starts to scan the frame images continuously.
56+
*/
5757
await scanner.show();
5858
} catch (ex) {
5959
let errMsg;

1.hello-world/12.read-video-es6.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h1 style="font-size: 1.5em;">Hello World for ES6</h1>
3434
try {
3535
const scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
3636
/*
37-
* onFrameRead is triggered after the library finishes reading a frame.
37+
* 'onFrameRead' is triggered after the library finishes reading a frame.
3838
* There can be one or multiple barcodes on each frame.
3939
*/
4040
scanner.onFrameRead = results => {

3.settings/6.dense-barcodes.html

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<meta
7+
name="description"
8+
content="Read barcodes from camera with Dynamsoft Barcode Reader and update settings for dense codes."
9+
/>
10+
<meta name="keywords" content="read barcode from camera, dense" />
11+
<link
12+
rel="canonical"
13+
href="https://demo.dynamsoft.com/Samples/DBR/JS/3.settings/6.dense-barcodes.html"
14+
/>
15+
<title>Dynamsoft Barcode Reader Sample - Dense Barcodes</title>
16+
<!--
17+
This sample makes use of the library hosted by the CDN jsDelivr. If you would rather use the
18+
library offline. Please see the guide on how to host the library:
19+
https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=latest#host-the-library-yourself-recommended
20+
-->
21+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.2.13/dist/dbr.js"></script>
22+
</head>
23+
<body>
24+
<div id="div-ui-container" style="width: 100%; height: 70vh"></div>
25+
<textarea
26+
id="textarea-results"
27+
style="width: 100%; height: 20vh;margin-top: 20px;"
28+
></textarea>
29+
<script>
30+
/** LICENSE ALERT - README
31+
* To use the library, you need to first specify a license key using the API "license" as shown below.
32+
*/
33+
34+
Dynamsoft.DBR.BarcodeReader.license =
35+
"DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9";
36+
37+
/**
38+
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=github&product=dbr&package=js to get your own trial license good for 30 days.
39+
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
40+
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.2.13&utm_source=github#specify-the-license or contact support@dynamsoft.com.
41+
* LICENSE ALERT - THE END
42+
*/
43+
44+
const textareaResults = document.querySelector("#textarea-results");
45+
46+
let scanner;
47+
48+
(async () => {
49+
try {
50+
scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
51+
52+
// Get ui by 'getUIElement()' and append it to DOM.
53+
document
54+
.querySelector("#div-ui-container")
55+
.append(scanner.getUIElement());
56+
57+
/**
58+
* 'onFrameRead' is triggered after the library finishes reading a frame image.
59+
* There can be multiple barcodes on one image.
60+
*/
61+
scanner.onFrameRead = (results) => {
62+
textareaResults.value = "";
63+
for (let result of results) {
64+
const format = result.barcodeFormat
65+
? result.barcodeFormatString
66+
: result.barcodeFormatString_2;
67+
const text = result.barcodeText;
68+
textareaResults.value += `${format}: ${text}\n`;
69+
}
70+
};
71+
72+
// Use template 'dense' for decoing dense barcodes and set high resolution.
73+
await scanner.updateRuntimeSettings("dense");
74+
await scanner.setResolution(3840, 2160);
75+
76+
/**
77+
* 'open()' opens the camera.
78+
* After that, the library starts to scan the frame images continuously.
79+
*/
80+
await scanner.open();
81+
} catch (ex) {
82+
let errMsg;
83+
if (ex.message.includes("network connection error")) {
84+
errMsg =
85+
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
86+
} else {
87+
errMsg = ex.message || ex;
88+
}
89+
console.error(errMsg);
90+
alert(errMsg);
91+
}
92+
})();
93+
</script>
94+
</body>
95+
</html>

3.settings/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ To learn more about `Region` and how to use them, please refer to this [article]
6363

6464
Region detection can also be used to pre-detect the region of interest of a large image to get several areas where the barcodes may exist to reduce processing time. The different modes of [RegionPredetectionModes](https://www.dynamsoft.com/barcode-reader/programming/javascript/api-reference/interface/FurtherModes.html?ver=latest#regionpredetectionmodes) correspond to different scenarios, some of which are clarified [here](https://www.dynamsoft.com/barcode-reader/parameters/scenario-settings/how-to-use-region-predetection.html).
6565

66+
## Dealing with Dense Barcodes
67+
68+
69+
6670
## Support
6771

6872
If you have any questions, feel free to contact Dynamsoft support via [email](mailto:support@dynamsoft.com) or [live chat](https://www.dynamsoft.com/barcode-reader/overview/) via the "Let's Chat" button.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ How to configure different settings of the barcode scanning library.
5050
* [**Blurry or Small codes**](https://demo.dynamsoft.com/samples/dbr/js/3.settings/3.blurred-small-barcodes.html?utm_source=sampleReadme): Set `DeblurModes` and `ScaleUpModes` for decoding blurry or small barcodes.
5151
* [**Deformed or Incomplete codes**](https://demo.dynamsoft.com/samples/dbr/js/3.settings/4.deformed-incomplete-barcodes.html?utm_source=sampleReadme): Set `DeformationResistingModes` or `BarcodeComplementModes` for decoding deformed or incomplete barcodes.
5252
* [**Define or Detect the Region**](https://demo.dynamsoft.com/samples/dbr/js/3.settings/5.regionOfInterest-regionPredetection.html?utm_source=sampleReadme): Set the region of interest manually or `regionPredetectionModes` to speed up the barcode reading process.
53+
* [**Dense codes**](https://demo.dynamsoft.com/samples/dbr/js/3.settings/6.dense-barcodes.html?utm_source=sampleReadme): Set `dense` template for decoding dense barcodes.
5354

5455
### Use Cases
5556

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ <h3>Barcode Reader Samples</h3>
188188
Region</a><span id="icon035" class="tooltipIcon"></span>
189189
<a class="github" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/main/3.settings/5.regionOfInterest-regionPredetection.html" title="Check code on GitHub"></a>
190190
</div>
191+
<div class="file"><a data-balloon-length="fit" data-balloon-pos="down" aria-label="Set 'dense' template for decoding dense barcodes." class="button title" href="3.settings/6.dense-barcodes.html">
192+
Dense Codes</a><span id="icon035" class="tooltipIcon"></span>
193+
<a class="github" href="https://github.com/Dynamsoft/barcode-reader-javascript-samples/blob/main/3.settings/6.dense-barcodes.html" title="Check code on GitHub"></a>
194+
</div>
191195
</div>
192196
<div class="file">Use Case</div>
193197
<div class="children">

0 commit comments

Comments
 (0)