A barcode recognition method and device based on deep learning

Through deep learning pre-trained code system classifiers and code readers, the code system type in the image is identified and the information is decoded, which solves the problems of low efficiency and complex process of bar code and QR code recognition in the existing technology, and achieves high efficiency and Anti-jamming multiple coding systems and multi-target recognition.

CN114021596BActive Publication Date: 2024-08-27XIAMEN HUALIAN ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111106727.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-22
Publication Date
2024-08-27
Estimated Expiration
2041-09-22

AI Technical Summary

Technical Problem

Existing barcode and QR code recognition methods have low efficiency, complex processes, and poor anti-interference capabilities.

Method used

The barcode recognition method based on deep learning is used to identify the code type in the image and decode the information through the pre-trained code classifier and code reader, simplifying the traditional recognition process and suitable for multiple code systems and multi-target recognition.

Benefits of technology

It improves the efficiency of barcode and QR code recognition, simplifies the recognition process, enhances anti-interference ability, and is suitable for multiple code systems and multi-target recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114021596B
    Figure CN114021596B
Patent Text Reader

Abstract

The present invention discloses a barcode recognition method and device based on deep learning, wherein the method comprises: obtaining a barcode or two-dimensional code image to be recognized; loading a code system classifier pre-trained by deep learning, and using the code system classifier to predict the code system type of the input image; judging whether the code system is valid according to whether the probability prediction value of the classification result of the code system classifier is greater than a threshold; when the code system is determined to be valid, loading a corresponding code recognizer pre-trained by deep learning according to the code system type, and the code recognizer maps the input image to recognize coded information; decoding the coded information obtained by the code recognizer mapping the input image to obtain the original information of the barcode or two-dimensional code. Through the present invention, most of the work of the traditional recognition process such as detection, correction, binarization, and grid division is realized in one-time processing, solving the problems of complex process and poor anti-interference ability of the existing barcode or two-dimensional code recognition method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of interactive control, and in particular to a barcode recognition method and device based on deep learning. Background Art

[0002] Barcode: It is a graphic identifier that expresses a set of information by arranging multiple black bars and spaces of different widths according to certain coding rules. Common barcodes are parallel lines composed of black bars (referred to as bars) and white bars (referred to as spaces) with very different reflectivity. Barcodes can mark the country of production, manufacturer, product name, production date, book classification number, mail start and end locations, categories, dates and many other information, so they are widely used in many fields such as commodity circulation, book management, postal management, banking system, etc.

[0003] QR code (2-Dimensional Bar Code): also known as a two-dimensional barcode, it mainly encodes information according to certain rules through certain specific geometric shapes. This encoding method can enable the two-dimensional code to store relatively rich data.

[0004] In the prior art, image acquisition equipment or photoelectric scanning equipment can be used to detect barcodes or QR codes, and further identify the information contained in the barcodes or QR codes. The QR code recognition process usually includes: detecting and cropping the QR code area, correcting the QR code, binarizing the QR code image, gridding to obtain binary encoding, and decoding. The recognition algorithm and process are relatively complex, and the recognition efficiency is low. Summary of the invention

[0005] The main technical problem solved by the present invention is to provide a barcode recognition method and device based on deep learning, which can improve the recognition efficiency.

[0006] To solve the above technical problems, a technical solution adopted by the present invention is: a barcode recognition method based on deep learning, comprising the following steps: obtaining a barcode or two-dimensional code image to be recognized; loading a code classifier pre-trained by deep learning, and using the code classifier to predict the code type of the input image; wherein the code type includes the code and version of the barcode and the two-dimensional code; judging whether the code is valid based on whether the probability prediction value of the classification result of the code classifier is greater than a threshold; when it is determined that the code is valid, loading a corresponding code recognizer pre-trained by deep learning according to the code type of the input image predicted by the code classifier, and having the code recognizer map the input image into encoding information; and decoding the encoding information obtained by the code recognizer mapping the input image to obtain the original information of the barcode or two-dimensional code.

[0007] Among them, pre-training the code classifier through deep learning specifically includes: obtaining barcode or two-dimensional code images of different code types to form a first data set; wherein each data at least contains {image saving path, code type, binary sequence encoding information}; using the first data set to perform deep learning model training to obtain the code classifier.

[0008] Among them, loading a code classifier pre-trained by deep learning, and using the code classifier to predict the code type of the input image, specifically includes: inputting the barcode or QR code image to be identified into the deep learning network; judging the code type corresponding to the maximum probability according to the output of the deep learning network.

[0009] The method of training the code recognizer by deep learning specifically includes: using formula (1) to calculate the code recognizer, and using formula (2) to calculate the loss function of the code recognizer; wherein x is the input image, belonging to the c-th type of code system, c ~ [1, M], M is a positive integer, y c G is the coding information mark. c For the code reader of type c, N c is the length of the binary sequence encoding information of the code system, G c is a code reader; c To predict the coding information, the length is also N c sequence; sigmoid is used to convert z c The value of the activation function is scaled to between 0 and 1, Loss c Code reader G for type c code system c loss;

[0010] z c =G c (x) (1)

[0011]

[0012] The code recognition device G is analyzed using formulas (1), (2) and the first data set. c Conduct deep learning training.

[0013] The method comprises: loading a corresponding code recognizer pre-trained by deep learning according to the code type of the input image predicted by the code classifier, and having the code recognizer map the input image into coding information, specifically comprising: selecting a corresponding code recognizer from a plurality of pre-trained code recognizers according to the code type of the input image predicted by the code classifier; mapping the input image to obtain predicted coding information by using formula (1); and binarizing the predicted coding information to obtain coding information of the input image.

