Barcode recognition method, terminal and system

Through the image segmentation neural network model and enhanced correction technology, the problem of insufficient positioning and accuracy in the recognition of densely arranged barcodes has been solved, and multiple densely arranged barcodes can be efficiently identified, improving production efficiency and recognition accuracy.

CN118428382BActive Publication Date: 2024-09-10SUNNIWELL AIOT TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410875184.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2024-09-10
Estimated Expiration
2044-07-02

AI Technical Summary

Technical Problem

Existing barcode recognition technology suffers from problems such as inaccurate positioning, low recognition rate, and low-quality image parsing errors in densely arranged barcode recognition, resulting in insufficient efficiency and accuracy.

Method used

The image segmentation neural network model is used for barcode detection and recognition. It removes noise through enhancement and correction methods, accurately locates barcodes and improves recognition accuracy. It can identify multiple densely arranged barcodes at one time.

Benefits of technology

It improves the accuracy and production efficiency of barcode recognition, especially performs well in low-quality image processing, and is suitable for densely arranged barcode recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118428382B
    Figure CN118428382B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a barcode recognition method, terminal and system; the method includes: reading image data containing a barcode; detecting the image data to obtain a barcode coordinate frame; using the barcode coordinate frame to cut out an image of a valid area of ​​the barcode to obtain image data and coordinate information corresponding to the barcode; recognizing the image data information of the barcode to obtain the encoding content corresponding to the barcode, specifically including: processing the barcode image to obtain a barcode feature array; calculating a black and white bar width data group according to the barcode feature array; obtaining black and white bar module quantity data according to the black and white bar width data group; formulating a coding table according to the barcode coding rules; obtaining the barcode encoding content according to the matching result between the coding table and the black and white bar module quantity data. The barcode can be accurately positioned, the recognition accuracy of the barcode is improved, and multiple densely arranged barcodes can be accurately recognized at one time, thereby improving production efficiency.
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 way of encoding information, barcodes represent different data information through a specific combination of bars and spaces, and have the advantages of large encoding capacity, high reliability, and low cost. With the development of the economy and the trend of globalization, barcodes have become an indispensable part of modern business activities and are widely used in many fields such as commodity circulation, logistics management, and identity recognition.

[0003] With the popularization of barcode applications, the accuracy and efficiency of its detection and recognition technology have become particularly important. In practical applications, barcode recognition technology can be divided into two categories: photoelectric scanning and image recognition. Photoelectric scanning technology uses the difference in the reflection of black and white bars on the barcode to obtain the data of the black and white bars after photoelectric conversion, and finally parses it according to the coding rules to complete the recognition and reading of the barcode content. However, photoelectric scanning technology must align the barcode area for scanning. When there are multiple densely arranged barcodes to be identified on a label sticker, it is necessary to manually hold a scanner to align and identify them one by one, which is not efficient overall. Image recognition technology uses a camera to take a photo of the area where the barcode to be identified is located, then detects the barcodes in it, and finally parses the detected barcodes. This method can recognize multiple barcodes at one time, eliminating the step of manually holding a scanner to scan one by one, but there are currently problems such as low recognition rate and poor stability caused by inaccurate barcode positioning, and barcode parsing errors caused by low barcode image quality. Summary of the invention

[0004] In view of this, on the one hand, some embodiments disclose a barcode recognition method, comprising the steps of:

[0005] S1, reading image data containing a barcode;

[0006] S2, detect image data and obtain barcode coordinate frame;

[0007] S3, using the barcode coordinate frame to cut out the image of the effective area of ​​the barcode, and obtain the image data and coordinate information corresponding to the barcode;

[0008] S4, identifying the image data information of the barcode, and obtaining the encoding content corresponding to the barcode; specifically including:

[0009] S401, processing the barcode image to obtain a barcode feature array;

[0010] S402, calculating and obtaining a black and white bar width data set according to the barcode feature array;

[0011] S403, obtaining black and white bar module quantity data according to the black and white bar width data group;

[0012] S404, formulating a coding table according to bar code coding rules;

[0013] S405: Obtain the barcode encoding content according to the matching result between the encoding table and the black and white bar module quantity data.

[0014] Further, in the barcode recognition method disclosed in some embodiments, step S2 specifically includes:

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

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

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

