Reading 1D optical codes
Enhancing image resolution and sharpening grayscale transitions using classical and machine learning techniques addresses the challenges of decoding 1D optical codes with low quality images, improving decoding accuracy and read rates.
Patent Information
- Application Number
- JP2023060380
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2022-06-07
- Filing Date
- 2023-04-03
- Publication Date
- 2024-09-25
- Estimated Expiration
- 2043-04-03
AI Technical Summary
Existing binarization methods for 1D optical codes struggle with poor quality images, such as low resolution, blur, and noise, leading to insufficient decoding performance, especially when module sizes are small.
A method that enhances image resolution and sharpens grayscale transitions using a combination of classical and machine learning techniques, such as convolutional neural networks or Richardson-Lucy deconvolution, to prepare for binarization, ensuring accurate decoding even in challenging conditions.
The method significantly improves the read rate of barcodes by effectively binarizing grayscale transitions, enabling successful decoding of barcodes with low resolution or blur, particularly when module sizes are small.
Smart Images

Figure 0007556088000001 
Figure 0007556088000002 
Figure 0007556088000003
Abstract
Description
[Technical field]
[0001] The invention relates to a method for reading a one-dimensional optical code according to the preamble of claim 1 and to a code reading device according to the corresponding claim 15. [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 code scanner detects each successive code that enters its reading field. In camera-based code readers, on the other hand, a line-scan camera captures the image of the object carrying the code information line by line as it moves relative to the object. When using 2D image sensors, multiple image data are regularly acquired, with some overlap depending on the imaging rate and conveying speed. To allow objects to be positioned on the conveyor in any orientation, the reading tunnel is often equipped with multiple code readers, allowing the object to be imaged from several or all sides.
[0004] Although there are many forms of 2D optical codes, 1D barcodes still play an important role. Barcodes consist of black bars and white spaces. In contrast, the data of the image scanned or photographed to read the code represents a grayscale, i.e. a grayscale value between 0 and 255 with a color depth of 8 bits. Decoders, with the exception of a few methods such as template matching, cannot handle grayscale values. Therefore, binarization is usually performed before the decoder, converting the grayscale values to black and white values or a color depth of only 1 bit.
[0005] Thresholding implies a significant reduction of information. The crucial information about the width of the bars and gaps must not be lost. Simple thresholding methods are sufficient only under ideal conditions. In practice this is not the case and there are many different disturbing influences, such as poor focus, optical distortions, dirt, noise, subject motion, reflections, damaged codes, poor exposure, etc.
[0006] Therefore, to enable successful decoding, clearly more complex thresholding algorithms are required, which in turn include more fine optimizations such as intelligent or local threshold selection and pre-filtering. In differentiation-type methods, the original grayscale value transition is differentiated to identify the positions of edges and extrema. There are also many optimizations for this. To combine the advantages of various thresholding algorithms, they are often run in parallel and the results are decoded separately.
[0007] Using these conventional binarization implementations, good results are obtained in many real-world code reading situations. Nevertheless, there still remain too many code acquisitions where the binarization quality is insufficient, e.g., very blurry, low signal-to-noise ratio, sampling effects, low contrast, low code resolution, etc. Particularly detrimental is the combination of these effects. It is precisely in this interaction that the interferences become complex, so that addressing each problem case individually and targetedly is extremely difficult and time-consuming even to write, much less develop appropriate algorithms.
[0008] Patent Document 1 discloses a photoelectric sensor for capturing codes that digitizes read color or grayscale image data while it is still being received and / or in real time, but does not discuss any specific digitization algorithm.
[0009] In Patent Document 2, regions of interest or code candidates are found based on the magnitude of contrast in preprocessing on an FPGA. This can be linked to binarization, but binarization is not described in detail.
[0010] In US Pat. No. 5,999,113, a classical decoder operating in a machine learning-free manner is used to train a classifier configured for machine learning, or more specifically a neural network. The classical decoder is preferably configured to binarize image data, but it is not described how the binarization specifically proceeds.
[0011] US 2007 / 0139996 describes a camera and a method for processing image data, in which segmentation using a neural network is performed in a streaming manner, i.e. image data is processed while further image data is still being read. At least a first layer of the neural network can be implemented on an FPGA. In one embodiment, an additional processing path is provided, which performs pre-processing steps, such as generating a binary image in a classical or learning-based manner on a separate copy of the original image that has been up-resolutioned, in parallel with the neural network. Here again, binarization is not considered in detail.
[0012] Patent Document 5 describes an image evaluation method. In this method, a scanned grayscale image is deblurred using deconvolution and binarized using an adaptive threshold. Patent Document 6 describes a method for increasing the resolution using a neural network, followed by binarization and decoding. This is not cut into a barcode, i.e., a one-dimensional code, and the quality of the binarization may still be insufficient in the problem situation described.
[0013] In the code reader described in US Pat. No. 6,299,136, additional algorithms are incorporated into the decoding process depending on the measured distance to the code. One of these additional algorithms can be deblurring using Richardson-Lucy deconvolution. However, this is not coupled with binarization. [Prior art documents] [Patent documents]
[0014] [Patent Document 1] EP 2 003 599 A1 [Patent Document 2] EP 2 555 160 B1 [Patent Document 3] EP 3 428 834 B1 [Patent Document 4] EP 3 916 633 A1 [Patent Document 5] US 8 576 446 B2 [Patent Document 6] US 2020 / 0394376 A1 [Patent Document 7] EP 3 812 953 A1 Summary of the Invention [Problem to be solved by the invention]
[0015] SUMMARY OF THE DISCLOSURE It is therefore an object of the present invention to improve binarization for reading barcodes. [Means for solving the problem]
[0016] This problem is solved by a method for reading a one-dimensional optical code according to the preamble of claim 1 and a code reading device according to the corresponding claim 15. In this document the term barcode is used synonymously with one-dimensional optical code, contrary to some documents where two-dimensional codes are sometimes also called barcodes. The step of reading the barcode proceeds automatically. It is a computer-implemented method.
[0017] Image data containing the code is acquired. A matrix camera can be used for this purpose. It is also conceivable to perform repeated shots with a line scan camera, in particular with a shift between the code and the line scan camera, and to combine successively shot image lines into one planar image. The intensity profile of the code scanner can also be interpreted as an image line. The code is captured multiple times by planar or repeated line shots, and accordingly multiple grayscale value transitions are obtained through the code. Each grayscale value transition represents the code, and in this sense the multiple grayscale value transitions are redundant. Since there are differences between the grayscale value transitions, it is not completely redundant, and therefore an overmeasurement of the multiple grayscale value transitions can be used to obtain a more robust reading result. A grayscale value transition is also called a "scan" after the code scanner. By extension, it is the intensity transition or image data along a line through the code, for example in 256 grayscale steps in the case of an 8-bit color or grayscale depth.
[0018] From the greyscale value transitions, a black-and-white transition is formed by binarization, which now has a colour or greyscale depth of only 1 bit, from which transition the code content of the code is read. The binarization can be carried out in any manner known per se, including by means of intelligent or local thresholds, or by using prior differentiation or machine learning methods (in particular neural networks). For reading the code, any classical decoder or machine learning methods known per se can also be used.
[0019] The basic idea from which the present invention begins is to generate a sharpened grayscale value transition from said multiple grayscale value transitions, taking advantage of their redundancy, to assist and prepare for binarization. The sharpened grayscale value transition has a higher resolution than the original image data (upsampling, super-resolution). In addition, edges and extreme values are sharpened in it (deblurring, amplitude expansion) and stand out more than in the original image data. Indistinct edges become clearer and steeper, grayscale values in bars become darker and grayscale values in gaps become lighter. The subsequent binarization is therefore obviously easier.
[0020] In a preferred embodiment, the resolution enhancement and the sharpening are separate steps. However, it is also conceivable to implicitly form an intermediate result of a grayscale value transition where only the resolution has been increased, but not yet the sharpening. In particular in the implementation using neural networks, the intermediate result can be left buried in the feature maps of the hidden layer, and the final sharp grayscale value transition with both improvements can be obtained directly at the output. The various steps of the method according to the invention, namely resolution enhancement, sharpening, binarization and code reading, are general and can each be performed classically or by machine learning methods. Various mixtures of classical and machine learning steps are possible here, in particular when implementing each step using neural networks, a separate neural network can be implemented for each step or for several successive steps.
[0021] The present invention has the advantage that a much larger number of barcodes can be successfully decoded, thereby increasing the reading rate. Even grayscale value transitions acquired with unclear, low resolution or other poor quality can still be accurately binarized and subsequently read. This is especially true when a small module size (i.e. pixels per smallest bar or smallest gap) is of critical importance, especially when the module size is in the range of 1 or less. The method according to the present invention can be used in parallel with other code reading methods or when other code reading methods fail.
[0022] Preferably, in a pre-processing step, the image data is segmented in order to find image regions containing the code, so that the reading of the barcode is restricted to regions of interest where the barcode is actually found with a high probability anyway. The segmentation is preferably carried out in a component separate from the subsequent code reading, in particular in an FPGA (Field Programmable Gate Array) and the code reading in a CPU (Microprocessor). In this respect, reference is made additionally to the above-mentioned US Pat. No. 5,399,413. The FPGA can process at least part of the method according to the invention, in particular by means of a neural network with an initial layer on the FPGA, as in the above-mentioned US Pat. No. 5,399,413.
[0023] Preferably, the orientation of the code in the image data is determined in the preprocessing, especially within the frame of the segmentation. The ideal reading direction runs across the bars of the barcode, whereas a reading direction along the bars is not possible. Once the orientation of the code is known, the appropriate grayscale value progression can be obtained. Preferably, only the choice between horizontal and vertical is made so that the rows or columns of the image data can be directly used. It is indeed customary that the ideal reading direction perpendicular to the bars runs diagonally, but due to the discontinuity of the image data raster, a diagonal grayscale value progression has grayscale value jumps. A careful consideration should be made between these two criteria. To distinguish between horizontal and vertical, a kind of check cross can be made with two mutually perpendicular lines. One of the two lines then crosses more bars and gaps or light-dark transitions, thereby determining the orientation of the code.
[0024] In preparation for binarization, it is preferable to first generate a high-resolution grayscale value transition from a plurality of grayscale value transitions. As already mentioned above, in this embodiment, two separate steps are performed: high-resolution and sharpening. The high-resolution grayscale value transition is generated using a redundant plurality of grayscale value transitions. The corresponding methods of high-resolution (super-resolution) are known per se, and there are classical algorithms for this, such as machine learning methods (especially those using neural networks).
[0025] Preferably, the sharpened grayscale value transition is generated from the high-resolution grayscale value transition by a deconvolution method. The deconvolution is a classical method, i.e. it is not a machine learning method, in particular not a neural network. In the case of barcodes, the Richardson-Lucy deconvolution is particularly suitable.
[0026] As an alternative, machine learning methods are used to generate sharpened grayscale transitions from the high-resolution grayscale transitions. Classical approaches such as Richardson-Lucy deconvolution work well with relatively few computational resources, but have the disadvantage that they require manual parameter setting to get good results. Data-driven machine learning methods do not require this, and often produce better results.
[0027] The machine learning method preferably comprises a neural network, in particular a convolutional network with a filter kernel whose width corresponds to the module size of the code in the up-converted grayscale value transition. For neural networks, in particular deep neural networks with hidden layers ("deep learning"), a large base of useful software packages is available, and if necessary, dedicated hardware is also available. Within the context of image processing, convolutional networks (CNN, Convolutional Neural Network) are particularly suitable. The desired binarization is particularly strongly dependent on local proximity relations, and mixing more than one module is more of a hindrance than a help. Convolutional networks with a filter kernel whose size is in the order of the module size are therefore particularly well suited to the application desired here. The invention is primarily intended for low-resolution code images with a module size of 1 pixel or less. Since after up-conversion the module width will be several pixels (for example 5 pixels), it is preferable to select a filter kernel whose width corresponds to the module width (5 pixels in the example given above). Filter kernels that are slightly narrower or wider are also conceivable, but should preferably not be a multiple of the module width. However, it is not compulsory to adapt the filter kernel to the module size, and the neural network can adapt to more unfavourable initial conditions through learning. The width of the filter kernel is for the first or initial layers, and in later layers the local context is further expanded to larger neighbouring regions anyway through repeated convolutions.
[0028] From the plurality of grayscale value transitions, a high-resolution or sharpened grayscale value transition is preferably generated by a machine learning method, in particular a convolutional network. The plurality of grayscale value transitions are preferably arranged one above the other and input as a two-dimensional image on the input side for this purpose. In a first method, the machine learning method performs the high-resolution in a single intermediate step, as already mentioned above as one possibility. In a second method, the two steps of high-resolution and sharpening are combined in one machine learning method. In that case, it is not decided whether the machine learning method first performs the high-resolution explicitly as an intermediate step, and in fact it usually does not, but in any case it is a purely internal intermediate result, for example in the form of a feature map of a hidden layer. The high-resolution is, however, somehow internally represented, since the resulting sharpened grayscale value transition has both improved resolution and sharpness.
[0029] The machine learning method is trained by supervised learning based on training data that assigns grayscale value transitions to black-white transitions, preferably from previously given code content or from successfully read codes. In supervised learning, the raw images presented during the later operation can be generalized based on a training data set that contains samples that have previously been given a correct evaluation. Since the appropriate architecture of the neural network and algorithms for training and operation (inference) is known in advance, a well-performing solution can be used or superimposed on top of it. A typical difficulty here is the generation of the training data set. In the present embodiment, this is solved by using two possible ways, either individually or in combination. First, the code content is given in advance, from which an ideal black-white transition can be constructed, which can be dissimilated to a grayscale value transition in various ways. On the other hand, a real code image can be read. In that case, the black-white transition is either a binarized version of a successful reading attempt or a black-white transition reconstructed from the read code content, and the grayscale value transition is taken from the image data of the code image. These grayscale value transitions are the training samples, and the black-white transitions are the desired results to be trained (labels, ground truth) associated with them.
[0030] Preferably, the resolution of the training data is reduced to obtain training data with a small module size. The successful reading attempts from which the training data is obtained are typically at high resolution. The motivation for the present invention is that problem cases with small module sizes are often unreadable. To still be able to use training samples from the field, in this embodiment, the original high-resolution grayscale value transitions obtained from real code images are artificially reduced in resolution to a smaller module size (downsampling). In addition, a black and white transition is newly constructed at the lower resolution or similarly adapted to the reduced resolution.
[0031] The image data is preferably acquired, in particular line by line, during a relative movement between the light receiving element and the object carrying the code, the light receiving element being part of a code reading device, and the relative movement is preferably caused by transporting the object carrying the code, for example on a transport device, past the reading field of a stationarily mounted code reading device.
[0032] A code reading device according to the invention for reading one-dimensional optical codes comprises at least one light receiving element for acquiring image data comprising the code and a control and evaluation unit arranged to carry out any of the embodiments of the method according to the invention. The code reading device can be a barcode scanner, for example with photodiodes as light receiving elements, in which case the intensity profile of the scan is the plurality of greyscale value transitions, which are processed as such or preferably first combined line by line into image data. Preferably, the code reading device is a camera-based code reader, with an image sensor as light receiving element. On the other hand, the image sensor can be a line sensor for capturing code lines or for capturing planar code images by combining image lines, or a matrix sensor, in which case the captured images of the matrix sensor can also be combined into a larger output image. The combination of several code readers or camera heads is likewise conceivable. The control and evaluation unit can itself be part of the barcode scanner or camera-based code reader or can be connected thereto as a control device.
[0033] 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]
[0034] [Figure 1] FIG. 1 is a schematic three-dimensional overview of an exemplary embodiment of a code reader mounted on a conveyor belt that transports objects bearing codes to be read. [Diagram 2]An example of a grayscale value transition through a barcode. [Diagram 3] An example of a segment of a grayscale value transition through a barcode with difficult to discern light-dark transitions. [Figure 4] FIG. 2 is a schematic illustration of a process for generating a high resolution greyscale value transition from a number of low resolution greyscale value transitions; [Diagram 5] Code example for neural network architecture for sharpening grayscale value transitions. [Figure 6] A comparison of the original grayscale value progression when sharpening using a neural network, the sharpened progression, and the ideal black and white progression we are aiming for. [Figure 7a] A cut-out portion of the code image with its original grayscale value transition. [Figure 7b] Part of Fig. 7a after applying a neural network for sharpening. [Figure 7c] Part of Fig. 7b after binarization to black and white transition. [Figure 7d] A comparison part (Ground Truth) with ideal black and white transitions. [Figure 8] Comparison of the original grayscale value transition after sharpening using Richardson-Lucy deconvolution, the sharpened transition, and the ideal black and white transition we are aiming for. [Figure 9a] A cut-out portion of the code image with its original grayscale value transition. [Figure 9b] Portion of Figure 9a after applying Richardson-Lucy deconvolution for sharpening. [Figure 9c] Part of Fig. 9b after binarization to black and white transition. [Figure 9d] A comparison part (Ground Truth) with ideal black and white transitions. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0035] FIG. 1 shows a photoelectric code reader 10 in a preferred use situation, mounted above a conveyor belt 12. The conveyor belt 12 transports objects 14, as indicated by the arrow 16, through a detection area 18 of the code reader 10. The objects 14 have a code area 20 on their outer surface, which is detected and evaluated by the code reader 10. This code area 20 can only be recognized by the code reader 10 if it is applied on 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 representation of FIG. 1 by mounting several code readers 10 from different directions, for example to read a code 22 applied on the side or bottom surface, thus allowing so-called multiple reading from all directions. In practice, the arrangement of several code readers 10 in a reading system is almost always implemented as a reading tunnel. Such use of code readers fixed near a conveyor belt is very common in practice. However, this example should not be interpreted as limiting, since the invention relates primarily to the code reader 10 itself or to a method of decoding the code implemented therein.
[0036] The code reader 10 acquires image data of the transported object 14 and the code field 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. The specific imaging method is not important for the invention, so that the code reader 10 can be constructed according to any principle known per se. For example, if only one line is captured in each case, a line-shaped image sensor can be used or a scanning method can be used, in which case a simple light receiver such as a photodiode is sufficient as the image sensor 24. The control and evaluation unit 26 evaluates the captured line or combines several lines captured during the transport movement to form image data. If a matrix-shaped image sensor is used, a larger area can be captured with just one exposure. Here too, the combination of several captured images can be performed both in the transport direction and in the cross direction. The detection areas 18 of the multiple code readers 10 together cover the entire width of the belt conveyor 12, and each code reader 10 captures only a fragment of the entire image, which are then joined together through image processing (stitching). It is also possible to perform decoding only piecemeal within each fragment, and then join the code fragments together.
[0037] The code reader 10 outputs information (e.g. read code or image data) via an interface 28. It is also conceivable that the control and evaluation unit 26 is not arranged in the code reader 10 itself, i.e. in the camera as shown in FIG. 1, but is instead connected as a separate control device to one or more code readers 10. The interface 28 then also serves to connect internal and external control and evaluation. The control and evaluation functions can be distributed almost arbitrarily between internal and external components, the latter even being connected via a network or cloud. All this is not differentiated further here, and the control and evaluation unit 26 is considered to be part of the code reader 10, regardless of its concrete implementation. The control and evaluation unit 26 can comprise several components, such as an FPGA (Field Programmable Gate Array) and a microprocessor (CPU). In particular, for the evaluation steps in machine learning methods not yet described (especially those using neural networks), special hardware components, such as an AI processor, an NPU (Neural Processing Unit), a GPU (Graphics Processing Unit), etc.
[0038] Figure 2 shows an exemplary grayscale value transition along a line through a barcode. As a partial step of code reading, it is necessary to binarize the grayscale value transition and, from the resulting black-white transition, identify the light-dark or dark-light transition intervals and thus the code content. Most bars and gaps, i.e. the dark and light areas of the barcode, are recognized as significant maxima and minima of grayscale value. There are also saddles, double peaks and less significant extrema, which are not yet clearly determinable by the naked eye as being transitions between bars and gaps or simply noise or inaccuracies in grayscale value detection. At these points, even with locally adapted thresholds, binarization errors may still occur, resulting in misreading or unreadable barcodes.
[0039] Figure 3 shows a part of the grayscale value transition like that of Figure 2. In the circled areas, the narrow gaps of the barcode are not shown as local maxima or even as saddle points, but simply as gradient boundaries. The motivation of the present invention can be summarized as follows: by processing the grayscale value transition, we create an initial situation in which the binarization will give correct results even in such problem areas.
[0040] The basic principle of the invention is thus to not immediately subject the original grayscale value transitions to a binarization algorithm, but to previously apply a nonlinear filter that modifies the grayscale value transitions in the light of the subsequent binarization. Such a nonlinear filter can highlight information for binarization that would not be obtained by conventional methods, even in cases such as the example of FIG. 3, where the grayscale value transitions are low-resolution and unclear. In the embodiment described in detail below with reference to FIGS. 5 to 7a-d, the filter is implemented by machine learning methods, in particular a neural network (data-driven approach) trained to improve the quality of difficult-to-read grayscale value transitions. On the other hand, in the embodiment described in detail with reference to FIGS. 8 and 9a-d, a classical method is used. The filter generates a sharpened grayscale value transition each time from a number of original grayscale value transitions. That is to say, on both the input and output sides, grayscale values with a color or grayscale depth of, for example, 8 bits are present. The color depth is then reduced to 1 bit by a relatively simple binarization algorithm. For this, practically any binarization algorithm known per se can be used, such as conventional differentiation or threshold algorithms. In principle, it would be possible to use machine learning methods for binarization as well (especially the same as the machine learning methods for filters) to directly obtain black and white transitions as output data from multiple original grayscale value transitions as input data.
[0041] FIG. 4 illustrates an additional preparatory step of processing the original grayscale value transitions 30 first into a single high-resolution grayscale value transition 32 (super-resolution). The non-linear sharpening filter mentioned above preferably receives this high-resolution grayscale value transition 32 as input. The grayscale value transitions 30 are preferably along lines passing through the same barcode, in particular by processing planar image portions of the barcode rather than a single individual line. The planar image portions do not have to be taken directly from the captured image of the barcode, for example the grayscale value transitions 30 may be arranged vertically from more widely spaced to less closely spaced, or horizontally aligned with each other. Whether the input data are referred to as planar image portions or as lines is of no importance for the method hereafter. It is advantageous if said lines are along image rows or image columns. An optimal orientation perpendicular to the bars of the barcode for reading can then be achieved, usually only approximately, by choosing the image rows or image columns. Lines passing diagonally through the image of the barcode are also conceivable, but this may lead to disturbing discontinuity artifacts. In the drawing of Figure 4, the original grayscale value transitions 30 are already properly oriented across the barcode. This preparation step can be omitted, but then the nonlinear filter must be able to handle additional rotational degrees of freedom, which would require a large number of training samples, especially when using machine learning methods.
[0042] Since the present invention is primarily intended for barcodes captured at low resolution, i.e. small module sizes of less than one pixel per module, the increased resolution is advantageous. For larger module sizes, conventional binarization without special pre-processing is usually already sufficient, although the present invention is of course still applicable to such barcodes. By capturing multiple grayscale value transitions 30, the information redundancy of the barcode is advantageously utilized, which is in any case acquired spatially and / or temporally multiplexed in normal code reading applications. As an alternative, it is also conceivable to use only one grayscale value transition as input, the resolution of which can be increased by interpolation as well. However, unlike the solution shown in FIG. 4 with multiple grayscale value transitions 30 as input, the information base is not broadened by the interpolation.
[0043] The high-resolution grayscale value transition 32 is the starting point for the subsequent sharpening, which will now be described. In the sharpening, the transitions between the bars and the gaps are sharpened, making the bars and the gaps darker or lighter in grayscale value, respectively. The desired result is as close as possible to a binary light-dark transition, still represented by grayscale values, but with very sharp edges. Note that the high-resolution grayscale value transition 32 does not necessarily have to be generated as an explicit intermediate result. In particular, when using machine learning methods, the high-resolution and sharpening can be performed in one step, but in that case the high-resolution is a hidden part of the method. In exactly the same way, the binarization can be incorporated into the machine learning method instead of being a separate step. In this case, a comparison must be made in each case between the training of several sub-steps, which are themselves simpler, and the training of a common but more complex step. Since very simple known classical methods are available for some sub-steps (such as binarization), the approach of using a monolithic highly complex neural network for all steps is not necessarily advantageous.
[0044] In the following, a nonlinear filter for sharpening the high resolution grayscale value transition 32 is described in detail in two embodiments. The first embodiment is based on machine learning methods (here, neural networks as an example) and is illustrated in Fig. 5 to Fig. 7a-d. The second embodiment is based on classical methods (here, Richardson-Lucy deconvolution as an example) and is illustrated in Fig. 8 and Fig. 9a-d.
[0045] Fig. 5 shows a part of a program code (code excerpt) for generating an exemplary neural network that can be used as a nonlinear filter for sharpening grayscale value transitions. Preferably, at the input, one high-resolution grayscale value transition 32 with 3991 consecutive grayscale values is input as an example. To alternatively directly process multiple original grayscale value transitions 30, it is preferable to adapt the architecture accordingly, for example input multiple short lines rather than one long line, and target the first part of a single high-resolution line in the architecture.
[0046] The exemplary neural network is a convolutional network (CNN) with several hidden layers. The kernel size is chosen here as N=5, which corresponds to the module size of 5, and for this module size the kernel captures approximately one module each time. The module size in this exemplary example arises when a barcode, originally photographed with a module size of less than 1.5, is first up-resolutioned to a resolution or module size 5 times higher. In other words, the kernel then corresponds to the actual pixels of the original low-resolution barcode image. The kernel may deviate from this by a little wider or narrower. Depending on the individual's choice, one can use a one-dimensional convolutional layer with kernel size N or a two-dimensional convolutional layer with kernel size N×1. The example network in Figure 1 uses a one-dimensional convolutional layer in the initial layer and a two-dimensional convolutional layer in the subsequent layers. The depth and width of the architecture can be changed. What is important is that the training produces a sharpened grayscale value transition, which can be used to read the code content.
[0047] The example convolutional network operates with a step width of 1 (strides=1) since the output sharpened grayscale value transition should preferably be the same size as the input grayscale value transition. Padding with valid and activation function ReLu have proven effective in test runs, although variations on this are possible.
[0048] Supervised learning of convolutional networks requires samples that contain grayscale value transitions and, for each of them, the appropriate black-white transitions as labels or ground truth. During training, grayscale value transitions are presented at the input and the neural network learns by adapting the weights accordingly based on the error between the prediction or its binarization at the output and the respective correct black-white transitions of the training data set. The black-white transitions to be learned are preferably ideal, i.e. they change from the lightest to the darkest and vice versa only over one position on each edge depending on the code content. This strict requirement does not necessarily have to be met, it is enough that the black-white transitions are successfully read by a suitable decoder. Note that we are talking here about black-white transitions, i.e. transitions with only one bit of color depth. For training, grayscale value transitions that only take the extreme grayscale values, for example 0 and 255, or other very low and high grayscale values, are also of equal value. We will not make any further distinction between them.
[0049] For performance relevant to use, it is advantageous to base the training on real sample images. In this way, the convolutional network is trained to maximally adapt to the effects that appear in reality, especially to the combination of these effects. Preferably, for this purpose, a barcode with a large module width is photographed so that the code content can be reliably read, so that the correct black-white transition appears or can be reconstructed from the code content. The grayscale value transition is reduced (downsampled) to artificially and a posteriori induce a situation in which the barcode is photographed with a small module size (e.g. 0.75 pixels per module). The resolution of the associated black-white transition is correspondingly reduced.
[0050] To reduce discontinuity or sampling artifacts during resolution reduction, it is preferable to first apply a pre-filter according to the target resolution and then sample the filtered signal at the target resolution. Alternatively, a simple averaging calculation can suffice if the scaling factor is an integer. Yet another method is weighted averaging, e.g. 0.5*x1+x2+x3+x4+0.5*x5 for a step size of 3 pixels and a scaling factor of 3 for the neighborhood of each pixel x1 to x5. This operation increases blurring, which may be desirable for training that needs to cover exactly such critical situations.
[0051] Alternatively, or to increase the amount of training data, it is also possible to use artificially generated grayscale value transitions and corresponding black and white transitions. Such transitions can be generated from code content, but in that case, various dissimilarity filters should at least be applied to the grayscale value transitions in order to at least approximate real image capture. Note that such dissimilarity filters are also suitable for deriving additional training data sets from existing training data sets.
[0052] Since a convolutional network is thus trained for a particular module size, it may be worthwhile to scale the input grayscale transitions to this trained module size during runtime, prior to inference. However, careful consideration should be given to whether scaling by a non-integer factor would introduce artifacts that would negate the benefits of the optimized module size.
[0053] Figure 6 shows an exemplary result of the application of a trained convolutional network. The input signal is a sharpened grayscale value transition 32. As already explained in figures 2 and 3, not all extreme values and edges are clearly visible, and the available grayscale range is practically not used up anywhere. In contrast, the sharpened grayscale value transition 34 generated by the convolutional network changes between the minimum and maximum brightness with very sharp edges. The sharpened grayscale value transition 34 coincides with the ideal black-white transition 36 (the correct answer) over a large range. Differences are still visible at the edges and at some extreme values. As can be seen, if we simply set a threshold at the central grayscale value, the binarization using it will be at least very close to the ideal black-white transition 36. This criterion is in any case not perfect here, but is a prerequisite for successful code reading.
[0054] Figures 7a-d show the result in different ways. In Figure 7a, the enhanced grayscale value transition 32 is now duplicated above and below as one image part. This image is unclear and has low contrast. Figure 7b shows the corresponding enhanced grayscale value transition 34. There are now only a few transitions with grayscale values that are neither white nor black. Figure 7c shows the corresponding binarization result. The grayscale values are now eliminated by classifying them as white or black. Figure 7d shows the corresponding ideal black-white transition 36. Comparing Figures 7c and 7d, some slightly thinner bars still remain. But in any case, if such differences in width of bars and gaps are clearly within the range of the module size, the decoder can handle them well, or if not, they can be handled by multiple trials, error correction, etc.
[0055] In another embodiment, the nonlinear filter can be implemented as a classical method instead of a machine learning method. Here we will explain it by using the Richardson-Lucy deconvolution as an example. It is an iterative algorithm that aims to remove the blurring caused by the image capture (deblurring) from the signal. The method is based on the point spread function and assumes that the blurring is caused by convolution with this point spread function in the optical system. The deconvolution can then be used to remove the blurring appropriately.
[0056] Preferably, first it is estimated whether the input high resolution grayscale value transition 32 is blurred to begin with. If so, a Richardson-Lucy iteration process is performed, preferably a predefined number of times. Then, a sharpened grayscale value transition 34 is at hand. As point spread function, for example, a Gaussian blurring function is assumed. The width of the blurring function can be selected depending on the pre-estimated blurring. The number of iterations is chosen by balancing the available computation time, the desired sharpness and possible artifacts due to overcorrection. The point spread functions listed above have been empirically verified. The number and the appropriate point spread function can be varied and selected based on the results.
[0057] Figure 8, constructed similarly to Figure 6, shows a comparison of a sharpened greyscale transition (this time sharpened using a classical method rather than a machine learning method, specifically Richardson-Lucy deconvolution in this example instead of a convolutional network 34) with an ideal black and white transition 36. Again, the nonlinear filter produces a clear improvement, but the convolutional network performs slightly better in the example shown, although there is no significant drop-off after binarization.
[0058] Figures 9a-d show the results again, similar to those in Figures 7a-d, where Figure 9a shows the high-resolution grayscale value transition 32, Figure 9b shows the grayscale value transition sharpened by Richardson-Lucy deconvolution 34, Figure 9c shows the corresponding binarization result, and Figure 9d shows the ideal black and white transition 36.
[0059] The two embodiments specifically described with reference to Fig. 5 to Fig. 9a-d are based on the input of a high-resolution grayscale value transition 32. As already mentioned, the two steps of high-resolution and sharpening can also be performed together. In this case, in particular, an image including a plurality of original grayscale value transitions 30 corresponding to the left diagram of Fig. 4 is received as a two-dimensional input (the plurality of original grayscale value transitions may be optionally further aligned with each other in the row direction), and then a convolutional network is trained that outputs a sharpened grayscale value transition 34 by two-dimensional convolution without explicitly outputting the high-resolution grayscale value transition 32. Optionally, this convolutional network can also learn up to binarization at the same time, but this step is very simple thanks to the pre-processing, so that classical processing may be advantageous.
Claims
1. A method for reading a one-dimensional optical code (20), comprising obtaining image data of the code (20), obtaining from the image data a plurality of greyscale value transitions (30) passing through the code, forming a black-and-white transition from the greyscale value transitions (30) by binarization, and reading the code content of the code (20) from the black-and-white transitions, generating from said plurality of greyscale value transitions (30) a sharpened greyscale value transition (34) having higher resolution, sharper edges and more pronounced extreme values compared to the original image data in preparation for binarization, and binarizing said sharpened greyscale value transition (34) to form said black and white transition; generating a high-resolution grayscale value transition (32) from said plurality of grayscale value transitions (30) in preparation for said binarization; and generating the sharpened grayscale value transition (34) from the high-resolution grayscale value transition (32) by a machine learning method; The method comprising:
2. 2. The method according to claim 1, wherein the machine learning method comprises a neural network, in particular a convolutional network, using a filter kernel of width corresponding to a module size of the code (20) in the enhanced grayscale value transition (32).
3. 2. The method according to claim 1, further comprising generating an enhanced grayscale value transition (32) from said plurality of grayscale value transitions (30) by a machine learning method, in particular a convolutional network.
4. 4. The method according to claim 1, wherein the machine learning method is trained by supervised learning on training data for correlating greyscale value transitions (30, 32, 34) with black-and-white transitions (36), the training data being obtained from pre-given code content or from successfully read codes (20).
5. The method of claim 4 , further comprising reducing the resolution of the training data to obtain training data having a module size of one pixel or less.
6. 2. The method according to claim 1, wherein the image data is acquired during a relative movement between the light receiving element (24) and the coded object (14), in particular line by line.
7. A code reading device (10) for reading a one-dimensional optical code (20), comprising at least one light receiving element (24) for acquiring image data comprising said code (20), and a control and evaluation unit (26) configured to perform the method according to claim 1.
Citation Information
Patent Citations
Optoelectronic sensor and method for recording codes
EP2003599A1
Generation of an image segmented into interesting and uninteresting areas
EP2555160B1
Optoelectronic code reader and method for reading optical codes
EP3428834B1
Code reader and method for reading optical codes
EP3812953A1
Camera and method for processing image data
EP3916633A1