[0014] Among them, when the barcode or two-dimensional code image to be identified is a plurality of targets, the method further comprises: loading a pre-trained deep learning multi-target detection model, and using the deep learning multi-target detection model to detect and identify the input image to obtain target features corresponding to each of the plurality of barcodes or two-dimensional codes; loading a code classifier pre-trained by deep learning, and using the code classifier to predict the code type of the input image, specifically: loading a code classifier pre-trained by deep learning, and using the code classifier to respectively predict the code types of the target features corresponding to each of the plurality of barcodes or two-dimensional codes; loading a corresponding code recognizer pre-trained by deep learning according to the code type of the input image predicted by the code classifier; , and the code recognizer maps the input image into coding information, specifically: according to the code type of the target features corresponding to the multiple barcodes or two-dimensional codes predicted by the code classifier, the corresponding code recognizers pre-trained by deep learning are loaded respectively, and the target features corresponding to the multiple barcodes or two-dimensional codes are mapped and recognized by the code recognizer as corresponding predicted coding information, and the predicted coding information is binarized; the coding information obtained by the code recognizer mapping the input image is decoded to obtain the original information of the barcode or two-dimensional code, specifically: the coding information obtained by the code recognizer recognizing the target features corresponding to the multiple barcodes or two-dimensional codes is decoded respectively to obtain the original information of the multiple barcodes or two-dimensional codes.

[0015] Pre-training the multi-target detection model through deep learning specifically includes: obtaining barcode or two-dimensional code images of different code types to form a second data set; wherein, the second data set additionally annotates the position and size information of each code in the image, and the annotation content at least includes: image saving path, position and size information, code type, and binary sequence encoding information; setting the target category of the multi-target detection model to 2; and minimizing the loss function of the multi-target detection model through the second data set and deep learning technology to train the multi-target detection model.

[0016] Another technical solution adopted by the present invention is to provide a barcode recognition device based on deep learning, including a storage unit, an image acquisition unit and a processing unit; the processing unit includes an image processing unit and a decoding unit; the image acquisition unit is used to acquire a barcode or two-dimensional code image to be recognized; the image processing unit includes: a code classification module, used to load a code classifier pre-trained by deep learning, and use the code classifier to predict the code type of the input image; a code recognition module, used to judge whether the code is valid according to whether the probability prediction value of the classification result of the code classifier is greater than a threshold, and when it is determined that the code is valid, load the corresponding code recognizer pre-trained by deep learning according to the code type of the input image predicted by the code classification module, and the code recognizer maps the input image into encoding information; the decoding unit is used to decode the encoding information obtained by the code recognizer mapping the input image to obtain the original information of the barcode or two-dimensional code.

[0017] The method further includes a model training unit, which is used to: obtain barcode or two-dimensional code images of different code types to form a first data set; wherein each piece of data at least contains information of {image saving path, code type, binary sequence encoding information}; use the first data set to perform deep learning model training to obtain the code classifier; use formula (1) to calculate the code reader, and use formula (2) to calculate the loss function of the code reader, and use formula (1), (2) and the first data set to train the code reader G c Conduct deep learning training;

[0018] z c =G c (x) (1)

[0019]

[0020] Where x is the input image, belonging to the cth type of code, c ~ [1, M], M is a positive integer, y c G is the coding information mark. c For the code reader of type c, N c The length of the binary sequence encoding information of the code system; c To predict the coding information, the length is also N c The sigmoid is used to convert z c The value of the activation function is scaled to between 0 and 1, Loss c Code reader G for type c code system c loss.

[0021] The code recognition module is further used to select a corresponding code recognizer according to the code type determined by the code classification module, calculate predicted coding information according to the code recognizer and formula (1), and perform binarization processing on the predicted coding information.

[0022] Wherein, the image processing unit further includes a multi-target detection module; when the barcode or two-dimensional code image to be identified is a plurality of targets, the multi-target detection module is used to load a pre-trained deep learning multi-target detection model, and use the deep learning multi-target detection model to detect and identify the input image to obtain target features corresponding to each of the plurality of barcodes or two-dimensional codes; the code classification module is used to load a code classifier pre-trained by deep learning, and use the code classifier to respectively predict the code types of the target features corresponding to each of the plurality of barcodes or two-dimensional codes; the code recognition module is used to load the corresponding code recognizer pre-trained by deep learning according to the code types of the target features corresponding to each of the plurality of barcodes or two-dimensional codes predicted by the code classifier, and the code recognizer maps and identifies the target features corresponding to each of the plurality of barcodes or two-dimensional codes into corresponding predicted coding information, and performs binarization processing on the predicted coding information; the decoding unit is used to respectively decode the coding information obtained by the code recognizer from identifying the target features corresponding to each of the plurality of barcodes or two-dimensional codes, so as to obtain the original information of the plurality of barcodes or two-dimensional codes.

[0023] It also includes a multi-target model training unit, which is used to obtain barcode or two-dimensional code images of different code types to form a second data set, set the target category of the multi-target detection model to 2, and minimize the loss function of the multi-target detection model through the second data set and deep learning technology to train the multi-target detection model; wherein, each code in the second data set is additionally annotated with its position and size information in the image, and the annotation content at least includes: image save path, position and size information, code type, and binary sequence encoding information.