[0018] S204, extracting the contour of the binary grayscale image;

[0019] S205, traversing the extracted contour and calculating the area of ​​the contour;

[0020] S206, if the area of ​​the contour is not greater than the preset threshold, it is ignored;

[0021] S207, if the area of ​​the contour is greater than the preset threshold, the contour is put into the valid contour list and the subsequent steps are continued;

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

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

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

[0025] S211, re-extracting the outline of the rotated barcode mask image and drawing a circumscribed rectangle;

[0026] S212, obtaining a coordinate frame corresponding to each barcode according to the circumscribed rectangle of each contour;

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

[0028] S214: Obtain the final barcode coordinate frame according to the newly determined left and right boundaries.

[0029] In the barcode recognition method disclosed in some embodiments, step S201 also includes a training step of an image segmentation neural network model, specifically including:

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

[0031] S2012, compiling a character dictionary according to the data content of the barcode, and generating a list of character strings of varying lengths within a preset range according to the character dictionary;

[0032] S2013, 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;

[0033] S2014. Set the white part of the barcode image to transparent;

[0034] S2015, randomly selecting an image from the background gallery as a background image;

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

[0036] S2017, generating a training image and a corresponding label mask image to obtain a barcode image segmentation data set;

[0037] S2018. Use the prepared barcode image segmentation dataset to train the image segmentation neural network model;

[0038] S2019. Training is completed and the barcode segmentation neural network model file is output.

[0039] In the barcode recognition method disclosed in some embodiments, step S213 specifically includes:

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

[0041] S2132, 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;

[0042] S2133, 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;

[0043] S2134, 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;

[0044] S2135, 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, return and determine that the position of the previous black bar is the leftmost boundary; otherwise, continue searching for black bars to the left;

[0045] S2136, searching for a black bar from the rightmost side of the coordinate frame to the right; if no black bar is found after exceeding the distance of five module widths, return and determine that the position of the previous black bar is the rightmost boundary; otherwise, continue searching for a black bar to the right;

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

[0047] In the barcode recognition method disclosed in some embodiments, step S401 specifically includes:

[0048] S4011, converting the received barcode image into a grayscale image;

[0049] S4012, calculating the pixel average value of the grayscale image, and calculating the image enhancement scale factor according to the pixel average value;

[0050] S4013, enhancing the image according to the image enhancement scale factor to increase the contrast of the grayscale image;

[0051] S4014, filtering the image to remove noise, and calculating the pixel average value of the enhanced image;

[0052] S4015, the image is enhanced again, with the new pixel average value as the boundary, the values ​​below one third of the new pixel average value are set to 0, the area from the new pixel average value to 255 is divided into three equal parts, and the part close to 255 is set to 255;

[0053] S4016, traverse the enhanced image data line by line, add up all lines to the last line, and finally divide by the image height to obtain the barcode feature array.

[0054] In the barcode recognition method disclosed in some embodiments, step S402 specifically includes:

[0055] S4021, calculating the pixel average value of the barcode feature array;

[0056] S4022, traverse the barcode feature array, find the local extreme value, and determine the center point set of the black and white bars in combination with the pixel average value;

[0057] S4023, processing the barcode feature array according to the center point set of the black and white bars, setting the white point position to 255 and the black point position to 0;

[0058] S4024, creating a grayscale image of the same size as the original barcode, assigning each row to the barcode feature array, and obtaining a final grayscale image;

[0059] S4025, binarizing the final grayscale image to obtain a binarized image, and processing the binarized image to obtain a two-dimensional array, wherein all black points are set to 1, and the rest are set to 0;

[0060] S4026. Traverse the two-dimensional array row by row to obtain a black and white bar width data array.

[0061] In the barcode recognition method disclosed in some embodiments, step S403 specifically includes:

[0062] S4031, selecting the black and white bar width data with the largest number of occurrences from the black and white bar width data group, and obtaining a selected black and white bar width two-dimensional array;

[0063] S4032, calculating the one-dimensional array of black and white bar width data according to the selected two-dimensional array of black and white bar widths;

[0064] S4033, calculating the module width according to the one-dimensional array of black and white bar width data and in combination with the bar code encoding rules;

