## 3 Research on Image Acquisition System of Lining Cracks
### The Method of Fast Acquisition Parameter Calculation
#### 3.2.2 Camera Focus  
For application scenarios and stability considerations, standard industrial cameras do not have the automatic focusing capability of digital cameras, so the focusing parameters need to be calculated separately. This can be obtained from the imaging formula of the convex lens in Equation (7). When the focal length and the object distance are determined, the image distance (the distance between the camera sensor and the optical center) can be calculated. The image captured by the camera is clearest when the camera sensor is in the image plane at the distance \(v\) from the optical center of the lens. \[\frac{1}{u}+\frac{1}{v}=\frac{1}{f} \tag{7}\]  
where \(f\) is the focal length, \(u\) is the object distance, and \(v\) is the image distance. Therefore, it is planned to establish the mapping relationship between the focus and the object distance \(u\) and the focal length \(f\) when shooting the clearest image from imaging experiments. However, the focal length is adjusted by the zoom in the imaging system. This experiment will fit the focus of the clear image to the object distance \(u\) and the zoom. After determining the zoom and the object distance \(u\), the image captured by the camera is observed while fine-tuning the focal length, and when the clearest image appears, the focal length is recorded at this time. Then, the above operations are repeated after adjusting the object distance \(u\) and the corresponding zoom. To ensure the applicability of the fitted data, the zoom will be fine-tuned at different object distances to establish the binary correspondence between the focus and the zoom, the object distance \(u\). The recorded data perform binary fitting to establish the functional relationship between focus, object distance \(u\), and focal length zoom when the clear image is formed. The test process is as follows:  
1. Object distance calculation: According to Section 3.1.3, the common working distance of the camera is 2.0-7.0 m.
2. Determination of focal length zoom: Round the calculated working distance of the camera to an integer and calculate the corresponding zoom of the focal length. Furthermore, adjust it respectively after rounding to expand the scope of application. There are 18 sets of data in total, as listed in Table 1.
3. According to the determined parameters, conduct an experiment to determine the focus corresponding to the clear image under each group of object distances and focal lengths. 4. Take the focus corresponding to the clear image as the dependent variable, the object distance \(u\), and the focal length zoom as the independent variables, and perform binary fitting to establish the corresponding functional relationship. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Object Distance/m** & **2** & **3** & **4** & **5** & **6** & **7** \\ \hline \multirow{4}{*}{Zoom} & 5 & 5 & 20 & 30 & 30 & 40 \\  & 10 & 10 & 30 & 40 & 40 & 50 \\ \cline{1-1}  & 20 & 20 & 40 & 50 & 50 & 60 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The object distance and zoom used in the test. By adjusting the focus under the object distance and zoom of each group, when the edge of the crack is the sharpest in the image of the calibration plate, record the focus when the image of the camera is clear, as shown in Table 2.  
Using the method of curve fitting, taking the object distance and zoom as independent variables \(X\) and \(Y\), respectively, and the focus of the determined clear image as the dependent variable \(Z\), binary fitting is performed. By comparing the mean square error, correlation coefficient, and smoothness of the fitting equations of different degrees, the binary cubic fitting equation shown in Equation (8) is finally selected, and its fitting surface is shown in Figure 5.  
\[ \begin{array}{ll}Z=f(X,Y)&=88.68-19.51X-0.6809Y-0.7189X^{2}\\ &+0.5552 XY-0.002504Y^{2}+0.3514X^{3}\\ &-0.06936X^{2}Y+0.001301 XY^{2}+0.0001025Y^{3}\end{array}