Barcode recognition method, terminal and system in low-quality image scene

Through the atomic analysis method and image segmentation neural network model based on barcode "bars" and "empties", the accuracy problem of barcode recognition under low-quality images is solved, the recognition accuracy is improved, and efficient barcode data extraction and sorting are achieved.

CN118569285BActive Publication Date: 2024-10-18SUNNIWELL AIOT TECH LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411045502.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-10-18
Estimated Expiration
2044-08-01

AI Technical Summary

Technical Problem

In low-quality image scenarios, the accuracy and efficiency of barcode recognition technology are affected. Especially when the image is damaged, incomplete, dirty, blurred or distorted, the recognition rate is not high, affecting production efficiency.

Method used

Using the atomic analysis method based on barcode "bar" and "empty", through image preprocessing, edge extraction, edge detection and confidence assignment, high-quality barcode data is generated, combined with the image segmentation neural network model, to extract and sort character data. Improve recognition accuracy.

Benefits of technology

It significantly improves the accuracy of barcode recognition in low-quality image scenarios, realizes the conversion from low-quality images to high-quality data, and obtains the final barcode parsing results through confidence ranking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569285B_ABST
    Figure CN118569285B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a barcode recognition method, terminal and system; the method comprises: reading image data containing a barcode, detecting and obtaining barcode image data and coordinate information corresponding to the barcode; converting the obtained barcode image into a grayscale image, calculating the pixel average value, and processing to obtain a first preprocessed image; extracting "edge" data of the first preprocessed image, obtaining atomic data of "bars" and "spaces" and processing to generate a second preprocessed image; performing edge detection on the second preprocessed image, obtaining reference atomic data of "bars" and "spaces"; combining the atomic data of "bars" and "spaces" with the reference atomic data, obtaining "bar and space" atomic data with confidence, and obtaining final module width data; determining a character encoding data list according to the final module width data, decoding to obtain a final string list; sorting the final strings in order of confidence, and using the string with the highest confidence as the final barcode recognition result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image information processing, and in particular relates to a barcode recognition method, terminal and system. Background Art

[0002] As a form of information encoding, barcodes represent different data using specific combinations of bars and spaces. They offer advantages such as large encoding capacity, high reliability, and low cost. With economic development and globalization, barcodes have become an indispensable part of modern business activities, widely used in a variety of fields, including commodity circulation, logistics management, and identity recognition.

[0003] With the increasing popularity of barcodes, the accuracy and efficiency of their detection and recognition technology have become particularly important. In practical applications, barcode recognition technologies can be divided into two categories: photoelectric scanning and image recognition. Photoelectric scanning technology uses the difference in light reflection between the "bars" and "spaces" on a barcode to obtain the data of the "bars" and "spaces" through photoelectric conversion. Finally, it is parsed according to the encoding rules to complete the identification and reading of the barcode content. However, photoelectric scanning technology must be aligned with the barcode area for scanning. When a label contains multiple densely arranged barcodes to be identified, manual handheld scanning is required to identify each barcode one by one, which is overall inefficient. Image recognition technology uses a camera to take a picture of the area where the barcode to be identified is located, then detects any barcodes present, and finally parses the detected barcodes. This method can recognize multiple barcodes at once, eliminating the need to manually scan each barcode one by one with a handheld scanner. However, barcode recognition still faces significant challenges when high-quality images are unavailable. For example, if the image is damaged, incomplete, dirty, blurred, or distorted, the barcode recognition accuracy is low, affecting barcode recognition efficiency and generally reducing the overall production efficiency of the factory. Summary of the Invention

[0004] In view of this, on one hand, some embodiments disclose a barcode recognition method in a low-quality image scenario, comprising the steps of:

[0005] S1. Read image data containing a barcode and detect and obtain the barcode image data and coordinate information corresponding to the barcode;

[0006] S2. Converting the obtained barcode image into a grayscale image, calculating a pixel average, setting an image enhancement scale factor according to the pixel average, performing image enhancement according to the image enhancement scale factor, increasing the contrast of the grayscale image, and obtaining a first preprocessed image;

[0007] S3, extracting "edge" data from the first preprocessed image, removing abnormal "edge" data, obtaining atomic data of "bars" and "spaces", and generating a second preprocessed image based on the atomic data of "bars" and "spaces";

[0008] S4, performing edge detection on the second pre-processed image to obtain reference "edge" data; obtaining reference atomic data of "bars" and "spaces" based on the reference "edge" data;

[0009] S5. Combining the atomic data of the “bar” and “space” with the reference atomic data to obtain the atomic data of the “bar space” with confidence;

[0010] S6. Obtaining the final module width data based on the “space” atomic data with confidence;

[0011] S7. Determine a character encoding data list according to the final module width data;

[0012] S8. Decode the character encoding data list to obtain a final string list;

[0013] S9. Sort the strings in the final string list in descending order of confidence;

[0014] S10. The character string with the highest confidence in the final character string list is used as the final barcode recognition result.

[0015] On the other hand, some embodiments disclose a barcode recognition terminal for executing a barcode recognition method in a low-quality image scenario.

[0016] In yet another aspect, some embodiments disclose a barcode recognition system including a barcode recognition terminal.

[0017] The barcode recognition method in low-quality image scenarios disclosed in the embodiments of the present invention recognizes low-quality barcode images based on the atomic parsing method of the barcode's "bars" and "spaces". High-quality barcode data can be obtained from the low-quality original image. Corresponding confidence levels are further assigned to possible combinations of "bars" and "spaces". The confidence levels of character data composed of the bar and space combinations are obtained. The character data are sorted according to the confidence levels, and the character combination with the highest confidence level is obtained as the barcode parsing result. This greatly improves the barcode recognition accuracy in low-quality image scenarios and has good application prospects in the barcode field. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 Flowchart of a barcode recognition method in low-quality image scenarios disclosed in some embodiments;

[0019] Figure 2Some embodiments disclose a flow chart for detecting image data to obtain barcode coordinate frames;

[0020] Figure 3 A flowchart of an image segmentation neural network model training disclosed in some embodiments;

[0021] Figure 4 A flowchart of redetermining the left and right boundaries of a barcode based on a coordinate frame corresponding to the barcode disclosed in some embodiments;

[0022] Figure 5 Some embodiments disclose step S3 generating a second pre-processed image flow chart;

[0023] Figure 6 Step S4 disclosed in some embodiments obtains a reference atomic data flow diagram of "bar" and "space";

[0024] Figure 7 Step S5 disclosed in some embodiments obtains a "bar-space" atomic data flow diagram with confidence;

[0025] Figure 8 Step S6 disclosed in some embodiments obtains the final module width data flow chart;

