## 2 Materials and Methods
### Pose Estimation  
In visual localization, camera pose estimation is performed by minimizing the reprojection error. The 3D points are projected onto the current frame based on the pose and camera model of the camera, resulting in image points. The camera pose is iteratively adjusted to minimize the error between the observed and projected image points. It is assumed that these points are perfectly matched. The error \(\mathbf{e}_{ij}\) for the 3D point \(\mathbf{p}_{j}\) in the frame \(i\) is defined as follows [3]:  
\[\mathbf{e}_{ij}=\mathbf{u}_{ij}-\Pi\Big{(}\mathbf{T}_{cw}\bigoplus\mathbf{p}_ {j}\Big{)} \tag{1}\]  
where \(\mathbf{u}_{ij}\) is the coordinate of the observed point in the pixel coordinate system and \(\Pi:\mathbb{R}^{3}\rightarrow\mathbb{R}^{n}\) represents the projection function of the camera. \(\mathbf{T}_{cw}\) stands for the transformation from the world to camera coordinate. \(\bigoplus\) is the transformation operation of \(SE(3)\) group over \(\mathbb{R}^{3}\) elements. We adjusted the number of levels in the multi-level feature-extraction process to enhance the processing speed of the system. This adjustment introduces feature-extraction and matching errors, which can ultimately lead to deviations in pose estimation. To maintain the accuracy of pose estimation, it is essential to incorporate additional information constraints and reduce the influence of outliers. The global distribution characteristics of the position points can be leveraged. The principal direction, representing the direction with the most significant data variation and maximum variance, reflects the distribution characteristics of the data. Incorporating the projection error along the principal direction into the error calculation can improve pose estimation accuracy. Specifically, we first centralize the matched image feature point \(\mathbf{x}_{ij}\) and compute the covariance matrix \(\mathbf{C}\). By decomposing the covariance matrix, we obtain the principal direction. The position points \(\mathbf{p}_{j}\) in the world coordinate system are then transformed into the pixel coordinate system and projected into the principal direction, where we compare the projection error. \[\mathbf{x}^{c}_{ij}=\mathbf{x}_{ij}-\mathbf{u} \tag{2}\]  
\[\mathbf{C}=\frac{\sum_{j}^{n}\mathbf{x}^{c}_{ij}\mathbf{x}^{c}_{ij}\mathbf{T} }{n-1} \tag{3}\]  
\[\mathbf{C}=\mathbf{V}^{\mathrm{T}}\mathbf{\Lambda}\mathbf{V} \tag{4}\]  
\[\mathbf{x}^{\prime}_{ij}=\mathbf{v}^{\mathrm{T}}_{m}*\Pi\Big{(}\mathbf{T}_{cw }\bigoplus\mathbf{p}_{i}\Big{)}*\mathbf{v}_{m}+\mathbf{u} \tag{5}\]  
where \(\mathbf{u}\) is the center of image feature points, \(n\) is the number of feature points, \(\mathbf{V}^{\mathrm{T}}\) is the matrix of eigenvectors, \(\mathbf{\Lambda}\) is the diagonal matrix of eigenvalues, and \(\mathbf{v}_{m}\) is the principal direction, the eigenvector corresponding to the largest eigenvalue. After obtaining the projected point \(\mathbf{x}^{\prime}_{ij}\), the principal direction projection error \(\mathbf{e}^{\prime}_{ij}\) is  
\[\mathbf{e}^{\prime}_{ij}=\mathbf{u}^{\prime}_{ij}-\mathbf{x}^{\prime}_{ij} \tag{6}\]Given that multiple error functions are optimized simultaneously, an error upper bound constraint \(\varepsilon\) is introduced to ensure the quality of the solution, constraining the projection error along the principal direction. \[\mathbf{e}^{\prime}_{ij}\mathbf{\ast}\mathbf{e}^{\prime}_{ij}<\varepsilon \tag{7}\]  
Thus, the improved error formula is  
\[\left\{ \begin{aligned} & argmin\left(\sum_{i}^{n}\left\|\mathbf{e}_{ ij}\right\|_{\Sigma}+\sum_{i}^{n}\left\|\mathbf{e}^{\prime}_{ij}\right\|_{\Sigma} \right)\\ &\mathbf{e}^{\prime}_{ij}\mathbf{\ast}\mathbf{e}^{\prime}_{ij}< \varepsilon\end{aligned} \right. \tag{8}\]  
In Equation (8), the reprojection error \(\sum_{i}^{n}\left\|\mathbf{e}_{ij}\right\|_{\Sigma}\) is consistent with the formulation in Reference [3], where \(n\) represents the number of feature points, and \(\Sigma\) denotes the covariance matrix.