Barcode decoding method and apparatus, and computer readable medium

By acquiring and processing scan line segments in the image in barcode technology, calculating codeword position and width, the barcode reading problem is solved when deficient or density changes, and efficient codeword decoding is achieved.

WO2025108368A1PCT designated stage expired Publication Date: 2025-05-30SHANGHAI SUMI TECH CO LTD

Patent Information

Application Number
PCT/CN2024/133491
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-11-21
Filing Date
2024-11-21
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The prior art is difficult to effectively read when barcodes are damaged, distorted or print density changes, resulting in the inability to accurately decode them.

Method used

By acquiring the image of the region of interest of the barcode in the image, determining the barcode distribution range and arrangement direction, and obtaining a single-row pixel grayscale value along the vertical direction of the barcode arrangement direction, forming a scanning line segment. Based on these segments, the position and width of the codeword start or ending character is calculated, the codeword width and the minimum module width are determined, and a single or multiple scanning lines are used for codeword decoding.

Benefits of technology

It realizes effective reading of barcodes in various states, especially when defilement, distortion or density changes, to ensure the smoothness of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024133491_30052025_PF_FP_ABST
    Figure CN2024133491_30052025_PF_FP_ABST
Patent Text Reader

Abstract

The present invention provides a barcode decoding method and apparatus, and a computer readable medium. The method comprises: determining a barcode distribution range and a barcode arrangement direction; forming a first segment of a first scan line from a first side of a barcode; on the basis of detected bar and space positions and measured pixel width values of a start character or end character of the barcode, calculating a code word width and the minimum module width value of the start character or end character of the barcode; determining to use a single scan line or a plurality of scan lines to perform subsequent code word decoding; starting with the end position of the first scan line corresponding to the start character or end character of the barcode, sequentially acquiring a single row of pixels of a second width and obtaining pixel gray values to form an Mth segment from a second segment of the first scan line to the end position of the barcode; when a plurality of scan lines are used, forming one or more new scan lines parallel to the first scan line in a direction perpendicular to the barcode arrangement direction; and calculating a code word corresponding to the second segment to the Mth segment of the first scan line.
Need to check novelty before this filing date? Find Prior Art

Description

Barcode decoding method, device and computer-readable medium Technical Field

[0001] The present invention relates to the field of barcode technology, and in particular to a barcode decoding method, device and computer-readable medium. Background Art

[0002] A barcode is 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 a one-dimensional code. Barcodes are extremely commonly used in areas such as cash registers, warehousing, and packaging, and accurate barcode recognition is therefore essential for their effective application. However, when a barcode is damaged, distorted, or printed with variable density due to various factors, the acquisition of the barcode's grayscale data is easily interfered with, and the detection of the bar and space positions is also prone to errors, making it impossible to effectively decode and recognize the barcode. Therefore, how to provide a barcode recognition method with strong robustness is a problem that needs to be addressed. Summary of the Invention

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

[0004] To solve the above technical problems, the present invention provides a barcode decoding method, comprising: acquiring an image of a barcode region of interest in an image, and determining the distribution range and arrangement direction of the barcode; acquiring a single row of pixels of a first width starting 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; 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 first segment of the first scan line; calculating the codeword width and minimum module width value of the start symbol or end symbol of the barcode based on the detected bar space position and pixel width value of the start symbol or end symbol of the barcode; and determining, based on the number of pixels corresponding to the minimum module width value, whether to use a single scan line or an end symbol for subsequent codeword decoding. Multiple scan lines; starting from the end position of the first scan line corresponding to the start character or the end character of the barcode, sequentially acquiring a single row of pixels of a second width and obtaining pixel grayscale values ​​to form a 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 a direction perpendicular to the arrangement direction of the barcode; based on the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode or the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode and the segment of the corresponding new scan line, the code words corresponding to the second segment to the Mth segment of the first scan line are calculated.

