Compare commits

..

10 Commits

Author SHA1 Message Date
Joe Tretter
d0d3209dcf added two times segment size test file 2022-09-07 16:08:58 -05:00
Joe Tretter
8f65a33ac8 delete invalid chunks in video decoder 2022-09-06 11:19:20 -05:00
Joe Tretter
f8de654574 creation of chunks directory if it doesn't exist and rename the webcam receiver to have a clearar name 2022-09-06 11:12:10 -05:00
Joe Tretter
d65d1800c9 adding video decoder 2022-09-06 11:05:20 -05:00
Joe Tretter
95e7968516 Beautify 2022-09-05 11:24:51 -05:00
Joe Tretter
c904b5ffef rename the receiver... 2022-09-05 10:54:49 -05:00
Joe Tretter
4b4c3fcbd5 Introduce delay before displaying QR code... 2022-09-05 10:53:10 -05:00
Joe Tretter
a4ec1720f0 Merge branch 'main' of ssh://kawomi.com/var/local/git/qrtransfer 2022-09-05 10:36:43 -05:00
Joe Tretter
80d4171cc4 Fix counting of the segments to be easier
Add test for exact test file
2022-09-05 10:36:27 -05:00
Joe Tretter
9dd6b0a838 chang the chunk combiner to start counting at 1 as of recent UI change. 2022-09-05 10:22:46 -05:00
7 changed files with 62 additions and 45 deletions

View File

