## 3 The key Technology of the Multi-DOF Automatic Image Acquisition System
### The Calculation of Camera Position
#### 3.1.2 Camera Position Calculating Method by Data Fitting  
The relationship between each axis needs to be determined by data fitting. The reasons are as follows: On the one hand, the mathematical modeling method is usually assumed to be carried out under ideal conditions. However, there will be camera installation errors in the actual measurement  
\begin{table}
\begin{tabular}{c c c c c c} \hline
**ID** & \(\Delta x\) **(mm)** & \(\Delta y\) **(mm)** & \(\Delta z\) **(mm)** & \(\alpha\) **(\({}^{\circ}\))** & \(\beta\) **(\({}^{\circ}\))** \\ \hline  
271 & \(-\)67.044 & \(-\)12.58 & 35.41 & \(-\)22.86 \\
20 & 77.552 & \(-\)75.036 & \(-\)25.16 & 26.8125 & \(-\)24.83 \\ \hline \end{tabular} \(z_{0}=\) 62.9 mm when the camera is in focus.  
\end{table}
Table 1: Acquisition points of each axis.  
Figure 6: Error before and after correction: (**a**) error before and after correction of \(\Delta z\); (**b**) error before and after correction of \(\alpha\); (**c**) error before and after correction of \(\beta\).  
process. On the other hand, there is also the error caused by the rotation axes when calculating the camera rotation angle through a simple geometric relationship. The specific process is as follows: Controlling the \(x\)-, \(y\)-, and \(z\)-axes to move \(\Delta x\), \(\Delta y\), and \(\Delta z\), then control the rotation axes \(a\) and \(b\) to rotate the corresponding \(\alpha\) and \(\beta\) angles respectively to ensure that the camera optical axis points (the record the values of \(\Delta x\), \(\Delta y\), \(\Delta z\), \(\alpha\), \(\beta\)); Repeating the above steps and recording the values of multiple groups of \(\Delta x\), \(\Delta y\), \(\Delta z\), \(\alpha\), \(\beta\). Finally, fitting the corresponding relationship between each axis. The experimental acquisition points are shown in Table 1. The polynomial fitting of degrees 1, 2, 3, and 4 were performed, and the fitting error is shown in Table 2.  
It can be seen from Table 2 that the error decreased with the increase of fitting times. When the fitting degrees were 4, the errors of \(\Delta z\), \(\alpha\), and \(\beta\) reached the minimum, but the errors were only slightly less than the errors of degrees 3. Considering the computational complexity and overfitting phenomenon, the fitting degrees were finally selected as 3. Finally, the relationship between the axes was obtained by data fitting as shown in Equation (3).  
\[\left\{\begin{array}{l}\alpha=8.127\times 10^{-8}\times\Delta x^{3}-3.562 \times 10^{-8}\times\Delta y^{3}-4.424\times 10^{-7}\times\Delta x^{2}-2.074 \times 10^{-6}\times\Delta y^{2}+1.864\times 10^{-8}\times\Delta x^{2}\times \Delta y+9.825\times 10^{-8}\times\\ \Delta x\times\Delta y^{2}-2.286\times 10^{-6}\times\Delta x\times\Delta y+0.0051 \times\Delta x+0.0001905\times\Delta y+0.001021\\ \beta=-6.336\times 10^{-9}\times\Delta x^{3}+2.108\times 10^{-8}\times\Delta y^{3}-4.2 18\times 10^{-7}\times\Delta x^{2}-6.109\times 10^{-10}\times\Delta y^{2}+3. 101\times 10^{-8}\times\Delta x^{2}\times\Delta y-8.65\times 10^{-10}\\ \times\Delta x\times\Delta y^{2}-5.084\times 10^{-5}\times\Delta x\times\Delta y-2.63 1\times 10^{-5}\times\Delta x+0.005444\times\Delta y+0.002839\\ \Delta z=-2.708\times 10^{-7}\times\Delta x^{3}+1.319\times 10^{-5}\times\Delta y^{ 2}+0.004024\times\Delta x^{2}+0.003225\times\Delta y^{2}-5.464\times 10^{-6} \times\Delta x^{2}\times\Delta y-2.844\times 10^{-6}\times\Delta x\\ \times\Delta y^{2}+0.0002364\times\Delta x\times\Delta y-0.004346\times\Delta x -0.1057\times\Delta y-69.67\end{array}\right. \tag{3}\]