A method, apparatus, and computer readable medium for decoding a barcode

By using segmented code character sampling and bar/space edge detection, combined with multiple scanning lines, the decoding problem of barcodes when they are dirty, distorted, or have changes in density is solved, enabling accurate barcode reading and making it suitable for cashier and warehousing operations.

CN117521695BActive Publication Date: 2025-11-28SHANGHAI SUMI TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311555053.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-21
Publication Date
2025-11-28
Estimated Expiration
2043-11-21

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately identify and decode barcodes when they are soiled, distorted, or have altered density.

Method used

By segmented codeword sampling and bar/space edge detection, combined with multiple scan lines, the position and width of the barcode start or end symbol are calculated. Interpolation and filtering are then used to achieve accurate decoding of the barcode.

Benefits of technology

Even when the barcode is damaged, twisted, or has a change in density, it can still accurately read the barcode characters, making it suitable for cashier and warehousing operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117521695B_ABST
    Figure CN117521695B_ABST
Patent Text Reader

Abstract

The application provides a barcode decoding method, device and computer readable medium, the method comprising: determining barcode distribution range and arrangement direction; forming first segment of first scanning line from first side of barcode; calculating code word width and minimum module width value of barcode start symbol or end symbol based on detected barcode start symbol or end symbol space position and pixel width value; determining to adopt single scanning line or multiple scanning lines for decoding subsequent code word; starting from end position of first scanning line corresponding to barcode start symbol or end symbol, sequentially obtaining single row of pixels with second width and obtaining pixel gray value to form second segment to Mth segment of first scanning line; when adopting multiple scanning lines, then forming one or more new scanning lines parallel to first scanning line in direction perpendicular to barcode arrangement direction; calculating code word corresponding to second segment to Mth segment of first scanning line.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of barcodes, and in particular to a barcode decoding method, device and computer readable medium. BACKGROUND

[0002] Barcode refers to a symbol composed of bars (i.e. black bars) and spaces (i.e. blank or white bars) according to certain coding rules, also known as one-dimensional code. Barcodes are extremely common in the fields of cash register, warehousing, packaging, etc., and thus accurate recognition of barcodes is an inevitable requirement for effective application of barcodes. However, when a barcode is damaged, distorted or has variable density due to various factors, the acquisition of barcode grayscale data is easily disturbed, and the detection of bar-space positions is also prone to errors, so that the barcode cannot be effectively decoded and recognized. Therefore, how to provide a barcode recognition method with strong robustness is a problem to be solved. SUMMARY

[0003] The technical problem to be solved by the present application is to provide a barcode decoding method, device and computer readable medium, and to realize effective reading of barcodes in various states.

[0004] To solve the above technical problem, the present application provides a barcode decoding method, comprising: acquiring an image of a barcode region of interest in an image, and determining a barcode distribution range and an arrangement direction; acquiring a single row of pixels of a first width from a first side of the barcode in a direction perpendicular to the arrangement direction of the barcode and obtaining pixel grayscale values to form a first segment of a first scan line; based on the first segment of the first scan line, calculating the position and width of a start symbol or an end symbol corresponding to the single row of pixels of the first width; based on the detected bar-space position and pixel width value of the start symbol or the end symbol of the barcode, calculating the code word width and minimum module width value of the start symbol or the end symbol of the barcode; determining whether to use a single scan line or multiple scan lines for decoding subsequent code words according to the number of pixels corresponding to the minimum module width value; starting from the end position of the first scan line corresponding to the start symbol or the end symbol of the barcode, sequentially acquiring a single row of pixels of a second width and obtaining pixel grayscale values to form a second segment to an Mth segment of the first scan line at the end position of the barcode; M is greater than 2 and is a positive integer; when multiple scan lines are used, one or more new scan lines parallel to the first scan line are formed in the direction perpendicular to the arrangement direction of the barcode; based on the second segment to the Mth segment of the first scan line at the end position of the barcode or the second segment to the Mth segment of the first scan line at the end position of the barcode and the segments of the corresponding new scan lines, the code word corresponding to the second segment to the Mth segment of the first scan line is calculated.

[0005] In an embodiment of the present application, the new scan line is n pixels away from the first scan line in a direction perpendicular to the arrangement direction of the barcode, where n is a positive integer.

