Steel pipe weld defect detection method and system based on machine vision
By using machine vision-based methods to accurately identify complex weld boundaries and combining them with grayscale gradient analysis, the problem of low accuracy in steel pipe weld defect detection in existing technologies has been solved, achieving efficient and accurate defect detection.
Patent Information
- Application Number
- CN202511368822.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-24
- Publication Date
- 2025-12-26
AI Technical Summary
Existing technologies are not very accurate in detecting defects in steel pipe welds, especially in complex geometries and complex industrial environments where it is difficult to accurately identify weld boundaries and micro-cracks, leading to misjudgments or missed detections.
A machine vision-based approach is adopted to acquire image data of the curved weld area, perform preprocessing and edge feature extraction, calculate curvature to determine the turning point, fit straight line segments and arc segments to generate a complete weld boundary point sequence, combine gray-scale gradient analysis to classify defects, and finally use the minimum bounding rectangle to determine the evaluation range.
It enables accurate identification of complex weld morphology and efficient and precise detection of defects, significantly improving the accuracy and reliability of detection and solving the problems of low detection efficiency and rough evaluation results in existing technologies.
Smart Images

Figure CN121213499A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial automation inspection and machine vision technology, and in particular to a method and system for detecting defects in steel pipe welds based on machine vision. Background Technology
[0002] Currently, steel pipe welding is a crucial link in modern industrial manufacturing, and its quality directly affects the safety of engineering structures in important fields such as water conservancy, petroleum, natural gas, and construction. Especially in recent years, steel pipes have been increasingly used in water diversion projects, and welding has become the primary method for connecting these pipes. Therefore, quality inspection of steel pipe welds is of paramount importance, particularly the accurate identification and location of weld defects, which has become a core requirement for ensuring project quality.
[0003] In existing technologies, weld defect detection often relies on manual visual inspection or simple image processing techniques, such as edge detection algorithms based on fixed thresholds. These methods perform reasonably well when dealing with welds with regular shapes and good image quality, but their limitations become apparent when faced with welds with complex geometries (such as curves or multi-segment polylines) or in complex industrial environments with uneven lighting and surface texture interference. On the one hand, traditional algorithms struggle to accurately capture and adapt to irregular weld boundary changes; on the other hand, noise and interference in the image severely affect the accuracy of edge detection, leading to incomplete or erroneous contour extraction, and consequently, misjudgment or missed detection of defects.
[0004] In summary, existing technologies suffer from low accuracy in detecting defects in steel pipe welds. Summary of the Invention
[0005] This invention provides a machine vision-based method and system for detecting defects in steel pipe welds, in order to solve the technical problem of low accuracy in detecting defects in steel pipe welds in existing technologies.
[0006] In a first aspect, to address the aforementioned technical problems, the present invention provides a machine vision-based method for detecting defects in steel pipe welds, comprising: The original image data of the curved weld area is acquired, and preprocessed and edge feature extracted to obtain a preliminary contour point set; A continuous pixel sequence is obtained from the initial contour point set, and the curvature of the continuous pixel sequence is calculated. Turning points are determined according to a preset curvature threshold, and a turning point annotation set is generated. The preliminary contour point set is segmented according to the inflection point annotation set, and straight line segments and arc segments are fitted to determine the geometric segmentation structure of the weld. Obtain the endpoints of the geometric segment structure and, in conjunction with the inflection point annotation set, determine the start and end points of the weld boundary to generate a complete boundary point sequence. The weld seam region is divided according to the complete boundary point sequence, and the gray-scale gradient within the weld seam region is analyzed to classify defects in abnormal regions and obtain defect location results. Extract the defect region boundary from the defect location results, and use the minimum bounding rectangle to enclose the defect region to determine the final evaluation range.
[0007] Preferably, the step of acquiring the original image data of the curved weld area and performing preprocessing and edge feature extraction to obtain a preliminary contour point set includes: The original image data of the curved weld area is acquired, and the original image data is smoothed to obtain a first image; The first image is enhanced by grayscale transformation to obtain the second image; Calculate the pixel gradient of the second image to obtain a third image of the edge intensity distribution; The regions in the third image with edge strength greater than a preset strength threshold are segmented to obtain a fourth image of the weld region; The preliminary contour point set is obtained by fitting a smooth contour curve to the weld boundary in the fourth image and resampling the smooth contour curve.
[0008] Preferably, the step of obtaining a continuous pixel sequence from the initial contour point set, calculating the curvature of the continuous pixel sequence, determining inflection points according to a preset curvature threshold, and generating an inflection point annotation set includes: The pixel coordinates in the preliminary contour point set are sorted according to their adjacency relationship to obtain an ordered set of pixel sequences. By calculating the angular changes of adjacent pixels in the ordered pixel sequence set, the curvature value of each pixel is determined, and a curvature distribution set is obtained. The pixels corresponding to curvature values greater than a preset curvature threshold in the curvature distribution set are marked as inflection points, thus obtaining the inflection point annotation set.
[0009] Preferably, the step of segmenting the preliminary contour point set according to the inflection point annotation set, and fitting straight line segments and arc segments to determine the geometric segmentation structure of the weld includes: Perform straight line feature detection on the preliminary contour point set to identify collinear pixels and obtain a set of straight line segment pixels; For the non-collinear pixels in the initial contour point set, perform arc fitting processing to obtain a set of arc segment pixels; By combining the set of pixel points for the straight line segment, the set of pixel points for the arc segment, and the set of annotations for the turning points, the geometric segmentation structure of the weld is determined.
[0010] Preferably, the step of obtaining the endpoints of the geometric segmentation structure and, in conjunction with the inflection point annotation set, determining the start and end points of the weld boundary to generate a complete boundary point sequence includes: The endpoints of each segment are obtained from the geometric segmentation structure, resulting in a set of endpoint coordinates; Determine the positional relationship between each endpoint in the endpoint coordinate set and the image boundary, and mark the endpoints on the image boundary as the start point and the end point, thus obtaining the start point set and the end point set; The set of starting points, the set of ending points, and the set of turning point labels are sequentially integrated, and the continuity of the integrated sequence is refined to obtain the complete boundary point sequence.
[0011] Preferably, the step of dividing the weld area according to the complete boundary point sequence, analyzing the gray-level gradient within the weld area, classifying abnormal areas for defects, and obtaining defect location results includes: Based on the complete sequence of boundary points, the weld region is divided into multiple weld sub-regions; Calculate the grayscale gradient value of each weld sub-region, and mark the sub-regions whose grayscale gradient values exceed a preset gradient threshold as abnormal regions; Feature points are extracted from the abnormal region and classified to obtain a set of defect types; Based on the set of defect types and combined with curvature calculation analysis of the abnormal region, the microcracks related to the inflection point are marked to obtain the defect location result.
[0012] Preferably, the step of extracting the defect region boundary from the defect location result and enclosing the defect region with a minimum bounding rectangle to determine the final evaluation range includes: The defect region in the defect location result is subjected to boundary tracking processing to obtain a sequence of defect boundary points; Calculate the minimum bounding rectangle surrounding the defect region based on the defect boundary point sequence; If the minimum bounding rectangle contains a turning point, then gray-level gradient calculation is performed within the minimum bounding rectangle to identify abnormal feature points; The final evaluation range is determined by dividing the range based on the abnormal feature points.
[0013] Secondly, the present invention provides a machine vision-based steel pipe weld defect detection device, comprising: The image acquisition and processing module is used to acquire the original image data of the curved weld area, and perform preprocessing and edge feature extraction to obtain a preliminary contour point set; The inflection point identification module is used to obtain a continuous pixel sequence from the preliminary contour point set, calculate the curvature of the continuous pixel sequence, determine the inflection point according to the preset curvature threshold, and generate an inflection point annotation set. The geometric structure segmentation module is used to segment the preliminary contour point set according to the inflection point annotation set, and fit straight line segments and arc segments to determine the geometric segmentation structure of the weld. The boundary sequence generation module is used to obtain the endpoints of the geometric segmentation structure and, in conjunction with the inflection point annotation set, determine the start and end points of the weld boundary to generate a complete boundary point sequence. The defect detection module is used to divide the weld area according to the complete boundary point sequence, analyze the gray-scale gradient within the weld area, classify defects in abnormal areas, and obtain defect location results. The defect assessment module is used to extract the defect region boundary from the defect location results and enclose the defect region with a minimum bounding rectangle to determine the final assessment range.
[0014] Thirdly, the present invention also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the machine vision-based steel pipe weld defect detection method described in any one of the above.
[0015] Fourthly, the present invention also provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the machine vision-based steel pipe weld defect detection method described above.
[0016] Compared with the prior art, the present invention has the following beneficial effects: (1) By preprocessing the weld image and combining curvature calculation and geometric fitting, the present invention can accurately identify and extract the complex weld boundary contour containing the start point, end point and turning point, which solves the technical problem that the existing technology is difficult to adapt to complex weld morphology due to inaccurate contour extraction, and provides a reliable foundation for subsequent accurate defect detection.
[0017] (2) By performing grayscale gradient analysis within a precisely defined weld area and combining it with curvature features, the present invention can effectively classify abnormal areas, especially identifying micro-cracks at weld inflection points. This solves the problem of missed defects and misjudgments caused by inaccurate area division in the prior art, and significantly improves the accuracy and reliability of defect detection.
[0018] (3) By constructing a fully automated process from contour extraction and defect location to final evaluation range determination, and performing boundary tracking and multi-level range refinement on the identified defect areas, this invention solves the problems of low detection efficiency and rough evaluation results in the existing technology, and realizes efficient and accurate evaluation of steel pipe weld defects, providing strong technical support for ensuring project quality. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of a machine vision-based method for detecting defects in steel pipe welds, provided in the first embodiment of the present invention. Figure 2 This is a schematic diagram of a machine vision-based steel pipe weld defect detection system provided in the second embodiment of the present invention. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Reference Figure 1 The first embodiment of the present invention provides a method for detecting defects in steel pipe welds based on machine vision, comprising the following steps: S11: Obtain the original image data of the curved weld area, and perform preprocessing and edge feature extraction to obtain a preliminary contour point set; S12, obtain a continuous pixel sequence from the preliminary contour point set, calculate the curvature of the continuous pixel sequence, determine the turning point according to the preset curvature threshold, and generate a turning point annotation set; S13, the preliminary contour point set is segmented according to the inflection point annotation set, and straight line segments and arc segments are fitted to determine the geometric segmentation structure of the weld. S14, obtain the endpoints of the geometric segmentation structure, and combine them with the inflection point annotation set to determine the start and end points of the weld boundary and generate a complete boundary point sequence. S15, Divide the weld area according to the complete boundary point sequence, analyze the gray-scale gradient in the weld area, classify the abnormal area for defects, and obtain the defect location result. S16, extract the defect region boundary from the defect location result, and use the minimum enclosing rectangle to enclose the defect region to determine the final evaluation range.
[0022] In step S11, the original image data of the curved weld area is acquired, and preprocessing and edge feature extraction are performed to obtain a preliminary contour point set, including: The original image data of the curved weld area is acquired, and the original image data is smoothed to obtain a first image; The first image is enhanced by grayscale transformation to obtain the second image; Calculate the pixel gradient of the second image to obtain a third image of the edge intensity distribution; The regions in the third image with edge strength greater than a preset strength threshold are segmented to obtain a fourth image of the weld region; The preliminary contour point set is obtained by fitting a smooth contour curve to the weld boundary in the fourth image and resampling the smooth contour curve.
[0023] In one implementation, a high-resolution industrial camera deployed at the inspection station acquires raw image data of the curved weld area. To suppress random noise in the image caused by uneven lighting or electromagnetic interference, Gaussian filtering is used to smooth the acquired raw image data to obtain the first image.
[0024] It should be noted that after obtaining the first image, a grayscale transformation can be performed on it to enhance the contrast between the weld seam and the background area. This transformation expands the dynamic range of the grayscale values of the pixels in the image to a standard range, such as 0 to 255, through linear stretching, thereby making the contour features of the weld seam more prominent in the image, resulting in the second image.
[0025] In another implementation, to obtain the edge information of the weld, the system calculates the pixel gradient of each pixel in the second image. It should be noted that this calculation is achieved through convolution processing, specifically using a convolution kernel based on well-known theories in image processing for approximating the first derivative of an image. This kernel weights the grayscale values of the center pixel and its neighboring pixels, yielding gradient components corresponding to the horizontal and vertical directions, respectively. Subsequently, the system synthesizes these two gradient components to obtain a final gradient value that characterizes the edge strength at that pixel. This final gradient value is the edge strength value, and the edge strength values of all pixels together constitute the third image of the edge strength distribution.
[0026] It is worth noting that the system performs region segmentation based on the edge intensity of the third image. This segmentation process first compares the edge intensity value of each pixel with a preset intensity threshold. The determination of this intensity threshold is as follows: Statistical analysis is performed on the gradient histograms of a large number of historical weld seam images to identify two main peaks representing background noise and weld seam edges, respectively. The valley value located between these two main peaks is determined as the intensity threshold (e.g., 100). For all pixels in the third image with edge intensities greater than this threshold and their adjacent regions, region growing segmentation is applied. This process uses these pixels as starting seed points and expands based on a neighboring pixel gray-level similarity criterion. Through this process, a connected weld seam region is finally formed, resulting in the fourth image.
[0027] It should be noted that the neighboring pixel grayscale similarity criterion is as follows: if the difference between the grayscale value of a neighboring pixel and the average grayscale value of the expanded region is less than a preset similarity threshold, then the neighboring pixel is merged. The process of determining the similarity threshold includes: selecting multiple known qualified weld seam internal regions from a large number of historical weld seam samples; calculating the standard deviation of the grayscale values of all pixels in each weld seam internal region to quantify the normal grayscale fluctuations within it; and based on the statistical distribution of all calculated standard deviations and according to the "3-sigma principle" in statistics, setting a value that can cover the vast majority of normal fluctuation ranges as the similarity threshold (e.g., 15).
[0028] It is worth noting that, for the weld boundary segmented from the fourth image that may contain jagged noise, the system fits a smooth contour curve based on the weld boundary and resamples the smooth contour curve to obtain the preliminary contour point set. In one implementation, the smoothing process can be achieved using spline curve interpolation, which generates a continuous contour curve that represents the smoothing trend of the boundary based on the original boundary point set. Subsequently, the system resamples along the contour curve at a predetermined resolution or step size. It should be noted that the predetermined resolution or step size is determined through offline experimental calibration based on the requirements for contour accuracy in the actual detection application and the limitations of system computing resources, ensuring that the number of data points is minimized while retaining necessary contour details, thereby improving processing efficiency; for example, it can be set to sample once every 1 pixel along the arc length of the curve. Through this resampling process, a new set of pixels with accurate coordinates and an ordered arrangement is obtained, and this new set of pixels is the preliminary contour point set.
[0029] For example, suppose we acquire a raw image of 1280×720 pixels, where the grayscale values of the weld area are concentrated in a narrow range of 100-150. The system first smooths the image using a 5×5 Gaussian filter kernel to obtain the first image. Then, it stretches the grayscale range to 0-255 using a linear grayscale transformation to obtain the second image. Next, it calculates the pixel gradient using a 3×3 convolution kernel to obtain the third image. Based on a preset intensity threshold of 100 derived from statistical analysis of historical data, the system segments the regions in the third image with edge intensities greater than 100 to obtain the fourth image. Finally, for any jagged boundaries that may exist in the fourth image, the system fits a smooth spline curve based on these boundaries and resamples along the curve at intervals of one pixel's arc length, ultimately obtaining the preliminary contour point set containing approximately 1000 precise coordinate points.
[0030] In step S12, a continuous pixel sequence is obtained from the preliminary contour point set, and the curvature of the continuous pixel sequence is calculated. Turning points are determined based on a preset curvature threshold, and a turning point annotation set is generated, including: The pixel coordinates in the preliminary contour point set are sorted according to their adjacency relationship to obtain an ordered set of pixel sequences. By calculating the angular changes of adjacent pixels in the ordered pixel sequence set, the curvature value of each pixel is determined, and a curvature distribution set is obtained. The pixels corresponding to curvature values greater than a preset curvature threshold in the curvature distribution set are marked as inflection points, thus obtaining the inflection point annotation set.
[0031] In one implementation, since the preliminary contour point set obtained in S11 is an unordered set of pixels, the system first sorts it according to the adjacency relationship of each pixel coordinate. It should be noted that this sorting process is implemented through iterative connections: the process first selects a starting point from the preliminary contour point set, and then iteratively searches for the nearest unvisited pixel in its eight neighborhoods, connecting it as the next point in the sequence, until all points have been visited and connected. Through this process, the unordered point set is finally reconstructed into an ordered set of pixel sequences capable of describing the continuous boundary of the weld.
[0032] It should be noted that after obtaining the ordered set of pixel sequences, the system determines the curvature value of each pixel by calculating the angular changes between adjacent pixels in the sequence. In one implementation, this calculation process is as follows: To handle the beginning and end boundary conditions of the sequence, the system treats the ordered set of pixel sequences as a closed loop sequence, that is, the forward neighbor of the first point in the sequence is the last point in the sequence, and the backward neighbor of the last point in the sequence is the first point in the sequence. For any central pixel B in the sequence and its preceding and following adjacent pixels A and C, vectors BA and BC are constructed respectively, and the angle between these two vectors is calculated. The quantized value of this angle is the curvature value of the central pixel B. After traversing the entire sequence, the curvature distribution set containing the curvature values of all pixels is obtained.
[0033] It is worth noting that the system compares each curvature value in the curvature distribution set with a preset curvature threshold. This preset curvature threshold is determined through offline analysis of a large number of labeled historical weld images. The determination process involves: statistically analyzing the curvature value distributions of known inflection point locations and smooth boundary locations in the historical images, and selecting a critical value (e.g., 0.7) that maximizes the distinction between these two types of regions as the preset curvature threshold. The system then marks all pixels with curvature values greater than this threshold as potential inflection points, ultimately obtaining the inflection point annotation set.
[0034] For example, assuming an ordered set of pixels contains 2000 points, the system calculates the angle change between vectors AB and BC between three consecutive points A, B, and C to obtain the curvature value of point B. If the curvature value of a smooth boundary is generally between 0.1 and 0.3, while the curvature value of a transition region is significantly higher, and a preset curvature threshold of 0.7 is determined based on historical data analysis, the system identifies 10 pixels with curvature values higher than 0.7 after traversing the curvature distribution set, and marks these points as transition points, forming the transition point annotation set.
[0035] In step S13, the preliminary contour point set is segmented according to the inflection point annotation set, and straight line segments and arc segments are fitted to determine the geometric segmentation structure of the weld, including: Perform straight line feature detection on the preliminary contour point set to identify collinear pixels and obtain a set of straight line segment pixels; For the non-collinear pixels in the initial contour point set, perform arc fitting processing to obtain a set of arc segment pixels; By combining the set of pixel points for the straight line segment, the set of pixel points for the arc segment, and the set of annotations for the turning points, the geometric segmentation structure of the weld is determined.
[0036] In one implementation, the system performs straight line feature detection on the preliminary contour point set obtained in S12. It should be noted that this detection can be implemented using Hough transform, the process of which is as follows: the coordinates of each pixel in the preliminary contour point set are mapped from the image coordinate space to a parameter space defined by polar coordinate parameters (polar radius ρ and angle θ), forming a series of curves; the system constructs a two-dimensional accumulator matrix in the parameter space. It should be noted that the dimension of the two-dimensional accumulator matrix is determined by the range and precision of the parameters: the angle θ dimension ranges from 0 to 179 degrees; if divided with a precision of 1 degree, the size of this dimension is 180; the polar radius ρ dimension ranges from [-D, D] (D is the diagonal length of the image); if divided with a precision of 1 pixel, the size of this dimension is 2D+1. The system iterates through all points in the initial contour point set, increments the count of the matrix units traversed by each curve, and completes the cumulative voting. Finally, the unit with the highest count value in the accumulator matrix is mapped back to the image coordinate space to obtain collinear pixels. These collinear pixels constitute the set of pixel points for the line segment.
[0037] It should be noted that for non-collinear pixels that fail to be identified by straight-line feature detection in the initial contour point set, the system performs arc fitting processing. In one implementation, this processing is achieved through iterative calculation: the process first randomly selects three points from the non-collinear pixels, calculates the center and radius of the candidate arc that can uniquely pass through these three points; calculates the distance from all other non-collinear pixels to the candidate arc, and counts the number of points whose distance is less than a preset fitting error threshold; it should be noted that the preset fitting error threshold is determined through offline experiments after balancing fitting accuracy and noise tolerance, ensuring that pixels belonging to the same arc can be correctly clustered (e.g., 3 pixels); by repeating this process, the candidate arc with the most supported points is finally selected as the best fitting result, and all pixels supporting this result are determined as the set of pixels for the arc segment.
[0038] It is worth noting that the system ultimately integrates the detected set of pixel points for straight line segments and the set of pixel points for arc segments with the set of inflection point annotations generated in S12. This integration process uses inflection points as the key segmentation basis, connecting and dividing independent straight line segments and arc segments, and finally constructing a geometric segmentation structure of the weld that can accurately describe the overall geometry of the weld.
[0039] For example, assuming an initial contour point set containing 1500 pixels, the system identifies three straight line segments, each containing approximately 200 pixels, through straight line feature detection. For the remaining non-collinear pixels, the system performs arc fitting processing to fit two arc segments with different radii. Finally, using the five identified turning points as boundaries, the system systematically combines these three straight line segments and two arc segments to form a complete, segmented description of the weld geometry.
[0040] In step S14, the endpoints of the geometric segmentation structure are obtained, and combined with the inflection point annotation set, the start and end points of the weld boundary are determined to generate a complete boundary point sequence, including: The endpoints of each segment are obtained from the geometric segmentation structure, resulting in a set of endpoint coordinates; Determine the positional relationship between each endpoint in the endpoint coordinate set and the image boundary, and mark the endpoints on the image boundary as the start point and the end point, thus obtaining the start point set and the end point set; The set of starting points, the set of ending points, and the set of turning point labels are sequentially integrated, and the continuity of the integrated sequence is refined to obtain the complete boundary point sequence.
[0041] In one implementation, the system extracts the endpoints that constitute each straight line segment and arc segment from the geometric segmentation structure generated in S13, and summarizes the coordinates of these endpoints to obtain the endpoint coordinate set.
[0042] It should be noted that, to determine the start and end points of the weld in the image, the system analyzes the positional relationship between each endpoint in the endpoint coordinate set and the image boundary. This analysis is achieved by comparing the coordinate values of the endpoints with the size boundary values of the image. It should also be noted that the system distinguishes endpoints located at the image edge according to a preset contour tracking direction (e.g., from left to right of the image): under this tracking direction, the first encountered boundary point is marked as the start point, and the last encountered boundary point is marked as the end point. Through this processing, a set of start points containing all start points and a set of end points containing all end points are finally obtained. It should also be noted that when there are multiple independent weld segments or forked welds in the image, the set of start points and the set of end points may each contain one or more coordinate points.
[0043] It is worth noting that the system integrates the acquired set of starting points, the set of ending points, and the set of turning point annotations generated in S12 into a sequence. This integration analyzes the spatial positional relationships of each key point and arranges them in a natural order along the weld boundary. To ensure the accuracy of the sequence, the arranged sequence can also undergo continuity refinement processing. This processing calculates the distance between adjacent points in the sequence and removes abnormal spacing points. It should be noted that the process of judging abnormal spacing points includes: calculating the average and standard deviation of the distances between all adjacent points in the preliminary boundary point sequence; setting an abnormal spacing threshold based on the average and standard deviation (e.g., average + 3 times the standard deviation); and finally, identifying points whose distances to adjacent points are greater than the threshold as abnormal spacing points and removing them. Through this refinement process, the complete boundary point sequence is finally obtained.
[0044] For example, suppose in a 1024×768 pixel image, the system extracts 10 endpoint coordinates from the geometric segmentation structure. Analysis reveals that coordinates (0, 300) are located at the left edge of the image, and coordinates (1023, 500) are located at the right edge. Following a left-to-right tracking direction, the system marks (0, 300) as the starting point and (1023, 500) as the ending point. Subsequently, the system integrates this starting and ending points with the previously identified two turning points (300, 400) and (600, 500), connecting them sequentially as (0, 300) → (300, 400) → (600, 500) → (1023, 500). Finally, this sequence is refined to remove any potentially isolated noise points, generating the final complete boundary point sequence containing approximately 15 keypoints.
[0045] In step S15, the weld area is divided according to the complete boundary point sequence, and the gray-level gradient within the weld area is analyzed to classify defects in abnormal areas and obtain defect location results, including: Based on the complete sequence of boundary points, the weld region is divided into multiple weld sub-regions; Calculate the grayscale gradient value of each weld sub-region, and mark the sub-regions whose grayscale gradient values exceed a preset gradient threshold as abnormal regions; Feature points are extracted from the abnormal region and classified to obtain a set of defect types; Based on the set of defect types and combined with curvature calculation analysis of the abnormal region, the microcracks related to the inflection point are marked to obtain the defect location result.
[0046] In one implementation, the system segments the weld region based on the closed region enclosed by the complete sequence of boundary points generated in S14. This segmentation can employ a grid-based partitioning method to divide the weld region into multiple weld sub-regions of equal size for subsequent fine-grained inspection.
[0047] It should be noted that the system calculates the grayscale gradient values of all pixels within each weld sub-region to quantify the severity of grayscale changes in that region. Subsequently, the calculated grayscale gradient values are compared with a preset gradient threshold. The process of determining the gradient threshold includes: acquiring a large number of defect-free weld sample images and calculating the grayscale gradient values of all their sub-regions; calculating the average and standard deviation of all these normal gradient values; and, based on the statistical principle of "3-sigma," determining the result of "average + 3 times the standard deviation" as the preset gradient threshold. If the grayscale gradient value of a sub-region exceeds this threshold, the system marks that sub-region as an abnormal region containing potential defects.
[0048] In another implementation, the system extracts feature points with abrupt changes in grayscale gradients from all labeled anomalous regions and classifies these feature points. This processing is implemented using a pre-trained convolutional neural network (CNN) model. It should be noted that the construction and training process of the CNN model includes: A training dataset containing a large number of labeled weld defect image patches is obtained. This dataset is created by collecting thousands of weld images under different lighting and angles, and based on physical inspection results, domain experts accurately label areas such as "cracks," "porosity," "slag inclusions," and "normal" on the images, producing image patch samples with clear classification labels. Preferably, the data scale can be further expanded and the model's generalization ability improved by performing data augmentation processing such as rotation, flipping, brightness, and contrast adjustments on the images in the training dataset.
[0049] Construct a convolutional neural network structure containing convolutional layers, pooling layers, and fully connected layers. For example, this structure may include: two convolutional layers, each using 32 3×3 convolutional kernels followed by a ReLU activation function; a 2×2 max-pooling layer following each convolutional layer for dimensionality reduction; and finally, a fully connected layer and a softmax output layer to map the extracted features to the final defect category probability.
[0050] Supervised learning is employed for model training. The training dataset is input into the constructed network model, and the error between the model's predicted class and the true label is calculated using the cross-entropy loss function. The backpropagation algorithm, driven by the Adam optimizer, iteratively adjusts the network weights. Training terminates when the model's loss value on the independent validation set converges and falls below a preset convergence threshold, resulting in the pre-trained convolutional neural network model. It should be noted that the convergence threshold is determined through offline experiments after balancing model prediction accuracy and training cost; its value is chosen to ensure sufficient model convergence while avoiding overfitting (e.g., 0.01).
[0051] The model receives the feature points and their neighborhood image patches as input, and outputs a classification label that can characterize the specific type of defect, thus obtaining the defect type set.
[0052] It is worth noting that the system performs further refined analysis of the abnormal regions based on the set of defect types. If an abnormal region is initially classified as a crack, the system analyzes the geometry of the feature points within that region by combining curvature calculations. This analysis identifies and marks the turning points in the crack path by calculating the angular changes of the paths formed by the feature points within the region. In particular, when the abnormal region is close to the weld turning point determined by S11, this method can effectively mark micro-cracks that are difficult to detect by conventional methods, ultimately generating the defect location result containing precise location and type.
[0053] For example, a weld region enclosed by a sequence of boundary points is divided into multiple 50×50 pixel sub-regions. The system calculates and finds that the grayscale gradient value of one of the sub-regions reaches 80, exceeding the preset gradient threshold of 50 determined based on historical data, and therefore marks it as an abnormal region. By inputting the feature point image patch within this abnormal region into a pre-trained CNN model, the model outputs that its defect type is a crack. Since this region is close to a known weld inflection point, the system further initiates curvature calculation analysis and finds a significant angular change between pixels (220, 320) and (225, 325), thus accurately marking this location as the location of a micro-crack and including it in the final defect location result.
[0054] In step S16, the defect region boundary is extracted from the defect location result, and the defect region is enclosed using a minimum bounding rectangle to determine the final evaluation range, including: The defect region in the defect location result is subjected to boundary tracking processing to obtain a sequence of defect boundary points; Calculate the minimum bounding rectangle surrounding the defect region based on the defect boundary point sequence; If the minimum bounding rectangle contains a turning point, then gray-level gradient calculation is performed within the minimum bounding rectangle to identify abnormal feature points; The final evaluation range is determined by dividing the range based on the abnormal feature points.
[0055] In one implementation, the system performs boundary tracing processing on each independent defect region in the defect localization result obtained in S15. It should be noted that this processing can be implemented using a contour tracing algorithm: this algorithm starts from any pixel on the defect region boundary, checks its eight neighboring pixels in a clockwise direction, and takes the first neighboring pixel that also belongs to the boundary as the next point in the sequence; the system iteratively executes this checking and connection process until the tracing path returns to the starting point, transforming the defect region into an ordered sequence of defect boundary points. Subsequently, the system calculates the minimum enclosing rectangle that can completely enclose the sequence based on the coordinate range of all points in the defect boundary point sequence.
[0056] It is worth noting that the system will further analyze the minimum bounding rectangle to check whether the area it covers contains the inflection points marked in step S12. It should be noted that if the minimum bounding rectangle does indeed contain inflection points, the system will trigger a refined detection process. This process performs grayscale gradient calculation again within the small area of the minimum bounding rectangle to identify more precise abnormal feature points related to complex defect morphologies such as microcracks.
[0057] In another implementation, the system divides the area based on the finally identified anomalous feature points. It should be noted that this division process includes: using density-based spatial clustering to automatically aggregate anomalous feature points with a distance less than a preset distance threshold into one or more point clusters; the preset distance threshold is determined based on statistical analysis of the physical dimensions of a large number of historical microcrack samples, and its value matches the maximum normal spacing (e.g., 10 pixels) of feature points within a typical microcrack; for each point cluster, a compact sub-rectangular region surrounding the cluster is determined by calculating the maximum and minimum horizontal and vertical coordinates of all points within the cluster. The set of these sub-rectangular regions constitutes the final evaluation range.
[0058] For example, suppose the system locates a defect and obtains a sequence of 10 defect boundary points through boundary tracing. Based on the coordinate range of this sequence, its minimum bounding rectangle is calculated to be the region from the top left corner (200, 300) to the bottom right corner (220, 310). The system detects a previously marked weld inflection point within this rectangular region and triggers refined detection. By performing local grayscale gradient calculation within the rectangle, a more precise set of anomalous feature points is identified, such as (210, 305) and (215, 308). Finally, the system uses clustering to group these two adjacent feature points into a cluster and calculates the minimum bounding rectangle of this cluster, generating a 5×5 pixel sub-rectangle as the final evaluation range.
[0059] To facilitate understanding of the present invention, some preferred embodiments of the present invention will be described in further detail below.
[0060] In one implementation, the method of the present invention can be applied to an automated vision inspection system deployed at the end of a steel pipe production line to achieve online, high-precision evaluation of the weld quality of pipe fittings. A complete workflow example is as follows: Step one: The system acquires a raw image of the curved weld area (1280×720 pixels) using an industrial camera. Then, the system smooths the image using a 5×5 Gaussian filter kernel and enhances contrast through linear grayscale transformation. Next, a 3×3 convolution kernel is used to calculate the pixel gradient, and based on an intensity threshold of 100 determined from historical data, regions with an intensity greater than 100 in the gradient image are segmented using region growing to obtain a preliminary weld boundary. Finally, the system fits a smooth spline curve based on this boundary and resamples along the curve at intervals of one pixel, obtaining a preliminary contour point set containing approximately 1000 precise coordinate points.
[0061] Step 2: The system processes the initial contour point set, quantifies the curvature of each point by calculating the angle between the vectors formed by three consecutive points in the sequence, and identifies 5 high curvature inflection points based on the preset curvature threshold of 0.7, generating an inflection point annotation set.
[0062] Step 3: The system uses these 5 turning points as the basis for segmentation and performs geometric fitting on the preliminary contour point set to identify that the weld is composed of 3 straight line segments and 2 arc segments.
[0063] Step four: The system analyzes the endpoints of each segment and finds that, under the left-to-right tracking convention, the first endpoint (0, 300) is located at the left boundary of the image, and the last endpoint (1023, 500) is located at the right boundary of the image. Therefore, they are marked as the start point and end point, respectively. The system then integrates and refines the sequence of the start point, end point, and five turning points to generate a complete sequence of boundary points.
[0064] Step five: Based on the complete boundary point sequence, the system divides the weld area into multiple 50×50 pixel sub-regions. Calculations show that one sub-region has a grayscale gradient value of 80, exceeding the preset threshold of 50, and is therefore marked as an abnormal region. The system inputs the image patch of this abnormal region into a pre-trained convolutional neural network (CNN) model, and the model outputs a classification result of "crack".
[0065] Step six: The system evaluates and determines the range of the location result classified as a "crack". First, the system obtains the sequence of boundary points of the crack through contour tracing and calculates its minimum bounding rectangle. The system detects a previously marked weld inflection point within this rectangle, triggering refined detection. By calculating the local grayscale gradient within the rectangle, a more precise set of anomalous feature points is identified. Finally, the system groups these feature points through clustering and calculates a compact 5×5 pixel sub-rectangle as the final evaluation range of the crack.
[0066] In another implementation, the system deployment architecture of this invention can be configured differently. For example, on a fixed production line, the camera, the electronic equipment performing calculations, and the monitoring system can be connected via industrial Ethernet, with all calculations performed on local edge computing nodes to ensure minimal latency. As another example, when inspecting installed pipelines, the detection device can be a portable device that uploads the collected data to a cloud server in real time via wireless networks such as 5G for analysis, and the analysis results are then sent to the mobile terminals of on-site personnel.
[0067] In summary, this invention discloses a machine vision-based method for detecting defects in steel pipe welds, comprising: acquiring raw image data of a curved weld region, performing preprocessing and edge feature extraction to obtain a preliminary contour point set; acquiring a continuous pixel sequence from the preliminary contour point set, calculating the curvature of the continuous pixel sequence, determining inflection points according to a preset curvature threshold, and generating an inflection point annotation set; segmenting the preliminary contour point set according to the inflection point annotation set, fitting straight line segments and arc segments to determine the geometric segmentation structure of the weld; acquiring the endpoints of the geometric segmentation structure, and combining them with the inflection point annotation set to determine the start and end points of the weld boundary, generating a complete boundary point sequence; dividing the weld region according to the complete boundary point sequence, analyzing the grayscale gradient within the weld region, classifying abnormal regions for defects, and obtaining defect location results; extracting the defect region boundary from the defect location results, and using a minimum bounding rectangle to enclose the defect region to determine the final evaluation range. This invention solves the technical problem of low accuracy in detecting defects in steel pipe welds by constructing a complete technical process from precise geometric analysis of complex weld contours to contour-based targeted defect detection and refined evaluation.
[0068] Reference Figure 2 The second embodiment of the present invention provides a machine vision-based steel pipe weld defect detection system, comprising: The image acquisition and processing module is used to acquire the original image data of the curved weld area, and perform preprocessing and edge feature extraction to obtain a preliminary contour point set; The inflection point identification module is used to obtain a continuous pixel sequence from the preliminary contour point set, calculate the curvature of the continuous pixel sequence, determine the inflection point according to the preset curvature threshold, and generate an inflection point annotation set. The geometric structure segmentation module is used to segment the preliminary contour point set according to the inflection point annotation set, and fit straight line segments and arc segments to determine the geometric segmentation structure of the weld. The boundary sequence generation module is used to obtain the endpoints of the geometric segmentation structure and, in conjunction with the inflection point annotation set, determine the start and end points of the weld boundary to generate a complete boundary point sequence. The defect detection module is used to divide the weld area according to the complete boundary point sequence, analyze the gray-scale gradient within the weld area, classify defects in abnormal areas, and obtain defect location results. The defect assessment module is used to extract the defect region boundary from the defect location results and enclose the defect region with a minimum bounding rectangle to determine the final assessment range.
[0069] It should be noted that the machine vision-based steel pipe weld defect detection system provided in this embodiment of the invention is used to execute all the process steps of the machine vision-based steel pipe weld defect detection method in the above embodiment. The working principles and beneficial effects of the two are one-to-one, so they will not be described again.
[0070] This invention also provides an electronic device. The electronic device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a machine vision-based steel pipe weld defect detection program. When the processor executes the computer program, it implements the steps described in the various machine vision-based steel pipe weld defect detection method embodiments above, for example... Figure 1 The step S11 shown. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the above-described device embodiments, such as the image acquisition and processing module.
[0071] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.
[0072] The electronic device may be a desktop computer, laptop, handheld computer, or smart tablet, etc. The electronic device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. It may include more or fewer components than described above, or combine certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0073] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the electronic device, connecting all parts of the electronic device via various interfaces and lines.
[0074] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0075] Wherein, if the modules / units integrated in the electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0076] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0077] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A method for detecting defects in steel pipe welds based on machine vision, characterized in that, include: The original image data of the curved weld area is acquired, and preprocessed and edge feature extracted to obtain a preliminary contour point set; A continuous pixel sequence is obtained from the initial contour point set, and the curvature of the continuous pixel sequence is calculated. Turning points are determined according to a preset curvature threshold, and a turning point annotation set is generated. The preliminary contour point set is segmented according to the inflection point annotation set, and straight line segments and arc segments are fitted to determine the geometric segmentation structure of the weld. Obtain the endpoints of the geometric segment structure and, in conjunction with the inflection point annotation set, determine the start and end points of the weld boundary to generate a complete boundary point sequence. The weld seam region is divided according to the complete boundary point sequence, and the gray-scale gradient within the weld seam region is analyzed to classify defects in abnormal regions and obtain defect location results. Extract the defect region boundary from the defect location results, and use the minimum bounding rectangle to enclose the defect region to determine the final evaluation range.
2. The method for detecting defects in steel pipe welds based on machine vision according to claim 1, characterized in that, The process of acquiring the original image data of the curved weld area, performing preprocessing and edge feature extraction to obtain a preliminary contour point set includes: The original image data of the curved weld area is acquired, and the original image data is smoothed to obtain a first image; The first image is enhanced by grayscale transformation to obtain the second image; Calculate the pixel gradient of the second image to obtain a third image of the edge intensity distribution; The regions in the third image with edge strength greater than a preset strength threshold are segmented to obtain a fourth image of the weld region; The preliminary contour point set is obtained by fitting a smooth contour curve to the weld boundary in the fourth image and resampling the smooth contour curve.
3. The method for detecting defects in steel pipe welds based on machine vision according to claim 1, characterized in that, The step of obtaining a continuous pixel sequence from the initial contour point set, calculating the curvature of the continuous pixel sequence, determining inflection points based on a preset curvature threshold, and generating an inflection point annotation set includes: The pixel coordinates in the preliminary contour point set are sorted according to their adjacency relationship to obtain an ordered set of pixel sequences. By calculating the angular changes of adjacent pixels in the ordered pixel sequence set, the curvature value of each pixel is determined, and a curvature distribution set is obtained. The pixels corresponding to curvature values greater than a preset curvature threshold in the curvature distribution set are marked as inflection points, thus obtaining the inflection point annotation set.
4. The method for detecting defects in steel pipe welds based on machine vision according to claim 1, characterized in that, The step of segmenting the preliminary contour point set according to the inflection point annotation set, and fitting straight line segments and arc segments to determine the geometric segmentation structure of the weld includes: Perform straight line feature detection on the preliminary contour point set to identify collinear pixels and obtain a set of straight line segment pixels; For the non-collinear pixels in the initial contour point set, perform arc fitting processing to obtain a set of arc segment pixels; By combining the set of pixel points for the straight line segment, the set of pixel points for the arc segment, and the set of annotations for the turning points, the geometric segmentation structure of the weld is determined.
5. The method for detecting defects in steel pipe welds based on machine vision according to claim 1, characterized in that, The process of obtaining the endpoints of the geometric segmentation structure and, in conjunction with the inflection point annotation set, determining the start and end points of the weld boundary to generate a complete boundary point sequence includes: The endpoints of each segment are obtained from the geometric segmentation structure, resulting in a set of endpoint coordinates; Determine the positional relationship between each endpoint in the endpoint coordinate set and the image boundary, and mark the endpoints on the image boundary as the start point and the end point, thus obtaining the start point set and the end point set; The set of starting points, the set of ending points, and the set of turning point labels are sequentially integrated, and the continuity of the integrated sequence is refined to obtain the complete boundary point sequence.
6. The method for detecting defects in steel pipe welds based on machine vision according to claim 1, characterized in that, The process of dividing the weld seam region based on the complete boundary point sequence, analyzing the grayscale gradient within the weld seam region, classifying abnormal regions for defects, and obtaining defect location results includes: Based on the complete sequence of boundary points, the weld region is divided into multiple weld sub-regions; Calculate the grayscale gradient value of each weld sub-region, and mark the sub-regions whose grayscale gradient values exceed a preset gradient threshold as abnormal regions; Feature points are extracted from the abnormal region and classified to obtain a set of defect types; Based on the set of defect types and combined with curvature calculation analysis of the abnormal region, the microcracks related to the inflection point are marked to obtain the defect location result.
7. The method for detecting defects in steel pipe welds based on machine vision according to claim 1, characterized in that, The step of extracting the defect region boundary from the defect location result and enclosing the defect region with a minimum bounding rectangle to determine the final evaluation range includes: The defect region in the defect location result is subjected to boundary tracking processing to obtain a sequence of defect boundary points; Calculate the minimum bounding rectangle surrounding the defect region based on the defect boundary point sequence; If the minimum bounding rectangle contains a turning point, then gray-level gradient calculation is performed within the minimum bounding rectangle to identify abnormal feature points; The final evaluation range is determined by dividing the range based on the abnormal feature points.
8. A machine vision-based system for detecting defects in steel pipe welds, characterized in that, include: The image acquisition and processing module is used to acquire the original image data of the curved weld area, and perform preprocessing and edge feature extraction to obtain a preliminary contour point set; The inflection point identification module is used to obtain a continuous pixel sequence from the preliminary contour point set, calculate the curvature of the continuous pixel sequence, determine the inflection point according to the preset curvature threshold, and generate an inflection point annotation set. The geometric structure segmentation module is used to segment the preliminary contour point set according to the inflection point annotation set, and fit straight line segments and arc segments to determine the geometric segmentation structure of the weld. The boundary sequence generation module is used to obtain the endpoints of the geometric segmentation structure and, in conjunction with the inflection point annotation set, determine the start and end points of the weld boundary to generate a complete boundary point sequence. The defect detection module is used to divide the weld area according to the complete boundary point sequence, analyze the gray-scale gradient within the weld area, classify defects in abnormal areas, and obtain defect location results. The defect assessment module is used to extract the defect region boundary from the defect location results and enclose the defect region with a minimum bounding rectangle to determine the final assessment range.
Citation Information
Patent Citations
Weld joint surface defect detection method and equipment based on machine vision and medium
CN114693610A
Special-shaped screen defect detection method and device, equipment and storage medium
CN119477864A
Workpiece welding line undercut defect identification processing method and system based on visual image detection
CN120451088A
Correcting rule violations in a layout
US20250189885A1
Cited By
Weld joint surface defect intelligent detection method and equipment
CN121861037A
A method and apparatus for intelligent detection of weld surface defects
CN121861037B
