A SLAM global bundle adjustment replacement method, device, equipment and medium

By encoding keyframe poses and map point coordinates into terms and using an attention-optimized network for layer-by-layer updates, the problem of excessive computational cost in global bundle adjustment in large-scale scenes is solved, and global consistency can be maintained quickly in SLAM systems.

CN123181770APending Publication Date: 2026-11-27SHENZHEN NEW TREND INT ROBOT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611698099.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-30
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing global bundle adjustment methods require iterative solutions in large-scale scenarios, leading to a superlinear increase in computational load and making it difficult to maintain global consistency in real-time SLAM systems.

Method used

The keyframe pose and map point coordinates are encoded into pose terms and map point terms, and then updated layer by layer through an attention optimization network. Attention bias is generated by combining reprojection error and matching reliability, and the keyframe pose and map point coordinates are optimized layer by layer.

Benefits of technology

It reduces the time spent on each global optimization, can maintain global consistency in large-scale scenes as keyframes increase, avoids the computational burden of repeatedly constructing normal equations in traditional methods, and improves real-time performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123181770A_ABST
    Figure CN123181770A_ABST
Patent Text Reader

Abstract

The application discloses a SLAM global light beam method adjustment replacement method, device, equipment and medium, and the method comprises the steps of obtaining an initial key frame pose, initial map point coordinates, feature observation correlation and matching confidence output by a SLAM front end; encoding the initial key frame pose and the initial map point coordinates into pose words and map point words respectively; calculating a re-projection error according to the feature observation correlation, and generating an attention bias combined with the matching confidence; inputting the pose words, the map point words and the attention bias into an attention optimization network, alternately updating and decoding layer by layer, and obtaining optimized key frame poses and map point coordinates; and when a new key frame is added, the history key value cached by the attention optimization network is reused for incremental updating. The application replaces iterative solving with one-time feedforward reasoning of the attention optimization network, reuses the history key value to process the new key frame, shortens the single-time consumption of global optimization, and maintains the global consistency in time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a SLAM global bundle adjustment substitution method, apparatus, equipment and medium. Background Technology

[0002] Simultaneous Localization and Mapping (SLAM) technology, based on image sequences captured by cameras, simultaneously estimates the device's own trajectory and constructs a 3D map of the environment under conditions of prior unknown. It is widely used in augmented reality, drone navigation, and service robots. Bundle Adjustment (BA) is a core component of the visual SLAM backend. It uses the poses of all keyframes and the 3D coordinates of all map points as variables to be optimized, and the sum of the reprojection errors of each map point across all keyframes observing that point as the objective function. Through joint optimization, it ensures that the trajectory and the 3D map remain consistent on a global scale.

[0003] Existing global bundle adjustment methods are typically based on Gauss-Newton iterations or Levenberg-Marquardt iterations. The solution process involves first calculating the reprojection residuals for each observation based on the current keyframe pose and map point coordinates. Then, the Jacobian matrix of the reprojection residuals with respect to the keyframe pose and map point coordinates is obtained, and a Hessian approximation matrix is ​​constructed based on this. Subsequently, using Schul complement elimination, the normal equations formed by this Hessian approximation matrix and the residual terms are solved to obtain the updated keyframe pose and map point coordinates, which are then added to the current estimate. This process of residual calculation, linearization, and normal equation solving is repeated until the updated values ​​converge below a preset threshold. To suppress the impact of feature mismatches on the solution results, a robust kernel function is introduced into the objective function, and its truncation threshold is manually set.

[0004] However, the above solution process requires repeatedly constructing and solving normal equations whose scale increases with the number of nodes. The computational cost increases superlinearly with the increase of the number of keyframes and map points. A single global solution often requires dozens of iterations to converge, resulting in excessively long single-time consumption of global bundle adjustment in large-scale scenes. In real-time visual SLAM systems, it is difficult to trigger global optimization as needed, and global consistency cannot be maintained in a timely manner. Summary of the Invention

[0005] This invention provides an alternative method, apparatus, device, and medium for SLAM global bundle adjustment, aiming to solve the technical problem that in the prior art, global bundle adjustment requires repeated iterative solutions and the time consumed per iteration increases superlinearly with the scene size, resulting in the inability to maintain global consistency in a timely manner.

[0006] In a first aspect, embodiments of the present invention provide a global bundle adjustment substitution method for SLAM, comprising: Obtain the initial keyframe pose and initial map point coordinates output by the SLAM front-end, as well as the feature observation correlation and matching confidence between each keyframe and each map point; The initial keyframe pose and the initial map point coordinates are encoded respectively to obtain the pose words corresponding to each keyframe and the map point words corresponding to each map point. Based on the feature observation association, the reprojection error between the pose lexicon and the map point lexicon is calculated, and the attention bias is generated by combining the matching confidence. The pose lexicon, the map point lexicon, and the attention bias input attention optimization network are alternately updated layer by layer to obtain the optimized pose lexicon and map point lexicon. The optimized pose words and the optimized map point words are decoded respectively to obtain the optimized keyframe pose and the optimized map point coordinates; When a new keyframe is added, the historical key values ​​cached by the attention optimization network are reused, and the optimized keyframe pose and map point coordinates are incrementally updated.

[0007] Secondly, embodiments of the present invention provide a SLAM global bundle adjustment substitution apparatus, comprising: The data acquisition module is used to acquire the initial keyframe pose and initial map point coordinates output by the SLAM front end, as well as the feature observation correlation and matching confidence between each keyframe and each map point. The lexical encoding module is used to encode the initial keyframe pose and the initial map point coordinates respectively to obtain the pose lexicals corresponding to each keyframe and the map point lexicals corresponding to each map point. The bias generation module is used to calculate the reprojection error between the pose lexicon and the map point lexicon based on the feature observation association, and generate an attention bias by combining the matching confidence. The iterative optimization module is used to input the pose lexical unit, the map point lexical unit, and the attention bias into the attention optimization network, and update the optimized pose lexical unit and map point lexical unit layer by layer. The output decoding module is used to decode the optimized pose words and the optimized map point words respectively to obtain the optimized keyframe pose and the optimized map point coordinates; The incremental update module is used to reuse the historical key values ​​of the attention optimization network cache when a new keyframe is added, and incrementally update the optimized keyframe pose and map point coordinates.