[0006] In an embodiment of the present application, the position and width of the start symbol or end symbol corresponding to the single row of pixels of the first width are calculated based on the first segment of the first scan line, including: performing a second-order derivation operation on the pixel gray values corresponding to the first segment of the first scan line, and determining the zero-crossing points of each second-order derivative as the positions of the empty boundaries of the first code word to be identified; and calculating the position and width of the start symbol or end symbol corresponding to the single row of pixels of the first width according to the start symbol or end symbol decoding rule of the barcode.

[0007] In an embodiment of the present application, the code words corresponding to the second segment to the Mth segment of the first scan line are calculated based on the second segment to the Mth segment of the first scan line and the corresponding segments of the new scan line from the second segment to the Mth segment of the first scan line to the end position of the barcode, including: calculating the variances of the pixel gray values corresponding to the second segment to the Mth segment of the new scan line and the second segment to the Mth segment of the first scan line, and determining whether to retain the segments of the new scan line according to a first gray threshold; if the segments of the new scan line are retained, then adding the pixel gray values corresponding to the segments of the new scan line to the pixel gray values corresponding to the second segment to the Mth segment of the first scan line to obtain the pixel gray accumulation value of the second segment to the Mth segment of the first scan line or the pixel gray accumulation average of the second segment to the Mth segment of the first scan line; performing a second-order derivation operation on the pixel gray accumulation value of the second segment to the Mth segment of the first scan line or the pixel gray accumulation average of the second segment to the Mth segment of the first scan line, and determining the zero-crossing points of each second-order derivative as the positions of the empty boundaries of the second code word to the Mth code word to be identified; and calculating the first-level decoding result of the code words corresponding to the second segment to the Mth segment of the first scan line according to the code word decoding rule of the barcode.

[0008] In an embodiment of the present application, the code words corresponding to the second segment to the Mth segment of the first scan line are calculated based on the second segment to the Mth segment of the first scan line, including: performing a second-order derivation operation on the pixel gray values of the second segment to the Mth segment of the first scan line, and determining the zero-crossing points of each second-order derivative as the positions of the empty boundaries of the second code word to the Mth code word to be identified; and calculating the first-level decoding result of the code words corresponding to the second segment to the Mth segment of the first scan line according to the code word decoding rule of the barcode.

[0009] In an embodiment of the present application, the method for decoding the barcode further comprises: when the first-level decoding result of the code word corresponding to the second segment to the Mth segment of the first scan line cannot be calculated according to the code word decoding rule of the barcode, obtaining the peak value and the trough value on the numerical curve corresponding to the pixel gray value of the second segment to the Mth segment of the first scan line, and the arrangement positions of the peak value and the trough value in the arrangement direction of the barcode; taking the midpoint of the arrangement positions of the adjacent peak value and trough value in the arrangement direction of the barcode as the bar space boundary position of the code word to be identified; and calculating the second-level decoding result of the code word corresponding to the second segment to the Mth segment of the first scan line according to the code word decoding rule of the barcode.

[0010] In an embodiment of the present application, the method for decoding the barcode further comprises: based on the analysis result of the first segment of the first scan line and the second-level decoding result of the code word corresponding to the second segment to the Mth segment of the first scan line, combining the barcode checking rule to check the calculated barcode code word.

[0011] In an embodiment of the present application, when the coordinates corresponding to the pixel position corresponding to the first scan line or the new scan line have no corresponding gray value in the image of the barcode region of interest in the image, the gray value of the pixel position is calculated by using an interpolation method.

[0012] In an embodiment of the present application, the interpolation method comprises a nearest neighbor interpolation or a bilinear interpolation method.

[0013] In an embodiment of the present application, the method for decoding the barcode further comprises: performing a filtering operation on the pixel gray value accumulation of the second segment to the Mth segment of the first scan line or the pixel gray value accumulation average of the second segment to the Mth segment of the first scan line.

[0014] In an embodiment of the present application, the filtering operation comprises a Gaussian smoothing filtering, a median filtering or a mean filtering.

[0015] In an embodiment of the present application, the barcode comprises a 128 barcode, a 39 code, a standard 25 code or a cross 25 code.

[0016] The present application also provides a decoding device for a barcode, comprising: a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement the method according to any one of the preceding embodiments.

[0017] The present application also provides a computer readable medium storing computer program code, which, when executed by a processor, implements the method according to any one of the preceding embodiments.

