# Novel Online Optimized Control for Underwater Pipe-Cleaning Robots
## 2 Catadioptric Panoramic Image-Based Vision Localization
### Projection Transformation Rules  
The purpose of projection transformation is to obtain the real position of the biofuling boundary based on the image features. Considering that the UPCR is in a random orientation, two-pixel coordinate systems named xoy and x'oy' were defined in the captured image, as shown in Figure 5a. Their origin coincided with the optical center of the camera. Axis oy and axis ox' are parallel to the  
Figure 4: Process of the feature extraction.  
moving direction of the UPCR and the axis of the pipe, respectively. \(\alpha\) is the rotation angle from xoy to x'oy', and can be calculated based on Equation (3) as follows:  
\[\alpha=\arctan\frac{n}{\sum k_{i}}\;\;i=1,2,\ldots,n \tag{3}\]  
According to the feature of Region B, points at the boundary of the area covered by biofouling can be described as P\({}_{i}\)(\(x_{i}\),\(y_{i}\)) in xoy. Their coordinates change to P'\({}_{i}\)(\(x_{i}^{\prime}\),\(y_{i}\)) in x'oy', which can be calculated by Equation (4):  
\[\left\{\begin{array}{l}{x_{i}}^{\prime}=x_{i}\cos(-\alpha)-y_{i}\sin(-\alpha )\\ {y_{i}}^{\prime}=x_{i}\sin(-\alpha)+y_{i}\cos(-\alpha)\end{array}\right. \tag{4}\]  
The camera imaging model is presented in Figure 5b. O\({}_{c}\)x\({}_{b}\)y\({}_{b}\)zb is the base coordinate system and x\({}_{p}\)o\({}_{p}\)y\({}_{p}\) is the image coordinate system on the image plane. O\({}_{c}\) is the equivalent optical center, which is symmetric with the optical center of the camera about the mirror. O\({}_{c}\)x\({}_{b}\), o\({}_{p}\)y\({}_{p}\), and ox\({}^{\prime}\) (in Figure 5a) have the same direction, as well as O\({}_{c}\)y\({}_{b}\), o\({}_{p}\)y\({}_{p}\), and oy\({}^{\prime}\). Then, P\({}_{pi}\)(\(x_{pi}\),\(y_{pi}\)) in x\({}_{p}\)o\({}_{p}\)y\({}_{p}\) corresponding to P'\({}_{i}\)(\(x_{i}^{\prime}\),\(y_{i}\)) is given as follows:  
\[\left\{\begin{array}{l}{x_{pi}}=K\cdot{x_{i}}^{\prime}\\ {y_{pi}}=K\cdot{y_{i}}^{\prime}\end{array}\right. \tag{5}\]  
where \(K\) is the scaling factor of coordinate transformation between x'oy' and x\({}_{p}\)o\({}_{p}\)y\({}_{p}\). It is constant and can be measured in advance by the following method.  
Figure 5: Schematic of the projection transformation: (**a**) Left view, (**b**) Top view.  
One of the points at the pipe edge is first chosen as Q(0,\(y_{Q}\)?) in x'oy' (Figure 5a), and Qb is the corresponding point of Q on the pipe (Figure 5b). Thus, OcQb and the pipe are tangent. Then, the corresponding point of Q in \(x_{\text{p}}\)o\({}_{\text{p}}\)y\({}_{\text{p}}\) defined Qp(0,\(y_{Qp}\)) can be calculated as follows:  
\[y_{Qp}=-\frac{f}{t}.d \tag{6}\]  
where \(f\) is the focal length and \(d\) is the distance between Oc and the pipe along axis Ocyb, which is given as follows:  
\[d=dis\cdot\cos\alpha \tag{7}\]  
where \(dis\) is the distance between the camera and the center of the UPCR, as shown in Figure 5a. \(t\) is a temp parameter that can be calculated based on geometric similarity as follows:  
\[\frac{\sqrt{t^{2}+d^{2}}}{L-t}=\frac{d}{R} \tag{8}\]  
where \(R\) is the radius of the pipe and \(L\) is the distance between Oc and the pipe along axis Oczb. Thus, \(K\) is given as Equation (9):  
\[K=\frac{y_{Qp}}{y_{Q}\prime} \tag{9}\]  
As equations of the line OcPbi and the surface of the pipe can be defined as Equations (10) and (11), respectively, the coordinates of points at the boundary of the area covered by biofouling on the pipe named Pbi(\(x_{bi}\),\(y_{bi}\),\(z_{bi}\)) can be calculated based on Equations (4), (5), (10), and (11):  
\[\frac{x_{bi}}{x_{pi}}=\frac{y_{bi}}{y_{pi}}=\frac{z_{bi}}{-f} \tag{10}\]  
\[\left(z_{bi}+L\right)^{2}+\left(y_{bi}+d\right)^{2}=R^{2} \tag{11}\]