A two-dimensional code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation

By improving the feature extraction layer and introducing a hybrid activation strategy and an edge-enhanced attention module on the YOLOv11 architecture, the problems of positioning accuracy and environmental adaptability in QR code detection were solved, achieving high-precision and high-speed QR code recognition.

CN122493089APending Publication Date: 2026-07-31ZHEJIANG MILEY ROBOT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG MILEY ROBOT CO LTD
Filing Date
2026-03-17
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing QR code detection technologies suffer from insufficient positioning accuracy, poor efficiency and flexibility, and weak environmental adaptability, especially when there is uneven lighting, blurred images, or background interference, resulting in poor robustness.

Method used

An improved model based on spatial decoupled attention and adaptive nonlinear feature transformation is adopted. By reconstructing the feature extraction layer on the YOLOv11 architecture, a hierarchical hybrid activation strategy and an edge-enhanced coordinate attention module are introduced. Combined with a multi-branch output structure and a dual-path parallel pooling strategy, the ability to capture QR code edge and corner features is enhanced.

Benefits of technology

It achieves sub-pixel-level high-precision positioning, improves the inference speed of embedded devices, can effectively recognize QR codes that are arbitrarily rotated and tilted, resists interference from complex background noise, and ensures real-time detection at a high frame rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122493089A_ABST
    Figure CN122493089A_ABST
Patent Text Reader

Abstract

This application discloses a QR code detection method based on spatial decoupled attention and adaptive nonlinear feature transformation, belonging to the field of QR code detection technology. It solves the problems of insufficient QR code positioning accuracy, poor efficiency and flexibility, and weak environmental adaptability in existing technologies. The method includes: reconstructing the feature extraction network based on the YOLOv11 architecture, balancing the shallow computation speed and deep semantic expression through a hierarchical hybrid activation strategy, and enhancing the ability to capture spatial location information by utilizing a coordinate attention mechanism. Then, it predicts the corner points, side lengths, center points, and rotation angles of the QR code in the input image through a multi-branch detection head, thereby determining the accurate bounding box. This overcomes the difficulty of balancing inference speed and detection performance under the limited computing power of embedded devices. It also solves the problems of false detection and inaccurate prediction of all angles of deformed QR codes under complex background noise interference such as metallic reflection and dirt.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of QR code detection and positioning technology, and in particular to a QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation. Background Technology

[0002] With the advancement of "Industry 5.0" and intelligent manufacturing, machine vision technology is being used more and more widely in logistics warehousing and automated production lines. Among them, two-dimensional barcodes such as Data Matrix and QR Code are often used as navigation landmarks for AGVs (Automated Guided Vehicles), identification cards for parts, and carriers for material tracking due to their large information capacity and strong error correction capabilities.

[0003] Current QR code detection technologies mainly fall into two categories: traditional image processing methods and deep learning-based object detection methods. Traditional methods utilize geometric features of the image (such as detecting the proportional relationships of graphics) for edge detection and contour extraction. These methods have extremely low computational cost, but exhibit very poor robustness in situations with uneven lighting, blurred images, or background texture interference. Deep learning-based object detection methods (such as the YOLO series and SSD) automatically extract features using convolutional neural networks (CNNs). Compared to traditional methods, their robustness against interference in complex environments is significantly enhanced, making them the mainstream choice in industry. In particular, the YOLO (You Only Look Once) series of algorithms, due to their end-to-end inference speed advantage, are often deployed in embedded industrial cameras or edge computing boxes.

[0004] The existing QR code detection still has the following problems:

[0005] 1. Insufficient positioning accuracy: Existing deep learning networks lose a lot of spatial location information during multiple downsampling processes, making it difficult to achieve industrial-grade pixel-level corner positioning accuracy;

[0006] 2. Poor performance and flexibility: Using the same activation function (such as using SiLU or ReLU for all) cannot balance the computational speed of shallow layers with the semantic expression ability of deep layers, making it difficult to achieve optimal performance on embedded devices;

[0007] 3. Weak environmental adaptability: The model is not strong enough to resist complex background noise such as dirt and reflection, and has poor robustness to QR code detection at arbitrary rotation angles. Summary of the Invention

[0008] The purpose of this application is to overcome the problems of insufficient positioning accuracy, poor efficiency and flexibility, and weak environmental adaptability of QR codes in the prior art, and to provide a QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation.

[0009] Firstly, a QR code detection method based on spatial decoupled attention and adaptive nonlinear feature transformation is provided, including:

[0010] Obtain a training dataset and perform standardized preprocessing on the training dataset, wherein the training dataset includes QR code images and labeled data containing their corresponding corner points and angle information;