[0018] Compared with the prior art, the present application has the following advantages: the technical scheme of the present application realizes accurate and effective reading of the bar code through the mode of segmenting the code word sampling and the bar edge detection, and then combining. Especially when the bar code is damaged, distorted or the printing density of the bar code changes, the code word of the bar code can still be accurately read. BRIEF DESCRIPTION OF DRAWINGS

[0019] The accompanying drawings are included to provide a further understanding of the present application, and are incorporated in and constitute apart of this application, illustrate embodiments of the present application, and together with the description serve to explain the principles of the present application.

[0020] In the drawings:

[0021] Figure 1 is a flow chart of the decoding method of the bar code according to an embodiment of the present application.

[0022] Figure 2 is a schematic diagram of a damaged bar code.

[0023] Figure 3 is a schematic diagram of the result of determining the distribution range and arrangement direction of the bar code according to an embodiment of the present application.

[0024] Figure 4 is a schematic diagram of the result of determining the distribution range and arrangement direction of the bar code according to another embodiment of the present application.

[0025] Figure 5 is a schematic diagram of forming the scanning line for reading the bar code according to an embodiment of the present application.

[0026] Figure 6 is a schematic diagram of forming the scanning line for reading the bar code according to another embodiment of the present application.

[0027] Figure 7 is a schematic diagram of the pixel width corresponding to the code word of the bar code according to an embodiment of the present application.

[0028] Figure 8 is a flow chart of calculating the first-level decoding result of the code word according to an embodiment of the present application.

[0029] Figure 9 is a flow chart of calculating the second-level decoding result of the code word according to an embodiment of the present application.

[0030] Figure 10 is a schematic diagram of determining the position of the wave peak and valley corresponding to the pixel value in the second-level decoding result of the code word according to an embodiment of the present application.

[0031] Figure 11 is a schematic diagram of the composition of the decoding device of the bar code according to an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments description will be briefly introduced. Obviously, the drawings in the following description are only some examples or embodiments of the present application, and for those skilled in the art, the present application can be applied to other similar scenarios without creative labor based on these drawings. Unless the context clearly indicates otherwise or otherwise stated, the same reference numbers in the drawings represent the same structure or operation.

[0033] As shown in the present application and claims, unless the context clearly indicates otherwise or otherwise stated, the words "one", "a", "an", and / or "the" do not necessarily specify a single number, but can also include a plurality. Generally speaking, the terms "comprise" and "include" only indicate the inclusion of the steps and elements explicitly identified, and these steps and elements do not constitute an exclusive list, and the method or device can also include other steps or elements.

[0034] Flowcharts are used in the present application to illustrate the operations performed by the system according to the embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed in sequence. Instead, various steps can be processed in reverse order or simultaneously. Meanwhile, other operations can be added to these processes, or one or more steps of operation can be removed from these processes.

[0035] The embodiments of the present application describe a method, device and computer readable medium for decoding a bar code. The bar code, for example, includes Code 128, Code 39, Standard 25 or Interleaved 25, or other bar codes, such as ISBN (International Standard Book Number).

[0036] Figure 1 is a flowchart of a method for decoding a bar code according to an embodiment of the present application. Referring to Figure 1The decoding method of the barcode comprises the following steps: in step 101, an image of a region of interest of the barcode in the image is acquired, and the distribution range and arrangement direction of the barcode are determined; in step 102, a single row of pixels of a first width is acquired from a first side of the barcode along a direction perpendicular to the arrangement direction of the barcode, and pixel gray value is obtained to form a first segment of a first scan line; in step 103, the position and width of a start symbol or an end symbol corresponding to the single row of pixels of the first width are calculated based on the first segment of the first scan line; in step 104, the code word width and the minimum module width value of the start symbol or the end symbol of the barcode are calculated based on the position and pixel width value of the barcode start symbol or end symbol detected; the single row scan line or the multiple row scan line is determined for decoding the subsequent code word according to the pixel number corresponding to the minimum module width value; in step 105, a single row of pixels of a second width is sequentially acquired from the end position of the first scan line corresponding to the start symbol or the end symbol of the barcode, and pixel gray value is obtained to form a second segment to an Mth segment of the first scan line ending at the end position of the barcode; M is greater than 2 and is a positive integer; when the multiple row scan line is used, one or more new scan lines parallel to the first scan line are formed in the direction perpendicular to the arrangement direction of the barcode; in step 106, the code word corresponding to the second segment to the Mth segment of the first scan line is calculated based on the second segment to the Mth segment of the first scan line or the second segment to the Mth segment of the first scan line and the segment of the corresponding new scan line.

