serratus / quaggaJS

An advanced barcode-scanner written in JavaScript
https://serratus.github.io/quaggaJS/
MIT License
5.05k stars 977 forks source link

Doesn't recognize correctly pretty much any barcode #256

Open localhosted opened 6 years ago

localhosted commented 6 years ago

I've tried getting quagga to work, but none of the EAN in consumer products, managed to get properly decoded. Here is an image that doesn't get recognized, pretty much anywhere (even quagga alternatives): https://imgur.com/a/SDnrR

jodiethecodie commented 6 years ago

Yep, I'm experiencing the same issue.

senritsu commented 6 years ago

same here, at most i can get some green boxes to show up with debug visualizations (and only the boxes property set in the result object), but even those are completely in the wrong place.

The live_w_locator example works, but i can't reproduce it even if i more or less copypaste the code into a new project.

frnsys commented 6 years ago

I was struggling this as well. I think it's very sensitive to your camera quality. I can hold a barcode in front of my laptop's webcam for a minute or two, adjusting it throughout, and it will eventually detect it. When using my phone's camera, it was still very finicky, but recognized the barcode quicker.

nitinsbuzz commented 6 years ago

To reduce number of false positives, use a buffer and sensitivity threshold. For example, increase frequency to 20 and save all barcode scans. If a specific barcode is scanned at least 5 times return this barcode.

e.g. increase frequency to 20 and save each code in array. The first barcode to be scanned 5 or 6 times is a better match. You can increase this number to 8 for even higher precision.

GIOkafor commented 6 years ago

increase frequency to 20 and save each code in array

Could you please show some code example of this in action?

ericblade commented 6 years ago

totally untested, but this is what nitinsbuzz is thinking of GIOkafor

let detectionHash = {};
function onDetected(result) {
    detectionHash[result.codeResult.code]++;
    if(detectionHash[result.codeResult.code] >= 5) {
        detectionHash = {};
        call_success_function(result.codeResult.code);
    }
}

not a bad idea, might consider doing that, if it doesn't exhibit speed issues.

GIOkafor commented 6 years ago

Thanks @ericblade, I decided to use Qr codes instead because it provides more reliable results but will definitely try this next time I have to implement barcode scanning.

mrtomnguyen commented 6 years ago

@GIOkafor how do select QR code?

I can confirm EAN barcode scanning on iOS 11 Safari. very cool!

skane526 commented 9 months ago

totally untested, but this is what nitinsbuzz is thinking of GIOkafor

let detectionHash = {};
function onDetected(result) {
    detectionHash[result.codeResult.code]++;
    if(detectionHash[result.codeResult.code] >= 5) {
        detectionHash = {};
        call_success_function(result.codeResult.code);
    }
}

not a bad idea, might consider doing that, if it doesn't exhibit speed issues.

This is a great fix! Thanks. I have near 100% accuracy now by setting it to 5. 4 and 3 seem to work pretty well too. Keep in mind the higher the buffer the slower it is.

ericblade commented 9 months ago

For sure. It works pretty well, but I eventually went for something that does a quick checksum validation on it, and if the barcode appears to be valid then accept it the first time, otherwise if it scans the same code several times with a high confidence, then accept it. I wrote a checksum checker some time ago here https://github.com/ericblade/barcode-validator .. i just realized i never documented it, but there are some tests at the bottom that are pretty self-explanatory on how to operate it.