## 3 Methods
### Visual Relocalization in Autonomous Vehicles  
1. Construction of the Map Scene Database;  
The map data are collected using the stereo visual camera and RTK system mounted on the autonomous vehicle. The MonSter [37] model calculates the disparity in the images. From this, depth information is derived using disparity-depth conversion. The pose information, RTK coordinates, and depth data for each image are linked to its image ID. Each image, along with its pose, RTK coordinates, and depth data, is stored in the database. This completes the map scene database construction. 2. Neural Network-Based Image Retrieval System;  
This section presents a neural network-based image retrieval system. Neural networks are better at feature encoding than traditional content-based methods. They can directly extract high-dimensional features from images. We use the ResNet-50 model for feature extraction. The model's shortcut connections help improve communication between feature vectors in different high-dimensional spaces. This design increases image classification accuracy without adding many parameters. The ResNet-50 model comprises 50 layers and is organized into four stages. Stage 1 contains three residual units, Stage 2 has four, Stage 3 includes six, and Stage 4 consists of three residual units. Each residual unit comprises three convolutional layers. The network also includes an initial convolutional layer, followed by a pooling layer and a fully connected layer at the end. To extract high-dimensional global image features for practical applications, the original architecture was modified in this study by removing the final pooling and fully connected layers. Figure 2 presents the visualizations of the output features from each residual block. Taking into account both the representational power and dimensionality of the features, the output of the fourth residual block is selected as the global descriptor. This descriptor is subsequently employed for image similarity measurement and retrieval-based matching tasks. After feature extraction of the images in the database using ResNet-50, a set of feature vectors \(V_{\text{base}}\) is obtained and stored as the feature descriptor database. For a query input image \(I_{q}\), its feature vector \(V_{Iq}\) is extracted using ResNet-50. The similarity between \(V_{Iq}\) and all feature vectors in \(V_{\text{base}}\) is then computed. The image with the highest similarity is selected as the retrieved image \(I_{k}\), and its corresponding feature descriptor vector is \(V_{Ik}\)  
Figure 2: Extraction of high-dimensional image features. The similarity is calculated as the cosine of the angle between the vectors in the feature space, with the formula given in Equation (1):  
\[Similarity(V_{lq},V_{lk})=\frac{<V_{lq}\bullet V_{lk}>}{|V_{lq}||V_{lk}|}, \tag{1}\]
3. Depth Estimate;  
Due to the unique design of stereo cameras, depth estimation can be achieved by comparing the images captured by the left and right cameras to calculate their disparity. Based on the principle of triangulation, the depth of each image point can be estimated. The stereo camera model is illustrated in Figure 3. In this model, \(O_{L}\) and \(O_{R}\) represent the optical centers of the left and right cameras, respectively. A 3D point \(p\) is projected onto the left and right image planes as \(P_{L}\) and \(P_{R}\). The baseline \(b\) denotes the distance between the optical centers, and \(f\) is the focal length. \(u_{L}\) and \(u_{R}\) are the horizontal coordinates of \(P_{L}\) and \(P_{R}\). Typically, the two image planes are coplanar and horizontally aligned. Based on triangulation, the depth \(z\) can be computed as:  
\[\left(\frac{z-f}{z}\right)=\left(\frac{b-u_{L}+u_{R}}{b}\right), \tag{2}\]  
After organizing the equations, we have:  
\[z=\frac{fb}{d},\,d=u_{L}-u_{R}, \tag{3}\]  
Here, \(d\) denotes the disparity, the horizontal coordinate difference between corresponding points in the left and right images.