# GNSS Spoofing Identification and Smoothing Localization Method for GNSS/Visual SLAM System
## 2 System Model
### Visual SLAM System Modeling and Error Analysis  
The sensor used in our visual SLAM system is a binocular vision mileage camera. Its localization principle is to estimate the rotation and translation matrix of the camera through the matching relationship between the feature points observed in two adjacent pictures, and to calculate the relative motion path of the camera. For visual SLAM, the relative motion path of the camera is estimated based on the information of two adjacent frames, and there is also an estimation error \(e_{v}(t)\) at time \(t\). With continuous calculations, these errors will gradually accumulate in the positioning results through calculations. If the positioning result is not corrected in time, the positioning error will continue to accumulate and increase, making the posture estimation deviation larger and larger. Therefore, we need to optimize to reduce the accumulation of errors. However, if all the observed frames are optimized to reduce the accumulation of errors, the amount of data will continue to increase. The computational burden to solve the optimization problem will also increase rapidly as the amount of data increases. Therefore, we set a visual processing sliding window (the size of the window is set to \(m\)) to store, optimize, and update the key frames constantly to reduce the computational burden of the system, reduce estimation errors, and improve positioning accuracy. The visual frame optimization algorithm is as follows. First of all, after obtaining the original information of the left-eye and right-eye image of the binocular camera in current frame, the current left-eye image is tracked with the left-eye image of the previous frame using the pyramid LK optical flow method [17] based on corner point features. The matched points between the two frames are retained as feature points, and the points with large differences are eliminated. Then, the feature point set is obtained, defined as \(\mathbf{P}_{l}=\{\mathbf{p}_{1},\mathbf{p}_{2},\ldots,\mathbf{p}_{n}\}\). For the right-eye image of the current frame, match it with the left-eye image of the current frame and extract feature points using the same method as above. Next, determine whether the current frame is a key frame according to the obtained feature point information and update the key frame in the visual processing sliding window. Calculate the number of common-view feature points between the left eye frame and the last key frame \(f_{k}\) in the visual processing sliding window. If the number of common-view feature points is less than the feature point threshold \(\mathrm{H}_{p}\), delete the first frame \(f_{1}\) in the visual processing sliding window, add the current left eye image to the visual processing sliding window as a key frame and sequentially update the key frames in the window (for example, frame \(f_{2}\) is updated to be frame \(f_{1}\), and frame \(f_{k-1}\) is updated to be \(f_{k-2}\)). Conversely, if the number of common-view feature points is greater than the feature point threshold \(\mathrm{H}_{p}\), delete the last key frame \(f_{k}\) and add the current left-eye image to the visual processing sliding window as a key frame to replace the last frame \(f_{k}\). Similarly, calculate the number of common-view feature points between the right-eye frame and the last key frame \(f_{k}\) in the window, and update the key frame in the visual processing sliding window. Then, optimize the feature information of the key frames in the visual processing sliding window and the rotation and translation matrix between frames to update the pose of the camera. The camera pose update is divided into two stages: the initialization stage and the stable updating stage. In the camera initialization stage, the world 3D coordinates of the feature points observed by the camera are unknown.