[0005] In one embodiment of the present invention, 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 one embodiment of the present invention, based on the first segment of the first scan line, calculating the position and width of the start symbol or end symbol corresponding to a single row of pixels of the first width includes: performing a second-order derivative operation on the pixel grayscale value corresponding to the first segment of the first scan line, and determining the zero-crossing position of each second-order derivative as the position of each empty boundary 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 rules of the bar code.

[0007] In one embodiment of the present invention, based on the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode and the corresponding segment of the new scan line, calculating the codeword corresponding to the second segment to the Mth segment of the first scan line includes: 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; if the segment of the new scan line is to be retained, comparing the pixel grayscale values ​​corresponding to the segment of the new scan line with the pixel grayscale values ​​corresponding to the second segment to the Mth segment of the first scan line; The pixel grayscale values ​​are accumulated to obtain the pixel grayscale accumulated values ​​from the second segment to the Mth segment of the first scan line or the pixel grayscale accumulated average value from the second segment to the Mth segment of the first scan line; a second-order derivative operation is performed on the pixel grayscale accumulated values ​​from the second segment to the Mth segment of the first scan line or the pixel grayscale accumulated average value from the second segment to the Mth segment of the first scan line, and the zero-crossing position of each second-order derivative is respectively determined as the position of each empty boundary of the second codeword to be identified to the Mth codeword; and a first-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line is calculated according to the codeword decoding rules of the barcode.

[0008] In one embodiment of the present invention, calculating the code words corresponding to the second segment to the Mth segment of the first scan line based on the second segment of the first scan line to the end position of the barcode includes: performing a second-order derivative operation on the pixel grayscale of the second segment to the Mth segment of the first scan line, and determining the zero-crossing position of each second-order derivative as the position of each empty boundary of the second code word to be identified to the Mth code word; and calculating the first-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.

[0009] In one embodiment of the present invention, the barcode decoding method further includes: when a first-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line cannot be calculated according to the barcode codeword decoding rules, obtaining the peak value and trough value on the numerical curve corresponding to the pixel grayscale values ​​of the second segment to the Mth segment of the first scan line, and the arrangement position of the peak value and trough value in the arrangement direction of the barcode; using the midpoint of the arrangement position of adjacent peak value and trough value in the arrangement direction of the barcode as the bar-space boundary position of the codeword to be identified; and calculating the second-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line according to the barcode codeword decoding rules.

[0010] In one embodiment of the present invention, the barcode decoding method further includes: based on the analysis result of the first segment of the first scan line and the second-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line, combined with the barcode verification rule, verifying the calculated barcode codeword.

[0011] In one embodiment of the present invention, when the coordinates corresponding to the pixel position corresponding to the first scan line or the new scan line have no corresponding grayscale value in the image of the barcode ROI, the grayscale value of the pixel position is calculated by interpolation.

[0012] In one embodiment of the present invention, the interpolation method includes nearest neighbor interpolation or bilinear interpolation.

[0013] In one embodiment of the present invention, the barcode decoding method further includes: performing a filtering operation on the accumulated grayscale value of pixels from the second segment to the Mth segment of the first scan line or the accumulated average grayscale value of pixels from the second segment to the Mth segment of the first scan line.

[0014] In one embodiment of the present invention, the filtering operation includes Gaussian smoothing filtering, median filtering or mean filtering.

[0015] In one embodiment of the present invention, the barcode includes Code 128, Code 39, standard 25 code or cross 25 code.

[0016] The present invention also provides a barcode decoding device, comprising: a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement any of the methods described above.

[0017] The present invention also provides a computer-readable medium storing computer program code, wherein the computer program code implements the method as described in any one of the preceding items when executed by a processor.

[0018] Compared with existing technologies, the present invention has the following advantages: The present invention's technical solution achieves accurate and effective barcode reading through segmented codeword sampling and bar / space edge detection, combined with a method that achieves accurate and effective barcode reading. This is especially true when barcodes are stained, distorted, or have varying print density.

[0019] Summary of the Figures

[0020] The above and other features, properties and advantages of the present invention will become more apparent through the following description in conjunction with the accompanying drawings and embodiments, in which:

