cozmo / jsQR

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.
https://cozmo.github.io/jsQR/
Apache License 2.0
3.67k stars 606 forks source link

qr code read multiple times? #104

Closed 1to10 closed 5 years ago

1to10 commented 5 years ago

qr code read multiple times?

cozmo commented 5 years ago

jsQR only exposes a single function, which you call with image data and only get 0 or 1 QRs back from.

const code = jsQR(imageData, width, height, options?);

if (code) {
  console.log("Found QR code", code);
}

If a QR is being scanned multiple times it's likely because wherever you're calling the jsQR function is calling it multiple times. I can't help with that since that's code that the consumer of the library has written. I'd suggest only calling jsQR if you haven't previously read a QR...something like this

if (hasScanned) {
  const code = jsQR(imageData, width, height, options?);

  if (code) {
    hasScanned = true;
    console.log("Found QR code", code);
  }
}

Closing this issue since as I understand it it relates to the usage of jsQR, not an issue within jsQR itself. Please comment/re-open if you disagree or have additional questions.