Keywords

1 Introduction

With the rapid development of industry, the use of cylindrical metal parts has become increasingly broad, and the surface quality of cylindrical metal parts is an important index to measure the overall quality of cylindrical metal parts. At the same time, property mutation, fatigue damage and corrosion are often concentrated in this area, which greatly reduces the working performance of cylindrical metal parts in the complex and harsh environment [1]. At present, the vast majority of cylindrical metal parts plants in the industry use the traditional manual visual inspection method or traditional non-destructive testing method in the detection of surface defects [2]. The manual visual inspection method is not only low speed and efficiency, but also difficult to ensure the standard of detection. It is difficult to make an effective judgment for the defects in the critical index, and it is more prone to miss detection and misjudgment. The speed of traditional detection methods and the kinds of defects that can be detected is limited, so it is impossible to evaluate the surface quality of products comprehensively. The above two traditional detection methods can not meet the requirements of height, high precision and high accuracy in the industry. With the development of computer and lens hardware in recent years, machine vision detection technology is growing rapidly. Machine vision system works for a long time, which can ensure the stability of detection and labeling, and is suitable for long-time observation, analysis and recognition tasks.

Using machine vision to detect defects is widely used in various fields, and there are many references in the aspect of algorithm analysis. Zhou F et al. [3] proposed an automatic surface defect detection method based on bilinear model to solve the problems of complex texture and changeable interference factors in metal surface defect detection. Renukalatha S et al. [4] Based on the principle of support vector machine to detect and diagnose glaucoma diseases. Li K et al. [5] proposed a method for detecting the surface defects and size of graphite sealing ring based on machine vision, and achieved good results through the combination of Canny algorithm and template matching. Du-MingTsai et al. [6] proposed a morphological method to detect surface defects with circular tool marks.

For the object with curved and highly reflective surface, the imaging difficulty is greater than that of plane. The imaging effect of incident light on the convex surface is worse, which further increases the difficulty of image algorithm. The existing detection theory based on computer vision can be divided into three categories: laser scanning method [7], area array CCD imaging method [8, 9], and linear array CCD imaging scanning method [10]. Therefore, this paper proposes to use the combination of linear array camera and linear light source to obtain the image. As long as the incident light angle is reasonable and the intensity distribution is uniform, the ideal surface defect image can be obtained, and then it can be recognized.

2 Image Acquisition

2.1 Design of Image Acquisition System

The diameter of the tested seamless steel pipe is 2.5 cm and the length is 30 cm to 40 cm. It is mainly used as the supporting steel pipe in the shock absorption of bicycles. The surface of steel pipe is a curved surface, which is more difficult to image than plane. When the area array light source is used, the arc-shaped outer surface makes the distance between the center of the light source and all parts of the irradiation area too large. At this time, if the area array camera is used directly, there will be too much redundant information, so the steel pipe image needs to use multiple images for splicing. At the same time, the light intensity is inconsistent on the curved steel pipe surface, and the light compensation is also needed for the steel pipe image. It greatly increases the difficulty of image processing and defect location. The combination of linear array camera and linear light source can not only greatly improve the image quality, but also speed up the image acquisition and processing (Fig. 1).

Fig. 1.
figure 1

Steel tube shot by area array camera

The design detection accuracy of steel pipe defect detection is required to be 1 mm. The GigE linear array camera produced by DALSA is selected, and its resolution is \(4096 \times 1\) pixels. When the working distance of camera is 75 cm, the field of view H = 4000 mm. According to the formula, the minimum detection accuracy can be calculated (Fig. 2)

$$\begin{aligned} R\mathrm{{s = }}\frac{H}{N}\mathrm{{ = }}\frac{{4000}}{{4096}}\mathrm{{ = }}0.97\,\mathrm{{mm}} \end{aligned}$$
(1)
Fig. 2.
figure 2

Schematic diagram of detection station

Under the premise of ensuring the field of view width to meet the whole length of steel pipe, the minimum defect size Rs can meet the minimum detection accuracy, so the camera and lens meet the requirements. The encoder uses Omron’s three wire DC encoder, which acquires the image in the mode of hard trigger. When the camera receives the rising edge of the signal from the encoder, it will trigger a shot. The circumference of the steel pipe is about 5 cm, and 1000 images are shot 1000 times in a rotation cycle, that is, one image is shot every 50 \(\upmu \) of the steel pipe, and the image is automatically synthesized and processed by the linear array camera, thus the curved surface of the steel pipe is expanded into a plane image.

2.2 Types and Causes of Defects

According to the national standard GB/T9797-2005, the surface coating of steel pipe shall be bright, and there shall be no spots, pits, speckle, pitting and other defects. Therefore, the surface of seamless steel pipe should be smooth with uniform reflectivity. In the dark field, the smooth plane produces diffuse reflection and makes the image dark, while the defect image shows different light intensity (Fig. 3).

Fig. 3.
figure 3

Pictures of defects (a) Pit (b) Speckle (c) Spalling (d) Pitting

