# Privacy-Preserved Visual Simultaneous Localization and Mapping Based on a Dual-Component Approach
## 3 Method
### Image Inpainting
#### 3.2.2 Algorithm Details  
Firstly, the original image \(I_{gt}\) is passed into the YOLOv8 network for the detection of privacy-sensitive areas. The objects that appear in the street view dataset, including people, bicycles, cars, motorcycles, buses, and trucks, are defined as to be detected due to the presence of sensitive information like faces and license plates. The detection threshold is mainly used to filter the prediction results. By retaining the results with prediction confidence higher than the threshold, a balance is achieved between reducing false positives and improving recall. In this paper, the detection threshold is set to 0.4 to ensure that as many privacy objects as possible are detected while avoiding false detections. Then, the areas \(S\) where the privacy objects are located are detected through multi-scale feature fusion, and the mask image \(M\) is generated. Moreover, the original image is grayscaled to obtain a grayscale image \(I_{grav}\) and is also subjected to an algorithm of contour detection called Canny to generate a contour image \(C_{gt}\). Secondly, \(I_{gt}\), \(I_{grav}\), and \(M\) are used to generate \(I_{grav}\) and \(I_{gt}\) by the Hadamard product. The purpose of this step is to ensure that privacy-sensitive information is invisible. Then, a contour image \(\hat{C}_{gt}\) is generated, where the privacy-sensitive areas are missing. After completing the above steps, \(\hat{I}_{grav}\), \(\hat{C}_{gt}\), and \(M\) are passed into the contour generator of the EdgeConnect network, generating the contour prediction \(C_{pred}\) for masked privacy-sensitive areas. Thirdly, the contour \(C_{comp}\) of the inpainted image is generated using \(C_{pred}\), \(C_{gt}\), and \(M\). Finally, \(\hat{I}_{gt}\) and \(C_{comp}\) are passed to the image completion network of the EdgeConnect network, and the inpainted image \(I_{pred}\) is obtained and then inputted to ORB-SLAM3 for localization and mapping. The specific process of our method is presented in Algorithm 1.  
```
1:Input: Original image \(I_{gt}\), The YOLOv8 \(YOLO\), Generators of the EdgeConnect \(EC_{G1}\), \(EC_{G2}\), The algorithm of contours detection \(Canny\), and The algorithm of grayscale conversion \(Gray\)
2:Output: Inpainted image \(I_{pred}\)
3:Privacy-sensitive areas detection:
4: Detection of privacy-sensitive areas \(S\):
5:\(S\gets YOLO(I_{gt})\)
6: Generation of a mask image \(M\):
7:\(M_{ij}\gets 1\) if \((i,j)\in S\), otherwise 0
8:Grayscale conversion:
9:\(I_{grav}\gets Gray(I_{gt})\)
10:Contours detection:
11:\(C_{gt}\leftarrow\) Canny(\(I_{gt}\))
12:Privacy-sensitive areas masking:
13:\(\hat{I}_{gt}\gets I_{gt}\odot(1-M)\)
14:\(\hat{I}_{grav}\gets I_{grav}\odot(1-M)\)
15:\(\hat{C}_{gt}\gets C_{gt}\odot(1-M)\)
16:Privacy-sensitive areas inpainting:
17:Contours prediction:
18:\(C_{pred}\gets EC_{G1}(\hat{I}_{grav},\hat{C}_{gt},M)\)
19:Contours combination:
20:\(C_{comp}\gets C_{gt}\odot(1-M)+C_{pred}\odot M\)
21:Image inpainting:
22:\(I_{pred}\gets EC_{G2}(\hat{I}_{gt},C_{comp})\)
```  
**Algorithm 1** Image inpainting method  
Differently from EdgeConnect [26], which aims to restore the original image, our method ensures that the generated image does not contain privacy-sensitive objects. The inpainted area should blend naturally with the surrounding areas to minimize the impact on the subsequent localization accuracy of ORB-SLAM3.