# Monocular Vision Guidance for Unmanned Surface Vehicle Recovery
## 2 Materials and Methods
### Visual Localization of the USV
#### 2.4.2 Visual Localization Process  
Using the PNP method for visual localization, autonomous recovery guidance for USVs can be achieved. By employing the PNP method, the distance and angle for USV positioning can be determined. The distance refers to the distance between the world coordinate system and the camera coordinate system, while the angle represents the angle between the optical axis and the plane of the artificial marker. To solve for the distance and angle, the external matrix \(M_{2}\) is computed through coordinate transformation. Subsequently, \(M_{2}\) is decomposed to obtain the rotation matrix \(R\) and the translation matrix \(T\). Finally, by using \(R\) and \(T\) matrices, the distance and angle can be derived. Figure 7 shows the translation and rotation between the two coordinate systems, where \(X_{w}Y_{w}O_{w}Z_{w}\) and \(X_{c}Y_{c}O_{c}Z_{c}\) represent the world coordinate system and the camera coordinate system, respectively. In Figure 7a, 'd' represents the distance between the coordinate systems(i.e., the distance determined by the localization method in this paper). In Figure 7b, '\(\beta\)' represents the angle between the camera optical axis \(Z_{c}\) and the \(X_{w}O_{w}Y_{w}\) plane of the world coordinate system (i.e., the angle determined by the localization method in this paper). The specific process for solving the rotation matrix \(R\) and the translation matrix \(T\) is as follows. The world coordinate system is established based on the center of the artificial marker as the origin. Thus, by utilizing the structural dimensions of the artificial marker as depicted in Figure 1 of Section 2.1, it is possible to calculate the world coordinates (\(X_{w}\), \(Y_{w}\), \(Z_{w}\)) for each circle's center point on the artificial marker. Subsequently, employing the methodology outlined in Section 2.3 enables the determination of the corrected pixel coordinates for the center point. Afterwards, by incorporating the world coordinates and pixel coordinates of the center point, along with the intrinsic matrix \(M_{1}\) derived from camera calibration, into Formula (12), it becomes feasible to derive the projection transformation matrix \(M_{2}\). Ultimately, by decomposing the \(M_{2}\) matrix, the rotation matrix \(R\) and the translation matrix \(T\) can be obtained, as evidenced by Formula (13). \[\left\{ \begin{array}{c}R=\left[\begin{array}{c c c}R_{11}&R_{12}&R_{13}\\ R_{21}&R_{22}&R_{23}\\ R_{31}&R_{32}&R_{33}\end{array}\right]\\ T=\left[\begin{array}{c}\Delta X\\ \Delta Y\\ \Delta Z\end{array}\right]\end{array} \right. \tag{13}\]  
We then calculate the distance through the translation matrix \(T\). The translation matrix \(T\) represents the translation relationship between two coordinate systems, as shown in Figure 7a. It mainly consists of three parameters, representing the translation amounts \(\Delta X\), \(\Delta Y\), and \(\Delta Z\) along the three coordinate axes. Based on the translation matrix \(T\), the distance between the camera coordinate system and the world coordinate system can be determined by using the formula shown in (14). \[d=\sqrt{\Delta X^{2}+\Delta Y^{2}+\Delta Z^{2}} \tag{14}\]  
We then calculate the angles based on the rotation matrix \(R\). The rotation matrix \(R\) represents the rotational transformation relationship between two coordinate systems, as shown in Figure 7b. To find the angle between the optical axis (i.e., the \(Z\)-axis of the camera coordinate system) and the artificial marker plane, it is equivalent to finding the  
Figure 7: Translation and rotation of coordinate systems: (**a**) translation of coordinate systems; (**b**) rotation of coordinate systems.