Got demo working on firefox

This commit is contained in:
Matt McWilliams 2024-12-22 22:13:45 -05:00
parent 5e93a5639b
commit 51573eebd6
6 changed files with 36 additions and 6 deletions

View File

@ -1,7 +1,15 @@
import cv2
from argparse import ArgumentParser
file_path = "test3.bin"
img = cv2.imread('grayscale_gradient.png', cv2.IMREAD_GRAYSCALE)
parser = ArgumentParser()
parser.add_argument('input', help='Input image')
parser.add_argument('output', help='Output bin')
args = parser.parse_args()
file_path = args.output
img = cv2.imread(args.input, cv2.IMREAD_GRAYSCALE)
height, width = img.shape
vals = []

View File

@ -3,6 +3,10 @@
FILE="${1}"
OUTPUT="${2}"
cat ${FILE} | qrencode -s 10 -8 -o "${OUTPUT}"
BIN=$(mktemp)
python encode.py "${FILE}" "${BIN}"
cat "${BIN}" | qrencode -s 10 -8 -o "${OUTPUT}"
rm -f "${BIN}"
#-O3 -flto

View File

@ -11,7 +11,20 @@
document.documentElement.classList.add('js');
</script>
<style>
*,body,html{
margin: 0;
padding: 0;
}
html,body{
background: #000;
max-width: 100vw;
width: 100vw;
overflow-x: hidden;
}
#display,#video{
width: 100vw;
height: auto;
}
</style>
</head>
<body>

View File

@ -38,10 +38,12 @@ var Content = /** @class */ (function () {
function Content() {
this.width = 19;
this.height = 14;
var dpr = window.devicePixelRatio;
this.displayCanvas = document.getElementById('display');
this.displayCtx = this.displayCanvas.getContext('2d');
this.displayCanvas.height = this.height;
this.displayCanvas.width = this.width;
//
this.videoCanvas = document.getElementById('video'); //document.createElement('canvas') as HTMLCanvasElement;
this.videoCtx = this.videoCanvas.getContext('2d');
this.startCamera();

View File

@ -1 +1 @@
{"version":3,"file":"content.js","sourceRoot":"","sources":["content.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;IAiBC;QAhBQ,UAAK,GAAY,EAAE,CAAC;QACpB,WAAM,GAAY,EAAE,CAAC;QAgB5B,IAAI,CAAC,aAAa,GAAI,QAAQ,CAAC,cAAc,CAAC,SAAS,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AAC,GAAG,cAAI,IAAI,CAAC,GAAG,UAAO,CAAC;YAC5E,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;IACF,CAAC;IACF,cAAC;AAAD,CAAC,AApGD,IAoGC;AAED,CAAC,SAAS,IAAI;IACb,IAAI,OAAO,EAAE,CAAC;AACf,CAAC,CAAC,EAAE,CAAC"}

View File

@ -16,12 +16,14 @@ class Content {
private video : HTMLVideoElement;
constructor () {
const dpr : number = window.devicePixelRatio;
this.displayCanvas = document.getElementById('display') as HTMLCanvasElement;
this.displayCtx = this.displayCanvas.getContext('2d');
this.displayCanvas.height = this.height;
this.displayCanvas.width = this.width;
//
this.videoCanvas = document.getElementById('video') as HTMLCanvasElement; //document.createElement('canvas') as HTMLCanvasElement;
this.videoCtx = this.videoCanvas.getContext('2d');
@ -39,6 +41,7 @@ class Content {
}
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
this.video = document.createElement('video') as HTMLVideoElement;
this.video.srcObject = stream;