# PLI-VINS: Visual-Inertial SLAM Based on Point-Line Feature Fusion in Indoor Environment
## 3 Point Line Feature Processing
### Adaptive Threshold Line Segment Extraction Algorithm  
When the traditional LSD algorithm is used in structural scenes, it is easy to produce many short, overlapping and overlapping line segments. As shown in Figure 3b,c, these line segments easily cause matching difficulties, resulting in the decrease in the rate and accuracy of camera pose estimation. We propose an adaptive threshold line segment extraction algorithm, which merges and removes the above-mentioned line segments to further reduce redundant matching and mismatching of line features, thus improving the robustness and accuracy of the proposed algorithm.  
Firstly, length screening was carried out for the set \(\{l_{1},l_{2},\cdots l_{N}\}\) of all line segments extracted by the traditional LSD algorithm; the short line segment whose \(len_{l_{i}}\) is less than the length threshold \(len_{\text{min}}\) is eliminated. The short lines that have great influence on attitude estimation can be deleted by length screening. The length threshold \(len_{\text{min}}\) satisfies the following formula:  
\[\begin{array}{l}len_{l_{i}}\geq len_{\text{min}},i\subseteq\{1,2,\cdots,N\} \\ len_{\text{min}}=\frac{N}{3N+|\max(W_{k},H_{k})|}\cdot\lceil\min(W_{k},H_{k})\rceil \end{array} \tag{1}\]  
where \(N\) is the number of line features extracted from the image of frame \(K\); \(W_{k}\) and \(H_{k}\) are the width and height of the current \(k\) frame; \(\lceil\bullet\rceil\) means round up.  
Figure 2: Comparison of the effects of the two algorithms: (**a**) EuRoC datasets scene; (**b**) traditional LSD + KLT optical flow; (**c**) the effect of our algorithm.  
In the case of the three common line segments as shown in Figure 4, this paper constructs the external matrix of the line segment \(l_{i}\) after length screening, and determines whether there are heads, tails and midpoint endpoints of other adjacent line segments in the external matrix area. Then, the line segment features that meet the conditions are added to the same set \(\left\{l_{i_{i}},l_{i_{1}},l_{i_{2}},\cdots l_{i_{n}}\right\}\). In Figure 4b, no endpoint is located in the external matrix to be eliminated. Since each line segment in the set is characterized by a known starting point and ending point, the main direction A=angle of the vector in the image coordinate system can be calculated. As shown in Figure 4a,c, the main directions of line segment \(l_{i}\) and other line segments \(l_{i_{n}}\) in the set were calculated and the average value was taken as the angle threshold \(ang_{\text{min}}\), and then the features of line segments whose angles with line segment \(l_{i}\) were greater than the angle threshold \(ang_{\text{min}}\) were eliminated. Finally, all line segments that meet the conditions are extracted from the beginning and end and the midpoint and end points, respectively, and the line segment is fitted to the point set by the least square method.  
Compared with the single threshold set by experience in the paper [20; 30; 31; 32], the threshold set in this paper is associated with the number of line segments extracted, image size and scene, which can more effectively adapt to the impact of different indoor scene changes.  
LBD descriptors were extracted from the filtered line segments for subsequent feature matching. The KNN algorithm is then used for line segment matching. If the matching distance and angle are less than the threshold value, the matching is considered successful.