# A Semantic Information-Based Optimized vSLAM in Indoor Dynamic Environments
## 3 Methodology
### Semantic Segmentation Module
#### 3.4.2 Refine Segmentation  
The depth camera can provide color and depth images. The two-dimensional image and semantic information of each key frame can be mapped to a three-dimensional point cloud based on the camera internal parameters, as shown in Figure 7. However, due to the over-segmentation problem in obtaining the semantic information of the image, the semantic information in two dimensions is mapped to the three-dimensional point cloud with large deviations, as shown in Figure 7c. Therefore, a region growing algorithm with depth information is given to optimize 3D semantic annotation, as shown in Table 1. As shown in Figure 8, the accuracy of optimized 3D semantic annotation by the algorithm in Table 1 has significantly improved. \[ \begin{split} m_{pq}=\sum\limits_{u,v}u^{p}v^{q}I(u,v),\ p,q=\{0,1\}\\ P_{center}=(u_{0},v_{0})=\left(\frac{m_{10}}{m_{00}},\frac{m_{ 01}}{m_{00}}\right)\end{split}  \tag{2}\]  
where \(p\), \(q\) is 0 or 1; \(I(u,v)\) represents the gray value at pixel \((u,v)\), \(m_{pq}\) represents the geometric moment of the contour of the mask. \(P_{center}\) represents the mask center point. Figure 6: Dynamic area detection. The effect of semantic segmentation of BiSeNet V2 network. In (**a**), the first row is the publicly available data in the TUM RGB-D dataset [25], and the second row is the data of the actual dynamic scene collected. The effect of BiSeNet V2 on the semantic segmentation of the image is shown in (**b**). In this figure, light blue indicates pedestrians, dark blue indicates monitors, red indicates books, and pink indicates chairs. In step 2 of the algorithm in Table 1, the Euclidean distance threshold \(T\) needs to be determined. The fixed threshold value is only applicable to a certain class of cases. Therefore, we give a method to dynamically select the Euclidean distance threshold \(T\) of the by random sampling within the mask. First, \(i\) pixel points in the semantic mask are randomly selected, and at the same time, the adjacent eight pixels of each random pixel point are also selected. The average Euclidean distance of the corresponding spatial coordinates between random pixel points and their adjacent pixels points is calculated by Equation (3). Then, \(\overline{p}_{m}\) is sorted, and after eliminating the largest and smallest terms in \(\overline{p}_{m}\), the average value of the Euclidean distance is calculated. Finally, the Euclidean distance threshold \(T\) in step 2 in Table 1 is calculated by Equation (7). \[\overline{p}_{m}=\frac{\sum_{n=1}^{8}\sqrt{(x_{n}^{m}-x_{m})^{2}+(y_{n}^{m}-y_{ m})^{2}+(z_{n}^{m}-z_{m})^{2}}}{\rho=\frac{1}{l-2}\sum_{n=1}^{i-1}\overline{p}_{m}},m=1,2,\ldots i \tag{3}\]  
where \(\overline{p}_{m}\) represents the average value of the Euclidean distance of the spatial coordinates corresponding to the random pixel points and their adjacent pixel points; \((x_{m},y_{m},z_{m})\) represent the spatial coordinates corresponding to the random pixel points, \((x_{n}^{m},y_{n}^{m},z_{n}^{m})\) represent the spatial coordinates corresponding to the adjacent 8 pixels of each random pixel point, and \(\rho\) represents the average value of Euclidean distance. \[T=\epsilon\rho \tag{4}\]  
where \(\epsilon\) represents the dynamic coefficient, and \(\rho\) represents the average value of Euclidean distance.