A Transformer local BA replacement method, device, equipment and medium
By performing clustering compression and common-view partitioning on map point data, and employing sparse attention interaction and state recursion, the problem of excessive computational load and memory consumption on computing-limited devices was solved by the Transformer local BA alternative, enabling real-time optimization of keyframe pose and map point position within the sliding window.
Patent Information
- Application Number
- CN202611664083.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-27
- Publication Date
- 2026-11-27
AI Technical Summary
Existing Transformer local BA alternatives struggle to optimize keyframe poses and map point positions in real time on computing-constrained devices, primarily due to the rapid increase in computational load and memory consumption with the number of nodes.
By clustering and compressing map point data, superpoint features are obtained and combined with keyframe data to form a window node sequence. Common view division is performed based on observation correlation. The common view node set undergoes sparse attention interaction, and the non-common view node set undergoes state recursion. Feature updates are performed by combining sparse attention interaction and state recursion, and finally, the optimized keyframe pose and map point position are output.
Real-time solution of local BA in sliding window was achieved on edge embedded devices with limited computing power, reducing computational load and memory usage while maintaining optimization accuracy.
Smart Images

Figure CN123181577A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, device, and medium for replacing local BA in Transformer. Background Technology
[0002] Sliding window local bundle adjustment (BA) is a common processing method in the backend of visual simultaneous localization and mapping (SLAM) systems. The visual frontend maintains a fixed-capacity sequence of keyframes, i.e., a sliding window, and jointly optimizes the keyframe poses and map point positions within this window. This minimizes the deviation between the image points projected onto the keyframe image plane according to the current map point pose and the actually observed image points, thus maintaining consistency between pose estimation and map structure within a local area. With the application of deep learning methods in geometric optimization, a technique has emerged that uses Transformer networks to replace the iterative local BA solution process. This type of scheme represents keyframes and map points within the sliding window as nodes, transmits geometric constraint information between nodes through an attention mechanism, and directly outputs the optimized keyframe poses and map point positions from the network.
[0003] However, existing Transformer local BA alternatives typically employ a standard full-attention architecture, which indiscriminately performs pairwise interactions on all nodes within the sliding window. On one hand, the computational cost of attention interactions increases quadratically with the number of nodes; on the other hand, the number of map points within the sliding window is usually far greater than the number of keyframes. If each map point is treated as an independent node in the attention interaction, the length of the node sequence will increase significantly. These two factors combined result in the computational cost and memory requirements for completing a single sliding window local BA replacement exceeding the resource budget of the embedded device, making it difficult to output optimized results at real-time frame rates on platforms with limited computing power.
[0004] Therefore, how to reduce the computational load and memory consumption of the Transformer local BA replacement process, so that it can optimize the keyframe pose and map point position within the sliding window in real time on devices with limited computing power, is a technical problem that needs to be solved in this field. Summary of the Invention
[0005] This invention provides a Transformer-based local BA replacement method, apparatus, device, and medium, aiming to solve the technical problem that existing Transformer-based local BA replacement schemes perform pairwise attention interactions on all nodes within the sliding window indiscriminately, and each map point participates in the calculation as an independent node, resulting in a sharp increase in computational load and memory consumption with the number of nodes, making it difficult to complete sliding window local BA optimization in real time on devices with limited computing power.
[0006] In a first aspect, embodiments of the present invention provide a Transformer local BA replacement method, comprising: Acquire keyframe data, map point data, and observation relationships within the sliding window, and input them into a local BA substitution model that has been pre-trained by knowledge distillation; The map point data is clustered and compressed using the local BA substitution model to obtain superpoint features, which are then combined with the keyframe data to form a window node sequence. Based on the observation correlation, the nodes in the window node sequence are divided into common-view nodes and non-common-view nodes; Sparse attention interaction is performed on the set of co-view nodes, state recursion is performed on the set of non-co-view nodes, and the two outputs are fused to obtain the updated node features. The updated node features are decoded to obtain the optimized keyframe pose and optimized map point position within the sliding window; The optimized keyframe poses and the optimized map point positions are written back to the sliding window to obtain the updated sliding window.
[0007] Secondly, embodiments of the present invention provide a Transformer local BA replacement device, comprising: The data acquisition module is used to acquire keyframe data, map point data, and observation relationships within the sliding window, and input them into the local BA substitution model that has been pre-trained by knowledge distillation. The superpoint clustering module is used to cluster and compress the map point data using the local BA substitution model to obtain superpoint features, and form a window node sequence with the keyframe data. The common-view partitioning module is used to partition the nodes in the window node sequence into common-view nodes and non-common-view nodes according to the observation correlation relationship, so as to obtain a common-view node set and a non-common-view node set. The feature update module is used to perform sparse attention interaction on the set of co-visible nodes, perform state recursion on the set of non-co-visible nodes, and fuse the two outputs to obtain the updated node features. The output decoding module is used to decode the updated node features to obtain the optimized keyframe pose and optimized map point position within the sliding window. The state write-back module is used to write back the optimized keyframe pose and the optimized map point position to the sliding window to obtain the state-updated sliding window.
[0008] Thirdly, embodiments of the present invention provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the Transformer local BA replacement method of the first aspect.
[0009] Fourthly, embodiments of the present invention provide a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the Transformer local BA substitution method of the first aspect.
[0010] This invention provides a Transformer local BA substitution method, comprising: acquiring keyframe data, map point data, and observation relationships within a sliding window, and inputting them into a local BA substitution model pre-trained by knowledge distillation; clustering and compressing the map point data using the local BA substitution model to obtain superpoint features, and forming a window node sequence with the keyframe data; dividing the nodes in the window node sequence into common-view nodes and non-common-view nodes according to the observation relationships; performing sparse attention interaction on the common-view node set and state recursion on the non-common-view node set, fusing the two outputs to obtain updated node features; decoding the updated node features to obtain optimized keyframe poses and optimized map point positions within the sliding window; and writing the optimized keyframe poses and optimized map point positions back to the sliding window to obtain a state-updated sliding window. This invention reduces the length of the window node sequence by clustering and compressing map point data, using a small number of superpoint features to carry joint information of spatially adjacent map point groups with consistent surface orientation and semantic labels. Based on observational relationships, the nodes in the window node sequence are divided into a set of shared-view nodes and a set of non-shared-view nodes. Sparse attention interaction is performed on shared-view nodes with direct observational relationships to ensure the modeling accuracy of shared-view constraints. State recursion is performed on non-shared-view nodes without direct observational relationships to transmit temporal information between nodes with low computational overhead. The two outputs are then fused to obtain updated node features, making the computational cost of updating window node features linearly increase with the number of nodes. Furthermore, the local BA substitution model is pre-trained using knowledge distillation, maintaining optimization accuracy even after parameter compression. Therefore, this invention can complete the substitution solution of sliding window local BA at a real-time frame rate on edge embedded devices with limited computing power, reducing memory usage while maintaining the optimization accuracy of keyframe pose and map point positions.
[0011] This invention also provides a Transformer local BA replacement device, a computer device, and a storage medium, which have the same beneficial effects as described above. Attached Figure Description
[0012] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1A flowchart illustrating a Transformer local BA replacement method provided in an embodiment of the present invention; Figure 2 This is a schematic block diagram of a Transformer local BA replacement device provided in an embodiment of the present invention. Detailed Implementation
[0014] 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, not all, of the embodiments of the present invention. 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.
[0015] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0016] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0017] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0018] Please see below. Figure 1 , Figure 1 The flowchart of a Transformer local BA replacement method provided in an embodiment of the present invention specifically includes steps S101 to S106.
[0019] S101. Obtain keyframe data, map point data, and observation relationships within the sliding window, and input them into the local BA substitution model that has been pre-trained by knowledge distillation. S102. Cluster and compress the map point data using the local BA substitution model to obtain superpoint features, and combine them with the keyframe data to form a window node sequence; S103. Based on the observation correlation, perform common-view partitioning on the nodes in the window node sequence to obtain a common-view node set and a non-common-view node set; S104. Perform sparse attention interaction on the set of co-view nodes, perform state recursion on the set of non-co-view nodes, and fuse the two outputs to obtain the updated node features. S105. Decode the updated node features to obtain the optimized keyframe pose and optimized map point position within the sliding window. S106. Write the optimized keyframe pose and the optimized map point position back to the sliding window to obtain the state-updated sliding window.
[0020] In step S101, keyframe data, map point data, and observation correlations within the sliding window are acquired and input into the local BA substitution model that has been pre-trained by knowledge distillation.
[0021] In one embodiment, in step S101, the local BA substitution model is obtained through hierarchical knowledge distillation training, the training process of which includes: Keyframe data, map point data, and observation correlations of the sample sliding window are obtained and used as training samples. The training samples are input into the fully attention-based teacher model and the lightweight student model respectively, and the corresponding teacher output and student output are obtained. Based on the student output, the confidence-weighted reprojection residual and the pose second-order difference smoothing constraint are calculated to obtain the task loss. Linearly align the intermediate layer features of the student model and the teacher model to obtain the feature layer alignment loss; The output layer alignment loss is calculated using the teacher's output as a soft label, and the local BA replacement model is obtained by training the various losses together.
[0022] In this embodiment, the sliding window refers to a fixed-capacity sequence of keyframes maintained chronologically by the visual front-end of the visual SLAM system. When a new keyframe enters the sequence, the oldest keyframe is removed, ensuring that the state variables required for optimization are always limited to the most recent trajectory segment. A keyframe is a representative image frame selected by the visual front-end from continuously acquired image frames based on factors such as the degree of viewpoint change and tracking quality, used to characterize that trajectory segment. In this embodiment, the sliding window capacity is 12 frames; on embedded platforms with 1 to 2 TOPS computing power, the sliding window capacity can be between 10 and 15 frames to achieve a balance between the optimization range and computational overhead.
[0023] Keyframe data includes the image features and initial pose of each keyframe within the sliding window. The image features are feature vectors extracted and encoded by the visual front-end from the image of that keyframe; the initial pose is the initial estimate of the camera's position and orientation in the world coordinate system given by the tracking component of the visual front-end, represented by three translational and three rotational components. Map point data includes the coordinates of 3D spatial points observed in each keyframe within the sliding window in the world coordinate system; these 3D spatial points are the map points. Observation correlation refers to the observation correspondence between map points and keyframes, i.e., which keyframes within the sliding window observe a particular map point, and the corresponding image point positions of that map point on the image plane of these keyframes. In this embodiment, the average number of map points within the sliding window is approximately 320.
[0024] In this embodiment, local BA refers to Local Bundle Adjustment (BA), which jointly optimizes the keyframe pose and map point positions within a sliding window to minimize the deviation between the image points obtained by projecting each map point onto the keyframe image plane according to its current pose and the actually observed image points. Traditional sliding window local BA solves the nonlinear least squares problem as shown in the following equation iteratively:
[0025] In the formula, It is the set of all keyframe poses within the sliding window W; W is the set of map points within the sliding window; O is the set of feature observations within the sliding window; (i,j) is a set of observation indices, indicating that map point i is observed by keyframe j; For map points Image point observations in keyframe j; Let be the pose of keyframe j; π(·) be the camera projection function, used to project 3D spatial points into 2D image points on the image plane based on camera intrinsic parameters and keyframe pose; ρ(·) be the robust kernel function, used to suppress the influence of mismatched observations on the solution results; ‖·‖ be the L2 norm of the vector; min in the formula represents finding the solution that minimizes the objective function on the set of keyframe poses and the set of map points within the sliding window. The above iterative solution takes tens of milliseconds to complete a single window optimization on an ARM-based embedded processor. The measured time in this embodiment is 38 ms, and it is prone to divergence in low-texture scenes due to insufficient effective observation constraints.
[0026] In this embodiment, the local BA substitution model refers to a neural network model centered on window node feature updates. Its inputs are keyframe data, map point data, and observation relationships within the sliding window. The output is the optimized keyframe pose and optimized map point position within the sliding window, functionally equivalent to the iterative sliding window local BA solution module described above. The local BA substitution model directly provides the optimization result with a single forward inference, eliminating the need for iterative solutions, thus ensuring stable and controllable time consumption for a single window optimization. In this embodiment, the local BA substitution model is deployed on an embedded platform equipped with a quad-core Cortex-A76 processor and a 1 TOPS Neural Processing Unit (NPU), and interfaces with the sliding window backend of the visual SLAM frontend.
[0027] In this embodiment, hierarchical knowledge distillation refers to a training method that simultaneously supervises the student model at three levels: task, feature, and output. The teacher model is a cloud-based full-attention model that performs pairwise attention interactions on all nodes within the window indiscriminately, resulting in high output accuracy but high computational cost. The student model is a lightweight model, namely the aforementioned local BA substitution model, where the number of attention heads, the hidden state dimension of the state space model, and the number of superpoints are configured according to the computing power budget of the embedded device. During training, keyframe data, map point data, and observation correlations from the sample sliding window are taken as training samples. The same training sample is input into both the teacher model and the student model, resulting in teacher output and student output, both of which include the pose increment of the keyframes within the window and the map point positions.
[0028] In this embodiment, the task loss calculated based on the student output is shown in the following formula:
[0029] In the formula, O represents the task loss; O is the set of feature observations within the sliding window. The matching confidence weight is the weight corresponding to the observation of map point i in keyframe j. Its value increases as the reliability of feature matching given by the visual front end increases, so that reliable observations account for a larger proportion of the loss. For map points Image point observations in keyframe j; π(·) is the pose of keyframe j in the student output; π(·) is the camera projection function; the first term on the right side of the equation is the confidence-weighted reprojection residual, which is used to constrain the keyframe pose of the student output to conform to the observation geometry with the map point position; W is the sliding window. Let be the translation component of the pose of keyframe j within the sliding window. and These are the translation components of the pose of the adjacent next keyframe and the previous keyframe within the window, respectively. The second term on the right side of the equals sign is the pose second-order difference smoothing constraint composed of these three components, which is used to suppress abrupt changes in the pose sequence within the window over time. The weights are the weights of the pose second-order difference smoothing constraint term.
[0030] In this embodiment, the feature layer alignment loss obtained by linearly aligning the intermediate layer features of the student model and the teacher model is shown in the following formula:
[0031] In the formula, For feature layer alignment loss; and These are the intermediate layer features of the lth layer of the student model and the teacher model, respectively. The learnable linear alignment matrix is used to map the intermediate layer features of the teacher model to the same dimension as the intermediate layer features of the student model, thus eliminating the impact of inconsistent feature dimensions. ‖·‖ represents the Frobenius norm, which is the square root of the sum of the squares of the matrix elements. This embodiment applies feature layer alignment to three corresponding levels of the student and teacher models, with the alignment loss of each level summed according to preset weights. This allows the geometric representation of the teacher model to be transferred layer by layer to the student model, compensating for the lack of constraints in the intermediate layers when supervision is only applied at the output.
[0032] In this embodiment, the output layer alignment loss calculated using the teacher's output as the soft label is shown in the following formula:
[0033] In the formula, This is the output layer alignment loss; and These are the window pose increments output by the student model and the teacher model, respectively. and These are the map point locations output by the student model and the teacher model, respectively. Compared to hard labels consisting solely of geometric truth values, the teacher model's output, as a soft label, also includes information on the error distribution of the teacher model across various observations, providing richer supervision signals for the student model.
[0034] In this embodiment, the tiered distillation loss obtained by combining the above losses is shown in the following formula:
[0035] In the formula, The hierarchical distillation loss is used; α and β are the weights of the feature layer alignment loss and the output layer alignment loss, respectively. In this embodiment, α=0.5 and β=1.0. The training data uses the TUM RGB-D public dataset and self-collected warehouse and home scene sequences. The output of the teacher model is supervised by the high-precision solution results of traditional sliding window local BA. The student model is trained with the hierarchical distillation loss until the loss converges, thus obtaining the local BA replacement model, which is then deployed to the edge embedded device. For example, under the condition that the number of parameters in the student model is reduced by 80% compared to the teacher model, the localization accuracy retention rate of the model trained by the above hierarchical knowledge distillation can be improved from 85% when training with only task loss to over 95%.
[0036] In step S102, the map point data is clustered and compressed using the local BA substitution model to obtain superpoint features, which are then combined with the keyframe data to form a window node sequence.
[0037] In one embodiment, step S102 includes: Using the local BA substitution model, clustering seeds for each superpoint are selected from the map point data by sampling from the farthest point; The similarity between each map point and the clustering seed is calculated based on spatial distance, the angle between normal vectors, and semantic consistency. Based on the similarity, each map point is iteratively assigned to the corresponding clustering seed to obtain a superpoint set with convergent members; Linear projection and mean pooling are performed on the features of map points within the superpoint set to obtain the corresponding superpoint features; The superpoint features and the keyframe features corresponding to the keyframe data are arranged in sequence to obtain the window node sequence.
[0038] In this embodiment, a superpoint refers to a set of map points that are spatially adjacent, have the same surface orientation, and the same semantic label. The map points within this set are called members of the superpoint. A superpoint feature is a feature vector that represents the overall information of the point set. Cluster compression refers to replacing a large number of map point features with fewer superpoint features in subsequent processing, thereby compressing the size of the nodes involved in the computation. A clustering seed is a map point used to represent a superpoint during the clustering process. Each map point is assigned to a corresponding superpoint according to its similarity to the clustering seed.
[0039] Farthest Point Sampling (FPS) involves first selecting a map point from the map point data as the initial cluster seed. Subsequently, each subsequent sampling selects a map point with the largest minimum spatial distance from the already selected cluster seed set as a new cluster seed, repeating this process until a predetermined number of cluster seeds are selected. This method results in spatially evenly distributed cluster seeds, preventing multiple cluster seeds from concentrating in the same local area and leaving some map points without a seed to belong to.
[0040] In this embodiment, the normal vector of a map point refers to the direction of the normal to the local surface where the map point is located. It is obtained by fitting map points within the neighborhood of the map point and is used to characterize the orientation of the object's surface at that location. The semantic label of a map point refers to the object category to which the visual front end identifies the map point. The similarity between each map point and the clustering seed is obtained by weighted summation of three criteria: spatial distance, angle between normal vectors, and semantic consistency, as shown in the following formula:
[0041] In the formula, The objective function for clustering is K, where a smaller value indicates a higher similarity between each map point and its superpoint; K is the total number of superpoints. Let x be the set of points corresponding to the kth superpoint; x is the set of points. The map points within the area are included in the calculation using their spatial coordinates in the first term on the right side of the equals sign; Let n be the spatial cluster center of the k-th superpoint, which is the mean of the spatial coordinates of all map points within that superpoint. The first term is the spatial distance term; n and n' ...""" These are the normal vectors of a map point and the average of the normal vectors of all map points within its superpoint, respectively. The second term is the angle between the normal vectors. This is a semantic consistency term. When the semantic label of a map point is inconsistent with the semantic label of its superpoint, this term takes a positive penalty value, and takes zero when they are consistent. and These are the weights of the angle between the normal vectors and the semantic consistency term, respectively. In this embodiment, we take... =0.3、 =0.2; ‖·‖ is the L2 norm of the vector. This criterion ensures that map points within the same superpoint remain homogeneous in terms of spatial location, surface orientation, and semantic category, thus preventing the loss of discriminative information during subsequent mean pooling.
[0042] In this embodiment, iterative allocation refers to repeatedly executing two stages: allocation and update. In the allocation stage, each map point is assigned to the superpoint corresponding to the cluster seed with the highest similarity, based on the aforementioned similarity. In the update stage, the spatial cluster center and average normal vector of each superpoint are updated using the mean spatial coordinates and mean normal vectors of all members within that superpoint. These two stages are executed alternately until the members of each superpoint no longer change, i.e., the members converge. The resulting point set is the superpoint set. For example, several map points located on the same wall, whose spatial positions are adjacent, whose normal vector directions are consistent, and whose semantic labels are all "wall," will be assigned to the same superpoint. However, map points located on a table in front of the wall, although spatially close to some of the wall map points, will be assigned to a different superpoint because their normal vector directions and semantic labels are different.
[0043] In this embodiment, the features of map points within the superpoint set are linearly projected and mean pooled to obtain the corresponding superpoint features, as shown in the following formula:
[0044] In the formula, X is the total set of map points within the sliding window, which is composed of the union of K superpoint sets; Let be the set of points corresponding to the kth superpoint; The superpoint feature of the k-th superpoint; | | represents the number of map points within the k-th superpoint set; x represents the point set in the formula. Feature vectors of points on the internal map; This is a learnable linear projection matrix used to map the features of map points to the same dimension as the keyframe features, allowing both types of features to participate in the computation within the same sequence. As can be seen from the above formula, the superpoint feature is the mean of the features of all map points within the superpoint after linear projection, thus enabling a single feature vector to carry the joint information of a homogeneous group of map points.
[0045] In this embodiment, the number of superpoints, K, is set to 48, meaning that approximately 320 map points within the window are compressed into 48 superpoint features. On an embedded platform with 1 to 2 TOPS computing power, the number of superpoints, K, can be set to a value no greater than 64 based on the computing power budget. Arranging the 48 superpoint features and 12 keyframe features sequentially yields a window node sequence of length 60, where each superpoint feature and each keyframe feature constitutes a node in this sequence. In contrast, in a point-level scheme where each map point is treated as an independent node, the length of the window node sequence is approximately 332. After the above clustering compression, the length of the window node sequence is compressed to approximately 18% of that in the point-level scheme, resulting in a corresponding decrease in the number of nodes participating in subsequent processing.
[0046] In step S103, the nodes in the window node sequence are divided into common-view nodes and non-common-view nodes according to the observation correlation relationship.
[0047] In one embodiment, step S103 includes: The number of shared feature points between node pairs is counted based on the observed correlation relationships. Node pairs whose number of shared feature points is not less than the co-view determination threshold are determined to be co-view node pairs; Nodes belonging to the shared-view node pair are assigned to the shared-view node set, and the remaining nodes are assigned to the non-shared-view node set.
[0048] In this embodiment, co-view refers to the situation where two nodes have shared feature points, such as two keyframe nodes observing the same batch of map points; the number of shared feature points refers to the number of feature points shared between two nodes, which can be directly obtained from the observation association relationship. Since the visual front end has already established and maintained the association of feature points between keyframes during the feature tracking stage, the statistics in this step can directly reuse the results of that stage without additional computational overhead. The determination of co-view partitioning is shown in the following formula:
[0049] In the formula, Let be the set of nodes that share a common view with node i, that is, the set of all nodes within the sliding window that form a common view pair with node i. Let be the set of non-co-visual nodes of node i; W be all nodes within the sliding window; j be any other node within the sliding window; The number of shared feature points between node i and node j; For the common-view determination threshold, this embodiment takes... =10.
[0050] In this embodiment, when the number of shared feature points between node i and node j is not less than the co-view determination threshold, node i and node j are determined to form a co-view node pair. Nodes belonging to the co-view node pair are assigned to the co-view node set, while nodes that do not form a co-view node pair with any other node in the sliding window are assigned to the non-co-view node set. For example, if the number of shared feature points between node i and node j is 23, which is not less than the threshold 10, then the two form a co-view node pair, and both node i and node j are assigned to the co-view node set; if the number of shared feature points between node i and node j is 4, which is less than the threshold 10, then the two do not form a co-view node pair; if the number of shared feature points between a node and all other nodes in the sliding window is less than the threshold 10, such as a keyframe node that has just entered the sliding window and has a large change in viewpoint, or a superpoint node located at the edge of the field of view and only observed in a single frame, then this node is assigned to the non-co-view node set.
[0051] In this embodiment, the value of the common-view determination threshold affects the size of the common-view node set: if the threshold is too small, node pairs with fewer shared feature points and weaker geometric constraints will also be determined as common-view node pairs, thus increasing the size of the common-view node set; if the threshold is too large, some node pairs with effective geometric constraints will be classified into the non-common-view node set. In this embodiment, the threshold is set to 10, so that the common-view node set can cover node pairs with effective geometric constraints within the window without becoming too large. The common-view node set and the non-common-view node set obtained from the common-view partition are used to determine the processing method adopted by each node in the window node sequence during subsequent feature updates.
[0052] In step S104, sparse attention interaction is performed on the set of co-viewing nodes, state recursion is performed on the set of non-co-viewing nodes, and the two outputs are fused to obtain the updated node features.
[0053] In one embodiment, step S104 includes: Perform sparse attention interaction constrained by the common-view mask matrix on the set of common-view nodes to obtain the sparse attention branch output; Perform temporal state recursion of the linear state-space model on the set of non-common-view nodes to obtain the state recursion branch output; The output of the sparse attention branch is concatenated with the output of the state recursion branch, and after passing through a linear layer and an activation function, the gating coefficient is output. Based on the gating coefficient, residual gating fusion is performed on the two outputs to obtain the fused node features; The fused node features are processed by a feedforward network and layer normalization to obtain updated node features.
[0054] In this embodiment, there is a direct observation relationship between co-seeing nodes, and their pose and position estimations are mutually constrained. Therefore, an attention-based interaction method is used to accurately transmit geometric constraint information between nodes. There is no direct observation relationship between non-co-seeing nodes; their mutual influence is mainly transmitted indirectly along the temporal direction within the window. Therefore, a state recursion method with lower computational overhead is used to transmit implicit information. The two types of nodes process and collaboratively complete the feature update of all nodes within the window, as shown in the following equation:
[0055] In the formula, Let i be the feature obtained after processing the corresponding branch of node i; SparseAttn(·) is the common-view mask sparse attention operator; Let i be the query vector for node i; and are the key matrix and value matrix corresponding to the set of common-view nodes of node i, respectively; SSM(·) is the recursive operator of the linear state space model (SSM); This represents the hidden state of the previous node in the window node sequence. This is the input feature vector of node i, also known as the node's token in the Transformer network; and These are the sets of nodes that share a common view and the sets of nodes that do not share a common view, respectively.
[0056] In this embodiment, sparse attention interactions constrained by a common-view mask matrix are performed on the set of shared-view nodes. The common-view mask matrix is used to restrict attention interactions to pairs of shared-view nodes. The resulting sparse attention branch output is shown in the following equation:
[0057] In the formula, This is the output of the sparse attention branch; Q, K, and V are the query matrix, key matrix, and value matrix obtained by linear transformation of node features, respectively, and the superscript T indicates the transpose of the matrix; The dimension of the attention head is used to scale the dot product result by dividing by its square root, avoiding excessively large values before normalization; M is the common-view mask matrix, whose elements correspond one-to-one with node pairs. Elements corresponding to common-view node pairs are 0, and elements corresponding to non-common-view node pairs are negative infinity, ensuring that the attention weights between non-common-view node pairs are strictly zero after normalization by the softmax function; softmax(·) is the normalization exponential function used to convert the attention score into weights that sum to 1. Since the attention weights of non-common-view node pairs are always zero, the operation of this branch is actually performed only on the set of common-view edges, and its computational complexity is linearly related to the number of common-view edges, rather than quadratically related to the number of nodes. In this embodiment, the number of attention heads is 4, and the dimension of the node features is 96.
[0058] In this embodiment, a temporal state recursion of a linear state-space model is performed on the set of non-co-seeing nodes to obtain the state recursion branch output, as shown in the following equation:
[0059] In the formula, Let be the hidden state vector of the i-th node. Ā is the hidden state vector of the previous node in the window node sequence; Ā is the state transition matrix, B̄ is the input mapping matrix, both of which are parameterized by the state space model and diagonalized, and are shared along the time axis, that is, the recursion of each node in the window uses the same set of parameters; C is the output mapping matrix. This is the input feature vector of the current node; The output is the recursive branch for the state of node i. Since the state transition matrix is diagonalized, the dimensions of the hidden state are updated independently. The computational cost of updating the hidden state of a single node is constant, and the total computational cost of recursing the states of all nodes is linearly related to the number of nodes, denoted as O(N), where N is the number of nodes in the window node sequence. This is significantly lower than the O(N²) of full attention. In this embodiment, the hidden state dimension of the state space model is 128; on embedded platforms with 1 to 2 TOPS computing power, the hidden state dimension can be set to a value no greater than 128 based on the computing power budget.
[0060] In this embodiment, the outputs of the sparse attention branch and the state recursion branch are concatenated along the feature dimension, processed by a linear layer and a sigmoid activation function to output gating coefficients, and then residual gating fusion is performed on the two outputs according to the gating coefficients, as shown in the following equation:
[0061] In the formula, The node features after fusion of node i; Let be the gating coefficient for node i; and These are the sparse attention branch output and the state recursion branch output of node i, respectively; [·;·] represents the concatenation of the two outputs along the feature dimension; and Here, σ and φ are the weight matrix and bias vector of the linear layer, respectively; σ(·) is the Sigmoid activation function, used to compress the output of the linear layer to between 0 and 1. As can be seen from the above equation, the sum of the weights corresponding to the two outputs is always 1, and the fusion result is a convex combination of the two outputs. When a node is located in a feature-rich region with sufficient common vision, the gating coefficient approaches 1, and the fusion result is biased towards the sparse attention branch to ensure the modeling accuracy of the common vision constraint; when a node is located in a low-texture region with weak common vision, the gating coefficient approaches 0, and the fusion result is biased towards the state recursion branch to maintain the temporal consistency of the node. The gating coefficient is learned automatically by the network during training, without the need for manual setting of switching rules, thus allowing computational resources to be adaptively allocated according to the features of the scene in which the node is located.
[0062] In this embodiment, the fused node features are processed by a feedforward network and layer normalization to obtain updated node features. The feedforward network (FFN) consists of two linear transformation layers and a nonlinear activation function in between, used to perform nonlinear transformations on the features of each node node-by-node to improve the expressive power of the features. Layer normalization is used to normalize the feature vector of each node along its feature dimension, keeping the distribution of features of each node stable and preventing numerical drift as the number of network layers increases. The updated node features obtained after the above processing are the output of this step.
[0063] In this embodiment, since sparse attention interaction is performed only on the set of shared edges, the computational complexity of state recursion is linearly related to the number of nodes. This step reduces the overall computational complexity of window node feature update from O(N²) in the full attention architecture to O(N) while maintaining the modeling accuracy of shared constraints.
[0064] In step S105, the updated node features are output decoded to obtain the optimized keyframe pose and optimized map point position within the sliding window.
[0065] In one embodiment, step S105 includes: The updated node features are separated into keyframe node features and super-node features according to node type; The keyframe node features and the superpoint node features are decoded respectively to obtain the pose increment and the superpoint position update amount; The pose increment is superimposed on the initial pose in the keyframe data to obtain the optimized keyframe pose. Based on the association between map points and superpoints established by the clustering compression, the superpoint position update amount is mapped to each map point to obtain the correction amount of each map point. The coordinates of each map point in the map point data are adjusted according to the correction amount to obtain the optimized map point position.
[0066] In this embodiment, node type refers to the source category of a node in the window node sequence, including two categories: keyframe nodes composed of keyframe features and superpoint nodes composed of superpoint features. Since the window node sequence is arranged in a fixed order, the position of each node in the sequence corresponds one-to-one with its source. Therefore, the updated node features can be directly separated into keyframe node features and superpoint node features based on their position. In this embodiment, a window node sequence of length 60 is separated into 12 keyframe node features and 48 superpoint node features.
[0067] In this embodiment, decoding keyframe node features and superpoint node features separately means using two independent decoding heads to perform linear transformations on the two types of node features respectively. The keyframe decoding head outputs the pose increment, and the superpoint decoding head outputs the superpoint position update. The pose increment refers to the change in the keyframe pose relative to its initial pose, including three translational components and three rotational components. The superpoint position update refers to the correction vector of the superpoint's spatial position, which is a three-dimensional vector. Using an incremental form instead of directly outputting the absolute pose allows for a smaller output range and more stable values from the decoding head, while retaining the initial estimation information already provided by the visual front end.
[0068] In this embodiment, the pose increment is superimposed on the initial pose in the keyframe data to obtain the optimized keyframe pose. For example, for a keyframe within a sliding window, if the translation component of its initial pose is (1.200, 0.350, 0.080) and the translation component of the decoded pose increment is (0.006, −0.003, 0.001), then the optimized translation component of the keyframe pose is (1.206, 0.347, 0.081). The rotation component is converted into a rotation correction transformation through Lie algebra exponential mapping, i.e., the rotation matrix corresponding to the rotation component, and then combined with the initial pose of the keyframe to obtain the optimized keyframe pose.
[0069] In this embodiment, the attribution relationship between map points and superpoints refers to the correspondence between each map point and its superpoint established in the clustering compression of step S102. Based on this attribution relationship, the superpoint position update is mapped to each map point; that is, the position update of a certain superpoint is used as the correction amount for all member map points within that superpoint. Then, the coordinates of each map point in the map point data are adjusted according to the correction amount; that is, the sum of the original coordinates of each map point and its correction amount is used as the new coordinates of that map point, thereby obtaining the optimized map point positions. For example, if a superpoint contains 7 map points, and the decoded position update of the superpoint is (0.004, 0.002, −0.001), then the coordinates of all 7 map points within the superpoint are adjusted according to this update amount. Thus, the position update amounts of 48 superpoints are restored to the coordinate corrections of all approximately 320 map points within the window, ensuring consistency in form between the output results and traditional local BA while compressing the node scale.
[0070] In step S106, the optimized keyframe pose and the optimized map point position are written back to the sliding window to obtain the state-updated sliding window.
[0071] In one embodiment, step S106 includes: Write the optimized keyframe pose back to the state data of the corresponding keyframe in the sliding window; The optimized map point locations are written back to the map point data structure associated with the sliding window; The sliding window is updated based on the written-back state data and map point data structure to obtain the state-updated sliding window. The updated sliding window is sent to the visual front end for subsequent feature tracking.
[0072] In this embodiment, state data refers to the state quantities maintained by the sliding window for each keyframe, including at least the pose of that keyframe; map point data structure refers to the data structure associated with the sliding window used to store the coordinates of map points within the window and their observation relationships. Write-back means overwriting the corresponding original values in the aforementioned state data and data structure with optimized values, without changing their organization and indexing method.
[0073] In this embodiment, the optimized keyframe poses are first written back to the state data of the corresponding keyframes in the sliding window according to the keyframe identifiers. Then, the optimized map point positions are written back to the map point data structure associated with the sliding window according to the map point identifiers. Subsequently, the sliding window is updated according to the written-back state data and the map point data structure, that is, the written-back values are used as the current state of the sliding window, thereby obtaining the state-updated sliding window.
[0074] In this embodiment, after the updated sliding window is sent to the visual front end, the visual front end uses the optimized keyframe pose and map point position as a reference for subsequent feature tracking. For example, it predicts the position of feature points in the next frame image and narrows the search range accordingly, thereby improving the efficiency and stability of feature tracking.
[0075] In this embodiment, since the input of this method consists of keyframe data, map point data, and observation correlations within the sliding window, and the output is the optimized keyframe pose and optimized map point position written back to the sliding window, the input and output are consistent with those of the traditional sliding window local BA solving module. Therefore, the existing sliding window local BA solving module in the visual SLAM system can be replaced using the same interface without modifying the feature extraction, feature tracking, and keyframe selection processes of the visual front end. For example, for an already deployed edge-side visual SLAM system, only the iterative local BA solving module at the back end needs to be replaced with the local BA replacement model of this embodiment to complete the upgrade without changing the visual front end.
[0076] In summary, the Transformer local BA replacement method provided in this embodiment of the invention obtains superpoint features by clustering and compressing map point data, thereby compressing the length of the window node sequence in terms of node scale. Furthermore, based on observation correlations, the window nodes are divided into a set of shared-view nodes and a set of non-shared-view nodes. Sparse attention interaction is performed on the shared-view node set, and state recursion is performed on the non-shared-view node set. The two outputs are then fused to obtain the updated node features, making the computational workload of updating window node features linearly increase with the number of nodes. Combined with hierarchical knowledge distillation training, the model, even with compressed parameter scale, can still maintain optimization accuracy.
[0077] On an embedded platform equipped with a quad-core Cortex-A76 processor and a 1 TOPS NPU, the results were validated using a 12-frame sliding window sequence with an average of 320 map points per window. Traditional sliding window local BA took 38 ms to complete a single window optimization. The Transformer alternative using a full-attention architecture had a window node sequence length of approximately 332, requiring 6.2 times the memory of traditional sliding window local BA, making it unsuitable for real-time operation on the same platform. The embodiment of this invention uses a window node sequence length of 60 (12 keyframe nodes and 48 superpoint nodes), completing a single window optimization in 31 ms, achieving a real-time processing frame rate of 30 Hz, and reducing memory usage by 72% compared to traditional sliding window local BA. Regarding positioning accuracy, based on the results of traditional sliding window local BA, the Transformer alternative using a full-attention architecture achieved an accuracy retention rate of 97%, but could not be deployed on the edge. The embodiment of this invention achieved an accuracy retention rate of 95.6%.
[0078] Therefore, this invention achieves real-time optimization comparable to the accuracy of traditional sliding window local BA on edge embedded devices with limited computing power. Moreover, it can replace existing solution modules without modifying the vision front end. It can be applied to service robots, augmented reality (AR) glasses, virtual reality (VR) glasses, and industrial automated guided vehicles (AGVs) and other scenarios with strict limitations on size, power consumption and computing power.
[0079] Combination Figure 2 As shown, Figure 2 This is a schematic block diagram of a Transformer local BA replacement device provided in an embodiment of the present invention. The Transformer local BA replacement device 200 includes: The data acquisition module 201 is used to acquire keyframe data, map point data and observation correlation within the sliding window, and input them into the local BA substitution model that has been pre-trained by knowledge distillation. The superpoint clustering module 202 is used to cluster and compress the map point data through the local BA substitution model to obtain superpoint features, and form a window node sequence with the keyframe data; The common-view partitioning module 203 is used to perform common-view partitioning on the nodes in the window node sequence according to the observation correlation relationship, so as to obtain a common-view node set and a non-common-view node set. Feature update module 204 is used to perform sparse attention interaction on the set of co-view nodes, perform state recursion on the set of non-co-view nodes, and fuse the two outputs to obtain the updated node features. The output decoding module 205 is used to decode the updated node features to obtain the optimized keyframe pose and the optimized map point position within the sliding window. The state write-back module 206 is used to write back the optimized keyframe pose and the optimized map point position to the sliding window to obtain the state-updated sliding window.
[0080] In this embodiment, the data acquisition module 201 is used to acquire keyframe data, map point data, and observation correlations within the sliding window, and input them into a local BA substitution model pre-trained by knowledge distillation; the superpoint clustering module 202 is used to cluster and compress the map point data through the local BA substitution model to obtain superpoint features, and form a window node sequence with the keyframe data; the common-view partitioning module 203 is used to partition the nodes in the window node sequence according to the observation correlations to obtain a common-view node set and a non-common-view node set; the feature update module 204 is used to perform sparse attention interaction on the common-view node set, perform state recursion on the non-common-view node set, and fuse the two outputs to obtain updated node features; the output decoding module 205 is used to decode the updated node features to obtain the optimized keyframe pose and optimized map point position within the sliding window; the state write-back module 206 is used to write back the optimized keyframe pose and optimized map point position to the sliding window to obtain a state-updated sliding window. The modules described above are connected in sequence and respectively implement steps S101 to S106 in the aforementioned method embodiment.
[0081] In one embodiment, the local BA substitution model in the data acquisition module 201 is obtained through hierarchical knowledge distillation training, the training process of which includes: Keyframe data, map point data, and observation correlations of the sample sliding window are obtained and used as training samples. The training samples are input into the fully attention-based teacher model and the lightweight student model respectively, and the corresponding teacher output and student output are obtained. Based on the student output, the confidence-weighted reprojection residual and the pose second-order difference smoothing constraint are calculated to obtain the task loss. Linearly align the intermediate layer features of the student model and the teacher model to obtain the feature layer alignment loss; The output layer alignment loss is calculated using the teacher's output as a soft label, and the local BA replacement model is obtained by training the various losses together.
[0082] In one embodiment, the super-clustering module 202 is specifically used for: Using the local BA substitution model, clustering seeds for each superpoint are selected from the map point data by sampling from the farthest point; The similarity between each map point and the clustering seed is calculated based on spatial distance, the angle between normal vectors, and semantic consistency. Based on the similarity, each map point is iteratively assigned to the corresponding clustering seed to obtain a superpoint set with convergent members; Linear projection and mean pooling are performed on the features of map points within the superpoint set to obtain the corresponding superpoint features; The superpoint features and the keyframe features corresponding to the keyframe data are arranged in sequence to obtain the window node sequence.
[0083] In one embodiment, the common-view partitioning module 203 is specifically used for: The number of shared feature points between node pairs is counted based on the observed correlation relationships. Node pairs whose number of shared feature points is not less than the co-view determination threshold are determined to be co-view node pairs; Nodes belonging to the shared-view node pair are assigned to the shared-view node set, and the remaining nodes are assigned to the non-shared-view node set.
[0084] In one embodiment, the feature update module 204 is specifically used for: Perform sparse attention interaction constrained by the common-view mask matrix on the set of common-view nodes to obtain the sparse attention branch output; Perform temporal state recursion of the linear state-space model on the set of non-common-view nodes to obtain the state recursion branch output; The output of the sparse attention branch is concatenated with the output of the state recursion branch, and after passing through a linear layer and an activation function, the gating coefficient is output. Based on the gating coefficient, residual gating fusion is performed on the two outputs to obtain the fused node features; The fused node features are processed by a feedforward network and layer normalization to obtain updated node features.
[0085] In one embodiment, the output decoding module 205 is specifically used for: The updated node features are separated into keyframe node features and super-node features according to node type; The keyframe node features and the superpoint node features are decoded respectively to obtain the pose increment and the superpoint position update amount; The pose increment is superimposed on the initial pose in the keyframe data to obtain the optimized keyframe pose. Based on the association between map points and superpoints established by the clustering compression, the superpoint position update amount is mapped to each map point to obtain the correction amount of each map point. The coordinates of each map point in the map point data are adjusted according to the correction amount to obtain the optimized map point position.
[0086] In one embodiment, the state write-back module 206 is specifically used for: Write the optimized keyframe pose back to the state data of the corresponding keyframe in the sliding window; The optimized map point locations are written back to the map point data structure associated with the sliding window; The sliding window is updated based on the written-back state data and map point data structure to obtain the state-updated sliding window. The updated sliding window is sent to the visual front end for subsequent feature tracking.
[0087] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0088] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed, can perform the steps provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0089] This invention also provides a computer device, which may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the steps provided in the above embodiments. Of course, the computer device may also include various network interfaces, a power supply, a graphics card, etc., to utilize the graphics card's performance to operate the model, such as for inference and training.
[0090] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0091] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method for replacing local BAs in a Transformer, characterized in that, include: Acquire keyframe data, map point data, and observation relationships within the sliding window, and input them into a local BA substitution model that has been pre-trained by knowledge distillation; The map point data is clustered and compressed using the local BA substitution model to obtain superpoint features, which are then combined with the keyframe data to form a window node sequence. Based on the observation correlation, the nodes in the window node sequence are divided into common-view nodes and non-common-view nodes; Sparse attention interaction is performed on the set of co-view nodes, state recursion is performed on the set of non-co-view nodes, and the two outputs are fused to obtain the updated node features. The updated node features are decoded to obtain the optimized keyframe pose and optimized map point position within the sliding window; The optimized keyframe poses and the optimized map point positions are written back to the sliding window to obtain the updated sliding window.
2. The Transformer local BA replacement method according to claim 1, characterized in that, The local BA substitution model is obtained through hierarchical knowledge distillation training, the training process of which includes: Keyframe data, map point data, and observation correlations of the sample sliding window are obtained and used as training samples. The training samples are input into the fully attention-based teacher model and the lightweight student model respectively, and the corresponding teacher output and student output are obtained. Based on the student output, the confidence-weighted reprojection residual and the pose second-order difference smoothing constraint are calculated to obtain the task loss. Linearly align the intermediate layer features of the student model and the teacher model to obtain the feature layer alignment loss; The output layer alignment loss is calculated using the teacher's output as a soft label, and the local BA replacement model is obtained by training the various losses together.
3. The Transformer local BA replacement method according to claim 1, characterized in that, The process of clustering and compressing the map point data using the local BA substitution model to obtain superpoint features, and then combining these features with the keyframe data to form a window node sequence, includes: Using the local BA substitution model, clustering seeds for each superpoint are selected from the map point data by sampling from the farthest point; The similarity between each map point and the clustering seed is calculated based on spatial distance, the angle between normal vectors, and semantic consistency. Based on the similarity, each map point is iteratively assigned to the corresponding clustering seed to obtain a superpoint set with convergent members; Linear projection and mean pooling are performed on the features of map points within the superpoint set to obtain the corresponding superpoint features; The superpoint features and the keyframe features corresponding to the keyframe data are arranged in sequence to obtain the window node sequence.
4. The Transformer local BA replacement method according to claim 1, characterized in that, The step of dividing the nodes in the window node sequence into common-view nodes and non-common-view nodes based on the observation correlation includes: The number of shared feature points between node pairs is counted based on the observed correlation relationships. Node pairs whose number of shared feature points is not less than the co-view determination threshold are determined to be co-view node pairs; Nodes belonging to the shared-view node pair are assigned to the shared-view node set, and the remaining nodes are assigned to the non-shared-view node set.
5. The Transformer local BA replacement method according to claim 1, characterized in that, The process of performing sparse attention interaction on the set of nodes with shared views, performing state recursion on the set of nodes with non-shared views, and fusing the two outputs to obtain the updated node features includes: Perform sparse attention interaction constrained by the common-view mask matrix on the set of common-view nodes to obtain the sparse attention branch output; Perform temporal state recursion of the linear state-space model on the set of non-common-view nodes to obtain the state recursion branch output; The output of the sparse attention branch is concatenated with the output of the state recursion branch, and after passing through a linear layer and an activation function, the gating coefficient is output. Based on the gating coefficient, residual gating fusion is performed on the two outputs to obtain the fused node features; The fused node features are processed by a feedforward network and layer normalization to obtain updated node features.
6. The Transformer local BA replacement method according to claim 1, characterized in that, The step of decoding the updated node features to obtain the optimized keyframe pose and optimized map point position within the sliding window includes: The updated node features are separated into keyframe node features and super-node features according to node type; The keyframe node features and the superpoint node features are decoded respectively to obtain the pose increment and the superpoint position update amount; The pose increment is superimposed on the initial pose in the keyframe data to obtain the optimized keyframe pose. Based on the association between map points and superpoints established by the clustering compression, the superpoint position update amount is mapped to each map point to obtain the correction amount of each map point. The coordinates of each map point in the map point data are adjusted according to the correction amount to obtain the optimized map point position.
7. The Transformer local BA replacement method according to claim 1, characterized in that, The step of writing back the optimized keyframe pose and the optimized map point position to the sliding window to obtain the state-updated sliding window includes: Write the optimized keyframe pose back to the state data of the corresponding keyframe in the sliding window; The optimized map point locations are written back to the map point data structure associated with the sliding window; The sliding window is updated based on the written-back state data and map point data structure to obtain the state-updated sliding window. The updated sliding window is sent to the visual front end for subsequent feature tracking.
8. A Transformer partial BA replacement device, characterized in that, include: The data acquisition module is used to acquire keyframe data, map point data, and observation relationships within the sliding window, and input them into the local BA substitution model that has been pre-trained by knowledge distillation. The superpoint clustering module is used to cluster and compress the map point data using the local BA substitution model to obtain superpoint features, and form a window node sequence with the keyframe data. The common-view partitioning module is used to partition the nodes in the window node sequence into common-view nodes and non-common-view nodes according to the observation correlation relationship, so as to obtain a common-view node set and a non-common-view node set. The feature update module is used to perform sparse attention interaction on the set of co-visible nodes, perform state recursion on the set of non-co-visible nodes, and fuse the two outputs to obtain the updated node features. The output decoding module is used to decode the updated node features to obtain the optimized keyframe pose and the optimized map point position within the sliding window. The state write-back module is used to write back the optimized keyframe pose and the optimized map point position to the sliding window to obtain the state-updated sliding window.
9. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the Transformer local BA replacement method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the Transformer local BA replacement method as described in any one of claims 1 to 7.