[0024] The present invention provides a barcode recognition method and device based on deep learning. A code classifier and a code identifier are pre-trained through deep learning, so that the code classifier is loaded on the acquired barcode or two-dimensional code image to predict the code type, and the corresponding code identifier is loaded to recognize the encoded information, thereby realizing one-time processing of most of the work of traditional recognition processes such as detection, correction, binarization, and grid division, and solving the problems of complex process and poor anti-interference ability of existing barcode or two-dimensional code recognition methods; at the same time, the code category of the target barcode or two-dimensional code image is identified by using the pre-trained deep learning code classifier, and subsequent processing is performed according to different code categories, which can be applicable to multiple code systems; further, the target recognition of multiple barcodes or two-dimensional code images can be performed by loading a deep learning-based multi-target detection model, so as to be applicable to multi-target barcode recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a schematic diagram of the barcode information composition of the prior art;

[0026] Figure 2 It is a schematic diagram of the QR code information composition of the prior art;

[0027] Figure 3 It is a flowchart of a barcode recognition method based on deep learning in one embodiment of the present invention;

[0028] Figure 4 It is a list of EAN-13 codes in the prior art;

[0029] Figure 5 is a flow chart of a method for pre-training a symbology classifier through deep learning in an embodiment of the present invention;

[0030] Figure 6 yes Figure 3 A flowchart of "loading a symbology classifier pre-trained by deep learning, and using the symbology classifier to predict the symbology type of an input image" in the implementation of step S12;

[0031] Figure 7 It is a schematic diagram of the structure of a code system classifier and a code recognizer obtained by deep learning training using a VGG-16 network structure in an embodiment of the present invention;

[0032] Figure 8 is a flow chart of a method for pre-training a code recognizer through deep learning in an embodiment of the present invention;

[0033] Fig. 9 yes Figure 3A flowchart of "loading a corresponding code recognizer pre-trained by deep learning according to the code type of the input image predicted by the code classifier, and having the code recognizer map and identify the input image as coded information" in the implementation of step S14;

[0034] Fig.10 is a flowchart of a barcode recognition method based on deep learning in another embodiment of the present invention;

[0035] Fig.11 It is a schematic diagram of the structure of a code system classifier and a code recognizer using a multi-target detection model (Faster-RCNN or SSD) network structure in an embodiment of the present invention;

[0036] Fig.12 is a flowchart of a method for pre-training a multi-target detection model through deep learning in an embodiment of the present invention;

[0037] Fig.13 is a structural schematic diagram of a barcode recognition device based on deep learning in an embodiment of the present invention;

[0038] Fig.14 It is a structural schematic diagram of a barcode recognition device based on deep learning in another embodiment of the present invention. DETAILED DESCRIPTION

[0039] In order to explain the technical content, structural features, achieved objectives and effects of the present invention in detail, the present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0040] Please also see Figure 1 , 2 , which is a schematic diagram of the barcode information composition of the prior art and a schematic diagram of the QR code information composition of the prior art (cited from: Gong Yahuan, Wang Chao, Hu Chen, Design and Implementation of EAN-13 Code Image Recognition System, Modern Electronic Technology, 2009, 032(022):106-109; ISO / IEC 18004:2015, Section 6.3). The present invention divides the image information of all barcodes and two-dimensional codes into "positioning information" and "coding information".

[0041] Positioning information is used to determine the location of the barcode or QR code; for example, Figure 1 As shown in the figure, the start character, separator and terminator of the barcode; Figure 2 As shown, the position detection pattern, correction pattern and separator of the QR code;

[0042] The coded information, represented by a binary sequence (black squares or lines represent 1, white squares or lines represent 0), includes: all the information needed for decoding; for example, Figure 1As shown, the data symbol and check symbol of the bar code; Figure 2 As shown, the format information, version information, data and error correction codeword parts of the QR code.

[0043] The specific content of the positioning information and the coding information depends on the respective coding specifications of each code system, and their differences should not deviate from the protection scope of the present invention.

[0044] See also Figure 3 The figure is a flowchart of a barcode recognition method based on deep learning in an embodiment of the present invention. In this embodiment, when the operator needs to perform single barcode or two-dimensional code image recognition, that is, when the barcode or two-dimensional code image to be recognized is a single target, the method includes the following steps:

[0045] Step S11, obtaining a barcode or two-dimensional code image to be identified.

[0046] The image is a GRB, YUV or grayscale image, which can be collected by a camera or generated by computer software.

[0047] Step S12: load a code system classifier pre-trained by deep learning, and use the code system classifier to predict the code type of the input image.

[0048] The code type includes the code system and version of barcode and QR code.

[0049] Specifically, there are many types of barcodes, including EAN code, 39 code and Codabar code, among which EAN code is divided into two versions: EAN-8 and EAN-13. There are also many types of QR codes, including QR code, PDF147 code and Hanxin code, among which QR code can have 1 to 40 different versions, and the encoding methods of different versions are different. In the embodiment of the present invention, the codes with the same length of binary sequence encoding information are determined to be the same code type.

[0050] Step S13, judging whether the code system is valid according to whether the probability prediction value of the classification result of the code system classifier is greater than a threshold; if so, proceeding to step S14; otherwise, the process ends.

[0051] When the probability prediction value of the classification result is greater than a threshold, it is determined that the coding of the predicted input image is valid; otherwise, it is determined that the coding of the predicted input image is invalid; in this embodiment, the threshold is pre-set to 0.5.

