serratus / quaggaJS

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

Problems scanning Book barcodes #192

Open Nashiralyana opened 7 years ago

Nashiralyana commented 7 years ago

Loving the idea of barcode reading on the client side using Javascript and I am currently implementing this library within a system which is reading book barcodes, but we are using laptop webcams (specifically chromebooks) to get the images of the barcodes. I am running into a few problems and was wondering if anyone could give me any pointers.

If I take a photo with a webcam of a barcode, most of the time I cannot get the barcode to read. I believe this is to do with the poor quality of a webcam vs a phone. I have experimented with different patch sizes and holding the book closer and further away from the web cam, but it can take sometimes upwards of 10 seconds of more to get a read of the barcode, and on some laptops I never get a read. Is there something I can do to make this more reliable? I found a post https://github.com/serratus/quaggaJS/issues/106 which talked about a local threshold for scanning book barcodes. Has anyone had any success with the ideas talked about in this post?

Barcode taken with my laptop: http://imgur.com/SGOKLxg Barcode taken with my phone camera: http://imgur.com/vY1kemI

Testing these two images with https://serratus.github.io/quaggaJS/v1.0.0-beta.1/examples/file_input/ shows that the phone camera gives a result, but the web cam does not.

I've also found for my books that I am not always getting the correct barcode back. Using the example here https://serratus.github.io/quaggaJS/v1.0.0-beta.1/examples/live_w_locator/ and trying to scan a Harry Potter book (barcode below) I am getting the correct barcode as well as many incorrect barcode results. Is there anything I can do to try to increase the likelihood of a correct barcode detected?

Barcode: http://imgur.com/JStog0E Results: http://imgur.com/gQVtqdR

Also my client has asked me to ask if the author does paid support for this library.

Thanks!

zardoz01 commented 7 years ago

Interesting concerns raised there Nashiralyana. You are a little further down the track with your work than me but I been faced with similar experiences using QuaggaJS. I'm testing with a Microsoft Lifecam 720p webcam and that auto-focus does seem to operate OK. I've played around with various approaches and using the live video feed is preferred although on occasions that throws up incorrect scans! Clearly some fine tuning is required. A 'poor detection rate' is one thing but I was disappointed to get some almost random results on occasion. I'm only looking at Code 39/128 bar-code types myself. Your phone camera bar-code image is nice and sharp but your laptop image is out of focus so there's no surprises on your results. Converting to grey scale has been suggested but with such an out of focus image who knows whether that would help. I'm only running a 1440p monitor rather than a UHD 2160p but even your harry potter bar-code image looks a little blurry to me so I'm not surprised that you're getting incorrect scans. It looks like a good HD or better webcam with fast auto-focus could give more reliable results.

A couple of others things that you might want to consider: -Good lighting over the bar-code and avoid shadows passing over the bar-code label during scanning. -I've done a little research on webcams for Chrome OS and ideally you want one that has the smarts to auto-focus etc. builtin. The LOGITECH HD PRO WEBCAM C920 is recommended for Chromebooks: http://cbookreviewguide.com/chromebook-compatible-external-webcam/

I'm continuing my work so I'll post any advice if I figure out how to improve successful scanning rates myself.

Nashiralyana commented 7 years ago

I did discover that using the scanner at night was a big part of my problem, as I usually code at night. During the day with better lighting I can get QuaggaJS to scan barcodes on almost every device. Thanks for the information about the external camera, I'll pass that on for any of our power users who want to scan a lot of barcodes reliably. We have decided on also adding a way to manually enter a barcode as a backup plan.

Interestingly I did some experiments with scanning using the live video feed and incorrect results and decided to see what would happen if I tallied the different barcode scan results within a set period of time. Most of the time I found that the barcode result which was found the highest number of times was the correct barcode. I've simply just implemented the scanner in such a way now where I can change the time I spend listening for a barcode, and return the barcode which was returned most often from QuaggaJS. It seems to be working for our purposes at the moment.

seanpoulter commented 6 years ago

@Nashiralyana, you can improve the reliability reading an ISBN by verifying the [built-in error correction code in an ISBN, the check digits. Excluding the invalid ISBNs will really reduce the noise.

edumats commented 4 years ago

I know that this is an old issue, but if anyone needs help when dealing with book barcodes, I found a great ISBN validation tool that goes beyond the ISBN check digit calculation which was not enough for me (I was getting false readings that were passing this check). After setting this method, I never get false readings, works as a charm. This version can be added as a .js file on the page, but there are npm installs as well if you do quick search: https://code.google.com/archive/p/isbnjs/downloads

Yes, a camera from a smartphone has much better detection than laptop webcams.

Also, if you are reading book barcodes, make sure to select ean_reader as the reader when configuring QuaggaJs.

I also found that it has a better detection when on daylight. With artificial lighting the detection rates are much worse.

I also defined locate as false and set up an area (check official documentation) where detection is possible, my area setting is like this:

area: { // defines rectangle of the detection/localization area
                            top: "20%",    // top offset
                            right: "20%",  // right offset
                            left: "20%",   // left offset
                            bottom: "20%"  // bottom offset
                        },
ericblade commented 4 years ago

good lord, that isbnjs is some seriously difficult to read code. Looks like it just does a checksum on the digits, stripping out any invalid characters first, but you shouldn't be getting invalid characters from quagga.

I've wanted to use area detection as an option, but i havent figured out how to get the CSS to display some sort of viable highlight over the area that is being scanned, so the user can tell what is happening. can you share how you manage that?