|
10 | 10 | <link rel="stylesheet" href="../balloon.min.css"> <!-- Used for tooltip styling --> |
11 | 11 | </head> |
12 | 12 |
|
13 | | -<!-- This sample demonstrates the minimum necessary JavaScript code to get the BarcodeScanner (video) up and running. The BarcodeScanner object is initialized with its default UI once the user clicks the 'Read Barcode via Camera' button. Any unique barcode results that are found are then displayed in an alert box to the user. |
14 | | -Please note that the organizationID '200001' corresponds to Dynamsoft's public license which is reserved for public samples. When hosting the sample in your own environment, please obtain a private trial by contacting the Dynamsoft Support Team via support@dynamsoft.com --> |
15 | | - |
16 | 13 | <body> |
17 | | - <button id='readBarcode'>Open Camera and Read Barcode</button> |
18 | | - <p></p> |
| 14 | + <h2>Formats and Count Per Frame</h2> |
19 | 15 | <button id='openSimpleSettingsMenu'>Open Runtime Settings Menu</button> |
20 | 16 |
|
21 | | - <!-- Manually defining the div that will contain the video so that the UI doesn't take up the full screen, hiding the --> |
| 17 | + <input type="text" id="result" title="Double click to clear!" readonly="true" class="latest-result" |
| 18 | + placeholder="The Last Read Barcode"> |
| 19 | + <!-- Manually defining the div that will contain the video so that the UI doesn't take up the full screen--> |
22 | 20 | <div id="div-video-container"> |
| 21 | + <span id='lib-load' style='font-size:x-large' hidden>Loading Library...</span> |
23 | 22 | <video class="dbrScanner-video" playsinline="true"></video> |
| 23 | + <canvas class="dbrScanner-cvs-drawarea" |
| 24 | + style="width: 100%; height: 100%; position: absolute; left: 0px; top: 0px; object-fit: contain;" |
| 25 | + width="1280" height="720"></canvas> |
24 | 26 | </div> |
25 | 27 |
|
26 | 28 | <!-- Settings Menu displayed in a modal --> |
|
30 | 32 | <div class="tooltip" |
31 | 33 | aria-label="If you know that your application will only be dealing with a certain type of |
32 | 34 | barcode format, you can save processing time by specifying which barcode formats the SDK should be looking for." |
33 | | - data-balloon-pos="down" data-balloon-length="medium">Choose Which Barcode Formats to Detect |
| 35 | + data-balloon-pos="down" data-balloon-length="fit">Choose the Formats to Detect |
34 | 36 | </div> |
35 | 37 | <form id="chooseBarcodeFormats"> |
36 | 38 | <input type="checkbox" id="OneD" name="barcodeFormat" value="BF_ONED"> |
37 | | - <label for="OneD"> 1D </label><br> |
| 39 | + <label for="OneD"> 1D </label><br /> |
38 | 40 | <input type="checkbox" id="QR" name="barcodeFormat" value="BF_QR_CODE"> |
39 | | - <label for="QR"> QR Code </label><br> |
| 41 | + <label for="QR"> QR Code </label><br /> |
40 | 42 | <input type="checkbox" id="PDF417" name="barcodeFormat" value="BF_PDF417"> |
41 | | - <label for="PDF417"> PDF 417 </label><br> |
| 43 | + <label for="PDF417"> PDF 417 </label><br /> |
42 | 44 | <input type="checkbox" id="Datamatrix" name="barcodeFormat" value="BF_DATAMATRIX"> |
43 | | - <label for="Datamatrix"> DataMatrix </label> <br> |
44 | | - <input type="checkbox" id="Aztec" name="barcodeFormat" value="BF_AZTEC"> |
45 | | - <label for="Aztec"> Aztec </label> <br> |
46 | | - </form><br> |
47 | | - <form id="chooseExpectedNumber"> |
48 | | - <div class="tooltip" |
49 | | - aria-label="This parameter helps save time and resources when the expected number of barcodes per scan is less than the actual number of barcodes. Should the number of found results be less than this value, the SDK will exhaust more resources and try more algorithms to reach the expected number." |
50 | | - data-balloon-pos="down" data-balloon-length="large"> Please input the expected number of barcodes |
51 | | - per scan |
52 | | - </div> |
53 | | - <input type="text" id="expectedNumberBarcodes" name="expectedNumber"> |
| 45 | + <label for="Datamatrix"> DataMatrix </label> <br /> |
54 | 46 | </form> |
| 47 | + <div class="tooltip" |
| 48 | + aria-label="This parameter helps save time and resources when the expected number of barcodes per scan is less than the actual number of barcodes. Should the number of found results be less than this value, the SDK will exhaust more resources and try more algorithms to reach the expected number." |
| 49 | + data-balloon-pos="down" data-balloon-length="fit"> Expected barcode count per frame |
| 50 | + </div><br /> |
| 51 | + <input type="range" min="1" max="20" step="1" id="expectedNumberBarcodes" value="1"> |
| 52 | + <span id="expectedNumberBarcodesLable">1</span> |
55 | 53 | </div> |
56 | 54 | </div> |
57 | 55 |
|
58 | 56 | <!-- JS Code --> |
59 | 57 | <script src="initScanner.js"></script> <!-- To initialize the barcode scanner --> |
60 | 58 |
|
61 | 59 | <script> |
62 | | - |
63 | | - /* Beginning of barcode formats assignment */ |
64 | | - |
65 | | - /* Should the user select one of the barcode format options, update the runtime settings accordingly and in the correct selection order */ |
66 | | - settingsForm.onchange = async function () { |
| 60 | + /** Beginning of barcode formats assignment |
| 61 | + * Should the user select one of the barcode format options, |
| 62 | + * update the runtime settings accordingly and in the correct selection order |
| 63 | + */ |
| 64 | + chooseBarcodeFormats.onchange = async function () { |
67 | 65 | try { |
68 | | - console.log("shiet"); |
69 | 66 | const checkboxes = document.querySelectorAll('input[name="barcodeFormat"]:checked'); |
70 | 67 | let settings = await scanner.getRuntimeSettings(); |
71 | | - settings.barcodeFormatIds = Dynamsoft.EnumBarcodeFormat.BF_NULL; // Set it to NULL first since the default is BF_ALL |
| 68 | + settings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_NULL; // Set it to NULL first since the default is BF_ALL |
72 | 69 | checkboxes.forEach((checkbox) => { |
73 | | - // go through each of the checked options and perform a compound bitwise OR to include each of the selected formats |
| 70 | + // go through each of the checked options and perform a compound bitwise OR |
| 71 | + // to include each of the selected formats |
74 | 72 | switch (checkbox.value) { |
75 | 73 | case "BF_ONED": |
76 | | - settings.barcodeFormatIds |= Dynamsoft.EnumBarcodeFormat.BF_ONED; |
| 74 | + settings.barcodeFormatIds |= Dynamsoft.DBR.EnumBarcodeFormat.BF_ONED; |
77 | 75 | break; |
78 | 76 | case "BF_QR_CODE": |
79 | | - settings.barcodeFormatIds |= Dynamsoft.EnumBarcodeFormat.BF_QR_CODE; |
| 77 | + settings.barcodeFormatIds |= Dynamsoft.DBR.EnumBarcodeFormat.BF_QR_CODE; |
80 | 78 | break; |
81 | 79 | case "BF_PDF417": |
82 | | - settings.barcodeFormatIds |= Dynamsoft.EnumBarcodeFormat.BF_PDF417; |
| 80 | + settings.barcodeFormatIds |= Dynamsoft.DBR.EnumBarcodeFormat.BF_PDF417; |
83 | 81 | break; |
84 | 82 | case "BF_DATAMATRIX": |
85 | | - settings.barcodeFormatIds |= Dynamsoft.EnumBarcodeFormat.BF_DATAMATRIX; |
86 | | - break; |
87 | | - case "BF_AZTEC": |
88 | | - settings.barcodeFormatIds |= Dynamsoft.EnumBarcodeFormat.BF_AZTEC; |
| 83 | + settings.barcodeFormatIds |= Dynamsoft.DBR.EnumBarcodeFormat.BF_DATAMATRIX; |
89 | 84 | break; |
90 | 85 | } |
91 | 86 | }); |
92 | 87 | await scanner.updateRuntimeSettings(settings); |
93 | 88 | } |
94 | 89 | catch (ex) { |
95 | | - console.log(ex.message); |
96 | | - throw ex; |
| 90 | + alert(ex.message); |
97 | 91 | } |
98 | 92 | } |
99 | 93 |
|
100 | 94 | /* End of barcode formats assignment */ |
101 | 95 |
|
102 | 96 | /* Now for the expected barcodes */ |
103 | | - // Should the user enter the expected number of barcodes to be found per scan, the runtime settings are updated as follows |
104 | | - expectedNumbersForm.onchange = async function () { |
| 97 | + // Should the user enter the expected number of barcodes to be found per scan, |
| 98 | + // the runtime settings are updated as follows |
| 99 | + expectedNumberBarcodes.onchange = async function () { |
105 | 100 | try { |
106 | 101 | let expectedVal = document.getElementById('expectedNumberBarcodes').value; |
| 102 | + document.getElementById('expectedNumberBarcodesLable').innerText = expectedVal; |
107 | 103 | let settings = await scanner.getRuntimeSettings(); |
108 | 104 | settings.expectedBarcodesCount = expectedVal; |
109 | 105 | await scanner.updateRuntimeSettings(settings); |
110 | 106 | } |
111 | 107 | catch (ex) { |
112 | | - console.log(ex.message); |
| 108 | + alert(ex.message); |
113 | 109 | } |
114 | 110 | } |
115 | 111 | </script> |
|
0 commit comments