0

I am using @zxing/ngx-scanner in my angular application. I am trying to scan a barcode of format code_128. But it won't scan it. I have attached the barcode.

I have had no issues yet with any other barcodes only this particular one is giving issues.

Can anyone please help?enter image description here

pix1289
  • 514
  • 1
  • 7
  • 24

1 Answers1

0

It's hard to say since your image is slightly distorted. A flatbed scan might produce a better image and a better answer. Without a precise image, it doesn't seem worthwhile to dig into the barcode spec and try to determine exactly what might be wrong. But it subjectively looks like the black lines are too narrow relative to the white spaces between. Maybe you're just barely getting away with this on other barcodes generated the same way as this one.

The ZXing app can't scan your original image or my attempt to clean it up. Notice how all the lines in the middle seem to be moved slightly toward the ends. That could just be foreshortening in your photo. ZXing easily detects another Code128 barcode that I created, even after it became fuzzy when I scaled it up. Look at the difference.

enter image description here

Kevin Krumwiede
  • 9,868
  • 4
  • 34
  • 82
  • Thanks @kevin. I tried Scandit SDK to scan the image i had posted. Using Scandit SDK i was able to scan the barcode but the same image doesn't get scanned either by Zxing or quagga js. So I was wondering if the image really has anything to do with the scanning since scandit is able to scan. Scandit is commercial and I am looking for an open source alternative. My options are either make it work with zxing or find an open source alternative which is as good as scandit. Do you have any idea in this regard? – pix1289 Apr 21 '21 at 05:14
  • @pix1289 I've only used ZXing. Any barcode reader is going to allow some deviation from a "perfect" barcode to account for perspective, damage, etc. If you look into the spec for Code128 and take careful measurements from the barcode, essentially decoding it by hand, you should be able to determine whether the problem is with ZXing or the barcode. If the barcode is in spec, then you could report it to the ZXing project or try to fix it yourself. – Kevin Krumwiede Apr 21 '21 at 08:54
  • @pix1289 ZXing also has a "try harder" feature, which I guess allows for more deviation. I've never used it, but you can find some references and code samples with a search. – Kevin Krumwiede Apr 21 '21 at 08:58
  • I have enabled "try harder" feature as well. An interesting thing is though if I make the image i shared of high resolution then zxing library scans it. So can you please suggest any way to increase the resolution of the image ? That is one way I am looking at to resolve this issue. – pix1289 Apr 23 '21 at 14:50
  • @pix1289 Not sure how resolution would matter unless scaling it up makes it a little blurry. – Kevin Krumwiede Apr 24 '21 at 16:02
  • @pix1289 if a commercial solution is not off the table, perhaps you could consider using STRICH (https://strich.io), a low-cost alternative Scandit and Dynamsoft (disclaimer: I am the author) – Alex Suzuki May 24 '23 at 18:10