DETERMINING A MODULE SIZE OF AN OPTICAL CODE
20210073499 · 2021-03-11
Inventors
Cpc classification
International classification
Abstract
A method for determining a module size of an optical code (20), wherein image data with the code (20) are detected, a brightness distribution is determined from the image data, and the module size is determined from the brightness distribution. The brightness distribution for example is a greyscale histogram.
Claims
1. A method for determining a module size of an optical code (20), wherein image data with the code (20) are detected, a brightness distribution is determined from the image data, and the module size is determined from the brightness distribution.
2. The method according to claim 1, wherein the brightness distribution is a greyscale histogram.
3. The method according to claim 1, where the module size is determined from a central region of the brightness distribution.
4. The method according to claim 1, wherein edges of the optical code (20) are located in the image data and the brightness distribution is formed only over image data in a neighborhood of edges.
5. The method according to claim 1, where the brightness distribution is tailored to an active area where the distribution exceeds a noise threshold.
6. The method according to claim 1, wherein the module size is determined from at least one of a width, an integral and a maximum value of the brightness distribution.
7. The method according to claim 6, wherein the module size is determined from a quotient of the integral and the width of the brightness distribution.
8. The method according to claim 7, wherein the quotient is mapped to the module size with a scaling function.
9. The method according to claim 8, wherein the quotient is mapped using units of pixels per module.
10. The method according to claim 1, wherein the brightness distribution is rescaled with different weighting factors at a center and at sides of the brightness distribution.
11. The method according to claim 10, wherein the center of the brightness distribution is raised relative to the sides.
12. The method according to claim 1, wherein the brightness distribution is divided into three parts, namely a left side, a center and a right side, and wherein a weight factor for each of the three parts is used for rescaling.
13. The method according to claim 1, wherein the optical code (20) is read after determining the module size.
14. The method according to claim 13, wherein the optical code (20) is at least one of read with a decoding method selected on the basis of the module size and parameterized by the module size.
15. The method according to claim 1, wherein the determined module size is compared with a limit value in order to use a decoding method or a component of a decoding method depending on whether the module size exceeds or falls below the limit value.
16. The method according to claim 15, wherein the limit value is in a range of a module size of one to three pixels per module.
17. A code reader (10) for reading optical codes (20), comprising an image sensor (24) for detecting image data with the code (20) and a control and evaluation unit (26) configured to read the code (20) after determining a module size of the code (20), the module size being determined from a brightness distribution that is determined from the image data.
18. The code reader (10) according to claim 17, wherein the brightness distribution is a greyscale histogram.
Description
[0030] 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:
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040] The code reader 10 uses an image sensor 24 to detect image data of the conveyed objects 14 and the code areas 20, which are further processed by a control and evaluation unit 26 using image evaluation and decoding methods. The specific imaging method is not important for the invention, so that the code reader 10 can be configured according to any known principle. For example, only one line is detected at any one time, either by means of a line-shaped image sensor or a scanning method, where in the latter case a simple light receiver such as a photodiode is sufficient as image sensor 24. An image line can directly be used for an attempt to read the code, or the control and evaluation unit 26 combines the lines detected during the conveyor movement to form the image data. With a matrix-shaped image sensor, a larger area can be captured in one image, where it is also possible to combine images both in the conveying direction and the transverse direction. The plurality of images may be taken one after the other and/or by a plurality of code readers 10 that for example cover the entire width of the conveyor belt 12 only with their combined detection areas 18, each code reader 10 detecting only one tile of the entire image and the tiles being combined by image processing (stitching). It is also conceivable to decode only fragments within individual tiles and then to stitch the code fragments.
[0041] The main task of the code reader 10 is to detect the code areas 20 and to read the codes therein. As a sub-step, preferably as early as possible in the processing chain and prior to the actual code reading, the module size is determined from a brightness distribution or a greyscale histogram of the images of the respective code 20. This is explained in detail below with reference to
[0042] The code reader 10 provides information, such as read codes or image data, via interface 28. It is also conceivable that the control and evaluation unit 26 is not arranged in the code reader 10 itself, i.e. the camera shown in
[0043]
[0044] The further specification is based on the example of barcodes, but the method according to the invention for determining the module size is analogous for two-dimensional codes. In the case of a barcode, the greyscale profile should not be captured almost parallel to the bars. If the module size is to be determined in absolute length units, the angle of the greyscale profile with respect to the code must be known. However, the size of interest for decoding is how many pixels represent a module (ppm, pixel per module), in the very same image data that the decoder receives, including a possible skew in the code 20.
[0045] In principle, the desired module size is already represented in
[0046]
[0047] According to the invention, the module size is not determined from greyscale profiles or derivatives thereof, but an indirect approach via a histogram of greyscale values or, more generally, a brightness distribution is used.
[0048]
[0049] For sufficient module size, the greyscale histogram is bimodal with a clear left and right peak for the dark and light code elements, respectively, and a flat area in between.
[0050]
[0051] This illustrates the basic idea of the invention: The brightness distribution, which is obtained in particular as a greyscale histogram, allows conclusions to be drawn about the module size. This may be a qualitative statement as to whether the module size is large or small, with the limit in between for example being 2 ppm, but it is also possible to estimate a numerical value for the module size.
[0052] As explained with reference to
[0053] It is therefore advantageous if the greyscale histogram is obtained only from pixels that correspond to this transition area. This can be achieved in that the greyscale histogram is not formed from all pixels of an image of a code, but only from pixels in the neighborhood of edges. There at the edges, the blurring effect due to under-sampling or too low resolution can be measured particularly well.
[0054] It has already been explained with reference to
[0055] An exemplary greyscale histogram based on edge neighborhoods is shown in
[0056] In order to determine a module size from the greyscale histogram based on edge neighborhoods, or alternatively a complete greyscale histogram, the greyscale histogram may be described by characteristic variables. Only an active area of the greyscale histogram preferably is considered to ensure that individual noise events do not affect the evaluation. This includes only those bins that exceed a noise threshold, for example either specified as a minimum number of pixels contributing to the bin or a minimum percentage.
[0057] It turns out that the width, as illustrated by an arrow in
[0058] The area of a normalized histogram of course is one, so the integral only makes a real contribution if the greyscale histogram is not normalized or is normalized before the active area is determined with the noise threshold, or if subareas are rescaled as explained below. Other possible characteristic variables are the height of the main maximum, the number of secondary maxima or the ratio of the height of the main maximum to the height of the first secondary maximum.
[0059] One possible specific calculation for the module size is to form the quotient of integral and width and to map this measured value with a scaling factor to a module size in units of ppm. The scaling factor can for example be obtained by reading codes in a calibration or teach-in process and subsequently determining the module sizes with high accuracy by common means. Then, in reversal of the later calculation, the known module size is compared with the quotient of integral and width to find the required scaling factor.
[0060]
[0061] In a step S1, input data is obtained, i.e. the image data of the code, for example in the form of one or more greyscale profiles, as explained above with reference to
[0062] In a step S2, the edge positions in the code are determined. The derivative of greyscale profiles can be used to that end, as explained above with reference to
[0063] In a step S3, the greyscale histogram is initialized by providing bins according to the possible grey values and initializing the respective bin counters with zero.
[0064] In a step S4, the grey values of the pixels at the edge positions as well as in their neighborhood are determined, for example the preceding i and the following j pixels.
[0065] In a step S5, the bins associated with the grey values determined in step S4 are incremented accordingly. Steps S4 and S5 are separated for explanation only. In practice, rather all edge positions and, for each edge position, the pixels in their neighborhood would be considered one after the other, and for each relevant pixel the bin of the corresponding grey value would be incremented. As an alternative to the edge-based greyscale histogram according to steps S2, S4 and S5, a greyscale histogram can also be formed from all pixels of the input data of step S1, in which case the estimation of the module size may become less accurate.
[0066] In a step S6, the greyscale histogram is normalized so that the sum over all bins is one. The normalization factor corresponds to the number of pixels contributing to the greyscale histogram or the sum over the greyscale histogram prior to normalization. The normalization is completely optional and could in particular also be replaced by using the scaling factor F to be introduced in step S10.
[0067] In a step S7, the greyscale histogram is limited to a so-called active area by only considering bins that have a minimum count or frequency of occurrence exceeding a noise threshold. The noise threshold can be a constant or a fraction of the sum of all bins of frequencies of occurrence, for example a per mille value, and eliminates outliers. A width B is calculated as the difference between the largest and smallest bin of the active area.
[0068] A subsequent step S8 is completely optional and is an example of an optional rescaling of the greyscale histogram that can be used to further enhance certain characteristic properties for determining the module size. In this specific example implementation, the active area is divided into three equally sized partial areas. The bins in the left and right part are multiplied by a side weight, the bins in the central part are multiplied by a central weight. Alternatively, a more finely resolved weighting function could be used. Preferably, the rescaling is used for a relative weakening of the side areas and a relative strengthening of the central area, whatever the specific design of the rescaling. This is because, as explained with reference to
[0069] In a step S9, the bins of the active area are summed up so that an integral or the area A of the active area is determined.
[0070] In a step S10, the quotient of area A and width B is formed. This already is the desired estimation of the module size, but still in the wrong units. Therefore, the module size is calculated as F*A/B, i.e. a scaling factor F is introduced, which scales the measured variables from the greyscale histogram to a module size in units of ppm. The scaling factor F can be empirically determined or taught-in in advance.
[0071]
[0072] In a data set of more than 700 code images taken from a real application, an average error of 0.15 of the estimated module size could be achieved. The calculations become less accurate for increasing module sizes. A major reason is that the scaling factor F is actually a scaling function that should be attenuated for increasing module sizes, for example of greater than 2 ppm. In principle, a scaling function can be determined empirically or taught-in in the same way as a scaling factor. In practice, however, this is not really necessary, since the small module sizes, where a constant scaling factor F results in a good estimation, are the more critical cases by far, and an estimation error for increasing module sizes can therefore usually be accepted.