[0052] Step S14, loading a corresponding code recognizer pre-trained by deep learning according to the code type of the input image predicted by the code classifier, and having the code recognizer map and identify the input image as coded information.

[0053] Different code types correspond to loading different code readers.

[0054] Step S15, decoding the coded information obtained by mapping and identifying the input image by the code recognizer to obtain the original information of the barcode or the two-dimensional code.

[0055] For example, when the input image predicted by the code system classifier is an EAN-13 version of the barcode, the decoding process decodes the encoded information by looking up the table to obtain the original information of the EAN-13 barcode, such as Figure 1 The barcode shown in the figure is mapped and recognized by the barcode reader as coded information: "101 0001011(9)0100111(0) 0110011(1) 0011011(2) 0111101(3) 0100011(4) 01010 1001110(5)1010000(6) 1000100(7) 1001000(8) 1110100(9) 1101100(2) 101", where the value in brackets is the value obtained by querying Figure 4 The EAN-13 code list shown in FIG. 1 is obtained by converting the code information into the EAN-13 code list (cited from: Gong Yahuan, Wang Chao, Hu Chen, Design and Implementation of EAN-13 Code Image Recognition System, Modern Electronic Technology, 2009, 032(022): 106-109). When the input image predicted by the code system classifier is a two-dimensional code of a QR code, the decoding process decodes the encoded information through operations such as masking and byte splitting to obtain the original information of the QR code. The decoding process is a prior art and is not described in detail here.

[0056] See also Figure 5 , pre-training the code system classifier through deep learning, including:

[0057] Step S20: acquiring barcode or two-dimensional code images of different code types to form a first data set.

[0058] Each piece of data at least includes {image saving path, code type, binary sequence encoding information}.

[0059] In practical applications, only a few commonly used code types may need to be selected. The embodiments of the present invention are illustrated by taking three code types, namely EAN-13 code, QR-2 code (25x25) and QR-5 code (37x37).

[0060] The binary sequence encoding information includes all the information required for decoding, but does not include the positioning information for locating the barcode or QR code. The binary means that the black lines of the barcode or the black grid points of the QR code represent 1, and the white lines or grid points represent 0. The binary sequence lengths of barcodes or QR codes of different code types are different. For example, the sequence lengths of EAN-13 code, QR-2 version code (25x25), QR-5 version code (37x37) are as follows:

[0061] EAN-13 code: 42 digits on the left and 42 digits on the right, a total of 84 digits;

[0062] QR-2 version code: 25x25 size, 15 bits for format information, 0 bits for version information, 359 bits for data and error correction codewords, a total of 374 bits;

[0063] QR-5 version code: 37x37 size, 15 bits for format information, 0 bits for version information, 1079 bits for data and error correction codewords, a total of 1094 bits;

[0064] The embodiments of the present invention can randomly generate barcode or two-dimensional code images of different code types by computer and form the first data set. For example, the open source standard libraries bar-code and qrcode based on Python can generate barcode and QR code images respectively, and the binary sequence codes required to construct the first data set can be obtained inside the functions generated by bar-code and qrcode.

[0065] Step S21: Use the first data set to perform deep learning model training to obtain the code system classifier.

[0066] The deep learning model may adopt VGG-16, SqueezeNet, MobileNet or other custom models; for example, the number of classification outputs of the deep learning model is set to 3, and the model is trained using a Softmax classifier and a cross entropy loss function, and a gradient descent algorithm.

[0067] See also Figure 6 Step S12, loading a code system classifier pre-trained by deep learning, and using the code system classifier to predict the code system type of the input image, specifically including:

[0068] Step S121, input the barcode or QR code image to be recognized into the deep learning network.

[0069] Step S122, judging the code type corresponding to the maximum probability according to the output of the deep learning network. Figure 7, the code system classifier outputs [0.01, 0.91, 0.08], which correspond to the prediction probabilities of the three codes [EAN-13, QR-2, QR-5] respectively; among them, the maximum is 0.91; therefore, it is judged that the current input is a QR-2 code, and 0.91>0.5, so the code system is judged to be valid.

[0070] See also Figure 8 , pre-train the code reader through deep learning, including:

[0071] Step S30, using formula (1) to calculate the code identifier, and using formula (2) to calculate the code identifier loss function.

[0072] Specifically, z c =G c (x) (1)

[0073]

[0074] Where x is the input image, belonging to the cth type of code, c ~ [1, M], M is a positive integer, y c G is the coding information mark. c For the code reader of type c, N c The length of the binary sequence encoding information of the code system; c To predict the coding information, the length is also N c The sigmoid is used to convert z c The value of the activation function is scaled to between 0 and 1, Loss c Code reader G for type c code system c loss.

[0075] Step S31, using formulas (1), (2) and the first data set to perform deep learning training on the code recognizer.

[0076] See also Fig. 9 Step S14, according to the code type of the input image predicted by the code classifier, a corresponding code recognizer pre-trained by deep learning is loaded, and the code recognizer maps the input image into coding information, specifically including:

[0077] Step S141 : selecting a corresponding code recognizer from a plurality of pre-trained code recognizers according to the code type of the input image predicted by the code classifier.

[0078] Step S142, using the formula (1) to map the input image to obtain prediction coding information.

[0079] Step S143: binarize the predicted coding information to obtain coding information of the input image.

