# DFD-SLAM: Visual SLAM with Deep Features in Dynamic Environment
## 3 Materials and Methods
### Frame Rotation Estimation and Feature Point Matching  
The feature extraction based on HFNet provides high-quality feature points and descriptors, thereby improving matching efficiency and triangulation accuracy, ultimately enhancing the accuracy of pose estimation. However, in instances of frame rotation, as noted in the HFNet-SLAM paper [7], the performance of deep-learning-based feature extraction significantly deteriorates, resulting in feature matching failures and tracking loss. In contrast, ORB descriptors used in ORB-SLAM3 have demonstrated excellent robustness in rotation, which is the foundation of our work. To tackle this issue, we assess the frame rotation between the current and previous frames to decide on the descriptor to be used and to select a suitable distance calculation method for various descriptors. We utilize the optical flow vectors obtained from the previous tracking step and estimate the frame rotation angle using these vectors. The detailed process of frame rotation angle estimation is outlined in Algorithm 2. When a frame rotation occurs in the frame, the distributed optical flow vectors around the image's center point exhibit a characteristic pattern, as shown in the figure. While motion between frames is complex and may involve rotations along multiple axes, including frame rotation, the perpendicular bisector of the optical flow vectors may not necessarily pass exactly through the center of the frame rotation. Additionally, the tracking of optical flow vectors may not be entirely accurate. Therefore, we employ a least-squares method to optimize and solve this problem. In Algorithm 2, the first line calculates the perpendicular bisector for each optical flow vector. Given a base optical flow vector, the midpoint and slope are used to determine the equation of its perpendicular bisector, represented by Equation (4):  
\[ax+by+c=0 \tag{4}\]  
The formula represents the line on which the optical flow vector lies, where \(a\), \(b\), and \(c\) are the coefficients corresponding to this line. \(x\) and \(y\) represent the points on the line of the optical flow vector, including the two endpoints of the optical flow vector. In the second line, the center point of the frame is chosen as the starting point for optimization. Since most detected and recognized frame rotations typically occur near the center of the image, this choice significantly reduces optimization time. Figure 2: The complete process of precise elimination. (**a**) The segmentation results of YOLOv8. (**b**) The results of optical flow tracking on the extracted feature points. (**c**) The results of epipolar constraints. (**d**,**e**) The system dividing the detected potential dynamic objects into sub-frames and identifying the dynamic regions within them. In (**e**), the red boxes indicate dynamic regions, while the green areas indicate static regions. (**f**) The final retained segmentation results after dilation processing. The third line constructs and solves the optimization function \(f(x,y)\) as outlined in Equation (5), aiming to minimize the distance between \(OP\) and all perpendicular bisector lines:  
\[f(x,y)=\sum_{i=1}^{n}\left(\frac{|a_{i}x+b_{i}y+c_{i}|}{\sqrt{a_{i}^{2}+b_{i}^{2 }}}\right)^{2} \tag{5}\]  
We seek a rough estimate of the frame rotation angle for real-time applications. BFGS optimization is employed for faster iteration.