# Automated Optical Inspection System for O-Ring Based on Photometric Stereo and Machine Vision
## 1 Introduction  
Recently, the automated optical inspection (AOI) system has taken the place of human inspection in highly automated manufacturing requirements. Human inspection is subjective since human inspection stability depends on operator experience and physical condition, among other factors. However, there are many reasons that make human inspection irreplaceable. For example, we cannot use a fixed light source to obtain a defect image unless we employ a light source at a particular relative direction to catch defect features on the O-Ring's surface. A such, the AOI system has experiences many oderals in various conditions. It is difficult to exploit the traditional image process of dealing with images from cameras captured from different light sources. Therefore, it is difficult to fix a threshold for traditional image processing. To address this problem, we studied other research that inspected rubber material. [PERSON] et al. [1] used 7 \(\times\) 7 kernels to find the gradient direction and convert the edge of this area to a cubic spline to measure the O-Ring dimension and to remove noise. Simultaneously, this study used the KFDA (kernel fisher discriminant analysis) to detect the O-Ring defect. [PERSON] et al. [2] used two inspection stations to inspect components made of rubber and metal. The first inspection station provided a camera and light source to inspect defects on the top of the component. The second inspection station provided a camera and a special telecentric lens used to inspect defects on each side of the component. The O-Ring dimension measurement was inspired by [3; 4; 5; 6]. Works proposed by [3; 4] employed an image processing method to calculate the dimension. Those papers provided a good idea to approximate contours and calculate the length of edge information. In [5],[PERSON] et al. approximated circular sections by cubic Bezier. Moreover, [PERSON] [6] proposed a method for using the cubic Bezier curve [7] combined with a fourth-order Bezier curve. [PERSON] [8] proposed a method for calculating the circular arc control point location using the Bezier curve. The approach proposed in this work is a two-stage solution in which the problem was converted from defect inspection and dimension measurement sites to a single station. The first stage was concerned with defects on the O-Ring's surface, while the second stage measured the O-Ring dimension. After repeated attempts, we find a 2.5-D defect detection system that can solve the problem we faced easier than the 2-D one. On the other hand, only a few people used defect detection by creating a 2.5D defect-free model. The defect detection method we proposed can detect any object with some trackable path. Then, the algorithm will create a defect-free model. Just only by subtracting two models can be found the approximate location of a defect easily. Furthermore, the photometric stereo method gives further potential for remote monitoring [9] and machine positioning and quality checks [10]. In this paper, we propose a simple O-Ring defect detection system and dimension measurement. The proposed system is described in Section 2, and the proposed experiment flow charts are shown in Figure 1. This paper divide into two-part. One is the defect detection part, We implemented photometric stereo to reconstruct the model with sample surface (e.g., defect-free surface Figure 2a), flow marks (Figure 2b), non-fills (Figure 2c) according to ISO 3601-3:2005 [11]) and compared to optical profilometer (VR-3100, Keyence Co., Osaka, Japan) reconstruct result. Then, develop a defect detection processing and compared result. Second, we compared the algorithm we proposed to raw contours data and Douglas-Peucker algorithm. At first, we calibrate the camera and calculate the homograpy matrix with the camera parameter. Then calculate edge information with different algorithms. Finally, we compare those results with known sample dimension to calculate absolute error. The O-Rings database we collected and evaluated in Section 3.