Identification code image quality evaluation method, device, equipment and storage medium

By performing grayscale conversion, region extraction and weighted calculation on the identification code image, the problem of inaccurate identification code quality evaluation is solved, and a comprehensive and accurate identification code image quality evaluation is achieved.

CN117132552BActive Publication Date: 2025-09-16SHENZHEN QIANHAI EVOC ASIA-PACIFIC ELECTRONIC EQUIP TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310990737.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-04
Publication Date
2025-09-16
Estimated Expiration
2043-08-04

AI Technical Summary

Technical Problem

In the prior art, the identification code quality evaluation result is inaccurate because only the entire image is evaluated while the local imaging quality and code printing quality of the identification code area are ignored.

Method used

By performing grayscale conversion on the original image, extracting the identification code area, evaluating the imaging quality and code printing quality respectively, and performing weighted calculation on the local and full image evaluation results, the identification code image quality evaluation result is obtained.

Benefits of technology

It realizes the all-round analysis and evaluation of the identification code image, ensures the comprehensiveness and accuracy of the evaluation results, and avoids the bias caused by the full image evaluation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117132552B_ABST
    Figure CN117132552B_ABST
Patent Text Reader

Abstract

The embodiment of the present application relates to the field of image processing technology, and discloses a method, device, equipment, and storage medium for evaluating the quality of an identification code image. The method includes: obtaining an original image; converting the original image into a grayscale image; performing imaging quality evaluation on the grayscale image to obtain an overall imaging quality evaluation result; extracting an identification code region from the grayscale image to obtain a local image; performing imaging quality evaluation on the local image to obtain a local imaging quality evaluation result; performing code printing quality evaluation on the local image to obtain a code printing quality evaluation result; performing weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain an identification code quality evaluation result; performing weighted calculation on the identification code quality evaluation result and the overall imaging quality evaluation result to obtain an identification code image quality evaluation result. Through the above-mentioned method, the embodiment of the present application can solve the problem of inaccurate identification code quality evaluation results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of image processing technology, and specifically to a method, apparatus, device, and storage medium for evaluating the quality of an identification code image. Background Art

[0002] Identification codes, such as barcodes and QR codes, are widely used in industrial production, logistics and warehousing, commodity trading, and other fields. To ensure that the identification code can be quickly and effectively recognized during subsequent use, the identification code is first evaluated for quality. The evaluation results determine whether the current identification code or the corresponding product can be put into normal use.

[0003] Currently, most methods for evaluating the quality of identification codes involve taking a photo of the identification code and then performing a quality assessment on the entire image to obtain the evaluation result. However, in actual operation, the actual identification code area may only occupy a small part of the entire image. Judging the quality of the identification code based on the quality of the entire image is often biased. Summary of the Invention

[0004] In view of the above problems, embodiments of the present application provide a method, apparatus, device and storage medium for evaluating the quality of an identification code image, which are used to solve the problem of inaccurate identification code quality evaluation results.

[0005] According to one aspect of an embodiment of the present application, a method for evaluating the quality of an identification code image is provided, including: obtaining an original image; converting the original image into a grayscale image; performing imaging quality evaluation on the grayscale image to obtain an overall image imaging quality evaluation result; extracting an identification code region in the grayscale image to obtain a local image; performing imaging quality evaluation on the local image to obtain a local imaging quality evaluation result; performing code printing quality evaluation on the local image to obtain a code printing quality evaluation result; performing weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain an identification code quality evaluation result; performing weighted calculation on the identification code quality evaluation result and the overall image imaging quality evaluation result to obtain an identification code image quality evaluation result.

[0006] In an optional manner, a code printing quality evaluation is performed on a partial image to obtain a code printing quality evaluation result, including: correcting the partial image so that the edges of the identification code in the partial image are horizontal and vertical to obtain a corrected image; cropping the edges of at least two sides of the corrected image by a preset size to obtain a cropped image; and performing a code printing quality evaluation on the cropped image to obtain a code printing quality evaluation result.

[0007] In an optional manner, a code printing quality evaluation is performed on a cropped image to obtain a code printing quality evaluation result, including: creating a preset number of straight lines in the horizontal direction on the cropped image; for each straight line, performing the following steps respectively: determining whether the minimum grayscale value among the pixel points through which the current straight line passes is less than or equal to the product of the maximum grayscale value and a first preset percentage; if so, outputting level 4, where 4 is a preset coefficient; if not, outputting level 0; and / or obtaining multiple groups of adjacent pixel points through which the current straight line passes, where adjacent pixel points are separated by an identification code edge in the cropped image; calculating the difference in grayscale values ​​between adjacent pixel points, and obtaining multiple grayscale values. value difference; determine whether the minimum value among multiple grayscale value differences is greater than or equal to the product of the maximum value and a second preset percentage; if so, output level 4; if not, output level 0; and / or calculate the ratio x between the difference between the maximum grayscale value and the minimum grayscale value and the sum of the maximum grayscale value and the minimum grayscale value in the pixel points passed by the current straight line; if x≥a, output level 4; if b≤x<a, output level 3; if c≤x<b, output level 2; if d≤x<c, output level 1; if x<d, output level 0, wherein 0<d<c<b<a<1; calculate the average value of the output levels of all straight lines and round it to obtain the code printing quality evaluation result.

