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

Problem Code 128 barcode #251

Closed
Spelt opened this issue Mar 21, 2020 · 6 comments
Closed

Problem Code 128 barcode #251

Spelt opened this issue Mar 21, 2020 · 6 comments

Comments

@Spelt
Copy link

Spelt commented Mar 21, 2020

HI,

Thanks for the great work!

I have a problem with a Code 128 barcode.

If I upload the same file for decode at https://zxing.org/ it decodes fine. Not sure if there is a bug with code 128. I have attached the image with barcode here.

Hope you can help!

Kind Regards,
Edward

128problem

@micjahn
Copy link
Owner

micjahn commented Apr 1, 2020

There is no guarantee that every barcode can be decoded. And there is no guarantee that the .Net version of zxing gives the same result as the original java version. For example since the beginning of the project I tried to implement a color-to-grayscale-algorithm which works like the java one. But I couldn't remove the last small differences yet. But an identical grayscale image is important for the binarizer to give the same result.

If you shrink the image by 50% the barcode can be decoded successfully.

@micjahn micjahn closed this as completed Apr 1, 2020
@Spelt
Copy link
Author

Spelt commented Apr 1, 2020 via email

@JohnTApp
Copy link

JohnTApp commented Apr 2, 2020

Hi Michael & Edward
My Names John, and I reported the issue. I just saw Micheal's comment here as I was checking the issue. Again, thanks for the great work and for looking at this. I love this tool.
I'm using this in a Delphi FMX application for iOS and Android mobile devices. My Client is a large supermarket and wants to scan shelf labels for inventory counts. (They also use EAN formats for other purposes in the App) All of their shelf labels are code 128. App uses device camera to scan barcode labels on the shelf, so I have no opportunity to scale the image as such. For responsiveness I'm processing about 20fps and Medium Camera resolution which seems to be the sweet spot. None of the shelf code 128 barcodes have successfully scanned at all as yet (whereas EAN is magnificently responsive using ZXING). Is there anything that you can suggest that I could try as a workaround? EG, is there any pre-processing of the image I can perform before parsing to ScanManager (image processing is a bit new to me) or do you think I should perhaps be looking at other means of barcode scanning for my particular use case scenario at this point in time?
Again, Thank you. I do appreciate your time.
Kind Regards,
John

@micjahn
Copy link
Owner

micjahn commented Apr 2, 2020

Without any details (like a code snippet of the barcode reader initialization, the selected resolution or a sample image) I can't help here.
The sample image above is taken with a very high resolution. Such images have a lot of noise.
The best opimization in such cases is shrinking the image or reducing the resolution of the camera. For mobile devices I got the best results with a preview resolution of about 1024x1024 pixels.
All other image optimization doesn't make much sense because you get a constantly stream of images of different quality. Normally after a short period of time the barcode reader gets an image in a quality which can be successfully decoded.
The only thing, I can image in your case with Code 128 is, that the barcode reader isn't correctly initialized. Perhaps the possible formats are restricted to EAN and Code 128 is disabled. Doesn't make much sense but it's possible:
var reader = new BarcodeReader { PossibleFormats = new List { BarcodeFormat.EAN13}};

@micjahn
Copy link
Owner

micjahn commented Apr 2, 2020

We have a main problem here: you are using a different library: https://github.com/Spelt/ZXing.Delphi/
I don't have any experiences with Delphi. It would be better that you open a new issue there.
If you have a captured image of a code 128 barcode I can only check if it can be decoded with ZXing.Net. Sorry.

@JohnTApp
Copy link

JohnTApp commented Apr 3, 2020

Oh. I see. I apologize. I saw this and thought you were a Delphi guy. I noticed that Edward had mentioned that he had the same issue in .Net but didn't realize that that was specifically why he had reached out to you. Many Thanks for your correspondence. It's been most appreciated.......... and I also learned something with respect to initializing with the hints. Was just trying to ensure anyone had all the info they needed. I'll leave it with Edward who I believe is the Delphi guru :-) .
Sorry for my misunderstanding.
Kind Regards,
John

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

3 participants