Skip to content

Commit f9c2d14

Browse files
committed
update
1 parent c3d17e6 commit f9c2d14

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

hello-world/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The second sample processes static images and returns barcode results.
4343

4444
In this sample, an event listener is set up so that the SDK decodes any images that the user uploads.
4545

46-
When working with the CaptureVisionRouter class for 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.
46+
When working with the CaptureVisionRouter class for single image processing, the main method to use is [`capture`](https://dynamsoft.com/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.
4747

4848
## Hello World in Angular
4949

hello-world/read-an-image.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,21 @@ <h1>Hello World (Read an Image)</h1>
4242
// Preload "BarcodeReader" module for reading barcodes. It will save time on the initial decoding by skipping the module loading.
4343
Dynamsoft.Core.CoreModule.loadWasm(["DBR"]);
4444

45+
const input = document.querySelector("input");
4546
const divResultContainer = document.querySelector(
4647
"#div-result-container"
4748
);
48-
49+
4950
const pRouter = Dynamsoft.CVR.CaptureVisionRouter.createInstance();
5051

51-
document.querySelector("input").onchange = async () => {
52-
try{
52+
input.onchange = async () => {
53+
try {
54+
if (!input.files[0]) return;
55+
5356
const router = await pRouter;
5457
// Decode selected image with 'ReadBarcodes_SpeedFirst' template.
5558
const result = await router.capture(
56-
this.files[0],
59+
input.files[0],
5760
"ReadBarcodes_SpeedFirst"
5861
);
5962

@@ -62,7 +65,8 @@ <h1>Hello World (Read an Image)</h1>
6265
divResultContainer.innerText += item.text + "\n";
6366
console.log(item.text);
6467
}
65-
} catch(ex) {
68+
if (!result.items.length) alert('No barcode found');
69+
} catch (ex) {
6670
let errMsg = ex.message || ex;
6771
console.error(errMsg);
6872
alert(errMsg);

0 commit comments

Comments
 (0)