Two-dimensional code image recognition method based on boundary completion and uncertainty modeling

By using technologies such as edge gradient analysis and rotational equivariant convolution, combined with the global attention mechanism and normal distribution model, the problems of cropping, rotation and annotation deviation in QR code image recognition in complex environments are solved, achieving efficient and robust recognition results.

CN120706451APending Publication Date: 2025-09-26FUZHOU UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510795527.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-13
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

Existing QR code image recognition methods have difficulty effectively handling cropping, rotation, and annotation deviations in complex environments, and lack robustness, especially in high-uncertainty scenarios.

Method used

Edge gradient analysis is used to detect the cropped area and generate a mask. Deformable convolution is used to generate enhanced features. Rotation-independent features are extracted by combining rotation equivariant convolution. The global attention mechanism is applied to correct the angle of the detection frame. Finally, a normal distribution model is constructed through a multi-layer perceptron to optimize the recognition results.

Benefits of technology

The accuracy and robustness of QR code recognition have been improved, and it can achieve accurate recognition in scenarios of cropping, rotation and annotation deviation, reduce interference from mislabeling, and adapt to complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120706451A_ABST
    Figure CN120706451A_ABST
Patent Text Reader

Abstract

The invention relates to a two-dimensional code image recognition method based on boundary completion and uncertainty modeling, and belongs to the field of computer vision. The method comprises the following steps: firstly, acquiring an input two-dimensional code image, detecting a cutting area through gray level conversion and edge gradient analysis, complementing the cutting area by utilizing a generative network, and generating enhanced features by adopting deformable convolution; and then extracting rotation irrelevant features through rotation isovariant convolution, fusing spatial information by applying a global attention mechanism, and correcting the angle of a detection frame based on a positioning mark. Secondly, extracting semantic features of candidate areas, calculating similarity with a standard template to generate semantic scores, detecting positioning mark angle distribution to generate geometric constraint scores, and adjusting candidate box confidence; and finally, establishing a confidence coefficient normal distribution model through the multi-layer perception mechanism, calculating a high confidence interval probability, constructing combined loss including classification, positioning, confidence coefficient and uncertainty loss, optimizing the model according to specified parameters, and storing the optimal model to obtain a two-dimensional code recognition result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision, and in particular relates to a two-dimensional code image recognition method based on boundary completion and uncertainty modeling. Background Art

[0002] In recent years, QR code image recognition has attracted widespread attention in the field of computer vision, with significant application value in mobile payments, logistics management, and identity verification. As an efficient information carrier, QR codes can quickly transmit data and are widely used in daily life and industrial scenarios. However, the task of QR code image recognition faces numerous challenges, particularly in complex environments, where the recognition process is susceptible to factors such as image cropping, rotation angle changes, and annotation errors. These issues significantly increase the difficulty of recognition and have become a key research focus in academia and industry.

[0003] Unlike general image recognition tasks, QR code image recognition is unique in that: (1) QR code images typically have a fixed black-and-white module structure, but in real-world scenarios, they may be cropped, occluded, or blurred, resulting in missing information in key areas; (2) complex environmental interference, such as lighting changes, background clutter, or image rotation, can lead to significant differences between samples within a class and make it more difficult to distinguish features between classes. In addition, due to the potential for bias in the labeled data, model predictions can be easily misleading, further exacerbating the complexity of recognition.

[0004] Benefiting from the powerful feature extraction capabilities of deep neural networks, significant progress has been made in tasks such as image classification, object detection, and image segmentation. Among them, the QR code recognition method based on convolutional neural networks has performed well in standard scenarios. In recent years, technologies such as convolution and attention mechanisms have been introduced into the QR code detection task, enhancing the model's adaptability to complex backgrounds. However, existing methods still face limitations when dealing with cropped images, changes in rotation angles, and annotation errors. Traditional methods often rely on fixed feature extraction strategies and are difficult to effectively deal with information loss or environmental interference, especially in high-uncertainty scenarios, where the model's robustness is insufficient. Therefore, proposing a QR code recognition method that can complete boundaries, correct rotations, and model uncertainty has become a technical need that needs to be urgently addressed. Summary of the Invention

[0005] The purpose of the present invention is to provide a two-dimensional code image recognition method based on boundary completion and uncertainty modeling, which can effectively handle the two-dimensional code image recognition problems of cropping, rotation and annotation deviation.

[0006] To achieve the above objectives, the technical solution of the present invention is: a two-dimensional code image recognition method based on boundary completion and uncertainty modeling, comprising:

[0007] Get the input QR code image, detect the QR code cropping area through grayscale conversion and edge gradient analysis, use the generative network to complete the cropping area, and use deformable convolution to generate enhanced features;

[0008] Rotation-independent features are extracted through rotation-equivariant convolution, spatial information is fused using a global attention mechanism, and the angle of the detection frame is corrected based on positioning markers.

[0009] Extract semantic features of candidate regions, calculate similarity with standard templates to generate semantic scores, detect the angle distribution of positioning markers to generate geometric constraint scores, and adjust the confidence of candidate boxes;

[0010] A confidence normal distribution model is constructed through a multi-layer perceptron, the probability of a high confidence interval is calculated, a combined loss including classification, positioning, confidence and uncertainty losses is constructed, the model is optimized according to the specified parameters, the optimal model is saved, and the QR code recognition result is obtained.

