# A Novel Indoor Localization Method Based on Image Retrieval and Dead Reckoning
## 4 Vision-Aided PDR System Design
### Vision-Aided PDR Fusing
It corrects the location only when the distance between the estimated result of PDR at time \(k\) and the last correction point is between the thresholds \(\xi_{1}\) and \(\xi_{2}\) or the positioning result of VPR at time \(k\) changes in height compared to the positioning result at time \(k-1\). \[\left\{ \begin{array}{l}z_{v}^{k}\
eq z_{v}^{k-1}\\ \xi_{1}<|p_{j}^{k}-p_{0}^{\prime}|<\xi_{2}\end{array} \right. \tag{16}\]  
where the thresholds \(\xi_{1}\) and \(\xi_{2}\) are related to the positioning accuracy corrected by experiment. As mentioned above, when working for long periods, the accumulative error leads to a decrease in positioning accuracy of PDR system. It is difficult for PDR to make reasonable estimates when spatial position changes. Focusing on these problems, we propose a solution by means of using VPR network to correct the localization results of PDR. VPR is called every 5 m or after going around a corner. The detailed fusion algorithm is shown in Algorithm 1. ```
0: Picture \(x_{i}\) in the facing direction \(i=0\) \(L_{0}^{p},p=VPR(x_{0})\) \(L_{0}^{p}=L_{0}^{p}\) while\(p\leq\lambda\)do  Turn right for 20 degrees and get new picture \(x_{0}\) \(L_{0}^{v},p=VPR(x_{0})\) \(L_{0}^{p}=L_{0}^{v}\) endwhile while\(i\leq t\)do  Get a new picture \(x_{i}\) in the facing direction \(L_{i}^{v},p=VPR(x_{i})\) if\(\xi_{2}\geq\left\|L_{i}^{v}-L_{i}^{p}\right\|\geq\xi_{1}\)then \(L_{i}^{p}=Fusion(L_{i}^{p},L_{i}^{v})\) endif \(i=i+1\) endwhile return\(L_{i}^{p}\)
```  
**Algorithm 1** Measure the location \(L_{t}\) at time \(t\)  
where \(L_{t}\) means the predicted location at time \(t\), \(L_{t}^{v}\) means the location and direction predicted by VPR and the location predicted by PDR is \(L_{t}^{p}\). \(\lambda\) is the setting threshold, obtained by correcting the median of Recall@1 in the test dataset. \(p\) is the probability of the top VPR location and \(\xi_{1}\) and \(\xi_{2}\) are the setting location values. The values of \(\xi_{1}\) and \(\xi_{2}\) were obtained through experiments. The function \(Fusion()\) is shown above. First, the starting point of PDR is determined by VPR. If the probability \(p\geq\lambda\), the starting point is \(L_{t}^{p}\). If not, then turn right for 20 degrees until \(p\geq\lambda\). When the VPR performs well, it locates the position while turning around. If it does not perform well, it moves 0.5 m in a random direction for new positioning and infer the positioning at this step based on the relationship between the previous positioning and the movement calculated by PDR. Then, it repeats the steps above until the initial positioning is obtained. Then, PDR enters working state and starts to continuously update locations of pedestrians. In the process, the pedestrian pauses to take images of a place, and VPR processes these images to get reasonable location coordinate to correct the location estimated by PDR. When the confidence of the positioning given by VPR is higher than the threshold \(\sigma\), and the positioning result is within the distance between the previous correct positioning result and the PDR detection, we confirm that the positioning of VPR is accurate. Then, we judge the difference between PDR and VPR positioning. If the distance between results of VPR and PDR is between thresholds \(\xi_{1}\) and \(\xi_{2}\), the PDR positioning result is chosen to be the location. If not, the location is corrected to the VPR location, as the PDR has a large offset. When the confidence of VPR positioning is less than the threshold \(\sigma\), or the distance between new positioning result and previous correct positioning result is more than the PDR detection distance, we regard the VPR result as incorrect and then locate the new place only by PDR. In the V-PDR, we determined the value of thresholds \(\xi_{1}\) and \(\xi_{2}\) through extensive experiments. The threshold \(\sigma\) was set as 0.6. After the correction, more accurate locations are estimated by V-PDR.