[0026] Figure 9 Flowchart of determining a character encoding data list in step S7 disclosed in some embodiments;

[0027] Figure 10 、 one The final string list is obtained in step S8 disclosed in some embodiments. DETAILED DESCRIPTION

[0028] The term "embodiment" is used herein specifically to describe any embodiment as "exemplary," and should not be construed as superior or preferable to other embodiments. Performance indicators in the embodiments of the present invention were tested using conventional testing methods in the art, unless otherwise specified. It should be understood that the terms used in the embodiments of the present invention are intended solely to describe specific implementations and are not intended to limit the disclosure of the embodiments of the present invention.

[0029] Unless otherwise specified, the technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which the embodiments of the present invention pertain; any experimental methods and technical means not otherwise specified in the embodiments of the present invention refer to experimental methods and technical means commonly used by those skilled in the art.

[0030] Throughout this document, including in the claims, transitional terms such as "comprises," "includes," "with," "having," "contains," "involving," and "accommodating" are understood to be open-ended, meaning "including but not limited to." Only the transitional terms "consisting of" and "composed of" are closed transitional terms.

[0031] In order to better illustrate the present invention, numerous specific details are provided in the following specific examples. It should be understood by those skilled in the art that the present invention can be practiced without certain specific details. In the examples, some methods, means, instruments, and equipment well known to those skilled in the art are not described in detail in order to highlight the main purpose of the present invention.

[0032] Under the premise of no conflict, the technical features disclosed in the embodiments of the present invention can be arbitrarily combined, and the resulting technical solutions belong to the contents disclosed in the embodiments of the present invention.

[0033] In some embodiments, as Figure 1 As shown, the barcode recognition method in a low-quality image scenario includes the following steps:

[0034] S1. Read image data containing a barcode and detect and obtain the barcode image data and coordinate information corresponding to the barcode;

[0035] S2. Converting the obtained barcode image into a grayscale image, calculating a pixel average, setting an image enhancement scale factor according to the pixel average, performing image enhancement according to the image enhancement scale factor, increasing the contrast of the grayscale image, and obtaining a first preprocessed image;

[0036] S3, extracting "edge" data from the first preprocessed image, removing abnormal "edge" data, obtaining atomic data of "bars" and "spaces", and generating a second preprocessed image based on the atomic data of "bars" and "spaces";

[0037] S4, performing edge detection on the second pre-processed image to obtain reference "edge" data; obtaining reference atomic data of "bars" and "spaces" based on the reference "edge" data;

[0038] S5. Combining the atomic data of the “bar” and “space” with the reference atomic data to obtain the atomic data of the “bar space” with confidence;

[0039] S6. Obtaining the final module width data based on the “space” atomic data with confidence;

[0040] S7. Determine a character encoding data list according to the final module width data;

[0041] S8. Decode the character encoding data list to obtain a final string list;

[0042] S9. Sort the strings in the final string list in descending order of confidence;

[0043] S10. The character string with the highest confidence in the final character string list is used as the final barcode recognition result.

[0044] Some embodiments disclose a barcode recognition method in a low-quality image scenario, wherein step S1 specifically includes: reading image data containing a barcode, detecting the image data to obtain a barcode coordinate frame, using the barcode coordinate frame to crop an image of a valid area of ​​the barcode, and obtaining barcode image data and coordinates corresponding to the barcode.

[0045] The embodiment of the present invention discloses a barcode recognition method in a low-quality image scenario. After reading an image containing a barcode, a barcode detector is used to detect the barcode in the image, and a valid area is extracted. Image prediction is further performed in the valid area to obtain the approximate position of the barcode. The approximate area containing the barcode is further processed to obtain an accurate coordinate frame of the valid area containing the barcode, and valid barcode data is obtained. The barcode valid data is further processed and parsed by a barcode recognizer. Based on the atomic parsing method of the barcode's "bar" and "space", the low-quality barcode image is recognized, and high-quality barcode data can be obtained from the low-quality original image. Corresponding confidence levels are further assigned to possible "bar" and "space" combinations to obtain the confidence levels of character data composed of the "bar" and "space" combinations. The character data is sorted according to the confidence levels, and the character combination with the highest confidence level is obtained as the barcode parsing result, thereby finally obtaining the encoded content of the barcode.

[0046] Some embodiments disclose a barcode recognition method, such as Figure 2 As shown, in step S1, the process of detecting image data to obtain a barcode coordinate frame specifically includes:

[0047] S101, sending the image data to the barcode segmentation model for prediction to obtain model output data;

[0048] S102, parsing the model output data and obtaining the barcode mask image predicted by the model;

[0049] S103, converting the barcode mask image into a binary grayscale image, wherein the background is black and the barcode valid area is pure white;

[0050] S104, performing contour extraction on the binary grayscale image; usually, before contour extraction, the binary grayscale image may be eroded and closed to fill holes and remove scattered points, and contour extraction is then performed on the eroded and closed binary image;

[0051] S105, traverse the extracted contour and calculate the area of ​​the contour;

[0052] S106. If the area of ​​the outline is not greater than the preset threshold, it is ignored. Taking the Code 128 barcode as an example, a complete barcode generally contains at least 4 characters, namely, a start character, a data character, a check character, and an end character. The 4 characters comprise a total of 46 modules. If the minimum module width is 1 pixel, then the minimum width of the barcode is 46 pixels. If the height of the barcode is not less than 30 pixels, then the preset threshold for the area is determined to be 46 × 30 = 1380.

[0053] S107, if the area of ​​the contour is greater than a preset threshold, the contour is put into a valid contour list;

[0054] S108, traverse the valid contour list, draw an outer approximate polygon for each valid contour, and generate a new barcode mask image;

[0055] S109, detecting all straight lines of the new barcode mask image, selecting the longest straight line and calculating its inclination;

[0056] S110, performing rotation correction on the new barcode mask image according to the inclination angle so that the barcode remains horizontal;

[0057] S111, re-extracting the contour of the rotated barcode mask image and drawing a circumscribed rectangle;

[0058] S112, obtaining a coordinate frame corresponding to each barcode according to the circumscribed rectangle of each outline;

[0059] S113, re-determining the left and right boundaries of the barcode according to the coordinate frame corresponding to the barcode;

[0060] S114. Obtain the final barcode coordinate frame based on the newly determined left and right boundaries.

[0061] In the barcode recognition method for low-quality image scenes disclosed in some embodiments, in step S101, the image data is fed into the barcode segmentation model for prediction to obtain model output data, which also includes a training step for the image segmentation neural network model, such as Figure 3 As shown, the specific methods include:

[0062] S1011 uses a camera to collect N images of the production line environment and stores them in the background image library;

[0063] S1012. Compile a character dictionary based on the data content of the barcode, and generate a list of character strings of varying lengths within a preset range based on the character dictionary;

