The invention relates to a technology for reading and decoding a two-dimensional code, and particularly to a two-dimensional code detection system and a two-dimensional code detection program for reading plural two-dimensional codes simultaneously and recognizing the respective two-dimensional codes accurately.
According to an aspect of the invention, a two-dimensional-code detection system includes a reading unit, a recognizing unit, a calculating unit and a position specifying unit. The reading unit reads an image including plural two-dimensional codes. The recognizing unit recognizes position detection patterns of the respective two-dimensional codes from the image, which includes the plural two-dimensional codes and is read by the reading unit. The calculating unit selects at least two of the position detection patterns of the plural two-dimensional codes read by the reading unit. The calculating unit calculates a minimum unit forming each of the selected position detection patterns. The position specifying unit judges whether or not the minimum units forming the selected at least two position detection patterns are substantially equal to each other. When judging that the minimum units forming the selected at least two position detection patterns are substantially equal to each other, the position specifying unit specifies a region of a two-dimensional code using the selected at least two position detection patterns.
Exemplary embodiment s of invention will be described in detail based on the following figures, wherein:
Exemplary embodiments of the invention will be described below with reference to accompanying drawings. This exemplary embodiment relates to an algorithm for recognizing respective two-dimensional codes from a single raster image data, when a two-dimensional code detection system and a two-dimensional code detection program according to this exemplary embodiment reads a paper document on which the two-dimensional codes (e.g. QR codes) are arranged with a flatbed scanner.
(Explanation of Entire System)
This system executes various processes on the basis of the decoded data. For instance, when the decoded data is an ID number (hereinafter, referred to as a document ID) identifying a document stored in a database, the system queries a database 6 with using the ID as a retrieving key, to acquire a document data body as a result of the query and print the document data body by using an image output device 5 such as a printer. Alternatively, the system may transmit the document data body to another computer via an external interface 4 and a network.
Hereinafter, exemplary embodiments will be described. QR codes are employed as an example of the two-dimensional code to be detected.
(Process Procedures of Entire System)
Next, the CPU 3 detects center coordinates of position detection patterns of the two-dimensional code (here, the QR codes) from the binarized raster image data (step S13). The QR code contains three position element patterns. As a detection method, the existing method (JIS X 0510, which is incorporated by reference in its entirety) is employed. That is, in order to detect the QR codes from the image, the CPU 3 scans the entire image and detects position element patterns. Thereafter, the CPU 3 calculates all center coordinates of the detected position element patterns.
The center coordinates of the detected position detection patterns have been calculated. At least two such position detection patterns are used (three in this exemplary embodiment) to indicate one bar code. At this step, it has not been known which combination of three position detection patterns indicates a bar code.
In a process of detecting a combination of position detection patterns (step S14), the CPU 3 determines a combination of three position detection patterns, which indicates a bar code. A method of determining the combination will be described in detail. On the basis of the thus determined combination of the three position detection patterns, the CPU 3 specifies a bar code area. Since a rotation angle of the bar code can be known from the relation among the three position detection patterns, the CPU 3 corrects the rotation angle of the bar code area for the bar code to erect the bar code area (step S15). Next, the CPU 3 trims the elected bar code area to decode the bar code (step S16). The existing decoding method (a method described in the JIS) is employed (step S17).
If plural bar codes areas are detected as a result of the combination detection, the CPU 3 performs rotation correction (step S15), trimming (step S16) and decodes process (step S17) on all the bar code areas. When all combinations are finished, the process is ended (step S18).
The detection of the combination of the position detection patterns in step 14 of
One QR code contains three position detection patterns. Therefore, if there are N QR codes, there are 3N center coordinates of position detection patterns. The CPU 3 acquires a list of the center coordinates (step 21).
Next, the CPU 3 selects three coordinates from among the 3N center coordinates, as a combination. A combination method selects 3 pieces from 3N pieces so as to perform a round robin system. The number of the combination is calculated by taking 3 pieces from 3N pieces. For instance, if number of the OR codes is 2, the number of the center coordinates of the position detection patterns is 2N=6, and the number of the combination selecting 3 pieces from 6 pieces is 20. If the number of the OR codes is 10, the number of the combination is 4,060 (see the following equation (1).
(Estimation of Module Size)
Next, the center coordinates of the selected three position detection patterns are referred to as X, Y, and Z, respectively. In addition, the CPU 3 calculates a module size from the position detection patterns to which the respective coordinates belong. The module size is a size of a unit square (minimum unit). The position detection patterns of the QR codes are formed of this module. Specifically, the width of an external frame of the position detection pattern is equal to seven modules.
In the same way, pixel values are checked in the vertical direction from the center point p0, points where pixel values change are calculated, and distances dy1, dy2, dy3, dy4 and dy5 between the points are calculated as shown in
In addition, only the horizontal distances dx1, dx2, dx3, dx4, and dx5 are calculated, and the estimated module size may be calculated on the basis of the following equation;
By using the above method, the module sizes Mx, My, and Mz of the three position detection patterns are calculated (step S22 to S24).
Next, the CPU 3 compares the module sizes Mx, My and Mz (step S25). That is, the module sizes calculated from the three position detection patterns forming one QR code are equal to each other. If the three module sizes are different, one QR code is not formed and therefore the CPU 3 does not evaluate the combination of the three. In contrast, when the three module sizes are almost equal, there is a possibility that one QR code is formed and therefore the CPU 3 proceeds to the subsequent process. For instance, when the difference between any two of the three module sizes is within a predetermined permissible range, the CPU 3 determines two module sizes are almost equal. Furthermore, a user may designate the permissible range. Since there are variation factors due to the image scanning, some margin may be permissible when the module sizes are evaluated.
(Evaluation of Isosceles Right Triangle)
Next, the CPU 3 evaluates whether or not the center coordinates X, Y and Z of the three position detection patterns whose module sizes are almost equal form an isosceles right triangle.
First, in
A process for determining whether or not the three points form the isosceles right triangle with the right angle located in each point will be described with reference to a flowchart shown in
Then, the CPU 3 determines whether or not the distance XY is equal to the distance XZ (step S44) and judges whether the angle θ=90° (step S45). If any of the judgments is true, the CPU 3 determines that the three points form the isosceles right triangle. If any of the judgments is false, the CPU 3 determines that the three points do not form the isosceles right triangle.
Turning to
A second exemplary embodiment relates to a method of calculating the module size when the position detection patterns are inclined.
(Estimation of Module from Inclined Position Detection Pattern)
As shown in
As shown in
As shown in
In a third exemplary embodiment, module sizes are calculated in the same way as the first and second exemplary embodiments, and a maximum size of the QR codes, which cab be taken, is calculated from the module sizes, and a position detection pattern only within the predetermined range is estimated.
(Specification of Maximum QR Size from Module Size)
The QR codes are defined from the model number 1 to the model number 40 in JIS. The largest number is the model number 40.
The module size Mx of the position detection pattern having the center point X has been already calculated. It is assumed that a distance between the position detection patterns of this QR code whose module size is D. In this case, D is equal to 170·Mx. Accordingly, a center point of the position detection pattern where a distance from the center point X is within D may form one QR code together with the center point X. In contrast, a center point of the position detection pattern where a distance from the center point X is longer than D cannot form one QR code together with the center point X. (see
The CPU 3 compares the distance D with the distances XY and XZ between the center points of the selected three position detection patterns (step S54 to S55). When the distances XY and XZ are shorter than the distance D (Yes in step S54 and S55), there is a possibility that the points X, Y and Z form one QR code. Therefore, the CPU 3 estimates whether or not the three points form the isosceles right triangle (step S56). The subsequent process is similar to the first exemplary embodiment. When the three points form the isosceles right triangle, the CPU 3 stores the three points X, Y and Z (step S57).
In the explained exemplary embodiment, the QR code is selected as the example of the two-dimensional code. The two-dimensional code detection method and the two-dimensional code detection program are applied to an image forming apparatuses such as a copier as well as a small apparatus such as a mobile phone and a mobile terminal. In addition, the two-dimensional code detection program may be stored in a predetermined storage medium to be distributed, or may be distributed through a network.
The foregoing description of the exemplary embodiments of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Obviously, many modifications and variations will be apparent to practitioners skilled in the art. The exemplary embodiments were chosen and described in order to best explain the principles of the invention and its practical applications, thereby enabling others skilled in the art to understand the invention for various embodiments and with the various modifications as are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the following claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
P2006-033216 | Feb 2006 | JP | national |
Number | Name | Date | Kind |
---|---|---|---|
5276315 | Surka | Jan 1994 | A |
5319181 | Shellhammer et al. | Jun 1994 | A |
5686718 | Iwai et al. | Nov 1997 | A |
5691527 | Hara et al. | Nov 1997 | A |
5726435 | Hara et al. | Mar 1998 | A |
5951056 | Fukuda et al. | Sep 1999 | A |
6181839 | Kannon et al. | Jan 2001 | B1 |
6267296 | Ooshima et al. | Jul 2001 | B1 |
6394349 | Shigekusa et al. | May 2002 | B1 |
6612497 | Iida et al. | Sep 2003 | B1 |
6678412 | Shigekusa et al. | Jan 2004 | B1 |
6685095 | Roustaei et al. | Feb 2004 | B2 |
6729542 | Iwai et al. | May 2004 | B2 |
6863218 | Muramatsu | Mar 2005 | B2 |
6918539 | Nakajima et al. | Jul 2005 | B2 |
20020051573 | Sakai et al. | May 2002 | A1 |
20050279832 | Kobayashi et al. | Dec 2005 | A1 |
20070069026 | Aoyama | Mar 2007 | A1 |
20070071320 | Yada | Mar 2007 | A1 |
Number | Date | Country |
---|---|---|
0 672 994 | Sep 1995 | EP |
A-06-012515 | Jan 1994 | JP |
B2-2938338 | Jun 1999 | JP |
Number | Date | Country | |
---|---|---|---|
20070187512 A1 | Aug 2007 | US |