Vous êtes sur la page 1sur 5

1

Recognition & Conversion of Barcode using


Camera Image
Amna Meer Reg. No.442 Aneeba Masood Reg. No.443

Asadullah Hussain Reg. No.404 Rahma Shaukat Gill Reg. No.456

BEE-5D

Abstract—In this report we present the method of Barcodes are used to encode specific information about the
deciphering the barcode using image processing, and product, for the ease of consumers and shopkeepers. Several
its implementation on Matlab®. 1D barcode labeling types of devices are there to read these barcodes, e.g., LED
is a commercial method to store information about a scanners, Laser scanners etc. These devices are cumbersome to
product for the checkout systems of large marts and use and are neither readily available nor mobile. This limits the
shopping centers. Nearly all products are labeled product information to the shop owners only, to aid costumers
with barcodes at the time of their manufacturing and in extracting this information, portable solution to the
sometimes shop owners label products using their deciphering of barcodes must be provided. One of these
solutions is the deciphering of the barcode using handheld
own barcodes. The conventional bar code scanners
devices such as mobile phones and digital cameras. These
are not portable as they need both a power source
devices take the picture of the barcode and then use either an
and a computer with the database of the product, to
online platform to extract the information about the product or
be read. Also they are not readily available. It would use some other kind of connectivity to the database containing
be convenient for the costumers to read and decipher the information about the product. Retrieval of such
these barcodes using their portable devices such as information is vital for people with medical afflictions towards
digital cameras and mobile phones, In order to gain some products and for the validation of price and legitimacy of
the specific information about the product provided the product. Many efforts have been made to achieve the
by the manufacturer. Our aim in this project was to deciphering using images of camera phone (see references for
take those barcode images taken by cameras and details). These methods may be more accurate but they are
decipher them. We used edge detection to find the computationally expensive and time consuming. So we have
edges of barcode and through the knowledge of the developed a method of robust deciphering [1] of the barcode
standard that the barcode is encoded in; we convert which is a practically viable solution. The details of our
the image into the decimal code. method and its Matlab® implementation are discussed next.

1. INTRODUCTION 2. OBJECTIVES

Barcodes is a machine readable encoding process. It is The main objectives of our project were:
being used extensively throughout the world. There are
different standards of the barcode, each having its pros and Read a Barcode from a camera image
cons. The latest barcode standard is EAN, which was formerly
Decode the barcode
known as “European Article Number” but now is called
Remove any type of noise that may occur
“International Article Number”. But we have chosen UPC,
Universal Product Code, because it is the most widely used
barcode and has an error detection mechanism in it, which aids
the deciphering process.
2

3. BARCODE DETECTION In this method without searching for the edges the scanline
binarizes all the pixels. The pixel selected first is the middle
The first step in the deciphering is the detection of barcode. one. To cater for the noises first the scanline pixels are
This can be easily achieved by several edge detection smoothed and then the luminance value Y(x) Ԑ [0, 1] is
techniques. We have employed the fact that barcode is an calculated for each pixel, whose position is given by:
intensity image. It contains vertical strips of black and white
lines. So we use the gray thresh value of the image to detect
the start and the end of the barcode strips. This can be .
achieved by the wavelet transform method [3] or by
morphological operations [10] but we want a method that is Then the local minima and maxima are computed. The
both quick and efficient so we use scanline based approach. Matlab® implementation is described in Appendix A.
This method uses the fact that a horizontal scanline is at the
center of the barcode. If the image of barcode is not centered
or the center region contains distortions then the algorithm will
simply shift the scanline above or below the center of the
image until we get non distorted region. The Matlab®
implementation is given in Appendix A.

Fig. 2 Block Diagram of our Algorithm, Input is an image of barcode.


Which is detected and binatized by scanline approach, then error
check and decimanl conversion are applied.

5. ERROR CHECKING

Fig. 1 The Scanline Approach [1]


Once the image has been binarized then all we have to do is to
use our knowledge about the construction of the barcode, this
in our case is achieved by the knowledge of UPC‟s encoding
4. BINARIZATION
process. In nearly all the Barcode standards we have a total of
13 decimal digits. The last is the parity bit. This digit is used
The next step is the Binarization of the image. We have to to provide the second step of the double error check.
distinguish the barcode i.e., black strips from the white
background i.e., spaces. First the start and the end of the
barcode is detected i.e., first black strip and last black strip. A. The UPC standard [12]
Then scanline scans the pixels from the center. Then the gray
thresh values are used to assign 1s to spaces and 0 s to strips. An UPC-A barcode consists of four areas:
If the gray thresh is other than that of black or white. We have
defined two ranges for gray thresh values, one range is allotted i. The number system
1 for white and other is assigned a binary 0 for black. If the ii. The manufacturer code
gray thresh value of a pixel lies within the white range it is iii. The product code
assigned binary 1 i.e., we say that this pixel is white or space iv. The check digit
but has been discolored, if it lies in other range then it is
assigned the opposite binary number i.e., 0 we say that the
pixel was black but has been decolored. In this way the
decolored pixels that may arise in the barcode image are
accounted for and thus a type of noise is taken care of. This
method is derived from the luminous method described in [1].
3

Number System is for the class or type to which the product


belongs.
To ensure that the scanline does not go outside the boundary
The manufacturer code is given to each manufacturer by UCC of the image, we set our starting position in the middle of the
council for companies. image, to the value where luminance is 0 or we start with a bar
(black). Then we scan left and right from this point by using
The product code is a 5-digit number that the manufacturer pre-determined steps or blocks of pixels. The choice of the
gives to his products. steps helps us in finding the guard bars, which are used for the
first step of the error detection.
The check digit verifies the validity of the product. It tells
whether the barcode has been scanned properly of not.
The error detection is as follows:
If
The first 3 bits of the binarized image are equal to 101.
The bit 46 is 0, 47 is 1, 48 is 0, 49 is 1 and 50 is 0.
The last three bits i.e., 93, 94 and 95 are equal to 101.