[0065] S4034. Correct the one-dimensional array data of the black and white bar width data according to the module width, and calculate and generate black and white bar module quantity data.

[0066] In the barcode recognition method disclosed in some embodiments, step S405 specifically includes:

[0067] S4051, traverse the array of black and white bar module quantity data, and query and match the black and white bar module quantity combination corresponding to each character in the coding table;

[0068] S4052, if the match is successful, compose a character string based on the matched characters;

[0069] S4053, combining the barcode encoding rules, performing data verification on the matched barcode content;

[0070] S4054. If the verification fails, an empty string is returned;

[0071] S4055. If the verification is passed, the barcode recognition is completed and the coded content data is obtained;

[0072] S4056. If the match is unsuccessful, traverse the encoding table, calculate the similarity one by one, find the character corresponding to the most similar combination of the number of black and white bar modules, and then execute steps S4053 to S4055.

[0073] On the other hand, some embodiments disclose a barcode recognition terminal for executing a barcode recognition method.

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

[0075] The barcode recognition method disclosed in the embodiment of the present invention accurately locates the barcode in the barcode image detection stage, and then uses enhancement, superposition and correction methods to remove noise in the barcode recognition stage, thereby reducing the influence of bad data in the barcode and improving the overall barcode recognition accuracy, especially improving the accuracy of low-quality image barcode recognition. It can also accurately recognize multiple densely arranged barcodes at one time, thereby improving production efficiency and having good application prospects in the barcode field. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] Figure 1 Flowchart of a barcode recognition method disclosed in some embodiments;

[0077] Figure 2 Some embodiments disclose a flow chart of detecting image data to obtain barcode coordinates;

[0078] Figure 3 A flowchart of a neural network model training for image segmentation disclosed in some embodiments;

[0079] Figure 4 Some embodiments disclose a flow chart for re-determining the left and right boundaries of a barcode according to a coordinate frame corresponding to the barcode;

[0080] Figure 5 A flowchart of processing a barcode image to obtain a barcode feature array disclosed in some embodiments;

[0081] Figure 6 Some embodiments disclose a flow chart for calculating a black and white bar width data set based on a barcode feature array;

[0082] Figure 7 Some embodiments disclose a flow chart for obtaining black and white bar module quantity data based on a black and white bar width data group;

[0083] Figure 8 Some embodiments disclose a flowchart for obtaining barcode encoding content based on the matching results of the encoding table and the black and white bar module quantity data. DETAILED DESCRIPTION

[0084] The word "embodiment" used herein as an "exemplary" does not necessarily mean that any embodiment described is superior or better than other embodiments. Performance index tests in the embodiments of the present invention are performed using conventional test methods in the art unless otherwise specified. It should be understood that the terms described in the embodiments of the present invention are only used to describe specific implementation methods and are not intended to limit the contents disclosed in the embodiments of the present invention.

[0085] Unless otherwise specified, the technical and scientific terms used herein have the same meanings as commonly understood by ordinary technicians in the technical field to which the embodiments of the present invention belong; other experimental methods and technical means not specifically specified in the embodiments of the present invention refer to experimental methods and technical means commonly used by ordinary technicians in the field.

[0086] The terms "substantially" and "approximately" used herein are used to describe small fluctuations. For example, they can refer to less than or equal to ±5%, such as less than or equal to ±2%, such as less than or equal to ±1%, such as less than or equal to ±0.5%, such as less than or equal to ±0.2%, such as less than or equal to ±0.1%, such as less than or equal to ±0.05%. The numerical data represented or presented in the range format herein are used only for convenience and brevity, and therefore should be flexibly interpreted as not only including the values ​​clearly listed as the limits of the range, but also including all independent values ​​or sub-ranges contained in the range. For example, the numerical range of "1-5%" should be interpreted as including not only the clearly listed values ​​of 1% to 5%, but also the independent values ​​and sub-ranges within the range shown. Therefore, independent values ​​such as 2%, 3.5% and 4% and sub-ranges such as 1%-3%, 2%-4% and 3%-5% are included in this numerical range. This principle also applies to the range of only one numerical value. In addition, such an explanation applies regardless of the width of the range or the characteristics.