[0080] For example, if the code type of the input image predicted by the code classifier is the cth type, then the multiple code recognizers that have been pre-trained Select the corresponding code reader as G c Using formula (1), the input image is mapped to obtain the prediction coding information z c . The predicted coding information z c Binarization is performed to obtain the encoding information of the input image; wherein, the sequence z c If the element is greater than 0, it is set to 1; if it is less than or equal to 0, it is set to 0.

[0081] Please refer again Figure 7 , is a structural diagram of a code classifier and a code recognizer obtained by deep learning training using the VGG-16 network structure; the main structure of the code recognizer is a three-layer fully connected (Dense) network, and both share part of the network structure with the code classifier (VGG-16), that is, the Conv4-3 layer output of the VGG-16 network is used as the input of the fully connected network, so that the network structure and weights of the Conv4-3 layer and before are shared.

[0082] Specifically, the code system classifier (VGG-16) is used to predict that the code system type of the input image is a QR-2 version of the two-dimensional code, that is, c = 2; further, the code system classifier (VGG-16) performs probability prediction on the classification result of the QR-2 version of the two-dimensional code, and the maximum probability value obtained is 0.91, then according to the probability prediction value of the classification result, it is determined that the QR-2 version of the two-dimensional code system is valid. Then, according to the predicted code system type, the corresponding code recognition device G is loaded 2 , the code reader G 2 The output is a sequence of [1.342, 0, 2.103, -0.421, ..., -1.097], that is, the predicted coding information z 2 , a total of 374 elements; finally, the predicted coding information z is binarized using formula (3) 2 , when the element is greater than 0, the element is set to 1, and when it is less than or equal to 0, it is set to 0, and the resulting sequence is [1, 0, 1, 0, ..., 0].

[0083]

[0084] In other embodiments, the code classifier and the code recognizer may also be jointly trained, that is, the training process of the two is performed simultaneously; specifically, for the same input, the cross entropy loss of the code classifier and the loss of the code recognizer are calculated respectively (Formula (2)), the cross entropy loss and the loss of the code recognizer are summed, and the sum of the losses is minimized to achieve joint training.

[0085] See also Fig.10 , is a barcode recognition method based on deep learning in another embodiment of the present invention. In this embodiment, when the operator needs to perform multi-target barcode or two-dimensional code image recognition, that is, when the barcode or two-dimensional code image to be recognized is multiple targets, the method includes:

[0086] Step S40, obtaining a barcode or two-dimensional code image to be identified.

[0087] Step S41, loading a pre-trained deep learning multi-target detection model, and using the deep learning multi-target detection model to detect and identify the input image to obtain target features corresponding to each of the multiple barcodes or QR codes.

[0088] Among them, the target feature is the input feature of the classification layer of the multi-target detection model. The classification layer is usually a fully connected layer or its deformation structure. In this embodiment, the category of the classification layer is set to 2, which is used to predict whether the target to be identified is the background or the barcode.

[0089] Step S42: load a code system classifier pre-trained by deep learning, and use the code system classifier to predict the code system type of the input image.

[0090] Specifically, a code system classifier pre-trained by deep learning is loaded, and the code system classifier is used to respectively predict the code system type of the target features corresponding to each of the multiple barcodes or two-dimensional codes.

[0091] Step S43, judging whether the symbology is valid or not according to whether the probability prediction value of the classification result of the symbology classifier is greater than a threshold value, so as to screen out target features of valid symbology.

[0092] Step S44, loading a corresponding code recognizer pre-trained by deep learning according to the code type of the input image predicted by the code classifier, and having the code recognizer map the input image into encoding information.

[0093] Specifically, the corresponding code types of the target features corresponding to the multiple barcodes or QR codes respectively predicted by the code classifier are loaded with corresponding code recognizers pre-trained by deep learning, and the code recognizers map and identify the target features corresponding to the multiple barcodes or QR codes respectively as corresponding predicted coding information, and binarize the predicted coding information.

[0094] See also Fig.11, is a schematic diagram of the structure of a code classifier and a code identifier using a multi-target detection model (Faster-RCNN or SSD) network structure in an embodiment of the present invention. In this embodiment, when the Faster-RCNN algorithm model is adopted, multiple region proposals are output after region pooling, which represent candidate target features and are used to classify the target. Therefore, the features contained in each region proposal are the target features. For another example, when the SSD algorithm is adopted, the features contained in each feature pixel in its multi-scale feature map represent possible detection targets, so the channel features where the feature pixel is located are the target features. The principle of multi-target detection and recognition is the same as that of the prior art and will not be repeated here.

[0095] Step S45, decoding the coded information obtained by mapping and identifying the input image by the code recognizer to obtain the original information of the barcode or the two-dimensional code.

[0096] Specifically, the coded information obtained by the code reader identifying the target features corresponding to each of the plurality of bar codes or two-dimensional codes is decoded respectively to obtain the original information of the plurality of bar codes or two-dimensional codes.

[0097] See also Fig.12 , pre-training multi-target detection models through deep learning, including:

[0098] Step S50: acquiring barcode or two-dimensional code images of different code types to form a second data set.

[0099] Among them, each code in the second data set needs to be additionally annotated with its position and size information in the image, and the position and size information is used to train the multi-target detection model; that is, the annotation content of each code includes at least: image saving path, position and size information, code type, and binary sequence encoding information.

