## 3 Materials and Methods
### Detection and Tracking of Intruders  
When an intruder appears in the FOV of the SVS, the skeleton of the individual is analyzed to identify its feature. The functions of the openNI library is used for skeleton detection, and the identified feature is composed of joints and limb links, as shown in Figure 7a. Given the height of the intruder is about 170 cm, then the proposed distance between the intruder and the robot (or the SVS) for detection is 2500 mm to 3000 mm. In this range, the full body of the intruder can be viewed in the field of view (FOV) of SVS for skeleton analysis without being too close or too far. In order to track the intruder, the center between left and right hip nodes is used to estimate the orientation and the distance between the robot and the intruder. Assume that the image coordinate in horizontal and depth of the left and right hip nodes are \((i_{lh}\)\(i_{rh})\) and \((d_{lh}\)\(d_{rh})\), respectively. Thus, the tracking target of the intruder and its distance are defined as \(i_{ch}=(i_{lh}+i_{rh})/2\) and \(d_{ch}=(d_{lh}+d_{rh})/2\). The detection results are presented in Figure 7b. In addition, while an intruder is detected, the function of the robot is changed from patrolling to tracking until the intruder disappears from the FOV of SVS.  
Figure 6: (**a**) An inspection point marker with radio frequency identification (RFID) tag and (**b**) the corresponding binarized results from SVS.  
On the other hand, the tracking algorithm is similar to the inspection point approach algorithm, except for the near and far threshold values of tracking length, \(d_{kn}\) and \(d_{kf}\). At first, the robot is turned until \(i_{IT}\leq i_{h}\leq i_{IT}\). As long as the value of \(d_{ch}\) exceeds the far threshold value of tracking length \(d_{kf}\), then the robot moves forward; i.e., until the value of \(d_{ch}\) is less than \(d_{kf}\). Conversely, the robot moves backward until \(d_{ch}\) is larger than \(d_{kn}\). If the value of \(d_{ch}\) falls between \(d_{kn}\) and \(d_{kf}\), then the robot remains in the same position. The code of the tracking algorithm is shown in algorithm 1. Moreover, to view the intruder fully, the values of \(d_{kn}\) and \(d_{kf}\) are set to 2500 mm and 3000 mm, respectively. The robot also records images of intruders while tracking them, and uploads the images to a server via the upload web-service. When the target moves beyond the viewing window, the robot ceases its tracking task and returns to its patrol task.  
```
1: Detecting the skeleton of an intruder
2: Getting the image coordinates and distance of the left and right hip, \(\left(\begin{array}{cc}i_{lh}&i_{lh}\end{array}\right)\) and \(\left(\begin{array}{cc}d_{lh}&d_{rh}\end{array}\right)\)
3: Calculating the tracking target, \(i_{ch}=(i_{lh}+i_{rh})/2\), and \(d_{ch}=(d_{lh}+d_{rh})/2\)
4:if\(i_{ch}<i_{IT}\)then
5: The robot is turned CCW for 15\({}^{*}\)
6:elseif\(i_{ch}>i_{IT}\)then
7: The robot is turned CW for 15\({}^{*}\)
8:elseif\(i_{IT}\leq i_{ch}\leq i_{IT}\)then
9:If\(d_{ch}>d_{kf}\)then
10: The robot moves forward
11:elseif\(d_{ch}<d_{kn}\)then
12: The robot moves backward
13:elseif\(d_{kn}\leq d_{ch}\leq d_{kf}\)then
14: The robot remains in the same position
15:endif
16:endif
```  
**Algorithm 1** Tracking of intruders.