[0087] In this document, including in the claims, transitional words such as "comprises," "includes," "with," "having," "containing," "involving," "accommodating," etc. are understood to be open-ended, i.e., meaning "including but not limited to." Only the transitional words "consisting of" and "composed of" are closed transitional words.

[0088] In order to better illustrate the present invention, numerous specific details are provided in the specific examples below. It should be understood by those skilled in the art that the present invention can be implemented without certain specific details. In the embodiments, some methods, means, instruments, equipment, etc. well known to those skilled in the art are not described in detail in order to highlight the gist of the present invention.

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

[0090] In some embodiments, Figure 1 As shown, the barcode recognition method includes the steps of:

[0091] S1, reading image data containing a barcode;

[0092] S2, detect image data and obtain barcode coordinate frame;

[0093] S3, using the barcode coordinate frame to cut out the image of the effective area of ​​the barcode, and obtain the image data and coordinate information corresponding to the barcode;

[0094] S4, identifying the image data information of the barcode, and obtaining the encoding content corresponding to the barcode; specifically including:

[0095] S401, processing the barcode image to obtain a barcode feature array;

[0096] S402, calculating and obtaining a black and white bar width data set according to the barcode feature array;

[0097] S403, obtaining black and white bar module quantity data according to the black and white bar width data group;

[0098] S404, formulating a coding table according to bar code coding rules;

[0099] S405: Obtain the barcode encoding content according to the matching result between the encoding table and the black and white bar module quantity data.

[0100] The barcode recognition method disclosed in the embodiment of the present invention reads an image containing a barcode, detects the barcode in the image using a barcode detector, extracts a valid area, further performs image prediction in the valid area, obtains the approximate position of the barcode, further processes the approximate area containing the barcode, obtains an accurate valid area coordinate frame containing the barcode, obtains valid barcode data, further processes and analyzes the valid barcode data using a barcode identifier, obtains the number of black and white bar modules through a barcode feature array, and finally obtains the encoded content of the barcode based on the matching result of the black and white bar module number data with a coding table; usually, after using the barcode recognition method to process a fuzzy barcode, a barcode with a clear display and accurate black and white bars can be obtained.

[0101] In the barcode recognition method disclosed in some embodiments, in step S2, the image data is detected to obtain a barcode coordinate frame, such as Figure 2 As shown, the specific methods include:

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

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

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

[0105] S204, 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 some scattered points, and contour extraction is then performed on the binary image after erosion and closure;

[0106] S205, traversing the extracted contour and calculating the area of ​​the contour;

[0107] S206. If the area of ​​the contour is not greater than the preset threshold, it is ignored. Taking Code128 barcode as an example, a complete barcode usually contains at least 4 characters, namely, a start character, a data character, a check character and an end character, and the 4 characters have a total of 46 modules. If the minimum width of the module 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 of the area is determined to be 46×30=1380.

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

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

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

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

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

[0113] S212, obtaining a coordinate frame corresponding to each barcode according to the circumscribed rectangle of each contour;

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

[0115] S214: Obtain the final barcode coordinate frame according to the newly determined left and right boundaries.

[0116] In the barcode recognition method disclosed in some embodiments, in step S201, the image data is sent to 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:

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

[0118] S2012, compiling a character dictionary according to the data content of the barcode, and generating a list of character strings of varying lengths within a preset range according to the character dictionary;

[0119] S2013, 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;

[0120] S2014. Set the white part of the barcode image to transparent;

[0121] S2015, randomly selecting an image from the background gallery as a background image;

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

[0123] S2017, generating a training image and a corresponding label mask image to obtain a barcode image segmentation data set;

[0124] S2018. Use the prepared barcode image segmentation dataset to train the image segmentation neural network model;

[0125] 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 out 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, including model prediction accuracy, model inference speed and model size, comprehensively consider the space occupied by memory, video memory and hard disk; generally, you can consider choosing a model with faster inference speed and smaller resource occupation as much as possible under the premise of meeting the prediction accuracy requirements;

[0126] S2019. Training is completed and the barcode segmentation neural network model file is output.

[0127] In the barcode recognition method disclosed in some embodiments, step S213 re-determines 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:

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

[0129] S2132, 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;

