# Research on a Measurement Method for the Ocean Wave Field Based on Stereo Vision
## 2 Materials and Methods
### Sea Surface Base Plane Calibration  
We then converted the image coordinates to camera coordinates and the specific method for this conversion is described as follows:  
Assume that the coordinates of the wave target point in the left camera coordinate system \(\text{O}_{\text{w}}-\text{X}_{\text{w}}\text{Y}_{\text{w}}\text{Z}_{\text{w}}\) are \((x_{\text{w}},y_{\text{w}},z_{\text{w}})\) and that the coordinates of the corresponding image points on the left and right images are \((u_{\text{l}},v_{\text{l}}),(u_{\text{r}},v_{\text{r}})\). According to the conversion  
Figure 2: Schematic diagram of the principle of image matching. relationship, the formula for converting the left and right image points to the left camera coordinate system can be given as:  
\[z_{cl} \begin{bmatrix}u_{1}\\ v_{1}\\ 1\end{bmatrix} =H_{1}\times \begin{bmatrix}x_{w}\\ Y_{w}\\ z_{w}\\ 1\end{bmatrix} ,z_{cr} \begin{bmatrix}u_{r}\\ v_{r}\\ 1\end{bmatrix} =H_{r} \begin{bmatrix}x_{w}\\ y_{w}\\ z_{w}\\ 1\end{bmatrix}  \tag{8}\]  
\[H_{l}=A_{l}\times \begin{bmatrix}E&0\end{bmatrix}  \tag{9}\]  
\[H_{r}=A_{r}\times \begin{bmatrix}R&T\end{bmatrix}  \tag{10}\]  
In above formula, \(A_{l},A_{r}\) are the internal parameter matrices of the left and right cameras, respectively; \(R,T\) are the rotation and translation matrices of the dual target, which can be obtained by calibration, and, then, \(H_{l}\) and \(H_{r}\) can be obtained. Expanding the above formula can provide the following formulas:  
\[M= \begin{bmatrix}u_{l}h_{31}-h_{l11}&u_{h}h_{32}-h_{l12}&u_{h}h_{33}-h_{l13}\\ v_{l}h_{13}-h_{l21}&v_{l}h_{32}-h_{l22}&v_{l}h_{l33}-h_{l23}\\ u_{r}h_{r31}-h_{r11}&u_{r}h_{r32}-h_{r12}&u_{r}h_{r33}-h_{r13}\\ v_{r}h_{r31}-h_{r21}&v_{r}h_{r32}-h_{r22}&v_{r}h_{r33}-h_{r23}\end{bmatrix}  \tag{11}\]  
\[U= \begin{bmatrix}h_{l14}-u_{l}h_{l34}\\ h_{l24}-v_{l}h_{l34}\\ h_{r14}-u_{r}h_{r34}\\ h_{r24}-v_{r}h_{r34}\end{bmatrix}  \tag{12}\]  
where \(M,U\) can be obtained from \(H_{l},H_{r}\), and the pixel coordinates \((u_{l},v_{l}),(u_{r},v_{r})\). Then the camera coordinates of the wave space point \((x_{w},y_{w},z_{w})\) can be obtained through the following formula:  
\[ \begin{bmatrix}x_{w}\\ y_{w}\\ z_{w}\end{bmatrix} =\left(M^{T}\times M\right)^{-1}M^{T}U \tag{13}\]  
Hereafter, we converted the camera coordinates to the object coordinates; the specific method is as follows:  
Select the calm sea images that match. The sea surface base plane equation is given as:  
\[ax_{w}+by_{w}+z_{w}+c=0 \tag{14}\]  
In the formula, a and b are the normal vectors in the X and Y directions and c is the average distance from the camera to the sea surface base plane. Through the transformation of the coordinate system, the coordinates of the feature points in the camera coordinate system are obtained as:  
\[B= \begin{bmatrix}x_{w1}&y_{w1}&1\\ x_{w2}&y_{w2}&1\\ \cdots&\cdots&\cdots\\ x_{wn}&y_{wn}&1\end{bmatrix}  \tag{15}\]  
\[L= \begin{bmatrix}z_{w1}&z_{w2}&\ldots&z_{wn}\end{bmatrix} ^{T} \tag{16}\]  
The parameters of the sea surface base plane can be calculated using the least squares method as:  
\[\left[a,b,c\right]=\left(B^{T}\times B\right)^{-1}\times B^{T}\times L \tag{17}\]Normalizing the plane normal vector that was obtained from each image results in:  
\[\overset{\rightharpoonup}{n}=\frac{\text{ai}+\text{bj}-\text{k}}{\sqrt{\text{a}^ {2}+\text{b}^{2}+1^{2}}} \tag{18}\]  
In the formula, \(\overset{\rightharpoonup}{n}\) is the normal vector of the sea surface base plane. The spherical coordinate transformation is performed on the normal vector, which is convenient for calculating the changing relationship between the image coordinate system and the object coordinate system. \[\varphi=\arccos(c/\sqrt{\text{a}^{2}+\text{b}^{2}+1^{2}}) \tag{19}\]  
\[\theta=\arctan(\text{b}/\text{a}) \tag{20}\]  
In these formulas, \(\varphi\) and \(\theta\) correspond to the spherical coordinates of the sea surface base plane.