[0037] Figure 2 Fig. 1 is a schematic diagram of a dirty barcode. In step 101, the image of the region of interest of the barcode in the image is acquired, and the distribution range and the arrangement direction of the barcode are determined. Figure 3 Fig. 2 is a schematic diagram of the image processing result of the region of interest of the barcode in the image according to an embodiment of the present application. Since the barcode has certain texture features, i.e., the gradient direction consistency of the local region, the region of interest (ROI) of the barcode to be recognized is obtained by, for example, a gradient detection algorithm, so as to roughly determine the image range to be processed.

[0038] Figure 3 Fig. 3 is a schematic diagram of the result of determining the distribution range and the arrangement direction of the barcode according to an embodiment of the present application. Figure 4 Fig. 4 is a schematic diagram of the result of determining the distribution range and the arrangement direction of the barcode according to another embodiment of the present application. In Figure 3 , the distribution range 301 of the barcode and the arrangement direction AB of the barcode are indicated. For convenience of display, Figure 3 the distribution of the barcode is approximately in the vertical direction. In the actual barcode detection and decoding application process, the barcode can also be in a skew direction, for example, as shown in Figure 4 Figure 4 ​For example, the barcode distribution range 401 and the barcode arrangement direction CD are obtained. For the convenience of presentation, the barcode region of interest in the image in Figure 3 The technical solution content of the present application is described based on the barcode region of interest in the image in

[0039] Figure 5 is a schematic diagram of forming a scanning line for reading a barcode according to an embodiment of the present application. Figure 6 is a schematic diagram of forming a scanning line for reading a barcode according to another embodiment of the present application. Referring to Figure 5 In step 102, a single row of pixels of a first width w1 is obtained from the first side 201a of the barcode along a direction y perpendicular to the barcode arrangement direction ab, and a first segment 501 of a first scanning line 500 is formed based on the pixel grayscale values. In step 103, the position and width of the start symbol or the end symbol corresponding to the single row of pixels of the first width w1 are calculated based on the first segment 501 of the first scanning line 500. The first width w1 is represented by the number of pixels, for example, 20 image pixels. Figure 5 is a schematic diagram of the first scanning line starting to scan from the first side of the barcode when the barcode is placed at a normal angle (relative to human visual perception). Figure 6 is a schematic diagram of the first scanning line starting to scan from the first side of the barcode when the barcode is placed at a reverse angle (relative to human visual perception). In Figure 5 In the above, S0 is actually a start symbol, S7 is an end symbol, and S1 to S6 can be parsed as a code word of a barcode, for example, respectively, wherein S6 is a character for verification. Figure 6 In the above, R0 is an end symbol, R7 is a start symbol, and R1 to R6 can be parsed as a code word of a barcode, for example, respectively, wherein R1 is a character for verification.

[0040] In some embodiments, based on the first segment of the first scanning line, the position and width of the start symbol or the end symbol corresponding to the single row of pixels of the first width are calculated, including: step 411, performing a second-order derivative operation on the pixel grayscale values corresponding to the first segment of the first scanning line, and determining the zero-crossing points of each second-order derivative as the positions of the empty boundaries of the first code word to be identified; and step 412, calculating the position and width of the start symbol or the end symbol corresponding to the single row of pixels of the first width according to the start symbol or the end symbol decoding rules of the barcode. The width w11 of the start symbol or the end symbol is equal to or less than the first width w1.

[0041] Next, in step 104, the code word width and the minimum module width value of the start symbol or the end symbol of the barcode are calculated based on the detected empty space positions and pixel width values of the start symbol or the end symbol of the barcode; and the number of scanning lines for decoding the subsequent code word is determined according to the number of pixels corresponding to the minimum module width value. Figure 7Fig. 1 is a schematic diagram of pixel width corresponding to a code word of reading a barcode according to an embodiment of the present application. Figure 7 Fig. 1 is a schematic diagram of pixel width corresponding to a code word of reading a barcode according to an embodiment of the present application.

[0042] Fig. 1 is a schematic diagram of pixel width corresponding to a code word of reading a barcode according to an embodiment of the present application.

