Initial commit with all important and non-generated files.

This commit is contained in:
Matt McWilliams 2024-01-01 18:58:00 -05:00
commit ec82c36ca3
10 changed files with 10306 additions and 0 deletions

15
encode.py Normal file
View File

@ -0,0 +1,15 @@
import cv2
file_path = "test2.bin"
img = cv2.imread('grayscale_gradient_half.png', cv2.IMREAD_GRAYSCALE)
height, width = img.shape
vals = []
for i in range(height):
for j in range(width):
k = img[i, j]
vals.append(k)
with open(file_path, "wb") as file:
file.write(bytes(vals))

6
generate.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
FILE="${1}"
OUTPUT="${2}"
cat ${FILE} | qrencode -s 10 -8 -o "${OUTPUT}"

BIN
grayscale_gradient.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

BIN
grayscale_gradient_half.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

10100
js/jsQR.js Normal file

File diff suppressed because it is too large Load Diff

68
package-lock.json generated Normal file
View File

@ -0,0 +1,68 @@
{
"name": "content",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "content",
"version": "1.0.0",
"license": "ISC",
"devDependencies": {
"@types/node": "^20.10.6",
"typescript": "^5.3.3"
}
},
"node_modules/@types/node": {
"version": "20.10.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz",
"integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/typescript": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
}
},
"dependencies": {
"@types/node": {
"version": "20.10.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz",
"integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==",
"dev": true,
"requires": {
"undici-types": "~5.26.4"
}
},
"typescript": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
"dev": true
},
"undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
}
}
}

16
package.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "content",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"compile" : "./node_modules/.bin/tsc -p tsconfig.browser.json",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^20.10.6",
"typescript": "^5.3.3"
}
}

15
src/content.ts Normal file
View File

@ -0,0 +1,15 @@
class Content {
private width : number = 20;
private height : number = 15;
private displayCanvas : HTMLCanvasElement;
private videoCanvas : HTMLCanvasElement;
constructor () {
this.displayCanvas = document.getElementById('display') as HTMLCanvasElement;
}
}
(function main () {
new Content();
})();

65
test.html Normal file
View File

@ -0,0 +1,65 @@
<html>
<head>
<title>QRtest</title>
</head>
<body>
<img src="test4.png" id="test">
<div id="ms"></div>
<div id="data"></div>
<canvas id="canvas" width="19" height="14"></canvas>
<div id="ms2"></div>
</body>
<script src="js/jsQR.js"></script>
<script>
let ctx;
function main () {
const img = document.querySelector('#test');
let canvas = document.createElement('canvas');
ctx = canvas.getContext('2d');
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0);
const rgba = ctx.getImageData(
0, 0, img.width, img.height
).data;
let start = +new Date();
const code = jsQR(rgba, img.width, img.height);
let ms = (+new Date()) - start;
document.querySelector('#ms').innerText = (ms + 'ms');
if (code) {
document.querySelector('#data').innerText = code.binaryData.toString();
console.log(code);
}
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
start = +new Date();
display(code.binaryData);
ms = (+new Date()) - start;
document.querySelector('#ms2').innerText = (ms + 'ms');
}
function display (data) {
const w = 19;
const h = 14;
let x = 0;
let y = 0;
let val;
for (let i = 0; i < data.length; i++) {
val = data[i];
x = i % w;
y = Math.floor(i / w);
//console.log(`${x},${y} = ${val}`)
ctx.fillStyle = "rgba(" + val + "," + val + "," + val + ",1.0)";
ctx.fillRect(x, y, 1, 1);
}
}
addEventListener('DOMContentLoaded', main);
</script>
</html>

21
tsconfig.browser.json Normal file
View File

@ -0,0 +1,21 @@
{
"compilerOptions": {
"lib": ["es5", "es2015.promise", "dom", "es2015"],
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"rootDir": "src",
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"declaration": false,
"sourceMap": true
},
"exclude": [
"node_modules",
"js"
]
}