# Non-Contact Tilapia Mass Estimation Method Based on Underwater Binocular Vision
## 2 Materials and Methods
### Image Processing and Analysis
#### 2.3.1 Camera Calibration  
The refraction of light when shooting in underwater environments can lead to image distortion. To ensure the accuracy of the results, the binocular camera requires binocular calibration and distortion correction underwater [14]. The [PERSON]'s method [15,16] was used, and a 12 \(\times\) 9 square grid aluminum substrate was selected for the calibration plate. The size of each square was 30 mm \(\times\) 30 mm.  
Keeping the position of the camera unchanged, the position of the calibration plate was constantly changed, and several groups of images with different angles and positions were captured. The relative position of the binocular camera to the calibration board is shown in Figure 3. Forty of these images were selected and programmed to be split into separate left and right viewpoint maps and stored in separate folders. The left and right viewpoint maps were automatically calibrated using tools in Matlab2017b. The corner point detection results of the calibration board are shown in Figure 4. The optical aberrations produced by the images can be corrected using Equations (2)-(4).  
\[\left\{\begin{array}{l}X_{1}=x(1+k_{1}t^{2}+k_{2}t^{4}+k_{3}t^{6})\\ Y_{1}=y(1+k_{1}t^{2}+k_{2}t^{4}+k_{3}t^{6})\end{array}\right. \tag{2}\]  
\[\left\{\begin{array}{l}X_{2}=x+[2p_{1}xy+p_{2}(t^{2}+2x^{2})]\\ Y_{2}=y+[2p_{2}xy+p_{1}(t^{2}+2y^{2})]\end{array}\right. \tag{3}\]  
\[t=\sqrt{\left(\frac{x}{f_{x}}\right)^{2}+\left(\frac{y}{f_{y}}\right)^{2}} \tag{4}\]  
where (_x,y_) are the coordinates of the original image. \(X_{1}\), \(X_{2}\), \(Y_{1}\), and \(Y_{2}\) are the coordinates of the corrected image. \(f_{x}\) and \(f_{y}\) are the focal lengths in each direction. \(k_{1}\) and \(k_{2}\) are correction coefficients for radial distortion, and \(p_{1}\) and \(p_{2}\) are correction coefficients for tangential distortion. \(t\) is the distance from the image pixel point to the center of the image.  
Figure 2: Flowchart for mass estimation of tilapia based on underwater binocular vision.  
The histogram of the reprojection error of the Matlab2017b first calibration results is shown in Figure 5a. The maximum error in the first calibration reached 0.15, and it can be seen that several images had a large impact on the error. In order to further improve the subsequent estimation accuracy, we removed some image groups with large errors. The histograms of the reprojection errors after removal are shown in Figure 5b, and the errors were all below 0.1.  
The calculated camera parameters are shown in Table 1. It can be seen that the rotation matrix R approximates the unit matrix. The first parameter of the translation vector T represents the distance between the centers of the two cameras. The default parameter for the binocular camera baseline was 60 mm, which is within the tolerance of the error.  
Figure 4: Calibration board corner point detection.  
Figure 5: Comparison of reprojection error before and after processing: (**a**) histogram of reprojection error for first calibration; (**b**) histogram of reprojection error after removal of large errors.  
Figure 3: Relative position of binocular camera to calibration board.