[0008] In an optional manner, a code printing quality evaluation is performed on a cropped image to obtain a code printing quality evaluation result, including: creating a preset number of straight lines in the horizontal direction on the cropped image; for each straight line, performing the following steps respectively: obtaining multiple groups of adjacent pixel points through which the current straight line passes, wherein adjacent pixel points are separated by an identification code edge in the cropped image; calculating the difference in grayscale values ​​between adjacent pixel points to obtain multiple grayscale value differences; judging whether the minimum value among the multiple grayscale value differences is greater than or equal to the product of the maximum value and a second preset percentage; if so, outputting level 4; if not, outputting level 0; calculating the difference between the maximum grayscale value and the minimum grayscale value and the maximum grayscale value among the pixel points through which the current straight line passes. The ratio x between the sum of the maximum grayscale value and the minimum grayscale value is calculated; if x≥a, level 4 is output; if b≤x<a, level 3 is output; if c≤x<b, level 2 is output; if d≤x<c, level 1 is output; if x<d, level 0 is output, where 0<d<c<b<a<1; the ratio y between the minimum value of multiple grayscale value differences and the difference between the maximum grayscale value and the minimum grayscale value is calculated; if y≥e, level 4 is output; if f≤y<e, level 3 is output; if g≤y<f, level 2 is output; if h≤y<g, level 1 is output; if y<h, level 0 is output, where 0<h<g<f<e<1; the average value of the output levels of all straight lines is calculated and rounded to obtain the code printing quality evaluation result.

[0009] In an optional manner, before calculating the average value of the output levels of all straight lines and rounding it to the nearest integer to obtain the code printing quality evaluation result, the method further includes: taking the minimum value of the multiple levels output by each straight line as the output level of the straight line.

[0010] In an optional manner, before performing weighted calculation on the local imaging quality evaluation results and the code printing quality evaluation results to obtain the identification code quality evaluation results, it also includes: decoding the local image and outputting the decoding results; performing weighted calculation on the local imaging quality evaluation results and the code printing quality evaluation results to obtain the identification code quality evaluation results, including: performing weighted calculation on the local imaging quality evaluation results, the code printing quality evaluation results and the decoding results to obtain the identification code quality evaluation results.

[0011] In an optional manner, imaging quality evaluation is performed on a grayscale image to obtain a full-image imaging quality evaluation result, including: performing brightness, clarity, and grayscale uniformity evaluation on the grayscale image to obtain a full-image brightness evaluation result, a full-image clarity evaluation result, and a full-image grayscale uniformity evaluation result; performing weighted calculation on the full-image brightness evaluation result, the full-image clarity evaluation result, and the full-image grayscale uniformity evaluation result to obtain a full-image imaging quality evaluation result; and / or, imaging quality evaluation is performed on a local image to obtain a local imaging quality evaluation result, including: performing brightness, clarity, and grayscale uniformity evaluation on the local image to obtain a local brightness evaluation result, a local clarity evaluation result, and a local grayscale uniformity evaluation result; performing weighted calculation on the local brightness evaluation result, the local clarity evaluation result, and the local grayscale uniformity evaluation result to obtain a local imaging quality evaluation result.

[0012] According to another aspect of an embodiment of the present application, an identification code image quality evaluation device is provided, including: an acquisition module for acquiring an original image; a conversion module for converting the original image into a grayscale image; a first evaluation module for performing imaging quality evaluation on the grayscale image to obtain an overall image imaging quality evaluation result; an extraction module for extracting the identification code area in the grayscale image to obtain a local image; a second evaluation module for performing imaging quality evaluation on the local image to obtain a local imaging quality evaluation result; a third evaluation module for performing code printing quality evaluation on the local image to obtain a code printing quality evaluation result; a first calculation module for performing weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain an identification code quality evaluation result; and a second calculation module for performing weighted calculation on the identification code quality evaluation result and the overall image imaging quality evaluation result to obtain an identification code image quality evaluation result.

[0013] According to another aspect of an embodiment of the present application, an identification code image quality assessment device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to perform the operations of any one of the above identification code image quality assessment methods.

[0014] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which executable instructions are stored. When the executable instructions are executed on an identification code image quality evaluation device, the identification code image quality evaluation device performs the operation of any one of the above identification code image quality evaluation methods.

[0015] In the identification code image quality evaluation method provided in the embodiment of the present application, the full-image imaging quality, the local image imaging quality of the identification code area, and the code printing quality of the identification code area are evaluated respectively to obtain the full-image imaging quality evaluation result, the local imaging quality evaluation result, and the code printing quality evaluation result. Then, the local imaging quality evaluation result and the code printing quality evaluation result are weightedly calculated to obtain the identification code quality evaluation result. Then, the identification code quality evaluation result and the full-image imaging quality evaluation result are weightedly calculated to obtain the final identification code image quality evaluation result. The entire evaluation process covers the three dimensions of full-image imaging quality, imaging quality of the identification code area image, and code printing quality of the identification code, thereby realizing a comprehensive analysis and evaluation of the identification code image, thereby ensuring that the evaluation result is comprehensive and accurate.

[0016] The above description is only an overview of the technical solutions of the embodiments of the present application. In order to more clearly understand the technical means of the embodiments of the present application, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiments of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present application. In addition, the same reference symbols are used to represent the same components throughout the drawings. In the drawings:

[0018] Figure 1 A flowchart of a method for evaluating the quality of an identification code image provided in an embodiment of the present application;

[0019] Figure 2 for Figure 1 A schematic flow chart of the sub-steps of step 160;

[0020] Figure 3 for Figure 2 Schematic diagram of the sub-step flow chart of step 163;

[0021] Figure 4 A flowchart illustrating steps performed for each straight line according to another embodiment of the present application;

[0022] Figure 5 A flowchart illustrating steps performed for each straight line according to another embodiment of the present application;

[0023] Figure 6 A flowchart illustrating steps performed for each straight line according to another embodiment of the present application;

[0024] Figure 7 for Figure 1 Schematic diagram of the process of the steps before step 170 and the sub-steps of step 170;

[0025] Figure 8 for Figure 1 Schematic diagram of the sub-step flow chart of step 130;

[0026] Figure 9 for Figure 1 A schematic flow chart of the sub-steps of step 150;

[0027] Figure 10 A schematic diagram of the modular structure of the identification code image quality evaluation device provided in the application embodiment;

[0028] Figure 11 A schematic diagram of the modular structure of the identification code image quality evaluation device provided in the application embodiment. DETAILED DESCRIPTION