Pits are local depressions distributed on the surface of steel pipe with different areas, which are high brightness dots in the image; The spot is the rust spot formed by corrosive substances such as water during storage or processing. The image shows a round block bright spot, which is less bright than the reflection of pits; Spalling is the continuous surface spalling caused by the scratch of steel pipe, which is shown as a strip-shaped bright stripe on the image; Pockmarks are small pits on the surface, which have many bright spots in an area.

3 Image Processing

The surface defect detection of steel pipe is mainly realized by using complex image processing technology. There are mainly four kinds of defects on the surface of steel pipe, such as spots, pits, spalling and pitting. Firstly, preprocessed is used on the acquired surface image. According to the different characteristics of each defect, Fourier transform, gradient threshold and line detection are used to determine the defect. The algorithm processing is shown in the block diagram (Fig. 4).

3.1 Image Enhancement

In order to make the details of the image more prominent, image enhancement is used to enhance the contrast of the details of the image. Image enhancement algorithms [11] include: image enhancement based on histogram equalization, which is suitable for low contrast images; The image enhancement based on Laplace operator increases the sharpness of the whole image; Image enhancement based on logarithmic transformation is used to emphasize the low gray part of the image; Image enhancement based on gamma transform is mainly used for image correction. From the analysis of the original image, the more appropriate enhancement method is Laplacian. Enhancement Laplacian is a kind of second-order differential linear operator. For two-dimensional image f (x, y), the simplest Laplacian of second-order differential is defined as

$$\begin{aligned} {\nabla ^2}f = \frac{{{\partial ^2}f}}{{\partial {x^2}}} + \frac{{{\partial ^2}f}}{{\partial {y^2}}} \end{aligned}$$
(2)
Fig. 4.
figure 4

Algorithm flow chart

Fig. 5.
figure 5

(a) Before enhancement (b) After enhancement

Combined with the definition of second order differential, we can get the following results (Fig. 5)

$$\begin{aligned} {\nabla ^2}f(x,y) = f(x + 1,y) + f(x - 1,y) + f(x,y + 1),f(x,y - 1) - 4f(x,y) \end{aligned}$$
(3)

3.2 Line Detection Based on Gradient Image

Acquisition of Gradient Image. The gradient value of image is the change rate of gray value. The gradient of image function f (x, y) at point (x, y) is a quantity with size and direction. The gradient of the image in position (x, y) can be expressed as a vector

$$\begin{aligned} \nabla f(x,y) = {[Gx,Gy]^T} = [\frac{{\partial f}}{{\partial x}}\frac{{\partial f}}{{\partial y}}] \end{aligned}$$
(4)

\(Gy = \frac{{\partial f}}{{\partial y}}\) can be called the first derivative in the y-axis direction, and it can be expressed by

$$\begin{aligned} dy(i,j) = I(i,j + 1) - I(i,j) \end{aligned}$$
(5)

The x-axis direction is the same. In the spalling image, the gray value along the x-axis direction changes more consistently, while in the y-axis direction, the gray value has obvious mutation edge. Therefore, the edge information of defects can be obtained by calculating the gradient image along the y-axis direction (Fig. 6).

Fig. 6.
figure 6

Y-axis gradient image

Line Detection. The principle of Hough transform [12] is to transform the pixels in the image space into the lines in the parameter space by using the point line duality. The intersection of the middle lines in the parameter space corresponds to the lines in the image space. The problem of line detection in image space is transformed into the problem of cumulative statistics in parameter space. Hough detection sets a threshold T1 for the accumulation of line length. Only the line greater than T1 is regarded as a line, and the lines with similar distance and smaller angle are combined to avoid detecting the same line as multiple lines with smaller angle. After the above processing, an obvious straight line can be observed in the image. Here, we set a higher threshold to detect the straight line in the processed image. If the straight line is detected, it indicates that there is speckle defect in the image of steel pipe (Fig. 7).

Fig. 7.
figure 7

Results of linear detection

3.3 Image Segmentation Algorithm Based on Edge

The segmentation method based on edge detection tries to solve the segmentation problem by detecting the edges of different regions [13], which is one of the most commonly used methods. In the image, we mainly use the intensity of gray value change of pixels on the edge between regions to make judgment, which is one of the main assumptions of edge detection. First order or second order differential operators are often used for edge detection.

The Soble operator is an edge detection algorithm based on the first derivative, which combines the difference operation with the local average. Each point of the image is convoluted by two templates. Take the maximum value of two convolutions as the output value of the point. Laplacian is a second-order differential operator, which mainly uses the characteristic that the second-order differential of image presents zero value at the edge due to the step of image at the edge. Canny edge detection is also a first-order differential operator detection algorithm, based on which non maximum suppression and double threshold are added. Using non maximum suppression can not only effectively suppress multi response edges, but also improve the positioning accuracy of edges. Using double threshold can effectively reduce the missing rate of edges. From the edge results of the three algorithms in the figure below, Canny edge detection has the best effect (Fig. 8).

Fig. 8.
figure 8

