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

MLKit Vision is reading code128 and 39 barcodes poorly #32

Closed
chrisvanbuskirk opened this issue Feb 20, 2019 · 53 comments
Closed

MLKit Vision is reading code128 and 39 barcodes poorly #32

chrisvanbuskirk opened this issue Feb 20, 2019 · 53 comments

Comments

@chrisvanbuskirk
Copy link

I'm reading a buffer like such:

 let visionImage = VisionImage(buffer: sampleBuffer)
            barcodeDetector.detect(in: visionImage) { (barcodes, error) in
           ...
           }

I'm seeing errors of random characters being exchanged in code128/39 barcodes. No errors are raised. As you can see I'm checking enterprise labels. The 2D data matrix codes scan fine. However, their 1d counterparts randomly fail.

img_0163

@chrisvanbuskirk
Copy link
Author

MMS485Z5 Laser - ALS.pdf

Here is a sample barcode.

@chrisvanbuskirk
Copy link
Author

chrisvanbuskirk commented Feb 20, 2019

I'd like to also make note of the poor choppy performance of the camera while reading barcodes. I'm using the same camera code with Apple's vision with no issues.

@ulukaya
Copy link
Collaborator

ulukaya commented Oct 9, 2019

Please re-try with the latest barcode detection model (FirebaseMLVisionBarcodeModel 0.19.0) in MLKit

@chrisvanbuskirk
Copy link
Author

@ulukaya. I updated and I'm I'm still seeing character errors.

@ulukaya ulukaya transferred this issue from firebase/quickstart-ios Jun 30, 2020
@ulukaya ulukaya transferred this issue from another repository Jun 30, 2020
@miworking3
Copy link
Collaborator

Hey Chris,

We upgraded the Firebase MLKit API to the standalone Google MLKit API early this year: https://developers.google.com/ml-kit

I tried the the latest vision app with the given barcodes, looks like it works well with S, Q, H, could you give it a try and let us know if that would help your case as well?
H
S
Q

Thanks a lot!
Julie from MLKit team

@chrisvanbuskirk
Copy link
Author

@miworking3 I will test this.

@chrisvanbuskirk
Copy link
Author

@miworking3 Impressively done. Thanks! Closing this issue.

@chrisvanbuskirk
Copy link
Author

@miworking3 I am reopening. I was able to have reproduce similar issue, where this barcode produced N51%%3 after several tries.

Screen Shot 2020-08-05 at 1 27 42 PM

@miworking3
Copy link
Collaborator

Could you help me to reproduce it with the MLKit quickstart app?

I tried to move the camera off and on several times, the result looks consistent to me.
barcode

@chrisvanbuskirk
Copy link
Author

chrisvanbuskirk commented Aug 6, 2020

@miworking3 I'm not sure. I'd have to study the sample more carefully. This issue is very rare. You can see in the following screen shot it plugs in the wrong value. I'm not sure why. Position of camera. Some sort of flaw in our barcode. The 2D barcodes are fine.

I'm going to step through the sample, then my code. I may spend the day with it.

Screenshot 2020-08-05 at 10 14 18 AM

@chrisvanbuskirk
Copy link
Author

chrisvanbuskirk commented Aug 6, 2020

@miworking3

Fascinating...

I was using