[0100] For example, the position and size information is represented by (x, y, w, h), which respectively represent the starting position and length and width of the target on the XY axis of the image. For another example, there is a 300×300 sample image that contains an EAN-13 code and a QR-2 version code, so two annotation data are required: {demo.jpg, (60, 90, 80, 20), 1, 1010001...101}, {demo.jpg, (210, 150, 50, 50), 2, 0010001...00}.

[0101] Step S51, setting the target category of the multi-target detection model to 2.

[0102] Specifically, it is only necessary to predict whether the target area is coded or uncoded, wherein uncoded also represents the background category.

[0103] The multi-target detection technology has the ability to classify targets. Since the code categories of the barcode and QR code of the present invention have been identified by the code classifier, the multi-target detection model mainly realizes the positioning and detection of the target to determine whether the target to be detected is the background or a real barcode. Therefore, the target category is set to 2.

[0104] Step S52: Minimize the loss function of the multi-target detection model by using the second data set and deep learning technology to train the multi-target detection model.

[0105] Among them, the multi-target detection model has its prescribed loss function, such as SSD, YOLO and other multi-target detection models, which is the same as the principle of minimizing the loss function in the prior art and will not be repeated here.

[0106] In other embodiments, the multi-target detection model, the code system classifier and the code recognizer can be trained jointly, that is, the training process of the three is carried out simultaneously, and the specific method is:

[0107] For the same input image, the loss of the multi-target detection model, the cross entropy loss of the code classifier and the loss of the code recognizer are calculated respectively (Formula (2)), and the loss of the multi-target detection model, the cross entropy loss of the code classifier and the loss of the code recognizer are summed, and the sum of the losses is minimized to achieve joint training.

[0108] See also Fig.13 , which is a structural diagram of a barcode recognition device based on deep learning in an embodiment of the present invention, the device 60 includes a storage unit 61, an image acquisition unit 62, a processing unit 63 and a model training unit 64.

[0109] The storage unit 61 is used to store deep learning model parameters, code type, encoding information and the application itself; the medium of the storage can be, for example, a floppy disk, a hard disk, a CD-ROM and a semiconductor memory.

[0110] The image acquisition unit 62 is used to acquire a barcode or a two-dimensional code image to be recognized.

[0111] Furthermore, the processing unit 63 includes an image processing unit 631 and a decoding unit 632 .

[0112] The image processing unit 631 is used to recognize the encoding information of the barcode or the QR code according to the image input by the image acquisition unit 62 .

[0113] The decoding unit 632 is used to decode the coded information of the barcode or QR code recognized by the image processing unit 631, and output the original information of the barcode or QR code. The decoding method depends on the encoding rules of each code system, for example, the EAN-13 barcode is decoded by looking up a table, and the QR code is decoded by masking and other operations.

[0114] Furthermore, the image processing unit 631 includes:

[0115] A symbology classification module 6311 is used to load a symbology classifier pre-trained by deep learning, and use the symbology classifier to predict the symbology type of the input image;

[0116] The code recognition module 6312 is used to determine whether the code is valid according to whether the probability prediction value of the classification result of the code classifier is greater than a threshold value, and when the code is determined to be valid, load the corresponding code recognizer pre-trained by deep learning according to the code type of the input image predicted by the code classification module 6311, and the code recognizer maps the input image into encoded information.

[0117] In this embodiment, the code recognition module 6312 selects a corresponding code recognizer according to the code type determined by the code classification module 6311, calculates predicted coding information according to the code recognizer and formula (1), and performs binarization processing on the predicted coding information.

[0118] Furthermore, the code classification module 6311 is used to input the barcode or QR code image to be identified into the deep learning network, and determine the code type corresponding to the maximum probability according to the output of the deep learning network.

[0119] Furthermore, the model training unit 64 is used to obtain data and train a deep learning model. Specifically, the model training unit 64 obtains barcode or two-dimensional code images of different code types to form a first data set; and uses the first data set to perform deep learning model training to obtain the code classifier; wherein each piece of data at least contains information of {image saving path, code type, binary sequence encoding information}.

[0120] The model training unit 64 also uses formula (1) to calculate the code recognition function, and uses formula (2) to calculate the code recognition loss function, and uses formula (1), (2) and the first data set to train the code recognition function G c Conduct deep learning training.

[0121] Specifically, z c =G c (x) (1)

[0122]

[0123] Where x is the input image, belonging to the cth type of code, c ~ [1, M], M is a positive integer, y c G is the coding information mark. c For the code reader of type c, N c The length of the binary sequence encoding information of the code system; c To predict the coding information, the length is also N c The sigmoid is used to convert z c The value of the activation function is scaled to between 0 and 1, Loss c Code reader G for type c code system c loss.

[0124] Furthermore, the model training unit 64 is also used to jointly train the code classifier and the code recognizer. Specifically, for the same input, the cross entropy loss of the code classifier and the loss of the code recognizer are calculated respectively (Formula (2)), the cross entropy loss and the loss of the code recognizer are summed, and the sum of the losses is minimized to achieve joint training.

[0125] See also Fig.14 , is a schematic diagram of the structure of a barcode recognition device based on deep learning in another embodiment of the present invention. The device 70 includes a storage unit 71, an image acquisition unit 72, a processing unit 73 and a multi-target model training unit 74. The processing unit 73 includes an image processing unit 731 and a decoding unit 732; the image processing unit 731 includes a code classification module 7311, a code recognition module 7312 and a multi-target detection module 7313.

