## 5 Discussion
### Keyframe-Based LiDAR Optimization in a Multithreaded Framework  
In terms of accuracy, the ICP iterative algorithm can meet the global optimum although the geometrical information of the scene is not rich; for instance, when the scene has only one or several planes of cylindrical geometry and the pose of the ICP iterative calculation has a good constraint on the direction of the camera. Therefore, the geometric information of the scene can be used to constrain the visual SLAM. The local LiDAR corrected pose is propagated into local map construction, which can then provide an appropriate initial value for the map segmentation iterative optimization algorithm, and make the map optimization quickly reach the global optimum. After conducting a large number of experiments under normal tracking in different scenes, we obtained the correlation between the number of keyframes per map segment and the absolute cumulative error obtained by registration with LiDAR data, the ICP iterations, and correlation between the ICP iterations and the absolute cumulative error. As seen from Figure 20a,b, as the number of keyframes increases, the cumulative errors increase. When the number of keyframes per map segment  
Figure 19: (**a**) Constructed points (red) overlap with the LiDAR data (green) after motion recovery in low-light scenario and (**b**) constructed points (red) overlap with the LiDAR data (green) after motion recovery in motion blur scenario. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Operation** & **Medium (ms)** & **Mean (ms)** & **Std. Dev. (ms)** \\ \hline Receiving a frame & 33.33 & 33.33 & 33.33 \\ Creation of keyframe & 552.90 & 553.18 & 157.33 \\ \hline \hline \end{tabular}
\end{table} 
Table 9: Computation time for creating one keyframe in visual tracking thread. is within 80 frames, the position error is generally below 2.5 m, angular error is below 10\({}^{\circ}\), and the ICP iterative algorithm can quickly converge to the global optimal value with at most 35 in the number of iterations, as shown in Figure 20e. However, as the cumulative error increases, the locally acquired LiDAR data may not overlap with the point cloud generated by the depth image, resulting in the ICP algorithm acquiring an inaccurate camera pose. Figure 20: Correlation between the number of keyframes per map segment and cumulative error as well as LiDAR data optimization time. (**a**) Correlation between position drift error and number of keyframes per map segment, (**b**) correlation between angular drift error and number of keyframes per map segment, (**c**) correlation between ICP iterations and number of keyframes per map segment, and (**d**) correlation between ICP iterations and position error; (**e**) correlation between ICP iterations and angular error. In terms of real-time performance, the voxel downsampling of a certain resolution of the LiDAR data of a large scene greatly reduces the amount of data used. Furthermore, LiDAR data retrieval for large scenes requires high computation time. In this study, the pose obtained by camera tracking is used as the prerequisite for LiDAR data retrieval, and the LiDAR data is organized by the KD-tree method, which greatly reduces the computation time. In addition, the point cloud data collected by RGB-D is downsampled with a certain resolution to reduce the number of point clouds participating in the ICP iteration. The adopted map point culling strategy of the front window and the keyframe culling strategy of the back window eliminate the redundant optimization variables, and the calculation time of the Jacoby matrix and the Hessian matrix is thus reduced. The multithread segmentation optimization is applied to avoid global optimization of the overall map, ensuring the optimization time is within a certain threshold, and ensuring the optimized results are shared by each thread in real time. As seen from Figure 21a,b, the average optimization time per keyframe is reduced with the increase in the number of keyframes per map segment.