# Visual Detection of Surface Defects Based on Self-Feature Comparison in Robot 3-D Printing
## 3 Evaluation of Contour Similarity Based on Empirical Formula  
This paper introduces the experiment by using the model shown in Figure 6a, and divides the collected pictures into three parts according to the acquisition time. Some pictures are selected from each part arbitrarily as representatives to reflect the online detection results in the experiment process. Figure 6b-d are the experimental and theoretical results of randomly selected vertical acquisition nodes (a certain height layer) in the experiment, while \(\theta_{1}\)\(\theta_{2}\)\(\theta_{3}\) is the image from different angles in the printing process under the current height layer. At any time, theoretical pictures can be obtained from the collected signals, and the experimental pictures and theoretical pictures can be judged by comparison. The following picture shows the whole experimental and theoretical images of the model when printing is completed. As shown in Figure 7, the red-filled part is represented as contour, and the yellow border is the outer rectangle of contour. In this study, these contours are mainly presented by central coordinates, aspect ratio, and area. The parameters of Figure 7 are shown in the Tables 1 and 2. Figure 6: Some on-line test pictures during the experiment: (**a**) Theoretical model; (**b–d**) Experimental and theoretical results of randomly selected vertical acquisition nodes. \(\theta_{1}\)\(\theta_{2}\)\(\theta_{3}\) is the image from different angles in the printing process under the current height layer. Based on the above parameters, an evaluation function is proposed to evaluate the contours similarity in this paper. \[\text{SOCP}=\beta_{n}(\alpha_{1}*\frac{l-\sqrt{\left(x_{m}-x_{n}\right)^{2}+\left( y_{m}-y_{n}\right)^{2}}}{l}+\alpha_{2}*\left(\frac{r_{m}}{r_{n}}\right)^{-\frac{r_{m}-r_{n}}{ p_{m}-r_{n}}}+\alpha_{3}*\left(\frac{A_{m}}{A_{n}}\right)^{-\frac{A_{m}-A_{n}}{ \left(A_{m}-A_{n}\right)}} \tag{1}\]  
where SOCP means the similarity of contours parameters; \(\left(x\ y\right)\) are the center coordinates that represent the position of contour; \(r\) is aspect ratio of width to height that shows the shape of contour; \(A\) is the pixel statistical value that means the area of contour; m represents contour number in the picture captured from the platform; n represents the contour number in the picture projected from the theoretical model; 1 is the error threshold for contour location; \(\left(\alpha_{1}\ \alpha_{2}\ \alpha_{3}\right)\) are the weight coefficients of contour parameters; \(\beta_{n}\) is the weight coefficients of theoretical contours. \(x\) and \(y\) are the central coordinates of the contour location, r represents the aspect ratio of the shape of the contour, m real represents the contour number \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**Rectangle/Contour**} & **Center** & & & **Aspect Ratio** & **Contour Area (Statistical** \\  & **Coordinates** & & & **Width to** & **Value of the Interior Red** \\  & & & & **Height** & **Pixels)** \\ \hline No. 1 & (543, 189) & 253 & 139 & 1.820 & 23,496 \\ No. 2 & (1084, 190) & 252 & 127 & 1.984 & 22,374 \\ No. 3 & (814, 604) & 512 & 251 & 2.040 & 41,760 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Parameters of contours in Figure 7a (unit/pixel). \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**Rectangle/Contour**} & **Center** & & & **Aspect Ratio** & **Contour Area (Statistical** \\  & **Coordinates** & & & **Width to** & **Value of the Interior Red** \\  & & & & **Height** & **Pixels)** \\ \hline No. 1 & (514, 180) & 247 & 135 & 1.830 & 24,109 \\ No. 2 & (1067, 189) & 249 & 143 & 1.741 & 23,177 \\ No. 3 & (786, 619) & 522 & 266 & 1.962 & 39,168 \\ No. 4 & (758, 404) & 302 & 139 & 2.173 & 25,243 \\ No. 5 & (1162, 559) & 106 & 147 & 0.721 & 10,068 \\ No. 6 & (798, 882) & 221 & 105 & 2.105 & 15,249 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Parameters of contours in Figure 7b (unit/pixel).