[0043] Fig. 1 is a schematic diagram of pixel width corresponding to a code word of reading a barcode according to an embodiment of the present application. Figure 5 Fig. 1 is a schematic diagram of pixel width corresponding to a code word of reading a barcode according to an embodiment of the present application. Figure 6 In step 105, starting from the end position of the first scan line corresponding to the start symbol or end symbol of the barcode, a single row of pixels with the second width w2 is obtained in sequence and the pixel gray value is obtained to form the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode; M is greater than 2 and is a positive integer; when multiple scan lines are used, one or more new scan lines parallel to the first scan line are formed in the direction perpendicular to the arrangement direction of the barcode. w2 is represented by the number of pixels, for example, 23 image pixels or 25 image pixels. w1 and w2 are similar in length, or w2 is slightly longer than w1, for example, w2 is 5% to 10% longer than w1, or w2 is 3 to 5 pixels longer than w1. Figure 5 In the embodiment, the first scan line 500 includes 8 segments, i.e., M is 8, and specifically includes the second segment 502 of the first scan line 500 to the eighth segment 508 of the first scan line 500. The first scan line 600 includes 8 segments, i.e., M is 8, and specifically includes the second segment 602 of the first scan line 600 to the eighth segment 608 of the first scan line 600. Figure 5 In the embodiment, the multiple new scan lines parallel to the first scan line include the new scan line 510 to the new scan line 540. The new scan line 510 includes the second segment 512 to the eighth segment 518, for example, the new scan line 520 includes the second segment 522 to the eighth segment 528, and so on, and the new scan line 540 includes the second segment 542 to the eighth segment 548, for example.

[0044] In some embodiments, the new scan line is n pixels away from the first scan line in a direction perpendicular to the arrangement direction of the bar code, where n is a positive integer. For example, n can be 2 or 3 or 4 or 5.

[0045] Next, in step 106, the code words corresponding to the second segment to the Mth segment of the first scan line are calculated based on the second segment to the Mth segment of the first scan line or the second segment to the Mth segment of the first scan line and the segments of the corresponding new scan line.

[0046] Figure 8 FIG. 7 is a flowchart of the first-level decoding result of the calculated code words according to an embodiment of the present application. In some embodiments, referring to FIG. 7, the code words corresponding to the second segment to the Mth segment of the first scan line are calculated based on the second segment to the Mth segment of the first scan line and the segments of the corresponding new scan line, which includes the following steps. Figure 8 Figure 8 , the code words corresponding to the second segment to the Mth segment of the first scan line are calculated based on the second segment to the Mth segment of the first scan line and the segments of the corresponding new scan line, which includes the following steps. In step 711, the variances of the pixel gray values corresponding to the second segment to the Mth segment of the new scan line and the second segment to the Mth segment of the first scan line are calculated, and it is determined whether to retain the segments of the new scan line according to the first gray threshold. In step 712, if the segments of the new scan line are retained, the pixel gray values corresponding to the segments of the new scan line are added to the pixel gray values corresponding to the second segment to the Mth segment of the first scan line to obtain the pixel gray accumulation value of the second segment to the Mth segment of the first scan line or the pixel gray accumulation average value of the second segment to the Mth segment of the first scan line. The pixel gray accumulation average value is the pixel gray accumulation value divided by the number of scan lines. In step 713, the second-order derivative operation is performed on the pixel gray accumulation value of the second segment to the Mth segment of the first scan line or the pixel gray accumulation average value of the second segment to the Mth segment of the first scan line, and the zero-crossing points of each second-order derivative are determined as the positions of the empty boundaries of the second code word to the Mth code word to be recognized. In step 714, the first-level decoding result of the code words corresponding to the second segment to the Mth segment of the first scan line is calculated according to the code word decoding rule of the bar code. The first gray threshold th1 can be, for example, 5 or 8 or 10, and can also be adjusted as needed.

[0047] In some embodiments, the code words corresponding to the second segment to the Mth segment of the first scan line are calculated based on the second segment to the Mth segment of the first scan line, which includes the following steps. In step 721, the second-order derivative operation is performed on the pixel gray values of the second segment to the Mth segment of the first scan line, and the zero-crossing points of each second-order derivative are determined as the positions of the empty boundaries of the second code word to the Mth code word to be recognized. In step 722, the first-level decoding result of the code words corresponding to the second segment to the Mth segment of the first scan line is calculated according to the code word decoding rule of the bar code.