[0021] FIG1 is a flow chart of a barcode decoding method according to an embodiment of the present invention;

[0022] FIG2 is a schematic diagram of a damaged barcode;

[0023] FIG3 is a schematic diagram showing the results of determining the distribution range and arrangement direction of bar codes according to an embodiment of the present invention;

[0024] FIG4 is a schematic diagram showing the results of determining the distribution range and arrangement direction of bar codes according to another embodiment of the present invention;

[0025] FIG5 is a schematic diagram of a scan line for forming a barcode for reading according to an embodiment of the present invention;

[0026] FIG6 is a schematic diagram of a scan line for forming a barcode for reading according to another embodiment of the present invention;

[0027] FIG7 is a schematic diagram of pixel widths corresponding to code words in a barcode according to an embodiment of the present invention;

[0028] FIG8 is a flow chart of calculating a first-level decoding result of a codeword according to an embodiment of the present invention;

[0029] FIG9 is a flow chart of calculating the second-stage decoding result of a codeword according to an embodiment of the present invention;

[0030] FIG10 is a schematic diagram showing peak and valley positions corresponding to pixel values ​​determined in a second-stage decoding result of a codeword calculated according to an embodiment of the present invention;

[0031] FIG. 11 is a schematic diagram showing the composition of a barcode decoding device according to an embodiment of the present invention.

[0032] Preferred embodiments of the present invention

[0033] The present invention is further described below in conjunction with specific implementation methods and accompanying drawings. More details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can obviously be implemented in a variety of other ways different from the description. Those skilled in the art can make similar generalizations and deductions based on actual application situations without violating the connotation of the present invention. Therefore, the scope of protection of the present invention should not be limited by the content of this specific implementation method.

[0034] For example, a description later in the specification of a first feature being formed above or on a second feature may include an embodiment in which the first and second features are directly connected, or an embodiment in which an additional feature is formed between the first and second features, thereby eliminating the need for a direct connection between the first and second features. Furthermore, when a first element is described as being connected to or coupled to a second element, the description includes embodiments in which the first and second elements are directly connected or coupled to each other, as well as embodiments in which the first and second elements are indirectly connected or coupled to each other using one or more other intervening elements.

[0035] Although the present invention is disclosed above with reference to preferred embodiments, this is not intended to limit the present invention. Any person skilled in the art may make possible changes and modifications without departing from the spirit and scope of the present invention. Therefore, any modifications, equivalent variations, and modifications made to the above embodiments in accordance with the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the scope of protection defined by the claims of the present invention.

[0036] The present invention provides a method, apparatus, and computer-readable medium for decoding a barcode. The barcode may include, for example, Code 128, Code 39, Standard 2 of 5, or Interleaved 2 of 5, or other barcodes such as an ISBN (International Standard Book Number).

[0037] FIG1 is a flow chart of a barcode decoding method according to an embodiment of the present invention. Referring to FIG1 , the barcode decoding method includes the following steps: step 101, obtaining an image of a barcode region of interest in an image, and determining the distribution range and arrangement direction of the barcode; step 102, obtaining a single row of pixels of a first width from the 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; step 103, based on the first segment of the first scan line, calculating the position and width of the start symbol or end symbol corresponding to the single row of pixels of the first width; step 104, calculating the codeword width and minimum module width value of the start symbol or end symbol of the barcode based on the detected bar space position and pixel width value of the start symbol or end symbol of the barcode; and determining whether to use a single scan line for subsequent codeword decoding based on the number of pixels corresponding to the minimum module width value. Scan line or multiple scan lines; step 105, starting from the end position of the first scan line corresponding to the start character or the end character of the barcode, sequentially obtain a single row of pixels of the second width and obtain pixel grayscale values ​​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 a direction perpendicular to the arrangement direction of the barcode; step 106, based on the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode or the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode and the segment of the corresponding new scan line, calculate and obtain the codeword corresponding to the second segment to the Mth segment of the first scan line.