[0064] S1013, generating a barcode image according to the string list, wherein a plurality of barcode images with different module widths and heights are generated for each string;

[0065] S1014, setting the white portion of the barcode image to transparent;

[0066] S1015, randomly selecting an image from the background image library as a background image;

[0067] S1016, randomly placing multiple barcode transparent images at a certain position of the background image;

[0068] S1017, generating a training image and a corresponding label mask image to obtain a barcode image segmentation dataset;

[0069] S1018. Using the prepared barcode image segmentation dataset, train an image segmentation neural network model;

[0070] Generally, the image segmentation neural network model can be selected according to the task requirements and model performance. From the perspective of task requirements, it includes semantic segmentation, instance segmentation, interactive segmentation, panoramic segmentation, etc. The task requirement in this article is semantic segmentation. You can first find the currently available semantic segmentation model. The optional models are: PP-LiteSeg, PP-MobileSeg, DeepLabV3P, MobileSeg, BiSeNetV2, DeepLabV3, Fast-SCNN, UNet++, ESPNetV2, etc. You can also freely match various models in various combinations. From the perspective of model performance, it includes model prediction accuracy, model inference speed and model size, and comprehensively considers the space occupied by memory, video memory and hard disk. Generally, you can consider choosing a model with faster inference speed and smaller resource usage as much as possible while meeting the prediction accuracy requirements.

[0071] S1019: Training is completed, and the barcode segmentation neural network model file is output.

[0072] In the barcode recognition method disclosed in some embodiments, step S113 redefines the left and right boundaries of the barcode according to the coordinate frame corresponding to the barcode, such as Figure 4 As shown, the specific methods include:

[0073] S1131, cutting out an image of a corresponding area on the original image according to the coordinate frame of the barcode;

[0074] S1132, converting the cropped image into a grayscale image and performing binarization processing to obtain binary image data, and converting the binary image data into a two-dimensional array;

[0075] S1133. Traverse the two-dimensional array row by row, and in combination with the barcode encoding rules, find the total number of pixels contained in the black and white bars of the first M characters and store them in a list. Usually, the list can also be processed to eliminate abnormal data based on the standard deviation. Usually, barcode encoding rules include EAN-8, EAN-13, UPC-A, UPC-E, Code39, Code128, etc. Taking Code128 as an example, except for the end character, each character contains 3 "bars" and 3 "spaces". For intuitive understanding, in this article, we regard "bars" as black and "spaces" as white. Usually, the M characters of the black and white bars can be determined according to the task requirements. Taking the Code128 barcode as an example, a complete barcode contains at least 4 characters, namely the start character, data characters, check character, and end character. If the data character is at least 1 in the specific task, M can be set to 4.

[0076] S1134. Calculate the average value of the data in the list and divide it by the number of modules represented by M characters to obtain module width data. Usually, module width data is recorded as module-width.

[0077] S1135. Search for a black bar starting from the leftmost side of the coordinate frame and moving leftward. If no black bar is found after exceeding a distance of five module widths, the position of the previous black bar is determined to be the leftmost boundary. Otherwise, continue searching for a black bar to the left. Typically, the distance of five module widths is recorded as 5×module-width.

[0078] S1136, starting from the rightmost side of the coordinate frame and searching to the right for a black bar; if no black bar is found after exceeding a distance of five module widths, the position of the previous black bar is determined to be the rightmost boundary; otherwise, the search for a black bar continues to the right;

[0079] S1137. Use the obtained leftmost boundary and rightmost boundary as boundary data of the newly determined coordinate frame.

[0080] In some embodiments, the barcode recognition method in a low-quality image scenario disclosed in step S2 includes: converting the obtained barcode image into a grayscale image, calculating the pixel average value, recorded as P_av; setting the image enhancement scale factor according to the pixel average value P_av, recorded as α; performing image enhancement according to the image enhancement scale factor α to increase the contrast of the grayscale image, and obtaining a first preprocessed image, recorded as pre_image_1.

[0081] In some embodiments, the image enhancement scaling factor α may be calculated as follows:

[0082] If the value of P_av is in the range of (0, 60], the value of α is 3; if the value of P_av is in the range of (60, 70], the value of α is 2.5; if the value of P_av is in the range of (70, 105], the value of α is 2; otherwise, the value of α is 1.5.

[0083] Some embodiments disclose a barcode recognition method in a low-quality image scenario, such as Figure 5 As shown, step S3 specifically includes:

[0084] S301 , reading a first pre-processed image and calculating a pixel average value; usually, the first pre-processed image is a grayscale image after image enhancement, and the pixel average value of the grayscale image is calculated and recorded as P_av1.

[0085] S302. Process the first pre-processed image data line by line to obtain "edge" data and form an "edge" data list. Generally, the "edge" in the barcode image data refers to the edge of the "bar" and the edge of the "space" of the barcode, which usually refers to the boundary position between the "bar" and the "space";

[0086] Typically, a barcode grayscale image is a two-dimensional image with H rows and W columns, where H is the height of the image and W is the width of the image. When processing the first pre-processed image, the same method is typically used to process row by row. The process of processing one row of image data includes:

[0087] Take a line of image data, where the number of pixels is equal to W, and then traverse point by point, taking the pixel values ​​of four points forward from the current position, and record them as: y0_0, y0_1, y0_2, y0_3;

[0088] Calculate the first-order difference based on these four points, which are recorded as: y1_1, y1_2, where:

[0089] y1_1 = y0_1 - y0_2, y1_2 = y0_2 - y0_3;

[0090] If the absolute value of y1_1 is less than the absolute value of y1_2, and both y1_1 and y1_2 are greater than 0, then set the value of y1_1 to the value of y1_2;

[0091] Calculate the second-order differences, recorded as: y2_1, y2_2; where:

[0092] y2_1 = (y0_0 - y0_1) - (y0_1 - y0_2), y2_2 = (y0_1 - y0_2) - (y0_2 -y0_3);

[0093] Based on the above data, we can determine whether the current point is an edge. The judgment method is as follows:

[0094] If y2_1, y2_2, y0_0, y0_2, y0_3, and P_av1 satisfy the following two relationships at the same time:

[0095] (y2_1>=0 and y2_2<0) or (y2_1>0 and y2_2<=0);

[0096] y0_0<(P_av1×1.2) , and max(y0_2, y0_3)>(P_av1×0.6);

[0097] Among them, max(y0_2, y0_3) represents the maximum value of y0_2 and y0_3. If the value of y0_3 is the largest, the value of max(y0_2, y0_3) is the value of y0_3, otherwise it is the value of y0_2;

[0098] The current point is set as an edge with the type EdgeType.WTB, indicating an edge from white to black, and then the edge point is added to the line_edges list;

[0099] If y2_1, y2_2, y0_0, y0_2, y0_3, and P_av1 do not satisfy the above relationship, continue to judge whether they satisfy the following two relationships:

[0100] (y2_1<=0 and y2_2>0) or (y2_1<0 and y2_2>=0);

[0101] y0_0>(P_av1×0.6) and min(y0_2, y0_3)<(P_av1×1.2);

[0102] Among them, min(y0_2, y0_3) represents the minimum value of y0_2 and y0_3. If the value of y0_3 is the smallest, the value of min(y0_2, y0_3) is the value of y0_3, otherwise it is the value of y0_2;

[0103] The current point is set as an edge with the type EdgeType.BTW, indicating an edge from black to white), and then the edge point is added to the line_edges list.

[0104] After the single-line point-by-point traversal is completed, line_edges is added to the edges list, that is, the "edge" data list.

[0105] S303 , obtaining the X coordinate values ​​of the edge elements in the first column of the “edge” data list, storing them in the first column of the edge element x coordinate list, and calculating the mean and standard deviation of the x coordinates of the first column of the edge element list.

[0106] Typically, after receiving the edge data list, the x-coordinate value of the first column of edge data is obtained and stored in the first column of the edge element x-coordinate list, recorded as X1_list; the mean and standard deviation of the x-coordinate value are further calculated, recorded as X1_av and X1_std.

[0107] S304 : Based on the mean and standard deviation of the x-coordinate list of the edge elements in the first column, process the data in a loop and eliminate abnormal data.

[0108] Usually, the judgment is made based on X1_av and X1_std, and the loop processing is performed;

[0109] In some embodiments, the loop processing process includes:

[0110] If X1_std ≥ X1_av, remove the element with the largest deviation in X1_list and remove the row data in edges of the corresponding position;

[0111] Finally, recalculate the mean and standard deviation of X1_list until X1_std≤X1_av, otherwise repeat the above process;

[0112] If X1_std<X1_av, then traverse edges and remove the row data corresponding to the elements in the first column whose x coordinates are greater than 1.5 times the standard deviation.

[0113] S305. Traverse the "edge" data row by row after removing abnormal data, determine the width value, type and x-coordinate of the "bar" and the width value, type and x-coordinate of the "space" in each row of data as the atomic data of the "bar" and "space" in each row of data, and store them in the row atomic data list; after traversing all row data, store all row atomic data in the "bar" and "space" atomic data lists, and obtain the "bar" and "space" atomic data lists.

[0114] Typically, after receiving the generated "edge" data edges after removing abnormal data, the "edge" data list is traversed line by line; during the process of traversing the edges data list line by line, each line of data is processed in the same way;

[0115] Generally speaking, the processing of a row of data includes:

[0116] Read a row of data, traverse each element one by one, and determine whether the current element is the first element;

[0117] If yes, then record the x coordinate of the current element as X_off and set the previous element as the current element; if not, then judge the previous element and the current element. Among them, element refers to the "edge" data, and the judgment method is as follows:

[0118] If the type of the previous element is EdgeType.WTB and the type of the current element is EdgeType.BTW, then get the atomic data of the "bar", set its x coordinate to X_last-X_off, type to ElementType.BLACK, and width to X-X_last; where X_last is the x coordinate of the previous element and X is the x coordinate of the current element.

[0119] Otherwise, continue to judge:

[0120] If the type of the previous element is EdgeType.BTW and the type of the current element edge is EdgeType.WTB, then get the "empty" atomic data, set its x coordinate to X_last - X_off, type to ElementType.WHITE, and width to X - X_last; where X_last is the x coordinate of the previous element and X is the x coordinate of the current element;

[0121] Store the atomic data of "bar" and "empty" into the line atomic data list, i.e. line_element_list;

[0122] After processing a row of data, the row atomic data list is stored in the "bar" and "empty" atomic data lists, namely element_list;

[0123] After traversing row by row, we get the atomic data list of "bar" and "empty", namely element_list.

[0124] S306 , creating a row array with the same length as the width of the barcode image according to the atomic data list of “bar” and “space”, and setting all the values ​​in the row array to 255.

[0125] Typically, based on the generated atomic data lists of "bars" and "spaces", a row array with the same length as the width of the barcode image is created, recorded as line_array, wherein all the values ​​in the array are set to 255.

[0126] S307. Traverse the atomic data lists of "bar" and "empty" row by row, process the atomic data therein, if the type of the atomic data is "bar", subtract 1 from the value within the width range of the "bar" in the row array; if the type of the atomic data is "empty", add 1 to the value within the width range of the "empty" in the row array.

[0127] Typically, the atomic data lists of "bars" and "spaces" are traversed line by line, and the atomic data therein are processed in the same way for each line of data. Generally, the processing process of a line of data includes:

[0128] Take a row of data and judge each element in it:

[0129] If the type of the current element is ElementType.BLACK, which means the current element is a "bar", then the value in the range [X:X+W] in the line_array array is decremented by 1;

[0130] If the type of the current element is ElementType.WHITE, which means the current element is "empty", then the value in the range [X:X+W] in the line_array array is decremented by 1;

[0131] Where X is the x-coordinate of the current element, and W is the width of the current element.

[0132] S308. After the traversal is completed, the row array is corrected. If the value in the row array is less than 0, it is set to 0. If the value in the row array is greater than 255, it is set to 255 to obtain a corrected row array.

[0133] S309: Create a blank image with the same size as the barcode image, traverse the blank image, and fill each row of data with the data in the corrected row array to obtain a second pre-processed image.

[0134] Some embodiments disclose a barcode recognition method in a low-quality image scenario, such as Figure 6 As shown, step S4 specifically includes:

[0135] S401, using the Canny algorithm to perform edge detection on the second pre-processed image to obtain reference "edge" data; calculating the pixel average value of the corrected row array;

[0136] Typically, the data of the generated second pre-processed image is received; a row of data is taken, denoted as canny_line; and the pixel average value of the corrected row array is calculated, denoted as P_av2;

[0137] S402. Take any row of data in the reference "edge" data and determine the demarcation threshold between "strip" and "space" based on the pixel average value of the corrected row array. The demarcation threshold for "strip" is set to 0.8 times the pixel average value, and the demarcation threshold for "space" is set to 1.2 times the pixel average value. Generally, the demarcation threshold for "strip" is set to P_av2×0.8, and the demarcation threshold for "space" is set to P_av2×1.2.

[0138] S403. Traverse the row data point by point to determine a point that can be used as an edge element, store the "edge" data of the point in the "edge" data list, and obtain the final reference "edge" data; wherein the "edge" data includes the x-coordinate, edge type, and pixel value. If the edge type is from "space" to "bar", the pixel value of the point is 0, and if the edge type is from "bar" to "space", the pixel value of the point is 255;

[0139] Typically, the row data is traversed point by point, and the pixel value of each point is judged to determine whether it can be used as an edge element point; if the pixel value of the current point is equal to 255, the values ​​of some variables are set:

[0140] pre_pixel = image_line[max(last_edge.x, idx-2):idx];

[0141] cur_pixel = image_line[idx];

[0142] next_value = image_line[idx:min(len(canny_line)-1, idx+3)];

[0143] max_pre_pixel = max(pre_pixel);

[0144] min_pre_pixel = min(pre_pixel);

[0145] min_next_value = min(next_value);

[0146] max_next_value = max(next_value);

[0147] wtb_diff_value = int(max_pre_pixel) - int(min_next_value);

[0148] btw_diff_value = int(max_next_value) - int(min_pre_pixel);

[0149] Then judge the type of the previous point last_edge.type, pre_pixel, white_value_threshold, pre_pixel, next_value, and bytw_diff_value;

[0150] If the following relationships are satisfied simultaneously:

[0151] last_edge.type == EdgeType.WTB;

[0152] min(pre_pixel) < white_value_threshold;

[0153] min(pre_pixel) < min(next_value);

[0154] max(next_value) > white_value_threshold or btw_diff_value > 40;

[0155] where, min(next_value) represents the minimum value in the next_value list, max(next_value) represents the maximum value in the next_value list, last_edge.type represents the type of the previous point, and EdgeType.WTB represents the edge from white to black or from "empty" to "bar";

[0156] Then set the current point as an edge element point, with the type of EdgeType.BTW and the value of 255, and at the same time add this point to the canny_line_edges list.

[0157] If the following relationships are satisfied:

[0158] last_edge.type == EdgeType.BTW;

[0159] max(pre_pixel) > black_value_threshold;

[0160] max(pre_pixel) > max(next_value);