barcodeDetector.process(visionImage) { (barcodes, error) in
...and changed to method in the sample and am not seeing the problem.

barcodes = try barcodeScanner.results(in: visionImage)
I'm going to do even more testing. The handler seems to have problems.

@miworking3
Copy link
Collaborator

miworking3 commented Aug 7, 2020

Thanks for checking that!
Yes, for the realtime video frames, we would recommend to use the synchronous API results(in:), and there are also other tips for the videos that might be helpful:
For processing video frames, use the results(in:) synchronous API of the detector. Call this method from the AVCaptureVideoDataOutputSampleBufferDelegate's captureOutput(_, didOutput:from:) function to synchronously get results from the given video frame. Keep AVCaptureVideoDataOutput's alwaysDiscardsLateVideoFrames as true to throttle calls to the detector. If a new video frame becomes available while the detector is running, it will be dropped.

https://developers.google.com/ml-kit/vision/barcode-scanning/ios

@chrisvanbuskirk
Copy link
Author

chrisvanbuskirk commented Aug 7, 2020

@miworking3

self.session.sessionPreset = .hd1280x720

Seemed to really fix the errors. Not closing just yet, cause I have more testing..but it's going great so far.

@miworking3
Copy link
Collaborator

Thank you @chrisvanbuskirk for verifying this. We appreciate the data point from your side.
Yes, the preset can affect the results, and 1280x720 is a recommended setting by our doc as well:
The named capture session presets—AVCaptureSessionPresetDefault, AVCaptureSessionPresetLow, AVCaptureSessionPresetMedium, and so on)—are not recommended, however, as they can map to unsuitable resolutions on some devices. Instead, use the specific presets such as AVCaptureSessionPreset1280x720.

https://developers.google.com/ml-kit/vision/barcode-scanning/ios

@ruslan-podurets
Copy link

Hi, have issue with 128 code barcode, when ml kit returns wrong values. I use com.google.mlkit:barcode-scanning:16.0.2 with default camera resolution settings (tried different). Also analyze in this way:
val mediaImage = imageProxy.image
val image = InputImage.fromMediaImage(mediaImage, imageProxy.imageInfo.rotationDegrees)
scanner.process(image)
This issue happens on many Android and IPhone devices. F.e HTC U11.
Ussually kit returns wrong short text of numbers like "15771449", but sometimes valid long text: "1076839827TanCarol Windell A4030052420".
img url: https://ibb.co/yh3DJFT

@miworking3
Copy link
Collaborator

@ruslan-poduret Thanks for reporting this, could you provide more information about the iPhone device that you found this problem? When you mentioned about "This issue happens on many Android and IPhone devices", is it reproducible with the MLKit iOS quickstart app?

BTW: About the android API, I've already forwarded your message to our Android team, he might have further questions about it later.

@chrisvanbuskirk
Copy link
Author

chrisvanbuskirk commented Aug 14, 2020

@miworking I'm afraid I still am seeing bad reads every 40-50 scans. Just seems for the 128's. It's very random and odd, and I can't quite pinpoint why. If it's distance. The barcode quality. Digital v. non digital, etc... There are less errors with some refactoring I have done.

@miworking3
Copy link
Collaborator

@chrisvanbuskirk Do you know the expected value of the barcode being read? If so, you can save the samplebuffer to an image right at the time when it fails, and with that information, a further investigation can be continued. Thanks!

@chrisvanbuskirk
Copy link
Author

@miworking3 I will look into it.

@miworking3
Copy link
Collaborator

It's been a while, with previous major concerns clarified, closing this thread. Pls feel free to reopen it if new updates. Thanks!

@felipetce
Copy link

I have the version 16.0.2 and the same problem happens

@miworking3
Copy link
Collaborator

16.0.2 for Android SDK?

@felipetce
Copy link

I have the version com.google.mlkit:barcode-scanning:16.0.2 and the same problem happens

@felipetce
Copy link

Hi,

I tried com.google.mlkit:barcode-scanninig:17.0.0 and com.google.mlkit:barcode-scanninig:16.2.0 using https://github.com/googlesamples/mlkit/tree/master/android/vision-quickstart and it seems working well to detect the full barcode in the image.

com.google.mlkit:barcode-scanninig:16.0.1 may have the issue as it is an older version/barcode model. Could you verify the new versions work well for the image?

Hi, as I mentioned, the images were from barcode-scanninig:17.0.0:

image

barcode_com google mlkit vision demo

barcode_com google mlkit md

@felipetce
Copy link

After we exchanged Zxing for MLkit, we are having a lot of problems, analyzing the Zxing code, it seems that it had a better validation of the processed barcode