[0011] An improved model is constructed, which is based on the YOLOv11 architecture with the following improvements: In the backbone network, the feature extraction layer is reconstructed based on CSPDarknet and a hierarchical hybrid activation strategy is introduced, which includes ReLU in the shallow layer and SiLU in the deep layer; In the neck network, an edge-enhanced coordinate attention module is embedded, which strengthens the capture of QR code edge and corner features through a parallel pooling strategy of max pooling and average pooling; In the detection head, a multi-branch output structure is adopted to predict the corners, center point, and rotation angle of the QR code respectively.

[0012] The improved model is iteratively trained using the standardized preprocessed training dataset until the model converges to obtain the trained improved model.

[0013] After solidifying, formatting, and quantizing some weights of the trained improved model, the model operators are fused and optimized through the inference engine to construct a high-throughput inference execution file for real-time detection of input QR code images.

[0014] In some possible implementations, the training dataset undergoes normalization preprocessing, including:

[0015] Constructing the input tensor The input tensor is subjected to zero-mean standardization, calculated as follows:

[0016]

[0017] in, pixel coordinates Standardized pixel values, pixel coordinates The pixel values ​​of the original image. As the preset mean, The standard deviation is the preset value.

[0018] The normalized image is resampled to a fixed resolution, and geometric augmentation is performed using a probability matrix.

[0019] Based on the input size, a feature network with a specified step size is constructed as the anchor reference for subsequent regression.

[0020] In some possible implementations, the improved model includes a backbone network, a neck network, and a detection head. The backbone network comprises, in sequence, ConvModule convolutional module 1, ConvModule convolutional module 2, C3K2 module 1, ConvModule convolutional module 3, C3K2 module 2, edge-enhanced coordinate attention module 1, fast spatial pyramid pooling module, and edge-enhanced coordinate attention module 2. The neck network includes C3K2 module 3. The detection head includes ConvModule convolutional module 4 and ConvModule convolutional module 5. The ConvModule convolution module four is connected to Conv2d module one, and the ConvModule convolution module five is connected to Conv2d module two and Conv2d module three. Conv2d module one, Conv2d module two and Conv2d module three are respectively used to output confidence scores, bounding box information and rotation angles. The output of edge-enhanced coordinate attention module two is connected to C3K2 module three, and the output of C3K2 module three is connected to ConvModule convolution module four and ConvModule convolution module five respectively.

[0021] In some possible implementations, each of the ConvModule convolution module 1, ConvModule convolution module 2, ConvModule convolution module 3, ConvModule convolution module 4, and ConvModule convolution module 5 includes a Conv2d module, a BatchNorm module, and a dynamic activation function layer connected in sequence. Specifically, the ReLU activation function is used in the shallow feature extraction stage, and the SiLU activation function is used in the deep semantic enhancement stage.

[0022] In some possible implementations, C2K3 module one, C2K3 module two, and C2K3 module three all include:

[0023] Input convolutional unit one is used to perform convolution processing on the input feature map;

[0024] The splitting unit is used to split the feature map processed by the input convolutional unit into a first feature part and a second feature part in the channel dimension;

[0025] The first branch is used to directly pass the first feature portion to the splicing unit;

[0026] The second branch is used to perform deep feature extraction on the second feature part;

[0027] The splicing unit is used to splice the features output by the first branch with the features output by the second branch to generate fused features;

[0028] Output convolutional unit one is used to perform convolution processing on the fused features and output them.

[0029] In some possible implementations, the SPPF module includes:

[0030] Input convolutional unit 2: used to perform convolution processing on the input feature map to obtain the first feature;

[0031] Multiple pooling units: used to perform multiple max pooling operations of different sizes on the first feature to capture multi-scale contextual information, so as to generate pooled features of different receptive field scales;

[0032] A splicing unit is used to splice the first feature and the pooling features output by the at least one pooling unit in the channel dimension to obtain a multi-scale fused feature.

[0033] Output convolutional unit 2: used to perform convolution processing on the multi-scale fused features and output the final feature map.

[0034] In some possible implementations, the improved model employs dual-path decoupled pooling, performing one-dimensional global average pooling and one-dimensional global max pooling in parallel along the horizontal and vertical directions, respectively, for the feature component at height h in the horizontal direction of the c-th channel. The eigencomponent at the width w in the vertical direction The calculation is as follows:

[0035]

[0036]

[0037] in, This represents the horizontal aggregation feature of the c-th channel with height h. This represents the vertical aggregation feature of the c-th channel with width w. This represents the pixel value of the input feature map at coordinate (h,i) in the c-th channel, where W and H represent the width and height of the feature map, respectively.

[0038] Among some possible implementations, this also includes: constructing a system that includes a classification loss. Geometric regression loss and angle loss Composite objective function ;

[0039]

[0040] in, For the side length loss, Loss at the center point Loss at the center point;