[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 SLAM global bundle adjustment substitution 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 SLAM global bundle adjustment substitution method of the first aspect.

[0010] This invention provides a SLAM global bundle adjustment substitution method. It acquires the initial keyframe pose and initial map point coordinates output by the SLAM front-end, as well as the feature observation association and matching confidence between each keyframe and each map point. The initial keyframe pose and the initial map point coordinates are encoded to obtain pose terms corresponding to each keyframe and map point terms corresponding to each map point. Based on the feature observation association, the reprojection error corresponding to the pose terms and map point terms is calculated, and an attention bias is generated by combining the matching confidence. The pose terms, map point terms, and attention bias are input into an attention optimization network, and the optimized pose terms and map point terms are updated layer by layer. The optimized pose terms and optimized map point terms are decoded to obtain the optimized keyframe pose and optimized map point coordinates. When a new keyframe is added, the historical key values ​​cached by the attention optimization network are reused to incrementally update the optimized keyframe pose and map point coordinates.

[0011] This invention encodes keyframe poses and map point coordinates into pose terms and map point terms with unified dimensions. This transforms the geometric optimization variables, which originally required successive linear solutions, into inputs that can be processed by an attention optimization network. The updates to keyframe poses and map point coordinates are then provided by a single feedforward inference from the attention optimization network, eliminating the need to repeatedly construct and solve normal equations whose scale increases with the number of nodes. Furthermore, reprojection errors are combined with matching confidence to generate attention biases, which are then injected into the attention calculation. This reduces the weight of observations with large reprojection errors and low matching confidence after normalization, limiting the impact of mismatched observations on the optimization results without manually setting a truncation threshold. Therefore, stable optimization results can still be obtained even with limited initial accuracy. Intermediate results are passed between attention optimization layers via residual connections. Pose terms and map point terms are updated alternately layer by layer. Even if the correction amplitude of a single layer is limited, the cumulative effect across multiple layers can achieve a convergence level comparable to multiple iterative solutions. When a new keyframe is added, the historical key-values ​​cached by the attention optimization network are reused. The addition of a new keyframe and a new map point only requires one incremental attention calculation with the already cached historical key-values. The cost of maintaining the global result is related to the number of new nodes but not to the existing scene size. Therefore, this invention solves the technical problem in existing technologies where global bundle adjustment requires repeated iterative solutions and the time consumed per iteration increases superlinearly with scene size, leading to the inability to maintain global consistency in a timely manner. It shortens the time consumed per iteration of global optimization, enabling global consistency in large-scale scenes to be continuously maintained as the number of keyframes increases.

[0012] This invention also provides a SLAM global bundle adjustment substitution device, a computer device, and a storage medium, which have the same beneficial effects as described above. Attached Figure Description

[0013] 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.

[0014] Figure 1 A schematic flowchart of a SLAM global bundle adjustment substitution method provided in an embodiment of the present invention; Figure 2 A schematic block diagram of a SLAM global bundle adjustment substitution device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the hierarchical structure of the attention optimization network in a SLAM global bundle adjustment substitution method provided in an embodiment of the present invention. Detailed Implementation

[0015] 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.

[0016] 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.

[0017] 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.

[0018] 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.

[0019] Please see below. Figure 1 , Figure 1 The flowchart of a SLAM global bundle adjustment substitution method provided in this embodiment of the invention specifically includes steps S101 to S106.

[0020] S101. Obtain the initial keyframe pose and initial map point coordinates output by the SLAM front-end, as well as the feature observation correlation and matching confidence between each keyframe and each map point. S102. Encode the initial keyframe pose and the initial map point coordinates respectively to obtain the pose words corresponding to each keyframe and the map point words corresponding to each map point. S103. Based on the feature observation association, calculate the reprojection error between the pose lexicon and the map point lexicon, and generate an attention bias by combining the matching confidence. S104. The pose lexicon, the map point lexicon, and the attention bias are input into the attention optimization network and updated layer by layer to obtain the optimized pose lexicon and map point lexicon. S105. Decode the optimized pose words and the optimized map point words respectively to obtain the optimized keyframe pose and the optimized map point coordinates. S106. When a new keyframe is added, the historical key values ​​of the attention optimization network cache are reused, and the optimized keyframe pose and map point coordinates are incrementally updated.

[0021] This embodiment uses a visual SLAM system built with a binocular camera or a depth camera (RGB-D camera) as the carrier. The program modules corresponding to steps S101 to S106 are deployed on the host's graphics processing unit (GPU) or the edge's neural network processing unit (NPU) to replace the global bundle adjustment module at the back end of the visual SLAM system. The input and output quantities of the method are consistent with the existing global bundle adjustment module, so it can be connected to visual SLAM systems such as ORB-SLAM3 and DROID-SLAM in a plug-and-play manner, and is suitable for real-time positioning applications in large-scale scenarios such as augmented reality, drones, and service robots.

[0022] To facilitate understanding, the basic objects involved in this embodiment will first be explained. A keyframe refers to a representative image frame selected by the visual SLAM front-end from a continuously acquired image sequence according to preset criteria, used for back-end optimization. A map point refers to an environment point with three-dimensional coordinates in the world coordinate system, obtained by triangulation of mutually matched image features on several keyframes. A keyframe pose refers to the rigid body transformation of the camera coordinate system corresponding to the keyframe relative to the world coordinate system, including rotation and translation components. Reprojection error refers to the deviation between the coordinates of the projected image point obtained by projecting the map point according to the keyframe pose onto the keyframe image plane and the coordinates of the feature image point actually observed by the map point on the keyframe. Global bundle adjustment refers to a joint optimization process using all keyframe poses and all map point coordinates as variables to be optimized, and the reprojection error of each observation as the objective function.

[0023] Traditional global bundle adjustment targets reprojection error by jointly optimizing keyframe pose and map point coordinates. Its objective function is:

[0024] In the formula: ξ is the set of all keyframe poses; X is the set of all map points; V is the observation set, where each observation (i,j) represents a map point. Feature observations exist in keyframe j; The coordinates of the feature image points observed are π(·); π(·) is the camera projection function. ρ is the standard deviation of the observation noise; ρ(·) is the robust kernel function; and ||·|| is the L2 norm.

[0025] The specific form of the projection function π(·) is:

[0026] In the formula: For the pose transformation of the j-th keyframe; Let i be the three-dimensional coordinates of the i-th map point; The coordinates of the map point in the camera coordinate system after pose transformation; , The focal length of the camera; , These are the coordinates of the optical center. A value greater than zero indicates that the map point is located in front of the camera, and the projection is valid; A value less than or equal to zero indicates that the map point is behind the camera. This observation is masked out in subsequent attention calculations, thus avoiding invalid projections from interfering with the optimization results.

[0027] Traditional methods employ alternating Gauss-Newton iterations or Levenberg-Marquardt iterations to solve the linear equations of the pose blocks and map points.

[0028] In the formula: , These are the Hessian approximation matrices for the pose block and the map point block, respectively; , Let be the Jacobian matrices of the reprojection residuals with respect to pose and map points, respectively; r be the reprojection residual vector; λ be the Levenberg-Marquardt damping coefficient; I be the identity matrix; and Δξ and ΔX be the pose and map point updates obtained in this iteration. Traditional global bundle adjustment requires repeatedly constructing and solving the above linear equations until convergence.

[0029] The above process requires repeated residual calculation, Jacobi construction, and normal equation solving. A single global solution often requires dozens of iterations. The Jacobi derivation and sparse elimination implementation are quite complex, and the solution results are highly sensitive to initial values ​​and outliers. This embodiment maps the above iterative mechanism to a hierarchical structure of an attention optimization network, completing an update equivalent to multiple iterations with a single feedforward inference. Each step is explained below.

[0030] In step S101, the SLAM front-end refers to the processing stage in the visual SLAM system responsible for image acquisition, feature extraction, feature matching, pose tracking, and map point triangulation. For example, it can be implemented using the tracking thread of ORB-SLAM3. The initial keyframe pose refers to the keyframe pose estimate output by the SLAM front-end, which has not yet undergone global optimization. The initial map point coordinates refer to the three-dimensional coordinates of the map points obtained by the SLAM front-end triangulation, which have not yet undergone global optimization. The feature observation association refers to the correspondence between each map point and each keyframe that observed that map point, as well as the feature image coordinates of that map point on the corresponding keyframe image. The matching confidence is a numerical value given by the feature matching stage for each feature matching pair, representing the reliability of the match. Its value can be normalized to between 0 and 1, with a larger value indicating a more reliable match. This step provides all the input data for subsequent lexical encoding and attention bias generation.

[0031] In one embodiment, step S101 includes: The SLAM front-end filters out key frame images from the image sequence captured by the camera; Feature extraction is performed on each of the keyframe images to obtain the keyframe image features of each of the keyframe images; Feature matching is performed on the keyframe image features of adjacent keyframes to obtain each feature matching pair and matching confidence. Perform pose tracking and triangulation on each of the feature matching pairs to obtain the initial keyframe pose and initial map point coordinates; Record the coordinates of the feature image points observed by each map point in each keyframe to obtain the feature observation correlation.

[0032] In this embodiment, keyframe images are selected from the image sequence acquired by the camera through the SLAM front-end. The selection criteria can be set as follows: the number of shared features between the current image frame and the previous keyframe is less than a preset proportion, or the disparity or time interval between the two exceeds a preset threshold; if either of these conditions is met, the current image frame is registered as a keyframe image. The camera can be, for example, a binocular camera or a depth camera. The former directly obtains the initial depth of feature points based on the disparity between the left and right views, while the latter directly provides depth observation through the depth channel. Both can provide scale information for subsequent triangulation. Selection according to the above criteria can ensure scene coverage while avoiding image frame redundancy, thereby controlling the number of keyframes participating in subsequent optimization.

[0033] Feature extraction is performed on each keyframe image to obtain keyframe image features. These keyframe image features are sets of vectors describing the local appearance of salient points in the image, where each feature contains the two-dimensional coordinates of the salient point on the image and its corresponding descriptor. Feature extraction can be implemented using, for example, the Oriented Fast and Rotated BRIEF (ORB) method, or a feature extraction method based on convolutional neural networks. The former has lower computational cost and is suitable for real-time operation on edge devices, while the latter has better repeatability in scenarios with drastic lighting changes and can be selected based on the computing power of the deployment platform.

[0034] Feature matching is performed on the keyframe image features of adjacent keyframes to obtain each feature matching pair and its matching confidence score. A feature matching pair refers to a pair of image features belonging to two different keyframes and determined to correspond to the same environmental point. The matching confidence score can be, for example, the complement of the ratio of the nearest neighbor to the second nearest neighbor distance of the matching pair's descriptor distance, i.e., subtracting this ratio from one; the smaller the ratio, the higher the discriminative power of the match among the candidates, and the greater the matching confidence score. For example, if the ratio of the nearest neighbor distance to the second nearest neighbor distance of one matching pair is 0.4, its matching confidence score is 0.6; if the ratio of another matching pair is 0.9, its matching confidence score is 0.1. The latter is often caused by repetitive textures or moving objects, and its impact on the optimization results in subsequent steps will be correspondingly limited.

[0035] Pose tracking and triangulation are performed on each feature matching pair to obtain the initial keyframe pose and initial map point coordinates. Pose tracking refers to the process of solving the current keyframe pose based on the correspondence between known 3D coordinates of map points and matching features on the current keyframe; for example, this can be achieved using the Perspective-n-Point (PnP) method. Triangulation refers to the process of inversely calculating the 3D coordinates of an environment point based on its matching features and corresponding keyframe poses on two or more keyframes. The keyframe pose and map point coordinates obtained after the above processing are only derived from local constraints and still have accumulated deviations; therefore, they are used as initial values ​​for subsequent global optimization.

[0036] The feature image coordinates of each map point observed in each keyframe are recorded to obtain the feature observation association relationship. This association relationship can be stored, for example, in the form of observation records. Each record includes a map point identifier, a keyframe identifier, the feature image coordinates of the map point on that keyframe image, and the matching confidence score corresponding to that observation. For instance, after SLAM front-end processing, an indoor sequence is filtered to obtain 120 keyframes, which are then triangulated to obtain 12,000 map points. Each map point is observed on average in 4 to 6 keyframes, resulting in approximately 60,000 observation records. These records serve as the basis for subsequently determining the pairing relationship between keyframes and map points, and also as the source of actual observation data when calculating reprojection error.

[0037] It should be noted that all the above input quantities are taken from the existing output results of the SLAM front end. No additional intermediate quantities are required from the SLAM front end. Therefore, when integrating with an existing visual SLAM system, it is not necessary to change the processing flow of its front end, but only to replace the solution module of the back end.

[0038] In step S102, a term refers to a basic computational unit that can be processed by the attention optimization network after organizing the attributes of an object to be optimized into a fixed-length vector; a pose term refers to a term generated from the pose of a keyframe, corresponding one-to-one with the keyframe; a map point term refers to a term generated from the coordinates of a map point, corresponding one-to-one with the map point; encoding refers to the process of organizing the above geometric quantities into description vectors according to predetermined rules and mapping them into fixed-dimensional terms. This step converts pose quantities and coordinate quantities with different dimensions into vector representations with unified dimensions, enabling the two heterogeneous variables to be optimized, keyframes and map points, to participate in the calculation together in the same attention space. In this embodiment, the dimension d of both pose terms and map point terms is 256.

[0039] In one embodiment, step S102 includes: The pose of each initial keyframe is decomposed into a translation vector and a unit quaternion, and the velocity-related features of the corresponding keyframe are obtained. The translation vector, the unit quaternion, and the velocity-related features are concatenated to obtain the pose description vector for each key frame. Based on the aforementioned feature observation correlation, statistical features of the observation direction of each map point and average matching confidence are calculated. The initial map point coordinates, the observation direction statistical features, and the average matching confidence are concatenated to obtain the map point description vector; Linear projections are performed on the pose description vector and the map point description vector to obtain pose lexical units and map point lexical units.

[0040] In this embodiment, the pose of each initial keyframe is decomposed into a translation vector and a unit quaternion, and the velocity-related features of the corresponding keyframe are obtained. The translation vector refers to the three-dimensional vector representing the position of the camera's optical center in the world coordinate system in the keyframe pose; the unit quaternion refers to the rotation parameterization form that represents three-dimensional rotation with four components, and the sum of the squares of each component is one; the velocity-related features refer to the quantities representing the motion state of the keyframe, such as the estimated values ​​of linear velocity and angular velocity, obtained from the translation between adjacent keyframes and the acquisition time interval. Representing the rotation components with unit quaternions avoids the difficulties brought about by the orthogonal constraints between the nine elements of the rotation matrix to numerical regression, and does not have the gimbal lock problem of Euler angle representation; introducing velocity-related features makes the encoding result carry the motion trend of the keyframe, providing additional clues for subsequent pose correction in segments with rapid camera movement.

[0041] The translation vector, unit quaternion, and velocity-related features are concatenated to obtain the pose description vector for each keyframe. This concatenation refers to joining the components end-to-end in a fixed order to form a long vector, thus grouping the position, attitude, and motion state of the same keyframe into a single vector. For example, when the translation vector is 3-dimensional, the unit quaternion is 4-dimensional, and the velocity-related features are linear velocity and angular velocity (6 dimensions in total), the resulting pose description vector is 13-dimensional.

[0042] Based on the correlation of feature observations, statistical characteristics of the observation directions and average matching confidence of each map point are calculated. The statistical characteristics of the observation directions refer to the statistics derived from the unit direction vectors pointing from the map point to the optical centers of each keyframe that observed it, such as the distribution range of the mean vector of each unit direction vector and the angle between them. This statistic reflects the observed geometric configuration of the map point; the more dispersed the distribution of observation directions, the more angles the map point is observed from, and the more sufficient the constraint on its depth direction. The average matching confidence refers to the mean of the matching confidence of the map point across all observations, used to characterize the overall reliability of the map point. For example, if a map point is observed in 5 keyframes, and the matching confidence of each observation is 0.9, 0.85, 0.8, 0.75, and 0.7, then its average matching confidence is 0.8.

[0043] The initial map point coordinates, observation direction statistical features, and average matching confidence are concatenated to obtain the map point description vector. This concatenation results in a map point description vector that includes not only the current spatial location of the map point but also its observed geometric configuration and reliability, enabling subsequent attention calculations to distinguish between well-constrained and poorly constrained map points.

[0044] Linear projection is performed on the pose description vector and the map point description vector respectively to obtain pose terms and map point terms. The linear projection refers to performing an affine transformation on the description vectors using a learnable weight matrix and bias vector, mapping the two types of description vectors with different lengths to the same dimension. The pose branch and the map point branch are each equipped with independent weight matrices and bias vectors, allowing the two types of objects to retain their respective representations while sharing the same dimension. The above encoding process can be represented as:

[0045] In the formula: Let be the pose description vector of the j-th keyframe, derived from translation. Unit quaternion Speed-related characteristics Composed of splicing elements; Let i be the description vector of the i-th map point, consisting of three-dimensional coordinates. Statistical characteristics of observation direction Compared with average matching confidence Composed of splicing elements; , and , These are the learnable projection weights and biases for the pose branch and the map point branch, respectively. , These are the pose words of the j-th keyframe and the map point words of the i-th map point, respectively.

[0046] It should be noted that the above encoding incorporates matching confidence and observation configuration information when generating tokens, thus eliminating the need for subsequent steps to backtrack to the original observations to determine the reliability of each object to be optimized. As an alternative, velocity-related features can be zeroed out and used in stitching in cases of purely static shooting or unreliable inter-frame timestamps. In this case, the pose description vector degenerates into a combination of position and orientation, while the rest of the processing remains unchanged.

[0047] In step S103, an observation pair refers to a pair of objects involved in attention calculation, consisting of a map point and a keyframe that observes that map point, corresponding to an observation record in the feature observation association relationship; the projected image point coordinates refer to the two-dimensional coordinates obtained by projecting the map point in the observation pair onto the keyframe image plane according to the initial keyframe pose; the attention bias refers to the correction amount superimposed on the attention score before normalization, obtained based on geometric quantities and matching confidence. This step converts the reprojection error and matching confidence, two geometric and statistical priors, into values ​​that can be directly applied to the attention weights, so that the influence of mismatched observations can be limited without manually setting a truncation threshold.

[0048] In one embodiment, step S103 includes: Based on the feature observation association, determine each observation pair between the pose lexicon and the map point lexicon; Project the map points in each observation pair onto the corresponding keyframe according to the initial keyframe pose to obtain the coordinates of the projected image points. The deviation between the coordinates of the projected image points and the coordinates of the actual observed feature image points is calculated to obtain the reprojection error of each observation pair. The reprojection errors are input into a decreasing activation function parameterized by a temperature coefficient to obtain the decreasing activation value for each observation pair. The attention bias is obtained by multiplying each of the decreasing activation values ​​by the corresponding matching confidence and bias strength coefficients.

[0049] In this embodiment, observation pairs between pose lexical units and map point lexical units are determined based on feature observation associations. Specifically, each observation record is read sequentially, and the map point identifier and keyframe identifier are extracted. The map point lexical unit corresponding to the map point is paired with the pose lexical unit corresponding to the keyframe to form an observation pair. Map points not appearing in the observation records do not form observation pairs with keyframes and are masked in subsequent attention calculations. Therefore, the number of pairs involved in the calculation is equivalent to the number of observation records, rather than the product of the number of keyframes and the number of map points. Continuing the previous example, if 120 keyframes and 12,000 map points are paired, there will be 1.44 million pairs, while the observation pairs determined by the observation records are only about 60,000 pairs, thus reducing the computational load accordingly.

[0050] The map points in each observation pair are projected onto the corresponding keyframe according to the initial keyframe pose to obtain the coordinates of the projected image points. The projection is performed according to the projection function described above, that is, the world coordinates of the map points are first transformed to the camera coordinate system of the keyframe by the pose transformation of the keyframe, and then the coordinates in the camera coordinate system are mapped to the image plane according to the camera focal length and optical center coordinates. If the depth component obtained after transformation is less than or equal to zero, it indicates that the map point is behind the camera, and the observation pair is masked out and does not participate in subsequent calculations.

[0051] The deviation between the projected image point coordinates and the actual observed feature image point coordinates is calculated to obtain the reprojection error of each observation pair. The actual observed feature image point coordinates are taken from the feature observation correlation recorded in step S101. This deviation is usually taken as the L2 norm of the difference between the two. The larger the value, the less consistent the current keyframe pose and map point coordinates are with the observation. For example, if the projected image point coordinates of an observation pair are (320.4, 241.8) and the actual observed feature image point coordinates are (319.9, 241.5), then the reprojection error of this observation pair is about 0.58 pixels, which is considered a good match. If the reprojection error of another observation pair reaches 12 pixels, then this observation is mostly caused by mismatch or moving objects.

[0052] Each reprojection error is input into a decreasing activation function parameterized by a temperature coefficient to obtain the decreasing activation value for each observation pair. The decreasing activation function is a function whose output monotonically decreases as the input increases. In this embodiment, an S-shaped decreasing function parameterized by a temperature coefficient τ is used. For observation pairs with reprojection errors exceeding τ, their decreasing activation value drops below a preset level. The temperature coefficient τ determines the position and steepness of the function's transition from the high-value region to the low-value region: when τ is relatively small, the function transitions steeply, and the identification of reprojection errors is more stringent; when τ is relatively large, the function transitions smoothly, allowing more observations to participate in the optimization.

[0053] The attention bias is obtained by multiplying each decreasing activation value by its corresponding matching confidence and bias strength coefficient. The bias strength coefficient adjusts the magnitude of the attention bias relative to the inter-lexical relevance term; a larger value indicates a stronger dominance of the geometric prior on the attention weights. The construction process of the attention bias described above can be expressed as follows:

[0054] In the formula: This is the attention bias matrix, whose elements are composed of reprojection errors. The decreasing activation function σ(·) and the matching confidence The weighted composition is as follows: τ is the temperature coefficient; β is the bias intensity coefficient. As can be seen from this formula, the larger the reprojection error and the lower the matching confidence of the observation pair, the smaller the resulting attention bias, and the greater the decrease in its weight in the attention calculation in step S104.

[0055] The impact of mismatched observations is limited at the attention weight level, eliminating the need for a pre-set hard truncation threshold. Traditional global bundle adjustment relies on robust kernel functions such as the Huber kernel and Tukey kernel to suppress mismatched observations, and their truncation thresholds need to be manually tuned for the specific scene. This embodiment moves this function forward to the construction stage of the attention bias: observations with large reprojection errors receive lower biases and are automatically suppressed during weight normalization in step S104, thus providing a second layer of discrimination based on the matching confidence. The temperature coefficient τ and the bias intensity coefficient β are used as hyperparameters in the training of the attention optimization network and are jointly learned. In this embodiment, the initial value of τ is 2.0, and the initial value of β is 1.0. Therefore, their values ​​are determined by the data rather than manually specified, achieving a better suppression effect than a fixed kernel function in scenarios with many dynamic outliers.

[0056] As an alternative, when the known scenario is static and the feature matching quality is stable, the bias intensity coefficient β can be set to a smaller value, so that the attention weight is mainly determined by the correlation between words. In this case, the geometric prior becomes secondary, at the cost of a corresponding weakening of the ability to suppress occasional mismatches.

[0057] In step S104, the attention optimization network refers to a feedforward network composed of several cascaded attention optimization layers. Its inputs are pose words, map point words, and attention biases, and its outputs are optimized pose words and map point words. An attention optimization layer refers to a single processing layer in this network, where each layer performs an alternating update of pose words and map point words. Alternating update layer by layer refers to the processing method in which pose words and map point words are updated sequentially within the same layer, and the update results are passed to the next layer. This step is the core of this embodiment that replaces iterative solution: the residual statistics, linearization solution, and feedback correction repeatedly performed in the traditional scheme are correspondingly mapped to attention calculations within the attention optimization layer. Stacking N layers is equivalent to performing the aforementioned iterative update N times, without the need to construct a Hessian approximation matrix or solve equations. In this embodiment, the number of attention optimization layers N is 6, and the number of attention heads is 8. As an optional value range, the number of layers N can be an integer from 4 to 8, and the number of attention heads can be an integer from 4 to 16. The more layers there are, the more equivalent iterations there are, and the time consumed in a single inference will also increase accordingly. The selection can be made according to the scale of the scene and the computing power conditions.

[0058] In one embodiment, step S104 includes: In each preset attention optimization layer, the attention score is calculated using the pose term as the query and the map point term as the key. The attention score is added to the attention bias and then normalized to obtain the self-attention weight; Construct corresponding reprojection error features based on the reprojection error; The reprojection error features are aggregated using the self-attention weights to obtain the optimized pose lexical units. Perform cross-attention calculation on the optimized pose lexical and the map point lexical to obtain the optimized map point lexical; The results are passed to the next attention optimization layer via residual connections, and the final layer outputs the optimized pose lexicon and the optimized map point lexicon.

[0059] In this embodiment, in each preset attention optimization layer, an attention score is calculated using pose terms as queries and map point terms as keys. The query refers to a vector obtained by linearly transforming pose terms, used to retrieve information from other objects; the key refers to a vector obtained by linearly transforming map point terms, used for retrieval by the query; the attention score is the value obtained by scaling the inner product of the query and the key, used to measure the correlation between the keyframe and the map point. Using pose terms as queries and map point terms as keys means collecting information from the map points observed by the keyframe, which corresponds to the role of traditional solutions in accumulating error statistics from residual terms to pose blocks.

[0060] The attention score is added to the attention bias and then normalized to obtain the self-attention weight. The normalization is achieved using a normalization exponential function (Softmax), which converts the values ​​of each observation pair corresponding to the same keyframe into a set of weights that sum to one. Since the attention bias obtained in step S103 results in smaller values ​​for observation pairs with large reprojection errors and low matching confidence, these observation pairs are at a disadvantage in the normalization competition after addition, and their self-attention weights are suppressed. Consequently, the impact of mismatched observations on the pose update of the keyframe is limited.

[0061] Based on the reprojection errors obtained in step S103, corresponding reprojection error features are constructed, and these features are weighted and aggregated using self-attention weights to obtain optimized pose lexical units. The reprojection error features refer to vectors composed of the reprojection errors and their components of the corresponding observation pair, which are used as values ​​in the attention calculation for weighted summation. The weighted aggregation result reflects the error distribution of all valid observations on the keyframe, and the pose lexical units of the keyframe are corrected accordingly. This process can be expressed as:

[0062] In the formula: This is the query matrix obtained by linear transformation of pose words; , These are the key matrix obtained from map point terms and the value matrix composed of reprojection error features, respectively. The attention bias matrix obtained in step S103; is the attention head dimension; Softmax(·) is the normalization exponential function; the superscript ' indicates the output of this attention stage. This stage realizes the propagation of map point reprojection error information to the aggregation of pose words, which is consistent with the aforementioned... The error statistics function of r corresponds to that of r.

[0063] Cross-attention calculation is performed on the optimized pose lexical and map point lexical to obtain the optimized map point lexical. The cross-attention calculation refers to the attention calculation performed using map point lexical as the query and the updated pose lexical of the current layer as the key and value. Its direction is opposite to the previous stage, and it is used to feed back the keyframe pose correction results to each map point that observed the keyframe. This process can be represented as:

[0064] In the formula: This is the query matrix obtained from map point terms; ′ represents the key matrix obtained from the updated pose lexical units of this layer; This is the updated pose value matrix; This is the common-view prior bias matrix. The common-view prior bias matrix is ​​used to limit the scope of objects participating in the computation: only when a map point has a feature observation in a keyframe does the observation pair formed by that keyframe and the map point participate in the attention calculation; other combinations are masked before normalization. Therefore, the computational cost of a single layer is linearly related to the number of observations, and does not increase with the product of the number of keyframes and the number of map points. This stage realizes the feedback propagation of pose correction to map points, corresponding to the feedback mechanism in traditional solutions where the map point coordinates are corrected after pose update.

[0065] The information is passed to the next attention optimization layer via residual connections, and the final layer outputs optimized pose terms and optimized map point terms. The residual connection refers to adding the attention output of the current layer to the input of the current layer before performing layer normalization, ensuring that each layer learns an increment relative to the input rather than entirely new representations. Inter-layer transfer can be represented as:

[0066] In the formula: LN(·) is layer normalization, used to adjust the distribution of outputs from each layer to a similar scale; FFN(·) is a feedforward network, used to perform word-by-word nonlinear transformation on the aggregation result; the subscripts l and l+1 represent the l-th layer and the l+1-th layer, respectively. Figure 3 As shown, each attention optimization layer first executes a self-attention stage with pose terms as queries, followed by a cross-attention stage with map point terms as queries. The two stages and adjacent layers are connected by residual connections, thus maintaining stable gradient propagation even with a large number of stacked layers. In this embodiment, N is set to 6, and each layer sequentially completes six rounds of alternating pose and map point corrections. The cumulative effect is equivalent to executing the aforementioned iterations six times.

[0067] It is worth noting that the above structure of the attention optimization network corresponds layer by layer to the iterative steps of the traditional solution, rather than directly regressing the pose with a single round of global attention. Therefore, its intermediate results have a clear geometric meaning: the output of the self-attention stage corresponds to a correction of the pose, the output of the cross-attention stage corresponds to a correction of the map points, and the number of layers corresponds to the number of iterations.

[0068] The attention optimization network is trained end-to-end using a joint loss function before deployment. This joint loss is a weighted sum of sparse reprojection loss, dense luminosity loss, and a regularization term. The sparse reprojection loss, weighted by confidence, measures the reprojection bias after optimization, and its expression is:

[0069] In the formula: The sample weights generated by the aforementioned confidence mechanism reduce the contribution of low-quality observations to the training loss; the meanings of the other symbols remain the same. This loss corresponds to the reprojection residuals in traditional sparse feature global bundle adjustment.

[0070] Dense photometric loss measures the deviation between the grayscale value of a reference frame pixel at the current pose and the predicted grayscale value of the target frame after mapping. Its expression is:

[0071] In the formula: (x) is the gray value of keyframe j at pixel x; (x) represents the predicted grayscale value at pixel x after weighted mapping (warp) of the photometric information of the reference frame according to the current pose and the map; K is the set of keyframes participating in the photometric constraints. The mapping term maps the reference frame pixels to the target frame according to the currently estimated pose, and is implemented using differentiable bilinear sampling, so that this term can participate in gradient backpropagation. This loss corresponds to the direct photometric global bundle adjustment, so that the scene with sparse feature degradation still retains the source of constraints.

[0072] The regularization term is used to impose prior constraints on the optimization results, and its expression is:

[0073] In the formula: For the translation component of the j-th keyframe, its second-order difference term is used to suppress abrupt changes in the motion trajectory; Let i be the local normal vector of map point i. It is the mean of its neighborhood, which is used to smooth the normal of the map point surface; , This is the regularization weight. This term explicitly incorporates the implicit prior assumptions in the traditional solution into the training objective, making the results more physically plausible.

[0074] The total loss is obtained by weighted summation of the above three items, and its expression is:

[0075] In the formula: , , The weighting coefficients for the sparse reprojection loss, dense photometric loss, and regularization term are determined by performing a grid search on the validation set. These losses unify the sparse feature reprojection constraint and the direct photometric constraint within the same system. In scenarios of feature degradation, the constraint of the sparse term weakens while the constraint of the photometric term strengthens accordingly. The source of the constraint automatically switches according to the scenario, thus the same network can be compatible with both sparse feature and photometric optimization paradigms.

[0076] For example, the training configuration in this embodiment is as follows: the weighting coefficients of sparse reprojection loss, dense luminosity loss, and regularization term are 1.0, 0.5, and 0.1, respectively; the trajectory smoothing weight and normal smoothing weight within the regularization term are 0.1 and 0.01, respectively; and the temperature coefficient and bias intensity coefficient participate in training with the aforementioned initial values. The training set uses the TUM RGB-D dataset, the EuRoC MAV dataset, and self-collected indoor and outdoor sequences. The labels are generated offline using the Ceres solver with high-precision global bundle adjustment on the same batch of data. The optimizer is Adam, with a learning rate of 1e-4, and a total of 300 epochs of training. The hardware platform used for training is an NVIDIA RTX 3060 graphics card, and the hardware platform used for edge deployment is a Jetson Orin NX. After training, the model can output optimization results with accuracy comparable to traditional iterative solutions with a single feedforward inference.

[0077] In step S105, decoding refers to the process of restoring the tokens from the network's representation space into pose and coordinate quantities with geometric meaning; pose correction increment refers to the amount obtained from decoding used to correct the initial keyframe pose; coordinate correction increment refers to the amount obtained from decoding used to correct the initial map point coordinates. This step adopts incremental decoding, that is, the decoder outputs a correction amount relative to the initial input value rather than the absolute value of the pose and coordinates, and then the correction amount is superimposed with the initial value to obtain the final result. Compared with directly regressing the absolute value, incremental decoding allows the network to fit only a small correction amount, and its output value range is more concentrated. Moreover, when the initial value provided by the SLAM front end is good, the correction amount approaches zero, and the optimization result naturally degenerates to the initial value, without destroying the originally correct estimate due to fluctuations in the network output.

[0078] In one embodiment, step S105 includes: The optimized pose lexicon is input into the decoder to obtain the pose correction increment for each keyframe. The optimized map point terms are input into the decoder to obtain the coordinate correction increment of each map point; The pose correction increments are mapped and transformed to obtain the pose correction transformation amount of each key frame. The pose correction transformations are multiplied by the right and superimposed on the initial keyframe pose to obtain the optimized keyframe pose. The coordinate correction increments are superimposed on the corresponding initial map point coordinates to obtain the optimized map point coordinates.

[0079] In this embodiment, the optimized pose lexical units are input into the decoder to obtain the pose correction increment for each keyframe. The decoder refers to the mapping component corresponding to the encoding stage, which restores the uniformly dimensional lexical units to the low-dimensional quantities required for the object to be optimized; for example, it can be implemented by several layers of fully connected networks. The pose correction increment is a six-dimensional vector, where three dimensions correspond to the correction in the translation direction and three dimensions correspond to the correction in the rotation direction.

[0080] The optimized map point terms are input into the decoder to obtain the coordinate correction increments for each map point. The coordinate correction increments are three-dimensional vectors, corresponding to the corrections of the map point along the three coordinate axes in the world coordinate system. The pose branch and the map point branch share the same decoder structure but are each equipped with an independent output head, allowing both types of corrections to be solved in the same representation space, which helps maintain the consistency of their scales.

[0081] The pose correction increments are mapped and transformed to obtain the pose correction transformation amounts for each keyframe. This mapping transformation refers to converting the six-dimensional pose correction increments into rigid body transformations. In this embodiment, exponential mapping using Lie algebras is employed: the pose correction increments are treated as elements of a Lie algebra, and after exponential mapping, they become a rigid body transformation on the Lie group, i.e., the pose correction transformation amount. Using exponential mapping allows the decoder to freely regress in unconstrained six-dimensional space, while the transformation result always satisfies the constraints of orthogonality of the rotation components and a single determinant, eliminating the need for additional regularization.

[0082] The pose correction transformations are right-multiplied and superimposed onto the initial keyframe pose to obtain the optimized keyframe pose. This right-multiplication superposition refers to multiplying the pose correction transformations by the initial keyframe pose on the right, i.e., applying the correction in the camera coordinate system of the keyframe itself. Compared to the correction in the world coordinate system corresponding to left-multiplication superposition, right-multiplication superposition aligns with the definition of reprojection error, and the geometric meaning of the correction is more direct.

[0083] The coordinate correction increments are superimposed onto the corresponding initial map point coordinates to obtain the optimized map point coordinates. Since the map point coordinates are in Euclidean space and there are no rotational constraints, they can be directly summed as vectors. For example, if the initial coordinates of a map point are (1.204, 0.351, 2.870), and its coordinate correction increments are (-0.006, 0.002, 0.011), then the optimized map point coordinates are (1.198, 0.353, 2.881).

[0084] The optimized keyframe poses and optimized map point coordinates obtained from decoding are written back to the visual SLAM system in the data format agreed upon with the SLAM front end for subsequent processing. This data format is consistent with the output of the existing global bundle adjustment solution module.

[0085] In step S106, historical key values ​​refer to the key and value matrices generated and saved by the attention optimization network during previous inference processes, based on the pose words of existing keyframes and the map point words of existing map points. Caching refers to storing the aforementioned key and value matrices in GPU memory or system memory for direct retrieval during subsequent inference. Incremental update refers to an update method that only calculates the newly added parts and incorporates the results into existing results. This step ensures that adding new keyframes does not trigger a complete re-inference of all words: since the key values ​​of existing keyframes and existing map points remain unchanged when their own states do not change, recalculating these key values ​​is unnecessary; the cache can be directly accessed. Therefore, the cost of maintaining the global result is related to the number of new nodes, but not to the existing scale of the scene.

[0086] In one embodiment, step S106 includes: The newly added keyframes and their associated newly added map points are encoded to obtain the corresponding newly added tokens; For each newly added lexical unit, the cached historical key value is read from the attention optimization network, and a single incremental attention calculation is performed on each newly added lexical unit and the historical key value to obtain the newly added optimization result; The newly added optimization results are decoded and the historical key values ​​are written back. The optimized keyframe poses and map point coordinates are updated. At the same time, for every newly added preset number of keyframes, all lexical units are re-inputted into the attention optimization network to perform a full update.

[0087] In this embodiment, newly added keyframes and their associated newly added map points are encoded to obtain corresponding new lexical units. The newly added keyframes refer to keyframes newly selected by the SLAM front-end during the operation of the visual SLAM system; the newly added map points refer to map points obtained by triangulation of the matching features between the newly added keyframes and existing keyframes. The encoding method is the same as in step S102, that is, the pose description vector and the map point description vector are organized separately and linearly projected, so that the newly added lexical units and the historical lexical units in the cache are in the same representation space.

[0088] For each newly added lexical unit, the cached historical key-value pairs are read from the attention optimization network, and a single incremental attention calculation is performed on each newly added lexical unit and its historical key-value pairs to obtain the optimization result. The single incremental attention calculation refers to a single attention calculation performed using only the newly added lexical unit as the query and combining the historical key-value pairs with the key-value pairs of the newly added lexical unit itself as the key and value, without repeating the feedforward reasoning for all lexical units layer by layer. This process can be represented as:

[0089] In the formula: For queries corresponding to the terms of newly added keyframes and newly added map points; The key-value cache for existing keyframes and map points can be directly reused in incremental updates without recalculation; The key and value of the newly added term are defined in the formula. The key and value are composed of the historical cache and the newly added part, respectively. That is, the key for calculation is the combination of the historical key and the newly added key, and the value for calculation is the combination of the historical value and the newly added value. As can be seen from the formula, the addition of a new keyframe only triggers an incremental attention calculation once, and its computational cost is linearly related to the number of new nodes, thus avoiding a full re-optimization.

[0090] The newly optimized results are decoded and written back to the historical key values, updating the optimized keyframe poses and map point coordinates. The decoding method is the same as in step S105, that is, the decoder outputs the correction increment and adds it to the corresponding initial value; the write-back involves appending the keys and values ​​generated by the newly added lexical units to the cache, making them part of the historical key values ​​in the next incremental update. For example, if at a certain moment the key values ​​corresponding to 120 keyframes and 12,000 map points are already cached, and then one new keyframe and approximately 80 new map points are added, the incremental update only needs to calculate the attention between these 81 new lexical units and the cache, without having to re-infer the 12,120 cached lexical units along with the new lexical units.

[0091] Simultaneously, for every newly added preset number of keyframes, all lexical units are re-inputted into the attention optimization network for a full update. This preset number is denoted as M, meaning a full update is triggered every M newly added keyframes. While incremental updates are less costly, their results rely on existing caches. If only incremental updates are performed over a long period, a mismatch will gradually develop between the historical key values ​​in the cache and the corrected poses and coordinates. Therefore, a full update is performed periodically to realign the representations of all lexical units. The value of the preset number M needs to strike a balance between computational overhead and global consistency: a smaller M value results in more frequent full updates, better consistency maintenance, but an increase in average processing time; a larger M value results in a decrease in average processing time but an increased risk of cumulative mismatch. For example, in an indoor scene, M can be set to 20, meaning a full update is performed every 20 newly added keyframes.

[0092] Through steps S101 to S106, the visual SLAM system can update the global results in a timely manner with a small cost when adding new keyframes, and can also obtain a complete global alignment once a periodically, so that global consistency can be maintained continuously as keyframes increase.

[0093] In summary, the SLAM global bundle adjustment substitution method provided in this embodiment encodes keyframe poses and map point coordinates into pose terms and map point terms, converts reprojection errors and matching confidence into attention biases, and then uses an attention optimization network to alternately update and decode these layers into optimized poses and coordinates. Simultaneously, it utilizes cached historical key values ​​to perform incremental updates for new keyframes. First, it replaces repeated iterative solutions with a single feedforward inference from the attention optimization network, eliminating the need to construct a Hessian approximation matrix and solve the equations. While maintaining comparable accuracy to traditional solutions, the time consumed in a single global optimization is correspondingly reduced. In a scene containing 12,000 map points, the time consumed in a single global optimization is reduced from 965 milliseconds for global bundle adjustment using the Ceres solver to 128 milliseconds, a reduction of approximately 86.7%. The average inference speedup in multiple tests is 5 to 8 times, and the time consumption increases approximately linearly with the scene size. Second, attention bias limits the impact of mismatched observations at the weight level, eliminating the need for manually setting the cutoff threshold of the robust kernel function. In dynamic scenes with moving objects, the absolute trajectory error (ATE) decreases from 0.076 meters to 0.052 meters, a reduction of approximately 32%. Third, sparse reprojection constraints and photometric constraints are unified under the same training objective. In degenerate scenes where feature occlusion leads to insufficient sparse constraints, photometric constraints automatically supplement the constraint source, avoiding trajectory drift in such scenarios. Fourth, incremental updates combined with periodic full updates enable even computationally limited edge devices to maintain global consistency. Fifth, the input and output quantities of the proposed method are consistent with existing global bundle adjustment solution modules, allowing for plug-and-play replacement of mainstream visual SLAM system solution modules without modifying their front-end processes.

[0094] Combination Figure 2 As shown, Figure 2 This is a schematic block diagram of a SLAM global bundle adjustment substitution device provided in an embodiment of the present invention. The SLAM global bundle adjustment substitution device 200 includes: The data acquisition module 201 is used to acquire the initial keyframe pose and initial map point coordinates output by the SLAM front end, as well as the feature observation correlation and matching confidence between each keyframe and each map point. The lexical encoding module 202 is used to encode the initial keyframe pose and the initial map point coordinates respectively to obtain the pose lexicals corresponding to each keyframe and the map point lexicals corresponding to each map point. The bias generation module 203 is used to calculate the reprojection error between the pose lexicon and the map point lexicon based on the feature observation association, and generate an attention bias in combination with the matching confidence. The iterative optimization module 204 is used to input the pose lexical, the map point lexical and the attention bias into the attention optimization network, and update the optimized pose lexical and map point lexical layer by layer. The output decoding module 205 is used to decode the optimized pose words and the optimized map point words respectively to obtain the optimized keyframe pose and the optimized map point coordinates; The incremental update module 206 is used to reuse the historical key values ​​of the attention optimization network cache when a new keyframe is added, and incrementally update the optimized keyframe pose and map point coordinates.

[0095] In this embodiment, the data acquisition module 201 acquires the initial keyframe pose and initial map point coordinates output by the SLAM front-end, as well as the feature observation association and matching confidence between each keyframe and each map point; the lexical encoding module 202 encodes the initial keyframe pose and the initial map point coordinates respectively to obtain the pose lexicals corresponding to each keyframe and the map point lexicals corresponding to each map point; the bias generation module 203 calculates the reprojection error corresponding to the pose lexicals and the map point lexicals based on the feature observation association, and combines it with the matching confidence. An attention bias is generated; the iterative optimization module 204 inputs the pose lexicon, the map point lexicon, and the attention bias into the attention optimization network, and updates them layer by layer to obtain the optimized pose lexicon and map point lexicon; the output decoding module 205 decodes the optimized pose lexicon and the optimized map point lexicon respectively to obtain the optimized keyframe pose and the optimized map point coordinates; the incremental update module 206 reuses the historical key values ​​cached by the attention optimization network when a new keyframe is added, and incrementally updates the optimized keyframe pose and map point coordinates.

[0096] In one embodiment, the data acquisition module 201 is specifically used for: The SLAM front-end filters out key frame images from the image sequence captured by the camera; Feature extraction is performed on each of the keyframe images to obtain the keyframe image features of each of the keyframe images; Feature matching is performed on the keyframe image features of adjacent keyframes to obtain each feature matching pair and matching confidence. Perform pose tracking and triangulation on each of the feature matching pairs to obtain the initial keyframe pose and initial map point coordinates; Record the coordinates of the feature image points observed by each map point in each keyframe to obtain the feature observation correlation.

[0097] In one embodiment, the lexical encoding module 202 is specifically used for: The pose of each initial keyframe is decomposed into a translation vector and a unit quaternion, and the velocity-related features of the corresponding keyframe are obtained. The translation vector, the unit quaternion, and the velocity-related features are concatenated to obtain the pose description vector for each key frame. Based on the aforementioned feature observation correlation, statistical features of the observation direction of each map point and average matching confidence are calculated. The initial map point coordinates, the observation direction statistical features, and the average matching confidence are concatenated to obtain the map point description vector; Linear projections are performed on the pose description vector and the map point description vector to obtain pose lexical units and map point lexical units.

[0098] In one embodiment, the bias generation module 203 is specifically used for: Based on the feature observation association, determine each observation pair between the pose lexicon and the map point lexicon; Project the map points in each observation pair onto the corresponding keyframe according to the initial keyframe pose to obtain the coordinates of the projected image points. The deviation between the coordinates of the projected image points and the coordinates of the actual observed feature image points is calculated to obtain the reprojection error of each observation pair. The reprojection errors are input into a decreasing activation function parameterized by a temperature coefficient to obtain the decreasing activation value for each observation pair. The attention bias is obtained by multiplying each of the decreasing activation values ​​by the corresponding matching confidence and bias strength coefficients.

[0099] In one embodiment, the iterative optimization module 204 is specifically used for: In each preset attention optimization layer, the attention score is calculated using the pose term as the query and the map point term as the key. The attention score is added to the attention bias and then normalized to obtain the self-attention weight; Construct corresponding reprojection error features based on the reprojection error; The reprojection error features are aggregated using the self-attention weights to obtain the optimized pose lexical units. Perform cross-attention calculation on the optimized pose lexical and the map point lexical to obtain the optimized map point lexical; The results are passed to the next attention optimization layer via residual connections, and the final layer outputs the optimized pose lexicon and the optimized map point lexicon.

[0100] In one embodiment, the output decoding module 205 is specifically used for: The optimized pose lexicon is input into the decoder to obtain the pose correction increment for each keyframe. The optimized map point terms are input into the decoder to obtain the coordinate correction increment of each map point; The pose correction increments are mapped and transformed to obtain the pose correction transformation amount of each key frame. The pose correction transformations are multiplied by the right and superimposed on the initial keyframe pose to obtain the optimized keyframe pose. The coordinate correction increments are superimposed on the corresponding initial map point coordinates to obtain the optimized map point coordinates.

[0101] In one embodiment, the incremental update module 206 is specifically used for: The newly added keyframes and their associated newly added map points are encoded to obtain the corresponding newly added tokens; For each newly added lexical unit, the cached historical key value is read from the attention optimization network, and a single incremental attention calculation is performed on each newly added lexical unit and the historical key value to obtain the newly added optimization result; The newly added optimization results are decoded and the historical key values ​​are written back. The optimized keyframe poses and map point coordinates are updated. At the same time, for every newly added preset number of keyframes, all lexical units are re-inputted into the attention optimization network to perform a full update.

[0102] 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.

[0103] 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.

[0104] 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.

[0105] 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.

[0106] 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 substitution method for SLAM global bundle adjustment, characterized in that, include: Obtain the initial keyframe pose and initial map point coordinates output by the SLAM front-end, as well as the feature observation correlation and matching confidence between each keyframe and each map point; The initial keyframe pose and the initial map point coordinates are encoded respectively to obtain the pose words corresponding to each keyframe and the map point words corresponding to each map point. Based on the feature observation association, the reprojection error between the pose lexicon and the map point lexicon is calculated, and the attention bias is generated by combining the matching confidence. The pose lexicon, the map point lexicon, and the attention bias input attention optimization network are alternately updated layer by layer to obtain the optimized pose lexicon and map point lexicon. The optimized pose words and the optimized map point words are decoded respectively to obtain the optimized keyframe pose and the optimized map point coordinates; When a new keyframe is added, the historical key values ​​cached by the attention optimization network are reused, and the optimized keyframe pose and map point coordinates are incrementally updated.

2. The SLAM global bundle adjustment substitution method according to claim 1, characterized in that, The acquisition of the initial keyframe pose and initial map point coordinates output by the SLAM front-end, as well as the feature observation association and matching confidence between each keyframe and each map point, includes: The SLAM front-end filters out key frame images from the image sequence captured by the camera; Feature extraction is performed on each of the keyframe images to obtain the keyframe image features of each of the keyframe images; Feature matching is performed on the keyframe image features of adjacent keyframes to obtain each feature matching pair and matching confidence. Perform pose tracking and triangulation on each of the feature matching pairs to obtain the initial keyframe pose and initial map point coordinates; Record the coordinates of the feature image points observed by each map point in each keyframe to obtain the feature observation correlation.

3. The SLAM global bundle adjustment substitution method according to claim 1, characterized in that, The step of encoding the initial keyframe pose and the initial map point coordinates respectively to obtain the pose words corresponding to each keyframe and the map point words corresponding to each map point includes: The pose of each initial keyframe is decomposed into a translation vector and a unit quaternion, and the velocity-related features of the corresponding keyframe are obtained. The translation vector, the unit quaternion, and the velocity-related features are concatenated to obtain the pose description vector for each key frame. Based on the aforementioned feature observation correlation, statistical features of the observation direction of each map point and average matching confidence are calculated. The initial map point coordinates, the observation direction statistical features, and the average matching confidence are concatenated to obtain the map point description vector; Linear projections are performed on the pose description vector and the map point description vector to obtain pose lexical units and map point lexical units.

4. The SLAM global bundle adjustment substitution method according to claim 1, characterized in that, The step of calculating the reprojection error between the pose lexicon and the map point lexicon based on the feature observation association, and generating an attention bias by combining the matching confidence, includes: Based on the feature observation association, determine each observation pair between the pose lexicon and the map point lexicon; Project the map points in each observation pair onto the corresponding keyframe according to the initial keyframe pose to obtain the coordinates of the projected image points; The deviation between the coordinates of the projected image points and the coordinates of the actual observed feature image points is calculated to obtain the reprojection error of each observation pair. The reprojection errors are input into a decreasing activation function parameterized by a temperature coefficient to obtain the decreasing activation value for each observation pair. The attention bias is obtained by multiplying each of the decreasing activation values ​​by the corresponding matching confidence and bias strength coefficients.

5. The SLAM global bundle adjustment substitution method according to claim 1, characterized in that, The step of alternately updating the pose lexicon, the map point lexicon, and the attention bias input attention optimization network layer by layer to obtain the optimized pose lexicon and map point lexicon includes: In each preset attention optimization layer, the attention score is calculated using the pose term as the query and the map point term as the key. The attention score is added to the attention bias and then normalized to obtain the self-attention weight; Construct corresponding reprojection error features based on the reprojection error; The reprojection error features are aggregated using the self-attention weights to obtain the optimized pose lexical units. Perform cross-attention calculation on the optimized pose lexical and the map point lexical to obtain the optimized map point lexical; The results are passed to the next attention optimization layer via residual connections, and the final layer outputs the optimized pose lexicon and the optimized map point lexicon.

6. The SLAM global bundle adjustment substitution method according to claim 1, characterized in that, The process of decoding the optimized pose words and the optimized map point words to obtain the optimized keyframe pose and optimized map point coordinates includes: The optimized pose lexical units are input into the decoder to obtain the pose correction increment for each keyframe. The optimized map point terms are input into the decoder to obtain the coordinate correction increment of each map point; The pose correction increments are mapped and transformed to obtain the pose correction transformation amount of each key frame. The pose correction transformations are multiplied by the right and superimposed on the initial keyframe pose to obtain the optimized keyframe pose. The coordinate correction increments are superimposed on the corresponding initial map point coordinates to obtain the optimized map point coordinates.

7. The SLAM global bundle adjustment substitution method according to claim 1, characterized in that, The process of reusing the historical key values ​​of the attention-optimized network cache and incrementally updating the optimized keyframe pose and map point coordinates includes: The newly added keyframes and their associated newly added map points are encoded to obtain the corresponding newly added tokens; For each newly added lexical unit, the cached historical key value is read from the attention optimization network, and a single incremental attention calculation is performed on each newly added lexical unit and the historical key value to obtain the newly added optimization result; The newly added optimization results are decoded and the historical key values ​​are written back. The optimized keyframe poses and map point coordinates are updated. At the same time, for every newly added preset number of keyframes, all lexical units are re-inputted into the attention optimization network to perform a full update.

8. A SLAM global bundle adjustment substitution device, characterized in that, include: The data acquisition module is used to acquire the initial keyframe pose and initial map point coordinates output by the SLAM front end, as well as the feature observation correlation and matching confidence between each keyframe and each map point. The lexical encoding module is used to encode the initial keyframe pose and the initial map point coordinates respectively to obtain the pose lexicals corresponding to each keyframe and the map point lexicals corresponding to each map point. The bias generation module is used to calculate the reprojection error between the pose lexicon and the map point lexicon based on the feature observation association, and generate an attention bias by combining the matching confidence. The iterative optimization module is used to input the pose lexical unit, the map point lexical unit, and the attention bias into the attention optimization network, and update the optimized pose lexical unit and map point lexical unit layer by layer. The output decoding module is used to decode the optimized pose words and the optimized map point words respectively to obtain the optimized keyframe pose and the optimized map point coordinates; The incremental update module is used to reuse the historical key values ​​of the attention optimization network cache when a new keyframe is added, and incrementally update the optimized keyframe pose and map point coordinates.

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 SLAM global bundle adjustment substitution 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 SLAM global bundle adjustment substitution method as described in any one of claims 1 to 7.