[0130] S2133, traverse the two-dimensional array row by row, and 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 them in a list; usually, the list can also be processed to remove abnormal data according to the standard deviation; usually, the 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 judged in combination with the task requirements. Taking the Code128 barcode as an example, a complete barcode contains at least 4 characters, namely the start character, data character, check character, and end character. If the data character is at least 1 in the specific task, M can be set to 4;

[0131] S2134, calculate the average value of the data in the list, and then divide it by the number of modules represented by M characters to obtain module width data; usually the module width data is recorded as module-width;

[0132] S2135, 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 to search for black bars to the left; usually, the distance of five module widths is recorded as 5×module-width;

[0133] S2136, searching for a black bar from the rightmost side of the coordinate frame to the right; if no black bar is 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 a black bar to the right;

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

[0135] In the barcode recognition method disclosed in some embodiments, in step S401, the barcode image is processed to obtain a barcode feature array, such as Figure 5As shown, the specific methods include:

[0136] S4011, converting the received barcode image into a grayscale image;

[0137] S4012, calculate the pixel average value P of the grayscale image av1 , according to the pixel average value P av1 Calculate the image enhancement scale factor α;

[0138] S4013, enhancing the image according to the value of the image enhancement scale factor α to increase the contrast of the grayscale image;

[0139] S4014, filter the image to remove noise, and calculate the pixel average value P of the enhanced image av2 ;

[0140] S4015, re-enhance the image with a new pixel average value P av2 As the boundary, values ​​below one third of it are set to 0, and the average value of the new pixel P av2 The area from the average pixel value to 255 is divided into three equal parts, and the part close to 255 is set to 255; usually, the area from the average pixel value to 255 is divided into three equal parts, among which the part closest to 255 is set to 255;

[0141] S4016, traverse the enhanced image data row by row, add all rows to the last row, and finally divide by the image height to obtain a barcode feature array; the barcode feature array can be represented as code-feature-row.

[0142] In the barcode recognition method disclosed in some embodiments, in step S402, a black and white bar width data set is calculated based on the barcode feature array, such as Figure 6 As shown, the specific methods include:

[0143] S4021, calculating the pixel average value of the barcode feature array, recorded as feature-mean;

[0144] S4022, traverse the barcode feature array, find the local extreme value, and determine the center point set of the black and white bars in combination with the pixel average feature-mean, recorded as wp-list, bp-list;

[0145] S4023, processing the barcode feature array code-feature-row according to the center point set of the black and white bars, setting the white point position to 255 and the black point position to 0;

[0146] S4024, create a grayscale image of the same size as the original barcode, assign each row to the barcode feature array code-feature-row, and obtain the final grayscale image gray-final-image;

[0147] S4025, binarizing the final grayscale image to obtain a binary image, processing the binary image to obtain a two-dimensional array, wherein all black points are set to 1, and the rest are set to 0; usually, the final grayscale image gray-final-image can be binarized using the Otsu image threshold segmentation method, wherein all black points are set to 1, and the rest are set to 0, to obtain a two-dimensional data group code-binary-array;

[0148] S4026. Traverse the two-dimensional array row by row to obtain a black and white bar width data array, recorded as bw-array.

[0149] In the barcode recognition method disclosed in some embodiments, in step S403, the black and white bar module quantity data is obtained according to the black and white bar width data group, such as Figure 7 As shown, the specific methods include:

[0150] S4031, selecting the black and white bar width data with the largest number of occurrences from the black and white bar width data group to obtain a selected black and white bar width two-dimensional array; usually, the black and white bar width data array bw-array may be processed first to remove abnormal data, and after removing the abnormal data, the black and white bar width data with the largest number of occurrences is selected from the black and white bar width data array bw-array, and recorded as the selected black and white bar width two-dimensional array bw-selected;

[0151] S4032, calculating a one-dimensional array of black and white bar width data according to the selected black and white bar width two-dimensional array bw-selected, recorded as bw-list;

[0152] S4033, calculating the module width model-width according to the one-dimensional array bw-list of black and white bar width data and the bar code encoding rules;

[0153] S4034. The one-dimensional array bw-list of black and white bar width data is modified according to the module width model-width. After the modification is completed, the black and white bar module quantity data bar-code-data is generated by combining model-width calculation.

