**3. Front-End: Feature Extraction and Matching Tracking**

#### *3.1. Line Feature Extraction*

Commonly used line feature extraction algorithms include Hough [26], LSWMS [27], EDLine [28], and LSD [29]. Weighing factors such as accuracy, real-time performance, and the need for parameter adjustment, we chose LSD to extract line features. According to the bottom parameter optimization strategy, we modified an improved LSD algorithm, and a minimum geometric constraint method to realize line feature constraint matching.

Given an N-layer Gaussian pyramid as the scale space of LSD line features, the scale ratio of images in each layer is defined to reduce or eliminate the sawtooth effect in images. After scaling the image *s* times, a downsampling was performed, and then the gradient was calculated for all pixels in the new image obtained after downsampling. By traversing the image and getting the gradient values of all pixels, the pixel gradient rectangle can be merged according to the density of same-sex points to obtain a rectangle-like line segment *l*. The density *d* of homogeneous points in the rectangle can be expressed as:

$$d = \frac{k}{length(l) \cdot width(l)}, d \le D \tag{1}$$

where *k* is defined as the total number of pixels in the rectangle, and *D* is the density threshold of parity points. Different from the hypothesis in [12], a low co-location density threshold in the outdoor complex texture environment will extract a large number of invalid line features. Therefore, it is necessary to re-optimize the strategy according to the underlying parameters and select the following combinations near the original parameters (*s* = 0.8, *D* = 0.7), for real-time and accuracy experiments.

We measured the positioning accuracy by the root mean square error of absolute trajectory error (APE\_RMSE). The accuracy and real-time performance of different values of *s* and *D* on the Hong Kong 0428 dataset are shown in Figure 2. The Monte Carlo method was used in this experiment. Within the parameter range that ensures the stable operation of the line feature extraction algorithm, we conducted three experiments. First of all, as shown in Figure 2a, under the premise that the original scaling times *s* = 0.8, 100 random numbers were selected in the range of *D* ∈ (0.3, 0.9) to carry out the experiment of density threshold selection. Secondly, as shown in Figure 2b, we kept the original density threshold *D* = 0.7, and then selected 100 random numbers in the range of *s* ∈ (0.4, 0.9), which is to select the appropriate range of scaling times *s*. Finally, as shown in Figure 2c, within the appropriate parameter range obtained in the previous experiments, 100 groups of parameter combinations were randomly selected for line feature extraction to obtain the optimal value.

**Figure 2.** Underlying parameter selection. (**a**) Density threshold selection, (**b**) scaling times selection. (**c**) Experimental results by selecting the best combination of parameters. Noted that decreasing *s* and *D* will show better real-time performance with negligible loss of accuracy.

According to Figure 2c it can be seen that the operation time is shorter when the value of (*s*, *D*) is around (0.5, 0.6) or around (0.6, 0.6). Furthermore, we compared the accuracy of the above two groups of parameters. It can be concluded that the accuracy of line feature extraction of the former group is slightly higher than that of the latter group. Considering the accuracy and real-time, we chose *s* = 0.5, *D* = 0.6 as the parameter combination for our system.