Then

The binarized image is a valid UPC code. If any one of the


above mentioned conditions is not satisfied then the code is
not a valid UPC code.

The Matlab® implementation is given in Appendix A

6. CONVERSION

Fig.3 A standard UPC-A barcode [10] For the conversion of the binarized image to the decimal we
again use our knowledge of the UPC construction. There is a
lookup table [14] with which we compare our bits.
The barcode begins & ends with a „101‟ or “black-white-
black” pattern, these are also termed as guard bars. Between
these guard bars, we have two blocks of black and white We ignore first and last 3 bits as they are the guard bits. Also
strips, separated by a central bar which is a „01010‟ or “white- we do not consider the central bits. As these bits are same for
black-white-black-white” pattern. The two blocks on either all the barcodes. Starting from the 4th bit (first three bits are
side of the central bar contain the decimal code, which is guard bits) and selecting seven bits at a time. These seven bits
different for each product. Each decimal digit is encoded by are compared with the lookup table of Figure 2 and by
using 7 bits. Even and Odd alphabets are used for the comparison we allocate decimal values to the block of seven
encoding. First digit is called the meta-number or induced bits. We can see from the table that if we are looking at bits to
digit [1]. the left of the central bits then we use the “Left Bit Pattern”
column to compare, while if we are looking at bits on the right
of the central bits we use the “Right Bit Pattern”.

Digit Left Bit Pattern Right Bit Pattern


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

Fig. 4 A typical UPC barcode. Guard bars are highlighted green [14]
4

Once the 12 digits have been calculated the check sum bit is The Matlab® implementation is given in Appendix A
calculated, it is calculated by the following method [14]
1. The digits that are in the odd numbered positions are
added and multiplied by 3. 8. CONCLUSION

2. The digits in the even numbered positions are added. Hence we are able to achieve all of our preset objectives for
this semester project, i.e., we have successfully deciphered
3. The sum of even numbered is added to the sum of UPC barcode using image processing techniques in Matlab®.
odd numbered. We were also able to account for minor noise distortions as in
Figure 5 (d). For future our next step will be to remove as
4. The result is modulo 10.
many types of noises as we can from the image and add
5. If the result is zero then check bit is zero. Otherwise support for other barcode standards such as EAN and Codabar
subtract it from 10 and the answer is the result. as well.

9. ACKNOWLEDGMENTS
We would like to thank Mr. Saad Qaisar and Ms. Jaweria
Amjad for their support throughout the semester.

1) Dr. Saad Qaisar


saad.qaisar@seecs.edu.pk
7. EXPERIMENTS 2) Jaweria Amjad
jaweria.amjad@seecs.edu.pk .
We used a database of images [15]. To test our project using
Matlab®. The Experiments were very assuring and we reached 10. REFERENCES
a success rate of 97%. We also used images which were
affected by minor noise. [1]. Robust Recognition of 1-D Barcodes Using Camera
Phones by Steffen Wachenfeld, Sebastian Terlunen,
Xiaoyi Jiang, Computer Vision and Pattern Recognition
Group, Department of Computer Science, University of
M¨unster, Germany, 2006.

[2]. Mastering Matlab 7 by Duane Hanselman, Bruce


Littlefield
Fig. 5 (a) (b)
[3]. K. Wang, Y. Zou, H. Wang: 1D Bar Code Reading on
Camera Phones. Int. Journal of Image and Graphics,
7(3):529–550, 2007.

[4]. S. Wachenfeld, S. Terlunen, X. Jiang:


http://cvpr.uni-muenster.de/research/barcode

(d) (e) [5]. R. Muniz, L. Junco, A. Otero: A Robust Software Barcode


Images (a) - (e) Successfully Deciphered Reader Using the Hough Transform. In Proc. of the Int.
Conf. on Information Intelligence and Systems, 313–319,
1999.

[6]. E. Ohbuchi, H. Hanaizumi, L. A. Hock: Barcode Readers


Using the Camera Device in Mobile Phones. In Proc. of
the Int. Conf. on Cyberworlds, 260–265, 2004.

[7]. A Bayesian Algorithm for Reading 1D Barcodes; Ender


(f) Decoding Unsuccessful Tekin, James Coughlan, The Smith-Kettlewell Eye
Research Institute
5

[8]. Reading Challenging Barcodes with Cameras, Orazio


Gallo and Roberto Manduchi, University of California,
Santa Cruz

[9]. R. Adelmann, M. Langheinrich, C. Fl¨orkemeier:


Toolkit for Bar Code Recognition and Resolving
on Camera Phones – Jump Starting the Internet of
Things. Workshop on Mobile and Embedded Interactive
Systems (MEIS’06) at Informatik, GI LNI,
2006.

[10]. D. Chai, F. Hock: Locating and Decoding EAN-13


Barcodes from Images Captured by Digital Cameras.
5th Int. Conf. on Information, Communications
and Signal Processing, 1595–1599, 2005.

[11]. E. Joseph, T. Pavlidis: Bar Code Waveform Recognition


Using Peak Locations. IEEE Trans. on
PAMI, 16(6):630–640, 1998.

[12]. http://www.morovia.com/education/symbology/upc-a.asp

[13]. http://www.morovia.com/education/utility/upc-ean.asp

[14]. en.wikipedia.org

[15]. http://www.google.com/imghp

Vous aimerez peut-être aussi