Edge detection image (a) Soble (b) Laplacian (c) Canny

The minimum bounding rectangle is found for canny processed image. For the calculated rectangle, set the threshold of area size, and convert to the actual distance, that is, the area greater than 0.1 cm\(^2\) specified in the national standard is regarded as the defect of spot. At the same time, the threshold value is set for the number of rectangles, that is, the defects with more than 200 defects are regarded as pockmarks (Fig. 9).

Fig. 9.
figure 9

Pitting and speckle

3.4 Frequency Domain Method

For the discrete signal, the frequency value indicates the intensity of signal transformation or the speed of signal change [14]. The higher the frequency, the more dramatic the transformation, the smaller the frequency, the smoother the signal. In the corresponding image, high frequency signal is often edge signal and noise signal in image, while low frequency signal includes image contour and background light signal with frequent image change. Firstly, the time domain information of the image is converted to the frequency domain by Fourier transform. For the two-dimensional discrete Fourier transform, the definition is

$$\begin{aligned} \begin{array}{c} X(k,l) = \mathop \sum \limits _{m = 0}^{M - 1} \mathop \sum \limits _{n = 0}^{N - 1} x(n,m){e^{ - j\frac{{2\pi }}{N}kn}}{e^{ - j\frac{{2\pi }}{M}lm}} = \mathop \sum \limits _{m = 0}^{M - 1} \mathop \sum \limits _{n = 0}^{N - 1} x(n,m)w_N^{kn}w_M^{lm}\\ {w_N} = {e^{ - j\frac{{2\pi }}{N}}},{w_M} = {e^{ - j\frac{{2\pi }}{M}}} \end{array} \end{aligned}$$
(6)
Fig. 10.
figure 10

(a) Original image (b) After fourier transform (c) High frequency filter (d) Inverse Fourier transform

The main feature of pits is the highlight area in the image. The image is analyzed in frequency domain. High frequency information is filtered out by using high frequency filter, that is, the position of pits in the image. Then the inverse Fourier transform is used to change the image back to the time domain. At this time, the part left after high-frequency filtering is the image information of pits. At this time, whether there are pits or not is transformed into the problem of whether there is residual image information in the inverse transformed image. The existence of defects can be determined by traversing the image (Fig. 10).

4 Experiment and Analysis

In order to meet the requirements of docking production line to achieve a high degree of automation, the test equipment consists of four stations: lifting and drying position, feeding position, detection position and classification position. Because the oil and dust on the surface of the steel pipe will have a great impact on the image quality of the steel pipe, the rod less cylinder is used to drive the air knife to blow the surface of the steel pipe first. The feeding part uses the cylinder claw to grab the steel pipe from the jacking position to the detection station. In the detection station, the steel pipe is clamped and fixed by the bidirectional ball screw and the thimble at both ends, and a pressure sensor is installed at the forward motor of the screw to control the clamping degree, so as to prevent the scratch of the steel pipe head due to excessive clamping. The classification position is automatically classified according to the results given by the detection algorithm (Fig. 11).

Fig. 11.
figure 11

General view and camera station map

Table 1. Test results of different defects

Take 100 seamless steel pipe samples, of which 20 are defect free, 20 are pit defects, 20 are pitting defects, 20 are spot defects, 20 are spalling defects. The test is divided into two times. The first time, each defect type is tested separately to test the recognition accuracy of the algorithm. The second time, all 100 steel pipes are disturbed to test the stability of the algorithm (Table 1).

Table 2. Multiple test results

According to the above table, the detection efficiency and recognition accuracy are relatively high, the average detection time is about 1.5 s, and the repeated detection effect is stable, which basically meets the requirements of surface detection. For the most obvious spalling feature, the algorithm has the highest recognition accuracy. The misjudgment rate and missed detection rate of pitting are both high, because pitting is easy to be judged as pits or speckle when the corrosion area or depth is large, which leads to high misjudgment rate. In the continuous test, the main reason for the fluctuation of the pass rate is the accidental collision and surface fingerprints when taking the steel pipe, which indicates that the cleanliness of the surface inspection of the steel pipe to be inspected has a certain impact on the accuracy of the judgment of the steel pipe, and also reflects that the surface of the steel pipe will inevitably have defects in the production process (Table 2).

5 Summary

In this paper, the machine vision method is used to detect the defects on the surface of steel pipe. The seamless steel pipe used for shock absorber is taken as the research object. Combined with the bending high reflection surface of steel pipe, the traditional area array camera image acquisition will cause uneven illumination and information redundancy. An experimental platform composed of linear array camera, linear light source, encoder and rotation system is built to obtain the image of steel pipe. According to the different characteristics of four kinds of defects of steel pipe: pit, pitting, spot and spalling, a defect detection algorithm combining frequency domain transformation, gradient threshold and line detection is proposed and tested. The test results show that the average detection time of the algorithm is about 1.5 s and the average recognition rate is 93\(\%\). It can effectively distinguish four kinds of defects and avoid the disadvantages of traditional manual visual inspection.