[0029] The exemplary embodiments of the present application will be described in more detail below 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 can be implemented in various forms and should not be limited to the embodiments set forth herein.

[0030] A barcode is an image identifier that uses a set of information to represent a set of black bars and spaces of varying widths arranged according to a specific coding pattern. A QR code is an image identifier that uses a specific geometric pattern, alternating black and white, distributed on a plane according to a specific pattern to record data symbols.

[0031] In actual applications, image capture devices often experience diagonal inaccuracies during image acquisition, resulting in overexposure, underexposure, blur, and other abnormalities in the captured images. In these cases, the probability of decoding errors increases. If the identification code is used to indicate the product pass rate, a decoding error can lead to substandard products entering the market, causing huge losses to enterprises and society.

[0032] To evaluate the quality of identification codes, non-reference image quality assessment methods such as the IQA (Image Quality Assessment) algorithm can be used to score image clarity. However, barcodes typically only occupy a small portion of the entire image. Therefore, the evaluation results obtained by using the IQA algorithm on the entire image may not accurately reflect the imaging quality of the barcode area of ​​interest.

[0033] Based on this, this application combines the full image evaluation with the local evaluation of the identification code, and evaluates the imaging quality and code printing quality of the identification code area separately. Finally, the evaluation result obtained by weighted calculation of multiple evaluation results is used as the evaluation result of the identification code image quality, realizing multi-dimensional evaluation of the identification code image to fully ensure the comprehensiveness and accuracy of the evaluation results.

[0034] According to one aspect of the embodiment of the present application, a method for evaluating the quality of an identification code image is provided. Figure 1 The figure shows the process of the identification code image quality evaluation method provided by an embodiment of the present application. The method is executed by an identification code image quality evaluation device, such as a computer, server, etc. As shown in the figure, the method includes the following steps:

[0035] Step 110: Acquire the original image;

[0036] The original image can be obtained by taking a photo with a camera or scanning the image and then uploading it to the identification code image quality evaluation device.

[0037] Step 120: Convert the original image into a grayscale image.

[0038] In this step, the RGB three channels are converted into a single 256-level grayscale, realizing the conversion of the original image into a grayscale image.

[0039] Step 130: Perform imaging quality evaluation on the grayscale image to obtain an imaging quality evaluation result of the entire image.

[0040] Specifically, the above-mentioned IQA algorithm or other existing evaluation models can be used to evaluate the imaging quality of the grayscale image to obtain the full-image imaging quality evaluation result.

[0041] Step 140: extract the identification code region in the grayscale image to obtain a local image.

[0042] In this step, a neural network model can be used for semantic segmentation to realize the recognition and extraction of the identification code area in the grayscale image.

[0043] Step 150: Perform imaging quality evaluation on the local image to obtain a local imaging quality evaluation result.

[0044] Specifically, the imaging quality evaluation of a partial image may adopt the same algorithm or evaluation model as that for the imaging quality evaluation of the entire image.

[0045] Step 160: Perform code printing quality evaluation on the partial image to obtain a code printing quality evaluation result.

[0046] In this step, barcode print quality can be evaluated based on the barcode calculation standard IEC / IOS15416, while QR codes can be evaluated based on the calculation standard IEC / IOS15415. The barcode print quality rating is primarily used to measure whether the current barcode meets standard printing specifications, and code quality is generally tested based on the smallest decoding unit.

[0047] Step 170: Perform weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain the identification code quality evaluation result.

[0048] In this step, different weights can be pre-set for the imaging quality evaluation results and the code printing quality evaluation results. For example, the imaging quality evaluation results can have a weight of 0.4 and the code printing quality evaluation results can have a weight of 0.6. Alternatively, the imaging quality evaluation results can have a weight of 0.3 and the code printing quality evaluation results can have a weight of 0.7. Furthermore, before weighted calculation, the local imaging quality evaluation results and the code printing quality evaluation results are normalized.

[0049] Step 180: Perform weighted calculation on the identification code quality evaluation result and the full image imaging quality evaluation result to obtain the identification code image quality evaluation result.

[0050] In this step, different weights can be pre-set for the identification code quality evaluation results and the full image quality evaluation results. For example, the identification code quality evaluation results can have a weight of 0.6 and the full image quality evaluation results can have a weight of 0.4. Alternatively, the identification code quality evaluation results can have a weight of 0.7 and the full image quality evaluation results can have a weight of 0.3. Furthermore, the full image quality evaluation results are normalized before weighted calculation.

[0051] In the identification code image quality evaluation method provided in the embodiment of the present application, the full-image imaging quality, the local image imaging quality of the identification code area, and the code printing quality of the identification code area are evaluated respectively to obtain the full-image imaging quality evaluation result, the local imaging quality evaluation result, and the code printing quality evaluation result. Then, the local imaging quality evaluation result and the code printing quality evaluation result are weightedly calculated to obtain the identification code quality evaluation result. Then, the identification code quality evaluation result and the full-image imaging quality evaluation result are weightedly calculated to obtain the final identification code image quality evaluation result. The entire evaluation process covers the three dimensions of full-image imaging quality, imaging quality of the identification code area image, and code printing quality of the identification code, thereby realizing a comprehensive analysis and evaluation of the identification code image, thereby ensuring that the evaluation result is comprehensive and accurate.

[0052] For the above step 160, this application further proposes an implementation method, please refer to Figure 2 , the figure shows the sub-step process of step 160. As shown in the figure, step 160 includes the following steps:

[0053] Step 161: Correct the partial image so that the edges of the identification code in the partial image are horizontal and vertical, thereby obtaining a corrected image.

[0054] In this step, perspective transformation can be used to correct the partial image. For barcodes, the black bars are vertical after correction. For QR codes, the edges of the black bars or black blocks are horizontal and vertical after correction.