[0041]

[0042]

[0043]

[0044] in, To improve the model's prediction of the equivalent side length of the QR code, The actual label value for the side length. To improve the model's prediction of the QR code center point coordinates, The true label value of the center point coordinates. To improve the corner coordinates predicted by the model, These are the actual label values ​​for the corner coordinates. , and As a weighting factor, Represents the L1 norm;

[0045]

[0046] in, To improve the rotation angle predicted by the model, The actual label value for the rotation angle. This is the weighting factor.

[0047] In some possible implementations, after iterative training is completed, the weights of the improved model, which includes the hybrid activation strategy and the edge-enhanced coordinate attention module, are solidified and serialized into a general intermediate representation format. The FP16 half-precision quantization strategy is adopted to reduce the GPU memory usage and memory access bandwidth. Subsequently, the inference engine is used to perform inter-layer fusion and automatic kernel tuning on the hybrid activation layer and the dual-pooling operator in the edge-enhanced coordinate attention module of the improved model to build a high-throughput inference execution file. In the real-time inference stage, the acquired image stream is preprocessed and then input into the inference engine for real-time detection.

[0048] Some possible implementations include: for the original prediction results, firstly, performing physical boundary constraint verification, traversing the geometric coordinates of all predicted boxes, directly eliminating outliers where the center point or corner point exceeds the physical boundary of the image, generating a preliminary candidate set; then, performing high confidence screening, based on the confidence output of the classification branch, retaining only high-confidence candidate boxes with a confidence greater than a preset value; for the selected candidate box set, using a non-maximum suppression algorithm to remove overlapping redundancy and retain local optima; finally, performing corner point geometric topology rearrangement on the finally retained detection boxes, based on the polar coordinate relationship of the four corner points regressed on the image plane, standardizing and sorting the four corner points in a clockwise direction to output positioning information including QR code type, confidence, center point, side length, sorted precise corner point coordinates, and rotation angle.

[0049] This application offers the following advantages: It reconstructs the feature extraction network based on the YOLO architecture, balances shallow computation speed with deep semantic representation through a hierarchical hybrid activation strategy, and enhances the ability to capture spatial location information using a coordinate attention mechanism. This allows for the prediction of corner points, side lengths, center points, and rotation angles of QR codes in input images via a multi-branch detection head, thereby determining accurate bounding boxes. By introducing an edge-enhanced coordinate attention (E-CA) mechanism and employing a dual-path parallel pooling strategy, it keenly captures high-frequency edge abrupt changes in QR code corner points, effectively solving the problem of location information loss caused by downsampling and achieving sub-pixel-level high-precision positioning. Furthermore, by adopting a hierarchical hybrid activation strategy, it uses ReLU to reduce latency in the computationally intensive shallow network and SiLU to enhance nonlinear fitting in the semantically rich deep network, significantly improving the inference speed of embedded devices without sacrificing detection accuracy. Finally, by combining a geometrically constrained decoupled detection head with a composite loss function based on specific engineering weights, it breaks through the limitations of traditional methods. The angle limitation enabled the achievement of The system can accurately recognize QR codes that can be rotated or tilted at will, effectively resisting interference from metallic reflections and complex background textures. Attached Figure Description

[0050] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.

[0051] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 This is a flowchart of the QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to Embodiment 1 of this application;

[0053] Figure 2 This is a simplified flowchart of the QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to Embodiment 1 of this application;

[0054] Figure 3 This is a structural diagram of the improved model in the QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation in Embodiment 1 of this application;

[0055] Figure 4 This is a structural diagram of the ConvModule module in the improved model of the QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation in Embodiment 1 of this application;

[0056] Figure 5 This is a structural diagram of the C2K3 module in the improved model of the QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation in Embodiment 1 of this application;

[0057] Figure 6 This is a structural diagram of the SPPF module in the improved model of the QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation in Embodiment 1 of this application;

[0058] Figure 7 This is a structural diagram of the edge-enhanced coordinate attention module in the improved model of the QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation in Embodiment 1 of this application. Detailed Implementation

[0059] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0060] Example 1

[0061] like Figure 1 and Figure 2 As shown, Embodiment 1 of this application relates to a QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation, comprising:

[0062] S100. Obtain the training dataset and perform standardized preprocessing on the training dataset, wherein the training dataset includes QR code images and labeled data containing their corresponding corner points and angle information.

[0063] First, a dedicated training dataset for industrial logistics scenarios is constructed. This involves collecting raw grayscale images containing DataMatrix or QRCode. The image is then subjected to sub-pixel-level fine-grained geometric annotation. The annotation data contains the set of pixel coordinates of the four corner points of the QR code. The true values ​​of physical properties are obtained by using the minimum bounding rectangle algorithm: center point. Rotation angle And the equivalent side length calculated based on the rectangle's length and width. .

