## 3 Methodology
### Visual Odometry
Finally, the result is transformed into latitude/longitude coordinates, and the process is repeated with the next image. In this experiment, the similarity distance for the worst match (among the best 200 matches) is 691. Therefore, we set a threshold of 300 to ensure that we only include good matches and the output is shown in Figure 5. Although we could set a lower threshold, it is important to maintain sufficient keypoints to prevent outliers from inducing errors in the estimation of rotation and translation. In [44], an analysis of threshold selection for establishing matches using ORB is presented. However, the selection of these thresholds will depend on the application [51]. Once we know the correspondence between both point clouds, we compute their centroid:  
\[C_{i}=\left(\frac{1}{n}\sum_{j=1}^{n}x_{ij},\frac{1}{n}\sum_{j=1}^{n}y_{ij}\right) \tag{1}\]  
where \(C_{i}\) is the centroid of the 2D points in the image \(i\), \(x\), and \(y\) are the pixel coordinates of the feature \(j\) in image \(i\), and \(n\) is the number of good matches. Then, we determine the optimal rotation between points, taking them to the origin and applying Singular Value Decomposition (SVD) [52; 53], as follows:  
\[H=(q_{1i}-C_{1})(q_{2i}-C_{2})^{T} \tag{2}\]  
\[[U,S,V]=\text{SVD}(H) \tag{3}\]  
\[R=VU^{T} \tag{4}\]  
where \(q_{ji}\) are the coordinates of point \(i\) from the point cloud \(j\). Figure 1:0 Matches between consecutive images. The red lines connect the pixels from the first image with their corresponding ones in the second image. The figure shows the best 200 matches. Figure 1:1 Matches between consecutive images. The figure shows, with red lines, the matches between keypoints with \(\rho<300\). Now, it is possible to find the translation \(d^{(px)}\) with  
Figure 1:2  
For more detailed information on this algorithm and a full derivation of finding the optimal rotation and translation between point clouds, we recommend [52; 53]. The goal is to determine the UAV movement by measuring the displacement from one point cloud to the next. It is important to note that we have access to the angle of rotation since this is information obtained from the IMU and it is available even if the GPS has been corrupted. It then involves converting the displacement of the point clouds, measured in pixel units, into the UAV displacement in meters. There is an issue of ambiguity when trying to convert from pixels to meters. It may be true that a large displacement between the centroids is due to either moving very fast or having the keypoints very close to the UAV. Since the altitude (estimated using the barometer) is another piece of information we have access to even without GPS, we use the barometer to heuristically scale \(s\) the altitude and use this value to convert from pixel units to meters. The scale \(s\) is calculated with  
Figure 1:3  
where \(s\) is the scale to transform from pixel to meters. \(\delta\) is a correction factor that has been determined by running the algorithm (using only visual odometry) and reducing the error with respect to the GPS route, and \(h\) represents the distance from the UAV to the ground. This is  
Figure 1:4  
where \(a\) is the UAV altitude and \(e\) is the terrain elevation, taken from the Digital Elevation Model (DEM), which is displayed in Figure 1:5  
Since we are calculating a relationship between image pixels and meters, it is necessary to convert the GPS coordinates into a system that uses meters as the unit of measurement, such as UTM. This is done using the open-source Geospatial Data Abstraction Library (GDAL), which is a library used to work with geospatial data formats. We start from the last coordinates obtained from GPS (before it has been denied) and convert them to UTM coordinates. In the UTM system, the Earth is divided into 60 longitudinal zones, each spanning 6 degrees of longitude. These zones are numbered consecutively from west to east, starting at 180\({}^{\circ}\)W. Each zone is designated by a number from 1 to 60.