[0126] In this embodiment, when the barcode or QR code image that the operator needs to identify is multiple targets, the multi-target detection module 7313 is used to load a pre-trained deep learning multi-target detection model, and use the deep learning multi-target detection model to detect and identify the input image to obtain the target features corresponding to each of the multiple barcodes or QR codes.

[0127] The code classification module 7311 is used to load a code classifier pre-trained by deep learning, and use the code classifier to predict the code type of the target features corresponding to each of the multiple barcodes or two-dimensional codes.

[0128] The code recognition module 7312 is used to load the corresponding code recognizers pre-trained by deep learning according to the code type of the target features corresponding to the multiple barcodes or QR codes predicted by the code classifier, and the code recognizer maps and identifies the target features corresponding to the multiple barcodes or QR codes into corresponding predicted coding information, and binarizes the predicted coding information.

[0129] The decoding unit 732 is used to respectively decode the coded information obtained by the code reader from identifying the target features corresponding to each of the multiple barcodes or two-dimensional codes, so as to obtain the original information of the multiple barcodes or two-dimensional codes.

[0130] The multi-target model training unit 74 is used to obtain barcode or two-dimensional code images of different code types to form a second data set, set the target category of the multi-target detection model to 2, and minimize the loss function of the multi-target detection model through the second data set and deep learning technology to train the multi-target detection model. In the second data set, each code needs to be additionally annotated with its position and size information in the image, and the position and size information is used to train the multi-target detection model; that is, the annotation content of each code at least includes: image saving path, position and size information, code type, and binary sequence encoding information.

[0131] Furthermore, the multi-target model training unit 74 is also used to jointly train the multi-target detection model, the code classifier and the code recognizer. Specifically, for the same input, the loss of the multi-target detection model, the cross entropy loss of the code classifier and the loss of the code recognizer are calculated respectively (Formula (2)), and the loss of the multi-target detection model, the cross entropy loss of the code classifier and the loss of the code recognizer are summed, and the sum of the losses is minimized to achieve joint training.

[0132] A barcode recognition method and device based on deep learning are provided in an embodiment of the present invention. A code classifier and a code identifier are pre-trained through deep learning, so that the code classifier is loaded on the acquired barcode or two-dimensional code image to predict the code type, and the corresponding code identifier is loaded to recognize the encoded information, thereby realizing one-time processing of most of the work of the traditional recognition process such as detection, correction, binarization, and grid division, and solving the problems of complex processes and poor anti-interference ability of the existing barcode or two-dimensional code recognition methods; at the same time, the code category of the target barcode or two-dimensional code image is identified by using the pre-trained deep learning code classifier, and subsequent processing is performed according to different code categories, which can be applicable to multiple code systems; further, the target recognition of the acquired multiple barcodes or two-dimensional code images can be performed by loading a multi-target detection model based on deep learning, so as to be applicable to multi-target barcode recognition.

[0133] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical or other forms.

[0134] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0135] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0136] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the technical solution of the present invention can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a management server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: read-only memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.

[0137] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A barcode recognition method based on deep learning, characterized in that: The steps include: Obtain a barcode or QR code image to be identified; Loading a symbology classifier pre-trained by deep learning, and using the symbology classifier to predict the symbology type of the input image; wherein the symbology type includes the symbology and version of a barcode and a QR code; Judging whether the symbology is valid according to whether the probability prediction value of the classification result of the symbology classifier is greater than a threshold; When it is determined that the code system is valid, a corresponding code recognizer pre-trained by deep learning is loaded according to the code system type of the input image predicted by the code system classifier, and the code recognizer maps and identifies the input image as coded information; and Decoding the coded information obtained by mapping and identifying the input image by the code recognizer to obtain the original information of the barcode or QR code; Pre-training of symbology classifiers through deep learning, including: Obtain barcode or two-dimensional code images of different code system types to form a first data set; wherein each piece of data at least includes {image saving path, code system type, binary sequence encoding information}; Using the first data set to perform deep learning model training to obtain the code system classifier; The code reader is trained through deep learning, including: The code reader is calculated using formula (1), and the code reader loss function is calculated using formula (2); wherein x is the input image, belonging to the c-th type of code system, c ~ [1, M], M is a positive integer, y c is the coding information mark, G c For the code reader of type c, N c The length of the binary sequence encoding information of the code system; c To predict the coding information, the length is also N c sequence; sigmoid is used to convert z c The value of the activation function is scaled to between 0 and 1, Loss c Code reader G for type c code system c loss; z c =G c (x)(1) The code recognition device G is analyzed using formulas (1), (2) and the first data set. c Conduct deep learning training.

2. The barcode recognition method based on deep learning according to claim 1, characterized in that: Loading a symbology classifier pre-trained by deep learning and using the symbology classifier to predict the symbology type of the input image, specifically including: Input the barcode or QR code image to be recognized into the deep learning network; The code type corresponding to the maximum probability is determined according to the output of the deep learning network.

3. A barcode recognition method based on deep learning according to claim 1 or 2, characterized in that: According to the code type of the input image predicted by the code classifier, a corresponding code recognizer pre-trained by deep learning is loaded, and the code recognizer maps the input image into encoding information, specifically including: Selecting a corresponding code recognizer from a plurality of pre-trained code recognizers according to the code type of the input image predicted by the code classifier; Mapping the input image to obtain prediction coding information using the formula (1); and The predicted coding information is binarized to obtain coding information of the input image.

