# DFD-SLAM: Visual SLAM with Deep Features in Dynamic Environment
## 3 Materials and Methods
### Dynamic Points Culled Algorithm  
Our method combines optical flow and epipolar lines for the initial assessment of dynamic feature points, refining the removal process with semantic information. This approach draws inspiration from the LK optical flow and epipolar line motion consistency check methods, resembling the dynamic detection strategy of DS-SLAM. Initially, we apply the LK optical flow method to track feature points extracted by HFNet from the previous frame, obtaining optical flow vectors according to the results of the current frame, as illustrated in Figure 2b. The points successfully tracked across the previous and current frames are denoted as \(P_{1}\) and \(P_{2}\), as depicted in Equation (1), where \(u\) and \(v\) represent pixel coordinates. \[P_{1}=[u_{1},v_{1},1]\quad P_{2}=[u_{2},v_{2},1] \tag{1}\]  
After applying the RANSAC algorithm to filter out anomalous optical flow vectors and obtain the fundamental matrix between the two frames [31], the epipolar line \(L_{1}\) can be represented as shown in Equation (2):  
\[L_{1}= \begin{vmatrix}X\\ Y\\ Z\end{vmatrix} =FP_{1}=F \begin{vmatrix}u_{1}\\ v_{1}\\ 1\end{vmatrix}  \tag{2}\]  
The distance \(D\) between a pixel in the current frame and its corresponding epipolar line can be expressed as shown in Equation (3). If the distance is too far, the point is considered a potential dynamic point. \[D=\frac{\left|P_{2}^{\text{T}}FP_{1}\right|}{\sqrt{\|X^{2}\|+\|Y^{2}\|}} \tag{3}\]  
This method has been widely applied in various dynamic SLAM systems. Although this method can approximately identify dynamic feature points, significant errors in optical flow tracking and epipolar line calculations, coupled with issues when dynamic feature  
Figure 1: System architecture. points move along epipolar lines, necessitate its combination with semantic information. Over-removal or under-removal can severely impact the system's robustness. Despite heightened attention to this issue in recent research, a satisfactory solution remains elusive. Our proposed Algorithm 1 addresses this issue to a certain extent, facilitating more precise removal. ```
1:Dynamic points \(P_{D}\), Static points \(P_{S}\), Detect boxes \(D_{B}\), Mask; Thresholds \(\sigma_{1}\), \(\sigma_{2}\);
2:Precise mask, Final mask;
3:for each \(db\) in \(D_{B}\)do
4: Divide \(db\) into nine boxes \(DDB_{n}\);
5:for each \(ddb\) in \(DDB_{n}\)do
6: Initialize \(Dib=\{\}\), \(Sib=\{\}\);
7:\(Dib\leftarrow\)AppendTheDynamicPoints(\(P_{D}\),\(ddb\));
8:\(Sib\leftarrow\)AppendTheStaticPoints(\(P_{S}\),\(ddb\));
9:\(dynamicRatio\leftarrow\operatorname{Len}(Dib)/(\operatorname{Len}(Dib)+ \operatorname{Len}(Sib))\);
10:if\(dynamicRatio<\sigma_{1}\)then
11: Append \(ddb\) to \(Staticboxes\);
12:else
13: Append \(ddb\) to \(Dynamicboxes\);
14:endif
15:endfor
16: Check and merge near boxes from \(Staticboxes\) to \(Dynamicboxes\);
17:if\(\operatorname{Len}(Dynamicboxes)>\sigma_{2}\)then
18:\(Dynamicboxes\leftarrow Dynamicboxes\cup Staticboxes\);
19:endif
20: Remove the corresponding mask from \(dynamicboxes\);
21:endfor
```  
**Algorithm 1** Dynamic Points Culled Algorithm  
After the initial selection of dynamic and static points on the current frame using the optical flow-epipolar line method, the system divides the target detection boxes into nine areas, as shown in Figure 2d. Between lines 3 and 6, each box's dynamic points are evaluated and categorized into Dynamic In Box (Dib) or Static In Box (Sib). From lines 7 to 12, based on the ratio of dynamic to static points, each small box is determined to be either a static or dynamic sub-box. At line 14, the system identifies dynamic sub-boxes within the mother detection box and adjusts adjacent boxes to a dynamic state to ensure no potential dynamic regions are missed in the mask, with the final result shown on the left side of Figure 2e. Moreover, considering dynamic objects may move between frames, lines 15 to 18 assess the dynamic level of the target.