[0055] Step 162: Crop the edges of at least two sides of the corrected image by a preset size to obtain a cropped image.

[0056] In this step, for a barcode, 5% or 10% of the total height can be cut off at the upper and lower ends of the barcode; for a QR code, 5% or 10% of the total height can be cut off at the upper and lower ends of the barcode, and 5% or 10% of the total width can be cut off at the left and right sides.

[0057] Step 163: Perform code printing quality evaluation on the cropped image to obtain a code printing quality evaluation result.

[0058] In this embodiment, the local image is first corrected to make the edges of the identification code horizontal and vertical, which facilitates subsequent processing. In order to prevent the accuracy of the code printing quality evaluation from being affected by the presence of background at the edge of the identification code in the extracted local image, the edge of the corrected image is cropped so that the identification code content accounts for a larger proportion in the cropped image. Finally, the code printing quality evaluation is performed on the cropped image to ensure that the code printing quality evaluation result is accurate and reliable.

[0059] Regarding the operation of evaluating the code printing quality of the cropped image, this application proposes an implementation method. Figure 3 , the figure shows a sub-step flow chart of step 163. As shown in the figure, step 163 includes the following steps:

[0060] Step 1631: Create a preset number of straight lines along the horizontal direction on the cropped image.

[0061] In this step, the preset number can be, for example, 1, 2, 5, 10, 20, etc., and its specific value is not limited here. When creating multiple straight lines, the multiple straight lines can be evenly arranged in the vertical direction, and the intervals between the multiple straight lines can evenly divide the total height of the cropped image.

[0062] For each line, perform the following steps:

[0063] Step 16321: Determine whether the minimum grayscale value among the pixels that the current straight line passes through is less than or equal to the product of the maximum grayscale value and the first preset percentage.

[0064] Specifically, the first preset percentage may be 50%, for example.

[0065] If the judgment in step 16321 is yes, then step 16323 is executed: output level 4, where 4 is a preset coefficient.

[0066] If the judgment in step 16321 is no, then execute step 16325: output level 0.

[0067] Through the above method, the depth of the entire bar of the identification code can be judged. If it is darker, it will output level 4, and if it is lighter, it will output level 0.

[0068] Step 1633: Calculate the average value of the output levels of all straight lines and round it up to obtain the code printing quality evaluation result.

[0069] Specifically, the average value can be rounded to an integer using any of the following methods: rounding to zero, floor rounding, right rounding, and rounding. After rounding, a value between (0-4) is obtained. To facilitate subsequent weighted calculations, the value between (0-4) is normalized to a value between (0-1).

[0070] The final code printing quality evaluation result is obtained by averaging the output levels of all straight lines and rounding them up, which can more intuitively reflect the printing quality of the identification code.

[0071] like Figure 4 As shown in , in some embodiments, for each straight line, the following steps may be performed separately:

[0072] Step 16322: Obtain multiple groups of adjacent pixel points that the current straight line passes through, where adjacent pixel points are separated by an identification code edge in the cropped image.

[0073] Specifically, the adjacent pixel points are composed of two adjacent pixel points in the cropped image, an edge of the identification code in the cropped image is between the two adjacent pixel points, and the current straight line passes through the two adjacent pixel points.

[0074] Step 16324: Calculate the grayscale value differences between adjacent pixels to obtain multiple grayscale value differences.

[0075] Step 16326: Determine whether the minimum value among the multiple grayscale value differences is greater than or equal to the product of the maximum value and the second preset percentage.

[0076] Specifically, the second preset percentage may be, for example, 15%.

[0077] If the judgment in step 16326 is yes, execute step 16327: output level 4.

[0078] If the judgment in step 16326 is no, then execute step 16328: output level 0.

[0079] Through the above method, it can be determined whether part of the identification code is thin or the background at the edge of the identification code is dirty. If part of the identification code is thin or the background at the edge of the identification code is dirty, level 0 will be output. If part of the identification code is thin or the background at the edge of the identification code is not dirty, level 4 will be output.

[0080] like Figure 5 As shown in , in some embodiments, for each straight line, the following steps may be performed separately:

[0081] Step 163201: Calculate the ratio x between the difference between the maximum grayscale value and the minimum grayscale value and the sum of the maximum grayscale value and the minimum grayscale value among the pixels through which the current straight line passes.

[0082] Specifically, the maximum grayscale value is R max , the minimum gray value is R min , x=(R max -R min ) / (R max +R min ).

[0083] Step 163202: x ≥ a?

[0084] If the judgment in step 163202 is yes, execute step 163203: output level 4.

[0085] If the judgment in step 163202 is no, then execute step 163204: b≤x<a?

[0086] If the judgment in step 163204 is yes, execute step 163205: output level 3.

[0087] If the judgment in step 163204 is no, then execute step 163206: c≤x<b?

[0088] If the judgment in step 163206 is yes, execute step 163207: output level 2.

[0089] If the judgment in step 163206 is no, then execute step 163208: d≤x<c?

[0090] If the judgment in step 163208 is yes, execute step 1632091: output level 1.

[0091] If the judgment in step 163208 is no, then execute step 1632092: output level 0.

[0092] Specifically, 0<d<c<b<a<1. In an optional manner, a=0.7, b=0.55, c=0.4, d=0.2.

[0093] By means of the above method, the overall contrast of the identification code area can be evaluated.

[0094] It should be noted that for each straight line, you can choose Figure 3 、 Figure 4 or Figure 5 Any one of the above implementations can be used, or any two or three of them can be used simultaneously. For the solution where any two or three of these implementations are used simultaneously, each line corresponds to only one final output level, which is determined by the minimum of the two or three levels output for the corresponding line. If an identification code fails one of the print quality criteria, it is likely to be unrecognizable and undecodable. Therefore, using the minimum of the multiple levels output for each line as the final output level ensures the objectivity and accuracy of the evaluation results.

