ericblade / quagga2

An advanced barcode-scanner written in Javascript and TypeScript - Continuation from https://github.com/serratus/quaggajs
MIT License
761 stars 84 forks source link

Problem in scanning some barcodes #483

Open mer30boy opened 1 year ago

mer30boy commented 1 year ago

Hello I use quagga. But some barcodes are difficult to scan or not scanned at all. While the same barcode is scanned in other barcode reader programs (especially this app) at a very high speed. Example : error_sc

What is the problem and what can be the solution?

github-actions[bot] commented 1 year ago

Thank you for filing an issue! Please be patient. :-)

ericblade commented 1 year ago

Most of the problems that I see are usually improved with settings adjustments, or having more whitespace around the barcode.

My gut feeling on this one, though, is that maybe the whitespace around each individual piece of the barcode is way beyond the normal. I can't recall seeing a barcode that wide with as little data in it.

What sort of barcode is this? And what is your quagga configuration?

mer30boy commented 1 year ago

I scanned this barcode using this app and the result was this: sc (Code_93)

The strange thing is the extremely high speed of the scanning process in mentioned app. I'm using ngx-barcode=scanner and its basic default settings and I've added different types of barcodes to it. I don't have any problem in scanning other Code_93 barcodes and only some barcodes similar to the one mentioned are not scanned

ericblade commented 1 year ago

i'm pretty sure the camera in chrome runs on a different thread, so it's entirely possible that it does something before the visuals stabilize or after the display makes a questionable update :D

From your example here, what I'm seeing, is that it scanned the barcode successfully. Is there an error here, other than the display looks incorrect? I don't think there's much of anything I can do about that, if that's the issue.

mer30boy commented 1 year ago

I think I did not understand your meaning correctly. The image I uploaded in the previous post is actually not my program and does not use quagga. Rather, it is a native Android app. I just took a screenshot of this app to show you the scanning speed and the type of barcode. In my program that I have used quagga, it does not scan the said barcode at all.

ericblade commented 1 year ago

Oh, I'm sorry, I did not understand your message.

The image supplied decodes normally using the standard settings in the quagga file test app

image

Also works when plugged into the browser test suite as image-011

image

and works when used in node

image

Can you supply your quagga.init() settings?

mer30boy commented 1 year ago

In some devices, the automatic focus does not work well and barcode scanning is difficult. Is there a way to manage the focus operation of the camera? For example, by calling a function, the camera will focus on the center of the livestream. Is it possible to add this feature?

ericblade commented 1 year ago

As far as I'm aware, focus control has not been implemented in any browsers at this time, though this link explains quite a lot of the control that is proposed. I don't believe anyone has implemented any of it, right now, though.

https://stackoverflow.com/questions/60188128/tap-screen-to-trigger-autofocus-with-getusermedia

Are you able to share your Quagga.init() parameters?

liangxuxing commented 1 year ago

@ericblade hello,my barcodes also can't be scaned correctly? is it wrong type ? i can scan the top barcode,but the bottom barcode is long and complex test

test1 and this image ,i can scan the middle barcode but the top and bottom barcode i can't

ericblade commented 1 year ago

Hi @liangxuxing !! These are different kinds of barcodes, and I'm guessing that your reader configuration includes 'ean_reader' and/or 'upc_reader', which is what is reading the EAN-13 barcode in the second image, and the EAN/JAN code in the f irst image.

The other code in the first image is "GS1-128" format, as it says, and although I've not heard of it until now, it looks like according to a google search, it is a "subset of Code128", which Quagga does support. So if you add "code128" to your list of readers, it looks like that should work. If you want to scan both, you'll need to add "multiple: true" to the configuration, otherwise it will only return the first code found. If you only want to scan the one, remove the reader for the one you don't want to scan.

On the second image, I do not know what f ormat the other barcodes are in. They do not say what they are, and I'm not an expert in recognition. I'd try code128 on those, and see if it reads them. Other online or native barcode softwares may be able to detect the type, and then you can use that to inform Quagga which types you want to use.

I haven't yet run into a 2D barcode that Quagga doesn't support, but it is very possible that there are other ones. Code32 was a recent implementation that was contributed by another user.

ericblade commented 1 year ago

FWIW, we do sacrifice some flexibility in Quagga for some optimization -- it would be possible to make Quagga check every one of it's readers, and see if any of them can read it, and return all possible matches, but in general usage, most people only want one or two different kinds of barcodes, so that is the use case that is supported directly.

It would be possible to write a separate front end to Quagga that actually does this, but I'll leave that as an exercise for others. You'd need to write a separate frame grabbing interface, and pass it to the decoder using decodeSingle, with each configuration you wanted. (my plans for a v2 may make that quite a lot easier to do inside quagga, but who knows when that might get to usable status...)

liangxuxing commented 1 year ago

@ericblade Thank you for your reply, I feel that there are too many types of barcodes printed on different products. It seems that Quagga does not support the types I need. I use "code128" ,but it doesn't work. and then I put all readers in the list (I don't know if there is any harm ,maybe the efficiency?)in the end ,I found that only some commonly used barcodes can be recognized, and some newer ones may not work, and I don’t know if they are new barcodes.Does this mean that Quagga need to implement its decoding format to be more perfect?

ericblade commented 1 year ago

If you put in all of them, you'll probably have conflicts -- several of the barcode formats are close enough to each other, that one reader will read another in error, and I think that even with multiple: true on, if one reader recognizes a barcode, then it won't pass it to any other readers to try also.

I just tried out every online barcode scanner that I know of on those images, and none of them were able to recognize the second barcode on the first image. Weirdly enough, even my laser barcode scanner gave an incorrect result on it, and it supports a LOT of different formats. To even get Quagga to find a barcode in that image, I had to adjust the resolution setting up to 1280

On the second image, I was only able to determine that the "Product No" field is using Code-39. None of hte online readers I tried were able to decode the Serial No field, although my laser scanner does decode it, my laser scanner does not tell me what format it is in :| :|

So it does look like that first image is using a format that is unknown to most readers, or the code itself is broken somehow.