Skip to content

Commit b7a7634

Browse files
authored
Merge pull request #9 from Dynamsoft/_dev
Dev
2 parents 91010a2 + 495c82e commit b7a7634

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1189
-941
lines changed

1.hello-world/1.minimum-code.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h1 style="font-size: 1.5em;">Read Barcodes from a Camera</h1>
4949
*/
5050
scanner.onUnduplicatedRead = (txt, result) => {
5151
alert(txt);
52-
console.log("Unique Code Found: " + result);
52+
console.log("Unique Code Found: ", result);
5353
}
5454
await scanner.show();
5555
} catch (ex) {

1.hello-world/10.read-video-pwa/helloworld-pwa.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<meta name="keywords" content="read barcode from camera in PWA">
99
<title>Dynamsoft Barcode Reader PWA Sample - Hello World (Decoding via Camera)</title>
1010
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.js"></script>
11-
<link rel="manifest" href="./helloworld-pwa.webmanifest">
11+
<link rel="manifest" href="./helloworld-pwa.json">
1212
</head>
1313

1414
<body>
@@ -38,7 +38,7 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
3838
}
3939
});
4040
try {
41-
let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
41+
const scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
4242
scanner.onFrameRead = results => {
4343
console.log("Barcodes on one frame:");
4444
for (let result of results) {
@@ -47,7 +47,7 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
4747
};
4848
scanner.onUnduplicatedRead = (txt, result) => {
4949
latestResult = txt;
50-
console.log("Unique Code Found: " + result);
50+
alert(txt, result);
5151
}
5252
await scanner.show();
5353
} catch (ex) {

1.hello-world/10.read-video-pwa/helloworld-pwa.webmanifest renamed to 1.hello-world/10.read-video-pwa/helloworld-pwa.json

File renamed without changes.

1.hello-world/10.read-video-pwa/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const cacheName = 'helloworld-pwa';
33
const appShellFiles = [
44
'./helloworld-pwa.html',
55
'./dbr-big.png',
6-
'./helloworld-pwa.webmanifest',
6+
'./helloworld-pwa.json',
77
];
88

99
// Installing Service Worker

1.hello-world/11.read-video-requirejs.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
1414
<script src="https://cdn.jsdelivr.net/npm/requirejs@2.3.6/require.js"></script>
1515
<script>
1616
requirejs(['https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.js'], function({
17-
DBR,
1817
BarcodeReader,
1918
BarcodeScanner
2019
}) {
@@ -36,7 +35,7 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
3635
let pScanner = null;
3736
document.getElementById('readBarcode').onclick = async function() {
3837
try {
39-
let scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
38+
const scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
4039
scanner.onFrameRead = results => {
4140
console.log("Barcodes on one frame:");
4241
for (let result of results) {
@@ -45,7 +44,7 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
4544
};
4645
scanner.onUnduplicatedRead = (txt, result) => {
4746
alert(txt);
48-
console.log("Unique Code Found: " + result);
47+
console.log("Unique Code Found: ", result);
4948
}
5049
await scanner.show();
5150
} catch (ex) {

1.hello-world/12.read-video-webpack/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"author": "Dynamsoft Team",
1010
"devDependencies": {
1111
"webpack": "5.52.1",
12-
"webpack-cli": "4.8.0"
12+
"webpack-cli": "^4.9.2"
1313
},
1414
"dependencies": {
1515
"dynamsoft-javascript-barcode": "8.8.7"
1616
}
17-
}
17+
}

1.hello-world/12.read-video-webpack/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let pScanner = null;
2020
if (document.getElementById('readBarcode')) {
2121
document.getElementById('readBarcode').onclick = async function() {
2222
try {
23-
let scanner = await (pScanner = pScanner || DBR.BarcodeScanner.createInstance());
23+
const scanner = await (pScanner = pScanner || DBR.BarcodeScanner.createInstance());
2424
scanner.onFrameRead = results => {
2525
console.log("Barcodes on one frame:");
2626
for (let result of results) {
@@ -29,7 +29,7 @@ if (document.getElementById('readBarcode')) {
2929
};
3030
scanner.onUnduplicatedRead = (txt, result) => {
3131
alert(txt);
32-
console.log("Unique Code Found: " + result);
32+
console.log("Unique Code Found: ", result);
3333
}
3434
await scanner.show();
3535
} catch (ex) {
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<meta name="description" content="Quickly read barcodes with Dynamsoft Barcode Reader from a live camera stream.">
8+
<meta name="keywords" content="camera based barcode reading">
9+
<title>Dynamsoft Barcode Reader Sample - Hello World (Decoding via Camera)</title>
10+
<!--
11+
This sample makes use of the library hosted by the CDN jsDelivr. If you would rather use the
12+
library offline. Please see the guide on how to host the library:
13+
https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=latest#host-the-library-yourself-recommended
14+
-->
15+
</head>
16+
17+
<body>
18+
<h1 style="font-size: 1.5em;">Read Barcodes from a Camera</h1>
19+
<button id="btn-show-scanner">Show Barcode Scanner</button>
20+
<script type="module">
21+
/** LICENSE ALERT - README
22+
*
23+
* The library requires a license to work.
24+
* If the license is not specified, a free public trial license will be used by default which is the case in this sample.
25+
* Note that network connection is required for the public license to work.
26+
* For more info, please check https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=8.8.7&utm_source=github#specify-the-license or contact support@dynamsoft.com.
27+
*/
28+
29+
/* When using your own license, uncomment the following line and specify your license. */
30+
31+
// Dynamsoft.DBR.BarcodeReader.license = "YOUR-ORGANIZATION-ID or YOUR-HANDSHAKECODE or AN-OFFLINE-LICENSE or ANY-OTHER-TYPE-OF-SUPPORTED-LICENSE-STRING";
32+
33+
/** LICENSE ALERT - THE END */
34+
import { BarcodeRender, BarcodeScanner } from 'https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.mjs';
35+
36+
// DBR.productKeys = "PRODUCT-KEYS";
37+
38+
BarcodeRender.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/";
39+
40+
41+
let pScanner = null;
42+
document.getElementById('btn-show-scanner').addEventListener('click', async () => {
43+
try {
44+
const scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
45+
/*
46+
* onFrameRead is triggered after the library finishes reading a frame.
47+
* There can be one or multiple barcodes on each frame.
48+
*/
49+
scanner.onFrameRead = results => {
50+
console.log("Barcodes on one frame:");
51+
for (let result of results) {
52+
console.log(result.barcodeFormatString + ": " + result.barcodeText);
53+
}
54+
};
55+
/*
56+
* onUnduplicatdRead is triggered only when a 'new' barcode is found.
57+
* The amount of time that the library 'remembers' a barcode is defined by
58+
* "duplicateForgetTime" in "ScanSettings". By default it is set to 3000 ms.
59+
*/
60+
scanner.onUnduplicatedRead = (txt, result) => {
61+
alert(txt);
62+
console.log("Unique Code Found: ", result);
63+
}
64+
await scanner.show();
65+
} catch (ex) {
66+
alert(ex.message);
67+
throw ex;
68+
}
69+
});
70+
</script>
71+
</body>
72+
73+
</html>

1.hello-world/3.read-video-angular/src/app/app.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { BrowserModule } from '@angular/platform-browser';
33

44
import { AppComponent } from './app.component';
55
import { HelloWorldComponent } from './hello-world/hello-world.component';
6-
import { BarcodeScannerComponent } from './barcode-scanner/barcode-scanner.component';
6+
import { VideoDecodeComponent } from './barcode-scanner/barcode-scanner.component';
7+
import { ImgDecodeComponent } from './img-decode/img-decode.component';
78

89
@NgModule({
910
declarations: [
1011
AppComponent,
1112
HelloWorldComponent,
12-
BarcodeScannerComponent
13+
VideoDecodeComponent,
14+
ImgDecodeComponent
1315
],
1416
imports: [
1517
BrowserModule
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.component-barcode-scanner{width:100%;height:100%;min-width:640px;min-height:480px;background:#eee;position:relative;resize:both;}
2+
.dbrScanner-bg-loading{animation:1s linear infinite dbrScanner-rotate;width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
3+
.dbrScanner-bg-camera{width:40%;height:40%;position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;fill:#aaa;}
4+
.dbrScanner-video{width:100%;height:100%;position:absolute;left:0;top:0;}
5+
.dbrScanner-cvs-drawarea{width:100%;height:100%;position:absolute;left:0;top:0;}
6+
.dbrScanner-cvs-scanarea{width:100%;height:100%;position:absolute;left:0;top:0;}
7+
.dbrScanner-scanlight{width:100%;height:3%;position:absolute;animation:3s infinite dbrScanner-scanlight;border-radius:50%;box-shadow:0px 0px 2vw 1px #00e5ff;background:#fff;}
8+
.dbrScanner-sel-camera{margin:0 auto;position:absolute;left:0;top:0;}
9+
.dbrScanner-sel-resolution{position:absolute;left:0;top:20px;}
10+
.dbrScanner-msg-poweredby{position:absolute;left:50%;bottom:10%;transform:translateX(-50%);}
11+
.dbrScanner-msg-poweredby svg {height:max(3vmin,17px);fill:#FFFFFF;}
12+
@keyframes dbrScanner-rotate{from{transform:rotate(0turn);}to{transform:rotate(1turn);}}
13+
@keyframes dbrScanner-scanlight{from{top:0;}to{top:97%;}}

0 commit comments

Comments
 (0)