# Monocular Vision Guidance for Unmanned Surface Vehicle Recovery
## 2 Materials and Methods
### Detection of Artificial Markers and Extraction of Ellipse Centers  
The detection of artificial markers is a prerequisite for visual positioning. By detecting the artificial markers installed on the mother ship, the positioning of the USV can be achieved based on the characteristics of the artificial markers. Therefore, a method combining color segmentation and least squares ellipse fitting is proposed to achieve the detection of artificial markers and the extraction of the center points of the imaged ellipses. This method is aimed toward achieving accurate detection and localization of the artificial markers. The color segmentation technique is employed to initially differentiate artificial markers from the background. Color segmentation is a method of image segmentation that relies on color features. Converting the acquired \(RGB\) image to the \(HSV\) color space enables better differentiation of color characteristics, facilitating the segmentation of artificial markers. The conversion formula for the \(HSV\) image is given by Equation (1), where \(H\), \(S\), and  
Figure 1: Camera shooting scene. represent the hue, saturation, and value, respectively. \(R\), \(G\), and \(B\) correspond to the values of the red, green, and blue channels, respectively. \[\left\{\begin{array}{l}H=\left\{ \begin{array}{l}\frac{1}{6}(\frac{G-B}{Max(R,G,B)-Min(R,G,B)}),if\ R=Max(R,G,B)\\ \frac{1}{6}(2+\frac{B-R}{Max(R,G,B)-Min(R,G,B)}),if\ G=Max(R,G,B)\\ \frac{1}{6}(4+\frac{R-G}{Max(R,G,B)-Min(R,G,B)}),if\ B=Max(R,G,B)\\ \\ S=\frac{Max(R,G,B)-Min(R,G,B)}{Max(R,G,B)}\\ V=Max(R,G,B)\end{array} \right. \tag{1}\]  
The color-segmented image of the artificial marker is shown in Figure 2b after color segmentation. However, in Figure 2b, there are still other interferences present besides the region of the artificial marker. To eliminate these interferences and extract the pixel coordinates of the center point of the imaged ellipse, a least squares ellipse fitting method is employed [27]. The final fitting result is illustrated in Figure 2c. The purpose of using the least squares ellipse fitting method is due to the fact that the projection of a circle on the image plane is always approximately an ellipse. The principle of the least squares ellipse fitting method is to first assume the parameters of the ellipse and then calculate the sum of the squared distances between all of the points and the assumed ellipse. Finally, the parameters that minimize this sum are determined as the parameters of the assumed ellipse. The specific implementation process is as follows:  
First, let us assume an equation for an ellipse (as shown in Equation (2)), where the pixel coordinates of the ellipse in the image plane are denoted as \(P_{i}(x_{i},y_{i})\). Based on the ellipse equation in Equation (2) and the principle of least squares, the objective function \(F(A,\)\(B,\)\(C,\)\(D,\)\(E)\) is derived. The objective function \(F\) is represented by Equation (3). \[x^{2}+Axy+By^{2}+Cx+Dy+E=0 \tag{2}\]  
\[F(A,B,C,D,E)=\sum_{i=1}^{N}\left(x_{i}^{2}+Ax_{i}y_{i}+By_{i}^{2}+Cx_{i}+Dy_{i} +E\right)^{2} \tag{3}\]  
To obtain the minimum value of the objective function \(F\), it is necessary to set the partial derivatives of \(F(A,\)\(B,\)\(C,\)\(D,\)\(E)\) with respect to each parameter to zero, as shown in Equation (4). \[\frac{\partial F}{\partial A}=\frac{\partial F}{\partial B}=\frac{\partial F }{\partial C}=\frac{\partial F}{\partial D}=\frac{\partial F}{\partial E}=0 \tag{4}\]  
According to the principle of solving partial derivatives, Equation (5) can be derived. Then, by substituting the acquired pixel coordinates of the ellipse in the image plane, \(P_{i}(x_{i},y_{i})\), into Equation (5), the unknown parameters of the ellipse, \(A\), \(B\), \(C\), \(D\), and \(E\), can be solved. Figure 2: Diagrams illustrating the process of detection and ellipse fitting of artificial markers: (**a**) the original image; (**b**) color segmentation; (**c**) least squares fitting of an ellipse. \[