# NGLSFusion: Non-Use GPU Lightweight Indoor Semantic SLAM
## 3 Method
### Visual Odometry  
The VO module used in the algorithm is improved based on ORB-SLAM2, and its algorithm framework is shown in Figure 2, where green is the input, red is the output, and yellow and blue are the judgment and processing, respectively. The module is implemented by initializing the first frame of the input into the module using ORB feature extraction due to its rotation, illumination, and scale invariance, extracting key points using FAST [56] features, then comparing the point pairs selected in a fixed pattern around the key points to obtain a binary BRIEF descriptor [57], and then combining the obtained feature points with their depth information to generate map points using the EPNP algorithm [58] to complete the initialization of the first frame. Figure 1: Algorithm framework of NGLSFusion. After initialization, the Lucas-Kanade optical flow method [33] is used to track the feature points on the subsequent non-keyframes, assuming that the grayscale value of the feature point in the previous frame at moment t is denoted as \(G(x,y,t)\), where \((x,y)\) denotes the coordinates of the feature point in the incoming image in the two-dimensional plane. After time \(\Delta t\), the grayscale value of the same feature points in the current frame are represented by \(G(x+\Delta x,y+\Delta y,t+\Delta t)\), which leads to the following equation:  
\[G(x+\Delta x,y+\Delta y,t+\Delta t)=G(x,y,t) \tag{1}\]  
The Taylor expansion of Equation (1):  
\[G(x+\Delta x,y+\Delta y,t+\Delta t)=G(x,y,t)+\frac{\partial G}{\partial x}dx+ \frac{\partial G}{\partial y}dy+\frac{\partial G}{\partial t}dt+o(dx,dy,dt) \tag{2}\]  
According to Equations (1) and (2), the following relationship is obtained:  
\[\frac{\partial G}{\partial x}dx+\frac{\partial G}{\partial y}dy+\frac{ \partial G}{\partial t}dt+o(dx,dy,dt)=0 \tag{3}\]  
Dividing both sides of Equation (3) by d simultaneously yields:  
\[\frac{\partial G}{\partial x}\cdot\frac{dx}{dt}+\frac{\partial G}{\partial y} \cdot\frac{dy}{dt}+\frac{\partial G}{\partial t}=0 \tag{4}\]  
where \(\frac{\partial G}{\partial x}\) and \(\frac{\partial G}{\partial y}\) denote the partial derivative of the grayscale value of the feature point to the coordinates \(x\) and \(y\) in the two-dimensional plane, \(\frac{\partial G}{\partial t}\) denotes the partial derivative to time \(t\), \(\frac{dx}{dt}\) and \(\frac{dy}{dt}\) denote the displacement of the feature point in the previous frame, and \(o(dx,dy,dt)\) denotes the minimum of the coordinates \(x\) and \(y\) and time \(t\), and the displacement can be used to locate the position of the same feature point in the current frame and obtain the correspondence of the feature point. If there is a large movement, the same feature points of the previous frame and the current frame are easily mismatched, so it is necessary to use the reverse optical flow to eliminate the error. As shown in Figure 3 below, the feature points 1, 2, and 3 in the previous frame are tracked by forward and reverse optical flow to determine their positions, such as 1 corresponds to 4, 2 corresponds to 5, and 3 corresponds to 6 in the forward optical flow; 4 corresponds to 7, 5 corresponds to  
Figure 2: Algorithm framework of VO module. 8, and 6 corresponds to 9 in the reverse optical flow. The error between 3 and 9 by forward and reverse tracking is already greater than 0.5 pixels, which is defined as a wrong tracking point and executed to delete it, so as to improve the optical flow tracking accuracy. New keyframes are created according to the matching relationship of feature points on the extracted images, and, finally, the feature points are extracted and their descriptors are calculated for the newly created keyframes using the direct method of DSO [36]. After obtaining enough feature points, the camera pose is calculated and optimized using the 3D-2D PnP-Ransac algorithm, assuming that there are n feature points obtained by the direct method of tracking keyframes, where the 3D points and feature points correspond as follows:  
\[s_{i}