Two-dimensional code identification method and device
By detecting, picking and marking QR code images, combining the version detection of the prior network model and enhancing the noise reduction and defuzzing processing of the network model, the standard QR code grid is used for guidance, and the problems of skew, dummy, and motion blur in QR code recognition are solved, achieving efficient and accurate recognition and improvement in the success rate of recognition.
Patent Information
- Application Number
- CN202510294053.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-13
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2045-03-13
AI Technical Summary
The prior art is difficult to deal with problems such as skew, dummy focus, motion blur during the QR code recognition process, resulting in failed identification or incorrect identification.
The detection network model is used to detect, pick up and mark QR code images, and the prior network model is used to detect QR code versions, and a standard QR code grid is generated as prior knowledge input into the enhanced network model. The enhanced network model uses noise reduction and defuzzing processing, combined with standard QR code grids for guidance, to achieve high-quality enhancement of QR codes.
The ability to process and enhance skewed, dummy, and motion fuzzy QR codes has been improved, and the success rate of QR code recognition has been significantly improved, achieving efficient and accurate identification.
Smart Images

Figure CN119785277A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a two-dimensional code recognition method and device. Background Art
[0002] A QR code is a specific geometric shape that distributes black and white rectangular arrays on a plane according to a certain pattern to record data symbol information.
[0003] At present, in order to ensure accurate scanning and recognition of QR codes, it is necessary to ensure that the scanned QR code image is clear; however, in actual scanning and recognition scenarios, it may be difficult to scan a clear QR code image smoothly. For example, when scanning a QR code with a handheld scanning device, the scanned QR code may be motion blurred due to hand shaking, the distance between the scanning device and the QR code is too far, or the resolution of the scanning device is not enough. It is impossible to accurately distinguish the boundaries of the black and white cells in the QR code, and then the QR code cannot be recognized or is incorrectly recognized. In actual scanning and recognition scenarios, the scanned QR code image may be skewed, out of focus, and other conditions that affect recognition due to reasons such as scanning angle and light. If one or more of the above conditions occur at the same time, it will increase the difficulty of efficient and accurate recognition of QR codes. Summary of the invention
[0004] In view of the problems existing in the prior art, the present invention proposes a two-dimensional code recognition method and device, which uses a detection network model to detect, extract and mark the intercepted two-dimensional code image; uses a priori network model to detect the two-dimensional code version of the two-dimensional code, generates a corresponding standard two-dimensional code grid according to the detected two-dimensional code version information, and inputs the corresponding standard two-dimensional code grid into the enhancement network model as priori knowledge; the enhancement network model performs noise reduction and deblurring processing on the received two-dimensional code, and at the same time, uses the standard two-dimensional code grid to guide the noise reduction and deblurring processing process, so as to achieve high-quality enhancement of the two-dimensional code; thereby achieving efficient and accurate recognition of the two-dimensional code and improving the success rate of two-dimensional code recognition.
[0005] To achieve the above object, the present invention adopts a two-dimensional code recognition method, comprising the following sequential steps: S1. Detect whether there is a QR code in the target area, lock and intercept the QR code in the target area; S2. Use the detection network model to detect, extract and mark the intercepted QR code image, and identify and mark the three corner points of the QR code; S3. Calculate the perspective transformation matrix based on the identified corner points of the QR code to achieve QR code alignment; S4. Input the adjusted Founder QR code into the QR code decoding library for decoding. If it can be directly decoded, the identification content of the QR code is obtained; if the QR code cannot be decoded, it is input into the prior network model and the enhanced network model; S5. Use the prior network model to detect the QR code version of the adjusted Founder QR code, generate the corresponding standard QR code grid according to the detected QR code version information, and input the corresponding standard QR code grid as prior knowledge into the enhanced network model; S6. The enhanced network model performs noise reduction and deblurring processing on the received QR code. At the same time, the standard QR code grid is used to guide the noise reduction and deblurring process to achieve high-quality enhancement of the QR code. S7. Input the enhanced two-dimensional code image into a two-dimensional code decoding library for decoding, thereby obtaining the identification content of the two-dimensional code.
[0006] Preferably, the enhanced network model adopts the DeblurGANv2 model, the backbone network of which adopts the MobileNet lightweight network and adopts efficient technologies such as deep separable convolution, which significantly reduces the number of parameters and calculations, while ensuring high performance and enabling the model to be deployed on terminals with low computing levels for efficient operation.
[0007] Preferably, a Batch Normalization normalization layer is used in the enhanced network model, which reduces the quantization accuracy loss when the model is deployed on a terminal device compared to the original Instance Normalization normalization layer.
[0008] Preferably, the detection network model adopts the YOLOv8 model to achieve lightweight design, significantly reduce computing costs while maintaining high accuracy, and is suitable for real-time detection scenarios.
[0009] Preferably, the prior network model adopts the MobileNetv2 model, which can achieve low computing power operation while maintaining high detection accuracy and speed.
[0010] Preferably, it also includes a first two-dimensional code data set for training the detection network model, and the first two-dimensional code data set is obtained by the following steps: A first QR code data set for training is formed by shooting a QR code video and averaging consecutive short exposure frames to generate a blurred image; The two-dimensional code video contains multiple two-dimensional codes of different versions and with dispersed and unfixed positions. The detection network model is trained using the first two-dimensional code data set to obtain parameter weights, thereby ensuring high detection accuracy and speed of the model.
[0011] Preferably, it also includes a second two-dimensional code data set for training the prior network model, and the second two-dimensional code data set is obtained by the following steps: A second QR code data set for training is formed by shooting a QR code video and averaging consecutive short exposure frames to generate a blurred image; The QR code video contains different versions of QR codes collected by version classification. The QR code images in the second QR code data set are input into the prior network model for training according to the version to obtain the parameter weights under the corresponding version; the prior network model training process is repeated, and different versions of QR codes are used for training in turn to obtain the corresponding parameter weights under each different version, thereby ensuring the high detection accuracy and speed of the model.
[0012] Preferably, a third two-dimensional code data set for training the enhanced network model is also included, and the third two-dimensional code data set is obtained by the following steps: A fuzzy image is generated by shooting a QR code video and averaging consecutive short exposure frames, and the original QR code images constituting the QR code video are used as clear images, so that the two images are combined in pairs to form a third QR code data set for training; The QR code video contains different versions of QR codes collected by version classification. The QR code images in the third QR code data set are input into the enhanced network model in pairs according to the versions for training, and the standard QR code grid of the corresponding version is input at the same time as prior knowledge to guide the denoising and deblurring process to obtain the parameter weights under the corresponding version; the enhanced network model training process is repeated, and different versions of QR codes are used for training in turn to obtain the corresponding parameter weights under each different version, so that the model can have high-accuracy enhancement capabilities for different versions of QR codes, thereby improving the generalization of the model.
[0013] Preferably, a structural similarity measurement value SSIM between the enhanced two-dimensional code image and the original two-dimensional code image is greater than or equal to 0.7 and less than 1, so as to ensure the decodability of the enhanced two-dimensional code image.
[0014] The present invention also provides a two-dimensional code recognition device, comprising: The image acquisition module detects and determines whether there is a QR code in the target area, and intercepts the QR code in the target area. During the interception process, the ISP exposure is automatically adjusted according to the scene environment, and the intercepted QR code is transmitted to the image correction module; The image correction module detects and extracts the QR code from the image, and performs processes such as rotation and deformation adjustment on the QR code, adjusts the QR code that is tilted at any angle and deformed to a square QR code in the correct position, and transmits the adjusted square QR code to the QR code decoding module; The QR code decoding module uses the ZXing QR code decoding library to decode the received QR code and obtain the identification content of the QR code; if it fails to decode the received QR code, it transmits the QR code to the version prior module and the image enhancement module; The version priori module performs a QR code version detection on the received QR code, generates a corresponding standard QR code grid according to the detected QR code version information, and inputs the corresponding standard QR code grid into the image enhancement module as priori knowledge; The image enhancement module performs noise reduction and deblurring processing on the received QR code. At the same time, the standard QR code grid is used to guide the noise reduction and deblurring process to achieve high-quality enhancement of the QR code. The structural similarity measurement value SSIM between the enhanced QR code image and the original QR code image is greater than or equal to 0.7 and less than 1. The enhanced QR code image is input into the QR code decoding module.
[0015] The present invention realizes the recognition of QR codes by combining multiple neural network models, thereby improving the processing and enhancement capabilities of skewed, out-of-focus, and motion-blurred QR codes. Each network model is pre-trained with high quantity and complexity, and the trained model is highly flexible and versatile, thereby improving the universality of the present invention.
[0016] The present invention utilizes a priori network model to perform QR code version detection on a QR code, generates a corresponding standard QR code grid according to the detected QR code version information, and inputs the corresponding standard QR code grid as priori knowledge into an enhanced network model; the enhanced network model performs noise reduction and deblurring processing on the received QR code, and at the same time, utilizes the standard QR code grid to guide the noise reduction and deblurring processing process to achieve high-quality enhancement of the QR code; thereby achieving efficient and accurate recognition of the QR code and improving the success rate of QR code recognition.
[0017] The enhanced network model adopts the DeblurGANv2 model. The backbone network of this model adopts the MobileNet lightweight network, which significantly reduces the number of parameters and calculations. While ensuring high performance, the model can be deployed on terminals with low computing levels and run efficiently. The enhanced network model also uses the Batch Normalization normalization layer to reduce the loss of quantization accuracy when the model is deployed on terminal devices, avoiding data errors generated by the model.
[0018] The present invention adopts an adversarial loss function that integrates the structural similarity metric SSIM. The structural similarity metric SSIM is used to guide the discriminator to more accurately evaluate the structural similarity between the generated image and the real image. It also helps the generator to generate images that are more structurally similar, thereby improving the quality of image generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 A flowchart of a two-dimensional code recognition method of the present invention; Figure 2 The figure is a schematic diagram of the structural modules of a two-dimensional code recognition device of the present invention. DETAILED DESCRIPTION
[0021] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Example 1
[0022] Reference Figure 1 This embodiment provides a method for identifying a QR code. First, in step S1, whether there is a QR code in the target area is detected. The target area can be the area that the camera can monitor when it is fixed at a certain position; the target area can also be the area that the handheld camera lens can capture when scanning the code. If there is a QR code in the target area, the QR code is locked and intercepted. During the interception process, the ISP exposure is automatically adjusted according to the scene environment to avoid overexposure of the image; if there is no QR code in the target area, the detection continues.
[0023] Affected by factors such as different shooting distances and angles, the captured QR code images may have different sizes and shapes. For example, in the captured QR code image, the QR code part may be a diamond or a square. The length of the QR code boundary and the position of the QR code in the image may also be different between different QR code images.
[0024] In step S2, the detection network model is used to detect the position of the two-dimensional code in the image, and the two-dimensional code is extracted, and the three corner points of the two-dimensional code are identified and marked; in order to ensure the high detection accuracy and rapidity of the model, and to achieve lightweight design, the detection network model adopts the YOLOv8 model, and the first two-dimensional code data set for training the detection network model is designed and produced. Specifically, by shooting a two-dimensional code video, and averaging continuous short exposure frames to generate a blurred image, thereby forming a first two-dimensional code data set for training. The two-dimensional code video is cross-mixed with multiple two-dimensional codes of different versions and scattered and unfixed positions. For example, the fourth version of the two-dimensional code image can be set after the first version of the two-dimensional code image, and the second version of the two-dimensional code image can be set after the fourth version of the two-dimensional code image. In addition, the two-dimensional code can be randomly rotated at any angle to increase the diversity and complexity of the training sample, so as to simulate various scanning situations that can be encountered in the actual scanning scene. Each version of the two-dimensional code blurred image should be no less than 5000. The detection network model is trained using the first two-dimensional code data set to obtain parameter weights, thereby ensuring the high detection accuracy and rapidity of the model.
[0025] The captured QR code image is processed using the trained detection network model. Since the model has been trained for blurred QR code images during training, the trained detection network model can quickly detect the QR code position of the received blurred QR code image, extract the QR code, and identify and mark the three corner points of the QR code.
[0026] After identifying and marking the three corner points of the QR code, proceed to step S3, perform perspective transformation matrix calculation based on the identified corner points of the QR code, and achieve QR code alignment; specifically, establish a corresponding mapping relationship based on the three marked corner points of the QR code and the three corner points under the standard coordinates, correct the QR code image based on the mapping relationship, rotate and deform the QR code, and adjust the QR code to be a square QR code in the correct orientation. The so-called correct orientation means that the three corner points of the QR code are respectively at the upper left, upper right, and lower left positions, and the QR code as a whole is not tilted.
[0027] In step S4, the adjusted Founder QR code is input into the QR code decoding library for decoding to determine whether it can be decoded. The QR code decoding library can use the ZXing QR code decoding library. If it can be directly decoded, the identification content of the QR code is obtained; if the QR code cannot be decoded, it is input into the prior network model and the enhanced network model.
[0028] The prior network model is used to detect the version information of the QR code and generate the corresponding standard QR code grid. In order to ensure the high detection accuracy and rapidity of the model and realize low computing power operation, the prior network model can use the MobileNetv2 model. A second QR code data set for training the prior network model is designed and produced. The second QR code data set for training is formed by shooting a QR code video and averaging continuous short exposure frames to generate a blurred image. The QR code video contains different versions of QR codes collected by version classification, and the position of the QR code in the image is scattered and not fixed, and the QR code has different rotation angles in the image to increase the diversity and complexity of the training samples, so as to simulate various scanning situations that can be encountered in the actual scanning scene. The number of blurred images of each version of the QR code should be no less than 5,000. The QR code images in the second QR code data set are input into the prior network model according to the version for training to obtain the parameter weights under the corresponding version. Repeat the prior network model training process, and train with different versions of QR codes in turn to obtain the corresponding parameter weights under each different version.
[0029] In step S5, the trained prior network model is used to detect the QR code version of the adjusted Founder QR code, and a corresponding standard QR code grid is generated according to the detected QR code version information, such as a grid corresponding to the fourth edition QR code, the grid size is 33x33 pixels, which is the same as the size of the fourth edition QR code, and the minimum square size in the grid is also the same as the minimum square size of the fourth edition QR code; then the corresponding standard QR code grid is input into the enhanced network model as prior knowledge. Since the training has been carried out for the fuzzy QR code image during the model training process, the trained prior network model can quickly detect and identify the QR code version of the received fuzzy QR code image, generate the corresponding standard QR code grid according to the detected QR code version information, and input the corresponding standard QR code grid into the enhanced network model as prior knowledge.
[0030] The enhanced network model is used to reduce noise and deblur the QR code. To ensure the deblurring effect and rapidity of the model, the third QR code dataset for training the enhanced network model is first designed and produced. The QR code video is shot and the blurred image is generated by averaging continuous short exposure frames. The original QR code images that constitute the QR code video are used as clear images, so that the third QR code dataset for training is formed by pairing. The QR code video contains pairs of QR codes collected by version classification. The number of QR code pairs for each version should be no less than 5,000.
[0031] In real life, the need for QR code recognition often occurs on terminals with low computing power, and the recognition time is strictly limited. Therefore, the enhanced network model of the present invention can adopt the DeblurGANv2 model, which maintains extremely low parameter and computational complexity while ensuring efficient detection. The overall structure of the model includes two parts: a generator and a discriminator.
[0032] The generator network of the enhanced network model is constructed by introducing the feature pyramid network (FPN) and the MobileNet backbone network; the feature pyramid network has a bottom-up path, a top-down path and a lateral connection; in the bottom-up path, through continuous convolution and pooling operations, the spatial resolution of the feature map is gradually reduced, while the depth of the feature map is increased, thereby extracting the semantic information of the image. In the top-down path, upsampling technology is used to increase the size of the original image. By cleverly applying appropriate interpolation algorithms between the original image pixels, new pixel elements are inserted to achieve the expansion of the image size. Horizontal connection: used to match and fuse the deep and shallow feature maps, this fusion enhances the semantic information of the feature map and retains the detail information.
[0033] In the present invention, the MobileNet network is used as the backbone network, which is a solution design for improving the efficiency and adaptability of deblurring processing. The network adopts efficient technologies such as deep separable convolution, which significantly reduces the number of parameters and calculations. Compared with the ResNet network as the backbone network, it can ensure high performance while enabling it to be deployed on terminals with low computing levels and run efficiently.
[0034] In the present invention, the discriminator network of the enhanced network model adopts a dual-scale structure, including a global discriminator and a local discriminator. The global discriminator discriminates the entire image, while the local discriminator discriminates the local area in the image. This dual-scale structure enables the discriminator to better capture the global and local features in the image. The discriminator measures the difference between the real image and the generated image based on the use of a specific loss function. In the present invention, an adversarial loss function that incorporates the structural similarity metric SSIM is used, and the structural similarity metric SSIM is used to guide the discriminator to more accurately evaluate the structural similarity between the generated image and the real image, while also helping the generator to generate images that are more similar in structure, thereby improving the quality of image generation.
[0035] In the DeblurGANv2 model adopted by the present invention, both the generator and the discriminator are provided with a normalization layer. In the existing DeblurGANv2 model, the normalization layer in the generator and the discriminator often adopts the Instance Normalization normalization layer. When the enhanced network model adopting the Instance Normalization normalization layer is deployed on the terminal device for actual testing, it is tested that the model has errors in the data finally generated. Since the InstanceNormalization normalization layer calculates the mean and variance for each channel of each sample separately, it is greatly affected by the sample, resulting in that the dynamic range of the input and output may vary greatly, and quantization usually assumes that the dynamic range of the data is relatively fixed, so it is difficult to accurately represent the output of the Instance Normalization normalization layer, resulting in a serious loss of quantization accuracy, which in turn leads to errors in the data finally generated by the model.
[0036] In the present invention, by replacing the Instance Normalization normalization layer with the BatchNormalization normalization layer, the quantization accuracy loss of the model when deployed on the terminal device is effectively reduced, and the occurrence of erroneous data generated by the model is avoided. When the enhanced network model using the Batch Normalization normalization layer is deployed on the terminal device for actual testing, the generated data of the model is tested to be correct, ensuring the reliability of the model when deployed on the terminal device.
[0037] After the model is determined, the QR code images in the third QR code dataset are input into the enhanced network model in pairs according to the version for training, and the standard QR code grid of the corresponding version is input at the same time as the prior knowledge to guide the denoising and deblurring process, so as to obtain the parameter weights under the corresponding version. More specifically, based on the grid nature of the QR code, the grid structure is introduced as a geometric constraint to force the generated modules to be strictly aligned, effectively suppressing the edge distortion and shape displacement caused by motion blur, and ensuring that the reconstructed image meets the standard coding specifications. Secondly, the grid prior significantly optimizes the training efficiency by limiting the solution space dimension. The model does not need to traverse all pixel combinations, but focuses on the reasonable distribution that conforms to the logical structure of the QR code, which effectively improves the parameter convergence speed. More importantly, the grid template has adaptive error correction capabilities: when a local module is damaged, the network can infer the color distribution of the missing area based on the topological relationship of the adjacent modules, and intelligently complete the information combined with the redundant characteristics of the code, while maintaining visual coherence and improving decodability.
[0038] In the training process of each version, the structural similarity measurement value SSIM between the enhanced two-dimensional code image and the original two-dimensional code image is verified, and the calculated structural similarity measurement value SSIM is compared with the set structural similarity measurement value threshold. In the present invention, the structural similarity measurement value threshold is set to 0.7, and the threshold is determined based on multiple experimental verifications. When the structural similarity measurement value SSIM between the enhanced two-dimensional code image and the original two-dimensional code image is greater than or equal to 0.7 and less than 1, the enhanced two-dimensional code image can be decoded and recognized; when the structural similarity measurement value SSIM between the enhanced two-dimensional code image and the original two-dimensional code image is less than 0.7, the enhanced two-dimensional code image cannot be decoded and recognized, so the structural similarity measurement value threshold can be set to 0.7.
[0039] The calculation formula of the structural similarity measure SSIM is as follows: SSIM(x,y)=(2*μx*μy+C1)*(2*σxy+C2) / (μx^2+μy^2+C1)*(σx^2+σy^2+C2) Among them, x and y are the two images to be compared, μx and μy represent the means of the two images, σx^2 and σy^2 represent the variances of the two images, σxy represents the covariance of the two images, and C1 and C2 are constants used to avoid the situation where the denominator is 0. The value of the constant varies according to the color range. Generally, C1=(K1*L)^2, C2=(K2*L)^2, where L is the range of pixel values, L-1 is the maximum pixel value, and K1 and K2 are constants less than 1.
[0040] If the structural similarity measure value SSIM is less than the set structural similarity measure value threshold, the parameter weight is adjusted, retraining is performed, and the next structural similarity measure value SSIM comparison is performed; if the structural similarity measure value SSIM is greater than or equal to the set structural similarity measure value threshold, the corresponding parameter weight data is recorded.
[0041] After completing the training of one version, replace the QR code with the QR code of the next version, and repeat the above training process until all versions are trained. Finally, keep a record of the weight parameters generated by the training to complete the model training.
[0042] In step S6, the trained enhanced network model performs noise reduction and deblurring on the received QR code. At the same time, the standard QR code grid is used to guide the noise reduction and deblurring process. Based on the grid nature of the QR code, the grid structure is introduced as a geometric constraint to force the generated modules to be strictly aligned and arranged, effectively suppressing the edge distortion and shape displacement caused by motion blur, and ensuring that the reconstructed image meets the standard coding specifications. Secondly, the grid prior significantly optimizes the training efficiency by limiting the dimension of the solution space. The model does not need to traverse all pixel combinations, but focuses on the reasonable distribution that conforms to the logical structure of the QR code, which effectively improves the parameter convergence speed. More importantly, the grid template has adaptive error correction capabilities: when a local module is damaged, the network can infer the color distribution of the missing area based on the topological relationship of the adjacent modules, and intelligently complete the information based on the redundant characteristics of the code, while maintaining visual coherence and improving decodability; wherein, the structural similarity measure SSIM between the enhanced QR code image and the original QR code image is greater than or equal to 0.7 and less than 0.1.
[0043] The enhanced image is clearer and can be identified by decoding. Finally, step S7 is performed to obtain the identification content of the QR code by inputting the enhanced QR code image into a QR code decoding library for decoding; the QR code decoding library can adopt the ZXing QR code decoding library.
[0044] The recognition effect of the two-dimensional code recognition method of the present invention has also been tested and compared with other existing public methods. The data is shown in the following table.
[0045] Table 1. Comparison of recognition rates of various QR code enhanced recognition methods method DeblurGAN DeblurGAN-v2 Method of the present invention Recognition rate (%) 35.79% 54.99% 94.00% The two-dimensional codes used to test the recognition rates of the methods in the above table are all skewed, out-of-focus, or motion-blurred two-dimensional codes; the test data is shown in the above table. At present, the existing public excellent enhanced recognition method is the method using the DeblurGAN-v2 model, and the recognition rate of this method is 54.99%. Compared with the method using the previous version of the DeblurGAN model, the recognition rate is indeed improved, but in actual scene applications, the recognition rate is still low, affecting customer use. The recognition rate of the method of the present invention is 94.00%, which is high, and the recognition rate is also significantly improved compared to the existing public method using the DeblurGAN-v2 model. The present invention has excellent processing and recognition capabilities for skewed, out-of-focus, and motion-blurred two-dimensional codes. Example 2
[0046] Reference Figure 2 This embodiment provides a two-dimensional code recognition device, including an image acquisition module, an image correction module, a two-dimensional code decoding module, a version prior module, and an image enhancement module.
[0047] The image acquisition module detects and determines the QR code in the target area. The target area can be the area that the camera can monitor when it is fixed in a certain position; the target area can also be the area that the camera can capture when the camera lens is handheld to shoot and scan the code. When there is a QR code in the target area, the QR code is locked and intercepted. During the interception process, the ISP exposure is automatically adjusted according to the scene environment to avoid overexposure of the image; if there is no QR code in the target area, the detection continues. The intercepted QR code is transmitted to the image correction module.
[0048] The image correction module uses the trained detection network model to quickly detect the QR code position of the received blurred QR code image, extract the QR code, and identify and mark the three corner points of the QR code.
[0049] After identifying and marking the three corner points of the QR code, the detection network model is used to rotate and deform the QR code. Specifically, a corresponding mapping relationship is established based on the three corner points of the marked QR code and the three corner points under the standard coordinates. The QR code image is corrected based on the mapping relationship to adjust the QR code to a square QR code in the correct orientation. The so-called correct orientation means that the three corner points of the QR code are respectively at the upper left, upper right, and lower left positions, and the QR code as a whole is not tilted. The adjusted square QR code is input into the QR code decoding module.
[0050] The QR code decoding module uses the ZXing QR code decoding library to decode the received QR code and obtain the identification content of the QR code; if it fails to decode the received QR code, it transmits the QR code to the version prior module and the image enhancement module.
[0051] The version prior module uses the trained prior network model to detect the QR code version of the adjusted Founder QR code. Since the model has been trained for blurred QR code images during training, the trained prior network model can quickly detect and identify the received blurred QR code images, and then generate the corresponding standard QR code grid based on the detected QR code version information, and input the corresponding standard QR code grid as prior knowledge into the image enhancement module.
[0052] The image enhancement module uses the trained enhancement network model to perform noise reduction and deblurring on the received QR code. At the same time, the standard QR code grid is used to guide the noise reduction and deblurring process. Based on the grid nature of the QR code, the grid structure is introduced as a geometric constraint to force the generated modules to be strictly aligned and arranged, effectively suppressing the edge distortion and shape displacement caused by motion blur, and ensuring that the reconstructed image meets the standard coding specifications. Secondly, the grid prior significantly optimizes the training efficiency by limiting the dimension of the solution space. The model does not need to traverse all pixel combinations, but focuses on the reasonable distribution that conforms to the logical structure of the QR code, which effectively improves the parameter convergence speed. More importantly, the grid template has adaptive error correction capabilities: when a local module is damaged, the network can infer the color distribution of the missing area based on the topological relationship of the adjacent modules, and intelligently complete the information based on the redundant characteristics of the code, while maintaining visual coherence and improving decodability; among them, the structural similarity measure SSIM between the enhanced QR code image and the original QR code image is greater than or equal to 0.7 and less than 1.
[0053] The enhanced QR code image is input into the QR code decoding module, and the ZXing QR code decoding library is used to decode the enhanced QR code image to obtain the identification content of the QR code.
[0054] The embodiments described above are merely descriptions of preferred implementations of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope of the present invention.
Claims
1. A two-dimensional code recognition method, characterized in that: The following steps are involved: S1. Detect whether there is a QR code in the target area, lock and intercept the QR code in the target area; S2. Use the detection network model to detect, extract and mark the intercepted QR code image, and identify and mark the three corner points of the QR code; S3. Calculate the perspective transformation matrix based on the identified corner points of the QR code to achieve QR code alignment; S4. Input the adjusted Founder QR code into the QR code decoding library for decoding. If it can be directly decoded, the identification content of the QR code is obtained; if the QR code cannot be decoded, it is input into the prior network model and the enhanced network model; S5. Use the prior network model to detect the QR code version of the adjusted Founder QR code, generate the corresponding standard QR code grid according to the detected QR code version information, and input the corresponding standard QR code grid as prior knowledge into the enhanced network model; S6. The enhanced network model performs noise reduction and deblurring processing on the received QR code. At the same time, the standard QR code grid is used to guide the noise reduction and deblurring process to achieve high-quality enhancement of the QR code. S7. Input the enhanced two-dimensional code image into a two-dimensional code decoding library for decoding, thereby obtaining the identification content of the two-dimensional code.
2. A two-dimensional code recognition method according to claim 1, characterized in that: The enhanced network model uses the DeblurGANv2 model, and the backbone network of this model uses the MobileNet lightweight network.
3. A two-dimensional code recognition method according to claim 1 or 2, characterized in that: The Batch Normalization layer is used in the enhanced network model.
4. A two-dimensional code recognition method according to claim 1, characterized in that: The detection network model uses the YOLOv8 model.
5. A two-dimensional code recognition method according to claim 1, characterized in that: The prior network model uses the MobileNetv2 model.
6. A two-dimensional code recognition method according to claim 1 or 2 or 4 or 5, characterized in that: It also includes a first two-dimensional code data set for training the detection network model, and the first two-dimensional code data set is obtained by the following steps: A first QR code data set for training is formed by shooting a QR code video and averaging consecutive short exposure frames to generate a blurred image; The two-dimensional code video contains multiple two-dimensional codes of different versions and dispersed and unfixed positions, and the detection network model is trained using the first two-dimensional code data set to obtain parameter weights.
7. A two-dimensional code recognition method according to claim 1 or 2 or 4 or 5, characterized in that: It also includes a second two-dimensional code data set for training the prior network model, and the second two-dimensional code data set is obtained by the following steps: A second QR code data set for training is formed by shooting a QR code video and averaging consecutive short exposure frames to generate a blurred image; The two-dimensional code video contains different versions of two-dimensional codes collected by version classification, and the two-dimensional code images in the second two-dimensional code data set are input into the prior network model for training according to the version to obtain the parameter weights under the corresponding version; Repeat the prior network model training process and use different versions of QR codes for training in turn to obtain the corresponding parameter weights under different versions.
8. A two-dimensional code recognition method according to claim 1, 2, 4 or 5, characterized in that: A third two-dimensional code data set for training the enhanced network model is also included, and the third two-dimensional code data set is obtained by the following steps: A fuzzy image is generated by shooting a QR code video and averaging consecutive short exposure frames, and the original QR code images constituting the QR code video are used as clear images, so that the two images are combined in pairs to form a third QR code data set for training; The two-dimensional code video contains different versions of two-dimensional codes collected by version classification. The two-dimensional code images in the third two-dimensional code data set are input into the enhanced network model in pairs according to the versions for training, and the standard two-dimensional code grid of the corresponding version is input at the same time to guide the denoising and deblurring process as prior knowledge to obtain the parameter weights under the corresponding version; Repeat the enhanced network model training process and use different versions of QR codes for training in turn to obtain the corresponding parameter weights under different versions.
9. A two-dimensional code recognition method according to claim 1, characterized in that: The structural similarity measurement value SSIM between the enhanced two-dimensional code image and the original two-dimensional code image is greater than or equal to 0.7 and less than 1.
10. A two-dimensional code recognition device, used to execute a two-dimensional code recognition method according to any one of claims 1 to 9, characterized in that: include: The image acquisition module detects and determines whether there is a QR code in the target area, and intercepts the QR code in the target area. During the interception process, the ISP exposure is automatically adjusted according to the scene environment, and the intercepted QR code is transmitted to the image correction module; The image correction module detects and extracts the QR code from the image, and performs processes such as rotation and deformation adjustment on the QR code, adjusts the QR code that is tilted at any angle and deformed to a square QR code in the correct position, and transmits the adjusted square QR code to the QR code decoding module; The QR code decoding module uses the ZXing QR code decoding library to decode the received QR code and obtain the identification content of the QR code; If it fails to decode the received QR code, it transmits the QR code to the version prior module and the image enhancement module; The version priori module performs a QR code version detection on the received QR code, generates a corresponding standard QR code grid according to the detected QR code version information, and inputs the corresponding standard QR code grid into the image enhancement module as priori knowledge; The image enhancement module performs noise reduction and deblurring processing on the received QR code. At the same time, the standard QR code grid is used to guide the noise reduction and deblurring process to achieve high-quality enhancement of the QR code. The structural similarity measurement value SSIM between the enhanced QR code image and the original QR code image is greater than or equal to 0.7 and less than 1. The enhanced QR code image is input into the QR code decoding module.
Citation Information
Patent Citations
Method for correcting image in 2D code of quick response matrix
CN101093543A
Two-dimensional code identification method, device and equipment
CN110046529A
Low-quality two-dimensional code information extraction method and device based on run length coding
CN112069852A
License plate deblurring detection method based on deep learning
CN113111859A
Certificate character recognition method and device, computer and storage medium
CN114359923A
Cited By
Product information input method and system based on image recognition
CN120356066A
Brightness parameter debugging method and system in decoding scene
CN120996059A