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.68k stars 606 forks source link

False positives #90

Open cozmo opened 6 years ago

cozmo commented 6 years ago

The following images both incorrectly detect a QR code with no data. This is obviously not correct, but the exact place to fail them out is not entirely clear.

0000002597 0000003589

nosizejosh commented 5 years ago

hey @cozmo thanks for this. I am using your example in a node application to scan QR's through camera and I am getting very frequent false positives and this is making my app crash when it happens.

this line is the culprit and I have tried many variations but none works as all of them casue the stream to freeze.

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

Tried the following: 1.

if (code.data) {  // to confirm that there is really data
  console.log("Found QR code", code);
}

2.

if (isURL(code.data)) {  // to confirm that the data is a url
  console.log("Found QR code", code);
}

Please have you or anyone found a way to deal with this? I really need some help on this. Thanks.

iamacatperson commented 5 years ago

@nosizejosh You can try:

if(code && code.binaryData.length > 0) {
     console.log("Found QR code");
}

We got random false positives also but realised if it's not a QR code, the binaryData length would be 0.