[0038] Figure 2 is a schematic diagram of a damaged barcode. In step 101, an image of a barcode region of interest is acquired, and the barcode distribution range and barcode arrangement direction are determined. Figure 3 is a schematic diagram of the image processing results of a barcode region of interest in an image according to one embodiment of the present invention. Because barcodes have certain texture characteristics, namely, the consistency of gradient direction in local areas, a region of interest (ROI) of the barcode to be identified can be obtained, for example, through a gradient detection algorithm, thereby roughly determining the image range to be processed.

[0039] FIG3 is a schematic diagram of the results of determining the barcode distribution range and arrangement direction according to one embodiment of the present invention. FIG4 is a schematic diagram of the results of determining the barcode distribution range and arrangement direction according to another embodiment of the present invention. In FIG3 , the barcode distribution range 301 and the barcode arrangement direction AB are indicated. For ease of presentation, the barcode distribution in FIG3 is generally vertical. In actual barcode detection and decoding applications, the barcode may also be skewed, as shown in FIG4 . Based on FIG4 , for example, the barcode distribution range 401 and the barcode arrangement direction CD are obtained. For ease of presentation, the technical solution of the present invention is still described based on the barcode region of interest in the image in FIG3 .

[0040] FIG5 is a schematic diagram of forming a scan line for reading a barcode according to one embodiment of the present invention. FIG6 is a schematic diagram of forming a scan line for reading a barcode according to another embodiment of the present invention. Referring to FIG5 , in step 102, a single row of pixels of a first width w1 is acquired starting from the first side 201a of the barcode along a direction y perpendicular to the barcode arrangement direction ab, and the pixel grayscale values ​​are obtained to form a first segment 501 of the first scan line 500. In step 103, based on the first segment 501 of the first scan line 500, the position and width of the start symbol or end symbol corresponding to the single row of pixels of the first width w1 are calculated. w1 is represented, for example, by the number of pixels, such as 20 image pixels. FIG5 is a schematic diagram of scanning the barcode starting from the first side of the barcode when the barcode is at a normal display angle (relative to human vision). FIG6 is a schematic diagram of scanning the barcode starting from the first side of the barcode when the barcode is at a reverse display angle (relative to human vision). In Figure 5, S0 is actually a start character, S7 is an end character, and S1 to S6 can each be parsed into a barcode codeword, with S6 being the character used for verification. In Figure 6, R0 is an end character, R7 is a start character, and R1 to R6 can each be parsed into a barcode codeword, with R1 being the character used for verification.

[0041] In some embodiments, calculating the position and width of a start symbol or an end symbol corresponding to a single row of pixels of a first width based on a first segment of a first scan line includes: step 411, performing a second-order derivative operation on the grayscale values ​​of the pixels corresponding to the first segment of the first scan line, and determining the zero-crossing positions of each second-order derivative as the positions of each blank boundary of the first codeword to be identified; 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.

[0042] Next, in step 104, based on the detected bar and space positions and pixel width values ​​of the barcode start or end character, the codeword width and minimum module width value of the barcode start or end character are calculated; based on the number of pixels corresponding to the minimum module width value, it is determined whether a single scan line or multiple scan lines are used for subsequent codeword decoding. Figure 7 is a schematic diagram of the pixel width corresponding to the codeword of a barcode read according to an embodiment of the present invention. Figure 7 shows the distribution of bar and space positions of a barcode end character, and the corresponding bar and space pixel width values ​​are, for example, 20, 30, 30, 10, 10, 10, and 20. The minimum module width value (or minimum module size) is (20+30+30+10+10+10+20) / 13=10. In Code 128, for the end character, the minimum module width value is the codeword pixel width value divided by 13. For other characters or codewords, the minimum module width value is the codeword pixel width value of 11.

[0043] Determining whether to use a single scan line or multiple scan lines for decoding subsequent codewords based on the number of pixels corresponding to the minimum module width value includes, for example: when the number of pixels corresponding to the minimum module width value is less than or equal to 2, decoding the subsequent codewords using a single scan line. When the number of pixels corresponding to the minimum module width value is greater than 2, decoding the subsequent codewords using multiple scan lines. The pixel number threshold of 2 is used as an example, and may actually be 1, 3, or 4, for example, and may be a positive integer.

