Skip to content

Commit a39b0bf

Browse files
committed
Regain complete debug capabilities.
1 parent 6e6a872 commit a39b0bf

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

5.others/debug/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Quick debug
2+
3+
https://dynamsoft.github.io/barcode-reader-javascript-samples/5.others/debug/public/index.html
4+
15
# Collect runtime images for debugging
26

37
When you encounter unreadable barcodes via a video input, you can use this sample to take a few sample frames to share with the Dynamsoft Support Team for debugging purposes.

5.others/debug/public/index.html

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@
1212
<h1 style="font-size: 1.5em;">Read Barcodes from Camera - Debug</h1>
1313
<button id="btn-show-scanner">show scanner</button>
1414
<br>
15-
<div id="div-video-container" style="width:100%;height:calc(100vh - 100px);"></div>
15+
<label><input type="radio" name="video-settings" checked value="default">default</label>
16+
<label><input type="radio" name="video-settings" value="back-camera">back camera</label>
17+
<label><input type="radio" name="video-settings" value="only-video">only video</label>
18+
<br>
19+
<label><input id="cb-send-img" type="checkbox">send image to</label><input id="ipt-server-url" placeholder="server url, default ./collect">
20+
<br>
21+
<div id="div-video-container" style="width:100%;height:calc(100vh - 150px);"></div>
22+
<script src="https://cdnjs.cloudflare.com/ajax/libs/eruda/2.4.1/eruda.min.js"></script>
1623
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.3/dist/dbr.js"></script>
1724
<script>
25+
eruda.init();
26+
Dynamsoft.DBR._onLog = console.log;
1827
/** LICENSE ALERT - README
1928
* The library requires a license to work, you use the API organizationID to tell the program where to fetch your license.
2029
* If the Organizaion ID is not specified, a 7-day (public) trial license will be used by default which is the case in this sample.
@@ -49,11 +58,12 @@ <h1 style="font-size: 1.5em;">Read Barcodes from Camera - Debug</h1>
4958
scanner.ifSaveOriginalImageInACanvas = true;
5059
let processingCount = 0;
5160
scanner.onFrameRead = async results => {
61+
let bSendImg = !!document.getElementById("cb-send-img").checked;
5262
/**
5363
* The barcode reading speed is very fast, we must limit
5464
* the number of uploaded frames (4), so that it is feasible.
5565
*/
56-
if (processingCount < 4) {
66+
if (bSendImg && processingCount < 4) {
5767
++processingCount;
5868
try {
5969
/**
@@ -69,7 +79,7 @@ <h1 style="font-size: 1.5em;">Read Barcodes from Camera - Debug</h1>
6979
cvs.toBlob(blob => resolve(blob));
7080
});
7181
fd.append("img", blob);
72-
await fetch("collect", {
82+
await fetch(document.getElementById("ipt-server-url").value || "collect", {
7383
method: "POST",
7484
body: fd
7585
});
@@ -87,6 +97,24 @@ <h1 style="font-size: 1.5em;">Read Barcodes from Camera - Debug</h1>
8797
throw ex;
8898
}
8999
});
100+
101+
let switchVideoSettings = async()=>{
102+
if(!pScanner)return;
103+
let scanner = await pScanner;
104+
switch(document.querySelector('input[name="video-settings"]:checked').value){
105+
case "back-camera":
106+
await scanner.updateVideoSettings({video:{facingMode:"environment"}});
107+
break;
108+
case "only-video":
109+
await scanner.updateVideoSettings({video:true});
110+
break;
111+
default:
112+
await scanner.updateVideoSettings({video:{width:{ideal:1280},height:{ideal:720},facingMode:{ideal:"environment"}}});
113+
}
114+
};
115+
for(let ipt of document.querySelectorAll('input[name="video-settings"]')){
116+
ipt.addEventListener("change", switchVideoSettings);
117+
}
90118
</script>
91119
</body>
92120

0 commit comments

Comments
 (0)