[0154] In the barcode recognition method disclosed in some embodiments, in step S404, a coding table barcode-charset is formulated according to the barcode coding rules; in step S405, the barcode coding content is obtained according to the matching result of the coding table barcode-charset and the black and white bar module quantity data bar-code-data, such as Figure 8 As shown, the specific methods include:

[0155] S4051, traverse the array of black and white bar module quantity data bar-code-data, and query and match the black and white bar module quantity combination corresponding to each character in the encoding table barcode-charset;

[0156] S4052, if the match is successful, compose a character string based on the matched characters;

[0157] S4053, combining the barcode encoding rules, performing data verification on the matched barcode content;

[0158] S4054. If the verification fails, an empty string is returned;

[0159] S4055. If the verification is passed, the barcode recognition is completed and the coded content data is obtained;

[0160] S4056. If the match is unsuccessful, traverse the encoding table, calculate the similarity one by one, find the character corresponding to the most similar combination of the number of black and white bar modules, and then execute steps S4053 to S4055.

[0161] In some embodiments, in step S405, the barcode black and white bar width data is first corrected. For example, for black and white bars that are shorter than the module width, a certain width is borrowed from the left and right sides to make up for the width, and then character parsing is performed based on the corrected data.

[0162] Some embodiments disclose a barcode recognition terminal for executing a barcode recognition method. Generally, the barcode recognition terminal is configured with a computer-readable storage medium, the computer-readable storage medium stores computer code, and the barcode recognition terminal also includes an information processor. When the information processor processes the computer program code, the barcode recognition method is executed to scan and recognize the barcode.

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

[0164] The barcode recognition method disclosed in the embodiment of the present invention accurately locates the barcode in the barcode image detection stage, and then uses enhancement, superposition and correction methods to remove noise in the barcode recognition stage, thereby reducing the influence of bad data in the barcode and improving the accuracy of barcode recognition as a whole, especially improving the accuracy of barcode recognition of low-quality images, and can accurately recognize multiple densely arranged barcodes at one time, thereby improving production efficiency and having good application prospects in the barcode field.

[0165] The technical solutions disclosed in the embodiments of the present invention and the technical details disclosed in the embodiments 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 protection scope of the claims of the present invention.

Claims

1. Barcode recognition method, It is characterized in that Includes steps: S1, reading image data containing a barcode; S2, detect image data and obtain barcode coordinate frame; S3, using the barcode coordinate frame to cut out the image of the effective area of ​​the barcode, and obtain the image data and coordinate information corresponding to the barcode; S4, identifying the image data information of the barcode, and obtaining the encoding content corresponding to the barcode; Specifically include: S401, processing the barcode image to obtain a barcode feature array; specifically including: S4011, converting the received barcode image into a grayscale image; S4012, calculating the pixel average value of the grayscale image, and calculating the image enhancement scale factor according to the pixel average value; S4013, enhancing the image according to the image enhancement scale factor to increase the contrast of the grayscale image; S4014, filtering the image to remove noise, and calculating the pixel average value of the enhanced image; S4015, the image is enhanced again, with the new pixel average value as the boundary, and values ​​lower than one third of the new pixel average value are set to 0; the area from the new pixel average value to 255 is divided into three equal parts, and the part close to 255 is set to 255; S4016, traverse the enhanced image data line by line, accumulate all lines to the last line, and finally divide by the image height to obtain a barcode feature array; S402, calculating and obtaining a black and white bar width data set according to the barcode feature array; specifically including: S4021, calculating the pixel average value of the barcode feature array; S4022, traverse the barcode feature array, find the local extreme value, and determine the center point set of the black and white bars in combination with the pixel average value; S4023, processing the barcode feature array according to the center point set of the black and white bars, setting the white point position to 255 and the black point position to 0; S4024, creating a grayscale image of the same size as the original barcode, assigning each row to the barcode feature array, and obtaining a final grayscale image; S4025, binarizing the final grayscale image to obtain a binarized image, and processing the binarized image to obtain a two-dimensional array, wherein all black points are set to 1, and the rest are set to 0; S4026, traverse the two-dimensional array row by row to obtain a black and white bar width data array; S403, obtaining black and white bar module quantity data according to the black and white bar width data group; specifically including: S4031, selecting the black and white bar width data with the largest number of occurrences from the black and white bar width data group, and obtaining a selected black and white bar width two-dimensional array; S4032, calculating the one-dimensional array of black and white bar width data according to the selected two-dimensional array of black and white bar widths; S4033, calculating the module width according to the one-dimensional array of black and white bar width data and in combination with the bar code encoding rules; S4034, modifying the one-dimensional array data of the black and white bar width data according to the module width, and calculating and generating black and white bar module quantity data; S404, formulating a coding table according to bar code coding rules; S405: Obtain the barcode encoding content according to the matching result between the encoding table and the black and white bar module quantity data.

