From 51573eebd617cdf4133bfa975d48bd2d5b3bf106 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sun, 22 Dec 2024 22:13:45 -0500 Subject: [PATCH] Got demo working on firefox --- encode.py | 12 ++++++++++-- generate.sh | 6 +++++- index.html | 15 ++++++++++++++- src/content.js | 2 ++ src/content.js.map | 2 +- src/content.ts | 5 ++++- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/encode.py b/encode.py index 0a6e65a..c0d1f88 100644 --- a/encode.py +++ b/encode.py @@ -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 = [] diff --git a/generate.sh b/generate.sh index fc6d850..bc846b7 100644 --- a/generate.sh +++ b/generate.sh @@ -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 diff --git a/index.html b/index.html index cd0cb7a..38861f6 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,20 @@ document.documentElement.classList.add('js'); diff --git a/src/content.js b/src/content.js index 37e56ba..be8a1b8 100644 --- a/src/content.js +++ b/src/content.js @@ -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(); diff --git a/src/content.js.map b/src/content.js.map index 2b10efb..cc578b4 100644 --- a/src/content.js.map +++ b/src/content.js.map @@ -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,CAAsB,CAAC;QAC9E,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAEtD,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACxC,IAAI,CAAC,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAEtC,IAAI,CAAC,WAAW,GAAI,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAsB,CAAC,CAAC,wDAAwD;QACnI,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElD,IAAI,CAAC,WAAW,EAAE,CAAC;IACpB,CAAC;IAEK,6BAAW,GAAjB;;;;;;wBACO,WAAW,GAA4B;4BAC5C,KAAK,EAAG;gCACP,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;gCACtB,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;gCACvB,UAAU,EAAE,aAAa;6BACzB;4BACD,KAAK,EAAE,KAAK;yBACZ,CAAA;;;;wBAEe,qBAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,WAAW,CAAC,EAAA;;wBAA/D,MAAM,GAAG,SAAsD;wBACrE,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAqB,CAAC;wBAEjE,IAAI,CAAC,KAAK,CAAC,SAAS,GA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,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YAC7B,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YACzC,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,eAAQ,IAAI,CAAC,GAAG,cAAI,IAAI,CAAC,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"} \ No newline at end of file diff --git a/src/content.ts b/src/content.ts index c79d90c..2a237f8 100644 --- a/src/content.ts +++ b/src/content.ts @@ -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;