Method for evaluating the quality of a barcode image and a barcode reader
By dividing the barcode image into multiple functional regions, calculating the contrast feature value of each region and assigning different weights, the problem of inaccurate barcode image quality assessment in existing technologies is solved, and accurate prediction of the success probability of barcode image decoding is achieved.
Patent Information
- Application Number
- CN202611154148.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-31
- Publication Date
- 2026-11-20
Smart Images

Figure CN123141306A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of barcode reader technology, specifically to a method for quality assessment of barcode images and a barcode reader. Background Technology
[0002] A barcode is a data representation that encodes information into a set of black and white bars (or dots, squares) of varying widths for optical scanners to read. It is commonly used in scenarios such as product identification, inventory management, and logistics tracking.
[0003] In the field of barcode reading, the barcodes, such as QR codes, captured by barcode readers are varied and complex, resulting in unstable image quality and a reduced probability of successful decoding. Therefore, a method is needed to intuitively assess whether a QR code in an image can be decoded.
[0004] Currently, some image quality assessment methods calculate the image quality value through global pixel statistics. This quality assessment value reflects the overall contrast level of the image and is not linearly related to the difficulty of decoding the QR code image. It is difficult to intuitively reflect whether the QR code image can be successfully decoded in the future. Summary of the Invention
[0005] In view of the above problems, embodiments of this application provide a method and reader for quality assessment of barcode images, which can obtain a quality assessment score that intuitively reflects whether the barcode image can be successfully decoded subsequently.
[0006] According to one aspect of the embodiments of this application, a method for quality assessment of a barcode image is provided. The method includes: acquiring a barcode image containing a barcode; determining multiple functional regions of the barcode from the barcode image based on the symbol structure of the barcode; determining multiple contrast feature values for each functional region based on multiple pixel values within each functional region, wherein the multiple contrast feature values correspond to multiple preset contrast features; for each functional region, acquiring the weights corresponding to the multiple contrast features in that functional region; for each functional region, calculating the contrast corresponding to that functional region based on the multiple contrast feature values of that functional region and the weights corresponding to each contrast feature in that functional region; and determining a quality assessment score for the barcode image based on the contrast corresponding to each functional region.
[0007] In one optional approach, each functional region includes at least one module; determining multiple contrast feature values for each functional region based on multiple pixel values within each functional region further includes: for each functional region, determining multiple contrast feature values for each module based on multiple pixel values within each module; for each functional region, calculating the contrast of that functional region based on the multiple contrast feature values of that functional region and the weight corresponding to each contrast feature in that functional region, further including: for each functional region, calculating the contrast of each module based on the multiple contrast feature values of each module within that functional region and the weight corresponding to each contrast feature in that functional region; and for each functional region, determining the contrast of that functional region based on the contrast of all modules in that functional region.
[0008] In one alternative approach, the contrast feature values include sharpness, uniformity, dynamic range robustness, and detail fidelity. For each functional area, multiple contrast feature values for each module are determined based on multiple pixel values within each module, further including: determining the grayscale change rate in the vertical direction and the grayscale change rate in the horizontal direction for each module based on the multiple pixel values within each module; determining the sharpness of each module based on the grayscale change rate in the vertical direction and the grayscale change rate in the horizontal direction for each module; determining the uniformity of each module based on the standard deviation of the multiple pixel values within each module; determining the dynamic range robustness of each module based on the 95th and 5th quantiles of the multiple pixel values within each module; and determining the detail fidelity of each module based on the Laplacian value of the multiple pixel values within each module.
[0009] In one alternative approach, determining multiple functional regions of a barcode from a barcode image based on the barcode's symbolic structure further includes: dividing the barcode image into multiple sub-regions according to the smallest unit of the barcode, wherein each sub-region includes multiple pixel values; determining a representative pixel value for each sub-region based on all pixel values of each sub-region; determining multiple functional regions of the barcode from the barcode image divided into multiple sub-regions based on the barcode's symbolic structure, wherein each module within each functional region includes multiple sub-regions; and determining multiple contrast feature values for each module for each functional region based on the multiple pixel values within each module, further including: determining multiple contrast feature values for each module for each functional region based on the representative pixel values of the sub-regions included within each module.
[0010] In one alternative approach, the barcode image is divided into multiple sub-regions based on the smallest unit of the barcode, further comprising: determining a division interval based on the smallest unit of the barcode; and dividing the barcode image along the vertical and horizontal directions based on the division interval to obtain multiple sub-regions.
[0011] In one alternative approach, for each functional region, the contrast of each module is calculated based on multiple contrast feature values of each module within that functional region and the weight corresponding to each contrast feature in that functional region. This further includes: for each module within each functional region, multiplying each contrast feature value by the weight corresponding to each contrast feature in that functional region to obtain a weighted value for each contrast feature value; and summing the weighted values of all contrast feature values for each module to obtain the contrast of each module.
[0012] In one alternative approach, the functional areas include a positioning and correction graphic area, a format and version information area, and a data and error correction codeword area. The contrast features include sharpness features, uniformity features, dynamic range robustness features, and detail fidelity features. For the positioning and correction graphic area, the weight corresponding to the sharpness feature is greater than the weight corresponding to the uniformity feature, which in turn is greater than the weights corresponding to the dynamic range robustness feature and the detail fidelity feature, respectively. For the format and version information area, the weight corresponding to the uniformity feature is greater than the weight corresponding to the dynamic range robustness feature, which in turn is greater than the weights corresponding to the sharpness feature and the detail fidelity feature, respectively. For the data and error correction codeword area, the weights corresponding to the sharpness feature, uniformity feature, and dynamic range robustness feature are equal and greater than the weight corresponding to the detail fidelity feature.
[0013] In one alternative approach, determining the quality assessment score of the barcode image based on the contrast of each functional area further includes: determining the area weight corresponding to each functional area; multiplying the contrast of each functional area by the area weight corresponding to each functional area to obtain a contrast weighted value for each functional area; summing the contrast weighted values of all functional areas to obtain the contrast of the barcode image; and determining the quality assessment score of the barcode image based on the contrast of the barcode image.
[0014] In one alternative approach, determining a quality assessment score for a barcode image based on its contrast further includes: linearly mapping the contrast of the barcode image to a preset range to obtain a quality assessment score for the barcode image within the preset range, wherein the quality assessment score is linearly related to the probability of successful decoding of the barcode image within the preset range.
[0015] According to another aspect of the embodiments of this application, a barcode reader is provided, including a camera, a memory, and a processor. The camera is used to acquire barcode images; the memory stores a computer program; and the processor executes the computer program to implement the barcode image quality assessment method described in any of the above embodiments.
[0016] In the barcode image quality assessment method provided in this application, multiple functional areas of the barcode can be determined from the barcode image based on the symbol structure of the barcode. Since the contrast characteristics of each functional area have different requirements for successful barcode image decoding, different weights can be assigned to the various contrast characteristics of each functional area. Thus, after calculating multiple contrast characteristic values of each functional area based on multiple pixel values, the contrast of that functional area can be calculated based on these contrast characteristic values and the weights corresponding to each contrast characteristic within that functional area. Finally, a quality assessment score for the barcode image is determined based on the contrast of each functional area. The quality assessment score determined in this way comprehensively reflects the actual impact of each functional area of the barcode image on successful decoding, and is linearly related to the difficulty of decoding the QR code image, intuitively reflecting whether the QR code image can be successfully decoded subsequently.
[0017] The above description is merely an overview of the technical solutions of the embodiments of this application. In order to better understand the technical means of the embodiments of this application and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of this application more obvious and understandable, specific implementation methods of this application are described below. Attached Figure Description
[0018] The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 A schematic diagram of the QR code structure provided in an embodiment of this application is shown; Figure 2 A flowchart illustrating the barcode image quality assessment method provided in an embodiment of this application is shown. Figure 3 A flowchart illustrating a barcode image quality assessment method according to another embodiment of this application is shown; Figure 4 The following are schematic diagrams illustrating the structure of QR codes in different states according to embodiments of this application; Figure 5 A schematic diagram of the structure of the barcode image quality assessment device provided in an embodiment of this application is shown; Figure 6 A schematic diagram of the structure of the barcode reader provided in an embodiment of this application is shown. Detailed Implementation
[0019] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein.
[0020] Barcodes generally include one-dimensional (1D) and two-dimensional (2D) barcodes. One-dimensional barcodes consist of parallel lines and spaces, while two-dimensional barcodes consist of a matrix of dots, squares, or other geometric shapes, allowing for the storage of more data in a smaller space. Typically, barcodes are affixed to the surface of a product or its packaging. Taking QR codes as an example, scanning the QR code affixed to the product packaging with a handheld device such as a barcode reader provides detailed product information, increasing product transparency and enabling more efficient flow, exchange, and verification of product information, thus improving product distribution efficiency.
[0021] In the field of barcode reading, the barcodes captured by barcode readers, such as QR codes, are incredibly diverse, leading to unstable image quality and a reduced probability of successful decoding. The success of decoding hinges on the pixel intensity difference between the decoding unit blocks (black and white blocks) within the functional areas of the QR code image. Theoretically, optimal contrast is achieved when black pixels are 0 and white pixels are 255, facilitating decoding. However, in reality, factors such as material composition and ambient light often result in insufficient pixel differences between decoding unit blocks, drastically increasing decoding difficulty. Therefore, a method is urgently needed to intuitively assess whether a QR code in an image can be decoded, and, if the assessment indicates it cannot be decoded, to effectively guide image adjustments or re-capture for a reassessment of its decoding capability.
[0022] Currently, some image quality assessment methods first adjust the contrast of an image to different intensities, generating an image sequence composed of multiple preprocessed images. Then, the number of pixels corresponding to each gray level in each preprocessed image is counted to obtain the pixel distribution information of the preprocessed images, and feature information is extracted based on this pixel distribution information. Finally, by calculating the differences of these features among images with different contrast levels, the image quality assessment value is obtained.
[0023] However, when the above method is applied to QR code images, the calculated quality assessment value does not show a linear relationship with the ease of decoding the QR code image. This is because the method is based on the quality assessment value calculated according to global pixel statistics of the image, reflecting the overall contrast level of the image. Whether a QR code image can be successfully decoded depends not on the overall contrast, but on the contrast of the functional areas of the QR code.
[0024] For example, when the positioning and correction graphic area in a QR code image is severely exposed, resulting in minimal pixel differences between its internal black and white modules, while other areas of the QR code image appear normal, the quality assessment value calculated based on the global pixels of the QR code image may be high. However, due to the degradation of this crucial decoding area—the positioning and correction graphic—the probability of successfully decoding the QR code image remains very low. Therefore, existing schemes that calculate quality assessment values based on global pixels cannot intuitively reflect the ease or difficulty of subsequent decoding of the QR code image.
[0025] like Figure 1 The diagram shows the structure of a QR code. The QR code includes multiple functional graphic areas, such as the positioning and correction graphic area 10, the format and version information area 20, the data and error correction codeword area 30, and the silent area 40. The positioning and correction graphic area 10 serves as the geometric reference for decoding, with absolute edge sharpness as its core requirement, and is most sensitive to local sharpness. The format and version information area 20 carries key metadata such as error correction level and mask mode; although the amount of information is small, it is crucial, and it has the highest requirements for grayscale consistency and noise resistance. The data and error correction codeword area 30 is the main data storage area of the QR code, with the highest requirements for overall contrast balance, and can tolerate a certain degree of local degradation using error correction codes (ECC). The silent area 40 is the blank area surrounding the QR code, its function being to define the QR code boundary, requiring a clear and stable brightness interval with the background.
[0026] Therefore, the success of QR code image decoding depends on the contrast characteristics of different functional graphic regions of the QR code. For example, successful decoding of a QR code image has the highest requirements for the edge sharpness and uniformity of the positioning and correction graphic region 10, the highest requirements for the overall uniformity and dynamic range robustness of the format and version information region 20, the highest requirements for the edge sharpness, dynamic range robustness, and uniformity of the data and error correction codeword region 30, and no requirements for the silent region 40.
[0027] Based on this, different weights can be assigned to various contrast features of each functional region. After dividing the QR code image into multiple functional regions and calculating multiple contrast feature values for each functional region, the contrast of each functional region can be calculated based on its multiple contrast feature values and the weights corresponding to each contrast feature within that functional region. Finally, the quality assessment score of the QR code image determined based on the contrast of each functional region can comprehensively reflect the actual impact of each functional graphic region of the QR code image on successful decoding. This score is linearly related to the difficulty of decoding the QR code image and can intuitively reflect whether the QR code image can be successfully decoded subsequently.
[0028] Figure 2A flowchart of a barcode image quality assessment method provided in an embodiment of this application is shown. This method can be executed by a barcode reader, or by a computer, server, etc. This application uses a barcode reader as an example for illustration, which does not constitute a limitation. Figure 2 As shown, the method includes the following steps: Step S100: Obtain a barcode image containing the barcode.
[0029] The barcode can be a one-dimensional barcode or a two-dimensional barcode. The one-dimensional barcode can be a barcode; the two-dimensional barcode can be a QR code (Quick Response Code), a DM code (Data Matrix Code), or a PDF417 code. This application uses a two-dimensional barcode as an example for illustration, and does not constitute a limitation.
[0030] A barcode reader uses an optical sensor to capture a high-resolution raw image of a barcode affixed to the surface of a product or packaging box. The reader then uses image recognition algorithms to locate the barcode within this high-resolution image and crops out a smaller image containing only the barcode information—the barcode image. Because the barcode image contains only the barcode, a large number of irrelevant background pixels can be removed, significantly reducing the computational load for subsequent contrast feature analysis and improving the speed of quality assessment.
[0031] Step S200: Based on the symbol structure of the barcode, determine multiple functional areas of the barcode from the barcode image.
[0032] The symbol structure consists of the functional areas contained in the barcode and the positional rules of each functional area.
[0033] If the barcode is a QR code, please continue reading. Figure 1 The barcode may include four functional areas: the positioning and correction graphic area 10, the format and version information area 20, the data and error correction codeword area 30, and the silent area 40.
[0034] Each functional area includes at least one module. The positioning and correction graphic area 10 may include modules such as positioning graphic 101, peripheral dividing area 102, and correction graphic 103. Typically, there are three positioning graphics 101 and three peripheral dividing areas 102, while there may be one or more correction graphics 103. The format and version information area 20 may include format module 201 and version module 202. There may be three format modules 201 and two version modules 202. The data and error correction codeword area 30 includes all areas of the barcode image except for the positioning and correction graphic area 10 and the format and version information area 20. The data and error correction codeword area 30 may be a single module or divided into multiple modules based on its area size.
[0035] When the barcode is a barcode, it can include three functional areas: a start and stop character area, a data area, and a check digit area. Each functional area can be treated as a module.
[0036] Step S300: Based on the multiple pixel values in each functional area, determine multiple contrast feature values for each functional area, wherein the multiple contrast feature values correspond to multiple preset contrast features.
[0037] Pixel value is the grayscale intensity of each pixel within a functional area, while contrast feature value is a quantitative indicator calculated based on multiple pixel values within each functional area.
[0038] Multiple contrast features can include sharpness features, uniformity features, dynamic range robustness features, and detail fidelity features. The values of these multiple contrast features correspond to sharpness, uniformity, dynamic range robustness, and detail fidelity, respectively, for the sharpness feature, uniformity feature, dynamic range robustness feature, and detail fidelity feature.
[0039] Sharpness directly reflects the sharpness of the boundary between black and white blocks in a barcode image, affecting positioning and sampling accuracy. Uniformity measures whether the internal area of a functional region is pure black or white, or mixed with gray, affecting the accuracy of binarization. Dynamic range robustness avoids the influence of extreme point noise and measures the reliable contrast range that a functional region's modules can maintain while allowing a preset percentage (e.g., 5%) of pixel contamination. Detail fidelity effectively captures high-frequency details in the barcode image and is sensitive to degradation such as blurring and defocusing.
[0040] Specifically, the grayscale change rate in the vertical direction and the grayscale change rate in the horizontal direction of each functional area can be determined based on multiple pixel values within each functional area. Then, the sharpness of each functional area can be determined based on these two grayscale change rates. The uniformity of each functional area can be determined based on the standard deviation of multiple pixel values within each functional area. The dynamic range robustness of each functional area can be determined based on the 95th and 5th percentiles of multiple pixel values within each functional area. The detail fidelity of each functional area can be determined based on the Laplacian value of multiple pixel values within each functional area.
[0041] Step S400: For each functional area, obtain the weights of various contrast features corresponding to that functional area.
[0042] In this embodiment, the weights of various contrast features corresponding to each functional region can be pre-stored. Thus, in this step, for each functional region, the weights of various contrast features corresponding to that functional region can be directly obtained.
[0043] Taking QR codes as an example, the highest requirements for the edge sharpness and uniformity of the positioning and correction graphic area, the overall uniformity and dynamic range robustness of the format and version information area, and the edge sharpness, dynamic range robustness, and uniformity of the data and error correction codeword area are required for successful decoding of QR code images.
[0044] Therefore, for the positioning and correction graphic area, the weight corresponding to the sharpness feature can be set to be greater than the weight corresponding to the uniformity feature, and the weight corresponding to the uniformity feature can be greater than the weights corresponding to the dynamic range robustness feature and the detail fidelity feature, respectively. For the format and version information area, the weight corresponding to the uniformity feature is greater than the weight corresponding to the dynamic range robustness feature, and the weight corresponding to the dynamic range robustness feature is greater than the weights corresponding to the sharpness feature and the detail fidelity feature, respectively. For the data and error correction codeword area, the weights corresponding to the sharpness feature, uniformity feature, and dynamic range robustness feature are equal and greater than the weight corresponding to the detail fidelity feature. It should be noted that the silent area 40 in this application contains no information and does not participate in the contrast calculation; therefore, its weight can be set to zero.
[0045] For example, the weights of sharpness, uniformity, dynamic range robustness, and detail fidelity features in the localization and correction graphic area can be set to 0.5, 0.3, 0.15, and 0.15, respectively. The weights of sharpness, uniformity, dynamic range robustness, and detail fidelity features in the format and version information area can be set to 0.1, 0.5, 0.3, and 0.1, respectively. The weights of sharpness, uniformity, dynamic range robustness, and detail fidelity features in the data and error correction codeword area can be set to 0.3, 0.3, 0.3, and 0.1, respectively.
[0046] With this weighting method, when the positioning and correction graphic area is severely exposed, resulting in blurred edges, its clarity and uniformity are low. Since the positioning and correction graphic area has a high weight, the contrast of the final calculated barcode image can be reduced, avoiding the problem of high contrast of the barcode image caused by other functional areas being normal. This makes the difficulty of barcode image decoding linearly related to the contrast of the barcode image.
[0047] Step S500: For each functional area, calculate the contrast of the functional area based on the multiple contrast feature values of the functional area and the weight of each contrast feature in the functional area.
[0048] Specifically, for each functional region, each contrast feature value can be multiplied by the weight corresponding to each contrast feature in that functional region to obtain the weighted value of each contrast feature value. Then, the weighted values of all contrast feature values of each functional region are added together to obtain the contrast value corresponding to each functional region.
[0049] For example, assuming the weights of the sharpness feature, uniformity feature, dynamic range robustness feature, and detail fidelity feature of the data and error correction codeword region are 0.3, 0.3, 0.3, and 0.1 respectively, and the sharpness, uniformity, dynamic range robustness, and detail fidelity of the data and error correction codeword region are 0.8, 0.9, 0.7, and 0.6 respectively, then the contrast S of module 1 of the data and error correction codeword region is: S = 0.8 × 0.3 + 0.9 × 0.3 + 0.7 × 0.3 + 0.6 × 0.1 = 0.78.
[0050] Step S600: Determine the quality assessment score of the barcode image based on the contrast corresponding to each functional area.
[0051] The quality assessment score is the final quantitative indicator that measures whether the entire barcode image is easy to decode.
[0052] Specifically, the quality assessment score of a barcode image can be determined through the following steps: Step S610: Determine the area weight corresponding to each functional area.
[0053] Step S620: Multiply the contrast of each functional area by the corresponding area weight to obtain the contrast weighted value of each functional area.
[0054] Step S630: Sum the contrast weights of all functional areas to obtain the contrast of the barcode image.
[0055] Step S640: Determine the quality assessment score of the barcode image based on its contrast.
[0056] In this embodiment of the application, the area weights corresponding to each functional area can be preset and stored so that the area weights corresponding to each functional area can be directly determined in this step.
[0057] The weights of each functional area can be set according to their influence on the difficulty of barcode image decoding. The positioning and correction graphic area has the greatest influence on the difficulty of barcode image decoding, followed by the format and version information area, and the data and error correction codeword area has the least influence. Therefore, the area weights can be set as follows: Positioning and Correction Graphic Area > Format and Version Information Area > Data and Error Correction Codeword Area. For example, the area weights of Positioning and Correction Graphic Area, Format and Version Information Area, and Data and Error Correction Codeword Area can be set to 0.5, 0.3, and 0.2, respectively.
[0058] Assuming the contrast ratios of the positioning and correction graphic region, the format and version information region, and the data and error correction codeword region are 0.6, 0.8, and 0.7, respectively, and the corresponding region weights are 0.5, 0.3, and 0.2, respectively, then the contrast ratio Q of the barcode image is... raw Q raw =0.6×0.5+0.8×0.3+0.7×0.2=0.68.
[0059] By introducing regional weights corresponding to each functional area, the quality assessment score of the barcode image can be calculated by comprehensively considering the influence of each functional area on the successful decoding of the barcode image. This allows the quality assessment score to accurately reflect the probability of successful decoding. For example, the data and error correction codeword areas may have some degradation due to the use of the ECC mechanism, but as long as the positioning and correction graphic areas are normal, a high quality assessment score can still be calculated, indicating a high probability of successful decoding of the barcode image. Conversely, if the positioning and correction graphic areas are severely degraded, even if the format and version information areas and the data and error correction codeword areas are normal, a low quality assessment score can be given, indicating a low probability of successful decoding of the barcode image.
[0060] After calculating the contrast of the barcode image, it can be linearly mapped to a preset range to obtain a quality assessment score for the barcode image within that range. Within this range, the quality assessment score has a linear relationship with the probability of successful barcode decoding; that is, a higher quality assessment score increases the probability of successful decoding, and a lower score decreases the probability. This ensures that the probability of successful barcode decoding can be intuitively determined through the quality assessment score.
[0061] Specifically, the contrast of the barcode image can be linearly mapped to a quality assessment score within a preset interval [0, 100] using the following formula (1). : (1) in, Indicates the lower limit threshold. The upper and lower threshold values are all experimentally calibrated. The lower threshold can be set to 0.3, indicating poor contrast below this value and a very low probability of successful barcode image decoding. The upper threshold can be set to 0.9, indicating excellent contrast above this value and a very high probability of successful barcode image decoding.
[0062] For example, when the contrast of the barcode image is 0.68, the quality assessment score of the barcode image calculated by formula (1) is 63.
[0063] After obtaining the quality assessment score of the barcode image, the barcode reader can directly output the score, allowing the operator to decide whether to retake or adjust the barcode image. Alternatively, a score threshold can be preset. When the barcode image's quality assessment score is greater than the threshold, the barcode reader can directly decode the barcode image; when the score is less than or equal to the threshold, the barcode reader can directly retake or adjust the barcode image.
[0064] In the barcode image quality assessment method provided in this application, multiple functional areas of the barcode can be determined from the barcode image based on the symbol structure of the barcode. Since the contrast characteristics of each functional area have different requirements for successful barcode image decoding, different weights can be assigned to the various contrast characteristics of each functional area. Thus, after calculating multiple contrast characteristic values of each functional area based on multiple pixel values, the contrast of that functional area can be calculated based on these contrast characteristic values and the weights corresponding to each contrast characteristic within that functional area. Finally, a quality assessment score for the barcode image is determined based on the contrast of each functional area. The quality assessment score determined in this way comprehensively reflects the actual impact of each functional area of the barcode image on successful decoding, and is linearly related to the difficulty of decoding the QR code image, intuitively reflecting whether the QR code image can be successfully decoded subsequently.
[0065] Please continue reading. Figure 1The modules in each functional area are located at different positions in the barcode image, resulting in some modules within the same functional area being overexposed while others are normal. For example, when two positioning graphics 101 in the positioning and correction graphic area 10 are overexposed, if multiple contrast feature values of the positioning and correction graphic area 10 are calculated using the overall pixel values of the area, the subsequently calculated contrast of the positioning and correction graphic area 10 may be too high, ultimately leading to an overly high quality assessment score for the barcode image. However, in reality, the contrast feature values of the two overexposed positioning graphics 101 are very low, causing the barcode image to fail to decode due to the lack of crucial information from these two positioning graphics 101. Therefore, calculating the contrast of a functional area based on all pixel values of the entire functional area may reduce the accuracy of the contrast of that functional area, ultimately reducing the accuracy of the barcode image's quality assessment score.
[0066] To avoid the above problems, Figure 3 A flowchart illustrating another embodiment of this application provides a method for quality assessment of barcode images. As shown in the figure, the method includes: Step S710: Obtain a barcode image containing the barcode.
[0067] This step can be referred to. Figure 2 Step S100 shown will not be repeated here.
[0068] Step S720: Based on the symbol structure of the barcode, determine multiple functional areas of the barcode from the barcode image.
[0069] Specifically, step S720 may include the following steps: Step S721: Divide the barcode image into multiple sub-regions according to the smallest unit of the barcode, wherein each sub-region includes multiple pixel values.
[0070] The smallest unit of a barcode is the smallest black or white block, typically composed of multiple pixel values. Taking a QR code image as an example, the smallest unit of a QR code can be... Figure 1 Black block A in the image consists of 9 pixel values, and the grayscale value of each pixel value is 0.
[0071] like Figure 4 The diagram illustrates the structure of a QR code under different states. After acquiring barcode image A, the division interval can be determined based on the smallest unit of the barcode. Then, based on the division interval, barcode image A is divided along the vertical and horizontal directions to obtain multiple sub-regions in barcode image B. For example, using the smallest unit as the division interval, 20 vertical lines can be drawn at equal intervals along the vertical direction, and 20 horizontal lines can be drawn at equal intervals along the horizontal direction, thereby dividing the barcode image into 441 sub-regions.
[0072] By determining the division interval based on the smallest unit, it is possible to ensure that the grid lines fall precisely on the boundary of the smallest unit, so that each sub-region is the smallest unit of the barcode and corresponds exactly to a module. This avoids the mixing of module content caused by misalignment of the division and provides an accurate and independent analysis unit for subsequent extraction of contrast feature values module by module.
[0073] Step S722: Determine the representative pixel value of each sub-region based on all pixel values of each sub-region.
[0074] Please continue reading. Figure 4 After dividing the area into multiple sub-regions, for each sub-region, the average value of all pixel values in that sub-region can be used to determine the representative pixel value of that sub-region, thus obtaining the barcode image C. For example, when sub-region 1 includes 9 pixel values, the average value of these 9 pixel values is determined as the representative pixel value of sub-region 1.
[0075] In other embodiments, the representative pixel value of each sub-region can also be determined using principal component analysis, clustering, or other methods based on all pixel values of each sub-region.
[0076] Step S723: Based on the symbol structure of the barcode, determine multiple functional regions of the barcode from the barcode image after it has been divided into multiple sub-regions.
[0077] The specific steps for determining the multiple functional areas of the barcode in this step can be found in step S200, and will not be repeated here.
[0078] After defining multiple functional areas of the barcode, each module within each functional area comprises multiple sub-areas. For example... Figure 1 As shown, the positioning graphic 101 of the positioning and correction graphic area can include 36 sub-regions, and the outer dividing area 102 can include 8 sub-regions.
[0079] Information extraction from barcode images does not involve calculating gradients for each pixel value. Instead, it detects the steepness between the smallest black and white units, i.e., the gradient between black and white blocks. The larger the pixel value difference between them, the higher the probability of successful barcode decoding; conversely, the smaller the pixel value difference, the lower the probability of successful decoding. Therefore, after determining each sub-region through steps S721-S723, the subsequent quality assessment score of the barcode image calculated based on the pixel value difference between sub-regions can more accurately reflect the difficulty of barcode image decoding.
[0080] Step S730: For each functional area, determine multiple contrast feature values for each module based on multiple pixel values within each module.
[0081] In this step, the multiple pixel values within each module can be representative pixel values of all sub-regions included in that module. Then, for each functional area, multiple contrast feature values for each module can be determined based on the representative pixel values of the sub-regions included in that module, improving the accuracy of the multiple contrast feature values for each module. Of course, the multiple pixel values within each module can also be all pixel values included in that module.
[0082] Taking the multiple pixel values within each module as representative pixel values of all sub-regions included in that module as an example, the grayscale change rate in the vertical direction and the grayscale change rate in the horizontal direction of each module can be determined based on the multiple pixel values within each module. Then, the sharpness of each module can be determined based on the grayscale change rates in the vertical and horizontal directions of each module. The uniformity of each module can be determined based on the standard deviation of the multiple pixel values within each module. The dynamic range robustness of each module can be determined based on the 95th and 5th percentiles of the multiple pixel values within each module. The detail fidelity of each module can be determined based on the Laplacian value of the multiple pixel values within each module.
[0083] Assuming the representative pixel value (Mx,y) of each sub-region, the sharpness Fe of each module can be calculated using formula (2): Fe=(mean(|Ghorizontal|+|Gvertical|)) / Gmax, (2) Where Ghorizontal represents the grayscale change rate in the horizontal direction, Gvertical represents the grayscale change rate in the vertical direction, which can be calculated using the Sobel operator, mean() represents taking the mean value, and Gmax represents the theoretical maximum gradient value, for example, 255.
[0084] The uniformity Fu of each module can be calculated using formula (3): Fu=1 σ(Mx,y) / σmax,(3) Where σ represents the standard deviation of the representative pixel values of all sub-regions, and σmax represents the theoretical maximum standard deviation, for example, 127.5.
[0085] The consistency Fr of each module can be calculated using formula (4): Fr=(P95(Mx,y) P5(Mx,y)) / T,(4) Where P95 and P5 represent the 95th percentile and 5th percentile of the representative pixel values of multiple sub-regions, respectively, and T represents the effective contrast threshold, such as 200.
[0086] The detail fidelity Fd of each module can be calculated using formula (5): Fd=mean(| 2 Mx,y|) / Lmax,(5) in, 2 Represents the Laplace operator. 2 Mx,y represents the Laplacian value of the representative pixel value of each sub-region, and Lmax represents the maximum possible grayscale dynamic range, such as 255.
[0087] The contrast quality of each module is comprehensively evaluated by using four contrast feature values, which take into account edge sharpness, internal purity and noise resistance. It can accurately capture various image degradation defects caused by materials, ambient light or defocus, and overcome the shortcomings of traditional methods that rely on a single global contrast value and cannot reflect local detail degradation.
[0088] Step S740: For each functional area, obtain the weights of various contrast features corresponding to that functional area.
[0089] This step can be referred to. Figure 2 Step S400 shown will not be repeated here.
[0090] Step S750: For each functional area, calculate the contrast of each module based on the multiple contrast feature values of each module in the functional area and the weight of each contrast feature in the functional area.
[0091] Specifically, for each module in each functional area, each contrast feature value is multiplied by the weight corresponding to each contrast feature in that functional area to obtain the weighted value of each contrast feature value. Then, the weighted values of all contrast feature values of each module are added together to obtain the contrast value corresponding to each module.
[0092] For example, assuming the weights of the sharpness feature, uniformity feature, dynamic range robustness feature, and detail fidelity feature of the positioning and correction graphic region are 0.3, 0.3, 0.3, and 0.1 respectively, and the sharpness, uniformity, dynamic range robustness, and detail fidelity of module 1 of the positioning and correction graphic region are 0.7, 0.9, 0.6, and 0.8 respectively, then the contrast S1 of module 1 of the positioning and correction graphic region is: S1 = 0.7 × 0.3 + 0.9 × 0.3 + 0.6 × 0.3 + 0.8 × 0.1 = 0.74.
[0093] Step S760: For each functional area, determine the contrast corresponding to that functional area based on the contrast of all modules in that functional area.
[0094] Specifically, by iterating through all modules within each functional area, the contrast scores of all modules can be summed and then divided by the total number of modules in that functional area to obtain the average score of that functional area.
[0095] Assuming there are 10 modules in the localization and correction graphic area, the average score of the localization and correction graphic area can be obtained by summing the contrast of these 10 modules and then dividing by 10.
[0096] Step S770: Determine the quality assessment score of the barcode image based on the contrast corresponding to each functional area.
[0097] This step can be referred to. Figure 2 Step S600 shown will not be repeated here.
[0098] By first calculating multiple contrast feature values for each module using all pixel values, the contrast information of each module can be extracted independently and accurately, ensuring that local degradation information is not obscured. Then, the contrast of each module is calculated using these multiple contrast feature values, and the contrast of each functional area is calculated using the contrast of all modules within that functional area. This ensures the accuracy of the quality assessment score, allowing the final output quality assessment score to exhibit a more rigorous linear relationship with the difficulty of barcode image decoding, and more accurately reflecting whether the barcode image can be successfully decoded.
[0099] Figure 5 A schematic diagram of the structure of the barcode image quality assessment device provided in an embodiment of this application is shown. Figure 5 As shown, the barcode image quality assessment device 200 includes: a first acquisition module 210, a first determination module 220, a second determination module 230, a second acquisition module 240, a calculation module 250, and a third determination module 260.
[0100] The first acquisition module 210 is used to acquire a barcode image containing a barcode; the first determination module 220 is used to determine multiple functional regions of the barcode from the barcode image based on the symbol structure of the barcode; the second determination module 230 is used to determine multiple contrast feature values for each functional region based on multiple pixel values in each functional region, wherein the multiple contrast feature values correspond to multiple preset contrast features; the second acquisition module 240 is used to acquire the weights of the multiple contrast features corresponding to each functional region for each functional region; the calculation module 250 is used to calculate the contrast of each functional region based on the multiple contrast feature values of the functional region and the weights corresponding to each contrast feature in the functional region; the third determination module 260 is used to determine the quality assessment score of the barcode image based on the contrast of each functional region.
[0101] The specific implementation process and beneficial effects of each module in the barcode image quality assessment device 200 of the above embodiments to achieve the above functions can be referred to the foregoing. Figure 2 The embodiments of the barcode image quality assessment method shown are not described in detail here.
[0102] The vehicle barcode image quality assessment device 200 of this application embodiment also includes various modules for performing the steps of the above-described barcode image quality assessment method embodiment, which will not be described in detail here.
[0103] Figure 6 The diagram shows a structural schematic of a barcode reader provided in an embodiment of this application. The specific embodiments of this application do not limit the specific implementation of the barcode reader.
[0104] like Figure 6 As shown, the barcode reader 300 may include a processor 302, a memory 304, and a camera 306.
[0105] Camera 306 is used to acquire barcode images.
[0106] Memory 304 is used to store computer program 308. Memory 304 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device. The computer program 308 may include computer-executable instructions.
[0107] The processor 302 is used to execute the computer program 308 to implement the above-described barcode image quality assessment method embodiment.
[0108] Processor 302 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. The code reader includes one or more processors, which may be processors of the same type, such as one or more CPUs; or they may be processors of different types, such as one or more CPUs and one or more ASICs.
[0109] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described barcode image quality assessment method embodiment.
[0110] This application provides a computer program that can be executed by a processor to implement the above-described barcode image quality assessment method embodiment.
[0111] This application provides a computer program product, which includes a computer program that, when executed by a processor, implements the above-described barcode image quality assessment method embodiment.
[0112] In the several embodiments provided in this application, any function, if implemented as a software module / unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, part or all of the technical solutions of this application can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or other electronic device) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing computer program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0113] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of this application are not directed to any particular programming language. It should be understood that the content of this application described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of this application.
[0114] It should be noted that the above embodiments are illustrative of this application and not restrictive, and those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. This application can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In claims enumerating several means, several units or modules of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.
[0115] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for quality assessment of barcode images, characterized in that, The method includes: Get a barcode image containing the barcode; Based on the symbol structure of the barcode, multiple functional areas of the barcode are determined from the barcode image; Based on multiple pixel values within each functional region, multiple contrast feature values are determined for each functional region, wherein the multiple contrast feature values correspond to multiple preset contrast features. For each functional region, obtain the weights of the various contrast features corresponding to that functional region; For each functional region, the contrast of the functional region is calculated based on the multiple contrast feature values of the functional region and the weight corresponding to each contrast feature under the functional region. The quality assessment score of the barcode image is determined based on the contrast corresponding to each functional area.
2. The method according to claim 1, characterized in that, Each of the functional areas includes at least one module; The step of determining multiple contrast feature values for each functional region based on multiple pixel values within each functional region further includes: For each functional area, multiple contrast feature values for each module are determined based on multiple pixel values within each module; The step of calculating the contrast of each functional region based on multiple contrast feature values of that functional region and the weight corresponding to each contrast feature in that functional region further includes: For each functional region, the contrast of each module is calculated based on multiple contrast feature values of each module within that functional region and the weight corresponding to each contrast feature in that functional region. For each functional area, the contrast ratio corresponding to that functional area is determined based on the contrast ratios of all modules within that functional area.
3. The method according to claim 2, characterized in that, The contrast characteristics include sharpness, uniformity, dynamic range robustness, and detail fidelity. The step of determining multiple contrast feature values for each functional region based on multiple pixel values within each module further includes: Based on multiple pixel values within each module, determine the grayscale change rate in the vertical direction and the grayscale change rate in the horizontal direction for each module; The sharpness of each module is determined based on the grayscale change rate in the vertical direction and the grayscale change rate in the horizontal direction. The uniformity of each module is determined based on the standard deviation of multiple pixel values within each module; The dynamic range robustness of each module is determined based on the 95th and 5th percentiles of multiple pixel values within each module; The detail fidelity of each module is determined based on the Laplacian value of multiple pixel values within each module.
4. The method according to claim 2, characterized in that, The step of determining multiple functional regions of the barcode from the barcode image based on the symbol structure of the barcode further includes: The barcode image is divided into multiple sub-regions based on the smallest unit of the barcode, wherein each sub-region includes multiple pixel values; Based on all pixel values of each sub-region, determine the representative pixel value of each sub-region; Based on the symbol structure of the barcode, multiple functional regions of the barcode are determined from the barcode image after it has been divided into multiple sub-regions, wherein each module in each functional region includes multiple sub-regions; The step of determining multiple contrast feature values for each functional region based on multiple pixel values within each module further includes: For each functional area, multiple contrast feature values for each module are determined based on the representative pixel values of the sub-regions included in each module.
5. The method according to claim 4, characterized in that, The step of dividing the barcode image into multiple sub-regions based on the smallest unit of the barcode further includes: The division interval is determined based on the smallest unit of the barcode; The barcode image is divided along the vertical and horizontal directions based on the division interval to obtain multiple sub-regions.
6. The method according to claim 2, characterized in that, The step of calculating the contrast of each module for each functional region, based on multiple contrast feature values of each module within that functional region and the weight corresponding to each contrast feature in that functional region, further includes: For each module in each functional region, each contrast feature value is multiplied by the weight corresponding to each contrast feature in that functional region to obtain a weighted value for each contrast feature value. The weighted values of all contrast feature values of each module are summed to obtain the contrast of each module.
7. The method according to claim 1, characterized in that, The functional areas include a positioning and correction graphic area, a format and version information area, and a data and error correction codeword area. The contrast features include sharpness features, uniformity features, dynamic range robustness features, and detail fidelity features. For the positioning and correction graphic region, the weight corresponding to the sharpness feature is greater than the weight corresponding to the uniformity feature, and the weight corresponding to the uniformity feature is greater than the weights corresponding to the dynamic range robustness feature and the detail fidelity feature, respectively. For the format and version information area, the weight corresponding to the uniformity feature is greater than the weight corresponding to the dynamic range robustness feature, and the weight corresponding to the dynamic range robustness feature is greater than the weights corresponding to the sharpness feature and the detail fidelity feature, respectively. For the data and error correction codeword region, the weights corresponding to the sharpness feature, the uniformity feature, and the dynamic range robustness feature are equal and greater than the weight corresponding to the detail fidelity feature.
8. The method according to claim 1, characterized in that, The step of determining the quality assessment score of the barcode image based on the contrast corresponding to each functional area further includes: Determine the region weight corresponding to each of the aforementioned functional regions; Multiply the contrast of each functional region by the region weight corresponding to each functional region to obtain the contrast weighted value of each functional region. The contrast of the barcode image is obtained by summing the contrast weights of all the functional areas. A quality assessment score for the barcode image is determined based on its contrast.
9. The method according to claim 8, characterized in that, The step of determining the quality assessment score of the barcode image based on its contrast further includes: The contrast of the barcode image is linearly mapped to a preset range to obtain a quality assessment score of the barcode image within the preset range, wherein the quality assessment score is linearly related to the probability of successful decoding of the barcode image within the preset range.
10. A barcode reader, characterized in that, Includes camera, memory, and processor; The camera is used to acquire barcode images; The memory stores computer programs; The processor executes the computer program to implement the barcode image quality assessment method according to any one of claims 1 to 9.
