UPC-A Barcode Standards
From SoftwarePractice.org
About UPC-A Barcodes
UPC barcodes, also known as EAN,UCC-12, are predominantly utilised in North America within the retail industry. There are currently 2 different types: UPC-A, which is a fixed-length 12 digit code; and UPC-E which is a shortened version of UPC-A, consisting of 8 digits. The following discussion will focus upon UPC-A.
UPC-A barcodes employ a 12 digit numerical code. The barcode itself, has 2 codes visible: the machine-readable barcode, consisting of a series of bars and spaces; as well as a human readable 12-digit code.
The first 6 digits of the code refer to the maufacturer's ID number, increasing the ease at which a product can be aligned to its origin. The next 5 digits are the product's unique number, ensuring that the correct item is read by the software system. The last digit acts as a checksum, allowing the scanner to calculate if the barcode was scanned without mistake. In terms, of calculating the correctness of the machine-readable code by the scanner, a mathematical formula is followed
Each number, ranging from 0 to 9, has its own combination of bars and spaces, making it simpler to decipher the seemingly difficult code. The differing widths of the bars and spaces can be looked at to decipher the numerical code. The thinnest width corresponding to width 1, then there is double that which is width 2, triple width 1 relating to width 3, and width 4, which is four times the width of 1.
Or another perspective to view the numerical code are series of binary digits. Each number is assigned a 7 digit binary code. Therefore, in total, UPC barcodes are composed of 95 bits in total.
One thing to note is that at the start and end of each barcode, there is a particular bit pattern, 101, indicating to the deciphering program where the barcode is initialised and concluded. There are also guard bars, a particular sequence composing 01010, separating the manufacturer's ID number from the unique product number. It must also be taken to account that the sequences to the left of the guard bars differ to that on the right. The codes corresponding to each number are one's complement when comparing the codes on the left hand side to that on the right.
The Numerical Codes
UPC-A barcode digits are coded such that the left 6 digits and the right 6 digits are separated by a middle guard of 0-1-0-1-0, that is, space-bar-space-bar-space.
The left hand side codes have 10 possible space-bar combinations, with odd parity. It is evident, that the left hand codes start with a space. The bit patterns and widths are as follows:
Left Hand Side Codes:
0: 0001101 3-2-1-1
1: 0011001 2-2-2-1
2: 0010011 2-1-2-2
3: 0111101 1-4-1-1
4: 0100011 1-1-3-2
5: 0110001 1-2-3-1
6: 0101111 1-1-1-4
7: 0111011 1-3-1-2
8: 0110111 1-2-1-3
9: 0001011 3-1-1-2
On the other hand, the right hand side bit patterns relating to each digit are essentially ones complements of the left hand side pattern. They have an even parity and start with a bar. The bit patterns are as follows:
Right Hand Side Codes (Remember these are the ones complement!):
0: 1110010
1: 1100110
2: 1101100
3: 1000010
4: 1011100
5: 1001110
6: 1010000
7: 1000100
8: 1001000
9: 1110100
Calculating the Checksum
A checksum is, usually, some fixed value, which acts as a form of authentication to ensure that the actual data is correct or uncorrupted. This is done by taking the data and using it as input to some algorithm which is known by both the sending and receiving parties. The sending party sends the data as well as a checksum (or hash), the receiving party takes the data and calculates the hash again and compares it with the received checksum. If the two independantly calculated has values are the same then it can be accepted that the data has been received correctly.
The UPC-A method of calculating checksums takes into account the 'data' which in this case is the first 11 digits and performs some computation to decipher the checksum. The encryption technique is known as a mod10 encryption.
Step 1: Add the values of all digits in odd positions and multiply the sum by 3.
Step 2: Add the values of all digits in even positions.
Step 3: Add the result from step 1 and step 2 together.
Step 4: The checksum is the integer which, when added to Step 3 would give a resultant which is a multiple of 10.
Step 1: 5+3+0+1+6+0 = 15 15*3 = 45
Step 2: 4+0+0+8+7 = 19
Step 3: 45+19 = 64
Step 4: Therefore the check sum should equal 6, since the integer value 6 must be added to 64 in order for the resultant to equal a multiple of 10, in this case 64+6 = 70 which is a multiple of 10.
Back to Team F's Main Page Team F: Barcode Reading from Image