[0095] like Figure 6 As shown in , for each line, Figure 4 and Figure 5 After the steps of the embodiment shown, the following steps may be further performed:

[0096] Step 1632001: Calculate the ratio y between the minimum value among the multiple grayscale value differences in step 1324 and the difference between the maximum grayscale value and the minimum grayscale value in step 163201.

[0097] Step 1632002: y ≥ e?

[0098] If the judgment in step 1632002 is yes, execute step 1632003: output level 4.

[0099] If the judgment in step 1632002 is no, execute step 1632004: f≤y<e?

[0100] If the judgment in step 1632004 is yes, execute step 1632005: output level 3.

[0101] If the judgment in step 1632004 is no, then execute step 1632006: g≤y<f?

[0102] If the judgment in step 1632006 is yes, execute step 1632007: output level 2.

[0103] If the judgment in step 1632006 is no, then execute step 1632008: h≤y<g?

[0104] If the judgment in step 1632008 is yes, execute step 16320091: output level 1.

[0105] If the judgment in step 16320091 is no, then execute step 16320092: output level 0.

[0106] Specifically, 0<h<g<f<e<1. In an optional manner, e=0.7, f=0.6, g=0.5, h=0.4.

[0107] Through the above method, it is possible to more accurately determine whether the identification code is clear.

[0108] Similarly, for each line, Figures 4 to 6 The steps shown, or perform them simultaneously Figures 3 to 6 In the steps shown, each straight line will output three or four levels, and the minimum value among them will be used as the final output level of the line.

[0109] In order to further increase the reliability of the evaluation results, this application also proposes an implementation method, please refer to Figure 7 , the figure shows the steps before step 170 and the sub-step process of step 170. As shown in the figure, before step 170, the following steps are also included:

[0110] Step 1601: Decode the local image and output the decoding result.

[0111] Specifically, in some embodiments, step 1601 may include the following steps:

[0112] Correct the local image so that its edges are horizontal and vertical;

[0113] Traverse the image row by row and column by column;

[0114] According to the gradient change, the brightness and darkness width flow of the current scan line is obtained;

[0115] Initially filter the width stream;

[0116] If the filtered width stream meets the basic characteristics of the barcode, it is converted into a character stream based on the width stream lookup table and the check digit is calculated;

[0117] If the check bit is satisfied, the output decoding result is 1; if the check bit is not satisfied, the output decoding result is 0.

[0118] Step 170 includes the following steps:

[0119] Step 171: Perform weighted calculation on the local imaging quality evaluation result, the code printing quality evaluation result and the decoding result to obtain the identification code quality evaluation result.

[0120] It should be noted that before performing weighted calculation on the local imaging quality evaluation results, code printing quality evaluation results and decoding results, they are first normalized.

[0121] In an optional manner, the weight of the local imaging quality evaluation result is 0.3, the weight of the code printing quality evaluation result is 0.5, and the weight of the decoding result is 0.2.

[0122] In this solution, by using the decoding result as a dimension for evaluating the quality of the identification code, feedback can be provided to determine whether the identification code is outside the field of view. For example, if the evaluation results of other dimensions are relatively good, but only the decoding result is poor, it can be generally inferred that part of the identification code is outside the image field of view, and feedback can be provided to adjust the field of view of the camera.

[0123] Regarding the above step 130, this application further proposes an implementation method, please refer to Figure 8 , the figure shows the sub-step process of step 130. As shown in the figure, step 130 includes the following steps:

[0124] Step 131: Evaluate the brightness, clarity, and grayscale uniformity of the grayscale image to obtain a full-image brightness evaluation result, a full-image clarity evaluation result, and a full-image grayscale uniformity evaluation result.

[0125] In some embodiments, brightness evaluation of a grayscale image may be performed by the following steps:

[0126] Calculate the absolute value of the difference between the grayscale value of each pixel in the local image and 128 to obtain multiple difference values ​​m;

[0127] Sum all m and get the sum result sum;

[0128] Calculate the ratio between sum and the resolution of the grayscale image to get avg;

[0129] Calculate the absolute value of the difference between each m and avg to obtain multiple difference values ​​n;

[0130] Calculate the proportion of each grayscale value in the range of 0-255 in the grayscale image and get a list;

[0131] Calculate the product o between n corresponding to each pixel in the grayscale image and the list corresponding to the grayscale value of the pixel;

[0132] Sum all o and get the sum p;

[0133] Calculate the ratio between p and the resolution of the grayscale image to get mean;

[0134] Calculate the ratio between avg and mean to obtain the brightness evaluation result of the entire image.

[0135] In some embodiments, the clarity of the grayscale image can be evaluated by at least one of the following two methods:

[0136] Method 1: Use the Brenner gradient function for evaluation. The specific function is as follows:

[0137] D(f)=∑ y ∑ x |f(x+2,y)-f(x,y)| 2

[0138] Where f(x, y) represents the grayscale value of the pixel (x, y) in the grayscale image, and D(f) is the brightness evaluation result of the entire image.

[0139] Method 2: The Tenengrad gradient function uses the Soble operator to extract the horizontal and vertical gradients for evaluation. The specific function is as follows:

[0140]

[0141] Among them, G(x, y) is of the following form:

[0142]

[0143] Where T is the given edge detection threshold, and G(x, y) is the convolution of the Sobel horizontal and vertical edge detection operators at the pixel point (x, y).

[0144] For the embodiment using both of the above methods for clarity evaluation, after obtaining two evaluation results, the two evaluation results are normalized and weighted to obtain the final full image clarity evaluation result. Specifically, the weight of the two evaluation results can be 0.5 each.

[0145] In some embodiments, the grayscale uniformity evaluation of the grayscale image can be performed in the following manner:

[0146] A preset number of pixels are uniformly selected along the circumference from the edge of the grayscale image. Specifically, for example, 4, 6, 8, or 10 pixels can be uniformly selected.

