-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdbr_then_ddn.html
83 lines (69 loc) · 3.84 KB
/
dbr_then_ddn.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="description" content="Quickly read barcodes with Dynamsoft Barcode Reader from a live camera stream.">
<meta name="keywords" content="camera based barcode reading">
<link rel="canonical" href="https://demo.dynamsoft.com/Samples/DBR/JS/1.hello-world/1.hello-world.html">
<title>Dynamsoft Barcode Reader Sample - Hello World (Decoding via Camera)</title>
</head>
<body>
Loading...
<div id="div-ui-container" style="margin-top: 10px;height: 70vh;"></div>
<div id="normalized-result"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/eruda/2.4.1/eruda.min.js"></script>
<script>
eruda.init();
</script>
<script src="https://npm.scannerproxy.com/cdn/@scannerproxy/ddnjs@0.20230817135300.0/dist/ddn.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.6.20/dist/dbr.js"></script>
<script>
/* Thanks for Code from Ethan */
/** LICENSE ALERT - README
* To use the library, you need to first specify a license key using the API "license" as shown below.
*/
Dynamsoft.DDN.DocumentNormalizer.license = "";
Dynamsoft.DBR.BarcodeReader.license = '';
/**
* 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.
* 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.
* For more information, see https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/?ver=9.6.20&utm_source=github#specify-the-license or contact support@dynamsoft.com.
* LICENSE ALERT - THE END
*/
(async function () {
normalizer = await Dynamsoft.DDN.DocumentNormalizer.createInstance();
let error = await normalizer.setRuntimeSettings('{"ImageParameterArray":[{"Name":"DN_1","MaxThreadCount":4,"BinarizationModes":[{"Mode":"BM_LOCAL_BLOCK","ThresholdCompensation":5,"BlockSizeX":3,"BlockSizeY":3,"MorphOperation":"Close","MorphOperationKernelSizeX":9,"MorphOperationKernelSizeY":9,"EnableFillBinaryVacancy":0}],"ScaleDownThreshold":800,"NormalizerParameterName":"NormalizerParameter"}],"NormalizerParameterArray":[{"ColourMode":"ICM_COLOUR","ContentType":"CT_DOCUMENT","Name":"NormalizerParameter"}]}');
console.log(error);
const scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
scanner.maxCvsSideLength = 4096;
normalizer.maxCvsSideLength = 4096;
scanner.setResolution(4032, 3024);
scanner.onFrameRead = async results => {
console.log("Barcodes on one frame:");
for (let res of results) {
console.log("Unique Code Found: ", res);
image = scanner.getOriginalImageInACanvas();
// console.log(image);
let quads = await normalizer.detectQuad(image);
for(let quad of quads){
let normalizedImageResult = await normalizer.normalize(image, {
quad: quad.location
});
let resultImg = await normalizedImageResult.image.toCanvas();
console.log(`resultImg ${resultImg.width}x${resultImg.height}`);
document.getElementById("normalized-result").appendChild(resultImg);
scanner.hide()
}
}
};
/**
* 'show()' opens the camera and shows the video stream on the page.
* After that, the library starts to scan the frame images continuously.
*/
scanner.ifSaveOriginalImageInACanvas = true;
await scanner.show();
})();
</script>
</body>
</html>