[0048] Figure 9 is a flowchart of calculating the second-level decoding result of the code word according to an embodiment of the present application. In some embodiments, referring to Figure 9 , the decoding method of the barcode further includes: when the first-level decoding result of the code word corresponding to the second segment to the Mth segment of the first scan line cannot be calculated according to the code word decoding rule of the barcode, obtaining the peak value and the trough value on the numerical curve corresponding to the pixel gray value of the second segment to the Mth segment of the first scan line, and the arrangement position of the peak value and the trough value in the arrangement direction of the barcode; taking the midpoint of the arrangement position of the adjacent peak value and the trough value in the arrangement direction of the barcode as the bar space boundary position of the code word to be identified; and calculating the second-level decoding result of the code word corresponding to the second segment to the Mth segment of the first scan line according to the code word decoding rule of the barcode.

[0049] Figure 10 is a schematic diagram of determining the peak and trough positions corresponding to the pixel value in the calculation of the second-level decoding result of the code word according to an embodiment of the present application. Referring to Figure 10 , the peak value and the trough value on the numerical curve corresponding to the pixel gray value of the second segment to the Mth segment of the first scan line, and the arrangement position of the peak value and the trough value in the arrangement direction of the barcode are, for example, the first peak value p1, the second peak value p3, the third peak value p5, the fourth peak value p7, and the fifth peak value p9, and further include the first trough value p2, the second trough value p4, the third trough value p6, the fourth trough value p8, and the fifth trough value p10. t1 and t2 are, for example, the preliminary pixel threshold value for screening the peak value and the preliminary pixel threshold value for screening the trough value, respectively. Taking the midpoint of the arrangement position of the adjacent peak value and the trough value in the arrangement direction of the barcode as the bar space boundary position of the code word to be identified, the bar space boundary positions 901, 902, and 909 of the code word to be identified can be obtained, which are the midpoints of the arrangement position of the adjacent peak value and the trough value in the arrangement direction y of the barcode, respectively. Figure 10 The z-axis in the diagram represents the number axis corresponding to the pixel gray value. In the present application, the pixel gray value interval is, for example, [0, 255], in which 0 represents pure black and 255 represents pure white. In practice, it can also be represented in the opposite way, for example, 0 represents pure white and 255 represents pure black.

[0050] In some embodiments, the decoding method of the barcode further comprises, for example, based on the analysis result of the first segment of the first scan line and the second-level decoding result of the code word corresponding to the second segment to the Mth segment of the first scan line, combining the barcode check rule to check the calculated barcode code word. In addition, the decoding method of the barcode further comprises, for example, calculating multiple first-level decoding results for each to-be-identified code word, and taking the decoding result with the highest frequency in the multiple first-level decoding results as the final result of the first-level decoding of the to-be-identified code word. Alternatively, multiple second-level decoding results are calculated for each to-be-identified code word, and the decoding result with the highest frequency in the multiple second-level decoding results is taken as the final result of the second-level decoding of the to-be-identified code word.

[0051] In some embodiments, when the pixel position corresponding to the first scan line or the new scan line corresponds to no corresponding gray value in the image in the image region of interest of the barcode in the image, the gray value of the pixel position is calculated by interpolation. The interpolation method includes nearest neighbor interpolation or bilinear interpolation. Figure 10 The multiple rows of pixel values in the image are obtained by interpolation based on the multiple scan lines.

[0052] In some embodiments, the decoding method of the barcode further comprises, for example, performing a filtering operation on the pixel gray value accumulation of the second segment to the Mth segment of the first scan line or the pixel gray value accumulation average of the second segment to the Mth segment of the first scan line. The filtering operation includes Gaussian smoothing filtering, median filtering or mean filtering.

[0053] The barcode decoding method of the present application realizes accurate and effective reading of the barcode by segmenting the code word sampling and the barcode space edge detection, and then combining. Especially when the barcode is damaged, distorted or the barcode printing density changes, the code word of the barcode can still be accurately identified, thereby facilitating the smooth operation of the barcode application related business, such as cash register or warehouse business.

[0054] The present application also provides a barcode decoding device, comprising: a memory for storing instructions executable by a processor; and a processor for executing instructions to implement the method as described above.