2. The barcode recognition method according to claim 1, It is characterized in that Step S2 specifically includes: S201, sending the image data to the barcode segmentation model for prediction to obtain model output data; S202, parsing the model output data, and obtaining the barcode mask image predicted by the model; S203 converts the barcode mask image into a binary grayscale image, in which the background is black and the barcode valid area is pure white; S204, extracting the contour of the binary grayscale image; S205, traversing the extracted contour and calculating the area of ​​the contour; S206, if the area of ​​the contour is not greater than the preset threshold, it is ignored; S207, if the area of ​​the contour is greater than the preset threshold, the contour is put into the valid contour list and the subsequent steps are continued; S208, traverse the valid contour list, draw an outer approximate polygon for each valid contour, and generate a new barcode mask image; S209, detecting all straight lines of the new barcode mask image, selecting the longest straight line and calculating its inclination; S210, performing rotation correction on the new barcode mask image according to the inclination angle so that the barcode remains horizontal; S211, re-extracting the outline of the rotated barcode mask image and drawing a circumscribed rectangle; S212, obtaining a coordinate frame corresponding to each barcode according to the circumscribed rectangle of each contour; S213, re-determining the left and right boundaries of the barcode according to the coordinate frame corresponding to the barcode; S214: Obtain the final barcode coordinate frame according to the newly determined left and right boundaries.

3. The barcode recognition method according to claim 2, It is characterized in that The step S201 also includes a training step of the image segmentation neural network model, specifically including: S2011 uses a camera to collect N images of the production line environment and stores them in the background library; S2012, compiling a character dictionary according to the data content of the barcode, and generating a list of character strings of varying lengths within a preset range according to the character dictionary; S2013, 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; S2014. Set the white part of the barcode image to transparent; S2015, randomly selecting an image from the background gallery as a background image; S2016, randomly placing multiple barcode transparent images at a certain position of the background image; S2017, generating a training image and a corresponding label mask image to obtain a barcode image segmentation data set; S2018. Use the prepared barcode image segmentation dataset to train the image segmentation neural network model; S2019. Training is completed and the barcode segmentation neural network model file is output.

4. The barcode recognition method according to claim 2, It is characterized in that Step S213 specifically includes: S2131, cutting out an image of a corresponding area on the original image according to the coordinate frame of the barcode; S2132, 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; S2133, 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; S2134, 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; S2135, 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, return and determine that the position of the previous black bar is the leftmost boundary; otherwise, continue searching for black bars to the left; S2136, searching for a black bar from the rightmost side of the coordinate frame to the right; if no black bar is found after exceeding the distance of five module widths, return and determine that the position of the previous black bar is the rightmost boundary; otherwise, continue searching for a black bar to the right; S2137. Use the obtained leftmost boundary and rightmost boundary as boundary data of the newly determined coordinate frame.

5. The barcode recognition method according to claim 1, It is characterized in that Step S405 specifically includes: S4051, traverse the black and white bar module quantity data array, and query and match the black and white bar module quantity combination corresponding to each character in the coding table; S4052, if the match is successful, compose a character string based on the matched characters; S4053, combining the barcode encoding rules, performing data verification on the matched barcode content; S4054. If the verification fails, an empty string is returned; S4055. If the verification is passed, the barcode recognition is completed and the coded content data is obtained; S4056. If the match is unsuccessful, traverse the encoding table, calculate the similarity one by one, and find the character corresponding to the most similar combination of the number of black and white bar modules; then, execute steps S4053 to S4055.

6. Barcode recognition terminal, It is characterized in that Used to execute the barcode recognition method described in any one of claims 1 to 5.

7. Barcode recognition system, It is characterized in that Includes the barcode recognition terminal described in claim 6.