[0044] Continuing with Figures 5 and 6, in step 105, starting from the end position of the first scan line corresponding to the start or end symbol of the barcode, a single row of pixels of a second width w2 is sequentially acquired and pixel grayscale values ​​are 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 a positive integer. When multiple scan lines are used, one or more new scan lines are formed parallel to the first scan line in a direction perpendicular to the barcode arrangement direction. w2 is represented, for example, by the number of pixels, such as 23 image pixels or 25 image pixels. w1 and w2 are of similar 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. In Figure 5, the first scan line 500 includes 8 segments, i.e., M is 8, specifically including the second segment 502 of the first scan line 500 to the eighth segment 508 of the first scan line 500. First scan line 600 includes eight segments, i.e., M is 8, specifically including the second segment 602 of first scan line 600 to the eighth segment 608 of first scan line 600. In FIG5 , multiple new scan lines parallel to the first scan line include new scan line 510 to new scan line 540. New scan line 510, for example, includes the second segment 512 to the eighth segment 518, new scan line 520, for example, includes the second segment 522 to the eighth segment 528, ..., and new scan line 540, for example, includes the second segment 542 to the eighth segment 548.

[0045] In some embodiments, the new scan line is n pixels away from the first scan line in a direction perpendicular to the barcode arrangement direction, where n is a positive integer, for example, 2, 3, 4, or 5.

[0046] Next, in step 106, based on the second segment of the first scan line to the Mth segment of the first scan line at the end position of the bar code or the second segment of the first scan line to the Mth segment of the first scan line at the end position of the bar code and the segment of the corresponding new scan line, the code word corresponding to the second segment of the first scan line to the Mth segment is calculated.

[0047] FIG8 is a flowchart illustrating a first-level decoding result of a codeword according to an embodiment of the present invention. In some embodiments, referring to FIG8 , calculating the codeword corresponding to the second to Mth segments of the first scan line based on the segment from the second segment of the first scan line to the end position of the barcode and the corresponding segment of the new scan line includes: Step 711: Calculating the variance of the pixel grayscale values ​​corresponding to the second to Mth segments of the new scan line and the second to Mth segments of the first scan line, and determining whether to retain the segment of the new scan line based on a first grayscale threshold. Step 712: If the segment of the new scan line is to be retained, then accumulating the pixel grayscale values ​​corresponding to the segment of the new scan line with the pixel grayscale values ​​corresponding to the second to Mth segments of the first scan line to obtain the accumulated pixel grayscale value of the second to Mth segments of the first scan line or the accumulated average pixel grayscale value of the second to Mth segments of the first scan line. The accumulated average pixel grayscale value is the accumulated pixel grayscale value divided by the number of scan lines. In step 713, a second-order derivative is calculated for the accumulated grayscale values ​​of the pixels from the second segment to the Mth segment of the first scan line, or the accumulated average grayscale values ​​of the pixels from the second segment to the Mth segment of the first scan line. The zero-crossing points of each second-order derivative are determined as the positions of the barcode boundaries of the second to the Mth codewords to be identified. In step 714, the first-level decoding results of the codewords corresponding to the second to the Mth segments of the first scan line are calculated according to the barcode codeword decoding rules. The first grayscale threshold th1 is, for example, 5, 8, or 10, and can be adjusted as needed.

[0048] In some embodiments, based on the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode, calculating the code words corresponding to the second segment to the Mth segment of the first scan line includes: step 721, performing a second-order derivative operation on the pixel grayscale of the second segment to the Mth segment of the first scan line, and determining the zero-crossing position of each second-order derivative as the position of each empty boundary of the second code word to be identified to the Mth code word; step 722, according to the code word decoding rules of the barcode, calculating the first-level decoding result of the code word corresponding to the second segment to the Mth segment of the first scan line.

