A method for detecting quality of a tube flat grinding based on machine vision
The machine vision-based method for detecting the quality of oil pipe surface grinding solves the problems of low efficiency and difficulty in multi-classification in traditional detection technologies, realizes automated detection, and improves detection efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-12
- Publication Date
- 2026-03-24
AI Technical Summary
In existing technologies, the quality inspection of automotive oil pipes by surface grinding suffers from low efficiency, susceptibility to subjective factors, and high cost. Traditional non-destructive testing technologies cannot achieve multi-classification.
A machine vision-based method for inspecting the quality of oil pipe surface grinding is adopted, which includes image acquisition, white edge removal, distortion detection, preprocessing, geometric feature extraction, and parameter optimization based on SVM classifier to achieve automated inspection.
It has automated the quality inspection of oil pipe flat grinding, improved the inspection efficiency and accuracy, and has good rotational and dimensional invariance, avoiding errors caused by human parameter settings.
Smart Images

Figure CN115456949B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of machine vision, and particularly relates to a defect detection and classification method for an oil pipe flat grinding end face image, which can be used for detecting the flat grinding quality of an automobile oil pipe, so as to realize sorting and reprocessing of the oil pipe. BACKGROUND
[0002] The oil pipe of an automobile engine, as a hub connecting an oil tank and an engine, is crucial in terms of the quality of the flat grinding end face. At present, the flat grinding quality of the oil pipe is mainly detected by manual visual inspection, but manual visual inspection has problems such as low efficiency, slow speed, being easily affected by subjective factors, limited working time, etc. Therefore, it is of great practical significance to realize automatic detection of the flat grinding quality of the oil pipe.
[0003] The key to the flat grinding quality detection of the oil pipe lies in the detection and classification of the end face defects. Traditional non-destructive surface defect detection technologies such as magnetic flux leakage technology, eddy current detection technology, infrared detection technology, ultrasonic flaw detection technology, etc. can only detect a single target type, and the detection equipment is costly and cannot classify defects. However, the machine vision detection method can avoid the shortcomings of traditional non-destructive surface defect detection technologies while ensuring high detection efficiency and accuracy.
[0004] After continuous research by scholars at home and abroad, there are currently many surface defect detection algorithms based on traditional image processing methods. In the aspect of filter denoising, Jong-Sen Lee proposed an image contrast enhancement and noise filtering method based on local statistics. The prior mean and variance of each pixel are derived from the local mean and variance, and then the minimum mean square error estimator is used to filter additive noise, and the statistical optimal linear approximation is performed for multiplicative noise, which is extremely suitable for real-time image processing. In the aspect of image enhancement, Schettini and Raimondo proposed a contrast enhancement algorithm based on local and overall brightness of the image, which can correct images containing both overexposed and underexposed regions. Liu Jie et al. proposed an image enhancement algorithm based on multi-guide image filtering, designed a general image optimization model, expanded a single guide image to multiple images, smoothed the multiple output images, and added a regularization term to the image optimization model to improve the existing image enhancement algorithm output image boundary smoothing problem. In the aspect of threshold segmentation, the OTSU algorithm paper published by Japanese scholars in 1979 has been cited more than 20,000 times, and many improved algorithms have been derived based on it. Chen Kai of Central South University studied the surface defect segmentation algorithm of integrated circuit chips, combined OTSU, two-dimensional entropy and firefly algorithm, proposed three multi-threshold segmentation algorithms, and verified through experimental analysis that the OTSU multi-threshold segmentation algorithm combined with the improved firefly algorithm is overall better than the other two algorithms in terms of time, accuracy and stability. In the aspect of contour extraction, Liu Yu of South China University of Technology combined shape context features and iterative closest point algorithm, proposed a high-precision workpiece contour size detection algorithm, which can extract and filter the noise of the workpiece contour, and the experimental verification can achieve a detection accuracy of 0.5 pixels. Minh N. Do et al. proposed contourlet transform to overcome the limitations of one-dimensional wavelet transform in describing the geometric shape of image edges. This multi-scale transform can well describe the direction information and contour of the object, making up for the directional limitation of the two-dimensional separable wavelet basis formed by one-dimensional wavelet.
[0005] In view of the limitations of manual inspection and the shortcomings of traditional non-destructive surface defect detection technology, the present application provides a complete oil pipe flat grinding quality detection method based on the above surface defect detection algorithm in combination with the actual application scene of automobile oil pipe. SUMMARY
[0006] An aspect of the present disclosure aims to provide an oil pipe flat grinding quality detection method based on machine vision to solve the problems of manual inspection and realize automatic oil pipe flat grinding quality detection.
[0007] The technical scheme of the present application is an oil pipe flat grinding quality detection method based on machine vision, comprising the following steps:
[0008] Step 1, collect the oil pipe flat grinding end surface sample image, intercept the ROI centered on the oil pipe to reduce redundant information and improve operation efficiency;
[0009] Step 2, remove the white edge operation based on the region growing idea for the ROI intercepted image to eliminate large-scale noise occurring in the collection process, and expand the sample through rotation, flipping and scale transformation operation to form a sample set for quality detection;
[0010] Step 3, read the image in the sample set, use the horizontal gradient value of Sobel operator to perform distortion detection to screen out distorted samples;
[0011] Step 4, pre-process the undistorted sample image, including four operations of filter denoising, image enhancement, threshold segmentation and morphological processing, to further improve the image quality and facilitate the extraction of effective features;
[0012] Step 5, after pre-processing, extract the geometric features of the oil pipe sample from the image to form a feature vector group and perform normalization processing;
[0013] Step 6, train the SVM classifier according to the normalized feature vector group and perform five-dimensional joint parameter optimization based on grid search to obtain the optimal parameters and improve the classification accuracy;
[0014] Step 7, use the trained SVM classification model to classify the samples to realize the detection of oil pipe flat grinding quality.
[0015] Further, the specific implementation of the white edge removal operation in step 2 includes the following steps:
[0016] Step 2a, set the ROI intercepted sample image as the input image, and the row and column numbers of the output image are both the row and column numbers of the input image minus 2;
[0017] Step 2b, starting from the 2nd row of the input image, traverse the image pixel points from left to right, i.e. from the 2nd column to the last 2nd column, calculate the average gray value of the 3x3 neighborhood pixel points centered on the current coordinate pixel point and its right pixel point, denoted as avg0 and avg1;
[0018] Step 2c, set the gray value of the current coordinate pixel point in the output image to 0;
[0019] Step 2d, judge whether the amplitude of the difference between avg0 and avg1 is less than the set threshold T, if less than T, return to step 2b and continue to traverse the current row, otherwise copy the gray values of the remaining pixel points in the current row of the input image to the corresponding coordinates in the output image, and then directly enter the traversal of the next row;
[0020] Step 2e, repeat step 2a~step 2d until the second last row is traversed, and the traversal ends;
[0021] Step 2f, change the left-to-right traversal to right-to-left traversal, change avg0 and avg1 to the average of the gray values of the pixels in the 3x3 neighborhood centered on the current coordinate pixel and its left pixel, and take the image at the end of the first traversal as the input image, repeat step 2a~step 2e, and remove the white border operation.
[0022] Further, the convolution kernel for calculating the Sobel operator horizontal gradient value in step 3 is:
[0023]
[0024] Further, the specific implementation of step 4 includes the following steps:
[0025] Step 4a, further filter the sample image using a Gaussian filter, and the parameters of the filter are determined by the five-dimensional joint parameter optimization based on grid search in step 6;
[0026] Step 4b, perform sharpening operation on the sample image to enhance the edge information of the image, and the convolution kernel used for sharpening operation is:
[0027]
[0028] Step 4c, perform threshold segmentation on the enhanced sample image to realize the binarization of the image, set the threshold thres, and divide the image into black background part and white oil pipe part;
[0029] Step 4d, use morphological processing to remove white noise and black holes in the binarized image, including erosion operation and dilation operation.
[0030] Further, the geometric features of the oil pipe sample in step 5 include the area ratio and length ratio of the inner and outer ring profiles of the oil pipe, and the calculation formula of the area ratio and length ratio is:
[0031]
[0032]
[0033] where a is the area ratio of the profile, A c is the profile area, A img is the sample image area, l is the length ratio of the profile, L c is the profile perimeter, R img is the radius of the sample image, and the half of the side length is taken as the radius. The above area and length are measured in terms of pixel number.
[0034] Further, the normalization processing in step 5 adopts a Z-score normalization method, and the normalization formula is as follows:
[0035]
[0036]
[0037]
[0038] wherein x i is the i-th feature data extracted from the sample x, n is the total number of features extracted from the sample x, μ is the mean of the n feature data, and δ is the standard deviation of the n feature data.
[0039] Further, the specific implementation of the five-dimensional joint parameter optimization based on the grid search in step 6 includes the following steps:
[0040] Step 6a, the object of the five-dimensional joint parameter optimization based on the grid search includes the Gaussian filtering parameter group Gau, the parameters C and Gamma when training the SVM classifier, and the logarithmic step logStep and the sample division number k of k-fold cross validation used when optimizing the parameters C and Gamma;
[0041] Step 6b, determine the value range of Gau, C, Gamma, logStep and k, and construct a five-dimensional joint parameter grid;
[0042] Step 6c, calculate the average prediction accuracy corresponding to each group of parameters in the grid, constantly update the highest average accuracy, and record the parameter group corresponding to the highest average accuracy, until the iteration is completed, and output the optimal parameter group.
[0043] Compared with the prior art, the advantages and beneficial effects of the present application are:
[0044] 1. The present application solves the limitations of manual inspection, liberates workers, reduces costs, realizes the automation of oil pipe flat grinding quality detection, greatly improves the detection efficiency, and has a high detection accuracy.
[0045] 2. The geometric feature group used for the oil pipe sample in the present application utilizes the relative information of geometric features, rather than absolute information, and therefore has good rotation invariance and scale invariance.
[0046] 3. The present application implements five-dimensional joint parameter optimization based on the grid search in the process of training the classifier, avoiding the situation that the optimal accuracy is not reached due to the manual setting of parameters according to experience. BRIEF DESCRIPTION OF DRAWINGS
[0047] Figure 1It is a tubing flat grinding quality detection method flow chart according to an embodiment of the application.
[0048] Figure 2 It is an effect comparison chart of the white edge removal operation of the qualified sample, the defective sample and the truncated sample of the application; in the chart, (a) is the qualified sample before white edge removal, (b) is the defective sample before white edge removal, (c) is the truncated sample before white edge removal, (d) is the qualified sample after white edge removal, (e) is the defective sample after white edge removal, and (f) is the truncated sample after white edge removal.
[0049] Figure 3 It is a flow chart of the left-to-right traversal of the white edge removal algorithm based on the region growing idea of the application.
[0050] Figure 4 It is four types of sample images of the sample set for quality detection of the application; in the chart, (a) is a qualified sample, (b) is a defective sample, (c) is a truncated sample, and (d) is a distorted sample.
[0051] Figure 5 It is an effect chart and contour extraction effect chart of the sample image after pre-processing of the application; in the chart, (a) is a qualified sample pre-processing effect chart, (b) is a defective sample pre-processing effect chart, (c) is a truncated sample pre-processing effect chart, (d) is a qualified sample contour extraction effect chart, (e) is a defective sample contour extraction effect chart, and (f) is a truncated sample contour extraction effect chart.
[0052] Figure 6 It is a flow chart of the five-dimensional joint parameter optimization algorithm based on grid search of the application. DETAILED DESCRIPTION
[0053] The application will be further described in detail below in combination with the drawings and specific embodiments.
[0054] In order to solve the problems existing in manual inspection, improve the detection efficiency and accuracy, the application provides a tubing flat grinding quality detection method based on machine vision, which detects and classifies the defect of the tubing flat grinding end surface sample image, and realizes the automation of the tubing flat grinding quality detection.
[0055] Specifically comprising the following steps: collecting oil pipe flat grinding end face sample image, intercepting ROI centered on the oil pipe to reduce redundant information and improve operation efficiency; removing white edge operation based on the region growing idea is performed on the image after intercepting ROI to eliminate large-scale noise occurring in the collection process, and the sample is expanded through rotation, flipping and scale transformation operation to form a sample set for quality detection; reading the image in the sample set, using the horizontal gradient value of Sobel operator to perform distortion detection to screen out distorted samples; pre-processing the undistorted sample image, including four operations of filter denoising, image enhancement, threshold segmentation and morphological processing, to further improve the image quality and facilitate the extraction of effective features; after the pre-processing is completed, the geometric features of the oil pipe sample are extracted from the image to form a feature vector group, and normalization processing is performed; the SVM classifier is trained according to the normalized feature vector group, and five-dimensional joint parameter optimization based on grid search is performed to obtain the optimal parameters and improve the classification accuracy; the trained SVM classification model is used for sample classification, so that the oil pipe flat grinding quality detection is realized.
[0056] The specific implementation method and operation process of the application include the following 7 steps:
[0057] Step 1, collect oil pipe flat grinding end face sample image using industrial camera from oil pipe flat grinding assembly line, and intercept ROI centered on the oil pipe. The object of image collection is the automobile engine oil pipe with an end face diameter of 4.6mm, and the collected sample image is 2448*2048 8-bit grayscale image, including qualified sample, defect sample and distorted sample. The original sample image is intercepted to obtain a square region with a side length range of 440-460 centered on the oil pipe part as ROI.
[0058] Step 2, due to the complex workshop environment of sample image collection, after the intercepted sample image, there is still part of the image with "white edge", that is, large-scale noise with gray value significantly higher than the background part, as shown in (a)-(c) of Figure 2 The existence of large-scale noise may affect the threshold segmentation effect in the subsequent image pre-processing operation, therefore, the white edge removal operation based on the region growing idea is performed on the image after intercepting ROI. The flow chart of the white edge removal algorithm from left to right is shown in Figure 3 The white edge removal operation is performed on the qualified sample, defect sample and truncated sample, and the specific implementation process is shown in steps 2a-2f.
[0059] Step 2a, assuming that the sample image after intercepting ROI is an input image, the row and column numbers of the output image are both the row and column numbers of the input image minus 2;
[0060] Step 2b, starting from the 2nd row of the input image, traverse the image pixels from left to right, i.e. from the 2nd column to the last 2nd column, calculate the average value of the gray scale values of the pixels in the 3x3 neighborhood centered on the current coordinate pixel and its right pixel, denoted as avg0 and avg1;
[0061] Step 2c, set the gray scale value of the current coordinate pixel in the output image to 0;
[0062] Step 2d, judge whether the amplitude of the difference between avg0 and avg1 is less than the set threshold 6, if yes, return to step 2b and continue to traverse the current row, otherwise copy the gray scale values of the remaining pixels in the current row of the input image to the corresponding coordinates in the output image, and then directly enter the traversal of the next row;
[0063] Step 2e, repeat steps 2a-2d until the last 2nd row is traversed, and the traversal is completed;
[0064] Step 2f, change the left-to-right traversal to right-to-left traversal, and change avg0 and avg1 to the average values of the gray scale values of the pixels in the 3x3 neighborhood centered on the current coordinate pixel and its left pixel, take the image ended by the first traversal as the input image, and repeat steps 2a-2e to complete the white border removal operation.
[0065] The result of the white border removal operation is shown in (d)-(f) of Figure 2 . The sample images after white border removal are rotated, flipped and scaled to expand each type of sample to 500, forming a sample set for quality detection. The four types of samples in the sample set are shown in Figure 4 .
[0066] Step 3, the edge of the distorted sample collected due to failure to focus during image collection is blurred, and the effective features for judging whether the oil pipe flat grinding end face has defects cannot be extracted. Therefore, before further detection, it is necessary to identify and exclude the distorted samples.
[0067] Read the images in the sample set, and use the horizontal gradient value of the Sobel operator to detect distortion, and the convolution kernel for calculating the horizontal gradient value of the Sobel operator is:
[0068]
[0069] The distortion detection results of the images in the sample set are shown in Table 1. According to the data in the table, distortion detection can detect 97.4% of the distorted samples, and the false detection rate is only 0.27% (false detection rate is calculated for undistorted samples).
[0070] Table 1
[0071]
[0072]
[0073] Step 4, the undistorted sample image is pre-processed to improve the image quality and facilitate the extraction of effective features. The pre-processing includes four operations of filter denoising, image enhancement, threshold segmentation and morphological processing. The specific implementation process is shown in steps 4a-4d.
[0074] Step 4a, a Gaussian filter is used to further filter the sample image to smooth the slight distortion generated in the white edge removal process. The parameters of the filter include the window size winSize and the standard deviation sigma in the X and Y axis directions. Taking the standard deviations in the X and Y axis directions as the same number, winSize and sigma form a parameter set of the Gaussian filter. According to the properties of the Gaussian function, taking the size of winSize as about 6 times of sigma can obtain the optimal filtering effect. The value of sigma is set to be in the range of 1.5-5.0 with an interval of 0.5, so there are 8 groups of values for the parameter set of the Gaussian filter. The optimal parameter set of the Gaussian filter is winSize=13 and sigma=2 determined by the five-dimensional joint parameter optimization process based on grid search in step 6.
[0075] Step 4b, the sample image is sharpened to enhance the edge information of the image. The convolution kernel used in the sharpening operation is:
[0076]
[0077] Step 4c, the threshold segmentation is performed on the enhanced sample image to realize the binarization of the image. The threshold is set to be 70, and the image is divided into black background part and white oil pipe part.
[0078] Step 4d, morphological processing is used to remove white noise and black holes in the binarized image, including erosion operation and dilation operation. First, one erosion operation and one dilation operation are performed to avoid the oil pipe part in the sample being cut off and connected, which may affect the subsequent feature extraction; then two dilation operations are performed to eliminate the black holes in the sample image; finally, two erosion operations are performed to eliminate the white noise in the sample image.
[0079] The sample image after pre-processing is shown in (a)-(c) of Figure 5 The image completely separates the oil pipe part from the background part and better presents the basic features of the oil pipe, which facilitates the subsequent feature extraction operation.
[0080] Step 5, after the pre-processing, the geometric features of the oil pipe sample are extracted from the image to form a geometric feature group, and the normalization processing is performed.
[0081] Firstly, the contour is extracted from the pre-processed sample image, as shown in (d)-(f) of FIG. 2, and the maximum two contours are used to calculate the geometric features of the oil pipe, i.e. the area ratio and length ratio of the inner and outer ring contours of the oil pipe. The calculation formulae of the area ratio and length ratio are as follows: Figure 5
[0082]
[0083]
[0084] wherein a is the area ratio of the contour, A c is the contour area, A img is the sample image area, l is the length ratio of the contour, L c is the contour perimeter, R img is the radius of the sample image, and half of the side length is taken as the radius. The above area and length are measured in terms of the number of pixel points.
[0085] According to the characteristics of the defective sample, such as the small outer ring contour area and the truncated sample having only one maximum contour and a small area and a large perimeter, the geometric feature group composed of the area and perimeter of the maximum two contours can better distinguish the qualified sample, defective sample and truncated sample. In order to obtain the rotation-invariant and scale-invariant characteristics, the area and perimeter are changed into relative area and relative perimeter, i.e. the area ratio and length ratio represented by formulae (3) and (4).
[0086] Then, the feature vector group of the sample image is normalized by using the Z-score normalization method, and the normalization formula is as follows:
[0087]
[0088]
[0089]
[0090] wherein x i is the i-th feature data extracted from the sample x, n is the total number of features extracted from the sample x, μ is the mean of the n feature data, and δ is the standard deviation of the n feature data.
[0091] Step 6: The SVM classifier is trained according to the normalized feature vector group, and the five-dimensional joint parameter optimization based on grid search is performed to obtain the optimal parameters and improve the classification accuracy.
[0092] Take 70% of the sample images as training samples, use SVM model to train the classifier, the configuration type of SVM is C-class support vector machine, the kernel function is selected as Gaussian kernel function, and the maximum iteration number is set to 1000. In the training process, five-dimensional joint parameter optimization based on grid search is implemented, and the specific implementation process is shown in steps 6a-6c.
[0093] Step 6a, the objects of five-dimensional joint parameter optimization based on grid search include Gaussian filter parameter group Gau, parameters C and Gamma when training SVM classifier, and log step and sample division number k of k-fold cross-validation used when optimizing parameters C and Gamma;
[0094] Step 6b, determine the value range of Gau, C, Gamma, logStep and k, and construct a five-dimensional joint parameter grid. The values of Gau, C, Gamma, logStep and k are as follows:
[0095] Gau[winSize]∈{9,13,15,19,21,25,27,31};
[0096] Gau[sigma]∈{1.5,2,2.5,3,3.5,4,4.5,5};
[0097] logStep∈{5,10,15};
[0098] k∈{5,10,15};
[0099] C∈[10 -3 ,10 3 ];
[0100] Gamma∈[10 -4 ,10 2 ]。
[0101] Step 6c, calculate the average prediction accuracy corresponding to each group of parameters in the grid, constantly update the highest average accuracy, and record the parameter group corresponding to the highest average accuracy, until the iteration is completed, and output the optimal parameter group.
[0102] Optimizing the five parameters of Gau, C, Gamma, logStep and k can avoid the situation that the optimal accuracy is not reached due to the manual setting of parameters according to experience, and optimizing the values of logStep and k is to avoid the local optimal situation caused by single search step.
[0103] The flowchart of the five-dimensional joint parameter optimization algorithm based on grid search is as follows Figure 6The optimal parameter group obtained through optimization is: Gau[winSize]=13, Gau[sigma]=2, logStep=15, k=15, C=759.37, and Gamma=75.94.
[0104] In step 7, the remaining 30% of sample images are taken as prediction samples, and the SVM classification model obtained by using the optimal parameter group is used to classify the samples, so as to complete the detection of the oil pipe flat grinding quality.
[0105] The implementation results of the present application are shown in Tables 2-3.
[0106] Table 2 shows the prediction results of defect detection and classification of 150 qualified samples, 150 defective samples and 150 truncated samples under the optimal parameter group.
[0107] Table 2
[0108]
[0109] Table 3
[0110]
[0111] The implementation results of the present application show that the average prediction accuracy of the qualified samples, the defective samples and the truncated samples can reach 88.00%, among which the prediction accuracy of the truncated samples is as high as 99.33% due to the significant geometric features, and for the defective samples, the feature is not much different from the qualified samples after using the relative information of the geometric feature, so the accuracy is not higher than that of the qualified samples and the truncated samples. In addition, the time required for defect detection and classification of a single sample image is only 0.072 seconds, which is much less than the time required for manual visual inspection, greatly improving the detection efficiency and ensuring that the detection accuracy is not lower than that of manual visual inspection.
[0112] The present application realizes the automation of oil pipe flat grinding quality detection under the premise of ensuring the detection accuracy, solves the problems existing in manual visual inspection, greatly improves the detection efficiency, and has important significance for the real-time oil pipe flat grinding quality detection industrial application site.
[0113] The specific embodiments described herein are merely illustrative of the present application. Those skilled in the art can make various modifications or supplements to the described specific embodiments or use similar ways to replace them, without departing from the spirit of the present application or exceeding the scope defined by the appended claims.
Claims
1. A machine vision-based method for inspecting the quality of oil pipe surface grinding, characterized in that, Includes the following steps: Step 1: Collect sample images of the flat-ground end face of the oil pipe and extract the ROI centered on the oil pipe to reduce redundant information and improve computational efficiency; Step 2: Perform white edge removal operation on the image after ROI cropping based on the idea of region growing to eliminate large-scale noise that occurred during the acquisition process, and expand the sample through rotation, flipping and scaling operations to form a sample set for quality detection. Step 3: Read the images in the sample set and use the gradient value of the Sobel operator in the horizontal direction to detect distortion and filter out distorted samples. Step 4: Preprocess the undistorted sample images, including four operations: filtering and denoising, image enhancement, thresholding and segmentation, and morphological processing, to further improve image quality and facilitate the extraction of effective features. Step 5: After preprocessing, extract the geometric features of the oil pipe sample from the image to form a feature vector group, and then perform normalization processing. Step 6: Train an SVM classifier based on the normalized feature vector group and perform five-dimensional joint parameter optimization based on grid search to obtain the optimal parameters and improve classification accuracy. The specific implementation of the five-dimensional joint parameter optimization based on grid search in step 6 includes the following steps: Step 6a, the objects of the five-dimensional joint parameter optimization based on grid search include the Gaussian filter parameter set Gau, the parameters C and Gamma when training the SVM classifier, and the log step size logStep and the number of sample splits k for k-fold cross-validation used when optimizing parameters C and Gamma; Step 6b: Determine the range of values for Gau, C, Gamma, logStep, and k, and construct a five-dimensional joint parameter grid; Step 6c: Calculate the average prediction accuracy corresponding to each set of parameters in the grid, continuously update the highest average accuracy, and record the parameter set corresponding to the highest average accuracy until all iterations are completed, and output the optimal parameter set. Step 7: Use the trained SVM classification model to classify the samples into three types: qualified, defective, and truncated, thereby realizing the detection of the oil pipe flat grinding quality.
2. The method for detecting the quality of oil pipe surface grinding based on machine vision as described in claim 1, characterized in that: The specific implementation of the white edge removal operation in step 2 includes the following steps: Step 2a: Let the sample image after cropping the ROI be the input image, and the number of rows and columns of the output image be the number of rows and columns of the input image minus 2. Step 2b: Starting from the second row of the input image, traverse the image pixels from left to right, that is, from the second column to the second-to-last column, and calculate the coordinates centered on the current pixel and the pixel to its right. The average grayscale values of the pixels in the neighborhood are denoted as avg0 and avg1; Step 2c: Set the grayscale value of the pixel at the current coordinate in the output image to 0; Step 2d: Determine whether the magnitude of the difference between avg0 and avg1 is less than the set threshold T. If it is less than T, return to step 2b and continue traversing the current row. Otherwise, copy the gray values of the remaining pixels in the current row of the input image to the corresponding coordinates in the output image, and then directly proceed to the traversal of the next row. Step 2e: Repeat steps 2a to 2d until the second-to-last row has been traversed, at which point the traversal ends. Step 2f changes the traversal from left to right to right to left, and changes avg0 and avg1 to be centered on the current pixel and its leftmost pixel. The average gray value of the pixels in the neighborhood is used as the input image after the first traversal. Steps 2a to 2e are repeated to complete the white edge removal operation.
3. The method for detecting the quality of oil pipe surface grinding based on machine vision as described in claim 1, characterized in that: The convolution kernel for calculating the horizontal gradient of the Sobel operator in step 3 is: (1)。 4. The method for detecting the quality of oil pipe surface grinding based on machine vision as described in claim 1, characterized in that: Step 4 includes the following steps: Step 4a: The sample image is further filtered using a Gaussian filter. The parameters of the filter include the window size winSize and the standard deviation sigma in the X and Y axes, which are determined by the five-dimensional joint parameter optimization based on grid search described in step 6. Step 4b involves sharpening the sample image to enhance its edge information. The convolution kernel used for the sharpening operation is: (2) Step 4c: Threshold segmentation is performed on the enhanced sample image to achieve image binarization. The threshold thres is set to segment the image into a black background part and a white oil pipe part. Step 4d: Morphological processing is used to remove white noise and black holes in the binarized image, including erosion and dilation operations. First, one erosion operation and one dilation operation are performed to avoid the oil pipe parts in the sample from sticking together and affecting subsequent feature extraction. Then, two dilation operations are performed to eliminate black holes in the sample image. Finally, two erosion operations are performed to eliminate white noise in the sample image.
5. The method for detecting the quality of oil pipe surface grinding based on machine vision as described in claim 1, characterized in that: The geometric features of the tubing sample mentioned in step 5 include the aspect ratio and length ratio of the inner and outer ring contours of the tubing. The formulas for calculating the aspect ratio and length ratio are as follows: (3) (4) in a It is the aspect ratio of the outline. A c It is the area of the outline, A img It is the area of the sample image. l It is the length ratio of the outline. L c It is the perimeter of the outline. R img It is the radius of the sample image, taking half the side length as the radius. The area and length mentioned above are both measured in terms of the number of pixels.
6. The method for detecting the quality of oil pipe surface grinding based on machine vision as described in claim 1, characterized in that: The normalization process described in step 5 uses the Z-score normalization method, and the normalization formula is: (5) (6) (7) in x i It is a sample x The extracted first i Each feature data, n It is a sample x Total number of features extracted μ yes n The mean of each feature data, δ yes n The standard deviation of each feature data.
7. The method for detecting the quality of oil pipe surface grinding based on machine vision as described in claim 1, characterized in that: In step 6, the SVM configuration type is C-type support vector machine, and the kernel function is selected as Gaussian kernel function.
8. The method for quality inspection of oil pipe surface grinding based on machine vision as described in claim 1, characterized in that: The values of Gau, C, Gamma, logStep, and k are as follows: ; ; ; ; ; 。
Citation Information
Patent Citations
An objective evaluation method of full-reference stereo image quality based on visual salient image feature enhancement
CN109523506A