[0161] (min(next_value) < white_value_threshold or wtb_diff_value > 40;

[0162] where, min(next_value) represents the minimum value in the next_value list, max(next_value) represents the maximum value in the next_value list, last_edge.type represents the type of the previous element, and EdgeType.BTW represents the edge from black to white or from "bar" to "empty";

[0163] Then set the point as an edge element point, the type is EdgeType.WTB, the value is 0, and add the point to the canny_line_edges list, that is, refer to the "edge" data list;

[0164] After the line-by-line traversal, the final reference edge data canny_line_edges is obtained.

[0165] S404, traverse the final reference "edge" data and make a judgment on each data;

[0166] If the current data is the first data, the previous data is used as the current data. If the current data is not the first data, continue to the next step.

[0167] If the type of the previous data is an edge from "bar" to "space", and the type of the current data is an edge from "space" to "bar", then create "space" atomic data, where the x coordinate of the "space" atomic data is the x coordinate of the previous data, the type is "space", and the width is the x coordinate of the current data minus the x coordinate of the previous data;

[0168] If the type of the previous data is an edge from "space" to "bar", and the type of the current data is an edge from "bar" to "space", then create atomic data of "bar", where the x coordinate of the atomic data of "bar" is the x coordinate of the previous data, the type is "bar", and the width is the x coordinate of the current data minus the x coordinate of the previous data;

[0169] S405 , storing the created atomic data of the “bar” and the atomic data of the “space” into the final reference “edge” data list, and obtaining the reference atomic data lists of the “bar” and the “space”.

[0170] In some embodiments, the reference "edge" data canny_line_edges is traversed and each element is judged. If it is the first element, last_edge = edge is set; where last_edge represents the previous element and edge represents the current element.

[0171] If the current element is not the first element, continue to judge:

[0172] If the type of the previous element is EdgeType.WTB and the type of the current element is EdgeType.BTW, then create atomic data of a "bar" with the x coordinate being X_last, the type being ElementType.BLACK, and the width being X-X_last; X being the x coordinate of the current element, and X_last being the x coordinate of the previous element.

[0173] If the type of the previous element is EdgeType.BTW and the type of the current element is EdgeType.WTB, create "empty" atomic data with the x coordinate of X_last, the type of ElementType.WHITE, and the width of X-X_last; X is the x coordinate of the current element, and X_last is the x coordinate of the previous element.

[0174] The obtained "bar" and "empty" atom data are added to the canny_line_elements list;

[0175] After the traversal is completed, the reference atomic data of "bars" and "spaces" are obtained, recorded as: ref_elements.

[0176] Some embodiments disclose a barcode recognition method in a low-quality image scenario, such as Figure 7 As shown, step S5 specifically includes:

[0177] S501, taking an element in the reference atomic data list of "bar" and "space" as a reference element, and taking its x coordinate as the reference coordinate and its width as the reference width value; usually, the reference coordinate can be recorded as X_ref, and the reference width can be recorded as W_ref;

[0178] S502, using the reference element, traverse each element in the atomic data list of "bar" and "empty";

[0179] If the absolute value of the difference between the coordinate value of the current element and the reference coordinate value is not greater than 1, and the absolute value of the difference between the width value of the current element and the reference width value is not greater than 1, the current element is determined as the selected element; the selected element is stored in the selected atom data list;

[0180] Usually, if the current element satisfies the relationship, the current element is added to the selected_elements list:

[0181] abs(X -X_ref)≤1;

[0182] abs(W - W_ref≤1;

[0183] element.type == ref_element.type; that is, the current element type is the same as the reference element type;

[0184] Where X is the x-coordinate of the current element, X_ref is the reference coordinate, W is the width of the current element, and W_ref is the reference width.

[0185] S503, constructing dictionary data using the selected element; wherein the atomic data of the constructed dictionary data is the data of the selected element, the x coordinate is the reference coordinate, and the width value is the reference width; and storing the constructed dictionary data into the "bar space" atomic data list;

[0186] S504, the traversal is completed, and the "bar space" atomic data list is obtained;

[0187] S505, traverse the "space" atomic data list, extract the elements one by one, and recalculate the confidence of the corresponding element according to the number of reliable data;

[0188] In some embodiments, the bw_elements list is traversed, and the elements therein are taken out one by one. The current element traversed is recorded as element; then the dictionary data is constructed according to element:

[0189] temp_dict ={"element": element, "width": element.width, "count": 1};

[0190] Elements in bw_elements with the same width data are grouped together. Every time an identical data item is encountered, "count" is incremented by 1.

[0191] Calculate the confidence of the corresponding element according to the value of "count":

[0192] element.score = temp_dict["count"] / len(bw_elements["elements"]);

[0193] Among them, element.score represents the confidence of the current element, temp_dict["count"] represents the "count" data item in the constructed dictionary data, and len(bw_elements["elements"]) represents the data length of the "elements" data item in the bw_elements dictionary;

[0194] S506. The traversal is completed, and a list of "bar space" atomic data with confidence is obtained, which is recorded as the bw_elements list.

[0195] Some embodiments disclose a barcode recognition method in a low-quality image scenario, such as Figure 8 As shown, step S6 specifically includes:

[0196] S601, traversing the "bar space" atomic data with confidence level row by row, and extracting the data of each row during the loop traversal process;

[0197] In some embodiments, the bw_elements list is traversed row by row, and in the loop traversal, the data bw_dict of each row is taken out: that is,

[0198] {"id": idx, "elements": elements, "x": ref_x, "everage_width": width_list};

[0199] S602, extract the width value of each row of data, and construct a width data list as a temporary module width data list;

[0200] In some embodiments, data _element_list = bw_dict["elements"] is retrieved, the _element_list list is traversed, and data is constructed: _temp_width_list = [{"width": elem.width, "score":elem.score},{}, ... ];

[0201] Add all _temp_width_list to _temp_bw_data list;

[0202] S603. Extract data according to the barcode encoding rules; for example, for a barcode based on Code 128 encoding rules, extract data from the temporary module width data list, with the last seven data items as the end characters and the remaining data as six characters each, to obtain an extracted data slice;

[0203] S604: Perform a complete permutation and combination on the extracted data to obtain module width data corresponding to the characters and their confidence levels;

[0204] In some embodiments, the arrangement and combination of width data includes:

[0205] w1 is an item in _temp_bw_data[0][0:min(3,len(_temp_bw_data[0]))];

[0206] w2 is an item in _temp_bw_data[1][0:min(3,len(_temp_bw_data[1]))];

[0207] w3 is an item in _temp_bw_data[2][0:min(3,len(_temp_bw_data[2]))];

[0208] w4 is an item in _temp_bw_data[3][0:min(3,len(_temp_bw_data[3]))];

[0209] w5 is an item in _temp_bw_data[4][0:min(3,len(_temp_bw_data[4]))];

[0210] w6 is an item in _temp_bw_data[5][0:min(3,len(_temp_bw_data[5]))];

[0211] Further construct new data _char_code_dict: {"score": _score, "width": _width}, where:

[0212] _score=round(w1["score"]*w2["score"]*w3["score"]*w4["score"]* w5["score"]* w6["score"], 4);

[0213] _width=[w1["width"], w2["width"], w3["width"], w4["width"], w5["width"], w6["width"]];

[0214] S605, storing the module width data corresponding to the character and its confidence level into a character width data list;

[0215] In some embodiments, the module width data _char_code_dict corresponding to the constructed single character is added to the _char_code list;

[0216] S606 , sorting the character width data in descending order of confidence, and storing the data in a final module width data list.

[0217] In some embodiments, the data items in _char_code are sorted from large to small according to confidence, and then added to the final module width data list, that is, the final_bw_data list; after the bw_elements traversal is completed, the final module width data final_bw_data is obtained.

[0218] Some embodiments disclose a barcode recognition method in a low-quality image scenario, such as Figure 9 As shown, step S7 specifically includes:

[0219] S701. Formulate a coding table based on barcode coding rules;

[0220] S702, parsing the final module width data according to the barcode encoding rules to generate a character code;

[0221] In some embodiments, the barcode encoding table is formulated as code128_charset, and the parsing of the width data includes:

[0222] Traverse the final_bw_data list, where each data item corresponds to a character;

[0223] Take each data item bw_data_list and then traverse bw_data_list;

[0224] Take each data_dict in bw_data_list and set: _width_list = _dict["width"], score = _dict["score"];

[0225] Generate character encoding based on _width_list. The rules are as follows:

[0226] B = [0] * 6;

[0227] everage_width = sum(width_list) / 11.0;

[0228] e1 = width_list[0] + width_list[1];

[0229] e2 = width_list[2] + width_list[3];

[0230] e3 = width_list[4] + width_list[5];

[0231] E1 = max(2, round(e1 / everage_width));

[0232] E2 = max(2, round(e2 / everage_width));

[0233] E3 = max(2, round(e3 / everage_width));

[0234] R1 = width_list[0] / (width_list[0]+ width_list[1]);

[0235] R2 = width_list[2] / (width_list[2]+ width_list[3]);

[0236] R3 = width_list[4] / (width_list[4]+ width_list[5]);

[0237] B[0] = round(R1 * E1);

[0238] B[1] = E1 - B[0];

[0239] B[2] = round(R2 * E2);

[0240] B[3] = E2 - B[2];

[0241] B[4] = round(R3 * E3);

[0242] B[5] = E3 - B[4];

[0243] Convert the numbers in array B into characters and concatenate them. The resulting string is the character code charcode_str.

[0244] S703, searching and matching the generated character code in the code table to obtain a list of all possible values ​​for each character;

[0245] In some embodiments, when searching and matching the generated character code in the code table, if a match is found, the character code corresponding to the character is determined to be charcode_str. Otherwise, the most similar character code is found in the code table and recorded as charcode_str. The bw_data_list is traversed to obtain all possible values ​​of each character code_str_list;

[0246] S704. Traverse all possible value lists, construct data items, and add them to the character encoding list corresponding to the character; wherein the data item in the character encoding list corresponding to a single character includes the character encoding and confidence level corresponding to the barcode;

[0247] In some embodiments, the code_str_list list is traversed to construct a data item {"code": code_str, "score": score} and add it to the _char_code list; where code_str is the corresponding character code in the code_str_list, and score is the corresponding confidence score;

[0248] S705, sorting the data items in the character encoding list corresponding to the single character in descending order of confidence, and then adding them to the character encoding list corresponding to the barcode image;

[0249] In some embodiments, the data items in _char_code are sorted from largest to smallest according to confidence, and then added to the char_code_list list;

[0250] S706: The traversal is completed, and a character encoding data list corresponding to the barcode image corresponding to the final module width is obtained, namely, char_code_list.

[0251] In some embodiments, the data format of the character encoding data list is:

[0252] char_code_list = [;

[0253] [{'code': '211214', 'score': 1.0}], # first character;

[0254] [{'code': '321122', 'score': 0.9998}], # The second character;

[0255] [{'code': '123221', 'score': 0.9615}, {'code': '214121', 'score':0.0094}];

[0256] [{'code': '223211', 'score': 1.0}]; ...;

[0258] [{'code': '2331112', 'score': 1.0}] # The last character, the termination character;

[0259] ].

[0260] Some embodiments disclose a barcode recognition method in a low-quality image scenario, such as Figure 10 As shown, step S8 specifically includes:

[0261] S801, performing complete permutations and combinations on all possible characters in the character encoding data list corresponding to the barcode image to obtain a list of all possible character combinations;

[0262] In some embodiments, all possible characters in char_code_list are fully permuted and combined to obtain all possible character combinations code_data_all. To prevent the amount of data from being too large, we can set the maximum amount of data to N, for example, N is set to 3000;

[0263] S802, traverse the list of all possible character combinations, combine all possible values ​​of the barcode verification character, and verify each character combination;

[0264] S803: construct a data item for the character combination that passes the verification, where the data of the data item includes the character combination and the corresponding confidence level;

[0265] S804. Add the constructed data item to the decoded data list to obtain a list of strings that have completed decoding and passed verification as the final string list;

[0266] In some embodiments, the code_data_all list is traversed, and each character combination is verified in combination with a check code. Further, if the verification passes, a data item is constructed: {"content": decoded_str, "score": _score}, where: decoded_str is the character combination that passed the verification, and score is its corresponding confidence level; the data item is added to the decoded_str_list list as the final string list.

[0267] Some embodiments disclose a barcode recognition terminal for performing a barcode recognition method in low-quality image scenarios. Typically, the barcode recognition terminal includes a computer-readable storage medium storing computer code. The barcode recognition terminal also includes an information processor. When the information processor processes the computer program code, it executes the barcode recognition method to scan and recognize the barcode.

[0268] Some embodiments disclose a barcode recognition system, including a barcode recognition terminal.

[0269] The barcode recognition method in low-quality image scenarios disclosed in the embodiments of the present invention recognizes low-quality barcode images based on the atomic parsing method of the barcode's "bars" and "spaces". High-quality barcode data can be obtained from the low-quality original image. Corresponding confidence levels are further assigned to possible combinations of "bars" and "spaces". The confidence levels of character data composed of the combination of "bars" and "spaces" are obtained. The character data are sorted according to the confidence levels, and the character combination with the highest confidence level is obtained as the barcode parsing result. This greatly improves the accuracy of barcode recognition in low-quality image scenarios and has good application prospects in the barcode field.

[0270] The technical solutions and technical details disclosed in the embodiments of the present invention are merely illustrative of the inventive concept of the present invention and do not constitute a limitation on the technical solutions of the embodiments of the present invention. Any conventional changes, replacements or combinations of the technical details disclosed in the embodiments of the present invention have the same inventive concept as the present invention and are within the scope of protection of the claims of the present invention.

Claims

1. A barcode recognition method in a low-quality image scene, characterized in that: Includes steps: S1, reading the image data containing the barcode, and detecting and obtaining the barcode image data and coordinate information corresponding to the barcode; S2, converting the obtained barcode image into a grayscale image, calculating the pixel average, setting an image enhancement scale factor according to the pixel average, performing image enhancement according to the image enhancement scale factor, increasing the contrast of the grayscale image, and obtaining a first preprocessed image; S3, extracting "edge" data from the first preprocessed image, removing abnormal "edge" data, obtaining atomic data of "bars" and "spaces", and generating a second preprocessed image based on the atomic data of "bars" and "spaces"; specifically comprising: S301, reading a first preprocessed image and calculating a pixel average value; S302, processing the first pre-processed image data line by line to obtain "edge" data and form an "edge" data list; S303, obtaining the X coordinate values ​​of the edge elements in the first column of the "edge" data list, storing them in the first column of the edge element x coordinate list, and calculating the mean and standard deviation of the x coordinates of the first column of the edge element list; S304, according to the mean and standard deviation of the x-coordinate list of the edge elements in the first column, loop through the data and remove abnormal data; S305, traversing the "edge" data after removing abnormal data line by line, determining the width value, type and x-coordinate of the "bar" and the width value, type and x-coordinate of the "space" in each line of data as the atomic data of the "bar" and "space" in each line of data, and storing them in a line atomic data list; after traversing all line data, storing all line atomic data in the "bar" and "space" atomic data lists, that is, obtaining the "bar" and "space" atomic data lists; S306, according to the "bar" and "space" atomic data lists, create a row array with the same length as the barcode image width, and all values ​​in the row array are set to 255; S307, traverse the "bar" and "empty" atomic data lists row by row, process the atomic data therein, if the type of the atomic data is "bar", reduce the value within the width range of the "bar" in the row array by 1, if the type of the atomic data is "empty", increase the value within the width range of the "empty" in the row array by 1; S308, after the traversal is completed, the row array is corrected. If the value in the row array is less than 0, it is set to 0. If the value in the row array is greater than 255, it is set to 255 to obtain a corrected row array; S309, creating a blank image of the same size as the barcode image, traversing the blank image, and filling each row of data with the data in the corrected row array to obtain a second preprocessed image; S4, performing edge detection on the second preprocessed image to obtain reference "edge" data; obtaining reference atomic data of "bars" and "spaces" according to the reference "edge" data; specifically including: S401, using the Canny algorithm to perform edge detection on the second preprocessed image to obtain reference "edge" data; and calculating the pixel average value of the corrected row array; S402, taking any row of data in the reference "edge" data, and determining the demarcation threshold between "bar" and "space" according to the pixel average value of the corrected row array, wherein the demarcation threshold of "bar" is set to 0.8 times the pixel average value, and the demarcation threshold of "space" is set to 1.2 times the pixel average value; S403, traverse the row data point by point, determine the point that can be used as an edge element, store the "edge" data of the point in the "edge" data list, and obtain the final reference "edge" data; wherein the "edge" data includes the x-coordinate, edge type, and pixel value. If the edge type is from "empty" to "strip", the pixel value of the point is 0, and if the edge type is from "strip" to "empty", the pixel value of the point is 255; S404, traverse the final reference "edge" data and make a judgment on each data therein; If the current data is the first data, the previous data is used as the current data. If the current data is not the first data, continue to the next step. If the type of the previous data is the edge from "bar" to "space", and the type of the current data is the edge from "space" to "bar", then create "space" atomic data, where the x coordinate of the "space" atomic data is the x coordinate of the previous data, the type is "space", and the width is the x coordinate of the current data minus the x coordinate of the previous data; If the type of the previous data is the edge from "space" to "bar", and the type of the current data is the edge from "bar" to "space", then create the "bar" atomic data, where the x coordinate of the "bar" atomic data is the x coordinate of the previous data, the type is "bar", and the width is the x coordinate of the current data minus the x coordinate of the previous data; S405, storing the created "bar" atomic data and "blank" atomic data into the final reference atomic data list, to obtain the "bar" and "blank" reference atomic data lists; S5, combining the atomic data of "bars" and "spaces" with the reference atomic data to obtain atomic data of "bars and spaces" with confidence; S6. Obtaining final module width data according to the "space" atomic data with confidence; S7, determining a character encoding data list according to the final module width data; S8, decoding the character encoding data list to obtain a final string list; S9, sorting the strings in the final string list in descending order of confidence; S10. The character string with the highest confidence in the final character string list is used as the final barcode recognition result.

2. The barcode recognition method in low-quality image scenarios according to claim 1, characterized in that: Step S1 specifically includes: reading image data containing a barcode, detecting the image data, obtaining a barcode coordinate frame, cutting out an image of a valid area of ​​the barcode using the barcode coordinate frame, and obtaining barcode image data and coordinates corresponding to the barcode.

3. The barcode recognition method in low-quality image scene according to claim 2, characterized in that: In step S1, the process of detecting the image data to obtain the barcode coordinate frame specifically includes: S101, sending the image data to the barcode segmentation model for prediction to obtain model output data; S102, parsing the model output data, and obtaining the barcode mask image predicted by the model; S103, converting the barcode mask image into a binary grayscale image, wherein the background is black and the barcode valid area is pure white; S104, extracting the contour of the binary grayscale image; S105, traversing the extracted contour and calculating the area of ​​the contour; S106, if the area of ​​the contour is not greater than the preset threshold, it is ignored; S107, if the area of ​​the contour is greater than a preset threshold, the contour is put into a valid contour list; S108, traversing the valid contour list, drawing an outer approximate polygon for each valid contour, and generating a new barcode mask image; S109, detecting all straight lines of the new barcode mask image, selecting the longest straight line and calculating its inclination; S110, performing rotation correction on the new barcode mask image according to the inclination angle so that the barcode remains horizontal; S111, re-extracting the contour of the rotated barcode mask image and drawing a circumscribed rectangle; S112, obtaining a coordinate frame corresponding to each barcode according to the circumscribed rectangle of each contour; S113, re-determining the left and right boundaries of the barcode according to the coordinate frame corresponding to the barcode; S114. Obtain the final barcode coordinate frame according to the newly determined left and right boundaries.

4. The barcode recognition method in low-quality image scenarios according to claim 3, characterized in that: Step S113 re-determines the left and right boundaries of the barcode according to the coordinate frame corresponding to the barcode. The specific method includes: S1131, cutting out an image of a corresponding area on the original image according to the coordinate frame of the barcode; S1132, converting the cropped image into a grayscale image and performing binarization processing to obtain binarized image data, and converting the binarized image data into a two-dimensional array; S1133, traverse the two-dimensional array row by row, find the total number of pixels contained in the black and white bars of the first M characters in combination with the barcode encoding rules, and store it in a list; S1134, calculating the average value of the data in the list, and then dividing it by the number of modules represented by the M characters to obtain module width data; S1135, searching for black bars from the leftmost side of the coordinate frame to the left; if no black bars are found after exceeding the distance of five module widths, the position of the previous black bar is determined to be the leftmost boundary, otherwise, continue searching for black bars to the left; S1136, searching for black bars from the rightmost side of the coordinate frame to the right; if no black bars are found after exceeding the distance of five module widths, the position of the previous black bar is determined to be the rightmost boundary, otherwise, continue searching for black bars to the right; S1137. Use the obtained leftmost boundary and rightmost boundary as boundary data of the newly determined coordinate frame.

5. The barcode recognition method in low-quality image scenarios according to claim 1, characterized in that: Step S5 specifically includes: S501, taking an element in the reference atomic data list of "bar" and "space" as a reference element, taking its x coordinate as a reference coordinate, and its width value as a reference width value; S502, using the reference element, traverse each element in the atomic data list of "bar" and "space"; If the absolute value of the difference between the coordinate value of the current element and the reference coordinate value is not greater than 1, and the absolute value of the difference between the width value of the current element and the reference width value is not greater than 1, the current element is determined as the selected element; the selected element is stored in the selected atomic data list; S503, constructing dictionary data using the selected element; wherein the atomic data of the constructed dictionary data is the data of the selected element, the x coordinate is the reference coordinate, and the width value is the reference width; and storing the constructed dictionary data into the "bar space" atomic data list; S504, the traversal is completed, and the "bar empty" atomic data list is obtained; S505, traverse the "space" atomic data list, take out the elements one by one, and recalculate the confidence of the corresponding element according to the number of credible data; S506. The traversal is completed, and a list of "space" atomic data with confidence is obtained.

6. The barcode recognition method in a low-quality image scenario according to claim 1, characterized in that: Step S6 specifically includes: S601, traversing the "bar space" atomic data with confidence level row by row, and taking out the data of each row during the loop traversal process; S602, extract the width value of each row of data, and construct a width data list as a temporary module width data list; S603, extracting data according to barcode encoding rules; S604, performing complete permutation and combination on the extracted data to obtain module width data corresponding to the characters and their confidence levels; S605, storing the module width data corresponding to the character and its confidence level into a character width data list; S606 , sort the character width data in descending order of confidence, and store them in a final module width data list.

7. The barcode recognition method in low-quality image scenarios according to claim 1, characterized in that: Step S7 specifically includes: S701. Formulate a coding table in accordance with barcode coding rules; S702, parsing the final module width data according to the barcode encoding rules to generate character encoding; S703, searching and matching the generated character code in the code table to obtain a list of all possible values ​​for each character; S704, traverse all possible value lists, construct data items, and add them to the character code list corresponding to the character; wherein the data item of the character code list corresponding to a single character includes the character code and confidence level corresponding to the barcode; S705, sorting the data items in the character encoding list corresponding to the single character in descending order of confidence, and then adding them to the character encoding list corresponding to the barcode image; S706: The traversal is completed, and a character encoding data list corresponding to the barcode image corresponding to the final module width is obtained.

8. The barcode recognition method in low-quality image scenarios according to claim 1, characterized in that: Step S8 specifically includes: S801, completely arrange and combine all possible characters in the character encoding data list corresponding to the barcode image to obtain a list of all possible character combinations; S802, traverse the list of all possible character combinations, combine all possible values ​​of the barcode verification character, and verify each character combination; S803, constructing a data item for the character combination that passes the verification, wherein the data of the data item includes the character combination and the corresponding confidence level; S804: Add the constructed data items to the decoded data list to obtain a string list that has completed decoding and passed verification as the final string list.

9. A barcode recognition terminal, characterized in that: Used to execute the barcode recognition method in a low-quality image scene as described in any one of claims 1 to 8.

10. A barcode recognition system, characterized in that: Includes the barcode recognition terminal described in claim 9.

Citation Information

Patent Citations

  • Barcode correcting method and device

    CN105512595A

  • Decoding method of stained one-dimensional bar code

    CN114298078A