[0049] FIG9 is a flowchart of calculating a second-level decoding result of a codeword according to an embodiment of the present invention. In some embodiments, referring to FIG9 , the barcode decoding method further includes: step 811, when the first-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line cannot be calculated according to the barcode codeword decoding rules, obtaining the peak value and trough value on the numerical curve corresponding to the pixel grayscale values ​​of the second segment to the Mth segment of the first scan line, as well as the arrangement position of the peak value and trough value in the barcode arrangement direction; step 812, using the midpoint of the arrangement position of adjacent peak value and trough value in the barcode arrangement direction as the bar-space boundary position of the codeword to be identified; and step 813, calculating the second-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line according to the barcode codeword decoding rules.

[0050] FIG10 is a schematic diagram illustrating the peak and valley positions corresponding to pixel values ​​in the second-level decoding result of a codeword calculated according to an embodiment of the present invention. Referring to FIG10 , the peak and valley values ​​on the numerical curve corresponding to the grayscale values ​​of pixels from the second segment to the Mth segment of the first scan line are arranged in the barcode arrangement direction, for example, as 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. Furthermore, the first valley value p2, the second valley value p4, the third valley value p6, the fourth valley value p8, and the fifth valley value p10 are also included. For example, t1 and t2 are the preliminary pixel thresholds for filtering peak values ​​and valley values, respectively. The midpoints of the positions of adjacent peak and valley values ​​in the barcode arrangement direction are used as the bar / space boundary positions of the codeword to be identified. The bar / space boundary positions 901, 902, through 909 of the codeword to be identified are the midpoints of the positions of adjacent peak and valley values ​​in the barcode arrangement direction y. The z-axis in Figure 10 represents the pixel grayscale value. In the present invention, the pixel grayscale value range is, for example, [0, 255], where 0 represents pure black and 255 represents pure white. In practice, the opposite representation can also be used, for example, 0 represents pure white and 255 represents pure black.

[0051] In some embodiments, the barcode decoding method further includes, for example, verifying the calculated barcode codeword based on the parsing result of the first segment of the first scan line and the second-level decoding results of the codewords corresponding to the second segment to the Mth segment of the first scan line, in combination with the barcode verification rules. In addition, the barcode decoding method further includes, for example, calculating multiple first-level decoding results for each codeword to be identified, and using the decoding result with the largest number of occurrences among the multiple first-level decoding results as the final first-level decoding result of the codeword to be identified. Alternatively, calculating multiple second-level decoding results for each codeword to be identified, and using the decoding result with the largest number of occurrences among the multiple second-level decoding results as the final second-level decoding result of the codeword to be identified.

[0052] In some embodiments, when the coordinates corresponding to the pixel position corresponding to the first scan line or the new scan line do not have corresponding grayscale values ​​in the image of the barcode region of interest, an interpolation method is used to calculate the grayscale value of the pixel position. Interpolation methods include nearest neighbor interpolation and bilinear interpolation. For example, the multiple rows of pixel values ​​in Figure 10 are obtained based on interpolation of multiple scan lines.

[0053] In some embodiments, the barcode decoding method further includes, for example, performing a filtering operation on the accumulated grayscale value of pixels from the second segment to the Mth segment of the first scan line or the accumulated average grayscale value of pixels from the second segment to the Mth segment of the first scan line. The filtering operation includes Gaussian smoothing filtering, median filtering, or mean filtering.

[0054] The barcode decoding method of the present invention achieves accurate and effective barcode reading through segmented codeword sampling and bar / space edge detection, which are then combined. This method is particularly effective when the barcode is damaged, distorted, or has varying print density, while still being able to accurately read the barcode codeword. This facilitates the smooth operation of barcode-related businesses, such as cashiers and warehousing operations.

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

