-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdbrjs10-dialog.html
84 lines (72 loc) · 3.23 KB
/
dbrjs10-dialog.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
84
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- <script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader@10.0.21/dist/dbr.bundle.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-core@3.0.33/dist/core.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-license@3.0.40/dist/license.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-utility@1.0.21/dist/utility.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader@10.0.21/dist/dbr.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-capture-vision-router@2.0.32/dist/cvr.js"></script>
<!-- we use a inner version of camera enhancer -->
<script src="https://cdn.jsdelivr.net/npm/iv-dynamsoft-camera-enhancer@4.0.2-iv-202403151422/dist/dce.js"></script>
<!-- <div id="cameraViewContainer" style="width:100%;height:60vh;position:fixed;left:0;top:20px;display:none;"></div> -->
<button id="btn-scan">scan</button>
<textarea id="results" style="width: 100%; min-height: 10vh; font-size: 3vmin; overflow: auto" disabled></textarea>
<script src="https://cdnjs.cloudflare.com/ajax/libs/eruda/2.4.1/eruda.min.js"></script>
<script class="init-eruda">
eruda.init();
</script>
<script>
Dynamsoft.DCE.CameraEnhancer._onLog = console.log; // add log
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
let router, cameraEnhancer, pRouter;
document.querySelector('#btn-scan').addEventListener('click', async()=>{
await (pRouter = pRouter || (async()=>{
router = await Dynamsoft.CVR.CaptureVisionRouter.createInstance();
let view = await Dynamsoft.DCE.CameraView.createInstance();
cameraEnhancer = await Dynamsoft.DCE.CameraEnhancer.createInstance(view);
// cameraViewContainer.append(view.getUIElement());
let uiElement = view.getUIElement();
Object.assign(uiElement.style, {
width: '100%',
height: '60vh',
position: 'fixed',
left: '0',
top: '40px',
});
document.body.append(uiElement);
router.setInput(cameraEnhancer);
const resultsContainer = document.querySelector("#results");
router.addResultReceiver({ onDecodedBarcodesReceived: (result) => {
if (result.barcodeResultItems.length > 0) {
resultsContainer.textContent = '';
for (let item of result.barcodeResultItems) {
resultsContainer.textContent += `${item.formatString}: ${item.text}\n\n`;
}
router.stopCapturing();
cameraEnhancer.close()
}
}});
let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter();
filter.enableResultCrossVerification(
Dynamsoft.Core.EnumCapturedResultItemType.CRIT_BARCODE, true
);
filter.enableResultDeduplication(
Dynamsoft.Core.EnumCapturedResultItemType.CRIT_BARCODE, true
);
await router.addResultFilter(filter);
})());
await cameraEnhancer.open();
await router.startCapturing("ReadSingleBarcode");
setTimeout(()=>{
if(Dynamsoft.DCE.CameraEnhancer._onLog){
Dynamsoft.DCE.CameraEnhancer._onLog = null; // remove log
}
},1000);
});
</script>
</body>
</html>