4. The barcode recognition method based on deep learning according to claim 1, characterized in that: When the barcode or two-dimensional code image to be identified is a plurality of targets, the method further comprises: Loading a pre-trained deep learning multi-target detection model, and using the deep learning multi-target detection model to detect and identify the input image to obtain target features corresponding to each of the multiple barcodes or QR codes; Loading a code system classifier pre-trained by deep learning, and using the code system classifier to predict the code system type of the input image, specifically: loading a code system classifier pre-trained by deep learning, and using the code system classifier to respectively predict the code system type of the target features corresponding to each of the multiple barcodes or two-dimensional codes; According to the code type of the input image predicted by the code classifier, a corresponding code recognizer pre-trained by deep learning is loaded, and the code recognizer maps and identifies the input image as coding information, specifically: according to the code types of the target features corresponding to the multiple barcodes or two-dimensional codes predicted by the code classifier, the corresponding code recognizers pre-trained by deep learning are loaded respectively, and the target features corresponding to the multiple barcodes or two-dimensional codes are mapped and identified as corresponding predicted coding information by the code recognizer, and the predicted coding information is binarized; The coded information obtained by the code reader through mapping and identifying the input image is decoded to obtain the original information of the barcode or the two-dimensional code. Specifically, the coded information obtained by the code reader through identifying the target features corresponding to each of the multiple barcodes or the two-dimensional codes is decoded respectively to obtain the original information of the multiple barcodes or the two-dimensional codes.

5. The barcode recognition method based on deep learning according to claim 4, characterized in that: Pre-training of multi-target detection models through deep learning includes: Obtain barcode or two-dimensional code images of different code system types to form a second data set; wherein, in the second data set, each code is additionally annotated with its position and size information in the image, and the annotated content at least includes: image saving path, position and size information, code system type, and binary sequence encoding information; The target category of the multi-target detection model is set to 2; The loss function of the multi-target detection model is minimized by using the second data set and deep learning technology to train the multi-target detection model.

6. A barcode recognition device based on deep learning, comprising a storage unit, an image acquisition unit and a processing unit; the processing unit comprises an image processing unit and a decoding unit; the image acquisition unit is used to acquire a barcode or two-dimensional code image to be recognized; characterized in that, The image processing unit comprises: A symbology classification module, used to load a symbology classifier pre-trained by deep learning, and use the symbology classifier to predict the symbology type of an input image; A code recognition module, configured to determine whether the code system is valid according to whether the probability prediction value of the classification result of the code system classifier is greater than a threshold value, and when the code system is determined to be valid, load a corresponding code recognition module pre-trained by deep learning according to the code type of the input image predicted by the code system classification module, and the code recognition module maps and recognizes the input image as coded information; The decoding unit is used to decode the coded information obtained by the code recognizer mapping and identifying the input image to obtain the original information of the barcode or QR code; Model training unit, used to: Obtain barcode or two-dimensional code images of different code system types to form a first data set; wherein each piece of data at least includes information of {image saving path, code system type, binary sequence encoding information}; Using the first data set to perform deep learning model training to obtain the code system classifier; The code reader is calculated using formula (1), and the code reader loss function is calculated using formula (2), and the code reader G is calculated using formula (1), (2) and the first data set. c Conduct deep learning training; z c =G c (x)(1) Where x is the input image, belonging to the cth type of code, c ~ [1, M], M is a positive integer, y c is the coding information mark, G c For the code reader of type c, N c The length of the binary sequence encoding information of the code system; c To predict the coding information, the length is also N c sequence; sigmoid is used to convert z c The value of the activation function is scaled to between 0 and 1, Loss c Code reader G for type c code system c loss.

7. A barcode recognition device based on deep learning according to claim 6, characterized in that: The code recognition module is also used to select a corresponding code recognizer according to the code type determined by the code classification module, calculate and obtain predicted coding information according to the code recognizer and formula (1), and perform binarization processing on the predicted coding information.

8. The barcode recognition device based on deep learning according to claim 6, characterized in that: The image processing unit also includes a multi-target detection module; When the barcode or two-dimensional code image to be identified is a plurality of targets, the multi-target detection module is used to load a pre-trained deep learning multi-target detection model, and use the deep learning multi-target detection model to detect and identify the input image to obtain target features corresponding to each of the plurality of barcodes or two-dimensional codes; The code classification module is used to load a code classifier pre-trained by deep learning, and use the code classifier to predict the code type of the target features corresponding to each of the multiple barcodes or two-dimensional codes; The code recognition module is used to load corresponding code recognizers pre-trained by deep learning according to the code types of the target features corresponding to the multiple barcodes or two-dimensional codes respectively predicted by the code classifier, and the code recognizers respectively map and identify the target features corresponding to the multiple barcodes or two-dimensional codes as corresponding predicted coding information, and perform binarization processing on the predicted coding information; The decoding unit is used to respectively decode the coded information obtained by the code reader from identifying the target features corresponding to each of the multiple barcodes or two-dimensional codes, so as to obtain the original information of the multiple barcodes or two-dimensional codes.

9. A barcode recognition device based on deep learning according to claim 8, characterized in that: It also includes a multi-target model training unit, which is used to obtain barcode or two-dimensional code images of different code types to form a second data set, set the target category of the multi-target detection model to 2, and minimize the loss function of the multi-target detection model through the second data set and deep learning technology to train the multi-target detection model; wherein, in the second data set, each code is additionally annotated with its position and size information in the image, and the annotation content at least includes: image save path, position and size information, code type, and binary sequence encoding information.