# Remote Control of a Mobile Robot for Indoor Patrol
## 2 Image Processing  
In most image processing methods, the light source is very important to the final result. In this study, the image in the red/green/blue (RGB) color space is transformed to the hue/saturation/value (HSV) color space which can significantly reduce the impact of lightness. The HSV model defines a color space in terms of three constituent components; hue (\(H\)), saturation (\(S\)), and value (\(V\)). \(H\) is an angle from 0 degrees to 360 degrees. Saturation indicates the range of grey in the color space. It ranges from 0 to 100%. Sometimes the value is calculated from 0 to 1. Value is the brightness of the color and varies with color saturation. It ranges from 0 to 100%. The ranges of the hue and saturation color space can be set to appropriated values so that the image processing is performed as a filter and is utilized to discard useless information and preserve useful information. The center of an object can be detected by the use of the distance calculation method of the camera. With these methods, the robot can track a moving object. The RGB color space values are transferred to HSV color space values by the following equations [17; 18; 19]:  
\[ \begin{split} H&=\cos^{-1}\frac{(R-G)+(R-B)}{\sqrt {(R-B)^{2}+(R-B)(G-B)}},B\leqslant G\\ H&=2\pi-\cos^{-1}\frac{(R-G)+(R-B)}{\sqrt{(R-B)^{2 }+(R-B)(G-B)}},B>G\\ S&=\frac{\max(R,G,B)-\min(R,G,B)}{\max(R+B+G)}\\ V&=\frac{\max(R,G,B)}{255}\end{split}  \tag{1}\]  
After HSV transformation, the image is then transformed to a binary image so that the original image can be easily identified from the foreground and background. The binary image is applied to change the image color from 0 to 255, where 0 represents black and 255 represents white. A designation of 255 is the foreground representing the captured dynamic obstacle, whereas 0 is the background representing the image to be filtered out. In the binary image process, an appropriate threshold first needs to be set up. If the pixels' values of a captured image are larger than the threshold value, then they are set to 255. If the pixels' values are smaller than the threshold value, they are set to 0. The threshold will affect the captured image in object tracking control. Figure 1 shows an example of the original RGB image transformed into the HSV and binary images. Distance between the robot and the moving target can be obtained by a geometry method [20]. Figures 2 and 3 show the top view and side view of the EYECAM camera (Draganfly Innovations Inc., Saskatoon, SK, Canada). Three prerequisite angles can be obtained by Equations (4)-(6), where the angles are shown in Figures 2 and 3. \[\alpha=\tan^{-1}(\frac{E}{b}) \tag{4}\]  
\[\theta=\tan^{-1}(\frac{E}{L_{y}}) \tag{5}\]  
\[\beta=\tan^{-1}(\frac{L_{x}/2}{b+L_{y}}) \tag{6}\]  
\(E\) denotes the height from the camera to the floor, \(b\) represents the distance from the projection point of the camera on the floor to the closest viewpoint, and \(Ly\) is the largest range that the camera can see, as shown in Figure 3. \(Lx\) is the largest width that the camera can see; it is the length from the left to the right of the view, as shown in Figure 2. Coordinates of the target can be obtained as follows:  
Figure 1: (a) Original red/green/blue (RGB) image; (b) hue/saturation/value (HSV) space image; (c) Binary image of the HSV space. Figure 2: Top view of camera [17]. \[y=\frac{E}{\tan[(\alpha-\theta)\frac{v}{w}]} \tag{7}\]  
\[x=\tan[\beta(\frac{2u}{H})-1]\cdot y \tag{8}\]  
\(x\) is the distance of the target away from the center line of the camera, as shown in Figure 2. \(y\) is the distance of the target away from the WMR, as shown in \[\theta=\tan^{-1}(\frac{E}{L_{y}}) \tag{5}\]0  
In Equations (7) and (8), \(u\) and \(v\) are the horizontal pixel and the vertical pixel of the center coordinates of the captured target, respectively. The \(H\) and \(W\) represent the pixel lengths of an image provided by the camera. In this paper, \(E\) is 15 cm, \(Lx\) is 160 cm, \(Ly\) is 150 cm, \(b\) is 10 cm, \(H\) is 320, and \(W\) is 480.