Workpiece welding line undercut defect identification processing method and system based on visual image detection
Through visual image detection technology, welded edge detection and horizontal set methods are used to accurately identify welding edge defects, solving the problems of low efficiency and poor accuracy in traditional methods, and achieving efficient edge defect detection.
Patent Information
- Application Number
- CN202510532733.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-04-25
AI Technical Summary
In the detection of welding defects, especially in the identification of undercut defects, there are problems such as low efficiency, high cost and difficult to accurately identify. In particular, traditional methods have poor recognition of subtle defects, which can easily lead to missed detection or misjudgment.
Using a method based on visual image detection, the processing part images are preprocessed, edge detection, curve smoothing, curvature calculation and level set methods, abnormal points are selected, and symmetric deviation indicators are calculated to accurately locate and segment the undercut area.
It improves the accuracy of identification of undercut defects, reduces errors, can effectively capture real area boundaries, avoid global analysis covering up detailed defects, and improves detection accuracy and reliability.
Smart Images

Figure CN120451088A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of welding, and in particular to a method and system for identifying and processing weld undercut defects of a workpiece based on visual image detection. Background Art
[0002] With the development of modern industry, welding, as a key process for joining metal materials, occupies an extremely important position in the manufacturing industry. However, various defects that may occur during welding, such as undercuts and weld bumps, seriously affect the quality and service life of welded parts, and may even lead to serious safety accidents. Therefore, how to effectively detect and identify these welding defects has become a key issue in welding quality control.
[0003] Traditional methods for detecting weld defects rely primarily on manual inspection or nondestructive testing techniques such as X-rays and ultrasound. While these methods can detect weld defects to a certain extent, they are generally inefficient, costly, and highly dependent on operator experience. Furthermore, traditional methods can struggle to accurately identify subtle defects, leading to missed detections or misjudgments.
[0004] In recent years, with advances in computer vision and image processing algorithms, automated weld defect detection using digital image processing has become a research hotspot. In particular, the application of edge detection algorithms has made weld area extraction from workpiece surface images more accurate and efficient. For example, classic edge detection algorithms such as the Canny operator have been widely used to extract target contours, providing a foundation for subsequent defect analysis.
[0005] Despite this, existing technologies still have shortcomings when it comes to identifying specific welding defects, such as undercuts. For one thing, simple edge detection cannot effectively distinguish between normal weld lines and defective areas. Furthermore, one of the commonly used defect calculation algorithms is based on morphological processing and geometric feature analysis. These methods analyze the shape, size, and distribution of objects in an image for defect detection, but lack effective feature parameters to accurately determine the presence and severity of undercuts. Therefore, developing a method that can accurately identify and quantify undercuts is crucial for improving welding quality control. Summary of the Invention
[0006] The purpose of the present invention is to provide a method and system for identifying and processing weld undercut defects of workpieces based on visual image detection, which solves the above-mentioned technical problems pointed out in the prior art.
[0007] The present invention provides a method for identifying and processing weld undercut defects of a workpiece based on visual image detection, comprising the following steps:
[0008] Collect images of the workpiece, pre-process the images of the workpiece, and obtain images to be inspected;
[0009] Performing edge detection analysis on the image to be detected to obtain a weld mark area of the image to be detected;
[0010] Performing curve smoothing on the weld mark area to obtain sampling points; calculating the total arc length of the weld mark area based on the sampling points, calculating the curvature of each sampling point based on the total arc length, and screening abnormal points based on the curvature of the sampling points; forming an undercut area based on the abnormal points, and segmenting the undercut area to calculate a symmetry deviation index;
[0011] Whether there is a bite edge is determined based on the symmetry deviation index.
[0012] Preferably, the weld mark area is smoothed to obtain sampling points; and the total arc length of the weld mark area is calculated based on the sampling points. The specific operation steps are as follows:
[0013] The weld mark area is smoothed by using curve restoration to obtain s1, s2, ..., sn sampling points;
[0014] Connect each adjacent sampling point with a straight line to obtain an approximate curve; calculate the Euclidean distance between adjacent sampling points in the approximate curve as the arc length increment between the sampling points;
[0015] The arc length increment of each sampling point from sampling point s1 to sampling point sn is calculated to obtain the total arc length of the approximate curve.
[0016] Preferably, the curvature of each sampling point is calculated by the total arc length, and abnormal points are screened based on the curvature of the sampling points. The specific operation steps are as follows:
[0017] Calculating the equation of the circle using least squares circle fitting for each sampling point in the front and rear neighborhoods of each sampling point in the two-dimensional parametric curve;
[0018] And calculate the sum of the squares of the distances from all neighborhood sampling points to the sampling points of the circle;
[0019] Calculate the curvature of the sampling point based on the square sum of the distances and the equation of the circle;
[0020] and calculating the curvature of all sampling points to obtain the curvature distribution of the two-dimensional parametric curve;
[0021] Taking the sampling point as the center point, calculating the average curvature of each sampling point in the front and back neighborhood of the sampling point, and further calculating the curvature standard deviation of the average curvature of each sampling point in the front and back neighborhood;
[0022] Set the asymmetric threshold of the outlier point, and check whether the curvature standard deviation of each sampling point in the front and back neighborhood of the sampling point is less than the asymmetric threshold of the outlier point;
[0023] If so, it is determined that the curvatures of the sampling points in the front and rear neighborhoods of the sampling point fluctuate, and the points are regarded as abnormal points.
[0024] Preferably, the undercut area is formed by the abnormal points, and the undercut area is segmented to calculate the symmetric deviation index, including: using the level set method to calculate the convex hull boundary of the abnormal points, and taking the coverage range of the convex hull boundary as the candidate undercut area; obtaining the level set function of the approximate curve for the candidate undercut area; calculating the energy function for the inside and outside of the candidate undercut area through the approximate curve; updating the level set function through the energy function to find the undercut area; segmenting the undercut area into sub-areas, and calculating the symmetric deviation index through the edge contour of the sub-area.
[0025] Preferably, the convex hull boundary of the outlier point is calculated using the level set method, and the coverage of the convex hull boundary is used as the candidate undercut area; an approximate curve is obtained for the candidate undercut area to calculate the level set function, and the specific operation steps are as follows:
[0026] The convex hull boundary of the screened outliers is calculated using the level set method. The outliers are then used to cover the pixels in the surrounding neighborhood until all outliers completely cover the pixels in the surrounding neighborhood. The area covered by each outlier is used as a candidate undercut area.
[0027] Obtain an approximate curve for each candidate undercut area;
[0028] Counting the number of pixels inside and outside the approximate curve for each candidate undercut region; calculating the distance from the pixel points inside and outside the approximate curve of each candidate undercut region to the boundary of the approximate curve, and combining the calculated boundary distances of the pixel points inside and outside the approximate curve to form a level set function;
[0029] The level set function represents a partitioning function between the inside and the outside of the approximate curve of the candidate undercut region.
[0030] Preferably, an energy function is calculated for the inside and outside of the candidate undercut region using the approximate curve; the level set function is updated using the energy function, thereby finding the undercut region. The specific operation steps are as follows:
[0031] Calculating the inner average grayscale value and the outer average grayscale value of the pixel points inside and outside the approximate curve of the candidate undercut region respectively;
[0032] Calculating the curvature of an approximate curve of the candidate undercut region;
[0033] The finite difference method is used to calculate the average grayscale difference between the inner average grayscale value and the outer average grayscale value of the approximate curve of the candidate biting area, which is used as the grayscale driving force;
[0034] Searching for an outlier point with a maximum curvature and an outlier point with a minimum curvature on an approximate curve of the candidate undercut region, smoothing the outlier point corresponding to the maximum curvature and the outlier point with a minimum curvature after smoothing as a curvature driving force;
[0035] Calculating the grayscale driving force and the curvature driving force to obtain an energy function;
[0036] The energy function is expressed as a segmentation state of an approximate curve of the candidate undercut region using a level set function.
[0037] Preferably, the level set function is updated by an energy function to find the undercut region; the undercut region is divided into subregions, and the symmetry deviation index is calculated by the edge contours of the subregions. The specific operation steps are as follows:
[0038] Initializing the level set function of the candidate undercut region; and quantizing the energy function using a gradient descent method according to the grayscale driving force and the curvature driving force, so as to update the level set function;
[0039] Preset the function update threshold p and determine whether the updated level set function is equal to the function update threshold p;
[0040] If so, it is determined that the updated level set function finds the undercut region;
[0041] If not, the level set function is iteratively updated until the updated level set function is equal to the function update threshold p;
[0042] The undercut area is divided into sub-areas by using a segmentation algorithm, boundary points of edge contours of the sub-areas are discretized, and symmetry deviation indicators are calculated through the boundary points of the sub-areas.
[0043] Preferably, a segmentation algorithm is used to segment the undercut area into sub-areas, the boundary points of the edge contour of the sub-areas are discretized, and the symmetry deviation index is calculated based on the boundary points of the sub-areas. The specific operation steps are as follows:
[0044] Using a segmentation algorithm to segment the undercut region into four sub-regions: a first sub-region, a second sub-region, a third sub-region, and a fourth sub-region;
[0045] The sub-region is a horizontal segmentation of the undercut region, and then a center point on the horizontal segmentation line is found, and then the sub-region is segmented longitudinally along the center point;
[0046] The first and second sub-regions of the divided undercut region are adjacent to each other in the left and right directions, and the third and fourth sub-regions are adjacent to each other in the left and right directions; the first and second sub-regions and the third and fourth sub-regions are adjacent to each other in the top and bottom directions;
[0047] Extracting edge contours from each sub-region to obtain a contour boundary of each sub-region, and discretizing the contour boundary into a plurality of continuous boundary points;
[0048] Calculating the overall offset of the weld pattern and the coefficient of variation of the weld pattern edge for a longitudinal dividing line formed by longitudinally dividing a plurality of consecutive boundary points of each sub-region along the center point;
[0049] The ratio of the first sub-region to the second sub-region and the ratio of the third sub-region to the fourth sub-region are compared through the weld line edge variation coefficient of each sub-region and the overall weld line offset to obtain a symmetry deviation index.
[0050] Preferably, the overall offset of the weld mark and the coefficient of variation of the weld mark edge are calculated for a longitudinal dividing line formed by longitudinally dividing a plurality of consecutive boundary points of each sub-region along the center point. The specific operation steps are as follows:
[0051] Calculate the centroid coordinates of the boundary points of the left and right contours of each sub-region, and then connect the centroid coordinates of the boundary points of the left and right contours with a straight line as the ideal center line;
[0052] Using the transverse dividing line to search for a parallel ideal center line, and calculating the distance from the parallel ideal center line to the transverse dividing line, and selecting the parallel ideal center line with the minimum distance as the optimal center line;
[0053] The boundary points of the upper and lower contour boundaries of each sub-region are vertically connected to the optimal center line, and the vertical distances between the boundary points of the upper and lower contour boundaries are calculated;
[0054] According to the vertical distances of the boundary points of all upper and lower contour boundaries, find the vertical distance with the smallest sum of vertical distances as the overall offset of the weld pattern.
[0055] Preferably, the calculation of the weld edge variation coefficient is carried out in the following specific steps:
[0056] The overall offset of the weld pattern of the boundary points is sorted using the interquartile range, and the average of the overall offset of the weld pattern of the middle boundary points is calculated as the median of the overall offset of the weld pattern of the boundary points;
[0057] Calculate the average value of the overall offset of the weld pattern at the middle boundary points of the first half through the middle boundary points, and use it as the first quartile;
[0058] The average value of the overall offset of the weld pattern at the middle boundary point in the second half of the middle boundary point is calculated as the third quartile;
[0059] The interquartile range is calculated by using the first quartile and the third quartile;
[0060] The median and interquartile range of the overall offset of the weld mark at the boundary point are calculated to obtain a dimensionless index as the weld mark edge variation coefficient.
[0061] Compared with the prior art, the embodiments of the present invention have at least the following technical advantages:
[0062] From the analysis of the above-mentioned method and system for identifying and processing weld undercut defects of workpieces based on visual image detection provided by the present invention, it can be seen that in specific applications, curve restoration is used to smooth the curve of the weld mark area to obtain sampling points; an approximate curve of the weld mark area is obtained based on the connection of the sampling points, reflecting the shape and contour curvature of the weld mark area; and the total arc length of the approximate curve of the weld mark area is further calculated to understand the contour length of the weld mark area; the curvature and curvature distribution of the sampling point are calculated by the total arc length of the approximate curve, and the curvature degree of the curve along different positions can be understood through the calculated curvature and curvature distribution, thereby improving the accuracy of extracting abnormal points of the undercut and avoiding errors; and based on the curvature and curvature distribution of the sampling point, the curvature fluctuation of each sampling point in the neighborhood before and after the sampling point is judged to see whether there may be asymmetric changes, thereby screening out abnormal points;
[0063] Furthermore, the level set method is used to perform convex hull boundary analysis on the outliers, and the area not covered by the convex hull boundary is used as the initial candidate bite edge area. After the outliers are covered by the neighborhood, isolated outliers that may have errors can also be captured, thereby improving the capture rate of the real area boundary; and the boundary distance of the internal and external pixels of the approximate curve of the candidate bite edge area is calculated to reflect the spatial distribution of the pixels inside and outside the candidate bite edge area; the level set function is calculated by the boundary distance to reflect the segmentation state of the approximate curve, that is, the bite edge area of the real boundary; the grayscale driving force is obtained by grayscale calculation of the internal and external pixels of the approximate curve to reflect the background and foreground of the bite edge area; the curvature driving force is calculated by the curvature of the approximate curve to reflect the rule of the contour; and the energy function is calculated by the curvature driving force and the grayscale driving force to reflect the shape and other information of the candidate bite edge area; and the energy function is updated by the level set function to find the bite edge area;
[0064] Furthermore, the segmentation algorithm is used to segment the undercut area to obtain sub-areas to avoid the risk of global analysis covering up detail defects; the edge contour of each sub-area is extracted to extract boundary points, capture the edge variation coefficient of the weld mark and the overall offset of the weld mark to reflect the irregularity and local fluctuation of the sub-area, and further calculate the symmetry deviation index to reflect the abnormal undercut occurring in a certain local area. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 This is the main process of a method for identifying and processing weld undercut defects of a workpiece based on visual image detection in Example 1;
[0066] Figure 2 This is a flow chart of obtaining a symmetry deviation index for a method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to Example 1;
[0067] Figure 3 This is a flow chart of a method for identifying and processing weld undercut defects of a workpiece based on visual image detection in accordance with the first embodiment, which includes obtaining a symmetric deviation index of an undercut region according to a level set function;
[0068] Figure 4 Schematic diagram of the segmentation form of the level set function of a method for identifying and processing weld undercut defects of a workpiece based on visual image detection in Example 1;
[0069] Figure 5 This is a flow chart of a method for identifying and processing weld undercut defects of a workpiece based on visual image detection in accordance with the first embodiment, which obtains a symmetry deviation index by segmenting the undercut area;
[0070] Figure 6 Schematic diagram of sub-regions of a method for identifying and processing weld undercut defects of a workpiece based on visual image detection in Example 1;
[0071] Figure 7 This is a flow chart of the overall offset of the weld line and the coefficient of variation of the weld line edge of a method for identifying and processing weld line undercut defects of a workpiece based on visual image detection in Example 1;
[0072] Figure 8 This is a main flow chart of undercut analysis of a method for identifying and processing undercut defects in weld lines of workpieces based on visual image detection in Example 1;
[0073] Figure 9 This is a flow chart of a system for identifying and processing weld undercut defects of a workpiece based on visual image detection according to Example 2.
[0074] Reference numerals: acquisition module 10 ; weld mark module 20 ; analysis module 30 ; judgment module 40 . DETAILED DESCRIPTION
[0075] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0076] The present invention will be further described in detail below through specific embodiments in conjunction with the accompanying drawings.
[0077] Example 1
[0078] like Figure 1 As shown, the present application provides a method for identifying and processing weld undercut defects of a workpiece based on visual image detection, comprising the following steps:
[0079] S1: Collect images of the workpiece, pre-process the images of the workpiece, and obtain images to be inspected;
[0080] S2: Analyzing the image to be detected using an edge detection algorithm to obtain a weld mark area of the image to be detected;
[0081] It should be noted that the edge detection algorithm (such as the Canny operator) is used to extract the weld from the image to be inspected to obtain the weld mark area. The edge detection algorithm is well known and will not be described in detail.
[0082] S3: Smoothing the weld mark area to obtain sampling points; calculating the total arc length of the weld mark area based on the sampling points, calculating the curvature of each sampling point based on the total arc length, and screening abnormal points based on the curvature of the sampling points; forming an undercut area based on the abnormal points, and segmenting the undercut area to calculate a symmetry deviation index;
[0083] It should be noted that the edges of the welding area are smoothed to obtain discrete but continuous sampling points, which helps to remove noise and local mutations and obtain a more accurate contour shape; the sampling points are used to calculate the arc length of the entire weld, and the curvature of each sampling point is calculated based on the arc length. The curvature mutation often corresponds to the local edge depression or protrusion (i.e., undercut); by screening abnormal points, these abnormalities are combined into potential undercut areas, and these areas are further segmented and the symmetry deviation index is calculated. The symmetry deviation index is the symmetry of the segmented area after the undercut area is segmented. Under normal circumstances, the weld edge should be continuous, smooth and show a certain degree of symmetry, so as to obtain the symmetry deviation index to judge whether there is an undercut with obvious local curve depression or abnormal curvature;
[0084] S4: judging whether there is a biting edge according to the symmetry deviation index.
[0085] It should be noted that judging whether there is an undercut according to the symmetry deviation index specifically includes the following steps: presetting a symmetry threshold f, judging whether the symmetry deviation index is greater than or equal to the preset symmetry threshold f; if not, judging that there is no undercut abnormality in the workpiece; if so, judging that there is a change abnormality in the workpiece; using the coefficient of variation of the weld edge and the overall offset of each sub-region (obtained by local segmentation) calculated in S3, calculating the symmetry deviation index by ratio, and statistically quantifying the symmetry between each region;
[0086] When the symmetry deviation index exceeds the set threshold, it indicates that the local weld edge is obviously asymmetric due to undercut or other defects, thus making a detection judgment that an undercut defect exists; an ideal weld should have good symmetry, and local geometric features (such as the coefficient of variation and offset of the edge) should be relatively consistent between different sub-areas to avoid global averaging to mask subtle defects, thereby improving the accuracy of detection.
[0087] Specifically, if Figure 2 As shown, in step S3, the weld mark area is smoothed to obtain sampling points; the total arc length of the weld mark area is calculated based on the sampling points, the curvature of each sampling point is calculated based on the total arc length, and abnormal points are screened for the curvature of the sampling points; the undercut area is formed based on the abnormal points, and the undercut area is segmented to calculate the symmetry deviation index. The specific operation steps are as follows:
[0088] S31: smoothing the weld mark area using curve restoration to obtain s1, s2, ..., sn sampling points;
[0089] Connect each adjacent sampling point with a straight line to obtain an approximate curve; calculate the Euclidean distance between adjacent sampling points in the approximate curve as the arc length increment between the sampling points;
[0090] Calculate the arc length increment of each sampling point from sampling point s1 to sampling point sn to obtain the total arc length of the approximate curve;
[0091] It should be noted that curve restoration (i.e., curve restoration refers to the process of reconstructing an original or ideal continuous curve from discrete, possibly noisy or incomplete sampling data, with the goal of restoring a smooth, continuous curve that is more consistent with the shape of the actual object based on these discrete points) is used to smooth the weld mark area and the contour area to obtain s1, s2...sn sampling points; at the same time, a straight line is connected between each sampling point to obtain an approximate curve, that is, the contour of the weld mark area, and the weld mark area of the workpiece with different contours is also identified through the approximate curve (i.e., due to the shape of the workpiece itself or the angle of the welding point, different welding contours may appear during welding, which makes it difficult to identify the undercut of these welding contours. Therefore, the approximate curve can increase the accuracy of identifying the undercut of the weld mark area of the workpiece with different contours), thereby increasing the accuracy of identifying the undercut of the weld mark area of the workpiece with different contours;
[0092] And by calculating the Euclidean distance between the sampling points, the arc length of each sampling point of the approximate curve can be understood, that is, the arc length increment can be used to judge the degree of tortuosity of the approximate curve (that is, ). By calculating the arc length increment of each sampling point on the way from the sampling point s1 to the sampling point sn, the tortuous path of each sampling point can be understood. The total arc length of the weld mark area, that is, the length of the contour of the weld mark area, can be obtained by the final arc length increment from s1 to sn.
[0093] S32: parameterizing the incremental arc length of each sampling point of the total arc length of the approximate curve, mapping the sampling points into two-dimensional parameters, and constructing a two-dimensional parametric curve using the mapping parameters of each sampling point;
[0094] It should be noted that the total arc length of the approximate curve is parameterized by the incremental arc length, that is, according to the incremental arc length of each sampling point accumulated by the approximate curve, each sampling point si is mapped to a two-dimensional parameter (ui, vi), where ui is the incremental arc length of the sampling point si, and vi is the corresponding coordinate of the sampling point si; a two-dimensional parametric equation is constructed through the two-dimensional parameters of each sampling point, that is, a two-dimensional parametric curve; the parameterization of the incremental arc length can avoid the problem of uneven parameter distribution caused by the non-smoothness of the approximate curve, and make the final two-dimensional parametric curve smoother;
[0095] S33: Calculating the equation of a circle (i.e., fitting the circle) by least squares circle fitting for each sampling point in the front and rear neighborhood of each sampling point in the two-dimensional parametric curve;
[0096] And calculate the sum of the squares of the distances from all neighborhood sampling points to the sampling points of the circle;
[0097] Calculate the curvature of the sampling point based on the square sum of the distances and the equation of the circle;
[0098] and calculating the curvature of all sampling points to obtain the curvature distribution of the two-dimensional parametric curve;
[0099] Taking the sampling point as the center point, calculating the average curvature of each sampling point in the front and back neighborhood of the sampling point, and further calculating the curvature standard deviation of the average curvature of each sampling point in the front and back neighborhood;
[0100] It should be noted that for each sampling point si on the two-dimensional parametric curve, several sampling points in its front and back neighborhood are taken, and then the least squares method is used to perform circle fitting to obtain the parameters of the best fitting circle in the local area (center, radius, etc.), which effectively describes the curve shape near the sampling point; and further calculate the sum of the squares of the distances from all the sampling points in the neighborhood to the sampling point of the circle as the fitting error. The sum of the squares of the distances is not directly used as a parameter for calculating the curvature of the sampling point, but serves as an auxiliary function to suppress the interference of random noise on the curvature calculation, and is used to verify the reliability of the curvature and avoid misjudging noise or complex shapes as defects; at the same time, the calculated curvature and curvature distribution can be used to understand the degree of curvature of the curve at different positions, thereby improving the accuracy of extracting abnormal points of the bite edge and avoiding errors;
[0101] At the same time, the overall curvature trend of the local area is reflected according to the average curvature of the neighborhood before and after the sampling point, and the standard deviation of the curvature is further calculated to quantify the degree of dispersion of the curvature of all sampling points before and after the sampling point, so as to find the sampling point si with fluctuation before and after (that is, when all the sampling points in the neighborhood before and after the sampling point have fluctuations, it means that the curve of the sampling point may be asymmetric, so the fluctuation of the sampling points before and after will appear), and the sampling point si is regarded as an abnormal point;
[0102] S34: Setting an asymmetric threshold for an outlier point, and checking whether the curvature standard deviation of each sampling point in the front and back neighborhood of the sampling point is less than the asymmetric threshold for an outlier point;
[0103] If yes, then the curvature of each sampling point in the front and back neighborhood of the sampling point is determined to fluctuate, and the points are considered as abnormal points;
[0104] It should be noted that, by setting the asymmetric threshold of the abnormal point as a method for judging whether there is fluctuation in all the sampling points in the neighborhood before and after the sampling point, if the standard deviation of the curvature of each sampling point in the neighborhood before and after the sampling point is greater than or equal to the asymmetric threshold of the abnormal point, it means that the curvature of the sampling point has not changed significantly, and the curvature of each sampling point in the neighborhood before and after the sampling point has not fluctuated; if the standard deviation of the curvature of each sampling point in the neighborhood before and after the sampling point is less than the asymmetric threshold of the abnormal point, it means that the curvature of each sampling point in the neighborhood before and after the sampling point has fluctuated, and there may be asymmetric changes. In the undercut defect of the workpiece, the asymmetry of the weld mark area often indirectly indicates that there is an undercut in the weld mark area. Therefore, the asymmetry of the sampling points can be used to screen out abnormal points that may have an undercut.
[0105] S35: Calculating the convex hull boundary of the outlier using the level set method, and using the coverage of the convex hull boundary as a candidate undercut region; obtaining a level set function of an approximate curve for the candidate undercut region; calculating an energy function for the interior and exterior of the candidate undercut region using the approximate curve; updating the level set function using the energy function to find the undercut region; dividing the undercut region into subregions, and calculating a symmetry deviation index using the edge contours of the subregions;
[0106] It should be noted that it is difficult to directly determine whether scattered abnormal points are valid undercut features individually. Aggregating them through the convex hull boundary ensures that even if there are local discrete anomalies, the overall defect information will not be missed, while reducing the impact of noise. The level set function can express the approximate curve of the candidate undercut region in the form of a continuous function, capturing the details of the true boundary of the region. The minimization of the energy function shows the most obvious difference between the inside and outside of the approximate curve boundary, which is used to guide region segmentation. The level set function is iteratively updated using the energy function, so that the boundary of the initial candidate region gradually converges to the true undercut defect edge. Through energy-driven iterative updates, the boundary can be adaptively adjusted, making the segmentation process more accurate. After segmentation, the edge contour of each subregion is extracted, and then the symmetry deviation index is calculated to statistically measure the geometric consistency between different subregions to ensure sensitive detection of local defects.
[0107] Specifically, if Figure 3As shown, in step S35, the convex hull boundary of the abnormal point is calculated using the level set method, and the coverage of the convex hull boundary is used as the candidate undercut area; an approximate curve is obtained for the candidate undercut area to calculate the level set function; an energy function is calculated for the interior and exterior of the candidate undercut area using the approximate curve; the level set function is updated using the energy function to find the undercut area; the undercut area is divided into sub-areas, and the symmetry deviation index is calculated using the edge contours of the sub-areas. The specific operation steps are as follows:
[0108] S351: Calculating the convex hull boundary of the screened outliers using the level set method. The outliers are covered with pixels in the surrounding neighborhood through the convex hull boundary calculation until all outliers completely cover the pixels in the surrounding neighborhood. The area covered by each outlier is used as a candidate undercut area.
[0109] Obtain an approximate curve for each candidate undercut region (i.e., the approximate curve in step S351 is the outline of the candidate undercut region, which is different from the approximate curve in step S31, which is the outline of the weld mark region; and the method for obtaining the approximate curve of the candidate undercut region is the same as that of the weld mark region in step S31, which will not be repeated here);
[0110] Counting the number of pixels inside and outside the approximate curve for each candidate undercut region; calculating the distance from the pixel points inside and outside the approximate curve of each candidate undercut region to the boundary of the approximate curve, and combining the calculated boundary distances of the pixel points inside and outside the approximate curve to form a level set function;
[0111] The level set function represents the internal and external segmentation function of the approximate curve of the candidate undercut region (that is, the approximate curve itself is converted into a function form, and the level set function is used to reflect whether the true contour of the approximate curve is the undercut region, such as Figure 4 shown);
[0112] It should be noted that the convex hull boundary of the outlier point is calculated using the level set method. Each screened outlier point is processed, and the pixels of its surrounding neighborhood are gradually covered until the local area of all outliers is completely covered. Through the covering operation, the originally discrete or isolated outliers are also covered and transformed into coherent areas, thus forming a continuous set of multiple candidate bite edge areas. After the outliers are covered by the neighborhood, the capture rate of the true area boundary can also be improved for isolated outliers that may have errors.
[0113] For each candidate undercut region covered by the neighboring pixel points, an approximate curve (i.e., the outline of the candidate undercut region) is extracted. The approximate curve here is calculated in the same way as the approximate curve of the weld mark region (in S31), but is targeted at a different target region. By obtaining the approximate curve of the candidate undercut region, the abnormal region can be better described, thereby also determining the shape of the possible undercut.
[0114] By using the approximate curve to distinguish the pixels inside and outside the candidate undercut area, we can understand the segmentation status of the approximate curve for the inside and outside of the candidate undercut area. At the same time, the distance to the nearest boundary is calculated through these pixels, reflecting the spatial distribution of the pixels inside and outside the candidate undercut area. According to the segmentation status and spatial distribution, it is converted into a continuous function to obtain the level set function to reflect the segmentation function of the approximate curve inside and outside the candidate undercut area. Therefore, in order to calculate the boundary distance, the boundary distance reflecting the segmentation status and spatial distribution is used to calculate the level set function.
[0115] S352: Calculating the inner average grayscale value and the outer average grayscale value of the pixel points inside and outside the approximate curve of the candidate undercut region respectively;
[0116] Calculate the curvature of the approximate curve of the candidate undercut region (i.e., the curvature calculation of the approximate curve of the candidate undercut region in step S252 is the same as the curvature calculation step in step S33 above, and will not be repeated here).
[0117] The finite difference method is used to calculate the average grayscale difference between the inner average grayscale value and the outer average grayscale value of the approximate curve of the candidate biting area, which is used as the grayscale driving force;
[0118] Searching for an outlier point with a maximum curvature and an outlier point with a minimum curvature on an approximate curve of the candidate undercut region, smoothing the outlier point corresponding to the maximum curvature and the outlier point with a minimum curvature after smoothing as a curvature driving force;
[0119] Calculating the grayscale driving force and the curvature driving force to obtain an energy function;
[0120] The energy function is represented by a segmentation state of an approximate curve of the candidate undercut region using a level set function;
[0121] It should be noted that the above steps need to calculate the average grayscale value of the pixel points inside and outside the approximate curve of the candidate undercut region respectively, which reflects the contrast between the target region and the background; by calculating the curvature of the approximate curve of the candidate undercut region, the curvature of the approximate curve at each local point can be described; at the same time, by calculating the difference between the average grayscale values of the internal and external pixel points as the grayscale driving force, the approximate curve (i.e., the contour) of the candidate undercut region can be evolved towards the contour of the real undercut region; the introduction of curvature information makes the energy function not only focus on the grayscale contrast, but also consider the geometric smoothness of the region boundary, reduce the scattered segmentation caused by noise, and calculate the curvature driving force (i.e., in the calculation When calculating the curvature driving force, the reason for smoothing the outliers with the maximum curvature is that they may affect the surrounding area, avoiding jagged edges or noise interference. The outliers with the minimum curvature have relatively low noise. Therefore, when the outliers with the maximum curvature are smoothed, they will be close to the outliers with the minimum curvature, thus calculating the curvature driving force. The curvature driving force can eliminate contour irregularities caused by noise or fitting errors. At the same time, the energy function integrates grayscale and geometry (that is, curvature can not only smooth the candidate undercut area, but also reflect the shape of the candidate undercut area) information, providing a unified indicator for evaluating the quality of candidate region segmentation, guiding the contour to evolve towards the optimal segmentation result.
[0122] S353: Initializing the level set function of the candidate undercut region; and quantizing the energy function using the gradient descent method according to the grayscale driving force and the curvature driving force, so as to update the level set function;
[0123] Preset the function update threshold p and determine whether the updated level set function is equal to the function update threshold p;
[0124] If so, it is determined that the updated level set function finds the undercut region;
[0125] If not, the level set function is iteratively updated until the updated level set function is equal to the function update threshold p;
[0126] It should be noted that when the candidate undercut area passes through the convex hull of the approximate curve, the level set function is obtained, that is, the geometric contour (i.e., the approximate curve) is converted into a mathematical function form. When the level set function is equal to 0, the approximate curve is the contour boundary actually required, that is, the contour boundary of the final undercut area; when the level set function is less than or equal to 0, it means that the approximate curve of the level set function may have deviations due to background (i.e., the background is related to the gray value, so the gray value driving force and the curvature driving force are subsequently required to quantize the energy function and update the level set function) or noise. Therefore, the gray driving force and the curvature driving force need to use the gradient descent method to quantize the energy function and update the level set function.
[0127] The gradient descent method is used to adjust the approximate curve along the negative gradient direction of the energy function. The level set function, that is, the energy function is obtained by the gray driving force and the curvature driving force, and the gray driving force and the curvature driving force are the negative gradients of the energy function, indicating in which direction the approximate curve should move (that is, the negative gradient direction calculated by the gradient descent method, and the negative gradient is determined by the driving force, not the energy function) to reduce the energy function, thereby achieving the purpose of updating the level set function; and set the function update threshold p (that is, 0). When the level set function is equal to 0 after the update, the approximate curve no longer changes significantly, and the boundary of the bite area is found; if it is not equal to 0, continue to iterate until the threshold condition is met;
[0128] S354: Segmenting the undercut area into sub-areas using a segmentation algorithm, discretizing boundary points of edge contours of the sub-areas, and calculating a symmetry deviation index using the boundary points of the sub-areas;
[0129] It should be noted that the undercut area is divided into sub-areas through the segmentation algorithm, and the boundaries of the sub-areas are discretized to obtain multiple boundary points. The symmetry deviation index of the adjacent sub-areas on the left and right is calculated based on the boundary points of the sub-areas, so as to judge whether there is an undercut in the subsequent process.
[0130] Specifically, if Figure 5 As shown, in step S354, the undercut area is divided into sub-areas using a segmentation algorithm, the boundary points of the edge contour of the sub-areas are discretized, and the symmetry deviation index is calculated based on the boundary points of the sub-areas. The specific operation steps are as follows:
[0131] S3541: using a segmentation algorithm to segment the undercut region into four sub-regions: a first sub-region, a second sub-region, a third sub-region, and a fourth sub-region;
[0132] The sub-region is a horizontal segmentation of the undercut region, and then a center point on the horizontal segmentation line is found, and then the sub-region is segmented longitudinally along the center point;
[0133] The first and second sub-regions of the divided undercut region are adjacent to each other in the left and right directions, and the third and fourth sub-regions are adjacent to each other in the left and right directions; the first and second sub-regions and the third and fourth sub-regions are adjacent to each other in the top and bottom directions;
[0134] It should be noted that by dividing the overall area into four sub-areas, such as Figure 6 As shown in the figure, the geometric features of each local area can be precisely counted, avoiding the risk of global analysis masking detailed defects. For example, when the overall symmetry of the weld pattern is good, the characteristics of each sub-area (such as edge fluctuation) should be relatively close. However, local anomalies (such as undercut on one side) will lead to significant local deviation after partitioning.
[0135] S3542: Extracting edge contours from each sub-region to obtain a contour boundary of each sub-region, and discretizing the contour boundary into a plurality of continuous boundary points;
[0136] It should be noted that edge contour extraction is performed on each sub-region, and the contour is discretized into several continuous boundary points. The discretized boundary points provide discrete data for subsequent calculations, which can accurately capture the irregularities and local fluctuations of the edge.
[0137] S3543: Calculating the overall offset of the weld mark and the coefficient of variation of the weld mark edge for a longitudinal dividing line formed by longitudinally dividing a plurality of consecutive boundary points of each sub-region along the center point;
[0138] It should be noted that the weld edge variation coefficient can be used to measure the irregularity and fluctuation of the local edge. In symmetry detection, by comparing the weld edge variation coefficients of each sub-region (such as the first sub-region, the second sub-region, the third sub-region, and the fourth sub-region), if the weld has a good symmetrical structure, the characteristics of each sub-region should be similar. If the weld edge variation coefficient of a local region is abnormal, it means that the contour of the sub-region has shifted or changed irregularly, thereby affecting the overall symmetry.
[0139] The overall weld mark offset represents the average deviation of the actual weld mark in the sub-area from the ideal symmetric center line;
[0140] S3544: Compare the ratio of the first sub-region to the second sub-region with the ratio of the third sub-region to the fourth sub-region using the weld line edge variation coefficient and the overall weld line offset of each sub-region to obtain a symmetry deviation index. The calculation formula is:
[0141]
[0142] Q edgeThe symmetry deviation index is expressed as the ratio of the first and second sub-regions compared with the ratio of the third and fourth sub-regions;
[0143] B is a preset adjustment parameter used to adjust the sensitivity of the formula to the comparison value;
[0144] Wj i (i=1, 2, 3, 4) are the weld edge variation (fluctuation) coefficients in the first, second, third, and fourth sub-regions, respectively, reflecting the degree of irregularity of the local edge;
[0145] Δ i ′=Δ i ×G i (i=1, 2, 3, 4) represents the overall offset of the weld after geometric correction, where: Δ i is the average deviation between the weld line and the ideal centerline symmetry line in the i-th sub-region without correction;
[0146] G i is the corresponding geometric correction factor, which is used to eliminate the error caused by perspective or imaging angle;
[0147] It should be noted that the weld line edge variation coefficient and the overall weld line offset obtained in step S3643 are used to calculate the symmetry of the weld line variation coefficient (i.e., fluctuation) and the overall weld line offset (i.e., shape change or irregular symmetry) between the sub-regions (i.e., the first sub-region and the second sub-region, the third sub-region and the fourth sub-region), thereby obtaining a symmetry deviation index to reflect the abnormal undercut occurring in a certain local area.
[0148] Using the ratios between the sub-regions (for example, the characteristic ratios between region 1 and region 2, and region 3 and region 4), under ideal symmetry, these ratios should be close to the same. If there is a significant deviation, it may indicate that a local anomaly (such as undercut) has occurred, which statistically destroys the symmetry of the entire weld. If the weld is absolutely symmetrical, the two ratios should be close to equal. Once an undercut or other defect exists, it usually causes a change in the local geometric characteristics of one side, resulting in a significant difference between the two ratios.
[0149] Specifically, if Figure 7 As shown, in step S3543, the overall offset of the weld pattern and the coefficient of variation of the weld pattern edge are calculated for the longitudinal dividing line formed by longitudinally dividing the plurality of consecutive boundary points of each sub-region along the center point. The specific operation steps are as follows:
[0150] S35431: Calculate the centroid coordinates of the boundary points of the left and right contours of each sub-region, and then connect the centroid coordinates of the boundary points of the left and right contours with a straight line to form the ideal center line;
[0151] Using the transverse dividing line to search for a parallel ideal center line, and calculating the distance from the parallel ideal center line to the transverse dividing line, and selecting the parallel ideal center line with the minimum distance as the optimal center line;
[0152] It should be noted that the centroid coordinates of the left and right contour boundaries of the two-dimensional sub-region are calculated, for example, {(x1, y1), (x2, y2), ..., (x 100 ,y 100 )}(assuming there are 100 points); calculate the centroid: horizontal coordinate mean: The mean of the vertical axis: Left edge centroid: (C x,left , C y,left ), similarly calculate the right edge centroid (C x,right , C y,right ); then connect the centroid coordinates of the boundary points of the left and right contour boundaries with a straight line to make a theoretical symmetry axis (i.e., the ideal center line, which serves as the initial symmetry axis for calculating the offset). The centroid line defines the symmetry reference. If the left and right centroid lines deviate significantly from the expected position (e.g., one side is concave due to biting), it indicates that the symmetry is broken, which is used to calculate the offset of the weld mark.
[0153] Multiple ideal center lines parallel to the horizontal dividing line are searched as candidates, and their distances from the horizontal dividing line are calculated. Parallel ideal center lines can correct for offsets caused by local anomaly interference, making the optimal center line more consistent with the true symmetry axis of the actual target area. Selecting the parallel center line with the smallest distance as the optimal center line ensures that when the vertical distance of the upper and lower contours is subsequently calculated using this center line, the resulting offset is more in line with the actual situation. This is often the center line that is least affected by local anomalies and best represents the overall trend.
[0154] S35432: vertically connect the boundary points of the upper and lower contour boundaries of each sub-region to the optimal center line, and calculate the vertical distance between all boundary points of the upper and lower contour boundaries;
[0155] According to the vertical distances of all the boundary points of the upper and lower contours, find the vertical distance with the minimum sum of vertical distances, which is used as the overall offset of the weld pattern;
[0156] It should be noted that for the upper and lower contour boundaries of each sub-area, the boundary points are vertically projected onto the determined optimal center line, and these vertical distances are calculated. The vertical distance reflects the degree of deviation between the area boundary and the ideal center line, is a direct measure of the weld line offset, and can also comprehensively reflect the symmetry and offset distribution of the entire weld line area.
[0157] The distances obtained from all vertical connections are statistically analyzed to find a combination that minimizes the sum of the vertical distances. This combination is used as the overall offset of the weld pattern. Minimizing the sum of the vertical distances ensures that the selected optimal centerline best matches the upper and lower boundaries overall. This selection can better reflect the offset state of the actual weld pattern. By balancing the left-right and top-bottom relationships, distortion of the overall offset due to local anomalies is avoided, thereby improving detection accuracy.
[0158] S35433: Use the interquartile range to sort the overall offsets of the weld patterns of the boundary points, and calculate the average of the overall offsets of the weld patterns of the middle boundary points as the median of the overall offsets of the weld patterns of the boundary points;
[0159] Calculate the average value of the overall offset of the weld pattern at the middle boundary points of the first half through the middle boundary points, and use it as the first quartile;
[0160] The average value of the overall offset of the weld pattern at the middle boundary point in the second half of the middle boundary point is calculated as the third quartile;
[0161] The interquartile range is calculated by using the first quartile and the third quartile;
[0162] The median and interquartile range of the overall offset of the weld mark at the boundary point are calculated to obtain a dimensionless index as the weld mark edge variation coefficient;
[0163] It should be noted that the overall offset of the weld pattern at all boundary points is sorted by size, the middle part is selected for statistical analysis, and the average value of the middle part is calculated as the median; the interquartile range method can be used to eliminate extreme offset values, and the median is used as a central trend statistic to reflect the representative value of the overall offset;
[0164] The first quartile is calculated by averaging the first half of the middle boundary points, and the third quartile is calculated by averaging the second half. The interquartile range is then calculated using the two. The interquartile range is a robust measure of dispersion that measures the degree of data variation and reflects the distribution of the overall offset of the weld pattern at different boundary points. Compared with extreme values or standard deviations, the interquartile range is more sensitive to outliers and is more suitable for processing the coefficient of variation that may exist in actual measurements due to deviations from the data.
[0165] By calculating the median and the interquartile range (usually the ratio of the two or other normalized methods), a dimensionless index, the coefficient of variation of the weld edge, is obtained. The dimensionless index is not affected by the specific numerical dimension, allowing horizontal comparisons between different areas and different welds. Therefore, the dimensionless index can be used as a coefficient of variation to directly reflect the stability of the weld edge. A higher coefficient of variation indicates that there is a large fluctuation in the edge offset, which may indicate undercut or other quality issues; a lower coefficient of variation indicates that the weld edge is relatively stable and consistent.
[0166] Example 2
[0167] like Figure 9 As shown, the present application also provides a system for identifying and processing weld undercut defects of workpieces based on visual image detection, comprising: an acquisition module 10; a weld undercut module 20; an analysis module 30; and a judgment module 40;
[0168] The acquisition module 10 is used to acquire images of the workpiece and pre-process the images of the workpiece to obtain images to be detected;
[0169] The weld mark module 20 is used to analyze the image to be detected using an edge detection algorithm to obtain the weld mark area of the image to be detected;
[0170] The analysis module 30 is configured to smooth the curve of the weld mark area and obtain sampling points; calculate the total arc length of the weld mark area based on the sampling points, calculate the curvature of each sampling point based on the total arc length, and filter out abnormal points based on the curvature of the sampling points; form an undercut area based on the abnormal points, and segment the undercut area to calculate a symmetry deviation index;
[0171] The judgment module 40 is configured to judge whether a biting edge exists based on the symmetry deviation index.
[0172] In summary, the method and system for identifying and processing weld undercut defects of workpieces based on visual image detection proposed in the present invention can be seen as follows: curve restoration is used to smooth the weld mark area to obtain sampling points; an approximate curve of the weld mark area is obtained based on the connection of the sampling points, reflecting the shape and contour curvature of the weld mark area; and the total arc length of the approximate curve of the weld mark area is further calculated to understand the contour length of the weld mark area; the curvature and curvature distribution of the sampling points are calculated by the total arc length of the approximate curve, and the curvature degree of the curve along different positions can be understood through the calculated curvature and curvature distribution, thereby improving the accuracy of extracting abnormal points of undercuts and avoiding errors; and based on the curvature and curvature distribution of the sampling points, the curvature fluctuation of each sampling point in the neighborhood before and after the sampling point is judged to see whether there may be asymmetric changes, thereby screening out abnormal points;
[0173] Furthermore, the level set method is used to perform convex hull boundary analysis on the outliers, and the area not covered by the convex hull boundary is used as the initial candidate bite edge area. After the outliers are covered by the neighborhood, isolated outliers that may have errors can also be captured, thereby improving the capture rate of the real area boundary; and the boundary distance of the internal and external pixels of the approximate curve of the candidate bite edge area is calculated to reflect the spatial distribution of the pixels inside and outside the candidate bite edge area; the level set function is calculated by the boundary distance to reflect the segmentation state of the approximate curve, that is, the bite edge area of the real boundary; the grayscale driving force is obtained by grayscale calculation of the internal and external pixels of the approximate curve to reflect the background and foreground of the bite edge area; the curvature driving force is calculated by the curvature of the approximate curve to reflect the rule of the contour; and the energy function is calculated by the curvature driving force and the grayscale driving force to reflect the shape and other information of the candidate bite edge area; and the energy function is updated by the level set function to find the bite edge area;
[0174] Furthermore, the segmentation algorithm is used to segment the undercut area into sub-areas to avoid the risk of global analysis covering up detail defects; the edge contour of each sub-area is extracted to capture the edge variation coefficient of the weld mark and the overall offset of the weld mark to reflect the irregularity and local fluctuation of the sub-area, and the symmetry deviation index is further calculated to reflect the abnormal undercut that occurs in a certain area, such as Figure 8 shown.
[0175] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. A person skilled in the art may modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for identifying and processing weld undercut defects of workpieces based on visual image detection, characterized in that: The following steps are included: Collect images of the workpiece, pre-process the images of the workpiece, and obtain images to be inspected; Performing edge detection analysis on the image to be detected to obtain a weld mark area of the image to be detected; Performing curve smoothing on the weld mark area to obtain sampling points; Calculating the total arc length of the weld mark area based on the sampling points, calculating the curvature of each sampling point based on the total arc length, and screening abnormal points based on the curvature of the sampling points; forming an undercut area based on the abnormal points, and segmenting the undercut area to calculate a symmetry deviation index; Whether there is a bite edge is determined based on the symmetry deviation index.
2. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 1, characterized in that: Smoothing the weld mark area to obtain sampling points; calculating the total arc length of the weld mark area based on the sampling points. The specific steps are as follows: The weld mark area is smoothed by using curve restoration to obtain s1, s2, ..., sn sampling points; Connect each adjacent sampling point with a straight line to obtain an approximate curve; calculate the Euclidean distance between adjacent sampling points in the approximate curve as the arc length increment between the sampling points; The arc length increment of each sampling point from sampling point s1 to sampling point sn is calculated to obtain the total arc length of the approximate curve.
3. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 2, characterized in that: The curvature of each sampling point is calculated using the total arc length, and abnormal points are screened based on the curvature of the sampling points. The specific steps are as follows: Calculating the equation of the circle using least squares circle fitting for each sampling point in the front and rear neighborhoods of each sampling point in the two-dimensional parametric curve; And calculate the sum of the squares of the distances from all neighborhood sampling points to the sampling points of the circle; Calculate the curvature of the sampling point based on the square sum of the distances and the equation of the circle; and calculating the curvature of all sampling points to obtain the curvature distribution of the two-dimensional parametric curve; Taking the sampling point as the center point, calculating the average curvature of each sampling point in the front and back neighborhood of the sampling point, and further calculating the curvature standard deviation of the average curvature of each sampling point in the front and back neighborhood; Set the asymmetric threshold of the outlier point, and check whether the curvature standard deviation of each sampling point in the front and back neighborhood of the sampling point is less than the asymmetric threshold of the outlier point; If so, it is determined that the curvatures of the sampling points in the front and rear neighborhoods of the sampling point fluctuate, and the points are regarded as abnormal points.
4. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 3, characterized in that: The undercut area is formed by the abnormal point, and the undercut area is segmented and the symmetry deviation index is calculated, including: The convex hull boundary of the outlier point is calculated using the level set method, and the coverage of the convex hull boundary is used as a candidate undercut area; the level set function of the approximate curve of the candidate undercut area is obtained; Calculating an energy function for the inside and outside of the candidate undercut region using the approximate curve; The level set function is updated by an energy function to find the undercut region; the undercut region is divided into sub-regions, and a symmetry deviation index is calculated by edge contours of the sub-regions.
5. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 4, characterized in that: The level set method is used to calculate the convex hull boundary of the outlier point, and the coverage of the convex hull boundary is used as the candidate undercut area. The approximate curve of the candidate undercut area is obtained to calculate the level set function. The specific steps are as follows: The convex hull boundary of the screened outliers is calculated using the level set method. The outliers are then used to cover the pixels in the surrounding neighborhood until all outliers completely cover the pixels in the surrounding neighborhood. The area covered by each outlier is used as a candidate undercut area. Obtain an approximate curve for each candidate undercut area; Counting the number of pixels inside and outside the approximate curve for each candidate undercut region; calculating the distance from the pixel points inside and outside the approximate curve of each candidate undercut region to the boundary of the approximate curve, and combining the calculated boundary distances of the pixel points inside and outside the approximate curve to form a level set function; The level set function represents a partitioning function between the inside and the outside of the approximate curve of the candidate bite region.
6. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 5, characterized in that: An energy function is calculated for the interior and exterior of the candidate undercut region using the approximate curve; the level set function is updated using the energy function to find the undercut region. The specific steps are as follows: Calculating the inner average grayscale value and the outer average grayscale value of the pixel points inside and outside the approximate curve of the candidate undercut region respectively; Calculating the curvature of an approximate curve of the candidate undercut region; The finite difference method is used to calculate the average grayscale difference between the inner average grayscale value and the outer average grayscale value of the approximate curve of the candidate biting area, which is used as the grayscale driving force; Searching for an outlier point with a maximum curvature and an outlier point with a minimum curvature on an approximate curve of the candidate undercut region, smoothing the outlier point corresponding to the maximum curvature and the outlier point with a minimum curvature after smoothing as a curvature driving force; Calculating the grayscale driving force and the curvature driving force to obtain an energy function; The energy function is expressed as a segmentation state of an approximate curve of the candidate undercut region using a level set function.
7. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 6, characterized in that: The level set function is updated using the energy function to find the undercut area. The undercut area is divided into sub-areas, and the symmetry deviation index is calculated based on the edge contours of the sub-areas. The specific operation steps are as follows: Initializing the level set function of the candidate undercut region; and quantizing the energy function using a gradient descent method according to the grayscale driving force and the curvature driving force, so as to update the level set function; Preset the function update threshold p and determine whether the updated level set function is equal to the function update threshold p; If so, it is determined that the updated level set function finds the undercut region; If not, the level set function is iteratively updated until the updated level set function is equal to the function update threshold p; The undercut area is divided into sub-areas by using a segmentation algorithm, boundary points of edge contours of the sub-areas are discretized, and symmetry deviation indicators are calculated through the boundary points of the sub-areas.
8. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 7, characterized in that: The undercut area is divided into sub-areas using a segmentation algorithm, the boundary points of the edge contour of the sub-areas are discretized, and the symmetry deviation index is calculated based on the boundary points of the sub-areas. The specific operation steps are as follows: Using a segmentation algorithm to segment the undercut region into four sub-regions: a first sub-region, a second sub-region, a third sub-region, and a fourth sub-region; The sub-region is a horizontal segmentation of the undercut region, and then a center point on the horizontal segmentation line is found, and then the sub-region is segmented longitudinally along the center point; The first and second sub-regions of the divided undercut region are adjacent to each other in the left and right directions, and the third and fourth sub-regions are adjacent to each other in the left and right directions; the first and second sub-regions and the third and fourth sub-regions are adjacent to each other in the top and bottom directions; Extracting edge contours from each sub-region to obtain a contour boundary of each sub-region, and discretizing the contour boundary into a plurality of continuous boundary points; Calculating the overall offset of the weld pattern and the coefficient of variation of the weld pattern edge for a longitudinal dividing line formed by longitudinally dividing a plurality of consecutive boundary points of each sub-region along the center point; The ratio of the first sub-region to the second sub-region and the ratio of the third sub-region to the fourth sub-region are compared through the weld line edge variation coefficient of each sub-region and the overall weld line offset to obtain a symmetry deviation index.
9. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 8, characterized in that: The overall offset of the weld pattern and the coefficient of variation of the weld pattern edge are calculated for the longitudinal dividing line formed by longitudinally dividing the plurality of consecutive boundary points of each sub-region along the center point. The specific operation steps are as follows: Calculate the centroid coordinates of the boundary points of the left and right contours of each sub-region, and then connect the centroid coordinates of the boundary points of the left and right contours with a straight line as the ideal center line; Using the transverse dividing line to search for a parallel ideal center line, and calculating the distance from the parallel ideal center line to the transverse dividing line, and selecting the parallel ideal center line with the minimum distance as the optimal center line; The boundary points of the upper and lower contour boundaries of each sub-region are vertically connected to the optimal center line, and the vertical distances between the boundary points of the upper and lower contour boundaries are calculated; According to the vertical distances of the boundary points of all upper and lower contour boundaries, find the vertical distance with the smallest sum of vertical distances as the overall offset of the weld pattern.
10. The method for identifying and processing weld undercut defects of a workpiece based on visual image detection according to claim 9, characterized in that: The specific steps for calculating the coefficient of variation of the weld edge are as follows: The overall offset of the weld pattern of the boundary points is sorted using the interquartile range, and the average of the overall offset of the weld pattern of the middle boundary points is calculated as the median of the overall offset of the weld pattern of the boundary points; Calculate the average value of the overall offset of the weld pattern at the middle boundary points of the first half through the middle boundary points, and use it as the first quartile; The average value of the overall offset of the weld pattern at the middle boundary point in the second half of the middle boundary point is calculated as the third quartile; The interquartile range is calculated by using the first quartile and the third quartile; The median and interquartile range of the overall offset of the weld mark at the boundary point are calculated to obtain a dimensionless index as the weld mark edge variation coefficient.
Citation Information
Patent Citations
Fitting for a vehicle seat
CN102481870A
Method of measuring a property of a target structure, inspection apparatus, lithographic system and device manufacturing method
CN107077079A
Wheel weld surface defect detection method based on computer vision
CN113409313A
Steel die welding defect detection method and system based on machine vision
CN115100171A
Intelligent pavement crack detection method and system based on vision assistance
CN117893543A
Cited By
Method and device for quantifying morphology deviation degree of closed curve type defects
CN121033050A
A method and device for quantifying the morphology deviation of a closed curve type defect
CN121033050B
Steel pipe weld defect detection method and system based on machine vision
CN121213499A