Skip to content
Snippets Groups Projects
Commit 399014e5 authored by Tögl, Christina's avatar Tögl, Christina
Browse files

Merge branch 'master' of gitlab.tugraz.at:dbp/web-components/toolkit

parents d381fa38 8b78229d
No related branches found
No related tags found
No related merge requests found
Pipeline #13582 passed
......@@ -221,6 +221,9 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
requestAnimationFrame(tick);
}).catch((e) => { console.log(e); that.askPermission = true;});
let lastVideoTime = -1;
let lastCode = null;
function tick() {
if (that.sourceChanged) {
video.srcObject.getTracks().forEach(function(track) {
......@@ -291,9 +294,19 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
imageData = canvas.getImageData(maskStartX , maskStartY, maskWidth, maskHeight);
}
var code = jsQR(imageData.data, imageData.width, imageData.height, {
inversionAttempts: "dontInvert",
});
let code = null;
// We only check for QR codes 5 times a second to improve performance
let shouldAnalyze = Math.abs(lastVideoTime - video.currentTime) >= 1/5;
if (shouldAnalyze) {
lastVideoTime = video.currentTime;
code = jsQR(imageData.data, imageData.width, imageData.height, {
inversionAttempts: "dontInvert",
});
lastCode = code;
} else {
code = lastCode;
}
if (code) {
let topLeftCorner = code.location.topLeftCorner;
let topRightCorner = code.location.topRightCorner;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment