-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Bug report] EAN13 code starting with 0 detected as UPC-A #797
Comments
I like this issue, but for now https://react-native-vision-camera.com/docs/guides/code-scanning#upc-a-vs-ean-13-codes "You will need to keep this in mind and do the conversion from EAN-13 to UPC-A yourself. This can be done by removing the front 0 digit from the code to get a UPC-A code." I am sure they would take a PR for a fix |
@JavaLavaMT the issue is actually the opposite: I ask the library to recognize an EAN-13 code but it returns an UPC-A code, which it is not what I asked and it is not what I scanned. |
An EAN-13 beginning with "0" is by definition a UPC-A, at least in so far as the bar space pattern is identical. Only the placement of the human-readable text differs, whose recognition is not within the purview of a typical reader. The history for this is that when it became clear that the 12-digit numeric code required extending in order to allow some variant of the UPC to be used in the non-US markets, a construction was adopted where certain UPC symbol character sequences (bar space segments) were mirrored on the left-half of the newly-defined EAN-13 symbol, which was otherwise identically encoded. This allowed an additional leading digit to be derived by detecting which segments were mirrored. When no mirroring is taking place (i.e. identical bar/space pattern to UPC-A) then the prefix digit is defined to be "0". The scheme extended UPC-A into a 13-digit space and did so in a way that meant that the new EAN-13 symbols could be adopted universally, with legacy UPC-A only scanners still able to scan the sub subset of new EAN-13s beginning with a "0" that were intended for the US market. For further illustration of the equivalence of these symbologies, the transfer protocol for scanners defines a "symbology identifier" header that is transmitted ahead of the barcode data to instruct the host about the meaning of the data it is about to receive. It is intended to be "all that matters" from the perspective of reading barcode data. (Other devices such as verifiers may have graphical requirements, of course.) For EAN-13 and UPC-A the symbology identifier Note that UPC-E is also transmitted as a 13-digit number behind Aside: My experience is the the Barcode Scanning component of ML Kit is inconsistent with following the standards for data transmission, including a symbology identifier in the |
EAN13 codes starting with 0 are detected as UPC-A code, dropping the leading 0 in the returned code.
To Reproduce
Example Steps to reproduce the behavior in sample app:
I have modified the source to print out also the format of the detected code.
Here is the result using an EAN13 starting with 0:
As you can see the detected format is 512, which is UPC-A.
Here is the result using an EAN13 not starting with 0:
The detected format is 32, which is EAN13.
Expected behavior
EAN13 codes should be detected as they are, even when the code starts with 0.
SDK Info:
I'm not sure how to get this info, I simply run
pod install
and this is the result:Smartphone:
Development Environment:
(For Android issue feel free to skip this section)
The text was updated successfully, but these errors were encountered: