Addressing the attention divergence problem in detector-free local feature matching methods, this paper proposes SGFormer, a hierarchical Transformer framework that incorporates spatial structure awareness, guiding feature aggregation through a Triple-Structure-Attention module to improve the robustness and accuracy of matching in complex scenes.
Detector-free local feature matching methods, represented by LoFTR, have advanced the field through the global-range modeling capability of unconstrained attention mechanisms. However, the global features obtained by such methods can, in some scenes, weaken the model's attention to salient structures. The paper defines the phenomenon caused by this limitation as attention divergence: some high-confidence matching points are distributed outside the valid matching region, i.e., the image overlap region, and this problem is especially pronounced in scenes with large parallax variations.
In the relevant heatmaps and corresponding matching results of LoFTR, a typical detector-free matching method, such mismatches caused by scattered attention can be clearly observed.
Detector-free feature matching methods represented by LoFTR established the widely adopted mainstream technical paradigm in this field. The core of their architecture consists of three parts: a CNN-Transformer hybrid backbone for dense feature extraction, a Transformer module for feature transformation and matching, and a coarse-to-fine matching pipeline for outputting semi-dense sub-pixel-accuracy correspondences.
Subsequent related research has carried out targeted optimizations around this basic paradigm. ASpanFormer introduced a differentiable optical flow estimator to adaptively constrain the local windows of cross-attention, aiming to improve the running efficiency and local localization accuracy of the matching process; the Quadtree attention mechanism proposed an optimization scheme targeting the redundancy of the original attention computation, further compressing the computational cost of the matching pipeline.
The paper proposes two core innovations. The first is the structure-aware SGFormer framework for robust feature matching, which explicitly injects spatial structure awareness into a hierarchical Transformer architecture and can achieve significant improvements in matching accuracy and robustness in challenging scenes. The second is a brand-new "soft spatial regularization" paradigm for global attention mechanisms. Completely different from the existing idea among Transformer-based matching methods of relying on hard region cropping or local window constraints, this paradigm introduces low-level geometric structural priors to adaptively modulate Transformer attention, systematically constraining the model's attention range.
Under the overall evaluation conditions of the HPatches dataset, SGFormer achieved the best overall MMA scores at all thresholds, outperforming all detector-based methods, with its advantage becoming more pronounced at stricter thresholds, directly verifying the upper limit of the detector-free feature matching paradigm. In the comparison sequence of detector-free methods, SGFormer's performance leads LoFTR, exceeding it by 4.84%, 1.10%, and 2.15% at the 1-pixel, 3-pixel, and 5-pixel thresholds respectively. Under illumination changes, this performance advantage is further amplified, reaching a lead of 11.76% at the 1-pixel threshold and 2.08% at the 3-pixel threshold, directly confirming the robustness gains brought by the structure-aware design.
SGFormer targets robust local feature matching and adopts a semi-dense coarse-to-fine pipeline design. The overall architecture contains three core components: a hierarchical structure-guided Transformer backbone for extracting enhanced multi-scale features, a coarse-grained matching module for initial correspondence estimation, and a fine-grained matching module for sub-pixel-accuracy refinement. An image pair is first input into the backbone, a specially designed four-level Transformer that can inject spatial structure guidance information during feature extraction and output feature representations at different levels. Together with the immediately following module architecture diagram, you can fully trace the component arrangement logic across the entire pipeline from input features to attention computation and feature aggregation.
SGFormer's core innovation, the Triple-Structure-Attention module, uses high-resolution shallow structural features to guide the aggregation of discriminative visual representations in the early stages of the network. Features pre-calibrated with structural information are progressively refined through interleaved self-attention and cross-attention in subsequent deeper network layers, keeping the model's attention focused on the corresponding regions of the image pair while suppressing interference from irrelevant regions. Deeply integrated with the semi-dense coarse-to-fine matching pipeline, this module supports the model in producing robust correspondence estimation with sub-pixel accuracy.
On the relative pose estimation task of the MegaDepth public benchmark, SGFormer achieved results superior to the comparison baselines on all evaluation metrics. Its pose estimation AUC improves by 2.55%, 2.07%, and 0.87% over the retrained LoFTR baseline at the 5°, 10°, and 20° thresholds respectively, while matching accuracy reaches 98.2%, with lower reprojection error and less fluctuation, quantitatively verifying that SGFormer not only produces more correct matches but also yields correspondences with stronger geometric consistency. Please refer to the immediately following figure and focus on the performance differences in MMA metrics across pixel thresholds among different methods in the three scene types: overall, illumination change, and viewpoint change.
Ablation experiments on the core module show that after replacing SGFormer's TSA module with the standard linear attention module used by LoFTR, performance drops significantly at all pose estimation thresholds, with AUC@5° falling by 3.32%, directly confirming that the explicit structural feature extraction and guidance mechanism provided by TSA is the core component for achieving attention focus and improving matching robustness. Removing the RoPE component from the TSA module also causes a clear accuracy drop, with AUC@5° declining by 2.30%, verifying RoPE's key role in encoding rotation-equivariant spatial relations and helping the network distinguish features based on geometric context during the transformation stage.
The paper explicitly points out the performance boundary of SGFormer's current structural similarity guidance mechanism: in extreme viewpoint change scenes with significant scale changes or non-rigid deformations, the geometric consistency of the guiding structural features themselves decreases substantially, directly weakening the actual effect of the structural similarity guidance; this is the main limitation of the method at its current stage.