[0055] Figure 11A schematic diagram of a barcode decoding apparatus according to an embodiment of the present application is shown. The barcode decoding apparatus 1100 can include an internal communication bus 1101, a processor 1102, a read-only memory (ROM) 1103, a random access memory (RAM) 1104, and a communication port 1105. The barcode decoding apparatus 1100 is connected to a network through the communication port and can be connected to other devices. The internal communication bus 1101 can enable data communication between the components of the barcode decoding apparatus 1100. The processor 1102 can make decisions and issue prompts. In some embodiments, the processor 1102 can be composed of one or more processors. The communication port 1105 can enable sending and receiving information and data from the network. The barcode decoding apparatus 1100 can also include different forms of program storage units and data storage units, such as the read-only memory (ROM) 1103 and the random access memory (RAM) 1104, which can store various data files used by the computer processing and / or communication, and possible program instructions executed by the processor 1102. The processor executes these instructions to implement the main part of the method. The results of the processor processing can be transmitted to the user device through the communication port and displayed on the user interface.

[0056] The barcode decoding apparatus 1100 described above can be implemented as a computer program, stored in a memory and executable by the processor 1102 to implement the barcode decoding method of the present application.

[0057] The present application also provides a computer readable medium storing computer program code which, when executed by a processor, implements the barcode decoding method as described above.

[0058] Some aspects of the present application can be completely executed by hardware, completely executed by software (including firmware, resident software, microcode, etc.), or executed by a combination of hardware and software, such as a script program and a corresponding running platform. The above hardware or software can be referred to as "data block", "module", "engine", "unit", "component" or "system". The processor can be one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DAPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, or combinations thereof. In addition, aspects of the present application can be embodied as a computer product located in one or more computer readable media, which includes computer readable program code. For example, the computer readable medium can include, but is not limited to, magnetic storage devices (e.g., hard disk, floppy disk, magnetic tape…), optical disks (e.g., compact disk CD, digital versatile disk DVD…), smart cards, and flash memory devices (e.g., card, stick, key drive…).

[0059] A computer readable medium can include a propagated data signal with computer program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal can take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any combination thereof. Computer readable medium can be any medium that can be read by a computer, including magnetic cassettes, optical disks, hard disk drives, solid state drives, RAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic or optical cards, or any combination thereof. Computer readable medium can be any computer readable medium except for a transitory signal per se.

[0060] Similarly, it is to be noticed that the term "comprising", used in the description, should not be interpreted as being restricted to the means listed thereafter; it does not exclude other elements or steps. It is thus to be interpreted as specifying the presence of the stated features, integers, steps or components as referred to, but does not preclude the presence or addition of one or more other features, integers, steps or components, or groups thereof. Thus, the scope of the expression should be commensurate to the scope of the appended claims.

[0061] While this application has been described in terms of particular embodiments, it is not intended that it be limited to the specific embodiments described. Many modifications, variations, and alternatives to the one or more embodiments of the application can be made and it is intended that the application embrace all such modifications, variations, and alternatives that fall within the scope of the present application.

Claims

1. A method for decoding a barcode, comprising: acquiring an image of a region of interest of a barcode in an image, and determining a distribution range and an arrangement direction of the barcode; acquiring a first width of single row of pixels from a first side of the barcode along a direction perpendicular to the arrangement direction of the barcode, and obtaining pixel grayscale values to form a first segment of a first scan line; calculating a position and a width of a start symbol or an end symbol corresponding to the first width of single row of pixels based on the first segment of the first scan line; calculating a code word width and a minimum module width of the start symbol or the end symbol based on the detected position and pixel width value of the barcode start symbol or end symbol, and determining whether to use single scan line or multiple scan lines for decoding subsequent code words according to the number of pixels corresponding to the minimum module width; acquiring a second width to an Mth width of single row of pixels from an end position of the first scan line corresponding to the start symbol or the end symbol of the barcode, and obtaining pixel grayscale values to form a second segment to an Mth segment of the first scan line corresponding to the end position of the barcode; M is greater than 2 and is a positive integer; when multiple scan lines are used, one or more new scan lines parallel to the first scan line are formed in the direction perpendicular to the arrangement direction of the barcode; calculating code words corresponding to the second segment to the Mth segment based on the second segment to the Mth segment of the first scan line, or calculating code words corresponding to the second segment to the Mth segment based on the second segment to the Mth segment of the new scan line.

2. The method of decoding a barcode according to claim 1, wherein, The new scan line is n pixels away from the first scan line in the direction perpendicular to the arrangement direction of the barcode, and n is a positive integer.

3. The method of decoding a barcode according to claim 1, wherein, The calculation of the position and the width of the start symbol or the end symbol corresponding to the first width of single row of pixels based on the first segment of the first scan line comprises: performing a second-order derivative operation on the pixel grayscale values corresponding to the first segment of the first scan line, and determining the zero-crossing points of each second-order derivative as the space boundary positions of the first code word to be recognized; calculating the position and the width of the start symbol or the end symbol corresponding to the first width of single row of pixels according to the start symbol or the end symbol decoding rule of the barcode.

