# A Real-Time Map Restoration Algorithm Based on ORB-SLAM3
## 2 Materials and Methods
### Map Restoration Based on Reverse Tracking  
In the reverse tracking, we first take out a frame \(F_{i}\) in the stack and precise positioning tracking. We quickly match \(F_{i}\) with the first keyframe \(KF_{0}\) in the current active map using a bag-of-words. In the matching process, only the feature points belonging to the same node are matched, and the number of successful matching points \(n\) is obtained. If the number meets the requirements, MLPNP is used to estimate the pose of \(F_{i}\). MLPNP not only decouples the relationship with the camera model, but also has the advantages of fast speed and high accuracy. Then, the chi-square test is used to eliminate the outliers, and the reprojection error is calculated according to Equation (1),  
\[e=u-\bar{u}, \tag{1}\]  
where \(u\) is the pose of the feature point of \(F_{i}\) on the pixel plane, \(\bar{u}\) is the pose of the map point of \(KF_{0}\) projected to the \(F_{i}\) pixel plane. Affected by many independent factors, the reprojection error is random. According to the central limit theorem, the reprojection error obeys the Gaussian distribution,  
\[e\sim N(0,C), \tag{2}\]  
where \(C\) is the covariance,  
\[C=(s^{n}\times p)^{2} \begin{bmatrix}1&0\\ 0&1\end{bmatrix} , \tag{3}\]  
where \(s\) is the scaling factor of the image pyramid, \(p\) is the standard deviation of the 0 th layer. The error term in Equation (1) is weighted by covariance to obtain an error scalar \(r\),  
\[r=e^{T}C^{-1}e, \tag{4}\]  
which, according to the monocular projection, is 2 degrees of freedom, and the threshold of chi-square statistics is 5.99 at 0.05 significant level. We believe that the point greater than this threshold is the outlier, and the point less than this threshold is the interior point. Figure 1: System overview. Our system pipeline is an extension of ORB-SLAM3 [17]. Compared with ORB-SLAM3, the main improvements of our system have been marked with “*” in the flowchart. The red part indicates new additions, and the green indicates improvements. When the number of interior points \(m\) is sufficient, we update the pose \(T_{cw}\) in the world coordinate system of the current frame,  
\[T_{cw}= \begin{bmatrix}R_{cw}&t_{cw}\\ 0^{T}&1\end{bmatrix} , \tag{5}\]  
where \(R_{cw}\) and \(t_{cw}\) are the rotation and translation matrices from the world coordinate system to the current camera coordinate system, respectively.If the number of interior point \(m\) obtained in the previous step is small, as shown in Figure 2, the unmatched map points between frame \(KF_{0}\) and \(F_{i}\) are re-projected to the camera coordinate system of \(F_{i}\), and the new point pairs are obtained by using a more stringent threshold and smaller window matching. Finally, the pose optimization is carried out again. After tracking \(F_{i}\) and getting the pose, the fast reference frame tracking begins. After inserting \(F_{i}\) into the keyframe queue, the mappoints are inserted into the point cloud map, and we update this frame as a reference keyframe for the image frame in the stack. The next frame \(F_{i-1}\) of pop stack is quickly matched with its reference keyframe through the bag-of-words, and then the mappoints of the reference keyframe are projected to \(F_{i-1}\) and the pose estimation is carried out according to MLPNP, so as to obtain the pose transformation of the frame in the world coordinate system. The pose transformation \(T_{cr}\) of this frame relative to the reference frame is calculated according to Equation (6) and saved to the map file for the generation of map trajectory. \[ \begin{split} T_{cr}&=T_{cw}\times T_{urr}\\ T_{urr}&=T_{rw}^{-1}\\ T_{rw}&=\begin{bmatrix}R_{rw}&t_{rw}\\ 0^{T}&1\end{bmatrix}\end{split}  \tag{6}\]  
If the number of successful matching points of \(F_{i-1}\) is small, the steps similar to the completed precise positioning tracking between \(F_{i}\) and \(KF_{0}\) are performed.