[0056] Figure 11 shows a schematic diagram of the components of a barcode decoding device according to one embodiment of the present invention. Barcode decoding device 1100 may 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. Barcode decoding device 1100 is connected to a network and other devices via the communication port. Internal communication bus 1101 enables data communication between components of barcode decoding device 1100. Processor 1102 can perform judgments and issue prompts. In some embodiments, processor 1102 may be composed of one or more processors. Communication port 1105 enables the sending and receiving of information and data from the network. Barcode decoding device 1100 may also include various forms of program storage units and data storage units, such as read-only memory (ROM) 1103 and random access memory (RAM) 1104, capable of storing various data files used for computer processing and / or communication, as well as possible program instructions executed by processor 1102. The processor executes these instructions to implement the main part of the method. The results processed by the processor can be transmitted to the user device through the communication port and displayed on the user interface.

[0057] The barcode decoding device 1100 described above may be implemented as a computer program, stored in a memory, and recorded in the processor 1102 for execution to implement the barcode decoding method of the present invention.

[0058] The present invention also provides a computer-readable medium storing computer program code, which implements the above barcode decoding method when executed by a processor.

[0059] Some aspects of the present invention may be implemented entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software, such as a script program and a corresponding runtime platform. The above hardware or software may be referred to as a "data block," "module," "engine," "unit," "component," or "system." The processor may 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, various aspects of the present invention may be implemented as a computer product on one or more computer-readable media, the product including computer-readable program code. For example, computer-readable media may include, but are not limited to, magnetic storage devices (e.g., hard disks, floppy disks, magnetic tapes, etc.), optical disks (e.g., compact disks, digital versatile disks, DVDs, etc.), smart cards, and flash memory devices (e.g., cards, sticks, key drives, etc.).

[0060] A computer-readable medium may include a propagated data signal embodying computer program code, for example, in baseband or as part of a carrier wave. The propagated signal may be in a variety of forms, including electromagnetic, optical, etc., or a suitable combination thereof. A computer-readable medium may be any computer-readable medium other than a computer-readable storage medium that can be connected to an instruction execution system, apparatus, or device to communicate, propagate, or transmit the program for use. The program code on the computer-readable medium may be transmitted via any suitable medium, including radio, cable, fiber optic cable, radio frequency signal, or similar medium, or any combination of the above.

[0061] While the basic concepts have been described above, it will be apparent to those skilled in the art that the above disclosure is provided for illustrative purposes only and does not constitute a limitation of the present invention. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and revisions to the present invention. Such modifications, improvements, and revisions are suggested in the present invention and remain within the spirit and scope of the exemplary embodiments of the present invention.

Claims

1. A barcode decoding method, comprising: Acquire an image of a barcode region of interest in the image, and determine the distribution range and arrangement direction of the barcode; 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, calculate the position and width of the start symbol or the end symbol corresponding to a single row of pixels of the first width; Based on the detected bar space position and pixel width value of the start or end character of the bar code, the code word width and minimum module width value of the start or end character of the bar code are calculated; according to the number of pixels corresponding to the minimum module width value, a single scan line or multiple scan lines are determined for subsequent code word decoding; Starting from the end position of the first scan line corresponding to the start character or the end character of the barcode, a single row of pixels of a second width is sequentially acquired and the pixel grayscale values ​​are obtained to form a second segment of the first scan line 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 a direction perpendicular to the arrangement direction of the barcode; Based on the Mth segment of the first scan line from the second segment of the first scan line to the end position of the barcode or the Mth segment of the first scan line from the second segment of the first scan line to the end position of the barcode and the corresponding segment of the new scan line, the codeword corresponding to the second segment to the Mth segment of the first scan line is calculated.

2. The barcode decoding method according to claim 1, characterized in that: The new scanning line is n pixels away from the first scanning line in a direction perpendicular to the arrangement direction of the barcode, where n is a positive integer.

3. The barcode decoding method according to claim 1, characterized in that: Calculating the position and width of the start character or the end character corresponding to a single row of pixels of the first width based on the first segment of the first scan line includes: 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 point positions of each second-order derivative as the positions of each empty boundary of the first codeword to be identified; According to the decoding rule of the start character or the end character of the barcode, the position and width of the start character or the end character corresponding to the single row of pixels of the first width are calculated.

4. The barcode decoding method according to claim 1, characterized in that: Based on the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode and the corresponding segment of the new scan line, the codeword corresponding to the second segment to the Mth segment of the first scan line is calculated to include: 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; If the segment of the new scan line is retained, the pixel grayscale value corresponding to the segment of the new scan line is accumulated with the pixel grayscale values ​​corresponding to the second segment to the Mth segment of the first scan line to obtain the pixel grayscale accumulated value of the second segment to the Mth segment of the first scan line or the pixel grayscale accumulated average value of the second segment to the Mth segment of the first scan line; Performing a second-order derivative operation on the pixel grayscale cumulative value from the second segment to the Mth segment of the first scan line or the pixel grayscale cumulative average value from the second segment to the Mth segment of the first scan line, and determining the zero-crossing point positions of each second-order derivative as the positions of each empty boundary of the second codeword to be identified to the Mth codeword; According to the barcode codeword decoding rule, a first-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line is calculated and obtained.

5. The barcode decoding method according to claim 1, characterized in that: Based on the second segment of the first scan line to the Mth segment of the first scan line at the end position of the barcode, the codeword corresponding to the second segment to the Mth segment of the first scan line is calculated to include: Performing a second-order derivative operation on the pixel grayscales of the second segment to the Mth segment of the first scan line, and determining the zero-crossing point positions of each second-order derivative as the positions of each empty boundary of the second codeword to be identified to the Mth codeword; According to the barcode codeword decoding rule, a first-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line is calculated and obtained.

6. The barcode decoding method according to claim 4 or 5, characterized in that: Also includes: When the first-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line cannot be calculated according to the codeword decoding rule of the barcode, obtaining the peak value and the trough value on the numerical curve corresponding to the pixel grayscale 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; The midpoint of the arrangement positions of the adjacent wave peak values ​​and wave trough values ​​in the arrangement direction of the bar code is used as the bar-space boundary position of the codeword to be identified; According to the barcode codeword decoding rule, a second-level decoding result of the codeword corresponding to the second segment to the Mth segment of the first scan line is calculated and obtained.

7. The barcode decoding method according to claim 6, characterized in that: Also includes: Based on the analysis result of the first segment of the first scan line and the second level decoding result of the code words corresponding to the second segment to the Mth segment of the first scan line, the calculated bar code code words are verified in combination with the bar code verification rule.

8. The barcode decoding method according to claim 1, characterized in that: When the coordinates corresponding to the pixel position corresponding to the first scanning line or the new scanning line have no corresponding grayscale value in the image of the barcode region of interest in the image, the grayscale value of the pixel position is calculated by interpolation.

9. The barcode decoding method according to claim 8, characterized in that: The interpolation method includes nearest neighbor interpolation or bilinear interpolation.

10. The barcode decoding method according to claim 1, characterized in that: Also includes: A filtering operation is performed on the accumulated grayscale value of pixels from the second segment to the Mth segment of the first scan line or the accumulated average grayscale value of pixels from the second segment to the Mth segment of the first scan line.

11. The barcode decoding method according to claim 10, characterized in that: The filtering operation includes Gaussian smoothing filtering, median filtering or mean filtering.

12. The barcode decoding method according to claim 1, characterized in that: The barcode includes 128 barcode, 39 code, standard 25 code, cross 25 code or international standard book number encoding.

13. A barcode decoding device, comprising: a memory for storing instructions executable by a processor; as well as A processor, configured to execute the instructions to implement the method according to any one of claims 1 to 12.

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

Citation Information

Patent Citations

  • Method for identifying barcode image

    CN102034072A

  • Decoding method of stained one-dimensional bar code

    CN114298078A

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

    CN115688826A

  • Bar code decoding method and device and computer readable medium

    CN117521695A

  • Method and apparatus for decoding bar code images using information from previous scan lines

    US5438188A

Cited By

  • Bar code identification method and system based on segmented wave crest and adaptive threshold adjustment, and medium

    CN120339040A