## 2 Materials and Methods
### Feature Point Homogenization  
After deleting the mismatched point pairs, the number of feature points tracked by the optical flow has decreased. To achieve accurate and stable feature point tracking, it is necessary to supplement the reduced number of feature points. To avoid excessive concentration or sparsity of the supplemented feature points, we use image masking to uniformly distribute the feature points. The initially extracted feature points are shown in Figure 2a. First, the feature points tracked by optical flow in previous frame are sorted in descending order of tracking frequency, and an image mask with the same size as the image is created, which each pixel set to 255. The value of the mask position corresponding to the feature point is then traversed. If the value is 255, this feature point is retained. Furthermore, the area of a circle with the feature point position as its center and \(r\) as its radius is set to 0 in image mask. If the value of the image mask position corresponding to each feature point is 0, the feature points are deleted. After all the feature points have been traversed, the result of preserving the uniformly distributed feature points is shown in Figure 2b, and the final image mask is shown in Figure 2c. Finally, the Shi-Tomasi feature points are extracted in the image corresponding to the non-zero region of the image mask, as shown by the blue points in Figure 2d.  
The distance parameter \(r\) of the feature point is a crucial factor in achieving image mask homogenization. If \(r\) is set too small, the uniformity of the image will be poor, leading to the extraction of too many feature points. Conversely, if \(r\) is set too large, the quality of feature points extracted in low-texture environments may be compromised, although it can make the distribution of feature points more uniform. In order to automatically adapt to changes in the environment, we dynamically adjust the feature point distance \(r\) based on the quality of the optical flow feature points. We classify the tracked feature points into high-quality feature points and low-quality feature points, where the quality of the feature point is evaluated based on the variance \(\sigma\) of \(N\) pixels surrounding the feature point, as shown in following:  
\[\sigma^{2}=\frac{1}{N}\sum_{k=0}^{N-1}{(I_{k}-I_{mean})^{2}} \tag{7}\]  
where \(I_{mean}\) is the grayscale average of \(N\) pixels, \(I_{k}\) is the pixel value of the \(k\) pixel point. When \(\sigma\) exceeds the threshold value, the feature point is considered a high-quality feature point, otherwise it is a low-quality feature point. Then, we dynamically adjust \(r\) by counting the proportion of low quality feature points \(\alpha\):  
\[r=\begin{cases}max(r\times k,\frac{R}{2}),&\alpha>\tau_{1}\\ min(\frac{r}{R},2R),&\alpha<\tau_{2}\\ r,&otherwise\end{cases} \tag{8}\]  
Figure 2: Image mask homogenization. (**a**) The original feature points with the image mask (red dots), the black balls are the ineffective area of the mask; **(b**) the results of homogenization; **(c)** the generated mask; **(d)** the feature points of secondary extraction in the next frame.  
where \(k\) is the adjustment coefficient, which defaults to 0.8; \(R\) is the original radius, which defaults to 20; \(\tau_{1}\) is the upper limit threshold of low quality feature points, and the default value is 0.4, \(\tau_{2}\) is the lower threshold value of low quality feature points, and the default value is 0.03. When the proportion of low quality feature points is high, reduce the feature point distance \(r\) to obtain more close high-quality feature points; When the proportion of high-quality feature points is very high, increase the feature point distance \(r\) to make the distribution of feature points more uniform. When the scale is appropriate, the current feature point distance \(r\) is maintained unchanged.