[0011] The present invention also provides a two-dimensional code image recognition system based on boundary completion and uncertainty modeling, including a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, it can implement any of the method steps described above.

[0012] The present invention also provides a computer-readable storage medium on which computer program instructions that can be executed by a processor are stored. When the processor executes the computer program instructions, any of the method steps described above can be implemented.

[0013] The present invention also provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes any of the method steps described above.

[0014] The present invention also provides a computer program product, comprising a computer program, wherein the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform any of the method steps described above.

[0015] Compared with the prior art, the present invention has the following beneficial effects:

[0016] 1. The present invention constructs a QR code image recognition method based on boundary completion and uncertainty modeling. It detects the cropped area and generates a mask through edge gradient analysis, uses neighborhood pixel features to complete the missing part, combines deformable convolution to generate enhanced features, and adjusts the confidence level through the intersection of the bounding box and the mask to accurately update the detection box parameters.

[0017] 2. The present invention uses rotation-equivariant convolution to generate rotation-independent features, combines the global attention mechanism to fuse spatial information, calculates the rotation angle by locating the marker coordinates to correct the geometric coordinates of the detection frame, and only requires a small amount of annotation to achieve angle adaptation. At the same time, random rotation and translation are used to enhance model training.

[0018] 3. The present invention generates a semantic score by calculating the cosine similarity with the standard template, detects the positioning mark and analyzes the angle distribution to generate a geometric constraint score, combines the mean and variance of the multi-layer perceptron prediction confidence to construct a normal distribution model, calculates the confidence probability, and through the combined optimization of classification, positioning and uncertainty loss, can reduce the interference of mislabeling to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 Flow chart of the method of the present invention. DETAILED DESCRIPTION

[0020] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings.

[0021] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present application belongs.

[0022] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.

[0023] The present invention provides a two-dimensional code image recognition method based on boundary completion and uncertainty modeling, comprising:

[0024] Get the input QR code image, detect the QR code cropping area through grayscale conversion and edge gradient analysis, use the generative network to complete the cropping area, and use deformable convolution to generate enhanced features;

[0025] Rotation-independent features are extracted through rotation-equivariant convolution, spatial information is fused using a global attention mechanism, and the angle of the detection frame is corrected based on positioning markers.

[0026] Extract semantic features of candidate regions, calculate similarity with standard templates to generate semantic scores, detect the angle distribution of positioning markers to generate geometric constraint scores, and adjust the confidence of candidate boxes;

[0027] A confidence normal distribution model is constructed through a multi-layer perceptron, the probability of a high confidence interval is calculated, a combined loss including classification, positioning, confidence and uncertainty losses is constructed, the model is optimized according to the specified parameters, the optimal model is saved, and the QR code recognition result is obtained.

[0028] The following is a specific implementation process of the present invention.

[0029] like Figure 1 As shown, this embodiment provides a two-dimensional code image recognition method based on boundary completion and uncertainty modeling, which specifically includes the following steps:

[0030] Step S1: Detect the QR code cropping area through edge gradient analysis and generate a cropping mask; use the neighborhood pixel features to complete the cropping area; use deformable convolution to generate enhanced features; adjust the confidence level based on the intersection-over-union ratio of the bounding box and the mask, and update the detection box parameters;

[0031] Step S2: Generate rotation-independent features through rotation-equivariant convolution; use global attention mechanism to fuse spatial information; use random rotation and translation to enhance model training; calculate the rotation angle based on the positioning marker coordinates and correct the detection box geometric coordinates;

[0032] Step S3: Extract the black and white module features of the candidate area and generate a semantic feature vector; calculate the cosine similarity with the standard template to generate a semantic score; detect the positioning mark, calculate the angle distribution, and generate a geometric constraint score; adjust the confidence level based on the semantic and geometric scores and update the prediction parameters;

[0033] Step S4: Use a multi-layer perceptron to predict the mean and variance of the candidate box confidence, build a normal distribution model, and calculate the confidence probability; construct a combined loss including classification, positioning, and uncertainty loss, and optimize the model parameters.

[0034] In this embodiment, step S1 specifically includes the following steps:

[0035] Step S11, edge gradient analysis and cropping area detection, using the input two-dimensional code image data set, pre-processing to extract pixel intensity information; in , calculate the grayscale image I gry , through parameterized weighted fusion of red, green, and blue channels; the specific calculation method is as follows:

[0036] I gry (x g ,y g )=α R I in (x g ,y g ,1)+α G I in (xg ,y g ,2)+α B I in (x g ,y g ,3)

[0037] where α R ,α G ,α B is an adjustable weight based on the brightness perception standard, satisfying the constraints: α R +α G +α B =1;x g Represents the horizontal position of the image pixel, y g Represents the vertical position of the image pixel;

[0038] Apply the Sobel operator to calculate the horizontal gradient G x and vertical gradient G y , generate edge intensity feature map E edg ∈R H×W The specific calculation method is as follows:

[0039]

[0040] Among them, (x h ,y h ),(x v ,y v ) represent the pixel coordinates of the selected area; K hor ,K ver Represent the horizontal convolution kernel and the vertical convolution kernel respectively; (i h ,j h ),(i v ,j v ) represent K hor ,K ver The relative index of the edge intensity feature map E edg Input convolutional network f edg , where f edg Contains two 3x3 convolutional layers with channel numbers from 1 to 64 and 64 to 1 respectively, and the activation function is ReLU to generate the cropping probability P cut The specific calculation method is as follows:

[0041]

[0042] f edg (E edg )=W edg2 ·(W edg1 ·E edg +b edg1 )+b edg2

[0043] in and b edg1 、b edg2 are the weights and biases of the convolutional layer; (x p,cut ,y p,cut ) is the clipping probability map P cut The pixel coordinates of

[0044] Step S12: context feature extraction and cropping area completion, based on the cropping probability P generated in step S11 cut , through the threshold θ cut = 0.8 to generate a binary mask M cut ∈0,1, where the cropped area corresponds to 0 and the non-cropped area corresponds to 1; the input image I in With mask M cut Multiply to get the mask image I msk =I in ⊙M cut ; Through the convolutional network f cxt Extract context features C cxt , where f cxt Contains three 3x3 convolutional layers; the specific calculation method is as follows:

[0045] C cxt (x cxt ,y cxt )=f cxt (I msk )

[0046] f cxt =W cxt3 ReLU(W cxt2 ReLU(W cxt1 I msk +b cxt1 )+b cxt2 )+b cxt3

[0047] Where W cxt1 ∈R 3×3×3×64 、W cxt2 ∈R 3×3×64×64 、W cxt3 ∈R 3×3×64×64 and b cxt1 、b cxt2 、b cxt3 are weights and biases; (x cxt ,y cxt ) is the context feature map C cxt The pixel coordinates of

[0048] The mask image I msk and contextual features C cxtInput generation network g gen , where g gen A five-layer U-Net structure is used, including skip connections, to generate the feature map of the completed region I cmp The specific calculation method is as follows:

[0049] I cmp (x rec ,y rec )=g gen (I msk ,C cxt ;W gen )

[0050] Where W gen is the U-Net network parameter; (x rec ,y rec ) is the completed region feature map I cmp The pixel coordinates of

[0051] Step S13: Completion region feature map I generated in step S12 cmp Input the backbone network and extract the initial feature map F in , where F in The module from the third layer of the backbone network is 4 times the size of the input image downsampled; cmp Input blur estimation network f blr , where f blr Contains two 3x3 convolutional layers with channel numbers from 3 to 32 and from 32 to 1, generating the blur scalar σ blr ∈R; the specific calculation method is as follows:

[0052] σ blr =ReLU(W blr2 *ReLU(W blr1 *I cmp +b blr1 )+b blr2 )

[0053] W blr1 ∈R 3×3×3×32 、W blr2 ∈R 3×3×32×1 and b blr1 、b blr2 are weights and biases; ReLU is a nonlinear activation function in neural networks;

[0054] F in and σ blr Input deformable convolutional network f def , where f def Contains a 3×3 convolution layer with 256 channels to generate an enhanced feature map F enh The specific calculation method is as follows:

[0055]

[0056] where w def (k enh ,l enh )∈R (3×3×256×256) is the convolution kernel weight, is the offset, f off is a 1x1 convolutional layer; (x enh ,y enh ) is the enhanced feature map F enh Pixel coordinates of k enh ,l enh is the relative index of the 3x3 convolution kernel; W off is the bias convolution weight;

[0057] Step S14, bounding box confidence adjustment and loss calculation, based on the cropping mask M in step S12 cut , the bounding box B generated by the backbone network detection head det ={x det ,y det ,w det ,h det ,p det}Calculate and mask M cut Intersection over Union (IoU) cut , where x det ,y det represents the center coordinates of the bounding box, w det ,h det Indicates width and height, p det ∈[0,1] represents the confidence level; the specific calculation method is as follows:

[0058]

[0059] Among them, x box ,y box is the bounding box B det The pixel coordinates within; use the intersection-over-union ratio to adjust the confidence and generate the adjusted confidence p adj The specific calculation method is as follows:

[0060]

[0061] Among them, i box represents the order of bounding boxes, represents the adjusted confidence of the i-th bounding box, Represents the true confidence, which comes from the training set annotation.

[0062] In this embodiment, step S2 specifically includes the following steps:

[0063] Step S21, rotation equivariant convolution feature extraction, build a rotation equivariant convolution module, and use the enhanced feature map F generated in step S13 enh As input, generate feature representation F that is independent of the rotation angle rot ; Considering the computational efficiency, the feature map F enh Input rotation equivariant convolution layer f rot , where f rot Contains a 3x3 convolution kernel, generating corresponding features for the rotation group G = 0°, 90°, 180°, 270°; the specific calculation method is as follows:

[0064]

[0065] where w rot (k rot ,l rot ,g)∈R 3×3×256×256 To rotate a specific convolution kernel weight, Indicates the inverse rotation transformation; (x rot ,y rot ) is F rot The pixel coordinates at a specific rotation angle; k rot ,l rot is the relative index of 3x3 convolution, g represents 4 rotation angles; F rot Each rotation branch of merge Compression, generating fusion feature F fus The specific calculation method is as follows:

[0066] F fus (x fus ,y fus )=f merge (F rot (x fus ,y fus ,:);W merge )

[0067] Where W merge is the 1x1 convolution weight; (x fus ,y fus ) is the fusion feature F fus The pixel coordinates of

[0068] Step S22: Global attention feature fusion, using the global attention module to act on the fusion feature F generated in step S21 fus , generate enhanced features F att , to fuse global spatial information; calculate query Q att , key K att , value V att, weighted features through the attention mechanism; the specific calculation method is as follows:

[0069]

[0070] Among them, the enhanced feature F att Retain the original information and fuse the global context through residual connections; d k is the length of the vector; x att ,y att It's F att The pixel coordinates of x key ' ,y key ' Yes key K att The pixel coordinates of x val ”,y val " is the value V att The pixel coordinates of

[0071] Step S23: Generate rotation-enhanced training data using the enhanced feature F from step S22 att Drive rotation enhancement training to generate a series of image samples with rotation and position transformations; based on the input image I in , applying a random rotation angle θ aug ∈[0,360°] and random translation (t x ,t y ), generate enhanced image I aug The specific calculation method is as follows:

[0072]

[0073] Among them, x aug ,y aug They are enhanced images I aug The horizontal and vertical coordinates of x aug ,y aug The enhanced image I aug Input the backbone network to generate enhanced features F aug , and F att Calculate the consistency loss L aug The specific calculation method is as follows:

[0074]

[0075] Among them F aug and F att represents the enhanced and original features, and the loss is based on the mean square error; x loss ,y loss is the pixel coordinate where the loss is calculated; H loss is the feature map F aug ,F att Height, Wloss is the feature map F aug ,F att width;

[0076] Step S24: Positioning mark angle correction, using the enhanced feature F of step S22 att , detect the coordinates of the QR code positioning marker Generate rotation angle estimates and correct bounding boxes; pass keypoint detection network f key , where f key Contains two 3x3 convolutional layers to predict the marker coordinates P i The specific calculation method is as follows:

[0077] [P1,P2,P3]=f key (F att ;W key1 ,W key2 ),W key1 ∈R 3×3×256×128 ,W key2 ∈R 3×3×128×6

[0078] Among them, W key1 is the weight of the first 3x3 convolutional layer, W key2 is the weight of the second 3x3 convolutional layer; calculate the rotation angle θ est , based on marker coordinates and template coordinates The specific calculation method is as follows:

[0079]

[0080] Among them, θ mrk is the rotation angle variable; are the predicted marker coordinates; is the real positioning mark coordinate; for the detection frame B det ={x det ,y det ,w det ,h det ,p det}Apply angle correction to generate correction frame B adj The specific calculation method is as follows:

[0081]

[0082] in, From the standard QR code template.

[0083] In this embodiment, step S3 specifically includes the following steps:

[0084] Step S31: Calculate the bounding box B generated in step S14det ={x det ,y det ,w det ,h det ,p det} The corresponding semantic features of the cropped area; the candidate area image I output by the backbone network detection head box As input, through the convolutional network f sem Generate semantic features F sem ; The center of the reference region is determined by the bounding box center coordinates (x ctr ,y ctr ) is determined, and the specific calculation method is as follows:

[0085] (x ctr ,y ctr )=center(B det )

[0086] The candidate region image I box Input convolutional network f sem , where f sem Contains three 3x3 convolutional layers to generate semantic feature maps F sem The specific calculation method is as follows:

[0087] F sem (x sem ,y sem )=f sem (I box ;W sem1 ,W sem2 ,W sem3 )

[0088] f sem =W sem3 ReLU(W sem2 ReLU(W sem1 I box +b sem1 )+b sem2 )+b sem3

[0089] Among them, W sem1 ∈R 3×3×3×64 、W sem2 ∈R 3×3×64×64 、W sem3 ∈R 3×3×64×64 and b sem1 、b sem2 、b sem3 are weights and biases; x sem ,y sem is the semantic feature map F sem The pixel coordinates of

[0090] Fsem Perform global average pooling to generate semantic feature vector V sem ∈R 64 The specific calculation method is as follows:

[0091]

[0092] Among them, h box , w box They are semantic feature maps F sem The height and width of x pool ,y pool is the pixel position traversal of average pooling;

[0093] Step S32: Construct a semantic verification template based on the semantic feature vector V in step S31. sem , calculation and standard QR code template T qr ∈R 64 The matching score of T qr Obtained by averaging the standard QR code features in the training set; V sem With T qr Calculate cosine similarity and generate semantic score S qr The specific calculation method is as follows:

[0094]

[0095] in represents the i-th component of the corresponding eigenvector, S qr ∈[-1,1]; through the fully connected layer f score S qr Convert to normalized score S norm ∈(0,1), the specific calculation method is as follows:

[0096]

[0097] Where σ represents the sigmoid function; the semantic score S nrm Indicates the semantic similarity between the candidate region and the QR code template; W scr is the weight of the scoring function; b scr is the bias of the scoring function;

[0098] Step S33: predict the geometric features of the positioning markers of the candidate area in step S31 based on the enhanced feature map F enh ; Through the key point detection network f geo , predict the coordinates Q of the three positioning markers loc,i =(u loc,i ,v loc,i ), i=1,2,3, where f geoContains two 3x3 convolutional layers; the specific calculation method is as follows:

[0099] [Q loc,1 ,Q loc,2 ,Q loc,3 ]=f geo (F enh ;W geo1 ,W geo2 )

[0100] f geo =W geo2 ReLU(W geo1 ·F enh +b geo1 )+b geo2

[0101] in and b geo1 、b geo2 are weights and biases;

[0102] Calculate the angle between markers The specific calculation method is as follows:

[0103]

[0104] Angle-based and template-based The difference between the two generates the geometric constraint score G geo ∈(0,1]; the specific calculation method is as follows:

[0105]

[0106] Among them, λ aug is the regularization coefficient of the geometric constraint; is the predicted location marker pair i aug ,j aug The angle between Is the real positioning mark pair i aug ,j aug The angle between

[0107] Step S34: Calculate the verification loss function L ver , including semantic loss L sem and geometric loss L geo ; The semantic loss is based on the normalized score S in step S32 nrm and the true label y qr The mean square error of ∈0,1 is calculated as follows:

[0108]

[0109] Among them, N sem is the number of candidate regions, represents the score and label of the kth region; the geometric loss is based on the constraint score G in step S33 geo and the true label y qr , the specific calculation method is as follows:

[0110]

[0111] in, is the kth geo The geometric constraint score of the samples; is the kth geo The true labels of samples; N geo is the total number of samples;

[0112] In this embodiment, step S4 specifically includes the following steps:

[0113] Step S41: Based on the semantic feature vector V_{"{sem}} generated in step S31, the multi-layer perceptron f unc Predict the statistical characteristics of the candidate box confidence and generate the mean μ pr and log variance These parameters define the normal distribution of the confidence of each candidate box, which is used for subsequent uncertainty analysis; the network f unc Contains two fully connected layers; the specific calculation method is as follows:

[0114]

[0115] f unc =W unc2 ReLU(W unc1 ·V sem +b unc1 )+b unc2

[0116] in, and are weights and biases;

[0117] Step S42: Variance Calculated by exponential function, the specific method is as follows:

[0118]

[0119] Candidate box confidence p pr Normal distribution The confidence level of the prediction is:

[0120] p final =μ pr +∈ pr ·σ pr

[0121] in,

[0122] Step S43: Calculate the confidence level p using the normal distribution generated in step S41. pr Exceeding the threshold θ pr = 0.95 probability P pr , reflecting the credibility of the candidate box being a QR code; probability P pr It is determined by the cumulative function of the normal distribution, which is calculated as follows:

[0123]

[0124] Where Φ is the cumulative function of the standard normal distribution, μ pr,k ,σ pr,k is the mean and standard deviation of the k-th candidate box; is the kth pr The confidence score of the candidate box; Indicates the kth pr The confidence of the candidate box Exceeding the threshold θ pr The probability threshold θ pr =0.95 probability

[0125] Step S44: To optimize the model, define the loss function L unc , based on the probability P in step S42 pr and variance Balancing the reliability and uncertainty scale of confidence predictions; the loss function combines the logarithm of the probability and the regularization term of the variance, and is calculated as follows:

[0126]

[0127] Among them, N unc is the number of candidate boxes, P pr,k By numerical stabilization, a small constant ∈=10 is added. -6 make sure Computable; loss function encourages the model to improve confidence probability Controlling variance at the same time Not too large to cope with the uncertainty in complex scenarios.

[0128] In particular, this embodiment only requires positioning marker coordinates, without the need for additional angle or bounding box annotations. In view of the uniqueness of the two-dimensional code image recognition task, the present invention makes full use of the semantic features of the black and white modules and the geometric constraints of the positioning markers, reduces the interference of mislabeling through semantic and geometric verification, and combines the normal distribution model to predict the confidence probability, which can effectively deal with the uncertainty in complex scenarios. In response to the problem of information loss caused by cropping and rotation, the present invention extracts enhanced features and irrelevant features through boundary completion and rotation correction, combines the global attention mechanism to fuse spatial information, and provides a stable recognition basis. A two-dimensional code image recognition method based on boundary completion and uncertainty modeling constructed by the present invention can effectively realize two-dimensional code recognition in cropping, rotation and mislabeling scenarios, and meet the needs of diverse applications.

[0129] The present invention also provides a two-dimensional code image recognition system based on boundary completion and uncertainty modeling, including a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, it can implement any of the method steps described above.

[0130] The present invention also provides a computer-readable storage medium on which computer program instructions that can be executed by a processor are stored. When the processor executes the computer program instructions, any of the method steps described above can be implemented.

[0131] The present invention also provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes any of the method steps described above.

[0132] The present invention also provides a computer program product, comprising a computer program, wherein the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform any of the method steps described above.

[0133] The above are preferred embodiments of the present invention. Any changes made according to the technical solution of the present invention, as long as the resulting functions and effects do not exceed the scope of the technical solution of the present invention, shall fall within the scope of protection of the present invention.

Claims

1. A two-dimensional code image recognition method based on boundary completion and uncertainty modeling, characterized in that: include: Get the input QR code image, detect the QR code cropping area through grayscale conversion and edge gradient analysis, use the generative network to complete the cropping area, and use deformable convolution to generate enhanced features; Rotation-independent features are extracted through rotation-equivariant convolution, spatial information is fused using a global attention mechanism, and the angle of the detection frame is corrected based on positioning markers. Extract semantic features of candidate regions, calculate similarity with standard templates to generate semantic scores, detect the angle distribution of positioning markers to generate geometric constraint scores, and adjust the confidence of candidate boxes; A confidence normal distribution model is constructed through a multi-layer perceptron, the probability of a high confidence interval is calculated, a combined loss including classification, positioning, confidence and uncertainty losses is constructed, the model is optimized according to the specified parameters, the optimal model is saved, and the QR code recognition result is obtained.

2. A two-dimensional code image recognition method based on boundary completion and uncertainty modeling according to claim 1, characterized in that: The method comprises the following steps: Step S1: Detect the QR code cropping area through edge gradient analysis and generate a cropping mask; use neighborhood pixel features to complete the cropping area; use deformable convolution to generate enhanced features; adjust the confidence level based on the intersection-over-union ratio of the bounding box and the mask, and update the detection box parameters; Step S2: Generate rotation-independent features through rotation equivariant convolution; Use global attention mechanism to fuse spatial information; use random rotation and translation to enhance model training; calculate the rotation angle based on the positioning marker coordinates and correct the detection box geometric coordinates; Step S3: extract black and white module features of the candidate area and generate a semantic feature vector; calculate Generate semantic scores by comparing cosine similarity with standard templates; detect positioning markers, calculate angle distribution, and generate geometric constraint scores; adjust confidence levels based on semantic and geometric scores and update prediction parameters; Step S4: Use a multi-layer perceptron to predict the mean and variance of the candidate box confidence, build a normal distribution model, and calculate the confidence probability; construct a combined loss including classification, positioning, and uncertainty loss, and optimize the model parameters.

3. The two-dimensional code image recognition method based on boundary completion and uncertainty modeling according to claim 2, characterized in that: Step S1 is specifically implemented as follows: Step S11, edge gradient analysis and cropping area detection, using the input two-dimensional code image data set, pre-processing to extract pixel intensity information; in , calculate the grayscale image I gry , through parameterized weighted fusion of red, green, and blue channels; the specific calculation method is as follows: I gry (x g ,y g )=α R ·I in (x g ,y g ,1)+α G ·I in (x g ,y g ,2)+α B ·I in (x g ,y g ,3) where α R ,α G ,α B is an adjustable weight based on the brightness perception standard, satisfying the constraints: α R +α G +α B =1;x g Represents the horizontal position of the image pixel, y g Represents the vertical position of the image pixel; Apply the Sobel operator to calculate the horizontal gradient G x and vertical gradient G y , generate edge intensity feature map E edg ∈R H×W The specific calculation method is as follows: Among them, (x h ,y h ),(x v ,y v ) represent the pixel coordinates of the selected area; K hor ,K ver Represent the horizontal convolution kernel and the vertical convolution kernel respectively; (i h ,j h ),(i v ,j v ) represent K hor ,K ver The relative index of the edge intensity feature map E edg Input convolutional network f edg , where f edg Contains two 3x3 convolutional layers with channel numbers from 1 to 64 and 64 to 1 respectively, and the activation function is ReLU to generate the cropping probability P cut The specific calculation method is as follows: f edg (E edg )=W edg2 ·(W edg1 ·E edg +b edg1 )+b edg2 in and b edg1 、b edg2 are the weights and biases of the convolutional layer; (x p,cut ,y p,cut ) is the clipping probability map P cut The pixel coordinates of Step S12: context feature extraction and cropping area completion, based on the cropping probability P generated in step S11 cut , through the threshold θ cut = 0.8 to generate a binary mask M cut ∈0,1, where the cropped area corresponds to 0 and the non-cropped area corresponds to 1; the input image I in With mask M cut Multiply to get the mask image I msk =I in ⊙M cut ; Through the convolutional network f cxt Extract context features C cxt , where f cxt Contains three 3x3 convolutional layers; the specific calculation method is as follows: C cxt (x cxt ,y cxt )=f cxt (I msk ) f cxt =In cxt3 ·ReLU(W cxt2 ·ReLU(W cxt1 ·AND msk +b cxt1 )+b cxt2 )+b cxt3 Where W cxt1 ∈R 3×3×3×64 、W cxt2 ∈R 3×3×64×64 、W cxt3 ∈R 3×3×64×64 and b cxt1 、b cxt2 、b cxt3 are weights and biases; (x cxt ,y cxt ) is the context feature map C cxt The pixel coordinates of The mask image I msk and contextual features C cxt Input generation network g gen , where g gen A five-layer U-Net structure is used, including skip connections, to generate the feature map of the completed region I cmp The specific calculation method is as follows: I cmp (x rec ,y rec )=g gen (I msk ,C cxt ;W gen ) Where W gen is the U-Net network parameter; (x rec ,y rec ) is the completed region feature map I cmp The pixel coordinates of Step S13: Completion region feature map I generated in step S12 cmp Input the backbone network and extract the initial feature map F in , where F in The module from the third layer of the backbone network is 4 times the size of the input image downsampled; cmp Input blur estimation network f blr , where f blr Contains two 3x3 convolutional layers with channel numbers from 3 to 32 and from 32 to 1, generating the blur scalar σ blr ∈R; the specific calculation method is as follows: σ blr =ReLU(W blr2 *ReLU(W blr1 *AND cmp +b blr1 )+b blr2 ) W blr1 ∈R 3×3×3×32 、W blr2 ∈R 3×3×32×1 and b blr1 、b blr2 are weights and biases; ReLU is a nonlinear activation function in neural networks; F in and σ blr Input deformable convolutional network f def , where f def Contains a 3×3 convolution layer with 256 channels to generate an enhanced feature map F enh The specific calculation method is as follows: where w def (k enh ,l enh )∈R (3×3×256×256) is the convolution kernel weight, is the offset, f off is a 1x1 convolutional layer; (x enh ,y enh ) is the enhanced feature map F enh Pixel coordinates of k enh ,l enh is the relative index of the 3x3 convolution kernel; W off is the bias convolution weight; Step S14, bounding box confidence adjustment and loss calculation, based on the cropping mask M in step S12 cut , the bounding box B generated by the backbone network detection head det ={x det ,y det ,w det ,h det ,p det }Calculate and mask M cut Intersection over Union (IoU) cut , where x det ,y det represents the center coordinates of the bounding box, w det ,h det Indicates width and height, p det ∈[0,1] represents the confidence level; the specific calculation method is as follows: Among them, x box ,y box is the bounding box B det The pixel coordinates within; use the intersection-over-union ratio to adjust the confidence and generate the adjusted confidence p adj The specific calculation method is as follows: Among them, i box represents the order of bounding boxes, p adj,ibox represents the adjusted confidence of the i-th bounding box, Represents the true confidence, which comes from the training set annotation.

4. The method for two-dimensional code image recognition based on boundary completion and uncertainty modeling according to claim 3, characterized in that: Step S2 is specifically implemented as follows: Step S21, rotation equivariant convolution feature extraction, build a rotation equivariant convolution module, and use the enhanced feature map F generated in step S13 enh As input, generate feature representation F that is independent of the rotation angle rot ; Considering the computational efficiency, the feature map F enh Input rotation equivariant convolution layer f rot , where f rot Contains a 3x3 convolution kernel, generating corresponding features for the rotation group G = 0°, 90°, 180°, 270°; the specific calculation method is as follows: where w rot (k rot ,l rot ,g)∈R 3×3×256×256 To rotate a specific convolution kernel weight, rot g -1 Indicates the inverse rotation transformation; (x rot ,y rot ) is F rot The pixel coordinates at a specific rotation angle; k rot ,l rot is the relative index of 3x3 convolution, g represents 4 rotation angles; F rot Each rotation branch of merge Compression, generating fusion feature F fus The specific calculation method is as follows: F fus (x fus ,y fus )=f merge (F rot (x fus ,y fus ,:);W merge ) Where W merge is the 1x1 convolution weight; (x fus ,y fus ) is the fusion feature F fus The pixel coordinates of Step S22: Global attention feature fusion, using the global attention module to act on the fusion feature F generated in step S21 fus , generate enhanced features F att , to fuse global spatial information; Compute query Q att , key K att , value V att , weighted features through the attention mechanism; the specific calculation method is as follows: Among them, the enhanced feature F att Retain the original information and fuse the global context through residual connections; d k is the length of the vector; x att ,y att It's F att The pixel coordinates of x key ' ,y key ' Yes key K att The pixel coordinates of x val ” ,y val ” is the value V att The pixel coordinates of Step S23: Generate rotation-enhanced training data using the enhanced feature F from step S22 att Drive rotation enhancement training to generate a series of image samples with rotation and position transformations; based on the input image I in , applying a random rotation angle θ aug ∈[0,360°] and random translation (t x ,t y ), generate enhanced image I aug The specific calculation method is as follows: Among them, x aug ,y aug They are enhanced images I aug The horizontal and vertical coordinates of x aug ,y aug The enhanced image I aug Input the backbone network to generate enhanced features F aug , and F att Calculate the consistency loss L aug The specific calculation method is as follows: Among them F aug and F att represents the enhanced and original features, and the loss is based on the mean square error; x loss ,y loss is the pixel coordinate where the loss is calculated; H loss is the feature map F aug ,F att Height, W loss is the feature map F aug ,F att width; Step S24: Positioning mark angle correction, using the enhanced feature F of step S22 att , detect the coordinates of the QR code positioning mark P i = Generate rotation angle estimates and correct bounding boxes; pass keypoint detection network f key , where f key Contains two 3x3 convolutional layers to predict the marker coordinates P i The specific calculation method is as follows: [P1,P2,P3]=f key (F att ;W key1 ,W key2 ),W key1 ∈R 3×3×256×128 ,W key2 ∈R 3×3×128×6 Among them, W key1 is the weight of the first 3x3 convolutional layer, W key2 is the weight of the second 3x3 convolutional layer; calculate the rotation angle θ est , based on the marker coordinates and template coordinates P gt,igt The specific calculation method is as follows: Among them, θ mrk is the rotation angle variable; x mrk,imrk y mrk,imrk is the predicted marker coordinate; x gt,imrk y gt,imrk is the real positioning mark coordinate; for the detection frame B det ={x det ,y det ,w det ,h det ,p det }Apply angle correction to generate correction frame B adj The specific calculation method is as follows: Among them, P gt,igt From the standard QR code template.

5. The two-dimensional code image recognition method based on boundary completion and uncertainty modeling according to claim 4, characterized in that: Step S3 is specifically implemented as follows: Step S31: Calculate the bounding box B generated in step S14 det ={x det ,y det ,w det ,h det ,p det} The corresponding semantic features of the cropped area; the candidate area image I output by the backbone network detection head box As input, through the convolutional network f sem Generate semantic features F sem ; The center of the reference region is determined by the bounding box center coordinates (x ctr ,y ctr ) is determined, and the specific calculation method is as follows: (x ctr ,y ctr )=center(B det ) The candidate region image I box Input convolutional network f sem , where f sem Contains three 3x3 convolutional layers to generate semantic feature maps F sem The specific calculation method is as follows: F sem (x sem ,y sem )=f sem (I box ;W sem1 ,W sem2 ,W sem3 ) f sem =In sem3 ·ReLU(W sem2 ·ReLU(W sem1 ·AND box +b sem1 )+b sem2 )+b sem3 Among them, W sem1 ∈R 3×3×3×64 、W sem2 ∈R 3×3×64×64 、W sem3 ∈R 3×3×64×64 and b sem1 、b sem2 、b sem3 are weights and biases; x sem ,y sem is the semantic feature map F sem The pixel coordinates of F sem Perform global average pooling to generate semantic feature vector V sem ∈R 64 The specific calculation method is as follows: Among them, h box , w box They are semantic feature maps F sem The height and width of x pool ,y pool is the pixel position traversal of average pooling; Step S32: Construct a semantic verification template based on the semantic feature vector V in step S31. sem , calculation and standard QR code template T qr ∈R 64 The matching score of T qr Obtained by averaging the standard QR code features in the training set; V sem With T qr Calculate cosine similarity and generate semantic score S qr The specific calculation method is as follows: Where V sem,iqr ,T qr,iqr represents the i-th component of the corresponding eigenvector, S qr ∈[-1,1]; through the fully connected layer f score S qr Convert to normalized score S norm ∈(0,1), the specific calculation method is as follows: Where σ represents the sigmoid function; the semantic score S nrm Indicates the semantic similarity between the candidate region and the QR code template; W scr is the weight of the scoring function; b scr is the bias of the scoring function; Step S33: predict the geometric features of the positioning markers of the candidate area in step S31 based on the enhanced feature map F enh ; Through the key point detection network f geo , predict the coordinates Q of the three positioning markers loc,i =(u loc,i ,v loc,i ), i=1,2,3, where f geo Contains two 3x3 convolutional layers; the specific calculation method is as follows: [Q loc,1 ,Q loc,2 ,Q loc,3 ]=f geo (F enh ;W geo1 ,W geo2 ) f geo =In geo2 ·ReLU(W geo1 ·F enh +b geo1 )+b geo2 in and b geo1 、b geo2 are weights and biases; Calculate the angle γ between markers loc,iaug j aug ,i aug ,j aug ,k aug =1,2,3, the specific calculation method is as follows: Angle-based and template-based The difference between the two generates the geometric constraint score G geo ∈(0,1]; the specific calculation method is as follows: Among them, λ aug is the regularization coefficient of the geometric constraint; is the predicted location marker pair i aug ,j aug The angle between Is the real positioning mark pair i aug ,j aug The angle between Step S34: Calculate the verification loss function L ver , including semantic loss L sem and geometric loss L geo ; The semantic loss is based on the normalized score S in step S32 nrm and the true label y qr The mean square error of ∈0,1 is calculated as follows: Among them, N sem is the number of candidate regions, represents the score and label of the kth region; the geometric loss is based on the constraint score G in step S33 geo and the true label y qr , the specific calculation method is as follows: in, is the kth geo The geometric constraint score of the samples; is the kth geo The true labels of samples; N geo is the total number of samples; 6. The method for two-dimensional code image recognition based on boundary completion and uncertainty modeling according to claim 5, characterized in that: Step S4 is specifically implemented as follows: Step S41: Based on the semantic feature vector V_{"{sem}} generated in step S31, the multi-layer perceptron f unc Predict the statistical characteristics of the candidate box confidence and generate the mean μ pr and log variance These parameters define the normal distribution of the confidence of each candidate box, which is used for subsequent uncertainty analysis; the network f unc Contains two fully connected layers; the specific calculation method is as follows: f unc =In unc2 ·ReLU(W unc1 ·V sem +b unc1 )+b unc2 in and are weights and biases; Step S42: Variance Calculated by exponential function, the specific method is as follows: Candidate box confidence p pr Normal distribution The confidence level of the prediction is: p final =μ pr +∈ pr ·s pr in, Step S43: Calculate the confidence level p using the normal distribution generated in step S41. pr Exceeding the threshold θ pr = 0.95 probability P pr , reflecting the credibility of the candidate box being a QR code; probability P pr It is determined by the cumulative function of the normal distribution, which is calculated as follows: Where Φ is the cumulative function of the standard normal distribution, μ pr,k ,σ pr,k is the mean and standard deviation of the k-th candidate box; is the kth pr The confidence score of the candidate box; Indicates the kth pr The confidence of the candidate box Exceeding the threshold θ pr The probability threshold θ pr =0.95 probability Step S44: To optimize the model, define the loss function L unc , based on the probability P in step S42 pr and variance Balancing the reliability and uncertainty scale of confidence predictions; the loss function combines the logarithm of the probability and the regularization term of the variance, and is calculated as follows: Among them, N unc is the number of candidate boxes, P pr,k By numerical stabilization, a small constant ∈=10 is added. -6 make sure Computable; loss function encourages the model to improve confidence probability Controlling variance at the same time Not too large to cope with the uncertainty in complex scenarios.

7. A two-dimensional code image recognition system based on boundary completion and uncertainty modeling, characterized in that: The method comprises a memory, a processor, and computer program instructions stored in the memory and capable of being executed by the processor. When the processor executes the computer program instructions, the method steps according to any one of claims 1 to 6 can be implemented.

8. A computer-readable storage medium storing computer program instructions that can be executed by a processor, wherein when the processor executes the computer program instructions, the method steps according to any one of claims 1 to 6 can be implemented.

9. An electronic device comprising a processor and a memory, wherein: The memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to perform the method steps according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, wherein the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the method steps described in any one of claims 1 to 6.

Citation Information

Cited By

  • Building crack detection system based on image recognition

    CN121213509A