# Visual Detection of Surface Defects Based on Self-Feature Comparison in Robot 3-D Printing
## 2 Methodology  
### The Whole Process of Identifying Defects and Their Own Characteristics  
In this research, the hardware platform is shown in Figure 1 and the program is implemented with C++ and Open CV, during which the CCD camera is consolidated with the nozzle and always kept perpendicular to the outer surface during the printing process. The main software used in the development of the image detection system is Visual Studio 2015. The robot 3-D printer in research is based on the Japanese Mitsubishi RV-6 SD 6-DOF robot as the basic experimental platform, combined with the German Basler acA1600-20 gm camera and computer.  
The algorithm for visual detection of surface defects based on self-feature comparison is shown in Figure 2. First, the program slices the 3-D printing model into a discrete point cloud layer by layer, which is the common source of self-feature and machining path in 3-D printing, but their subsequent processes differ from each other.  
For the 3-D printing, the processing steps are as follows (as shown in Figure 2I).  
1. Generate the machining path and send G-code to robot;
2. The robot receives instructions and starts printing. Then, at a certain interval, the host computer transmits the current coordinates to the theoretical model while sending acquisition instructions to the camera.
3. The picture captured will be preprocessed by histogram equalization, Local Binary Patter (LBP), median filtering to be identified and processed easily by the computer.  
And for the self-feature extraction, the steps can be shown below (as shown in Figure 2 II).  
1. The printed part will be preserved according to the current coordinates, and the unprinted part will be ignored.
2. According to the current camera direction, the visual point clouds are selected.
3. Under established rules, feature points are extracted and theoretical contours are reconstructed.  
Figure 1: Hardware system structures of robot Fused deposition modeling (FDM) system.  
By calibrating the experimental platform, the mapping relationship between part and picture captured is obtained. Then the program projects the feature contours extracted above to the picture under the equal mapping condition.  
Then the contours from both the picture projected and the picture captured will be detected by the image processing technology, which is the contour detection technology based on the laminate structure characteristics of FDM [7]. At last, the defects and their own characteristics are identified by comparing the parameters of the contours in the picture captured from the platform and the picture projected from the theoretical model. When the similarity of parameters between the former contour and one of the latter contours reaches a threshold, it means the contour is its own feature, not the defect, and vice versa. For parts, the processing process in this system is shown in Figure 3.  
Figure 2: The flowchart of the visual detection algorithm of surface defects based on self-feature comparison in 3-D printing: I 3D printing processing steps; II Contour detection; III Identify defects and own characteristics.