[0147] Calculate the difference between the pixel value of each selected pixel and the pixel value of the center point of the grayscale image;

[0148] Calculate the average of multiple differences to obtain the grayscale uniformity evaluation result of the entire image.

[0149] Step 132: Perform weighted calculation on the full-image brightness evaluation result, the full-image clarity evaluation result, and the full-image grayscale uniformity evaluation result to obtain a full-image imaging quality evaluation result.

[0150] In some embodiments, the weight of the overall image brightness evaluation result may be set to 0.3, the weight of the overall image clarity evaluation result may be set to 0.4, and the weight of the global grayscale uniformity evaluation result may be set to 0.3.

[0151] Through the above method, it can be judged whether the imaging quality of the global image is qualified.

[0152] See also Figure 9 In some embodiments, step 150 includes the following steps:

[0153] Step 151: Evaluate the brightness, clarity, and grayscale uniformity of the local image to obtain a local brightness evaluation result, a local clarity evaluation result, and a local grayscale uniformity evaluation result;

[0154] Step 152: Perform weighted calculation on the local brightness evaluation result, the local clarity evaluation result, and the local grayscale uniformity evaluation result to obtain a local imaging quality evaluation result.

[0155] It is understandable that the specific operation process of step 151 and step 152 can be the same as the above description of step 131 and step 132, and will not be repeated here.

[0156] In the above manner, it can be determined whether the imaging quality of the identification code area image is qualified.

[0157] According to another aspect of the embodiment of the present application, a device for evaluating the quality of an identification code image is provided. Figure 10 The figure shows the modular structure of an identification code image quality assessment device. As shown in the figure, the identification code image quality assessment device 200 includes an acquisition module 210, a conversion module 220, a first assessment module 230, an extraction module 240, a second assessment module 250, a third assessment module 260, a first calculation module 270, and a second calculation module 280. Among them, the acquisition module 210 is used to acquire the original image; the conversion module 220 is used to convert the original image into a grayscale image; the first evaluation module 230 is used to perform imaging quality evaluation on the grayscale image to obtain the full-image imaging quality evaluation result; the extraction module 240 is used to extract the identification code area in the grayscale image to obtain a local image; the second evaluation module 250 is used to perform imaging quality evaluation on the local image to obtain a local imaging quality evaluation result; the third evaluation module 260 is used to perform code printing quality evaluation on the local image to obtain a code printing quality evaluation result; the first calculation module 270 is used to perform weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain the identification code quality evaluation result; the second calculation module 280 is used to perform weighted calculation on the identification code quality evaluation result and the full-image imaging quality evaluation result to obtain the identification code image quality evaluation result.

[0158] In some embodiments, the third evaluation module 260 is used to correct the local image so that the edges of the identification code in the local image are horizontal and vertical to obtain a corrected image; crop the edges of at least two sides of the corrected image by a preset size to obtain a cropped image; and perform code printing quality evaluation on the cropped image to obtain a code printing quality evaluation result.

[0159] In some embodiments, the third evaluation module 260 is used to create a preset number of straight lines in the horizontal direction on the cropped image; for each straight line, the following steps are performed respectively: determine whether the minimum grayscale value among the pixel points through which the current straight line passes is less than or equal to the product of the maximum grayscale value and the first preset percentage; if so, output level 4, where 4 is a preset coefficient; if not, output level 0; and / or, obtain multiple groups of adjacent pixel points through which the current straight line passes, where adjacent pixel points are separated by an identification code edge in the cropped image; calculate the difference in grayscale values ​​between adjacent pixel points to obtain multiple grayscale value differences; determine multiple grayscale values Whether the minimum value in the difference is greater than or equal to the product of the maximum value and the second preset percentage; if so, output level 4; if not, output level 0; and / or, calculate the ratio x between the difference between the maximum grayscale value and the minimum grayscale value and the sum of the maximum grayscale value and the minimum grayscale value in the pixel points passed by the current straight line; if x≥a, output level 4; if b≤x<a, output level 3; if c≤x<b, output level 2; if d≤x<c, output level 1; if x<d, output level 0, where 0<d<c<b<a<1; calculate the average value of the output levels of all straight lines and round it to obtain the code printing quality evaluation result.

[0160] In some embodiments, the third evaluation module 260 is used to create a preset number of straight lines in the horizontal direction on the cropped image; for each straight line, the following steps are performed respectively: obtain multiple groups of adjacent pixel points through which the current straight line passes, wherein adjacent pixel points are separated by an identification code edge in the cropped image; calculate the difference in grayscale values ​​between adjacent pixel points to obtain multiple grayscale value differences; determine whether the minimum value among the multiple grayscale value differences is greater than or equal to the product of the maximum value and a second preset percentage; if so, output level 4; if not, output level 0; calculate the difference between the maximum grayscale value and the minimum grayscale value and the sum of the maximum grayscale value and the minimum grayscale value among the pixel points through which the current straight line passes; The ratio x between the grayscale values ​​is calculated; if x≥a, level 4 is output; if b≤x<a, level 3 is output; if c≤x<b, level 2 is output; if d≤x<c, level 1 is output; if x<d, level 0 is output, where 0<d<c<b<a<1; the ratio y between the minimum value of multiple grayscale value differences and the difference between the maximum grayscale value and the minimum grayscale value is calculated; if y≥e, level 4 is output; if f≤y<e, level 3 is output; if g≤y<f, level 2 is output; if h≤y<g, level 1 is output; if y<h, level 0 is output, where 0<h<g<f<e<1; the average value of the output levels of all straight lines is calculated and rounded to obtain the code printing quality evaluation result.

[0161] In some embodiments, the third evaluation module 260 is further configured to use the minimum value among the multiple levels output by each straight line as the output level of the straight line.

[0162] In some embodiments, the identification code image quality evaluation device 200 further includes a decoding module configured to decode the local image and output a decoding result. The first calculation module 270 is configured to perform a weighted calculation on the local imaging quality evaluation result, the code printing quality evaluation result, and the decoding result to obtain an identification code quality evaluation result.

[0163] In some embodiments, the first evaluation module 230 is used to evaluate the brightness, clarity and grayscale uniformity of the grayscale image to obtain the full-image brightness evaluation result, the full-image clarity evaluation result and the full-image grayscale uniformity evaluation result; perform weighted calculation on the full-image brightness evaluation result, the full-image clarity evaluation result and the full-image grayscale uniformity evaluation result to obtain the full-image imaging quality evaluation result; and / or, the second evaluation module 250 is used to evaluate the brightness, clarity and grayscale uniformity of the local image to obtain the local brightness evaluation result, the local clarity evaluation result and the local grayscale uniformity evaluation result; perform weighted calculation on the local brightness evaluation result, the local clarity evaluation result and the local grayscale uniformity evaluation result to obtain the local imaging quality evaluation result.

[0164] According to another aspect of the embodiment of the present application, a device for evaluating the quality of an identification code image is also provided. Figure 11 The figure shows a structural schematic diagram of the identification code image quality evaluation device provided in an embodiment of the present application. The specific embodiment of the present application does not limit the specific implementation of the identification code image quality evaluation device.

[0165] like Figure 11 As shown, the identification code image quality assessment device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .

[0166] Processor 402, communication interface 404, and memory 406 communicate with each other via communication bus 408. Communication interface 404 is used to communicate with other devices, such as clients or other server network elements. Processor 402 is used to execute program 410, which may specifically perform the steps described in the embodiment of the method for evaluating the quality of identification code images.

[0167] Specifically, the program 410 may include program code including computer-executable instructions.

[0168] Processor 402 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 the present application. The one or more processors included in the identification code image quality assessment device may be processors of the same type, such as one or more CPUs, or may be processors of different types, such as one or more CPUs and one or more ASICs.

[0169] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0170] The program 410 can be specifically called by the processor 402 to enable the identification code image quality assessment device to perform the following operations:

[0171] Get the original image;

[0172] Convert the original image into a grayscale image;

[0173] Perform imaging quality evaluation on the grayscale image to obtain the full-image imaging quality evaluation result;

[0174] Extracting the identification code area in the grayscale image to obtain a local image;

[0175] Performing imaging quality evaluation on the local image to obtain a local imaging quality evaluation result;

[0176] Performing code printing quality evaluation on the local image to obtain a code printing quality evaluation result;

[0177] Performing weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain the identification code quality evaluation result;

[0178] The identification code quality evaluation result and the full image imaging quality evaluation result are weightedly calculated to obtain the identification code image quality evaluation result.

[0179] According to another aspect of an embodiment of the present application, a computer-readable storage medium is also provided, which stores executable instructions. When the executable instructions are run on an identification code image quality evaluation device, the identification code image quality evaluation device executes the identification code image quality evaluation method in any of the above method embodiments.

[0180] The executable instructions may be specifically used to enable the identification code image quality assessment device to perform the following operations:

[0181] Get the original image;

[0182] Convert the original image into a grayscale image;

[0183] Perform imaging quality evaluation on the grayscale image to obtain the full-image imaging quality evaluation result;

[0184] Extracting the identification code area in the grayscale image to obtain a local image;

[0185] Performing imaging quality evaluation on the local image to obtain a local imaging quality evaluation result;

[0186] Performing code printing quality evaluation on the local image to obtain a code printing quality evaluation result;

[0187] Performing weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain the identification code quality evaluation result;

[0188] The identification code quality evaluation result and the full image imaging quality evaluation result are weightedly calculated to obtain the identification code image quality evaluation result.

[0189] The algorithm or demonstration provided here are not inherently relevant to any particular computer, virtual system or other equipment. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing this type of system. In addition, the present application embodiment is not directed to any specific programming language yet. It should be understood that various programming languages ​​can be utilized to realize the content of the present application described here, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the present application.

[0190] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.

[0191] Similarly, it should be understood that in order to streamline the present application and assist in understanding one or more of the various aspects of the invention, in the above description of the exemplary embodiments of the present application, the various features of the embodiments of the present application are sometimes grouped together into a single embodiment, figure, or description thereof.

[0192] Those skilled in the art will appreciate that the modules in the devices in the embodiments can be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and can be divided into multiple submodules or subunits or subassemblies. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying abstract and drawings) and all processes or units of any method or device disclosed in this manner can be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying abstract and drawings) can be replaced by alternative features providing the same, equivalent or similar purpose.

[0193] The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application may be implemented by means of hardware comprising a number of distinct elements and by means of a suitably programmed computer. The use of the words first, second, and third, etc., does not denote any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order in which they are performed.

Claims

1. A method for evaluating the quality of an identification code image, characterized in that: The method comprises: Get the original image; Converting the original image into a grayscale image; Performing imaging quality evaluation on the grayscale image to obtain an imaging quality evaluation result of the entire image; Extracting the identification code region in the grayscale image to obtain a local image; Performing imaging quality evaluation on the local image to obtain a local imaging quality evaluation result; Performing code printing quality evaluation on the partial image to obtain a code printing quality evaluation result; Performing weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain an identification code quality evaluation result; A weighted calculation is performed on the identification code quality evaluation result and the full image imaging quality evaluation result to obtain an identification code image quality evaluation result.

2. The identification code image quality evaluation method according to claim 1, characterized in that: The performing code printing quality evaluation on the partial image to obtain a code printing quality evaluation result includes: Correcting the partial image so that the edges of the identification code in the partial image are horizontal and vertical, thereby obtaining a corrected image; cropping at least two sides of the corrected image by a preset size to obtain a cropped image; A code printing quality evaluation is performed on the cropped image to obtain a code printing quality evaluation result.

