The present invention relates generally to an apparatus and method for recognizing a barcode and, more particularly, to an apparatus and method for recognizing a barcode, used for a mobile terminal with a photographing means.
It is known that barcodes were first invented in 1932 through a thesis entitled “automation of calculation in supermarket” by Wallace Flin, and are currently printed on almost all items. A point of sale (POS) system automatically manages a buying process or a selling process using the barcodes. Further, the use of the barcodes has been rapidly increased with development of information technology (IT) for mail automation, factory automation, inventory control, library management, documentation management, and medical information management.
The barcodes are classified into two categories, that is, 1-dimensional barcodes such as Universal Product Code (UPC), European Article Numbering (EAN), Korean Article Numbering (KAN), code39, code93, and code128, and 2-dimensional barcodes such as code49, code16K, PDF-417, codablock, datacode, vericode, softstrip, and code1. The 2-dimensional barcode can contain up to 5,000 letters.
Readers for recognizing the barcodes include a laser reader, a light emitting diode (LED) reader, and a charge coupled device (CCD) reader according to devices used for the readers. Among them, the laser reader has been widely used because it can rapidly recognize the barcode. However, the laser reader is problematic in that it may recognize only the 1-dimensional barcode and is relatively expensive.
In recent years, there have been developed many readers using the CCD that can recognize the 2-dimensional barcode containing much information.
Meanwhile, with the advent of a smart phone, an application for acquiring a barcode image in real time and searching for a price and a bottom price of goods is developed.
A barcode signal is configured by continuously combining black and white modules, and information is encoded depending on a width of each module and a ratio of the modules. In order to precisely decode information, a size of each module must be restored within a margin of error. However, a barcode image acquired by a photographing means such as a camera may be blurred by focusing of the camera, and image noise may be caused by non-uniform illumination and barcode exposure environment at the time of acquiring the image. Thus, these factors must be overcome.
Accordingly, the present invention has been made keeping in mind the above problems occurring in the prior art, and an object of the present invention is to provide an apparatus and method for recognizing a barcode, intended to detect peaks of white and black modules of a barcode and to estimate a size of each module, thus enabling the barcode to be precisely recognized.
In order to accomplish the above object, there is provided an apparatus for recognizing a barcode, the apparatus comprising an extraction unit for selecting and interpolating X-axis data at an arbitrary Y-axis of the barcode; a restoration unit for detecting peaks of black and white modules of the barcode and restoring the barcode; and a decoding unit for estimating widths of the black and white modules, extracting binary data and decoding the binary data.
In a preferred embodiment, the extraction unit includes a selection unit for selecting the X-axis data at the arbitrary Y-axis, and an interpolation unit for interpolating the X-axis data selected by the selection unit using a predetermined interpolation method.
In another preferred embodiment, the selection unit converts RGB types of X-axis data into black-and-white data.
In still another preferred embodiment, the selection unit converts RGB types of X-axis data into peaked data when intensity of a white module signal is high and peaked data when intensity of a black module signal is high.
In yet another preferred embodiment, the interpolation method includes cubic spline interpolation.
In still yet another preferred embodiment, the restoration unit includes a peak detection unit for detecting the peaks of the black and white modules; a barcode-region detection unit for detecting an effective barcode region from output of the peak detection unit; a normalizing unit for removing a baseline; and an estimation unit for converting an output of the normalizing unit into a square wave.
In a further preferred embodiment, the peak detection unit detects peaks of the black and white modules using a descending slope trace wave (DSTW) method.
In another preferred embodiment, the peak detection unit obtains a DSTW signal for each of the black and white modules, detects a point where a difference between each of the black and white modules and the corresponding DSTW signal exceeds a predetermined value, and determines a point where previous data becomes zero (0) as a peak.
In still another preferred embodiment, the barcode-region detection unit removes an unnecessary peak from the peak of the data received from the peak detection unit, thus detecting the effective barcode region.
In yet another preferred embodiment, the barcode-region detection unit detects a position from which the effective barcode starts, thus detecting a predetermined number of peaks of subsequent black and white modules.
In still yet another preferred embodiment, the barcode-region detection unit calculates a difference in position between a subsequent peak and a current peak, and detects a position where the difference in position between the subsequent peak and the current peak is greater than a sum thereof and a predetermined weight, thus determining the detected position as a position from which the effective barcode starts.
In a further preferred embodiment, the barcode-region detection unit detects a predetermined number of peaks of black and white modules subsequent to the position from which the effective barcode starts.
In another preferred embodiment, the normalizing unit calculates a mean of peak data, thus removing distortion of the baseline.
In still another preferred embodiment, the decoding unit performs decoding in ASCII.
In yet another preferred embodiment, the decoding unit estimates a distance between pixels of the black and white modules from the output of the normalizing unit.
In still yet another preferred embodiment, the decoding unit sorts distances between the pixels, and determines a module width based on a boundary value depending on the module width.
In a further preferred embodiment, the decoding unit converts binary data of the module width.
Further, in order to accomplish the above object, there is provided a method for recognizing a barcode, comprising steps of selecting and interpolating X-axis data at an arbitrary Y-axis of the barcode; detecting peaks of black and white modules of the barcode and restoring the barcode; and estimating widths of the black and white modules, extracting binary data and decoding the binary data.
The present invention is advantageous in that peaks of white and black modules of a barcode are detected and a size of each module is estimated to recognize a barcode, thus achieving a high barcode recognition rate even under environment where there are non-uniform illumination, blurring and white noise.
a is a view illustrating an example of a general barcode;
b is a graph illustrating data selected by a selection unit according to an embodiment of the present invention at an arbitrary Y-axis data of
a is a view illustrating an image photographing a real barcode;
b is a graph illustrating data selected by the selection unit according to the embodiment of the present invention at an arbitrary Y-axis data of
a and 8b are graphs illustrating kinds of peaks in which a DSTW signal and an original signal are separated;
a and 9b are graphs illustrating a process of detecting peaks of GB and GW signals, respectively;
c is a graph extending
a is a view illustrating a barcode image actually acquired according to an embodiment of the present invention;
b is a graph illustrating peaks detected in
c is a graph illustrating a result of detecting effective barcode peaks of
a is a graph illustrating a method of finding a mean of peak data using a normalizing unit of
b is a graph illustrating a baseline obtained by the normalizing unit of
c is a graph illustrating a result obtained after the normalizing unit of
a and 13b are graphs illustrating determination of a module width based on a distance between pixels and a boundary value condition; and
Since the present invention may be variously changed and include several embodiments, particular embodiments shown in the drawings will be described in detail in the detailed description.
However, it is to be understood that the invention is not limited to the particular embodiments, and various changes, equivalences and substitutions may be made without departing from the scope and spirit of the invention.
Although the terms “first”, “second”, etc. are used herein to describe various components, these components should not be limited by these terms.
These terms are only used to distinguish one component from another component. For example, the second component may be designated as the first component without departing from the scope of the invention. Similarly, the first component may be designated as the second component.
Further, when the term “couple” or “connect” is used in the specification or claims, it is intended to mean not only “directly coupled or connected to” but also “indirectly coupled or connected to” such as connected through another component or components. In contrast, the term “directly coupled or connected to” means that there is no component between the coupled or connected components.
Also it is to be understood that terms employed herein are for the purpose of description of particular embodiments and not of limitation.
Further, the singular forms “a” and “an” include plural referents unless the context clearly dictates otherwise.
Furthermore, it should be understood that terms “include” or “have” are inclusive of characteristics, numerals, steps, operations, components, parts or combination thereof, which are described herein, but are not exclusive of one or more different characteristics, numerals, steps, operations, components, parts or combination thereof.
It should be understood that the appended drawings are not necessarily to scale for the convenience of description.
Now, the present invention will be described in detail with reference to the accompanying drawings, in which the same reference numerals are used throughout the different drawings to designate the same or similar components and a duplicated description thereof will be omitted.
As shown in the drawing, a user photographs a barcode 100 using a photographing means such as a camera installed in a mobile terminal 200. An apparatus for recognizing a barcode according to an embodiment of the present invention is received in the mobile terminal 200 to more precisely recognize the barcode acquired by the photographing means.
In the present invention, the term of ‘recognition of the barcode’ means the decoding of information in the barcode 100 acquired by the mobile terminal 200 having the photographing means such as the camera. Here, the mobile terminal 200 means a portable terminal carried by a user, and includes a cellular phone, a smart phone, a tablet computer, a lap-top computer, etc.
As shown in the drawing, the barcode recognizing apparatus 1 of the present invention includes an extraction unit 10, a restoration unit 20 and a decoding unit 30.
The extraction unit 10 selects X-axis data for any one point of a Y-axis barcode region, from an image photographed and acquired by the photographing means, and extends the number of X-axis pixels using a predetermined interpolation method (e.g. spline interpolation) to provide high resolution. This will be described in more detail with reference to
The selection unit 11 selects X-axis data in any Y axis within an (X, Y) area of the acquired barcode.
If the X-axis data is extracted for any Y axis (see A in
G
W
[n]=R[n]+G[n]+B[n],1≦b≦Xresolution <Equation 1>
G
B
[n]=arg
max(GW[n])−GW[n],1≦n≦Xresolution <Equation 2>
In the above equations, GW[n] denotes a peaked signal when intensity of the white module is high, and GB[n] denotes a peaked signal when intensity of the black module is high.
b is a graph illustrating data selected by the selection unit 11 according to an embodiment of the present invention at an arbitrary Y-axis data of
a is a view illustrating an image photographing a real barcode, and
Thus, the interpolation unit 12 of
The restoration unit 20 of
As shown in the drawing, the restoration unit 20 of the present invention includes a peak detection unit 21, a barcode-region detection unit 22, a normalizing unit 23 and an estimation unit 24.
The peak detection unit 21 detects the peak of the interpolated signal. The peak detection unit 21 of the present invention performs a peak detecting operation using a descending slope trace wave (DSTW) method. The DSTW method is originally created to detect a peak of an electrocardiogram signal, and shows an excellent peak detection rate in a signal having various frequencies and phases. Since the formation of a DSTW signal for an original signal is known to those skilled in the art, a detailed description thereof will be omitted.
As shown in the drawing, the DSTW(n) traces the x(n) from point a to point p. The DSTW(n) has an interval tH from point p to point d. Thereafter, DSTW(n) traces x(n−tH) until it becomes equal to or less than x(n). Here, tH may be optionally adjusted according to characteristics of a signal.
In order to generate an initial DSTW(n), a peak p must be detected at x(n). When detecting the peak p, the characteristics of the signal are divided as shown in
If the peak p is selected and the DSTW(n) is formed, the peak detection unit 21 detects the peak using the following equations 3 and 4.
Diff(n)=DSTW(n)−x(n),1≦n≦10,000 <Equation 3>
Threshold=Argmax[Diff(n)]×Weight,1≦n≦10,000 <Equation 4>
Here, ‘Weight’ is a value ranging between 0 and 1. The peak detection unit 21 detects a point exceeding a ‘Threshold’ at Diff(n), and determines a point at which previous data becomes 0, as a peak. That is, the point satisfying the following equation is detected and is determined as the peak.
if(Diff(n)<Threshold)
While(Diff(n)≠0) <Equation 5>
This point is a point p from which DSTW(n) and x(n) are separated, as shown in
a and 9b are graphs illustrating a process of detecting peaks of GB and GW signals, respectively, and
a is a view illustrating an actually acquired barcode image, and
That is, the barcode-region detection unit 22 detects a barcode region using characteristics wherein the image of the barcode is printed on a white background and each of the black and white modules of the barcode is set to be 30, in the case of a Universal Product Code (UPC)-A barcode, for example.
Referring to
P
D(n)=Index[PB(n−1)]−Index[PB(n)],1≦n≦Number of Peak/2 <Equation 6>
T
D(n)=mean(PD(n))+w,1≦n≦Number of Peak/2 <Equation 7>
if(PD(n)<TD(n)),DP=n,1≦n≦Number of Peak/2 <Equation 8>
In equation 6, Index[PB(n)] means an index (position) of the peak, PB(n) denotes the peak of the GB signal, and PD(n) denotes a difference in position between a subsequent peak and a current peak.
In equation 7, TD(n) means the ‘Threshold’, which is the sum of the weight (w) and the mean of PD(n). In this case, w varies depending on resolution of the camera.
In equation 8, PD(n) exceeding TD is detected, where n is an index (position) from which the effective barcode starts. Thereafter, a predetermined number of peaks is detected for the black and white modules.
For example, in the case of the UPC-A barcode, 30 peaks are detected for each of the black and white modules.
Meanwhile, a gray signal obtained from the barcode image is caused by non-specific illumination when acquiring an image, and distorts a baseline of a signal as shown in
In equation 9, PB(n) and PW(n) are peaks in the GB signal for the black and white modules, respectively, and P(k) is a vector that is the position sum of the modules. C denotes a mean of peak data of the GB signal at which P(k) and P(k+1) are located. If C is calculated, a position of C in the GB signal, R(k) must be found, which is represented in equation 10.
a is a graph illustrating a method of finding a mean of peak data using the normalizing unit of
As shown in the drawing, if k is an odd number, R(k) is found when the GB signal is greater than C. In contrast, if k is an even number, R(k) is found when the GB signal is less than C. After R(k) is obtained for the whole signal GB, the baseline connecting R(k) points to each other should be made. To this end, the normalizing unit 23 uses linear interpolation of equation 11.
b is a graph illustrating a baseline of
B
R(i)=2×mean[B]−B(i),1≦i≦10,000
G
BF(i)GB(i)+BR(i) <Equation 12>
c is a graph illustrating a result obtained after the normalizing unit 23 of
The estimation unit 24 of
Since the GB signal from which the baseline is removed by the normalizing unit 23 takes a shape of a sine wave, it is difficult to determine a size of the module. Thus, the estimation unit 24 converts the sine wave into the square wave, as shown in
In equation 13, CF is a reference of GBF(i) for generating a square wave. If GBF(i) exceeds CF, a maximum value of GBF(i) is inputted into L(i) of equation 14. In contrast, if GBF(i) is less than CF, a minimum value of GBF(i) is inputted into L(i) of equation 14. Such a conversion allows a square wave of
For such a signal converted into the square wave, the decoding unit 30 of
It will be described below in detail.
Each of the black and white modules of the barcode comprises modules having four kinds of widths from 1 to 4. When acquiring the real barcode image, the pixel size of one module is variably changed for several reasons, including illumination, rotation of the subject, tilting of the camera, and auto focusing conditions. Here, a distance between pixels of each module may be calculated using L(i) of equation 14, and each width from 1 to 4 of each module may be estimated.
a and 13b are graphs illustrating determination of a module width based on a distance between pixels and a boundary value condition.
If distances between pixels are arranged in descending order, it can be observed that they are shown in waveform as shown in
After widths of the black and white modules of the barcode are determined, the decoding unit 30 generates binary data. Assuming that the module width is 1, 2, 3 and 4, respective black modules are arranged in 1, 11, 111 and 1111 and respective white modules are arranged in 0, 00,000 and 0000. Afterwards, data is converted into an ASCII code by ASCII decoding that is widely known to those skilled in the art.
As shown in the drawing, the barcode recognizing method of the present invention acquires the image of the barcode by the photographing means (not shown) installed in the mobile terminal 200, at S141. The extraction unit 10 extracts X-axis data at any one point of the Y-axis barcode region, at S142.
In order to achieve high resolution, an X-axis pixel is extended to 10,000 pixels for example, using a predetermined interpolation method such as cubic spline interpolation, at S143.
Thereafter, the restoration unit 20 detects peaks of the black and white modules of the barcode from the interpolated data at S144. From the detected peaks, effective data is extracted, and an estimated barcode is restored at S145.
Subsequently, the decoding unit 30 calculates a distance between the black and white modules and a thickness of each module in the estimated barcode at S146, binary data is extracted using the thickness, and the ASCII data is decoded based on the binary data at S147.
Finally, the recognizing method of the present invention verifies an error through a parity check at S148. If there is a parity error at S149, the process proceeds to S142 and repeats the above steps. The parity check means a process of checking whether an error occurs using a parity bit (a bit that is added to an information bit to display whether an error occurs when information is transmitted). Since the parity check is widely known to those skilled in the art, a detailed description thereof will be omitted herein.
Meanwhile, the embodiments of the present invention may be implemented by recording a computer-readable program code on a recording medium that may be read by a computer. When the embodiments of the present invention are executed using software, components of the present invention are code segments for executing required operation. Further, programs or code segments may be stored in a medium that may be read by a processor of the computer, or may be transmitted through a transmission media or communication network in a computer data signal combined with a carrier wave.
The computer-readable recording medium may include all kinds of recording devices storing data that may be read by a computer system. For example, the computer-readable recording medium may include a ROM, a RAM, a CD-ROM, a magnetic tape, a floppy disk, an optical-data storage device, etc.
Further, computer-readable recording media may be distributed throughout computer systems connected via networks to store and execute computer-readable codes in a distributed manner.
Although the preferred embodiments of the present invention have been disclosed for illustrative purposes, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, without departing from the scope and spirit of the invention as disclosed in the accompanying claims.
Number | Date | Country | Kind |
---|---|---|---|
10-2010-0129184 | Dec 2010 | KR | national |
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/KR2011/008560 | 11/10/2011 | WO | 00 | 6/13/2013 |