Localize an optical code
20240078398 ยท 2024-03-07
Inventors
Cpc classification
G06K7/1439
PHYSICS
G06V30/224
PHYSICS
International classification
Abstract
A method for locating an optical code, on the basis of a finder pattern of the optical code, in an image having a plurality of pixels, the method comprising the steps of determining at least one candidate position for the finder pattern on the basis of edge transitions along at least one line through the image; determining a final position of the finder pattern in a vicinity of the candidate position; and verifying the final position, i.e. verifying that the image comprises the finder pattern in the final position, using a known property of the finder pattern.
Claims
1. A method for locating an optical code, on the basis of a finder pattern of the optical code, in an image having a plurality of pixels, the method comprising the steps of determining at least one candidate position for the finder pattern on the basis of edge transitions along at least one line through the image; determining a final position of the finder pattern in a vicinity of the candidate position; and verifying the final position, i.e. verifying that the image comprises the finder pattern in the final position, using a known property of the finder pattern.
2. The method according to claim 1, wherein the optical code is a QR code or an Aztec code.
3. The method according to claim 1, wherein the candidate position is determined when the edge transitions along the at least one line are spaced apart by a ratio of 1:1:3:1:1, taking into account a tolerance.
4. The method according to claim 1, wherein the candidate position is determined as the centroid of edge transitions along the at least one line.
5. The method according to claim 1, wherein, when the edge transitions along a plurality of mutually parallel lines are indicative of a finder pattern, the candidate position is determined centrally between the parallel lines.
6. The method according to claim 1, wherein, in order to determine the position of the finder pattern in a vicinity of the candidate position along beams emanating in a star shape from the candidate position, the three nearest edge transitions on each beam are determined.
7. The method according to claim 6, wherein the three nearest edge transition are determined on eight or sixteen beams at equal angular distance from one another.
8. The method according to claim 6, wherein at least one of a first ring, a second ring, and a third ring is formed, with the respective first edge transition of the beams being joined to form the first ring, the respective second edge transitions of the beams being joined to form the second ring, and the respective third edge transitions being joined to form the third ring.
9. The method according to claim 8, wherein confirmed ring sections of the rings are determined in that they run along an edge.
10. The method according to claim 9, wherein a Sobel filter is used to determine whether ring sections run along an edge.
11. The method according to claim 8, wherein ring sections of the rings are classified into horizontal and vertical ring sections, and wherein an orientation of the finder pattern is determined based on the horizontal and vertical ring sections.
12. The method according to claim 11, wherein an outermost ring section in each of the four main directions is selected according to the orientation, and wherein straight lines along the ring sections frame the location of the finder pattern.
13. The method according to claim 12, wherein, if no outermost ring section can be found in one of the main directions, the missing outermost ring section is reconstructed from other ring sections using a known structure of a finder pattern.
14. The method according to claim 1, wherein, in order to verify the finder pattern, seven mutually parallel half-lines are formed outwardly through one half of the finder pattern, starting from a main axis of the finder pattern and at a uniform distance from one another, and wherein it is required for the verification of the finder pattern that 1, 2, 3, 3, 2, 1 edge transitions lie in this sequence on each of the half-lines.
15. The method according to claim 14, wherein the distance of the edge transitions is additionally checked on at least one of the half-lines.
16. The method according to claim 1, wherein it is checked whether three finder patterns arranged to form a right-angled triangle are found in the image.
17. The method according to claim 1, wherein a region of the image localized on the basis of the finder pattern is fed to a decoder in order to read the optical code.
18. An optoelectronic code reading device comprising a light receiving element for recording an image comprising an optical code and a control and evaluation unit configured to locate an optical code, on the basis of a finder pattern of the optical code, in an image recorded using the light receiving element and having a plurality of pixels, in that at least one candidate position for the finder pattern is determined on the basis of edge transitions along at least one line through the image; a final position of the finder pattern in a vicinity of the candidate position is determined; and the final position is verified, i.e. it is verified that the image comprises the finder pattern in the final position, using a known property of the finder pattern.
Description
[0032] The invention will be explained in more detail in the following also with respect to further features and advantages by way of example with reference to embodiments and to the enclosed drawing. The Figures of the drawing show in:
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048] The code reader 10 uses an image sensor 24 to capture image data of the conveyed objects 14 and the codes 20, which are further processed by a control and evaluation unit 26 by means of image evaluation and a decoding process. For this purpose, the control and evaluation unit 26 has one or more computing modules, such as a microprocessor, an FPGA (field programmable gate array), a DSP (digital signal processor), an ASIC (application-specific integrated circuit), an AI processor, an NPU (neural processing unit), a GPU (graphics processing unit) or the like. Through an interface 28, the code reader 10 outputs information, such as read codes or image data possibly at various stages of processing.
[0049]
[0050] In a step S10, candidate positions for a finder pattern are found by evaluating the rows of pixels along mutually parallel scan lines through the image, preferably line by line. On these scan lines, when they cross a finder pattern, edge transitions lie at mutual distances characteristic of the finder pattern. In this way, the center of a suspected finder pattern can be roughly located. This position is called a candidate position because a candidate for a finder pattern has been detected there.
[0051] In a step S20, the vicinity of an edge position is further examined to precisely locate the finder pattern and confirm that it is a finder pattern. The result is the exact location of the finder pattern, for example in the form of a frame around those pixels that belong to the finder pattern.
[0052] In a step S30, the finder pattern is verified. After the exact location is known from step S20, the properties of the located finder pattern can be compared with the known properties of a finder pattern down to the level of individual code modules. Verification steps are possible which did not contribute to the finding in step S20 and which are in particular much more accurate. False positive finder patterns are thus filtered out very efficiently. This also makes it possible to remain somewhat more tolerant in step S20 and, for example, initially allow partially hidden finder patterns. Such an interplay of initially more generous selection in step S20 and then particularly precise verification in step S30 means that the vast majority of codes are found and they really are codes.
[0053]
[0054] In a step S12, the distances between the edge transitions of a scan line are checked. In the case of a scan line 32 through a finder pattern 30, six consecutive edge transitions 34 must have mutual distances in the ratio 1:1:3:1:1. This is because the finder pattern consists of a center with 3?3 code modules surrounded by two alternating rectangular rings of the width of one code module each. This results in the aforementioned 1:1:3:1:1 ratio for any direction of scan line 32 through the finder pattern. Thus, if six edge transitions 34 are found along a scan line 32 at intervals in the ratio 1:1:3:1:1, taking into account a tolerance, a finder pattern 30 is assumed at this location. The associated candidate position is preferably the center of the edge transitions, calculated for example as the common center of gravity of all edge transitions or only of the outermost of the six edge transitions considered.
[0055] In a step S13, candidate positions of successive scan lines 32 are combined into a candidate position 36, since this is not a new finder pattern in each case, but the same finder pattern 30 that is crossed a plurality of times by the successive scan lines 32. Again, there are various calculation methods, for example as the center of gravity of all edge transitions of the scan lines 32 concerned, only of the respective outermost edge transitions per scan line 32 and/or only of the outermost scan lines 32, or by determining a common center from the multiple candidate positions per scan line 32.
[0056]
[0057] In a step S22, the respective innermost, middle and outermost of the three edge transitions found for each beam 38 are connected to one another. If no three edge transitions could be found for a beam 38 in step S21, the corresponding point in ring 40 is omitted.
[0058] In the case that the candidate position 36 is located in a finder pattern 30 as in
[0059] Before doing that, it is referred to
[0060] In a step S23, the ring sections of the rings 40 are confirmed.
[0061] In a step S24, the ring sections 42, 44 are classified into two mutually orthogonal groups according to their direction. Preferably, only the confirmed ring sections 42 are used for this purpose. In
[0062] In a step S25, a ring section 42a-d preferably from the outer ring is found in each of the four main directions on both sides of the main axes 46a-b, i.e., to the right, left, up and down according to the now known orientation of the finder pattern 30. Once again, only confirmed ring sections 42 are preferably considered. Four straight lines along the found ring sections 42a-d form a frame around the finder pattern 30, whose position is thus now known. Optionally, the frame can be further refined by evaluating the surroundings of the straight lines, in particular additional scan lines orthogonal to the straight lines, and brought into an even better match with the finder pattern 30.
[0063] In a step S26, a ring section 42a-d is reconstructed if no ring section 42a-d could be found in one of the main directions, or in any case no ring section 42a-d of the outer ring.
[0064]
[0065] In a step S32 the edge transitions per half-line 50 are determined. For this purpose, the search needs to be performed only over a length of the half-line 50 that corresponds to half the size of the frame 48, possibly with a certain buffer. Edge transitions outside the frame 48 cannot be caused by a valid finder pattern 30.
[0066] In a step S33, the number of edge transitions found for each half-line 50 is compared with the number expected for a finder pattern 30, namely 1, 2, 3, 3, 2, 1 edge transitions for the seven half-lines 50 in this order. This required number is noted in
[0067] In an optional step S34, an additional condition can be checked, namely whether the distances or positions of the edge transitions on the respective half-line 50 are plausible. The one expected edge transition of the outer half-lines 50 is approximately at a distance of half the size of the finder pattern 30 and the frame 48, respectively, and this distance can also be expressed as 3? module sizes. The same expectation applies to the respective farthest edge transition of the other half-lines 50. The other half-lines 50 have additional inner edge transitions which are expected at a distance of 1? and 2? module sizes, respectively. Preferably, tolerances are to be provided for step S34 with respect to the expected distances and/or a ratio of the half-lines 50 which must satisfy the condition of step S34.
[0068] In addition to the steps of
[0069]
[0070] In particular for QR codes, a final test can check whether three finder patterns were located in an isosceles-rectangular triangle. Depending on the embodiment, finder patterns that do not meet this condition are immediately discarded, or, for example, an image area with only one or two finder patterns or a deviating arrangement of the finder patterns is only given lower priority or less decoder time in the decoder. The locating of finder patterns according to the invention can be applied in the same way to an Aztec code, in which case, of course, no three finder patterns are expected in a triangle, since an Aztec code has only a single finder pattern in the center. The invention can also be applied to other finder patterns, conditions specific to QR codes or Aztec codes, such as the ratio 1:1:3:1:1, must then be suitably adapted.
[0071] As can also be seen from the examples in