@@ -2,42 +2,46 @@
<html> <html>
<head> <head>
<title>QRTransfer</title> <title>QRTransfer</title>
<style>
input {
position: absolute;
left: 150px;
}
</style>
<script src="qrenc-4.0.0.js" type="text/javascript"></script> <script src="qrenc-4.0.0.js" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
let $ = (ele) => document.getElementById(ele); let fileDataB64,
let fileData,
chunkSize, chunkSize,
segmentPosition, dataPosition,
timoutHandle,
activeCanvas = 0; // double buffering. activeCanvas = 0; // double buffering.
let serveCodes = () => { const $ = (ele) => document.getElementById(ele);
let numChunks = fileData.length / chunkSize; const serveCodes = () => {
let currChunk = segmentPosition / chunkSize; let numChunks = Math.ceil(fileDataB64.length / chunkSize);
let currChunk = Math.ceil(dataPosition / chunkSize) + 1;
let delay = Number($("delay").value); let delay = Number($("delay").value);
let minLeft = ((numChunks - currChunk) * delay) / 1000 / 60; let minLeft = ((numChunks - currChunk) * delay) / 1000 / 60;
$("status").innerText = `${currChunk}/${Math.ceil(numChunks)}/${(currChunk / numChunks).toFixed(2)}% (${minLeft.toFixed(2)} minutes left.)`; $("status").innerText = `${currChunk}/${numChunks}/${((currChunk / numChunks) * 100).toFixed(2)}% (${minLeft.toFixed(2)} min left.)`;
displayQR( displayQR(currChunk + "|" + fileDataB64.substring(dataPosition, dataPosition + chunkSize), Number($("qrSize").value), Number($("ecc").value));
currChunk + 1 + "|" + fileData.substring(segmentPosition, segmentPosition + chunkSize), dataPosition += chunkSize;
Number($("qrSize").value),
Number($("ecc").value)
);
segmentPosition += chunkSize;
if (segmentPosition < fileData.length) { if (dataPosition < fileDataB64.length) {
window.setTimeout(serveCodes, delay); timoutHandle = window.setTimeout(serveCodes, delay);
} }
}; };
let displayQR = (data, size, ecc) => { const displayQR = (data, size, ecc) => {
window.scrollTo(0, 0);
var qr = new QR($("qrcanv" + activeCanvas), data, size, size, ecc); var qr = new QR($("qrcanv" + activeCanvas), data, size, size, ecc);
$("qrcanv" + (activeCanvas === 0 ? 1 : 0)).style.display = "none"; $("qrcanv" + (activeCanvas === 0 ? 1 : 0)).style.display = "none";
$("qrcanv" + activeCanvas).style.display = "block"; $("qrcanv" + activeCanvas).style.display = "block";
activeCanvas = activeCanvas === 0 ? 1 : 0; activeCanvas = activeCanvas === 0 ? 1 : 0;
}; };
let getFile = (fileName) => { const startAction = (fileName) => {
chunkSize = Number($("chunkSize").value); chunkSize = Number($("chunkSize").value);
segmentPosition = Number($("startChunk").value * chunkSize); dataPosition = Number($("startChunk").value * chunkSize);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("GET", fileName, true); xhr.open("GET", fileName, true);
@@ -45,13 +49,14 @@
xhr.onload = (e) => { xhr.onload = (e) => {
tgt = e.currentTarget; tgt = e.currentTarget;
if (tgt.status == 200) { if (tgt.status == 200) {
let uInt8Array = new Uint8Array(tgt.response); let allCharCodes = new Uint8Array(tgt.response);
let binaryString = new Array(uInt8Array.length); let allChars = new Array(allCharCodes.length);
uInt8Array.map((x, idx) => (binaryString[idx] = String.fromCharCode(x))); allCharCodes.map((x, idx) => (allChars[idx] = String.fromCharCode(x)));
// it seems that the qr library doesn't support binary data - converting to base64 // it seems that the qr library doesn't support binary data - converting to base64
fileData = window.btoa(binaryString.join("")); fileDataB64 = window.btoa(allChars.join(""));
window.scrollTo(0, 0);
serveCodes(); timoutHandle && window.clearTimeout(timoutHandle);
timoutHandle = window.setTimeout(serveCodes, 3000);
} }
}; };
xhr.send(); xhr.send();
@@ -59,25 +64,15 @@
</script> </script>
</head> </head>
<body> <body>
<center> <center><canvas id="qrcanv0"></canvas><canvas id="qrcanv1"></canvas></center>
<canvas id="qrcanv0"></canvas>
<canvas id="qrcanv1"></canvas>
</center>
<hr /> <hr />
Status:<span id="status">...</span> Status:<span id="status">...</span> <button onclick="startAction($('inputFileName').value)">Start(3 sec delay)</button>
<hr /> <hr />
Filename:<input type="text" id="inputFileName" value="testInput/5K.dat" /> Filename:<input type="text" id="inputFileName" value="testInput/5K.dat" /> <br />
<br /> ECC (1-4):<input type="number" value="4" id="ecc" /> <br />
ECC (1-4):<input type="number" value="4" id="ecc" /> Qr-Size:<input type="number" value="800" id="qrSize" /> <br />
<br /> Chunk-Size<input type="number" value="1200" id="chunkSize" /> <br />
Qr-Size:<input type="number" value="800" id="qrSize" /> Start-Chunk:<input type="number" value="0" id="startChunk" /> <br />
<br />
Chunk-Size<input type="number" value="1200" id="chunkSize" />
<br />
Start-Chunk:<input type="number" value="0" id="startChunk" />
<br />
Delay:<input type="number" value="1500" id="delay" /> Delay:<input type="number" value="1500" id="delay" />
<br />
<button onclick="getFile($('inputFileName').value)">Read</button>
</body> </body>
</html> </html>

View File

@@ -0,0 +1 @@
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

View File

@@ -0,0 +1 @@
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

View File

@@ -1,15 +1,17 @@
#!/bin/bash #!/bin/bash
rm output.dat rm output.dat
currFN=0 currFN=1
chunkNum=$(ls chunks/*.chunk | wc -l)
echo "processing chunks " echo "processing chunks "
while /bin/true; do while [ $currFN -le $chunkNum ] ; do
if [ ! -f chunks/${currFN}.chunk ] ; then if [ ! -f chunks/${currFN}.chunk ] ; then
echo chunk $currFN is missing! echo chunk $currFN is missing!
exit 1 exit 1
else else
echo -n $currFN/ echo -n [$currFN/$chunkNum]
fi fi
cat chunks/${currFN}.chunk >> output.dat cat chunks/${currFN}.chunk >> output.dat
let currFN=$currFN+1 let currFN=$currFN+1
done done
echo DONE.

17
Decoder/extractVideo.sh Executable file
View File

@@ -0,0 +1,17 @@
#/bin/bash
mkdir -p chunks
echo extracting frames
ffmpeg -loglevel 24 -stats -i input.mp4 /tmp/$$.out%05d.png
echo done, processing frames
ls /tmp/$$.out*.png | while read f;do
dta=$(zbarimg -q --raw --nodbus ${f})
chunkNum=${dta/|*/}
chunkData=${dta/*|/}
echo from ${f} received: ${chunkNum}
echo $chunkData | base64 -d > chunks/${chunkNum}.chunk
if [ $? -ne 0 ]; then
echo at ${f} - file decode failed, deleting chunk
rm chunks/${chunkNum}.chunk
fi
done

BIN
Decoder/input.mp4 Normal file

Binary file not shown.

View File

@@ -1,4 +1,5 @@
#/bin/bash #/bin/bash
mkdir -p chunks
while /bin/true;do while /bin/true;do
fswebcam -q -r 800x800 a.png fswebcam -q -r 800x800 a.png
#dta=$(fswebcam -q -r 1280x720 - | zbarimg -q --raw --nodbus -) #dta=$(fswebcam -q -r 1280x720 - | zbarimg -q --raw --nodbus -)