3. The identification code image quality evaluation method according to claim 2, characterized in that: The performing code printing quality evaluation on the cropped image to obtain a code printing quality evaluation result includes: Creating a preset number of straight lines along the horizontal direction on the cropped image; For each straight line, perform the following steps: Determine whether the minimum grayscale value among the pixels that the current line passes through is less than or equal to the product of the maximum grayscale value and the first preset percentage; if so, output level 4, where 4 is a preset coefficient; If not, output level 0; and / or, Obtaining multiple groups of adjacent pixel points that the current line passes through, wherein the adjacent pixel points are separated by an identification code edge in the cropped image; calculating the difference in grayscale values ​​between the adjacent pixel points to obtain multiple grayscale value differences; determining whether a minimum value among the multiple grayscale value differences is greater than or equal to the product of a maximum value and a second preset percentage; if so, outputting level 4; if not, outputting level 0; and / or, Calculate the ratio x between the difference between the maximum grayscale value and the minimum grayscale value and the sum of the maximum grayscale value and the minimum grayscale value among the pixels passed by the current straight line; if x ≥ a, output level 4; if b ≤ x < a, output level 3; if c ≤ x < b, output level 2; if d ≤ x < c, output level 1; if x < d, output level 0, where 0 < d < c < b < a < 1; The average value of the output levels of all the straight lines is calculated and rounded to obtain the code printing quality evaluation result.

4. The identification code image quality evaluation method according to claim 2, characterized in that: The performing code printing quality evaluation on the cropped image to obtain a code printing quality evaluation result includes: Creating a preset number of straight lines along the horizontal direction on the cropped image; For each straight line, perform the following steps: Obtaining multiple groups of adjacent pixel points that the current line passes through, wherein the adjacent pixel points are separated by an identification code edge in the cropped image; calculating the grayscale value differences between the adjacent pixel points to obtain multiple grayscale value differences; determining whether a minimum value among the multiple grayscale value differences is greater than or equal to the product of a maximum value and a second preset percentage; if so, outputting level 4; if not, outputting level 0; Calculate the ratio x between the difference between the maximum grayscale value and the minimum grayscale value and the sum of the maximum grayscale value and the minimum grayscale value among the pixels passed by the current straight line; if x ≥ a, output level 4; if b ≤ x < a, output level 3; if c ≤ x < b, output level 2; if d ≤ x < c, output level 1; if x < d, output level 0, where 0 < d < c < b < a < 1; Calculate the ratio y between the minimum value of the plurality of grayscale value differences and the difference between the maximum grayscale value and the minimum grayscale value; if y ≥ e, output level 4; if f ≤ y < e, output level 3; if g ≤ y < f, output level 2; if h ≤ y < g, output level 1; if y < h, output level 0, wherein 0 < h < g < f < e < 1; The average value of the output levels of all the straight lines is calculated and rounded to obtain the code printing quality evaluation result.

5. The identification code image quality evaluation method according to claim 3 or 4, characterized in that: Before calculating the average value of the output levels of all the straight lines and rounding it to obtain the code printing quality evaluation result, the method further includes: The minimum value among the multiple levels output by each straight line is used as the output level of the straight line.

6. The identification code image quality evaluation method according to any one of claims 1 to 4, characterized in that: Before performing weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain the identification code quality evaluation result, the method further includes: Decoding the local image and outputting a decoding result; The weighted calculation of the local imaging quality evaluation result and the code printing quality evaluation result to obtain the identification code quality evaluation result includes: A weighted calculation is performed on the local imaging quality evaluation result, the code printing quality evaluation result and the decoding result to obtain an identification code quality evaluation result.

7. The identification code image quality evaluation method according to any one of claims 1 to 4, characterized in that: The performing imaging quality evaluation on the grayscale image to obtain a full-image imaging quality evaluation result includes: performing brightness, clarity, and grayscale uniformity evaluation on the grayscale image to obtain a full-image brightness evaluation result, a full-image clarity evaluation result, and a full-image grayscale uniformity evaluation result; performing weighted calculation on the full-image brightness evaluation result, the full-image clarity evaluation result, and the full-image grayscale uniformity evaluation result to obtain a full-image imaging quality evaluation result; and / or, The performing imaging quality evaluation on the local image to obtain a local imaging quality evaluation result includes: performing brightness, clarity, and grayscale uniformity evaluation on the local image to obtain a local brightness evaluation result, a local clarity evaluation result, and a local grayscale uniformity evaluation result; and performing weighted calculation on the local brightness evaluation result, the local clarity evaluation result, and the local grayscale uniformity evaluation result to obtain a local imaging quality evaluation result.

8. A device for evaluating the quality of an identification code image, characterized in that: The device comprises: An acquisition module, used to acquire the original image; A conversion module, configured to convert the original image into a grayscale image; A first evaluation module is used to evaluate the imaging quality of the grayscale image to obtain an overall image quality evaluation result; An extraction module, configured to extract the identification code region in the grayscale image to obtain a local image; A second evaluation module is used to evaluate the imaging quality of the local image to obtain a local imaging quality evaluation result; a third evaluation module, configured to evaluate the code printing quality of the partial image and obtain a code printing quality evaluation result; a first calculation module, configured to perform weighted calculation on the local imaging quality evaluation result and the code printing quality evaluation result to obtain an identification code quality evaluation result; The second calculation module is used to perform weighted calculation on the identification code quality evaluation result and the full image imaging quality evaluation result to obtain the identification code image quality evaluation result.

9. A device for evaluating the quality of an identification code image, characterized in that: include: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store executable instructions, and the executable instructions enable the processor to perform the operation of the identification code image quality evaluation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The storage medium stores executable instructions, and when the executable instructions are executed on the identification code image quality assessment device, the identification code image quality assessment device performs the operation of the identification code image quality assessment method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Two-dimensional code quality evaluation method and device, storage medium, electronic equipment and system

    CN110889304A

  • One-dimensional code detection method and device, storage medium and electronic equipment

    CN111882572A