Deep learning-based vslam key frame extraction method and device and storage medium
By optimizing the keyframe insertion strategy using a deep learning-based keyframe recognition network and a composite loss function, the robustness and stability issues in monocular visual SLAM algorithms are addressed, resulting in a reduction in the number of keyframes and an improvement in positioning accuracy.
Patent Information
- Application Number
- CN202410949083.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-07-16
AI Technical Summary
In existing monocular visual SLAM algorithms, the keyframe insertion strategy that relies on empirical values has low tracking robustness on outdoor public datasets, resulting in poor stability of tracking results and a large number of keyframes but low trajectory accuracy.
A keyframe extraction method based on deep learning is adopted. By training a keyframe recognition network, the keyframe insertion strategy is optimized using a composite loss function, including absolute trajectory error, relative pose error, keyframe insertion rate and global tracking time ratio loss, to update the keyframe recognition network.
This improves the robustness and stability of monocular vision SLAM systems, reduces the number of keyframes, and enhances the performance and localization accuracy of computer vision tasks.
Smart Images

Figure CN118918507B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of keyframe strategies for SLAM systems, and in particular to a method, apparatus, and storage medium for VSLAM keyframe extraction based on deep learning. Background Technology
[0002] The keyframe insertion algorithm in front-end odometry has a significant impact on back-end optimization, and the quality of the inserted keyframes determines the accuracy of loop closure. In existing monocular vision SLAM algorithms, empirical parameters are typically used to implement keyframe insertion strategies. These parameters are widely used in mainstream monocular vision SLAM tracking algorithms. However, in a study of the tracking robustness of the outdoor public dataset (KITTI), the empirically-based keyframe insertion strategy exhibited low robustness in front-end odometry tracking, leading to poor tracking stability and sometimes even resulting in a large number of keyframes but low trajectory accuracy. Summary of the Invention
[0003] The purpose of this invention is to provide a VSLAM keyframe extraction method, apparatus, and storage medium based on deep learning.
[0004] The objective of this invention can be achieved through the following technical solutions:
[0005] A VSLAM keyframe extraction method based on deep learning includes:
[0006] The video captured by the vehicle-mounted camera is obtained, and each frame of the video is sequentially input into the trained keyframe recognition network to obtain the keyframe recognition result output by the keyframe recognition network.
[0007] The training process of the keyframe recognition network includes:
[0008] Step S1: Obtain a sample video and the corresponding vehicle trajectory, wherein the sample video is captured by an onboard camera;
[0009] Step S2: Based on the sample video, perform position estimation to obtain the estimated vehicle trajectory;
[0010] Step S3: Synchronize the estimated vehicle trajectory and the actual vehicle trajectory on the time axis, and calculate the composite loss based on the estimated vehicle trajectory and the actual vehicle trajectory;
[0011] Step S4: Update the keyframe recognition network based on composite loss.
[0012] The mathematical expression for the composite loss is:
[0013]
[0014] in: For compound loss, For the loss of the first child, The second sub-loss is defined by σ1, the scaling factor for the first sub-loss is defined by σ2, the scaling factor for the second sub-loss is defined by AKr, the keyframe insertion rate loss is defined by OOTR, and the global tracking time percentage loss is defined by ATE. RMSE For absolute trajectory error, RPE RMSE This represents the relative pose error.
[0015] The mathematical expression for the absolute trajectory error is:
[0016]
[0017] Where: N is the number of points after trajectory discretization, T g,i Point P in the vehicle's actual trajectory g,i The pose transformation matrix, T esti,i To estimate point P in the trajectory of the vehicle esti,i The pose transformation matrix, (·) V For Lie algebra operations.
[0018] Point P g,i and point P esti,i Corresponding to the same moment
[0019] The mathematical expression for the relative pose error is:
[0020]
[0021] Wherein: T g,i+Δ Point P in the vehicle's actual trajectory g,i+Δ The pose transformation matrix, T esti,i+Δ To estimate point P in the trajectory of the vehicle esti,i+Δ The pose transformation matrix, where Δt is the position transformation matrix of point P. g,i+Δ and point P g,i The time interval.
[0022] Point P g,i+Δ and point P esti,i+Δ Corresponding to the same moment.
[0023] The mathematical expression for the keyframe insertion rate loss is:
[0024] AKr = 1.45Kr 5
[0025]
[0026] Where: AKr is the keyframe insertion rate loss, Kr is the keyframe insertion rate, and N is the number of keyframes. kf N represents the number of keyframes selected.all This represents the total number of frames in the sequence.
[0027] The mathematical expression for the global tracking time percentage loss is:
[0028]
[0029] Where: OOTR is the global tracking time percentage loss, T tracking T is the duration of a single stable tracking cycle of the system. all This represents the total time for the entire tracking process.
[0030] A VSLAM keyframe extraction device based on deep learning includes a memory, a processor, and a program stored in the memory, characterized in that the processor executes the program to implement the method described above.
[0031] A storage medium having a program stored thereon, which, when executed, implements the method described above.
[0032] Compared with the prior art, the present invention has the following advantages: it can effectively reduce the number of keyframes while maintaining accuracy, thereby effectively improving the performance of computer vision tasks. Attached Figure Description
[0033] Figure 1 This is a schematic diagram of the main steps of the method of the present invention;
[0034] Figure 2 This is a schematic diagram illustrating the principle of absolute trajectory error.
[0035] Figure 3 This is a schematic diagram illustrating the principle of relative pose error.
[0036] Figure 4 This is a schematic diagram illustrating the calculation method for relative pose error.
[0037] Figure 5 This is a diagram showing the comparison of keyframe extraction results. Detailed Implementation
[0038] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.
[0039] To make keyframe strategies more flexible and intelligent, this application proposes a deep learning-based keyframe strategy. This strategy, trained on a large amount of data, can more accurately and flexibly determine when a monocular vision SLAM system needs to insert keyframes. Compared to thresholds set based on empirical values, the strategy proposed in this application can more flexibly adapt to changes in different scenes and environments, reduce redundant keyframe insertions, lower the system's computational load, and improve the system's robustness and effectiveness in various complex scenarios, thereby enhancing the performance and stability of the monocular vision SLAM system.
[0040] Furthermore, this application also designs a composite loss function for network training, considering the tracking accuracy, tracking stability, and response speed of monocular visual SLAM systems. In summary, the network algorithm proposed in this application not only improves the mapping and localization accuracy of monocular visual SLAM systems but also reduces the number of keyframes maintained by the system, thereby effectively improving the performance of computer vision tasks. Therefore, the keyframe insertion strategy proposed in this application is of great significance for improving the accuracy and stability of monocular visual SLAM tracking.
[0041] A VSLAM keyframe extraction method based on deep learning includes:
[0042] The video captured by the vehicle-mounted camera is obtained, and each frame of the video is sequentially input into the trained keyframe recognition network to obtain the keyframe recognition result output by the keyframe recognition network.
[0043] The training process of the keyframe recognition network includes:
[0044] Step S1: Obtain a sample video and the corresponding vehicle trajectory, wherein the sample video is captured by an onboard camera;
[0045] Furthermore, there is a time-axis synchronization relationship between each frame in the sample video and the vehicle's actual trajectory; one frame in the sample video corresponds to a point in the vehicle's actual trajectory.
[0046] Step S2: Perform position estimation based on sample video to obtain the estimated vehicle trajectory;
[0047] This part is implemented by existing SLAM systems, so it will not be described in detail in this application.
[0048] Step S3: Synchronize the estimated vehicle trajectory and the actual vehicle trajectory on the time axis, and calculate the composite loss based on the estimated vehicle trajectory and the actual vehicle trajectory;
[0049] The composite loss consists of two parts: accuracy loss and system state loss. In the accuracy loss part, this embodiment uses pose error loss, which includes absolute trajectory error and relative pose error. In the system state loss, this embodiment uses keyframe insertion rate and global tracking time percentage.
[0050] Specifically, the mathematical expression for the composite loss is:
[0051]
[0052] in: For compound loss, For the loss of the first child, The second sub-loss is defined by σ1, the scaling factor for the first sub-loss is defined by σ2, the scaling factor for the second sub-loss is defined by AKr, the keyframe insertion rate loss is defined by OOTR, and the global tracking time percentage loss is defined by ATE. RMSE For absolute trajectory error, RPE RMSE This represents the relative pose error.
[0053] The absolute trajectory error part is derived by calculating the root mean square of the Lie algebra for each pose, as follows: Figure 2 As shown in the figure, there are two trajectories: the lower trajectory is the ground truth (g), and the upper trajectory is the estimation (esti). These two trajectories are discretized into an infinite number of points, and two points P are selected from each. esti,i and P g,i Its transformation relative to the origin P is shown in the following equation, where T is the Euclidean transformation.
[0054]
[0055] The Lie group form for calculating the error at the i-th point is:
[0056]
[0057] Since the rotation and translation of the SLAM system are calculated using the root mean square of the Lie algebra, we first need to find the Lie algebra corresponding to the error.
[0058]
[0059] After taking the norm, the root mean square is obtained. The absolute trajectory error of the SLAM system due to rotation and translation can then be obtained, as shown in the following formula:
[0060]
[0061] Where: N is the number of points after trajectory discretization, T g,i Point P in the vehicle's actual trajectory g,iThe pose transformation matrix, T esti,i To estimate point P in the trajectory of the vehicle esti,i The pose transformation matrix, (·) V For Lie algebra operations.
[0062] For the relative pose error component, the calculation method for relative pose error (RPE) is similar to that for absolute pose error. The principle is as follows: Figure 3 As shown. Relative pose error requires calculating the difference in transformation between two poses within the same timestamp. However, unlike absolute pose error, relative pose error calculation requires calculating the difference between two absolute poses, such as... Figure 4 As shown. In Figure 3 In the diagram, the lower trajectory represents the ground truth (g), and the upper trajectory represents the estimation (esti). Next, two points need to be selected on each trajectory. For any point i, there is a corresponding i+Δ point. The four points on the two trajectories are denoted as P. g,i P g,i+Δ P esti,i and P esti,i+Δ The changes in the true trajectory and the algorithm-estimated trajectory are calculated separately, expressed using Lie algebras:
[0063]
[0064] The algorithm estimates the Lie algebra of the change in the trajectory between two frames:
[0065]
[0066] The error in the change between two frames is calculated as follows:
[0067]
[0068] Finally, the root mean square (RMS) is taken to obtain RPE. all Since Δt corresponds to an integer number of frames, the root mean square is taken as N-Δ.
[0069] The mathematical expression for relative pose error is:
[0070]
[0071] Wherein: T g,i+Δ Point P in the vehicle's actual trajectory g,i+Δ The pose transformation matrix, T esti,i+Δ To estimate point P in the trajectory of the vehicle esti,i+Δ The pose transformation matrix, where Δt is the position transformation matrix of point P. g,i+Δ and point P g,i The time interval.
[0072] Regarding the keyframe insertion rate loss function, the keyframe insertion rate exhibits monotonicity and gradient invariance. These characteristics negatively impact the network's backward iterative training, forcing the network to approach zero keyframe insertion. While redundant keyframes negatively affect mapping quality, localization accuracy, and computational efficiency, insufficient keyframes also reduce map coverage and accuracy. Therefore, selecting an appropriate number of keyframes is crucial for the performance of monocular visual SLAM algorithms. Referring to empirical values for the keyframe number range in the ORB-SLAM2 system, the keyframe insertion rate (Auto Keyframeratio, AKr) loss function is defined as follows:
[0073] AKr = 1.45Kr 5
[0074]
[0075] Where: AKr is the keyframe insertion rate loss, Kr is the keyframe insertion rate, and N is the number of keyframes. kf N represents the number of keyframes selected. all This represents the total number of frames in the sequence.
[0076] For the global tracking time percentage loss component, a global tracking time percentage loss is designed. Global tracking time is an indicator for evaluating the tracking stability of a monocular vision SLAM system; it reflects the system's stability performance throughout the tracking process. This embodiment will use global tracking time to evaluate system tracking stability, defining the tracking time of the initial tracking as the interval from initialization to tracking loss, and using this as the tracking stability criterion. The global tracking time parameter is expressed as follows:
[0077]
[0078] Where: OOTR is the global tracking time percentage loss, T tracking T is the duration of a single stable tracking cycle of the system. all This represents the total time for the entire tracking process.
[0079] For composite loss, we can unify the loss functions of different dimensions and orders of magnitude mentioned above. We need a composite loss function that balances all loss terms. Furthermore, due to the randomness of the RANSAC algorithm and the selection of key points within the monocular vision SLAM system, the overall tracking accuracy of SLAM will exhibit a Gaussian distribution. Therefore, σ is the Gaussian distribution noise variance of the corresponding pose accuracy error.
[0080] Step S4: Update the keyframe recognition network based on composite loss.
[0081] The trained model files were deployed in the SLAM system, and experimental verification was performed, such as... Figure 5 As shown, the keyframe sparsity comparison on KITTI07 is illustrated, with blue lines representing the positions of keyframes inserted into the map. The left image shows the ORB-SLAM2 method, and the right image shows the method of this embodiment. It can be seen that the keyframes inserted by the method of this embodiment are sparser than those inserted by ORB-SLAM2.
[0082] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A VSLAM keyframe extraction method based on deep learning, comprising: The video captured by the vehicle-mounted camera is obtained, and each frame of the video is sequentially input into the trained keyframe recognition network to obtain the keyframe recognition result output by the keyframe recognition network. The training process of the keyframe recognition network is characterized by including: Step S1: Obtain a sample video and the corresponding vehicle trajectory, wherein the sample video is captured by an onboard camera; Step S2: Based on the sample video, perform position estimation to obtain the estimated vehicle trajectory; Step S3: Synchronize the estimated vehicle trajectory and the actual vehicle trajectory on the time axis, and calculate the composite loss based on the estimated vehicle trajectory and the actual vehicle trajectory; Step S4: Update the keyframe recognition network based on composite loss; The mathematical expression for the composite loss is: in: For compound loss, For the loss of the first child, For the loss of the second child, The scaling factor for the first sub-loss. The scaling factor for the second sub-loss. For keyframe insertion rate loss, For the percentage loss of global tracking time, For absolute trajectory error, This refers to the relative pose error. The mathematical expression for the keyframe insertion rate loss is: in: For keyframe insertion rate loss, For keyframe insertion rate, The number of keyframes selected. The total number of frames in the sequence; The mathematical expression for the global tracking time percentage loss is: in: For the percentage loss of global tracking time, The duration of a single stable tracking cycle of the system. This represents the total time for the entire tracking process.
2. The VSLAM keyframe extraction method based on deep learning according to claim 1, characterized in that, The mathematical expression for the absolute trajectory error is: in: N The number of points after discretization of the trajectory. Points in the vehicle's actual trajectory pose transformation matrix, To estimate points in the vehicle's trajectory The pose transformation matrix, (·) V For Lie algebra operations.
3. The VSLAM keyframe extraction method based on deep learning according to claim 2, characterized in that, Said point and points Corresponding to the same moment.
4. The VSLAM keyframe extraction method based on deep learning according to claim 2, characterized in that, The mathematical expression for the relative pose error is: in: Points in the vehicle's actual trajectory pose transformation matrix, To estimate points in the vehicle's trajectory pose transformation matrix, For point and points The time interval.
5. The VSLAM keyframe extraction method based on deep learning according to claim 4, characterized in that, Said point and points Corresponding to the same moment.
6. A VSLAM keyframe extraction device based on deep learning, comprising a memory, a processor, and a program stored in the memory, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1-5.
7. A storage medium having a program stored thereon, characterized in that, When the program is executed, it implements the method as described in any one of claims 1-5.