[0064] To address the statistical distribution characteristics of industrial grayscale images, domain-adaptive normalization preprocessing is performed. An input tensor is constructed. Zero-mean normalization is then performed on it, and the calculation formula is as follows:

[0065]

[0066] in, For pixel coordinates, As the preset mean, The preset standard deviation is used. Subsequently, the image is resampled to a fixed resolution of 1024×1280, and geometric enhancement, including horizontal flipping, is performed using a probability matrix. Rotation and affine transformation This is done to enrich the spatial distribution of training samples. Based on the input size, a feature grid with a stride of 32 is constructed. This serves as the anchor benchmark for subsequent regressions.

[0067] S200. Construct an improved model, wherein the improved model is based on the YOLOv11 architecture with the following improvements: In the backbone network, the feature extraction layer is reconstructed based on CSPDarknet and a hierarchical hybrid activation strategy is introduced, the hierarchical hybrid activation strategy includes ReLU in the shallow layer and SiLU in the deep layer; In the neck network, an edge-enhanced coordinate attention module is embedded, and the capture of QR code edge and corner features is enhanced through a parallel pooling strategy of max pooling and average pooling; In the detection head, a multi-branch output structure is adopted, which is used to predict the corners, center point and rotation angle of the QR code respectively.

[0068] like Figure 3As shown, after the image is input, it is first preprocessed, then features are extracted through the improved backbone layer, the feature information is processed through the neck layer, and finally the prediction result is generated through the bbox_head layer.

[0069] The improved model includes a backbone network, a neck network, and a detection head. The backbone network comprises ConvModule 1, ConvModule 2, C3K2 1, ConvModule 3, C3K2 2, Edge-enhanced Coordinate Attention Module 1, Fast Spatial Pyramid Pooling Module, and Edge-enhanced Coordinate Attention Module 2, connected sequentially. The neck network includes C3K2 Module 3. The detection head includes ConvModule 4 and ConvModule 5. ConvModule 4 is connected to Conv2d Module 1, and ConvModule 5 is connected to Conv2d Module 2 and Conv2d Module 3. Conv2d Module 1, Conv2d Module 2, and Conv2d Module 3 are used to output confidence scores, bounding box information, and rotation angles, respectively. The output of Edge-enhanced Coordinate Attention Module 2 is connected to C3K2 Module 3, and the output of C3K2 Module 3 is connected to ConvModule 4 and ConvModule 5, respectively.

[0070] Specifically, the improved backbone layer is reconstructed based on the CSPDarknet architecture, consisting of stemlayer, stagelayer1, and stagelayer2, and introduces a hierarchical hybrid activation strategy and an edge-enhanced spatial decoupling attention mechanism. The stemlayer contains a convolutional module; to ensure computational efficiency and gradient stability when processing high-resolution images, this layer uses ReLU as the activation function. Stagelayer1 consists of a convolutional module and a C3k2 module, also configured with the ReLU activation function for fast edge texture feature extraction. Stagelayer2, in the deeper regions of the network, uses the SiLU activation function to enhance non-linear semantic expression capabilities. Its structure is more complex: it consists of a convolutional module, a C3k2 module, an edge-enhanced coordinate attention (E-CA) module, a SPPF (fast spatial pyramid pooling) module, and the E-CA module connected in series. Specifically, after the C3k2 module extracts deep features, and after SPPF fuses multi-scale features, the coordinate attention module is connected to address the spatial location information loss during downsampling, accurately locking the boundaries and corners of the QR code.

[0071] The Neck layer contains a C3k2 module for further fusing deep semantics with shallow spatial features. The Bbox_head layer maintains a multi-branch output structure and extracts the prediction results: scores represent the scores (confidence) of the generated results, bbox represents the information of the bounding box (including the center point, side length, and four corner points), and angle represents the rotation angle (clockwise is positive).

[0072] like Figure 4 As shown, each of the ConvModule convolutional modules—ConvModule 1, ConvModule 2, ConvModule 3, ConvModule 4, and ConvModule 5—includes a Conv2d module, a BatchNorm module, and a dynamic activation function layer connected in sequence. Specifically, the ReLU activation function is used in the shallow feature extraction stage, and the SiLU activation function is used in the deep semantic enhancement stage.

[0073] like Figure 5 As shown, C2K3 module one, C2K3 module two, and C2K3 module three each include:

[0074] Input convolutional unit one is used to perform convolution processing on the input feature map;

[0075] The splitting unit is used to split the feature map processed by the input convolutional unit into a first feature part and a second feature part in the channel dimension;

[0076] The first branch is used to directly pass the first feature portion to the splicing unit;

[0077] The second branch is used to perform deep feature extraction on the second feature part;

[0078] The splicing unit is used to splice the features output by the first branch with the features output by the second branch to generate fused features;

[0079] Output convolutional unit one is used to perform convolution processing on the fused features and output them.

[0080] like Figure 6 As shown, the SPPF module includes:

[0081] Input convolutional unit 2: used to perform convolution processing on the input feature map to obtain the first feature;

[0082] Multiple pooling units: used to perform multiple max pooling operations of different sizes on the first feature to capture multi-scale contextual information, so as to generate pooled features of different receptive field scales;

[0083] A splicing unit is used to splice the first feature and the pooling features output by the at least one pooling unit in the channel dimension to obtain a multi-scale fused feature.

[0084] Output convolutional unit 2: used to perform convolution processing on the multi-scale fused features and output the final feature map.

[0085] The specific implementation logic of each module is as follows: Convolution module (e.g.) Figure 4 It contains a 2D convolutional layer, a batch normalization layer, and a dynamically selected activation function (ReLU or SiLU). The C3k2 module (such as...) Figure 5 The system employs a branching structure, dividing the input feature map into two parts: one part retains shallow features, and the other part extracts deep features through stacked Bottleneck structures, which are then concatenated and fused. The improved Edge-Enhanced Coordinate Attention (E-CA) module utilizes precise location information to encode channel relationships. The SPPF module (such as...) Figure 6 It captures multi-scale contextual information through multiple max-pooling layers of different sizes.

[0086] Considering the significant geometric edge and corner features of QR codes, this module innovatively employs a dual-pooling strategy: for the input feature map, one-dimensional global average pooling and one-dimensional global max pooling are performed in parallel along the horizontal (X-axis) and vertical (Y-axis) directions, respectively. The average pooling branch captures long-range background context dependencies, while the max pooling branch focuses on responding to high-frequency edge texture abrupt changes. The feature vectors generated by the two branches are superimposed and fused, then concatenated, transformed by convolution (dimensionality reduction and expansion), and activated by sigmoid to generate attention weight maps containing rich edge information along both spatial directions. Finally, the weight maps are multiplied back into the original feature map, significantly enhancing the network's sensitivity to locating the four corners and edges of the QR code in complex backgrounds. Figure 7 As shown, after the input features are processed through dual-path encoding and fusion transformation, the resulting weight map is multiplied back into the original feature map, which significantly enhances the network's sensitivity to locating the four corners and edges of the QR code in complex backgrounds.

[0087] S300. The improved model is iteratively trained using the standardized preprocessed training dataset until the model converges to obtain the trained improved model.

[0088] Specifically, a feature extraction network based on hybrid activation and edge-enhancing attention is constructed: preprocessed tensors are input into the improved backbone network. This network is based on the CSPDarknet topology and employs differentiated computational strategies according to the feature layer depth.

[0089] In the shallow feature extraction stage (Stem layer and Stage 1), the feature maps maintain a relatively high resolution. To reduce the number of floating-point operations (FLOPs) in high-dimensional tensor convolution operations and maintain the sparsity of gradients in the early stages of backpropagation, the network configures the convolutional modules with the ReLU activation function, which is mathematically expressed as:

[0090]

[0091] In the deep semantic enhancement stage (Stage 2), the activation function of the convolutional module is automatically switched to SiLU, leveraging its smooth and non-convex characteristics to enhance the model's ability to fit non-linear semantic features.

[0092]

[0093] in, This represents the pixel values ​​of the input feature map. and These represent the output values ​​after processing by shallow and deep activation functions, respectively. This represents the Sigmoid function. is the base of the natural logarithm.

[0094] At this stage, the C3k2 and SPPF modules integrate an Edge Enhanced Coordinate Attention (E-CA) module at their outputs. Let the input feature tensor be... This module performs dual-path parallel processing:

[0095] Dual-path decoupled pooling: One-dimensional global average pooling and one-dimensional global max pooling are performed in parallel along the horizontal (X-axis) and vertical (Y-axis) directions, respectively. For the c-th channel, the feature components at height h in the horizontal direction... Width in the vertical direction eigencomponents at the location The calculation is as follows:

[0096]

[0097]

[0098] in, This represents the horizontal aggregation feature of the c-th channel with height h; This represents the vertical aggregation feature of the c-th channel with width w; This indicates that the input feature map is at the c-th channel and coordinates. The pixel value at that location; W and H represent the width and height of the feature map, respectively.

[0099] Feature aggregation and recalibration: Statistical features in the same direction are fused, concatenated along the spatial dimension, and then processed through a shared 1×1 convolution. Intermediate encoded features F are generated by SiLU activation. Then, the Sigmoid function is used. Generate the final spatial attention weight map , The output Y is obtained by weighting back the original feature map through broadcasting multiplication.

[0100]

[0101]

[0102]

[0103] Where F represents the intermediate encoded features after convolution and activation; This represents a 1×1 convolution operation; This represents a tensor splitting operation; and These represent the generated horizontal and vertical attention weight maps, respectively. This indicates that the final weighted output feature map is in The value at that location.

[0104] Multi-branch detection head decoding based on geometrically constrained priors: Feature maps are fused at multiple scales through a Neck layer and then input to the decoupled detection head. This embodiment utilizes the "square" geometric prior of QR codes to decompose the target detection task into two sub-tasks: classification confidence estimation and geometric parameter regression. The classification branch outputs confidence using the Sigmoid activation function. Geometric regression branch is based on grid anchor points. Decode physical parameters, network output regression values :

[0105] Side length regression: Introducing a preset baseline side length L base =213, using an exponential function to ensure the non-negativity and scale sensitivity of the predicted values:

[0106]

[0107] Centroid Regression: Decoding the offset of the centroid relative to the anchor point:

[0108]

[0109] Corner Regression: Utilizing the enhanced edge features from step two, the offsets of the four corner points relative to the anchor points are directly regressed. This formula leverages the implicit corner semantics in the feature map:

[0110]

[0111] in, : Indicates the equivalent side length of the QR code predicted by the model; : Represents the preset baseline side length constant (taken as 213 here); : Represents the scaling regression parameters output by the network; : Represents the predicted coordinates of the center point of the QR code; : Represents the coordinates of the grid anchor point corresponding to the current feature point. ; : Represents the Sigmoid activation function, used to restrict the network output to the (0,1) interval; : Represents the center point offset coefficient of the network output; : Represents the predicted coordinates of the i-th corner point, where, ; : Represents the offset coefficient of the i-th corner point in the network output.

[0112] Full-angle regression: A piecewise regression strategy is adopted. If the angle is within the range of $[-\pi / 8,\pi / 8]$, the offset value is directly regressed; otherwise, it is mapped through modulo operation.

[0113]

[0114] in, : Indicates the final predicted rotation angle (in radians); : Represents the angle parameters output by the network's direct regression; : indicates modulo operation; Pi (π)

[0115] Construction and gradient optimization of composite loss functions: Constructing a function that includes classification loss. Geometric regression loss and angle loss Composite objective function And introduce specific normalization coefficients. As a gradient balancing factor.

[0116] The classification loss uses the binary cross-entropy loss (BCEWithLogits). The geometric regression loss is defined as the weighted sum of the errors of the side length, center point, and corner points:

[0117]

[0118] To eliminate the influence of different physical dimensions and enhance corner point localization, the following normalized calculation formula is introduced:

[0119]

[0120]

[0121]

[0122]

[0123] The corner loss is assigned a weight factor of 5, forcing the optimizer to focus on fine-tuning corner accuracy in the later stages of training. The angle loss is calculated using the normalized absolute error:

[0124]

[0125]

[0126] in, , and : These represent the side length loss, center point loss, and corner point loss, respectively;

[0127] , and : These represent the actual label values ​​(GroundTruth) for the side length, center point coordinates, and corner point coordinates, respectively. : Represents the L1 norm (absolute error); constants 5 and 21.3: are normalization coefficients and weighting factors used to balance the gradient contributions of different physical dimensions; : Represents the angle regression loss; : Represents the actual label value of the rotation angle.

[0128] The total loss $\mathcal{L}_{total}$ is backpropagated using the stochastic gradient descent (SGD) algorithm to iteratively update the weight parameters of the hybrid activation layer, convolutional layer, and E-CA module until the model converges.

[0129] S400: After solidifying, formatting, and quantizing and compressing some weights of the trained improved model, the model operators are fused and optimized through the inference engine to construct a high-throughput inference execution file for real-time detection of the input QR code image.

[0130] Specifically, after training iterations, the improved model weights, including the hybrid activation strategy and the Edge Enhanced Coordinate Attention (E-CA) module, are solidified and serialized into the ONNX general intermediate representation format. Considering the computing power constraints of industrial embedded terminals, an FP16 half-precision quantization strategy is adopted to reduce GPU memory usage and memory access bandwidth. Subsequently, high-performance inference engines such as TensorRT are used to perform inter-layer fusion and automatic kernel tuning on the hybrid activation layer (ReLU / SiLU heterogeneous operators) and the dual-pooling operator in the E-CA module, constructing a high-throughput inference execution file. In the real-time inference stage, the image stream captured by the camera is preprocessed and input into the inference engine to quickly calculate the prediction tensor containing classification confidence and geometric regression parameters.

[0131] For the original prediction results, a rigorous cascaded geometric verification and post-processing logic is performed to ensure the reliability of the output data. First, physical boundary constraint verification is performed, iterating through the geometric coordinates of all predicted bounding boxes and directly removing those whose center points or corner points exceed the image's physical boundaries. The abnormal solutions are used to generate an initial candidate set. Then, a high-confidence screening is performed based on the output of the classification branch. Only high-confidence candidate boxes with a confidence score greater than 0.9 are retained. Thanks to the significant suppression of background noise by the E-CA module, this high threshold setting can effectively filter out complex texture interference in industrial environments (such as metallic reflections or background patterns similar to QR codes). For the filtered candidate box set, the non-maximum suppression (NMS) algorithm is used to remove overlapping redundancy and retain local optima. Finally, a corner point geometric topology rearrangement operation is performed on the finally retained detection boxes. Based on the polar coordinate relationship of the four regressed corner points on the image plane, they are standardized and sorted in a clockwise direction to ensure that the output corner point sequence is consistent with the standard encoding direction of the QR code. The final output contains complete positioning information including QR code type, confidence score, center point, side length, sorted precise corner point coordinates, and rotation angle, which can be directly used by downstream AGV navigation. This method is particularly suitable for embedded industrial cameras with limited computing power, AGV vision navigation modules, and high-speed production line barcode scanning terminals, achieving sub-pixel-level positioning accuracy while ensuring a real-time detection frame rate of over 80 FPS.

[0132] In this embodiment, the feature extraction network is reconstructed based on the YOLO architecture. A hierarchical hybrid activation strategy balances the computational speed of shallow layers with the semantic representation of deep layers. A coordinate attention mechanism is used to enhance the ability to capture spatial location information. Then, a multi-branch detection head predicts the corners, side lengths, center points, and rotation angles of the QR code in the input image, thereby determining the accurate bounding box. By introducing an edge-enhanced coordinate attention (E-CA) mechanism and using a dual-path parallel pooling strategy to keenly capture high-frequency edge abrupt signals of QR code corners, the problem of location information loss caused by downsampling is effectively solved, achieving sub-pixel-level high-precision positioning. By adopting a hierarchical hybrid activation strategy, ReLU is used to reduce latency in the computationally intensive shallow network, and SiLU is used to enhance nonlinear fitting in the semantically rich deep network, significantly improving the inference speed of embedded devices without sacrificing detection accuracy. By combining a geometrically constrained decoupled detection head with a composite loss function based on specific engineering weights, a breakthrough is achieved in traditional methods. The angle limitation enabled the achievement of The system can accurately recognize QR codes that can be rotated or tilted at will, effectively resisting interference from metallic reflections and complex background textures.

[0133] The above are merely preferred embodiments of this application; however, the scope of protection of this application is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in this application, based on the technical solution and its improved concept, should be covered within the scope of protection of this application.

Claims

1. A QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation, characterized in that, include: Obtain a training dataset and perform standardized preprocessing on the training dataset, wherein the training dataset includes QR code images and labeled data containing their corresponding corner points and angle information; An improved model is constructed, which is based on the YOLOv11 architecture with the following improvements: In the backbone network, the feature extraction layer is reconstructed based on CSPDarknet and a hierarchical hybrid activation strategy is introduced, which includes ReLU in the shallow layer and SiLU in the deep layer; In the neck network, an edge-enhanced coordinate attention module is embedded, which strengthens the capture of QR code edge and corner features through a parallel pooling strategy of max pooling and average pooling; In the detection head, a multi-branch output structure is adopted to predict the corners, center point, and rotation angle of the QR code respectively. The improved model is iteratively trained using the standardized preprocessed training dataset until the model converges to obtain the trained improved model. After solidifying, formatting, and quantizing some weights of the trained improved model, the model operators are fused and optimized through the inference engine to construct a high-throughput inference execution file for real-time detection of input QR code images.

2. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 1, characterized in that, The training dataset undergoes standardization preprocessing, including: Constructing the input tensor The input tensor is subjected to zero-mean standardization, calculated as follows: in, pixel coordinates Standardized pixel values, pixel coordinates The pixel values ​​of the original image. As the preset mean, The standard deviation is the preset value. The normalized image is resampled to a fixed resolution, and geometric augmentation is performed using a probability matrix. Based on the input size, a feature network with a specified step size is constructed as the anchor reference for subsequent regression.

3. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 1, characterized in that, The improved model includes a backbone network, a neck network, and a detection head. The backbone network comprises ConvModule 1, ConvModule 2, C3K2 1, ConvModule 3, C3K2 2, Edge-enhanced Coordinate Attention Module 1, Fast Spatial Pyramid Pooling Module, and Edge-enhanced Coordinate Attention Module 2, connected sequentially. The neck network includes C3K2 Module 3. The detection head includes ConvModule 4 and ConvModule 5. ConvModule 4 is connected to Conv2d Module 1, and ConvModule 5 is connected to Conv2d Module 2 and Conv2d Module 3. Conv2d Module 1, Conv2d Module 2, and Conv2d Module 3 are used to output confidence scores, bounding box information, and rotation angles, respectively. The output of Edge-enhanced Coordinate Attention Module 2 is connected to C3K2 Module 3, and the output of C3K2 Module 3 is connected to ConvModule 4 and ConvModule 5, respectively.

4. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 3, characterized in that, The ConvModule convolution module one, ConvModule convolution module two, ConvModule convolution module three, ConvModule convolution module four and ConvModule convolution module five each include a Conv2d module, a BatchNorm module and a dynamic activation function layer connected in sequence. The ReLU activation function is used in the shallow feature extraction stage and the SiLU activation function is used in the deep semantic enhancement stage.

5. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 3, characterized in that, C2K3 Module 1, C2K3 Module 2, and C2K3 Module 3 all include: Input convolutional unit one is used to perform convolution processing on the input feature map; The splitting unit is used to split the feature map processed by the input convolutional unit into a first feature part and a second feature part in the channel dimension; The first branch is used to directly pass the first feature portion to the splicing unit; The second branch is used to perform deep feature extraction on the second feature part; The splicing unit is used to splice the features output by the first branch with the features output by the second branch to generate fused features; Output convolutional unit one is used to perform convolution processing on the fused features and output them.

6. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 3, characterized in that, The SPPF module includes: Input convolutional unit 2: used to perform convolution processing on the input feature map to obtain the first feature; Multiple pooling units: used to perform multiple max pooling operations of different sizes on the first feature to capture multi-scale contextual information, so as to generate pooled features of different receptive field scales; A splicing unit is used to splice the first feature and the pooling features output by the at least one pooling unit in the channel dimension to obtain a multi-scale fused feature. Output convolutional unit 2: used to perform convolution processing on the multi-scale fused features and output the final feature map.

7. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 1, characterized in that, In the improved model, dual-path decoupled pooling is employed, with one-dimensional global average pooling and one-dimensional global max pooling performed in parallel along the horizontal and vertical directions, respectively. For the feature component at height h in the horizontal direction of the c-th channel... The eigencomponent at the width w in the vertical direction The calculation is as follows: in, This represents the horizontal aggregation feature of the c-th channel with height h. This represents the vertical aggregation feature of the c-th channel with width w. This represents the pixel value of the input feature map at coordinate (h,i) in the c-th channel, where W and H represent the width and height of the feature map, respectively.

8. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 1, characterized in that, Also includes: Constructing including classification loss Geometric regression loss and angle loss Composite objective function ; in, For the side length loss, Loss at the center point Loss at the center point; in, To improve the model's prediction of the equivalent side length of the QR code, The actual label value for the side length. To improve the model's prediction of the QR code center point coordinates, The true label value of the center point coordinates. To improve the corner coordinates predicted by the model, These are the actual label values ​​for the corner coordinates. , and As a weighting factor, Represents the L1 norm; in, To improve the rotation angle predicted by the model, The actual label value for the rotation angle. This is the weighting factor.

9. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 1, characterized in that, After iterative training, the weights of the improved model, which includes the hybrid activation strategy and the edge-enhanced coordinate attention module, are solidified and serialized into a general intermediate representation format. The FP16 half-precision quantization strategy is adopted to reduce the GPU memory usage and memory access bandwidth. Subsequently, the inference engine is used to perform inter-layer fusion and automatic kernel tuning on the hybrid activation layer and the dual-pooling operator in the edge-enhanced coordinate attention module of the improved model to build a high-throughput inference execution file. In the real-time inference stage, the acquired image stream is preprocessed and then input into the inference engine for real-time detection.

10. The QR code detection method based on spatial decoupling attention and adaptive nonlinear feature transformation according to claim 1, characterized in that, It also includes: For the original prediction results, firstly, physical boundary constraint verification is performed, traversing the geometric coordinates of all predicted boxes, directly eliminating abnormal solutions where the center point or corner point exceeds the physical boundary of the image, generating a preliminary candidate set, then performing high confidence screening, based on the confidence output of the classification branch, only retaining high-confidence candidate boxes with a confidence greater than a preset value, for the selected candidate box set, non-maximum suppression algorithm is used to remove overlapping redundancy and retain local optima, finally, corner point geometric topology rearrangement is performed on the finally retained detection boxes, based on the polar coordinate relationship of the four corner points regressed on the image plane, the four corner points are standardized and sorted in a clockwise direction to output positioning information including QR code type, confidence, center point, side length, sorted precise corner point coordinates and rotation angle.