@felipetce
Copy link

felipetce commented Nov 9, 2021

ZXing
zxing
ng

@SilverDestiny
Copy link
Collaborator

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg
It seems consistently working for me.

For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).

Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?

It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.

We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

@felipetce
Copy link

felipetce commented Nov 9, 2021

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.

For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).

Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?

It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.

We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

@felipetce
Copy link

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

By code I verified that the processing of MLKIT barcodes is 1 second

@felipetce
Copy link

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

By code I verified that the processing of MLKIT barcodes is 1 second

that is, I think the processing is unsafe

@felipetce
Copy link

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

By code I verified that the processing of MLKIT barcodes is 1 second

that is, I think the processing is unsafe

we are having a lot of problems having changed the ZXing for ML

@felipetce
Copy link

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

By code I verified that the processing of MLKIT barcodes is 1 second

that is, I think the processing is unsafe

we are having a lot of problems having changed the ZXing for ML

As a multinational company and we need the guarantee of the read codes

@SilverDestiny
Copy link
Collaborator

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

Could you share an example for the same cropped image between ML Kit and ZXing?

@SilverDestiny
Copy link
Collaborator

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

By code I verified that the processing of MLKIT barcodes is 1 second

Our benchmark tests showed that for 1600x1200 input image, the inference time is around 100 ms.
The inference time depends on the input image size.

@SilverDestiny
Copy link
Collaborator

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

By code I verified that the processing of MLKIT barcodes is 1 second

that is, I think the processing is unsafe

We're working a project which will not request camera permission for barcode scanning, if you think this sounds safer to you.
It will be released soon next year.

@SilverDestiny
Copy link
Collaborator

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

By code I verified that the processing of MLKIT barcodes is 1 second

that is, I think the processing is unsafe

we are having a lot of problems having changed the ZXing for ML

Could clarify all the problems except this one? We're happy to hear and will try our best to resolve your problems.

@felipetce
Copy link

I cannot repro your issue for https://user-images.githubusercontent.com/16478800/141014762-323d5709-937c-4a51-ab2b-cca159b29291.jpg It seems consistently working for me.
For https://user-images.githubusercontent.com/16478800/141014875-66fc3c66-9626-4e16-a7ea-285df1d193ff.jpg, it is reproducible, but this image is cropped so that it doesn't contain the full barcode(left side is missing).
Did you mean ZXing also work for cropped images to detect the full barcode? Could you share an example?
It seems working properly for https://user-images.githubusercontent.com/16478800/141017954-1bdc85fe-d3a0-426d-b94a-37d5d6335196.jpg as well.
We probably can improve our model to consider more for the full barcode and ignore the partial barcode in future releases.

yes, Zxing did not processed barcodes not read completely

Could you share an example for the same cropped image between ML Kit and ZXing?

@felipetce
Copy link

Zxing does not process uncompleted scanned barcodes

@felipetce
Copy link

I found that we have no way to access the image processing source code

@felipetce
Copy link

Would it be possible to have access to this image processing code?

@felipetce
Copy link

It's causing us a lot of production problems with the ZXing switch

@felipetce
Copy link

I can't reproduce the same problem with ZXing, it seems the image processing is better

@SilverDestiny
Copy link
Collaborator

Zxing does not process uncompleted scanned barcodes

We'll work on this to see if we can improve to fix this issue.

@wsliaw
Copy link

wsliaw commented Oct 29, 2022

the problem still exists on latest version (android 17.0.2, iOS 2.2.0)
should we reopen it, until not process uncompleted scanned barcodes is implement?
thanks 🙏

@SilverDestiny SilverDestiny removed their assignment Oct 29, 2022
@miworking3 miworking3 assigned miworking3 and unassigned miworking3 Oct 31, 2022
@miworking3
Copy link
Collaborator

This thread has diverted multiple times, and the latest update is not related to the original title.
Please open a new request here with your request clarified, and we will look further into them ,thanks.

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

7 participants