Metal pipe end defect detection method and system based on machine vision
By constructing the metal tube end defect detection device, introducing an adaptive weight update mechanism to optimize the parallel gray wolf optimization algorithm, and building a PGWO-AW image segmentation algorithm, solving the problems of low efficiency and insufficient accuracy of traditional detection methods, and realizing automated, efficient and high-precision detection of metal tube end defects.
Patent Information
- Application Number
- CN202510358437.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-07-11
AI Technical Summary
The traditional metal tube end defect detection method has low efficiency and insufficient accuracy, poor artificial visual detection stability, and machine vision detection speed and accuracy need to be improved.
Using the metal tube end defect detection method based on machine vision, the metal tube end defect detection device is constructed, and the parallel gray wolf optimization algorithm is optimized by introducing an adaptive weight update mechanism, and a PGWO-AW image segmentation algorithm is constructed. Combined with image preprocessing and spot analysis, defects such as burrs and scratches at the end of the metal tube are automatically detected.
The efficiency and accuracy of defect detection at the end of metal pipes are improved, and automated, high-speed and high-precision defect detection is realized.
Smart Images

Figure CN120298340A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of metal pipe detection, and particularly to a method and system for detecting defects at the end of a metal pipe based on machine vision. Background Art
[0002] During the production process of metal square pipes and round pipes, due to reasons such as cutting, defects such as burrs, unevenness, and depressions often occur on the end faces of the metal pipes. These defects will affect the service performance and appearance quality of the metal pipes, so it is necessary to detect the defects at the ends of the metal pipes. Traditional detection methods mainly rely on manual visual inspection and machine vision inspection methods, but the efficiency and stability of manual visual inspection are insufficient, and the detection speed and accuracy of traditional machine vision inspection methods still need to be improved. Summary of the Invention
[0003] In order to solve the above technical problems, the purpose of the present invention is to provide a method and system for detecting defects at the end of a metal pipe based on machine vision, which can automatically detect defects such as burrs at the end of the metal pipe and scratches on the end surface, improving the detection efficiency and accuracy.
[0004] The first technical solution adopted by the present invention is: A method for detecting defects at the end of a metal pipe based on machine vision, comprising the following steps:
[0005] Construct a device for detecting defects at the end of a metal pipe to obtain an image of the metal pipe to be detected and perform image preprocessing to obtain a preprocessed image of the metal pipe to be detected;
[0006] Introduce an adaptive weight update mechanism to optimize the parallel grey wolf optimization algorithm, and construct a PGWO-AW image segmentation algorithm;
[0007] Based on the PGWO-AW image segmentation algorithm, segment the preprocessed image of the metal pipe to be detected to obtain a segmented image of the metal pipe to be detected;
[0008] Perform speckle analysis on the segmented image of the metal pipe to be detected to obtain the detection result of the defects at the end of the metal pipe.
[0009] Further, the step of constructing a device for detecting defects at the end of a metal pipe to obtain an image of the metal pipe to be detected and perform image preprocessing to obtain a preprocessed image of the metal pipe to be detected specifically includes:
[0010] Construct a device for detecting defects at the end of a metal pipe, and the device for detecting defects at the end of a metal pipe includes a side industrial camera, an upper industrial camera, and a lower industrial camera;
[0011] Collect an image of the metal pipe to be detected through the side industrial camera to obtain an image of the end face of the metal pipe;
[0012] The upper industrial camera and the lower industrial camera are used to collect images of the metal pipe to be detected, and the upper and lower surface images of the metal pipe part are obtained;
[0013] Combining the metal pipe end face image and the upper and lower surface images of the metal pipe part, the metal pipe image to be detected is obtained;
[0014] Image preprocessing is performed on the metal pipe image to be detected to obtain the preprocessed metal pipe image to be detected.
[0015] Furthermore, the step of performing image preprocessing on the metal pipe image to be detected to obtain the preprocessed metal pipe image to be detected specifically includes:
[0016] The color space conversion process is performed on the metal pipe end face image to obtain the metal pipe end face grayscale image;
[0017] The denoising process and the contrast enhancement process are sequentially performed on the metal pipe end face grayscale image to obtain the preprocessed metal pipe end face grayscale image;
[0018] Image filtering is performed on the upper and lower surface images of the metal pipe part to obtain the filtered upper and lower surface images of the metal pipe part;
[0019] The color space conversion process is performed on the filtered upper and lower surface images of the metal pipe part to obtain the preprocessed upper and lower surface grayscale images of the metal pipe part;
[0020] Combining the preprocessed metal pipe end face grayscale image and the preprocessed upper and lower surface grayscale images of the metal pipe part, the preprocessed metal pipe image to be detected is obtained.
[0021] Furthermore, the step of segmenting the preprocessed metal pipe image to be detected based on the PGWO-AW image segmentation algorithm to obtain the segmented metal pipe image to be detected specifically includes:
[0022] Initialize the PGWO-AW image segmentation algorithm, select the corresponding fitness function and set the gray wolf population size, maximum number of iterations, adaptive weight update parameter, and several computing units, and several of the computing units perform gray wolf optimization independently;
[0023] A group of independent gray wolf individuals are generated within each computing unit, and the gray wolf individuals represent different threshold combinations;
[0024] According to the fitness function, each wolf pack calculates its fitness value in parallel in its respective computing unit and stores the current best gray wolf individual;
[0025] According to the adaptive weight update parameter, the position of the current best gray wolf individual is adaptively weighted updated to obtain a new search vector;
[0026] Update the threshold combination of the wolf pack according to the new search vector, and obtain the fitness value of the updated wolf pack through the fitness function;
[0027] Loop through the steps of adaptively updating the weights of the position of the current best gray wolf individual and obtaining the fitness value of the updated wolf pack until the maximum number of iterations is met, and extract the threshold of the final best wolf pack individual from each computing unit as the global optimal threshold;
[0028] Segment the preprocessed metal pipe image to be detected according to the global optimal threshold to obtain the segmented metal pipe image to be detected.
[0029] Further, the step of performing speckle analysis on the segmented metal pipe image to be detected to obtain the metal pipe end defect detection result specifically includes:
[0030] Obtain a standard metal pipe end binary image, and the segmented metal pipe image to be detected includes a metal pipe end binary image and a metal pipe upper and lower surface binary image;
[0031] According to the center coordinates, perform an exclusive OR operation on the standard metal pipe end binary image and the metal pipe end binary image to obtain the defective speckle part;
[0032] Perform speckle pixel analysis on the defective speckle part. If the speckle pixels exceed the preset threshold, mark it as a defective product. If the speckle pixels do not exceed the preset threshold, mark it as a qualified product to obtain the first metal pipe end defect detection result;
[0033] Extract the contour of the metal pipe end surface of the metal pipe upper and lower surface binary image;
[0034] Perform speckle pixel analysis on the contour of the metal pipe end surface. If the speckle pixels exceed the preset threshold, mark it as a defective product. If the speckle pixels do not exceed the preset threshold, mark it as a qualified product to obtain the second metal pipe end defect detection result;
[0035] Combine the first metal pipe end defect detection result and the second metal pipe end defect detection result to obtain the metal pipe end defect detection result.
[0036] The second technical solution adopted by the present invention is: a metal pipe end defect detection system based on machine vision, including:
[0037] The first module is used to construct a metal pipe end defect detection device to obtain a metal pipe image to be detected and perform image preprocessing to obtain the preprocessed metal pipe image to be detected;
[0038] The second module is used to introduce an adaptive weight update mechanism to optimize the parallel gray wolf optimization algorithm and construct a PGWO-AW image segmentation algorithm;
[0039] The third module is used to segment the preprocessed metal pipe image to be detected based on the PGWO-AW image segmentation algorithm, and obtain the segmented metal pipe image to be detected;
[0040] The fourth module is used to perform spot analysis on the segmented metal pipe image to be detected, and obtain the detection result of the metal pipe end defect.
[0041] The beneficial effects of the method and system of the present invention are as follows: By constructing a metal pipe end defect detection device, the present invention acquires the metal pipe image to be detected and performs image preprocessing. Furthermore, an adaptive weight update mechanism is introduced to optimize the parallel grey wolf optimization algorithm, and the PGWO-AW image segmentation algorithm is constructed to segment the preprocessed metal pipe image to be detected. The defects such as burrs at the end of the metal pipe and scratches on the end surface are automatically detected through machine vision technology, improving the detection efficiency and accuracy. Description of the Drawings
[0042] Figure 1 is the flowchart of the steps of a metal pipe end defect detection method based on machine vision according to the present invention;
[0043] Figure 2 is the structural block diagram of a metal pipe end defect detection system based on machine vision according to the present invention;
[0044] Figure 3 is the schematic structural diagram of the device for acquiring the metal pipe end face image provided by a specific embodiment of the present invention;
[0045] Figure 4 is the schematic structural diagram of the device for acquiring the upper and lower surface images of the metal pipe part provided by a specific embodiment of the present invention. Detailed Embodiment
[0046] The following further elaborates the present invention in detail with reference to the drawings and specific embodiments. For the step numbers in the following embodiments, they are only set for the convenience of description and illustration, and no limitation is imposed on the order between the steps. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.
[0047] Referring to Figure 1 , the present invention provides a metal pipe end defect detection method based on machine vision, and the method includes the following steps:
[0048] S100. Construct a metal pipe end defect detection device to acquire the metal pipe image to be detected and perform image preprocessing, and obtain the preprocessed metal pipe image to be detected;
[0049] Specifically, a metal pipe end defect detection device is constructed. The metal pipe end defect detection device includes a side industrial camera, an upper industrial camera, and a lower industrial camera;
[0050] In this embodiment, the metal pipe end defect detection device of the present invention includes a conveyor belt, an industrial camera, a light source, a metal proximity sensor, a motor and a reduction device, an industrial control computer, and an auxiliary pusher device. The metal pipe is conveyed from left to right by the conveyor belt. Industrial cameras are respectively installed above, below, and on the side of each side of the conveyor belt. When the metal proximity sensor detects that the metal pipe enters the field of view of the industrial camera, it triggers the industrial camera to take a picture.
[0051] The side industrial camera is used to collect images of the metal pipe to be detected, and a metal pipe end face image is obtained;
[0052] The upper industrial camera and the lower industrial camera are used to collect images of the metal pipe to be detected, and upper and lower surface images of the metal pipe part are obtained;
[0053] Combining the metal pipe end face image and the upper and lower surface images of the metal pipe part, a metal pipe image to be detected is obtained;
[0054] In this embodiment, as Figure 3 and Figure 4 shown, the metal pipe is conveyed from left to right by the conveyor belt. When the metal proximity sensor detects that the metal pipe enters the field of view of the industrial camera, it triggers the industrial camera to take a picture; the side industrial camera collects the metal pipe end face image to detect whether it is a standard circle or square, whether the size is standard, and whether there are burrs; the upper industrial camera collects the upper surface image of the metal pipe end to detect whether there are scratches, foreign objects, etc.; the lower industrial camera collects the lower surface image of the metal pipe end to detect whether there are scratches, foreign objects, etc.; the collected images are transmitted to the industrial control computer, and image processing algorithms are used to respectively detect whether there are defects on the two end faces and the ends of the metal pipe; if there are defects, a signal is sent to the auxiliary pusher device to remove the defective metal pipe from the conveyor belt.
[0055] Image preprocessing is performed on the metal pipe image to be detected to obtain a preprocessed metal pipe image to be detected.
[0056] Among them, color space conversion processing is performed on the metal pipe end face image to obtain a metal pipe end face grayscale image; denoising processing and contrast enhancement processing are sequentially performed on the metal pipe end face grayscale image to obtain a preprocessed metal pipe end face grayscale image; image filtering processing is performed on the upper and lower surface images of the metal pipe part to obtain a filtered upper and lower surface image of the metal pipe part; color space conversion processing is performed on the filtered upper and lower surface image of the metal pipe part to obtain a preprocessed upper and lower surface grayscale image of the metal pipe part; combining the preprocessed metal pipe end face grayscale image and the preprocessed upper and lower surface grayscale image of the metal pipe part, a preprocessed metal pipe image to be detected is obtained.
[0057] For the end-face image of the metal pipe, the end-face image of the stainless steel pipe is collected from an industrial camera, the color image is converted into a grayscale image, and noise reduction is performed. Gaussian filtering or median filtering is used to remove the noise in the image to ensure that the segmentation process is not affected by noise. Further, the contrast is enhanced. The contrast of the image is enhanced by methods such as histogram equalization to improve the detection effect of the surface defects of the stainless steel pipe.
[0058] For the upper and lower surface images of the metal pipe part, the collected images are filtered to remove noise. Common filtering methods include mean filtering, median filtering, and Gaussian filtering, etc. Filtering can smooth the image and reduce the influence of noise on subsequent processing. Convert the color image into a grayscale image: Convert the filtered color image into a grayscale image. The grayscale image only contains brightness information, which is convenient for subsequent image processing and analysis.
[0059] S200. Introduce an adaptive weight update mechanism to optimize the parallel grey wolf optimization algorithm and construct the PGWO-AW image segmentation algorithm;
[0060] In this embodiment, aiming at the problem that the traditional grey wolf optimization algorithm (GWO) has a slow optimization calculation speed, the segmentation threshold or segmentation parameters of the image are optimized in parallel in multiple computing units (PGWO), and the wolf packs in each computing unit use an adaptive weight update mechanism (AW) to adjust the search direction, avoiding the problem that the optimal value search process falls into a local optimum, improving the accuracy and stability of optimization. The segmentation threshold or segmentation parameters of the image are optimized by the PGWO-AW algorithm to improve the efficiency of the segmentation task.
[0061] S300. Segment the preprocessed metal pipe image to be detected based on the PGWO-AW image segmentation algorithm to obtain the segmented metal pipe image to be detected;
[0062] Specifically, initialize the PGWO-AW image segmentation algorithm, select the corresponding fitness function, and set the gray wolf population size, maximum number of iterations, adaptive weight update parameter, and several computing units. The several computing units perform gray wolf optimization independently; a group of independent gray wolf individuals are generated within each computing unit, and the gray wolf individuals represent different threshold combinations; according to the fitness function, each wolf pack calculates its fitness value in parallel in its respective computing unit and stores the current best gray wolf individual; perform adaptive weight update on the position of the current best gray wolf individual according to the adaptive weight update parameter to obtain a new search vector; update the threshold combination of the wolf pack according to the new search vector, and obtain the fitness value of the updated wolf pack through the fitness function; loop through the steps of performing adaptive weight update on the position of the current best gray wolf individual and obtaining the fitness value of the updated wolf pack until the maximum number of iterations is met, and extract the threshold of the final best wolf pack individual from each computing unit as the global optimal threshold; segment the preprocessed metal pipe image to be detected according to the global optimal threshold to obtain the segmented metal pipe image to be detected.
[0063] In this embodiment, first, initialize the gray wolf optimization algorithm (GWO), which specifically includes:
[0064] 1) Population initialization: Randomly initialize multiple gray wolf individuals in parallel on the GPU, and each individual corresponds to a multi-threshold combination.
[0065] 2) Fitness function selection: Set the fitness function (Fitness), between-class variance, Kapur entropy, maximum entropy, etc.
[0066] 3) Parameter setting: Include the gray wolf population size N, maximum number of iterations T, and adaptive weight update parameter.
[0067] The second step is to perform parallel calculation of the fitness value. First, allocate GPU threads. Each thread independently calculates the fitness value of a candidate threshold combination, then calculates the between-class variance, and counts the between-class variance after segmentation by different thresholds to improve the category discrimination degree. And calculate the information entropy, calculate the Kapur entropy or maximum entropy to improve the information expression ability. Finally, store the best fitness value and save the fitness value of the current optimal threshold combination in the shared memory.
[0068] The third step is to update the gray wolf position, that is, threshold optimization. First, determine the α, β, and δ gray wolves, and select the three individuals with the highest fitness values as α (optimal), β (sub-optimal), and δ (third best). Secondly, calculate the search vector, calculate a new search direction based on the positions of α, β, and δ, perform adaptive weight update, adjust the step size according to the number of iterations to improve the convergence speed. Finally, update the threshold combination, generate a new candidate threshold combination, and check the boundary conditions.
[0069] The fourth step is to calculate the new fitness values in parallel. First, calculate the new between-class variance or entropy in parallel, and the GPU threads calculate the new fitness values respectively. Then store the optimal individuals, compare the old and new fitness values, and update the positions of α, β, and δ. Finally, check the convergence condition: if the change in the fitness value is less than the set threshold or the maximum number of iterations is reached, terminate the optimization.
[0070] The fifth step is to output the optimal threshold and perform image segmentation. First, select the optimal threshold combination, and take the threshold of the final α gray wolf individual as the best segmentation point. Then apply threshold segmentation, use the optimal threshold to segment the image, generate a binary or multi-level segmentation image, and finally visualize the result, display the segmented image, and calculate the evaluation metrics SSIM and PSNR.
[0071] S400. Perform speckle analysis on the segmented metal pipe image to be detected to obtain the detection result of the end defect of the metal pipe.
[0072] Specifically, obtain the binary image of the standard metal pipe end face. The segmented metal pipe image to be detected includes the binary image of the metal pipe end face and the binary images of the upper and lower surfaces of the metal pipe part. According to the center coordinates, perform an exclusive OR operation on the binary image of the standard metal pipe end face and the binary image of the metal pipe end face to obtain the defective speckle part. Perform speckle pixel analysis on the defective speckle part. If the speckle pixels exceed the preset threshold, mark it as a defective product; if the speckle pixels do not exceed the preset threshold, mark it as a qualified product to obtain the first detection result of the metal pipe end defect. Extract the contour of the metal pipe end surface of the binary images of the upper and lower surfaces of the metal pipe part. Perform speckle pixel analysis on the contour of the metal pipe end surface. If the speckle pixels exceed the preset threshold, mark it as a defective product; if the speckle pixels do not exceed the preset threshold, mark it as a qualified product to obtain the second detection result of the metal pipe end defect. Combine the first detection result of the metal pipe end defect and the second detection result of the metal pipe end defect to obtain the detection result of the metal pipe end defect.
[0073] For the binary image of the metal pipe end face, use the Hough circle transform to identify the contour of the circle in the image and determine the center of the circle. Extract the defective part. According to the center coordinates, perform an exclusive OR operation on the binary image of the metal end face obtained by PGWO-AW segmentation and the binary image of the standard metal pipe end face to obtain the defective speckle part. Perform speckle analysis, perform pixel analysis on the defective speckles of the defective part. If the speckle pixels exceed the threshold, it is determined as a defective product, otherwise it is a qualified product. Speckle analysis can be performed by calculating the number of pixels in the defective area and determining whether it exceeds the preset threshold.
[0074] For the binary images of the upper and lower surfaces of the metal pipe section, perform pixel spot analysis on the binary images. If the number of spot pixels exceeds the threshold, it is determined that the product has scratch or foreign object defects; otherwise, it is a qualified product. If all the detection results are qualified, send a qualified signal to drive the green indicator light to turn on. If there are defects, display the defect information in the image, send a defect error signal, drive the red indicator light to turn on, and control the auxiliary feeding device to act to remove the defective metal pipe.
[0075] Refer to Figure 2 , a metal pipe end defect detection system based on machine vision, including:
[0076] The first module 201 is used to construct a metal pipe end defect detection device to obtain an image of the metal pipe to be detected and perform image preprocessing to obtain the preprocessed image of the metal pipe to be detected;
[0077] The second module 202 is used to introduce an adaptive weight update mechanism to optimize the parallel grey wolf optimization algorithm and construct a PGWO-AW image segmentation algorithm;
[0078] The third module 203 is used to segment the preprocessed image of the metal pipe to be detected based on the PGWO-AW image segmentation algorithm to obtain the segmented image of the metal pipe to be detected;
[0079] The fourth module 204 is used to perform spot analysis on the segmented image of the metal pipe to be detected to obtain the metal pipe end defect detection result.
[0080] The content in the above method embodiments is applicable to the system embodiments. The functions specifically implemented in the system embodiments are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those in the above method embodiments.
[0081] The above is a specific description of the preferred embodiments of the present invention. However, the present invention is not limited to the described embodiments. Those skilled in the art can make various equivalent deformations or substitutions without departing from the spirit of the present invention, and these equivalent deformations or substitutions are all included within the scope defined by the claims of this application.
Claims
1. A method for detecting defects at the end of a metal tube based on machine vision, characterized in that, It includes the following steps: Construct a metal pipe end defect detection device to obtain an image of the metal pipe to be detected and perform image preprocessing to obtain the preprocessed image of the metal pipe to be detected; Introduce an adaptive weight update mechanism to optimize the parallel grey wolf optimization algorithm and construct the PGWO-AW image segmentation algorithm; Segment the preprocessed image of the metal pipe to be detected based on the PGWO-AW image segmentation algorithm to obtain the segmented image of the metal pipe to be detected; Perform speckle analysis on the segmented image of the metal pipe to be detected to obtain the metal pipe end defect detection result.
2. The method for detecting defects at the end of a metal tube based on machine vision according to claim 1, characterized in that, The step of constructing a metal pipe end defect detection device to obtain an image of the metal pipe to be detected and perform image preprocessing to obtain the preprocessed image of the metal pipe to be detected specifically includes: Construct a metal pipe end defect detection device, and the metal pipe end defect detection device includes a side industrial camera, an upper industrial camera and a lower industrial camera; Collect an image of the metal pipe to be detected through the side industrial camera to obtain a metal pipe end face image; Collect an image of the metal pipe to be detected through the upper industrial camera and the lower industrial camera to obtain the upper and lower surface images of the metal pipe part; Combine the metal pipe end face image and the upper and lower surface images of the metal pipe part to obtain an image of the metal pipe to be detected; Perform image preprocessing on the image of the metal pipe to be detected to obtain the preprocessed image of the metal pipe to be detected.
3. The method for detecting defects at the end of a metal tube based on machine vision according to claim 2, characterized in that The step of performing image preprocessing on the image of the metal pipe to be detected to obtain the preprocessed image of the metal pipe to be detected specifically includes: Perform color space conversion processing on the metal pipe end face image to obtain a metal pipe end face grayscale image; Perform noise removal processing and contrast enhancement processing on the metal pipe end face grayscale image in sequence to obtain the preprocessed metal pipe end face grayscale image; Perform image filtering processing on the upper and lower surface images of the metal pipe part to obtain the filtered upper and lower surface images of the metal pipe part; Perform color space conversion processing on the filtered upper and lower surface images of the metal pipe part to obtain the preprocessed upper and lower surface grayscale images of the metal pipe part; Combine the preprocessed metal pipe end face grayscale image and the preprocessed upper and lower surface grayscale images of the metal pipe part to obtain the preprocessed image of the metal pipe to be detected.
4. The method for detecting defects at the end of a metal tube based on machine vision according to claim 3, wherein, The step of segmenting the preprocessed image of the metal pipe to be detected based on the PGWO-AW image segmentation algorithm to obtain the segmented image of the metal pipe to be detected specifically includes: Initialize the PGWO-AW image segmentation algorithm, select the corresponding fitness function and set the grey wolf population size, maximum number of iterations, adaptive weight update parameters and several computing units, and several of the computing units perform grey wolf optimization independently; Generate a group of independent grey wolf individuals within each computing unit, and the grey wolf individuals represent different threshold combinations; According to the fitness function, each wolf pack calculates its fitness value in parallel in its respective computing unit and stores the current best grey wolf individual; Perform adaptive weight update on the position of the current best grey wolf individual according to the adaptive weight update parameters to obtain a new search vector; Update the threshold combination of the wolf pack according to the new search vector, and obtain the fitness value of the updated wolf pack through the fitness function; Loop through the steps of adaptively updating the weights of the positions of the current best gray wolf individuals and obtaining the fitness values of the updated wolf pack until the maximum number of iterations is reached. Then, extract the thresholds of the final best wolf individuals from each computing unit as the global optimal thresholds. Segment the preprocessed metal pipe image to be detected according to the global optimal threshold to obtain the segmented metal pipe image to be detected.
5. The method for detecting defects at the end of a metal pipe based on machine vision according to claim 4, characterized in that, The step of performing spot analysis on the segmented metal pipe image to be detected to obtain the metal pipe end defect detection result specifically includes: Obtain a binary image of the standard metal pipe end face. The segmented metal pipe image to be detected includes a binary image of the metal pipe end face and binary images of the upper and lower surfaces of the metal pipe part. According to the center coordinates, perform an exclusive OR operation on the binary image of the standard metal pipe end face and the binary image of the metal pipe end face to obtain the defective spot part. Perform spot pixel analysis on the defective spot part. If the spot pixels exceed the preset threshold, mark it as a defective product. If the spot pixels do not exceed the preset threshold, mark it as a qualified product to obtain the first metal pipe end defect detection result. Extract the contour of the metal pipe end surface of the binary images of the upper and lower surfaces of the metal pipe part. Perform spot pixel analysis on the contour of the metal pipe end surface. If the spot pixels exceed the preset threshold, mark it as a defective product. If the spot pixels do not exceed the preset threshold, mark it as a qualified product to obtain the second metal pipe end defect detection result. Combine the first metal pipe end defect detection result and the second metal pipe end defect detection result to obtain the metal pipe end defect detection result.
6. A metal pipe end defect detection system based on machine vision, characterized in that, It includes the following modules: The first module is used to construct a metal pipe end defect detection device to obtain the metal pipe image to be detected and perform image preprocessing to obtain the preprocessed metal pipe image to be detected. The second module is used to introduce an adaptive weight update mechanism to optimize the parallel gray wolf optimization algorithm and construct the PGWO-AW image segmentation algorithm. The third module is used to segment the preprocessed metal pipe image to be detected based on the PGWO-AW image segmentation algorithm to obtain the segmented metal pipe image to be detected. The fourth module is used to perform spot analysis on the segmented metal pipe image to be detected to obtain the metal pipe end defect detection result.