4. The method of decoding a barcode according to claim 1, wherein, The calculation of the code words corresponding to the second segment to the Mth segment of the first scan line based on the second segment to the Mth segment of the first scan line and the corresponding segment of the new scan line comprises: calculating the variance of the pixel grayscale values corresponding to the second segment to the Mth segment of the new scan line and the second segment to the Mth segment of the first scan line, and determining whether to retain the segment of the new scan line according to a first grayscale threshold value; if the segment of the new scan line is retained, the pixel grayscale values corresponding to the segment of the new scan line are added to the pixel grayscale values corresponding to the second segment to the Mth segment of the first scan line to obtain pixel grayscale cumulative values of the second segment to the Mth segment of the first scan line or pixel grayscale cumulative average values of the second segment to the Mth segment of the first scan line; performing a second-order derivation operation on the pixel gray scale cumulative values of the second segment to the Mth segment of the first scan line or the pixel gray scale cumulative average values of the second segment to the Mth segment of the first scan line, and determining the zero-crossing points of each second-order derivative as the positions of the empty boundaries of the second code word to the Mth code word to be identified; calculating the first-level decoding results of the code words corresponding to the second segment to the Mth segment of the first scan line according to the code word decoding rules of the barcode.

5. The method of decoding a barcode according to claim 1, wherein, based on the Mth segment of the first scan line from the second segment to the end position of the barcode, calculating the code words corresponding to the second segment to the Mth segment of the first scan line, including: performing a second-order derivation operation on the pixel gray scale cumulative values of the second segment to the Mth segment of the first scan line or the pixel gray scale cumulative average values of the second segment to the Mth segment of the first scan line, and determining the zero-crossing points of each second-order derivative as the positions of the empty boundaries of the second code word to the Mth code word to be identified; calculating the first-level decoding results of the code words corresponding to the second segment to the Mth segment of the first scan line according to the code word decoding rules of the barcode.

6. The method of decoding a barcode according to claim 4 or 5, wherein, Further comprising: when the first-level decoding results of the code words corresponding to the second segment to the Mth segment of the first scan line cannot be calculated according to the code word decoding rules of the barcode, obtaining the peak value and the trough value on the numerical curve corresponding to the pixel gray scale values of the second segment to the Mth segment of the first scan line, and the arrangement positions of the peak value and the trough value in the arrangement direction of the barcode; taking the midpoint of the arrangement positions of the adjacent peak value and trough value in the arrangement direction of the barcode as the empty boundary position of the code word to be identified; calculating the second-level decoding results of the code words corresponding to the second segment to the Mth segment of the first scan line according to the code word decoding rules of the barcode.

7. The method of decoding a barcode according to claim 6, wherein, Further comprising: based on the analysis result of the first segment of the first scan line and the second-level decoding results of the code words corresponding to the second segment to the Mth segment of the first scan line, combining the barcode check rules to check the calculated barcode code words.

8. The method of decoding a barcode according to claim 1, wherein, when the pixel position corresponding to the coordinates of the first scan line or the new scan line has no corresponding gray scale value in the image in the barcode region of interest in the image, the gray scale value of the pixel position is calculated by interpolation.

9. The method of decoding a barcode according to claim 8, wherein, The interpolation method includes nearest neighbor interpolation or bilinear interpolation.

10. The method of decoding a barcode according to claim 1, wherein, Further comprising: performing a filter operation on the pixel gray scale cumulative values of the second segment to the Mth segment of the first scan line or the pixel gray scale cumulative average values of the second segment to the Mth segment of the first scan line.

11. The method of decoding a barcode according to claim 10, wherein, The filter operation includes Gaussian smoothing filter, median filter or mean filter.

12. The method of decoding a barcode according to claim 1, wherein, The barcode includes 128 barcode, 39 code, standard 25 code, cross 25 code or international standard book number code.

13. A barcode decoding apparatus, comprising: a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement the method of any one of claims 1-12.

14. A computer readable medium storing computer program code which, when executed by a processor, implements the method of any one of claims 1-12.

Citation Information

Patent Citations

  • Bar code decoding method and apparatus

    CN106991348A

  • Decoding method and device of twisted bar code and electronic equipment

    CN115688826A