Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How are you validating ? #3

Closed
sudhamjayanthi opened this issue Nov 24, 2020 · 9 comments
Closed

How are you validating ? #3

sudhamjayanthi opened this issue Nov 24, 2020 · 9 comments

Comments

@sudhamjayanthi
Copy link

Hi @ericblade , Could you tell me what's logic behind this library ? How would you validate a barcode ?

@ericblade
Copy link
Owner

This just exports a single function that takes two parameters, a string representing a numeric barcode (like what you'd get from a barcode scanner), and an optional string containing what the type of barcode you're expecting it to be is.

The TypeScript definition file is pretty easy to read, even if you're not familiar with TypeScript https://github.com/ericblade/barcode-validator/blob/master/index.d.ts

It should work with anything similar to GTIN, ISBN, EAN, UPC types, I have not researched other types. The code itself, I think is pretty well documented. I personally use this in both browser and node code to determine if a barcode looks valid before sending it off to other services.

@sudhamjayanthi
Copy link
Author

sudhamjayanthi commented Nov 25, 2020

Ok! But I'm not asking about the code/technical part rather I would like to know the logic behind validating a barcode. What are checksums & how would you validate a barcode ? Is there some logic between the digits for every specific type of barcodes ?

P.S: I haven't worked with barcodes before.

@ericblade
Copy link
Owner

aha, you might want to read up on check digits for barcodes https://en.wikipedia.org/wiki/Check_digit

Basically, the last digit of most numeric barcodes is a digit that is calculated by various addition/multiplication operations.

Although, as wiki points out, the method was designed to catch human entry errors, it also can be used to catch laser and visual based scanner errors as well, to a degree.

@sudhamjayanthi
Copy link
Author

Oh, Got it! Thanks. Also would using this library be helpful for increasing accuracy of quagga js while using all the barcodes set ?

@ericblade
Copy link
Owner

I do use it for that, although i do find that if you just rely on "valid barcode" you'll end up with a lot of false positives with the UPC reader, still. I want to try combining both validating the barcode and using a threshold of error confidence to try to get it really close.. one thing that i have noticed, is that there are some upc barcodes on products out there that actually do not validate, so even if you could guarantee never having an actual read error, relying solely on the checksum is not 100%.

@sudhamjayanthi
Copy link
Author

sudhamjayanthi commented Nov 29, 2020

I do use it for that, although i do find that if you just rely on "valid barcode" you'll end up with a lot of false positives with the UPC reader, still. I want to try combining both validating the barcode and using a threshold of error confidence to try to get it really close.. one thing that i have noticed, is that there are some upc barcodes on products out there that actually do not validate, so even if you could guarantee never having an actual read error, relying solely on the checksum is not 100%.

Hey sorry @ericblade, I was a bit busy & unable to reply to you!

Can you tell how to use the error confidence to improve accuracy ? I actually have also gone through this thread about limiting false positives. But I found it tough to understand to understand this thing, I also searched in the documentation and got not much help! So could please drop a link here if there is detailed explanation in the documentation or somewhere else and maybe about the result object(what information can we get from it), what is error confidence, how can prevent false positives with it, are there any other methods to prevent false positives ?

PS: Thanks a lot for being patient and answering all questions ; ) Your explanations are really helping me to understand new concepts

@ericblade
Copy link
Owner

ericblade commented Nov 29, 2020

I was pretty successful using a method like serratus/quaggaJS#237 (comment)

When I re-wrote my app, I swapped that for doing a 100% validator approach, thinking that would be better... and it's not. With the error-confidence approach, i'd find that sometimes it would take too long to get a high confidence score, but with a pure valid-checksum approach, i get a lot more false scans. So, I think there's some use to both, and a combined method might do better.

I don't really know too much about the error values, sorry. This is more a question for https://www.github.com/ericblade/quagga2 though.

@sudhamjayanthi
Copy link
Author

sudhamjayanthi commented Nov 30, 2020

Ok! Yeah, this is a actually a question of quagga js, but I asked it here just as continuation to your message. Pl let me know if you find out & research more about the error values when you deep dive into quagga js library.

but with a pure valid-checksum approach, i get a lot more false scans

But it does improve than having no validation right ? (like this library doesn't show the right ones too wrong right?)

@ericblade
Copy link
Owner

sort of, yeah. between falses and products with UPCs that don't even pass validation anyway, i think i'm going to try to take a "if median of errors is below X or if checksum matches and median of errors is below Y" approach and see how that works.. just haven't got around to it in my app because i've got a million other things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants