Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

Engineering

TRC3500
Sensors & Artificial Perception

Section 8 Bar Codes


Bar Codes
Development of bar codes has had a vast
impact on the logistics and retail trades.

They allow items to be rapidly and accurately identified in


situations such as inventory control, item tracking, and point of
sale.

Bar codes are inexpensive using standard


printing technology, they are resistant to
damage and tolerate wide variations in
the orientation of the scanning device.

2
Example bar codes

UPC Bar Code EAN Bar Code


Used by supermarkets to ID Popular for books, used
manufacturers and products outside US/Canada

CODE 39
DATAMATRIX
Can encode alphanumeric and special
2D barcode, higher data density
characters
3
Barcode Scanners
Handheld scanner
1) Laser light scanned across barcode
2) Reflected intensity captured by photodiode
3) Circuitry converts intensity to numerical output

Omni-directional scanner
1) Extension of handheld scanner
2) Scans in multiple directions (Lissajous curves)

Imaging scanners
1) Small video camera to capture image of barcode
2) Image processing to decode barcode

4
The Supply Chain
A supply chain is the sequence of activities that delivers an
object or a service to a consumer. Supply chain management
involves passing orders and requests down from the consumer
and organising the sourcing of components and other items to
satisfy the consumer request. E.g.

Purchasing a packet of breakfast cereal at the supermarket checkout


will contribute to a new palate of cereal being ordered from the
warehouse
The palate of cereal leaving the warehouse may trigger the delivery of a
truck load of cereal from the manufacturer, etc.
Automated means of keeping track of the flow of materials through the
supply chain is essential to its efficient operation.

5
The Supply Chain
2. Items read
as shipped by
supplier and
1. Bar code
receiver
attached to
goods, palates,
cases at
manufacturer

3. Items read
as received by
4. Items read as removed from store
storage and put on shelves

5. Items read at checkout to


determine price and reduce stock 6. Items read in
levels in system pantry and fridge
(FUTURE?)

6
Bar code requirements
The code should contain 10 decimal characters (subsequently, 12
were required).

The symbol should be scannable omni-directionally, i.e.


regardless of its orientation with respect to a scanning device.

The symbol should be scannable when in motion at a velocity not


exceeding 100 inches per second.

The scanning reject rate should not exceed 0.01 and the
undetected error rate should not exceed 0.0001.

7
Bar code requirements
The depth of field should be at least one inch.

Normal environmental contamination (abrasion, dirt, etc.)


should not affect the scanning process significantly.

The symbol area should not exceed 1.5 square inches. (The
symbol selected is of variable size.)

8
The UPC
The Universal Product Code (UPC) is a widely used form of bar
code that will be familiar to everyone. Most products that are
purchased from a supermarket are identified by one of these bar
codes and each product is allocated a unique code number.

99% correct first scan and 1 in 10,000 scans returns a substitute


code.

We will now look at how information is coded in the stripes of a


bar code*.
* Savir, D. and Laurer, G.J., The characteristics and decodability of the Universal Product Code
symbol, IBM Systems Journal, Vol. 14, No. 1, 1975, pp16-34.

9
Binary code requirements
Simplest way to encode numbers and characters is to use binary
codes

A black bar represents a 1 while a white space represents a


0, double width bar represents two 1s etc.

Each character should be of fixed length and


stand alone

Each character should contain a fixed reference


from a leading edge of one mark to the leading
edge of another, enabling it to be read forwards
or backwards
10
Binary (n, k) codes
Information is coded in a (n, k) code (code of length n contains k
runs of 1s and k runs of 0s)

e.g. a (5, 2) code has 4 suitable codes with leading 1s:


10010, 10100, 11010, 10110

An (n, k) code can represent n-1C2k-1 different characters

m m!
Cr =
(m r)!r!

11
(n, k) codes
Distinct characters in (n, k) codes
k
1 2 3 4
2 1 0 0 0
3 2 0 0 0
4 3 1 0 0
5 4 4 0 0
n 6 5 10 1 0
7 6 20 6 0
8 7 35 21 1
9 8 56 56 8
10 9 85 126 36
12
UPC Code Characters
A (7, 2) code was selected to encode the ten characters 0
through 9 and to provide an indication of parity

Parity indicates whether the total number of 1s in the code is


odd or even

The following table gives you the correspondence between each


character with parity and the modules making up the code

A module is a unit of length for measuring codes

13
Decoding UPC Characters

Character Odd Parity Even Parity


0 0001101 1110010
1 0011001 1100110
2 0010011 1101100
3 0111101 1000010
4 0100011 1011100
5 0110001 1001110
6 0101111 1010000
7 0111011 1000100
8 0110111 1001000
9 0001011 1110100

14
The UPC Symbol

The parity of the


characters allow
the bar code to be
scanned in either
direction and the
two halves to be
put together in the
correct order.

15
Number System
NS Description
0 Regular Items
1 Reserved
2 Variable Weight Items
3 Drug/Health Items
4 In-store use on non-food items
5 Coupons
6 Regular Items
7 Regular Items
8 Regular Items
9 Regular Items

16
Modulo check digit (creation)
The modulo check digit is used to ensure the barcode has been
decoded correctly
CREATED as follows:
1. From right to left, add the digits in the odd-numbered positions (first, third, fifth, etc.)
together and multiply by three.
2. From right to left, add the digits in the even-numbered positions (second, fourth,
sixth, etc.) to the result.
3. Find the result modulo 10 (i.e. the remainder when divided by 10. e.g. 10 goes into
58, 5 times with 8 leftover, so 58 mod 10 = 8).
4. If the result is not zero, subtract the result from ten.

17
Modulo check digit (checking)
CHECKED as follows:
1. EXCLUDE THE SCANNED CHECK DIGIT
2. From right to left, add the digits in the odd-numbered positions (first, third, fifth, etc.)
together and multiply by three.
3. From right to left, add the digits in the even-numbered positions (second, fourth,
sixth, etc.) to the result.
4. Find the result modulo 10 (i.e. the remainder when divided by 10. e.g. 10 goes into
58, 5 times with 8 leftover, so 58 mod 10 = 8).
5. If the result is not zero, subtract the result from ten.
6. If the calculated digit does not match the scanned digit, an error has occurred in
scanning

18
Example
Check if the following scanned barcode is valid: 931007202213
1. Exclude the scanned check digit: 3
2. From right to left, odd digits: 122019 (digit sum = 15, 153 = 45)
3. From right to left, even digits: 20703 (digit sum = 12)
4. Check sum = 45 + 12 = 57
5. 57 mod 10 = 7, Check digit = 10 7 = 3
6. Scanned barcode is correct

19
Bar code ink spreading
Printing of barcodes is subject to ink spreading

Ink spreading varies between barcodes, but is relatively constant


within a single barcode

Can cause decoding


errors

How to account for this?

20
T - Values

This diagram shows


the T values of an
even parity 2
character

21
T4 Extended (T4e)

T4e is resistant to
spreading and
contains the first black
bar in the next
character (if you know
T4e
the size of this black
bar you can work out
T4)

22
The Effect of Ink Spreading
As the following slide illustrates, the choice of these four T-
values helps to make measurements independent of spreading
of the ink used to print the bar code.

23
Resistance to Spreading

T1 = T1

T2 = T2

24
Converting Measurements to Modules
Measurements made of the bar code are converted to integer
module values in the following way:

25
Converting Measurements to Modules
Measurements made of the bar code are converted to integer
module values in the following way:
Ti 2.5 If decision is correct,
ATi = 2 then ATi =Ti
T 7
2.5 Ti 3.5
ATi = 3
7 T 7 A one unit error in
interpreting T1 or T2
3.5 Ti 4.5
ATi = 4 results in a parity error
7 T 7 in decoded character
...

26
Decoding Characters

Using measured
values of t1, t2, and
t4 the character
can be decoded

27
EAN-13 Bar Codes
First 2 or 3 digits = country code of manufacturer

Next 4, 5 or 6 digits = company code

Next 2 to 6 digits = item number

Last digit = modulo check number

Note: there are only 12 characters


encoded using bars

28
Decoding a UPC Bar Code

101 0001011 0111101 0101111 0110001 01010 1110010 1100110 1000100 1001110 101
Guard Guard Guard
9O 3O 6O 5O bar 0E 1E 7E 5E
bar bar

ODD PARITY CHARACTERS EVEN PARITY CHARACTERS

29
EAN-13 Country Code
The left-most digit in the bar code is not coded as bars, it is
encoded in the parity of the left-hand group of digits.
0=OOOOOO
1=OOEOEE
2=OOEEOE
3=OOEEEO
4=OEOOEE
5=OEEOOE
6=OEEEOO
7=OEOEOE
8=OEOEEO
9=OEEOEO

30
EAN-13 Character Encoding
Left Digits Right Digits
Character Odd Parity Even Parity Even Parity
0 0001101 0100111 1110010
1 0011001 0110011 1100110
2 0010011 0011011 1101100
3 0111101 0100001 1000010
4 0100011 0011101 1011100
5 0110001 0111001 1001110
6 0101111 0000101 1010000
7 0111011 0010001 1000100
8 0110111 0001001 1001000
9 0001011 0010111 1110100

31
Decoding an EAN-13 Bar Code

0110011 0001101 0010011 1110010 1011100 1101100


101 0111101 0100111 0010001 01010 1110010 1011100 1010000 101

Guard Guard
3O 1E 0E 0O 7E 2O Guard 0E 0E 4E 4E 2E 6E
bar bar bar

PARITY = OEEOEO = 9 Modulo Check Digit created and checked


using the same procedure as for UPC
check digit

32
Now it is Your Turn!

What numbers are coded in this right hand half of a bar code?

33
Australia Post barcodes
4-state bars
3 Encoding methods C, N and Base-4

http://auspost.com.au/business/barcoding.html

34
Australia Post barcode format

Error correction code produced using Reed Solomon algorithm


4 parity numbers, encoded using 3 bars each (in Base-4)

35
Error correction codes
Used in (tele)communications

Enable the decoding of transmitted information (barcodes) even


in the presence of some errors

By adding t check symbols to the data, a Reed Solomon code


can detect any combination of up to t erroneous symbols, and
correct up to t/2 symbols

36
Error correction code principles
Redundancy
e.g. sampling a received bit 3 times Triplet
Interpreted as
received
Majority of bits determines 000 0
most likely received bit 001 0
010 0
Inefficient 3 bits required 100 0
to encode 1 data bit! 111 1
Data-rate = 1/3 110 1
101 1
011 1

37
Error correction code principles Code
Data
word
Hamming distance is the number of bits that are 0000 0000000
different between two code words 0001 1101001
Adding extra bits to the data allows an increase in the 0010 0101010
0011 1000011
Hamming distance between code words
0100 1001100
In this example Hamming(7,4) code, if a single bit 0101 0100101
error occurs in a received code word, it is possible to 0110 1100110
unambiguously ascertain the transmitted code word 0111 0001111
1000 1110000
e.g. 0000001 has been received/decoded
1001 0011001
Assuming ONE bit error, the only possible transmitted
1010 1011010
code word is 0000000
1011 0110011
This code can detect, but not correct, TWO bit errors 1100 0111100

The code shown here has 3 redundancy bits for 1101 1010101
1110 0010110
4 data bits, a data-rate of 4/7.
1111 1111111

38
2D barcodes (example Datamatrix)
http://www.gs1.org/sites/default/files/docs/barcodes/GS1_DataMatrix_Introduction_and_technical_overview.pdf

2D bar code which may be printed as a square or rectangular


symbol made up of individual dots or squares

Ordered grid of dark and light dots bordered by a finder pattern,


partly used to specify the orientation and structure of the
symbol

Finder
pattern
Data

39
Datamatrix capacity
Grid size determines data capacity of barcode

Area used can be much smaller than 1D barcodes 144x144 grid


can encode 3116 numbers

40
Datamatrix encoding
Data encoded in 2D code words

Code words arranged in matrix

8-bit data in 2D code word 8 code words arranged in 88 matrix


41
Datamatrix encoding example
Data to be encoded:

Datamatrix output:
Raw data Binary image Finder pattern added

42
Datamatrix decoding
Requires 2D scanner

Typically requires camera or imaging


technology
Your phone probably has a 2D barcode
reader application
Physical scale of the code does not
matter
Apply image thresholding to grey scale
image to retrieve binary matrix

Incorporates Reed Solomon error correction


codes

43
Problems
8.1 Why is it important to track goods in the supply chain?

8.2 What are the main advantages of using bar codes to identify goods?

8.3 The UPC bar code employs a (7,2) code. Explain what a (7,2) code is in terms of
the number of modules employed, how they code information and how may unique
characters can be represented by the code.

8.4 Bar codes can be decoded in terms of their T values. Explain how the T values
are resistant to the spreading of ink when the bar code is printed.

8.5 How is the left most character (the one that is not coded in the stripes) in an
EAN-13 bar code encoded?

44
More Problems
8.6 For the following EAN-13 bar codes which ones contain an error?
a) 9310072022116
b) 8995077200098
c) 9300462348216
d) 9310755305037
e) 8004880211114

8.7 What is the trade off in using error detecting/correcting codes?

45

You might also like