End-to-end Code128 bar code identification method, terminal and system
By constructing a neural network model including visual and sequence feature extraction modules, features are directly extracted from the original image and the recognition results are output, which solves the problem of poor barcode recognition accuracy and stability in the existing technology and achieves efficient and accurate Code128 barcodes. Identify.
Patent Information
- Application Number
- CN202411067534.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-09-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing barcode recognition technology has poor recognition accuracy and stability when faced with factors such as noise, reflection, blur, and distortion. It is especially inefficient when recognizing multiple densely arranged barcodes, and the algorithm based on image recognition is costly and difficult to identify. rate is low.
Using the end-to-end Code128 barcode recognition method, by building a neural network model including a visual feature extraction module, a sequence feature extraction module and a prediction module, features are directly extracted from the original image and the recognition results are output, simplifying the data processing process and improving recognition accuracy. and robustness.
It achieves high-accuracy recognition of Code128 barcodes in complex environments, reduces algorithm complexity, improves recognition efficiency and stability, and reduces recognition costs.
Smart Images

Figure CN118586418A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image information processing, and in particular relates to an end-to-end Code 128 barcode recognition method, terminal and system. Background Art
[0002] Since the birth of barcode technology in the mid-20th century, it has been widely used in many fields such as commodity circulation, logistics management, and identity recognition. As a way of encoding information, barcodes represent different data information through specific bar and space combinations, 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. Code128 was launched in 1981. It is a variable-length, continuous alphanumeric barcode with three different encoding types: A, B, and C, which can provide encoding of 128 characters in standard ASCII.
[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 types: photoelectric scanning and image recognition.
[0004] Barcode scanners use photoelectric scanning technology, which uses the difference in light reflection between the 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, one of the limitations of photoelectric scanning technology is that it must be scanned at the barcode area. When there are multiple densely arranged barcodes to be identified on a label sticker, it is necessary to manually hold the scanner and identify them one by one, which is not efficient overall.
[0005] Barcode recognition based on image recognition technology uses a camera to take a photo of the area where the barcode to be recognized is located, then detects the barcode in it, and finally parses the detected barcode; it can recognize multiple barcodes at a time, eliminating the step of manually scanning one by one with a handheld scanner. However, since image acquisition depends not only on the calibration of the camera equipment, but also on the on-site environment, there are many limiting factors, and the cost of obtaining high-quality images is high. Therefore, it is a very big challenge for image-based barcode recognition algorithms. The publicly available algorithms on the market currently still have shortcomings such as low recognition rate and poor stability.
[0006] Due to environmental or image acquisition equipment reasons, when there are unfavorable factors such as noise, reflection, blur, distortion, etc. in the barcode image to be recognized, traditional barcode recognition solutions are prone to errors, which seriously affects the final recognition accuracy. Summary of the invention
[0007] In view of this, on the one hand, some embodiments disclose an end-to-end Code 128 barcode recognition method, comprising the steps of: S1, read the image data containing the Code 128 barcode, and detect and obtain the barcode image corresponding to the Code 128 barcode; S2, preprocessing the barcode image to obtain a Code 128 barcode image to be identified that meets the set requirements; S3, loading a barcode recognition neural network model; the barcode recognition neural network model includes a visual feature extraction module, a sequence feature extraction module and a prediction module; S4, sending the Code128 barcode image to be recognized into the barcode recognition neural network model, executing model reasoning, obtaining model output data, and obtaining a character sequence number list predicted by the model; S5, according to the label character dictionary, combined with Code128 encoding rules, obtain the parsed string; S6. Verify the parsed character string, and the parsed character string that passes the verification is the barcode recognition result.
[0008] On the other hand, some embodiments disclose a barcode recognition terminal for performing an end-to-end Code 128 barcode recognition method.
[0009] In yet another aspect, some embodiments disclose a barcode recognition system, including a barcode recognition terminal.
[0010] The end-to-end Code 128 barcode recognition method disclosed in the embodiment of the present invention, the end-to-end Code 128 barcode, constructs a Code 128 barcode recognition neural network model, and uses the prepared training data set for training, realizing automatic learning from raw data input to output of training results, greatly simplifying the data processing flow and improving the accuracy of recognition. The end-to-end barcode recognition technology provided by the embodiment of the present invention directly uses the original image as input, and finally directly outputs the recognition result through the deep learning neural network model. Compared with the traditional recognition method, it greatly reduces the complexity of the algorithm and improves the robustness and accuracy of recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 Flowchart of an end-to-end Code 128 barcode recognition method disclosed in some embodiments; Figure 2 A flow chart of a method for detecting image data to obtain a valid area coordinate frame containing a barcode disclosed in some embodiments; Figure 3 A flowchart of a neural network model training for image segmentation disclosed in some embodiments; Figure 4Some 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; Figure 5 Step S3 of some embodiments disclosed a flow chart of a method for preparing a training data set; Figure 6 Step S3 of some embodiments disclosed is a flow chart of a method for constructing a barcode recognition neural network model; Figure 7 A flowchart of a method for obtaining a character sequence number list predicted by a model in step S4 disclosed in some embodiments; Figure 8 Some embodiments disclose a flow chart of a method for calculating a check value of a parsed character string in step S6. DETAILED DESCRIPTION
[0012] 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.
[0013] 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.
[0014] 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.
[0015] 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.
[0016] 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.
[0017] In some embodiments, Figure 1 As shown, the end-to-end Code 128 barcode recognition method includes the following steps: S1, read the image data containing the Code 128 barcode, and detect and obtain the barcode image corresponding to the Code 128 barcode; S2, preprocessing the barcode image to obtain a Code 128 barcode image to be identified that meets the set requirements; S3, loading a barcode recognition neural network model; the barcode recognition neural network model includes a visual feature extraction module, a sequence feature extraction module and a prediction module; S4, sending the Code128 barcode image to be recognized into the barcode recognition neural network model, executing model reasoning, obtaining model output data, and obtaining a character sequence number list predicted by the model; S5, according to the label character dictionary, combined with Code128 encoding rules, obtain the parsed string; S6. Verify the parsed string. The parsed string that passes the verification is the barcode recognition result. Usually, the last character output by the model is the end character, the second last character is the check character, and the label character dictionary number value of the check character is the "symbol character value" of the check character, that is, the check code.
[0018] In some embodiments, the end-to-end Code 128 barcode recognition method disclosed in step S1 includes: The image data containing the barcode is read, the image data is detected to obtain a barcode coordinate frame, and the image of the effective area of the barcode is cut out using the barcode coordinate frame to obtain a barcode image corresponding to the barcode.
[0019] Some embodiments disclose an end-to-end Code 128 barcode recognition method, which 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 coordinate frame of the valid area containing the barcode, obtains valid barcode data, further processes and parses the valid barcode data using a barcode recognizer, and finally obtains the encoded content of the barcode.
[0020] Some embodiments disclose an end-to-end Code 128 barcode recognition method, such as Figure 2 As shown, in step S1, the method of detecting image data to obtain a valid area coordinate frame containing a barcode 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, 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 eroded and closed binary 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. For Code 128 barcodes, a complete barcode usually contains at least 4 characters, namely, a start character, a data character, a check character, and an end character. 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. 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.
[0021] In some embodiments of the disclosed end-to-end Code 128 barcode recognition method, in step S101, image data is fed into a 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: S1011 uses the camera to collect N images of the production line environment and stores them in the background library; S1012, 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; 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; S1014, setting the white part of the barcode image to be transparent; S1015, randomly selecting an image from the background image library as a background image; S1016, randomly placing multiple barcode transparent images at a certain position of the background image; S1017, generating a training image and a corresponding label mask image to obtain a barcode image segmentation data set; S1018, using the prepared barcode image segmentation data set to train an image segmentation neural network model; 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; S1019, training is completed, and the barcode segmentation neural network model file is output.
[0022] In some embodiments of the disclosed end-to-end Code 128 barcode recognition method, step S113 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: 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, 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. For the Code128 barcode, 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; S1134, 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; 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 to search for black bars to the left; usually, the distance of five module widths is recorded as 5×module-width; 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.
[0023] In some embodiments of the disclosed end-to-end Code 128 barcode recognition method, step S3 includes a method for training a barcode recognition neural network model, specifically including a method for preparing a training data set, such as Figure 5 As shown, specifically including: S311, preparing a data character dictionary for generating valid data content of a barcode; Usually, Code128 barcode can encode 128 different characters, including ASCII character set; visible characters are only uppercase letters, lowercase letters, numbers, punctuation marks and special symbols, a total of 95 characters; the data character dictionary to be created is used to generate the valid data content of the barcode, so it only contains visible characters; the data character dictionary can be a character list, which contains the visible characters that can be encoded by Code128 barcode; In some embodiments, for character types with a higher probability of occurrence, their weights are appropriately increased in the data character dictionary; usually, in actual production activities, the probability of occurrence of different character types is different. For example, the number of occurrences of special characters is much less than that of numbers and letters. Therefore, for character types with a higher probability of occurrence, such as numbers and uppercase letters, their weights can be appropriately increased in the data character dictionary; usually the increased weight is reflected in the increase in the number of the character.
[0024] S312, generating a string list according to the generated data character dictionary; usually, after the data character dictionary is prepared, a string list can be further generated based on it; the strings in the string list will be used as encoding content to generate a barcode image in a subsequent process; In some embodiments, the method of generating a string list according to the generated data character dictionary includes: First, set the maximum length of the string to MAX_LEN according to actual production requirements; Then, characters are randomly selected from the data character dictionary and combined into strings of different lengths from 1 to MAX_LEN. N strings of each length are generated, and the character combinations are all randomly selected. Finally, the strings generated by different character combinations are stored in a string list.
[0025] S313, generating a barcode image and its corresponding character code according to the string list; Usually, according to the generated string list, the list is traversed, and each string in the list is used as the encoding content to generate a Code128 barcode image; usually, the generation of Code128 barcode images can be achieved with the help of existing tools, such as the open source Python library barcode; with the help of the tool, the string to be encoded is input to obtain the corresponding Code128 barcode image and its character encoding.
[0026] S314, obtaining a training image based on the generated barcode image, generating a label string based on the character encoding, and storing the training image and the corresponding label character into a label file as a training data set; Usually, in order to train a deep learning neural network model that can recognize Code128 barcodes, a training data set needs to be created. First, prepare a batch of background images and store them in the background image library. The background images can be collected in the actual production environment to make them closer to reality; then, set the generated Code barcode image to a transparent background, randomly paste it on the background image, and then cut it out to get the training image; then, generate a label string based on the character encoding corresponding to the barcode image; finally, write the storage path of the barcode image and its corresponding label string into the label file as the training data set.
[0027] In some embodiments, in order to obtain diverse training data, multiple different barcode images may be generated for the same string. For example, the multiple barcode images may be barcode images of different sizes, different module widths, and different image enhancement methods; the image enhancement methods include adding noise, changing brightness, adding snowflakes or blur effects, etc.
[0028] In some embodiments, the method of generating a label string according to the character code corresponding to the barcode image includes: Create a label character dictionary; Code128 has a total of 107 different bar and space combinations, that is, there are 107 different character codes, so the label character dictionary should also have 107 different characters to represent different character codes; in the label character dictionary, set the space to 0, set the space to Γ, set the characters with code numbers 95 to 106 to Σ, Ω, ψ, φ, π, ξ, ζ, δ, ε, β, λ, θ respectively; set the characters with code numbers 1 to 94 to the characters corresponding to the Code128B character set, including punctuation marks, numbers, uppercase letters, lowercase letters, and special characters; According to the character encoding corresponding to the barcode image and the prepared label character dictionary, the corresponding label string can be obtained.
[0029] In some embodiments of the disclosed end-to-end Code 128 barcode recognition method, step S3 includes a barcode recognition neural network model training method, specifically including a barcode recognition neural network model construction method, such as Figure 6 As shown, specifically including: S321, selecting a convolutional neural network model as a visual feature extraction module; S322, selecting a recurrent neural network model to be connected to the convolutional neural network model as a sequence feature extraction module; S323, selecting a prediction module to be connected to the recurrent neural network model; S324. Use the loss function to complete the joint training of the convolutional neural network model and the recurrent neural network model.
[0030] Generally, the neural network model used to recognize Code 128 barcodes consists of three parts: visual feature extraction module, sequence feature extraction module and prediction module; among them: Visual feature extraction module, used to extract visual feature sequences from barcode images. Convolutional neural network (CNN) can be used to extract visual feature sequences from barcode images. Convolutional neural network models such as VGGNet, ResNet, MobileNet, DenseNet, etc. The sequence feature extraction module is connected to the visual feature extraction module to extract sequence features containing contextual information from visual features, and then predict the label distribution of each frame. A recurrent neural network (RNN) can be used to do this, and recurrent neural network models such as LSTM, Bi-LSTM, GRU, Transformer, etc. The prediction module is connected to the sequence feature extraction module. Through the fully connected network and softmax activation function, the prediction of each frame is converted into the final label sequence. Finally, the CTC (Connectionist Temporal Classification) loss function is used to complete the joint training of CNN and RNN without sequence alignment.
[0031] In some embodiments of the disclosed end-to-end Code 128 barcode recognition method, step S3 includes a method for training a barcode recognition neural network model, specifically including: using the prepared training data set, selecting a deep learning framework to train the constructed barcode recognition neural network model. Usually, after the neural network model is constructed according to the task requirements, a deep learning framework can be selected as appropriate, such as Pytorch, PaddlePaddle, TensorFlow, etc., to train the constructed barcode recognition neural network model.
[0032] Some embodiments disclose an end-to-end Code 128 barcode recognition method, such as Figure 7 As shown, in step S4, the method for obtaining the character sequence number list predicted by the model includes: S41, loading the barcode recognition neural network model related files, and sending the Code128 barcode image to be recognized into the barcode recognition neural network model; S42, executing barcode recognition neural network model operation; S43. Output the character serial number sequence predicted by the barcode recognition neural network model, wherein each numerical value corresponds to a serial number of a label character dictionary.
[0033] Usually, after the barcode recognition neural network model is trained, it can be deployed. First, load the model-related files, then feed the barcode image to be recognized into the model, and then, after calculation, the model outputs the prediction result; a label sequence is obtained from the prediction result output by the model, in which each value corresponds to the serial number of the label character dictionary. Therefore, the serial number list of the predicted label character dictionary can be obtained from the model output.
[0034] In some embodiments of the disclosed end-to-end Code 128 barcode recognition method, in step S5, the process of obtaining the parsed string includes: According to the label character dictionary sequence number list, combined with the label character dictionary, the corresponding label string is obtained; wherein, if the symbol starts with the start character START_A, the character set A is first determined; if the symbol starts with the start character START_B, the character set B is first determined; if the symbol starts with the start character START_C, the character set C is first determined; further, by using the switch character CODE A, B or C or the conversion character SHIFT, the character set is re-determined in the symbol; Combined with the encoding rules of Code128, the final parsed string is obtained.
[0035] Usually, the corresponding label string can be obtained according to the label character dictionary serial number list output by the model and combined with the label character dictionary. In the Code128 encoding rules, there are 3 independent data character sets: character set A, character set B and character set C. The selection of character set depends on the use of the start character START A, B or C, the switch character CODE A, B or C or the conversion character SHIFT. If the symbol starts with the start character START_A, the character set A is determined first; if the symbol starts with the start character START_B, the character set B is determined first; if the symbol starts with the start character START_C, the character set C is determined first; the character set can be re-determined in the symbol by using the switch character CODE A, B or C or the conversion character SHIFT.
[0036] Combined with the encoding rules of Code128, the final parsed string can be obtained. For example, the character Γ in the label string corresponds to the space character in Code128 character set A and character set B and the "00" string in character set C, and the character β corresponds to the start character START_B.
[0037] Some embodiments disclose an end-to-end Code 128 barcode recognition method, such as Figure 8 As shown, in step S6, the method for calculating the check value of the parsed string includes: S61. Generate a weight list according to the label character dictionary number list. The length of the weight list = the length of the label character dictionary number list output by the model – 2. The content of the weight list is: [1, 1, 2, 3, 4, 5, 6, …], the first item is fixed to 1, and the remaining items are incremented from 1. S62, generating a character value list according to the label character dictionary serial number list; that is, removing the last two data items of the label character dictionary serial number list to obtain the character value list; S63, multiplying the corresponding positions of the weight list and the character value list to obtain a multiplier list; S64, accumulating all items in the multiplier list to obtain a sum; S65, the accumulated sum is modulo 103 to obtain a remainder. Usually, the remainder is the check value of the "parsed string". If the value of the remainder is equal to the character value of the check character, the check passes, otherwise the check fails.
[0038] Some embodiments disclose a barcode recognition terminal for executing an end-to-end Code 128 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.
[0039] Some embodiments disclose a barcode recognition system, including a barcode recognition terminal.
[0040] The end-to-end Code 128 barcode recognition method disclosed in the embodiment of the present invention, the end-to-end Code 128 barcode, constructs a Code 128 barcode recognition neural network model, and uses the prepared training data set for training, realizing automatic learning from raw data input to output of training results, greatly simplifying the data processing flow and improving the accuracy of recognition. The end-to-end barcode recognition technology provided by the embodiment of the present invention directly uses the original image as input, and finally directly outputs the recognition result through the deep learning neural network model. Compared with the traditional recognition method, it greatly reduces the complexity of the algorithm and improves the robustness and accuracy of recognition.
[0041] 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. An end-to-end Code 128 barcode recognition method, characterized in that: Includes steps: S1, read the image data containing the Code 128 barcode, and detect and obtain the barcode image corresponding to the Code 128 barcode; S2, preprocessing the barcode image to obtain a Code 128 barcode image to be identified that meets the set requirements; S3, loading a barcode recognition neural network model; the barcode recognition neural network model includes a visual feature extraction module, a sequence feature extraction module and a prediction module; S4, sending the Code128 barcode image to be recognized into the barcode recognition neural network model, executing model reasoning, obtaining model output data, and obtaining a character sequence number list predicted by the model; S5, according to the label character dictionary, combined with Code128 encoding rules, obtain the parsed string; S6. Verify the parsed character string, and the parsed character string that passes the verification is the barcode recognition result.
2. The end-to-end Code 128 barcode recognition method according to claim 1, characterized in that: Step S1 includes: The image data containing the Code 128 barcode is read, the image data is detected to obtain a barcode coordinate frame, and the image of the effective area of the barcode is cropped using the barcode coordinate frame to obtain a barcode image corresponding to the Code 128 barcode.
3. The end-to-end Code 128 barcode recognition method according to claim 1, characterized in that: Step S3 includes a method for training the barcode recognition neural network model, specifically including a method for preparing a training data set, specifically including: S31, preparing a data character dictionary for generating valid data content of a barcode; S32, generating a string list according to the generated data character dictionary; S33, generating a barcode image and its corresponding character code according to the string list; S34, obtaining a training image based on the generated barcode image, generating a label string based on the character encoding, and storing the training image and the corresponding label character into a label file as a training data set.
4. The end-to-end Code 128 barcode recognition method according to claim 3, characterized in that: Step S3 includes a training method for a barcode recognition neural network model, specifically including a construction method for a barcode recognition neural network model, specifically including: The convolutional neural network model is selected as the visual feature extraction module; A recurrent neural network model is selected and connected to the convolutional neural network model as a sequence feature extraction module; Select the prediction module and connect it to the recurrent neural network model; Use the loss function to complete the joint training of the convolutional neural network model and the recurrent neural network model.
5. The end-to-end Code 128 barcode recognition method according to claim 4, characterized in that: Step S3 includes a method for training a barcode recognition neural network model, specifically including: Using the prepared training data set, a deep learning framework is selected to train the constructed barcode recognition neural network model.
6. The end-to-end Code 128 barcode recognition method according to claim 5, characterized in that: In step S4, the process of obtaining the character sequence number list predicted by the model includes: Load the model-related files and send the Code128 barcode image to be recognized into the model; Execute model operations; Output the sequence of character numbers predicted by the model, where each value corresponds to a sequence number in the label character dictionary.
7. The end-to-end Code 128 barcode recognition method according to claim 6, characterized in that: In step S5, the process of obtaining the parsed string includes: According to the label character dictionary sequence number list, combined with the label character dictionary, the corresponding label string is obtained; wherein, if the symbol starts with the start character START_A, the character set A is first determined; if the symbol starts with the start character START_B, the character set B is first determined; if the symbol starts with the start character START_C, the character set C is first determined; further, by using the switch character CODE A, B or C or the conversion character SHIFT, the character set is re-determined in the symbol; Combined with the encoding rules of Code128, the final parsed string is obtained.
8. The end-to-end Code 128 barcode recognition method according to claim 6, characterized in that: In step S6, the method for calculating the check value of the parsed string includes: Generate a weight list based on the label character dictionary number list. The length of the weight list = the length of the label character dictionary number list output by the model – 2. The content of the weight list is: [1, 1, 2, 3, 4, 5, 6, …], the first item is fixed to 1, and the remaining items increase in sequence starting from 1. Generate a character value list according to the tag character dictionary serial number list; that is, remove the last two data items in the tag character dictionary serial number list to obtain the character value list; Multiply the corresponding bits of the weight list and the character value list to obtain a multiplier list; Add up all the items in the multiplier list to get the sum; Take the remainder of the accumulated sum modulo 103; The remainder is the checksum of the "parsed string".
9. A barcode recognition terminal, characterized in that: Used to execute the end-to-end Code 128 barcode recognition method 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
Deep learning-based bar code identification method and book retrieval system
CN114417904A
Bar code identification method, terminal and system
CN118428382A
String Parsed Categoric Encodings for Machine Learning
US20210141801A1
Cited By
Book and archive management method, system, equipment and medium
CN119577221A
