Locating the optical code
The method improves optical code localization by using edge transitions and geometric verification to reduce errors, enhancing sensitivity and specificity for efficient real-time decoding.
Patent Information
- Application Number
- JP2023122278
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2022-09-02
- Filing Date
- 2023-07-27
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2043-07-27
AI Technical Summary
Existing code reading technologies struggle with high error rates in locating optical codes due to interference, distortion, occlusion, and blurring, leading to inefficient decoding processes.
A method for identifying the position of optical codes using a computer-implemented approach that involves locating candidate positions based on edge transitions, verifying the search pattern through geometric attributes, and employing a verification step to ensure accuracy, thereby reducing false detections.
The method achieves low error rates in locating optical codes, ensuring high sensitivity and specificity, allowing for real-time decoding and increased read rates by processing only valid code regions.
Smart Images

Figure 0007571217000001 
Figure 0007571217000002 
Figure 0007571217000003
Abstract
Description
[Technical field]
[0001] The present invention relates to a method for determining the location of an optical code according to the preamble of claim 1 . [Background technology]
[0002] Code readers are known for their use in logistics, such as at supermarket checkouts, automatic baggage identification, mail sorting, and baggage dispatch at airports. In a code scanner, the reading beam is guided across the code by a rotating mirror or polygon mirror wheel. Camera-based code readers use an image sensor to take an image of an object with a code on its surface, and image analysis software extracts the code information from the image.
[0003] In one important group of applications, objects bearing codes are conveyed past a code reader. A scanning code reader detects each successive code that enters its reading field. In camera-based code readers, on the other hand, a line-scan camera reads the object image containing the code information line by line as it moves relative to the object. When using a two-dimensional image sensor, multiple image data are regularly acquired, with some overlap depending on the imaging rate and the conveying speed. To allow objects to be positioned on the conveyor in any orientation, multiple code readers are often provided in the reading tunnel, so that the object can be imaged from several or all sides. Scanning code readers can also capture diffuse reflected light and ultimately capture multiple image lines that can be combined into an object image, but in practice image sensors are preferred for this purpose. Code areas can be identified in such object images and the code can be read.
[0004] Decoding is a relatively expensive process. Therefore, preprocessing usually focuses on only those image fragments in which the optical code has been recognized, and passes them to the decoder, preferably together with other information such as the exact position and orientation of the code as well as its type and size. Some types of codes aid location by means of easily and robustly recognizable search patterns (finder patterns). For example, the QR Code has a search pattern in three corners for this purpose, while the Aztec code has one in the center. The search pattern itself consists of 7x7 code modules, with a central 3x3 field surrounded by two alternating rings or rectangles.
[0005] In theory, such a search pattern should be easy to find based on known attributes. To do this, the image is searched line by line for edge transitions characteristic of the search pattern, and an estimation box is set around the search pattern based on the edge transitions. However, real images have interferences, distortions, occlusions, lack of contrast and blurring. It is therefore necessary not to make the edge transition conditions for the search pattern too strict. This would increase the number of false positives of the search pattern depending on the tolerance, so that the decoder still processes image areas that in fact do not have any code at all. Conversely, partially occluded search patterns are often rejected in the past, and the code there is then missed and not read. Thus, in order to minimize the number of errors of the first and second types mentioned above, high sensitivity and specificity in locating the code is desired. However, this has not been achieved satisfactorily in the prior art.
[0006] There are other approaches to finding search patterns, including template matching, Haar features, and machine learning, but they still produce similar errors, and while machine learning in particular seems capable of producing better results in principle, it is not possible to do so with the hardware typically available for code reading, or with the short response times required for real-time code reading.
[0007] US Pat. No. 5,399,433 discloses a system for recognizing and decoding QR codes, which generates a search pattern and thus a template for pattern matching to find the code.
[0008] In US Pat. No. 5,399,436, the search pattern along the scan line is recognized based on a specific spacing between black and white transitions. The document does not discuss how to handle tolerances and errors. US Pat. No. 5,399,436 cites US Pat. No. 5,399,436 in its introduction and similarly seeks a known structure of the search pattern line by line. [Prior art documents] [Patent documents]
[0009] [Patent Document 1] US 9 355 293 B2 [Patent Document 2] US 2004 / 0020989 A1 [Patent Document 3] US 7 546 950 B2 Summary of the Invention [Problem to be solved by the invention]
[0010] It is therefore an object of the present invention to improve the localization of optical codes. [Means for solving the problem]
[0011] This problem is solved by a method for determining the location of an optical code as described in claims 1 and 15, respectively, and by an optoelectronic code reading device in which said method is implemented. To be clear, this is an automatically operating method, in particular a computer-implemented method, for example running in the code reader or in a computing device connected thereto (control device, computer, edge device, network, cloud, etc.). An image is taken, which is supposed to show at least one optical code, in particular a QR code or an Aztec code. As explained at the beginning, this can be done in one exposure or one after another during a relative movement, in which case the brightness profile of the code scanner can also be interpreted as an image line. The image comprises a pixel raster with a large number of pixels, typically m×n pixels.
[0012] The code is located using at least one search pattern (finder pattern). First, candidate positions that at least at first glance appear to be part of the search pattern are located. To this end, edge transitions along at least one line that crosses the image are identified. An edge is the name given to a transition between a dark and a light code element, or conversely between a light and a dark code element. It should be noted that the code elements are really black and white only in the binarized image, otherwise for the sake of simplicity no distinction is made here between white and light and black and dark gray shades. The line preferably runs along the row or column direction. Other directions are in principle possible, but they are more expensive to implement and may lead to discretization artifacts.
[0013] The search pattern is then located around the candidate positions. The candidate positions are still fairly coarse, e.g. single points approximately at the estimated centers of the search patterns. The search pattern positions, on the other hand, indicate which pixels belong to the search pattern, e.g. in the form of a frame surrounding the search pattern. The specific form of representation is not important and is not limited, e.g. as corners or as a surrounding rectangle.
[0014] The basic idea from which the invention starts is to re-verify a search pattern that has already been found up to its location. The location (e.g. frame) of the search pattern can be used to check the attributes of the pattern (such as module size) up to the individual code modules. A code module, or module for short, is the smallest element of a code. Correspondingly, the module size, which is a measure of the size of a module, is expressed in pixels per module (ppm). Since it is perfectly known how the search pattern should look, it is possible to check other attributes of the search pattern to be verified that have not yet been used to identify its location, at least in this form, or to carry out check steps that have not been used to find its location.
[0015] The invention has the advantage that the error rate in locating the search pattern and ultimately the optical code is low. The search patterns can be recognized in a somewhat tolerant way, including partially hidden search patterns and those where edge recognition occasionally fails, for example due to lack of contrast. Search patterns are therefore hardly ever overlooked. Any search patterns that are initially incorrectly accepted are reliably rejected correctly by the verification at the end. Overall, therefore, the rate of errors of the first and second types is low. Or, expressed positively, both the sensitivity and specificity of the recognition of the search pattern and thus of the code are very high. Since simple geometric operations are required, with only a few accesses to the pixels of the image, the method works efficiently and quickly, so that it can be applied in real time or requires only a small part of the short time window available for decoding in the reading tunnel. The decoder is presented with almost the entire code very quickly (sensitivity), but does not have to waste calculation time on image areas that do not actually contain any code at all (specificity). This increases the reading rate and therefore the most important quality criterion when used for code reading.
[0016] Preferably, candidate positions are determined if the edge transitions along said at least one line are spaced from each other in a ratio of 1:1:3:1:1, taking into account a tolerance. This corresponds to the convention of the search pattern of a QR code or an Aztec code with an inner 3x3 square and two surrounding rectangular rings. A special feature of this search pattern is that this spacing ratio exists in all directions and is therefore completely independent of the orientation of the code and applies to lines in any predefined direction, in particular the row direction of the image. Since said spacing ratio cannot be expected exactly in a real image, it is preferable to allow for a tolerance.
[0017] The candidate position is preferably determined as the centroid of the edge transitions along the at least one line. The candidate position should be as central as possible within the search pattern, which is achieved once in the line direction by this centroid formation. In the perpendicular direction, the center of the search pattern cannot be far away anyway, because otherwise the edge transition condition in the line direction would not be fulfilled. In particular, the spacing ratio of 1:1:3:1:1 only appears for lines passing through the central 3x3 grid. There are various ways to calculate the centroid, for example the middle between both outermost edge transitions or the average of all edge transitions.
[0018] Preferably, the candidate position is determined to be the center between parallel lines when the edge transitions along the parallel lines point to the search pattern. From the edge transitions of adjacent parallel lines, the cross section of the search pattern, in particular the edge transition spacing ratio of 1:1:3:1:1, can be inferred. The center of the search pattern is then expected to be on the middle line, or between the two middle lines if there is an even number of lines in question. This center can be found in two steps: first, the center of gravity is determined for each line as in the previous paragraph, and then the center of gravity of the center of gravity in the direction perpendicular to the line direction is determined. However, the calculation can be arbitrarily performed, for example, for all the edge transitions of the lines in question, or only for the outermost edge transitions or lines, respectively.
[0019] In order to locate the search pattern around the candidate position, it is preferable to locate the three closest edge transitions along rays extending radially from the candidate position, in particular along 8 or 16 rays spaced at the same angle from each other. The candidate position was initially found based only on lines of the same direction (in particular row direction). The radial rays now locate the search pattern more accurately in all directions. In this case, preferably 8 directions offset by 45 degrees from each other or 16 directions offset by 22.5 degrees from each other are used. A further narrowing of the angle raster is too costly without significant improvement. An uneven angle raster is also conceivable, but it makes an unreasonable implicit assumption that some directions are more important. An even division by other numbers of rays (for example 7) has the disadvantage that the slope of the rays is no longer a simple value such as 1 / 2, 1 or 2, which leads to discretization errors. The three closest edge transitions pass through two rectangular rings surrounding the candidate position if it is actually more or less central in the search pattern. As an optional step, one can check whether the spacing of the edge transitions appears to coincide with the crossing of the two rectangular rings in all directions, or at least in most directions.
[0020] Preferably, a first edge transition of each of the rays is connected to form a first ring, a second edge transition of each of the rays to form a second ring, and / or a third edge transition of each of the rays to form a third ring, which are thus far estimated approximations of the edges between the center of the search pattern and the rectangular ring.
[0021] Preferably, ring fragments of said rings are found that extend along the edge and are considered valid, in particular by using a Sobel filter. The edge transition along said ray may not actually match a rectangular ring of the search pattern for various reasons, either because there is no search pattern at all at the candidate location, or because the edge transition along a ray is hidden, has low contrast or is overlooked by the criteria set for edge transitions. Therefore, an additional check is useful whether the ring fragment really extends along the edge of the search pattern. The three rings are then divided into valid and non-valid ring fragments, and further processing is preferably performed using only the valid ring fragments. If there are no or too few valid ring fragments, the processing for this candidate location can be interrupted. One preferred way to check the validity of the ring fragment is by using a Sobel filter.
[0022] Preferably, the ring fragments are classified into horizontal and vertical ring fragments, from which the orientation of the search pattern is determined. The ring fragments are derived from the connecting lines between edge transitions on radial rays emanating from the candidate positions. If these lines actually extend along the edges between the center of the search pattern and the rectangular ring, they will only show two orientations corresponding to the main horizontal and vertical directions of the search pattern. At least approximately, this is also true for the found ring fragments, which are found by clustering them accordingly. Each main orientation is then determined, for example, as the average orientation of the ring fragments of each cluster. All ring fragments may be used, but preferably only ring fragments that are considered valid and / or ring fragments of, for example, one ring (such as the third ring, the outermost ring) may be used.
[0023] Preferably, the outermost ring fragment is selected in each of the four main directions according to the orientation, so that straight lines along the ring fragment enclose the location of the search pattern. Once the orientation of the search pattern is determined, four main directions are defined in the coordinate system associated with the orientation: "up", "down", "right" and "left". In each of these main directions, the outermost ring fragment (preferably a valid ring fragment of the third ring) is then located. Straight lines passing through these ring fragments then form a frame around the search pattern, thereby identifying the location of the pattern.
[0024] If the outermost ring fragment cannot be found in a main direction, it is preferable to reconstruct the missing outermost ring fragment from other ring fragments based on the known structure of the search pattern. It may be that in a main direction, the outermost ring fragment (at least the outermost ring fragment that is considered valid) cannot be found because the search pattern is hidden or the contrast is too low or for other reasons. In this case, the edge of the frame in this main direction can be reconstructed from other information (in particular from ring fragments of the first and / or second ring in this main direction and / or from the outermost ring fragments in the main directions on both sides of this direction). The basis for the reconstruction may again be the known spacing ratio of the search pattern, 1:1:3:1:1.
[0025] To verify a search pattern, it is preferred to draw seven equally spaced parallel rays outward from the main axis of the search pattern through half of the search pattern, and to verify the search pattern, it is required that the rays have 1, 2, 3, 3, 3, 2, 1 edge transitions in this order. The seven rays cover half of the search pattern in an even raster. Since the location of the search pattern has been previously determined, the module size as well as the expected code modules are known, including their positions in the search pattern. The rays are drawn in the raster such that each ray covers a different row of code modules, and together they cover all the code modules in the respective half of the search pattern. Deviations from the even raster are allowed, but are minor, without leaving the respective code modules. If the search pattern is actually present under the rays, they should intersect 1, 2, 3, 3, 3, 2, 1 edges in this order. This is a consequence of the structure of the search pattern with a 3x3 core and two rectangular rings surrounding it. A tolerance can then be imposed, for example, on the number of edge transitions on at least one of the ray lines not matching. The above verification of one half of one axis can be repeated for the other half and for the two halves of the other axis, resulting in a total of four verifications. Again, a tolerance can be imposed, for example, on the number of edge transitions on the ray lines not matching in one of the four verification steps. These tolerances can be used to adjust the error rate between being too strict, rejecting real search patterns, and being too lenient, including falsely detected search patterns.
[0026] Preferably, the distance to each edge transition is additionally checked on at least one half-line. On the outer half-lines, there should be only one edge transition, which occurs at a distance of approximately half the size of the search pattern. On the inner half-lines, there should be several edge transitions according to the regulation. In addition to the last edge transition, these half-lines can also be checked for their spacing according to the structure of the half-search pattern. That is, it is not only expected how many edge transitions there should be, but also how far apart or where they are located. This allows for an additional optional verification step.
[0027] Preferably, a check is made to see whether three search patterns arranged in a right-angled triangle are found in the image. For a single QR code, it is unlikely that there is only one, two or more than three search patterns. If there are three search patterns, they must form a right-angled isosceles triangle, from which the frame for the optical code can be read immediately. This check can be made at any point in the method, in particular very early or very late. "Very early" means that from the very start there must be three suitable candidate positions in order to examine the image fragment particularly more accurately. "Very late" means that only after the individual search patterns have been verified is a check made to see whether there are three suitable triangular search patterns in it.
[0028] Preferably, the portion of the image located based on the search pattern is passed to a decoder for reading the optical code. This can be done immediately following the location or at a later time, in the same or in a different device. Thanks to the reliable location of the optical code, the decoder only has to deal with the image fragment that actually contains the optical code. This reduces the decoding time and ultimately improves the read rate.
[0029] In a preferred development, an optoelectronic code reading device is presented which has a light receiving element for capturing an image with an optical code and a control and evaluation unit in which an embodiment of the method for determining the location of an optical code according to the invention is implemented. In this case, it is preferable to read the optical code as soon as it has been found, but this can also take place at a later time and / or in a separate device, as just explained. Depending on the embodiment, the image sensor is a line sensor or a matrix sensor of a camera-based code reader. Barcode scanners are also conceivable, whose light receiving element acquires the respective intensity profile during the scanning process and can be treated as an image line. The combination of several code readers or camera heads is likewise conceivable. The control and evaluation unit is preferably part of the code reading device itself, in particular accommodated in its casing. However, at least partially external control and evaluation units are also conceivable. The code is preferably attached to an object which is conveyed through the detection area of the image sensor on a conveying device. This is a typical application in which the code reader or at least its imaging part is fixedly mounted in the vicinity of a conveying device or a conveyor belt to read the code.
[0030] The invention, together with further features and advantages thereof, will now be described in greater detail with reference to exemplary embodiments and with reference to the accompanying drawings, in which: FIG. [Brief description of the drawings]
[0031] [Figure 1] FIG. 1 is a schematic overall view of an example in which a code reading device is installed above a conveyor belt. [Diagram 2] 1 illustrates an exemplary flowchart for finding candidate locations for a search pattern, pinpointing the location of the search pattern, and validating the search pattern. [Diagram 3] 1 illustrates an exemplary flowchart for finding candidate locations for a search pattern. [Figure 4] 1 illustrates an exemplary flowchart for pinpointing a search pattern around a candidate location. [Diagram 5]1 illustrates an exemplary flowchart for validating a search pattern. [Figure 6] FIG. 2 is an exemplary diagram showing a search pattern with scan lines and edge transitions for finding candidate positions of the search pattern. [Figure 7] FIG. 1 is an exemplary diagram illustrating a search pattern with radial rays and rings connecting edge transitions along the rays. [Figure 8] 8 is an example of the ring of FIG. 7 in an image containing multiple codes and search patterns. [Figure 9] 1 is an exemplary diagram showing a search pattern with valid and invalid ring fragments of the outer ring; [Figure 10] An exemplary diagram showing a search pattern with two main directions found based on grouping ring fragments. [Figure 11] An example image including a box around the search pattern, reconstructed in one main direction. [Figure 12] An exemplary diagram showing a search pattern with seven equally spaced rays that cover half of the search pattern. [Figure 13] 1 is an example image containing a search pattern found and verified by the method according to the present invention. [Figure 14] FIG. 14 is a diagram showing the example image of FIG. 13 in the explanation of the verification based on the seven half lines of FIG. 12 . DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0032] FIG. 1 shows a code reader 10 mounted above a belt conveyor 12. The belt conveyor 12 conveys objects 14 through a detection area 18 of the code reader 10 as indicated by an arrow 16. The objects 14 have a code 20 on their outer surface, which is detected and evaluated by the code reader 10. This code 20 can only be recognized by the code reader 10 if it is applied to the top surface, or at least if it is applied so that it is visible from above. It is therefore possible to deviate from the illustration of FIG. 1 by mounting several code readers 10 from different directions, for example to read a code 22 applied to a side or bottom surface, thereby enabling so-called multiple reading from all directions. In practice, it is very common to use code readers fixed in this way near the belt conveyor 12. However, since the present invention relates primarily to the determination and reading of the code 20 or to the code reader 10 itself, this example should not be interpreted as limiting.
[0033] The code reader 10 acquires image data of the conveyed object 14 and code 20 by means of an image sensor 24, which data is further processed by a control and evaluation unit 26 using image analysis and decoding methods, which for this purpose comprises one or more computing components, such as a microprocessor, a Field Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an Application-Specific Integrated Circuit (ASIC), an AI processor, a Neural Processing Unit (NPU), a Graphics Processing Unit (GPU), etc. Through an interface 28, the code reader 10 outputs information, such as the read code and image data, possibly at various stages of processing.
[0034] Fig. 2 shows an exemplary flow chart for determining the location of a code 22 in image data captured by a code reader 10. The method can be performed in the control and evaluation unit 26 or at least partly externally. Firstly, three steps are generally described and then they are explained in more detail with reference to Figs. 3 to 5. It is mentioned here beforehand that, although it is very advantageous to carry out all steps of Figs. 3 to 5 in succession, the invention also includes sub-combinations, so that each sub-step should be understood as optional at the outset.
[0035] In step S10, candidate locations of the search pattern are found by evaluating, preferably line by line, sequences of pixels along parallel scan lines passing through the image. If these scan lines pass over the search pattern, then there are edge transitions on the scan lines at intervals characteristic of the search pattern. In this way, the location of the center of the putative search pattern can be roughly determined. This location is called the candidate location, since a candidate for the search pattern is now recognized.
[0036] In step S20, the area around the candidate location is further examined to precisely locate the search pattern and confirm that it is a search pattern, so that the exact location of the search pattern is known, for example in the form of a box around the pixels that belong to the search pattern.
[0037] In step S30 the search patterns are verified. After the exact location is known from step S20, the attributes of the found search patterns can be compared with the known attributes of the search patterns down to the level of the individual code modules. In this case, a particularly very precise verification step can also be carried out which did not contribute to the detection in step S20. Falsely detected search patterns are thereby very efficiently rejected. This makes it possible to be somewhat tolerant in step S20 and, for example, to accept partially hidden search patterns for the time being. This collaboration of an initially more lenient selection in step S20 and then a very precise verification in step S30 ensures that the majority of codes are found and are indeed codes.
[0038] Figure 3 shows an exemplary flow chart for finding candidate locations, which may be considered as a sub-step of step S10 of Figure 2. This is illustrated in Figure 6, which shows an exemplary search pattern 30. In step S11, parallel scan lines 32 are drawn through the image area under investigation. These are preferably horizontal scan lines, only two of which are shown in Figure 6 for clarity. Along the scan lines 32, edge transitions 34 between light and dark code regions, or conversely between dark and light code regions, are identified.
[0039] In step S12, the spacing between the edge transitions of the scan lines is checked. For a scan line 32 penetrating the search pattern 30, six consecutive edge transitions 34 must be spaced apart from each other in the ratio 1:1:3:1:1. This is because the search pattern 30 is structured as a central portion with 3x3 code modules, surrounded by two alternating rectangular rings, each with a width of one code module. The ratio 1:1:3:1:1 is therefore obtained regardless of the direction in which the scan line 32 penetrates the search pattern. That is, if six edge transitions 34 are found along a scan line 32 with a spacing ratio of 1:1:3:1:1, taking into account the tolerances, it is assumed that the search pattern 30 is present here. The associated candidate position is preferably the center point of the edge transitions, calculated for example as the common center of gravity of all edge transitions or only the common center of gravity of the outermost edge transitions of the six considered.
[0040] In step S13, the candidate positions of successive scan lines 32 are merged into one candidate position 36, since it is not each new search pattern that is in question but the same search pattern 30, with multiple hits of successive scan lines 32. Again, various calculation methods are available, such as finding the centroid of all edge transitions of the concerned scan lines 32, only the respective outermost edge transitions of each scan line 32 and / or only the outermost scan line 32, finding a common midpoint of the candidate positions of each scan line 32, etc.
[0041] FIG. 4 shows an exemplary flow chart for pinpointing the location of a search pattern around a candidate position, which may be considered as a sub-step of step S20 of FIG. 2. In step S21, radial rays 38 are generated starting from the candidate position 36, as shown in the search pattern 30 depicted in FIG. 7. Here, exemplarily, 16 rays 38 are formed in a uniform angular raster spaced at an angular interval of 22.5 degrees from each other. On each ray 38, the three edge transitions closest to the origin at the candidate position 36 are identified. Depending on the concrete results of steps S10-S13, the candidate position 36 may be slightly off-center within the 3×3 central area of the search pattern 30, unlike FIG. 7.
[0042] In step S22, the innermost, middle and outermost of the three edge transitions found for each ray 38 are connected together, respectively. This results in three rings 40. If in step S21 no three edge transitions are found on any ray 38, the corresponding point in the ring 40 is omitted. If the candidate locations 36 are within the search pattern 30 as in FIG. 7, then the rings 40 as a whole coincide with the light-dark transitions of the search pattern 30. Due to the simplicity of how the rings 40 are constructed with connecting lines, this is not the case for some ring fragments, but this will be discussed further shortly in step S23.
[0043] Before that, FIG. 8 shows an example image with several search patterns to which step S22 has been applied. The search patterns there are very well captured by rings. In the top right corner, there is an example where points had to be omitted because the three edge transitions were not found for several rays. In addition to the search patterns found, there are several possible positions of false positives, where the connecting lines are hardly rings but rather confused. This is because they contain three edge transitions formed by some structure, but which are not part of the search pattern, and some are located very far away. These possible positions of false positives will be eliminated in the following steps. In principle, if the deviations are obvious, as in many of the cases in FIG. 8, they could already be recognized as false positives, since the spacing ratio of the edge transitions along the corresponding ray 38 is quite unlikely.
[0044] In step S23, the validity of the ring segments of the ring 40 is checked. FIG. 9 shows this for the outermost ring 40. To check the validity of a ring segment, it is checked whether the corresponding line runs along a light-dark edge. In FIG. 9, this is the case for the ring segments 42 which are found to be valid, whereas the ring segments 44 which are not found to be valid run inside the dark area and therefore do not run along a light-dark edge. One way to find valid ring segments 42 is to determine the respective direction of the light-dark transition using a Sobel filter. A valid ring segment 42 must lie on a point highlighted by the Sobel filter. Isolated outliers may be tolerated.
[0045] In step S24, the ring fragments 42, 44 are classified into two mutually orthogonal groups according to their extension directions. It is preferable to use only the ring fragments 42 that are recognized as valid. It can be seen from FIG. 9 that the ring fragments 42 that are recognized as valid extend very clearly horizontally or vertically with respect to the search pattern 30, while the orientation of the ring fragments 44 that are not recognized as valid deviates. Within the two groups, the respective main axes can be determined from the orientations of the distributed ring fragments 42, 44, for example as the average orientation within the group. FIG. 10 shows two main axes 46a-b of the search pattern 30 found in this way.
[0046] In step S25, ring segments 42a-d are found, preferably from the outer ring, in the four main directions on either side of the main axis 46a-b, i.e. on the right, left, top and bottom sides respectively according to the now known orientation of the search pattern 30. Again, preferably only ring segments 42 that qualify as valid are taken into consideration. Four straight lines along the found ring segments 42a-d form a box surrounding the search pattern 30, whereby its location is now known. Optionally, the box can be further refined to better match the search pattern 30 by evaluating the perimeter of the straight lines with additional scan lines, in particular perpendicular to the straight lines.
[0047] In step S26, the ring segments 42a-d are reconstructed if no ring segments 42a-d were found in any of the main directions, or if at least no ring segments 42a-d of the outer ring were found. FIG. 11 shows an example image with a missing ring segment at the top due to partial occlusion or other image errors. Therefore, a frame 48 is reconstructed at its upper edge 48a. Other edges of the frame 48 that are well identified and / or ring segments of the inner rings can be used. The reconstruction or extrapolation further incorporates the known size ratio of the search patterns. For the example of FIG. 11, it can be assumed for simplicity that all edges of the frame must be the same length as the lower edges. Additional information is that the edge 48a to be reconstructed and the opposite lower edge should be approximately the same distance from the candidate position 36. Alternatively or in addition, ring segments at the top, i.e. ring segments of the inner and / or middle rings, are also identified. Based on the structure of the search pattern, it is known what the spacing ratio between the inner ring and the outer ring to be reconstructed is, namely according to a spacing ratio of 1:1:3:1:1. Thanks to step S26, the location of the search pattern 30 is still identified in the deterministic case. This increases the risk of an increase in false positive search patterns, which is prevented by the last verification that will now be described.
[0048] Fig. 5 shows an exemplary flow chart for validating a search pattern, which can be considered as a sub-step of step S30 of Fig. 2. Fig. 12 shows the validation based on a copy of the search pattern 30. In step S31, seven parallel ray 50 are drawn for each main direction, i.e. to the right, to the left, above and below with respect to the known orientation with the main axes 46a-b. The ray 50 extends from one of the main axes 46a-b perpendicularly thereto, across half of the search pattern 30. If there are four such groups each containing seven ray 50, then there are a total of 28 ray s, which are rotated four times by 90 degrees with respect to each other, each covering half of the search pattern 30. Since the frame 48 surrounding the search pattern 30 has been found before, the size of the search pattern 30 as well as its module size are now known. The ray s can therefore be spaced so that each ray 50 extends through a different row of modules. This is achieved, for example, by equally dividing the width or height of the search pattern 30, with deviations being tolerated as long as each ray 50 still passes through its respective module column. The number of 7 ray 50 has therefore been appropriately chosen for the 7×7 code modules of the search pattern 30.
[0049] In step S32, edge transitions are identified for each ray 50. To do this, it is necessary to only search along a length of the ray 50 that corresponds to half the size of the box 48, possibly with a certain buffer. Edge transitions outside the box 48 are no longer considered to belong to a valid search pattern 30.
[0050] In step S33, the number of edge transitions found for each ray 50 is compared with the number expected in the search pattern 30 (i.e. 1, 2, 3, 3, 3, 2, 1 edge transition for the seven rays 50, respectively). These required numbers are marked at the end of each ray 50 in FIG. 12. It is immediately clear from the figure why this number is expected. For example, the outer ray 50 extends completely inside the dark outer rectangle of the search pattern, so only one edge transition should be found, which is at the edge of the search pattern. In principle, it would be possible to allow discrepancies in the number of edge transitions on a single ray 50, but this would significantly weaken the verification. It would instead be possible not to require a match between the calculated number of edge transitions and the expected number for all rays 50. Such a tolerance could be set for each group of rays 50 or for all rays 50. That is, for example, requiring that 6 out of 7 rays 50 per group extend through the correct number of edge transitions, or 26 out of 28 rays 50. The search pattern 30 is considered to be validated according to step S33 if the comparison indicates a sufficient match, with or without a tolerance depending on the embodiment.
[0051] In optional step S34, an additional condition is checked, namely the distance or position of the edge transitions on each ray 50, whether they are plausible. An edge transition is expected in the outer ray 50 at a distance of approximately half the size of the search pattern 30 or frame 48. This distance can also be expressed as three and a half module sizes. A similar expectation applies to the furthest edge transitions in each of the other rays 50. Each of the other rays 50 also has edge transitions further inwards, but these are expected to be at a distance of one and a half or two module sizes. A tolerance is preferably imposed in step S34, and preferably on the expected distance and / or on the proportion of the rays 50 that must satisfy the condition of step S34.
[0052] In addition to the steps shown in Fig. 5, further optional extensions are possible. If it is determined early that a match cannot be achieved within the tolerance range, for example because too many ray patterns 50 already do not meet the expectations regarding the number and / or distance of edge transitions, the verification can be terminated early with a negative conclusion. This occurs, for example, when too many modules of the search pattern are hidden. Another possible test is to determine for each ray pattern 50 whether the center of the search pattern 30 must be light or dark in order to be consistent with the ray pattern 50, based on the light-dark transitions. The color of the center must be sufficient to match more than 75% of the ray patterns 50, for example, by this test.
[0053] Figure 13 shows an example image containing several search patterns found and verified by the method according to the invention. Figure 14 shows the verification using the ray just described. The dark ray is where the search pattern is found to be valid, the light ray is where it is not. At 52 the verification correctly fails at several candidate positions, only the genuine search pattern is verified to be valid.
[0054] For QR codes in particular, a final test can be made to check whether the search patterns are found in groups of three in the form of a right-angled isosceles triangle. Depending on the embodiment, search patterns that do not satisfy this condition are either rejected immediately or image regions with, for example, only one or two search patterns or misaligned search patterns are given a lower priority in the decoder or a shorter decoding time is allocated to them. The detection of search patterns according to the invention can also be applied to Aztec codes, where it is of course not expected that the three search patterns are triangular, since Aztec codes only have one central search pattern. The invention can also be applied to other search patterns, where the conditions specific to QR codes and Aztec codes (such as the ratio 1:1:3:1:1) are appropriately adapted.
[0055] As can be seen from the example of FIG. 14, the present invention allows the sensitivity of the code localization to be increased by initially accepting more candidate positions. Thus, even difficult-to-recognize search patterns, such as partially occluded or low-contrast search patterns, are caught. Furthermore, the location of the search pattern, which is found in each case, for example as a frame 48, is improved compared to bounding boxes and other prior art methods. The increase in the number of candidate positions does not in any way lead to an increase in false positives, due to the final verification, but rather the search pattern finally recognized by the present method is more reliable than in the prior art. That is to say, a high selectivity is also achieved. In this case, the search pattern can even be reconstructed or extrapolated before verification.
Claims
1. A method for locating an optical code (20), in particular a QR code or an Aztec code, in an image having a large number of pixels based on a search pattern (30) of said optical code (20), comprising first determining at least one candidate position (36) of the search pattern (30) based on an edge transition along at least one line (32) passing through the image, and then locating a location (48) of said search pattern (30) around said candidate position (36), comprising: At the found location (48), verifying that the image shows the search pattern (30) at the location (48) based on known attributes of the search pattern.
2. 2. The method of claim 1, further comprising determining candidate locations (36) where edge transitions along the at least one line (32) are spaced apart from one another in a ratio of 1:1:3:1:1, taking into account tolerances.
3. The method of claim 1 , wherein the candidate locations (36) are determined as centroids of edge transitions along the at least one line (32).
4. 2. The method of claim 1, wherein the candidate location (36) is determined to be midway between parallel lines (32) when edge transitions along the parallel lines point to a search pattern (30).
5. 2. The method of claim 1, further comprising identifying the three nearest edge transitions along rays extending radially from the candidate position, in particular along 8 or 16 rays spaced at equal angular intervals from each other, in order to identify the location (48) of the search pattern (30) around the candidate position (36).
6. 6. The method of claim 5, further comprising connecting first edge transitions of each of the rays (38) to form a first ring (40), connecting second edge transitions of each of the rays (38) to form a second ring (40), and / or connecting third edge transitions of each of the rays (38) to form a third ring (40).
7. 7. The method according to claim 6, further comprising searching for ring segments (42, 44) of said ring (40) that are valid and extend along an edge, in particular by using a Sobel filter.
8. 7. The method of claim 6, further comprising classifying the ring segments (42, 44) of the ring (40) into horizontal and vertical ring segments and determining the orientation (46a-b) of the search pattern (30) therefrom.
9. 9. The method of claim 8, further comprising selecting an outermost ring segment (42, 44) in each of the four main directions according to the orientations (46a-b) such that straight lines along said ring segments (42, 44) enclose a location (48) of said search pattern (30).
10. 10. The method of claim 9, wherein if an outermost ring fragment (42, 44) cannot be found in a given main direction, the missing outermost ring fragment (48a) is reconstructed from other ring fragments (42, 44) based on the known structure of the search pattern.
11. 2. The method of claim 1, wherein to verify the search pattern, seven equally spaced parallel lines are drawn outward from a major axis of the search pattern, through half of the search pattern, and the lines must have 1, 2, 3, 3, 3, 2, and 1 edge transitions in this order to verify the search pattern.
12. 12. The method of claim 11, further comprising checking the distance to each edge transition on at least one straight line (50).
13. 2. The method of claim 1, further comprising checking whether three search patterns (30) arranged in a right triangle are found in the image.
14. 2. The method of claim 1, further comprising: passing a portion of an image located based on the search pattern to a decoder for reading the optical code.
15. A photoelectric code reading device (10) having a light receiving element (24) for capturing an image including an optical code (20) and a control and evaluation unit (26) in which the method for determining the location of an optical code (20) according to claim 1 is implemented.
Citation Information
Patent Citations
Method and device for searching and encoding machine readable symbol
JP1998021322A
Optical information reader, information processor, document, and recording medium
JP1998307886A
Method for detecting two dimensional code, detecting device, and detecting program
JP2007094584A
Two dimensional-code reader and program thereof
JP2010044586A
Method and apparatus for reading information contained in a barcode
JP2011513809A
