A method for planar weld seam identification and welding trajectory planning for electron beam welding
Patent Information
- Application Number
- CN202611097429.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-16
AI Technical Summary
[0006]本发明旨在提供一种用于电子束焊接的平面焊缝识别与焊接轨迹规划方法,通过机器视觉自动识别平面焊缝并生成有序轨迹,解决人工观察、逐点示教、重复校准耗时及轨迹一致性依赖人员经验的问题
[0015] This invention uses machine vision to automatically generate a sequence of trajectory points, reducing manual observation, point-by-point teaching, and repetitive data entry in the preparation of planar weld trajectories.
Smart Images

Figure CN122913644A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of electron beam welding, machine vision, and trajectory planning, and specifically to a method and system for automatically identifying planar welds, extracting ordered center lines, and generating electron beam welding trajectories. Background Technology
[0002] Before electron beam welding, the position, direction, and endpoints of the planar weld need to be determined and converted into trajectory points arranged in the welding sequence. Traditional trajectory preparation relies on manual observation, point-by-point teaching, and repeated calibration; after the workpiece clamping position or weld shape changes, re-teaching is usually required, which is cumbersome and dependent on personnel experience.
[0003] Machine vision can obtain the weld seam region through thresholding, edge detection, semantic segmentation, or instance segmentation. However, the detection box or segmentation mask usually still needs to be further converted into a continuous and ordered welding trajectory. After obtaining the continuous and ordered trajectory from the weld seam region, steps such as mask merging, main region preservation, centerline extraction, corner and end processing, curve fitting, and coordinate transformation are still required.
[0004] Slender welds are affected by reflections, shadows, textures, and viewing angles, making the mask edges and ends prone to burrs, jagged edges, or misalignments. Generating trajectories directly from the mask edges or by manually selecting points can easily result in the centerline deviating from the middle of the weld width, overly smoothed corners, or pseudo-branches at the ends. Using the outer contour splitting midpoint method, combined with corner and end corrections, helps obtain an ordered geometric centerline without relying on skeleton refinement.
[0005] Deep segmentation models may lose slender edges after multiple downsampling. Directly incorporating shallow features into the detection prediction path alters the distribution of detection features. When long welds extend beyond a single field of view, inconsistencies in direction, displacement, and overlapping segments exist in the local trajectory. Furthermore, existing electron beam weld recognition methods based on YOLOv11-seg often combine instance segmentation results with edge detection or curve fitting, making them susceptible to the weak boundaries of slender welds, end burrs, corner offsets, and discontinuous trajectories across fields of view. Therefore, it is necessary to enhance mask details while maintaining relative independence of the detection path, and to convert the recognition results into verifiable electron beam welding trajectories using non-model geometry processing and multi-image stitching. Summary of the Invention
[0006] This invention aims to provide a method for planar weld seam identification and welding trajectory planning in electron beam welding. It automatically identifies planar weld seams and generates ordered trajectories using machine vision, solving the problems of time-consuming manual observation, point-by-point teaching, and repeated calibration, as well as the reliance on human experience for trajectory consistency. This invention also addresses issues such as isolated noise in candidate masks, reliance on manual point selection for centerline extraction, easy smoothing deviation in corner areas, burrs affecting trajectory start and end points, and difficulty in stably stitching together local trajectories from multiple images.
[0007] To achieve the above objectives, the present invention provides a planar weld seam identification and welding trajectory planning method for electron beam welding, comprising the following steps:
[0008] S1. Obtain a planar workpiece image containing the weld seam to be welded, and obtain one or more candidate weld seam masks through the YOLOV11-MCPG image segmentation model.
[0009] S2 binarizes the candidate weld masks that meet the area conditions and merges them through logical OR operation. Then, it performs connected component analysis on the merged masks and retains the largest connected weld region as the trajectory extraction mask.
[0010] S3, extract the outer contour of the trajectory mask, split the outer contour into two boundary paths based on the two points farthest apart on the contour, resample the two boundaries with an equal number of samples and take the midpoint of the corresponding points to generate the geometric center line of the weld, and arrange the center lines in an orderly manner according to the extension direction of the weld.
[0011] S4 performs a moving average smoothing on the weld geometric centerline, and corrects the centerline point of the corner region based on the centroid of the grayscale profile of the corner neighborhood. Short branches, edge offset points, angle abrupt pseudo-branches, and end cap segments at both ends of the centerline are trimmed, and the end trimming results are determined based on the distance-transformed ridge coverage.
[0012] S5. While maintaining the beginning and end points, the processed centerline is smoothed by Savitzky-Golay and fitted with cubic B-spline. Then, it is sampled at equal intervals according to the arc length. Based on the pixel-physical coordinate transformation relationship, the sampled points are converted into a sequence of planar welding trajectory points.
[0013] S6: When multiple planar workpiece images cover the weld seam to be welded, the displacement of each image is accumulated, the local welding trajectory is transformed to a unified coordinate and then stitched together.
[0014] The present invention also provides a planar weld identification and welding trajectory planning system for performing the above steps.
[0015] This invention uses machine vision to automatically generate a sequence of trajectory points, reducing manual observation, point-by-point teaching, and repetitive data entry in the preparation of planar weld trajectories.
[0016] This invention extracts the geometric center line of the weld by the midpoint method of outer contour splitting, and combines corner grayscale centroid correction, end burr trimming and distance ridge coverage acceptance to make the trajectory centerness, end stability and corner fit have a calculable basis.
[0017] This invention obtains the main weld area by merging effective instance masks and preserving the maximum connected region, and performs fitting and equal arc length sampling to output the trajectory while maintaining the endpoints; the YOLOV11-MCPG model is used as the preferred mask source and maintains a replaceable data interface with subsequent non-model processing. Attached Figure Description
[0018] Figure 1 A schematic diagram of the overall process for electron beam welding planar weld seam identification and welding trajectory planning.
[0019] Figure 2 This is a diagram of the network structure of the YOLOV11-MCPG model.
[0020] Figure 3 This is a schematic diagram of multi-level gated polymerization and Snake-LSK mask prototype enhancement.
[0021] Figure 4 This is a schematic diagram of centerline extraction using the midpoint method for mask processing and contour splitting.
[0022] Figure 5 This is a schematic diagram of centerline geometric correction, trajectory generation, and multi-image stitching. Detailed Implementation
[0023] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are used to illustrate the implementation of the present invention, and the scope of protection is determined by the technical features described in the claims.
[0024] like Figure 1 As shown, in one embodiment of the present invention, an image containing the weld seam on the plane to be welded is used as input, and planar trajectory points arranged in the welding sequence are used as output. The input image can be a grayscale image or a color image. After acquiring the image, the system retains the original image size, pixel coordinate system, and calibration relationship, and converts the subsequently generated pixel trajectory into the physical coordinates of the workpiece plane through proportional calibration, planar calibration, homography transformation, or a preset correspondence between image coordinates and workpiece plane coordinates. The candidate weld seam mask is used to represent the possible weld seam area, and can be either a binary mask or a probabilistic mask; this mask can be obtained by instance segmentation, semantic segmentation, grayscale or color segmentation, edge closure region extraction, and other algorithms that can output candidate weld seam areas. Therefore, the subsequent trajectory planning process can be combined with various weld seam candidate area generation methods.
[0025] In the algorithm processing, the recognition stage first outputs candidate weld masks that correspond to or can be restored to the original image size. Then, in the mask processing stage, the candidate masks are converted into single-subject trajectory extraction masks. Next, the centerline extraction stage generates ordered centerlines based on the outer contour of the subject mask. Following this, the geometric correction stage corrects the corner positions, end pseudo-branches, and end cap offsets of the centerlines. Afterward, the trajectory generation stage smooths, fits, and samples the corrected centerlines with equal arc lengths. Finally, the coordinate output stage converts pixel trajectory points into physical trajectory points on the workpiece plane and outputs a trajectory file for use or import by electron beam welding equipment. All of the above processes complete trajectory calculations in the original image coordinate system, followed by a unified coordinate transformation to ensure that the trajectory position remains under a unified original image coordinate reference.
[0026] like Figure 2 As shown, the method employs the YOLOv11-MCPG instance segmentation model to obtain a weld instance-level probabilistic mask. This model includes a feature extraction network, a feature fusion network, a detection prediction path, and a mask prototype enhancement path. P3, P4, and P5 level features are used to output detection boxes, categories, and mask coefficients, while P2 and additional P3 level features are used to enhance the mask prototype. By isolating the detail enhancement path from the detection prediction path, the model can improve the mask quality at weld edges and corners while primarily using low-level detail features for mask prototype enhancement, maintaining relative stability in the detection box and category prediction branches, and ensuring the stability of the detection prediction process.
[0027] At the deep feature processing location of the instance segmentation model, a C2-style multi-level gated aggregation module can be set up, which can be denoted as WeldC2Moga in software implementation. This module divides the input feature F into an identity branch Fi and a context branch Fc through a 1×1 convolution. The identity branch directly retains the original response, while the context branch enters the multi-level gated aggregation block. The two branches are concatenated and then subjected to a 1×1 convolution to obtain the output feature. Each multi-level gated aggregation block includes a multi-level gated aggregation unit and a channel feedforward network, which can be connected at a learnable residual scale, which can be initialized to 0.01. The multi-level gated aggregation unit first subtracts the global average pooling result from the pre-transformed feature to form a centered feature, and then stacks them according to the learnable decomposition scale to enhance the expression difference between contexts at different scales.
[0028] In practice, the input features are first processed by a 1×1 convolution to obtain pre-transformed features X, which are then generated by another 1×1 convolution to produce a gated response. Simultaneously, a multi-level depthwise convolution generates a value response. The gated response and the SiLU-activated value response are multiplied element-wise, and then projected by a 1×1 convolution. The multi-level depthwise convolution can first perform a 5×5 basic depthwise convolution on all channels, then divide them into low-order, mid-order, and high-order groups according to channel proportions. The low-order group retains the basic response, the mid-order group performs a 5×5 depthwise convolution with a dilation rate of 2, and the high-order group performs a 7×7 depthwise convolution with a dilation rate of 3. The responses from each group are concatenated and then projected by a 1×1 convolution. The channel feedforward network can expand the channels through 1×1 convolutions, generate single-channel generalized features after 3×3 depthwise convolutions and GELU activation, and feed back the difference between the expanded features and the generalized features according to a learnable scale, then restore the channels through a 1×1 convolution. The kernel size, channel ratio, dilation rate, and initial values mentioned above are optional implementations and can be adjusted according to implementation requirements. The scope of protection is determined by the technical features defined in the claims.
[0029] like Figure 3 As shown, the mask prototype enhancement path can adopt a Snake-LSK structure. After channel adjustment, the P2-level features and the additional P3-level features are processed through 3×3 local depth convolution, 1×11 stripe depth convolution, 11×1 stripe depth convolution, 5×5 depth convolution with a dilation rate of 2, and 3×3 depth convolution with a dilation rate of 3 to obtain candidate responses C1 to C5. Subsequently, the mean and maximum values of the detail features are calculated along the channel dimension. The two feature maps are then concatenated and sequentially processed through 5×5 convolution, normalization, activation, and 1×1 convolution to generate five spatial weight maps. Softmax normalization is then performed on the candidate response dimension, allowing the selection of candidate responses with different directions and receptive fields based on the local morphology for straight lines, corners, and arcs.
[0030] In this mask prototype enhancement method, the detail prototype Y can be obtained by element-wise weighting of the normalized spatial weight map and the corresponding candidate response, and the relationship can be expressed as:
[0031]
[0032] In the formula, Sᵢ is the i-th spatial weight map, Cᵢ is the i-th candidate response, and ⊙ represents element-wise multiplication. After upsampling the P3 detail prototype, it is scale-aligned with the P2 detail prototype, and the two are concatenated and subjected to convolution and the Sigmoid function to obtain the gated weight W. The fused detail prototype D can be expressed as:
[0033]
[0034] In the formula, D2 is the P2 detail prototype, and D3 is the scale-aligned P3 detail prototype.
[0035] Scale alignment can be achieved using transposed convolution, interpolation upsampling plus convolution, or other learnable upsampling methods. Since the gating weights possess both spatial and channel dimensions, the edge details of P2 and the semantic information of P3 can be adaptively fused according to their positions. Furthermore, directional continuity gating can be generated based on the horizontal and vertical context of the fused detail prototype D, and D is then subjected to 1×9 depthwise convolution, 9×1 depthwise convolution, and pointwise convolution to generate a continuous residual. This residual is then modulated by directional continuity gating and Sobel edge gating to obtain the continuous detail prototype D′. The enhanced mask prototype P can be represented as:
[0036]
[0037] In the formula, P0 is the basic mask prototype, R is the detail refinement operation, G is the edge gating, and α is a learnable weight that can be initialized to zero. During training, the gradient ratio of the backpropagation of P2-level features and additional P3-level features to the feature extraction network can be set to a value less than 1, such as 0.20, to reduce the perturbation of the main features by the detail branches. During inference, the basic mask prototype and the mask coefficients of each instance are combined to obtain the instance-level probability mask; the instance mask can be binarized by a threshold and restored to the original image size. The threshold can be 0.5, or it can be adaptively determined based on the validation set or image quality. The subsequent trajectory processing program takes the candidate weld mask and optional confidence as input and is decoupled from the intermediate features of the detection network. Therefore, the candidate mask can be obtained by other instance segmentation, semantic segmentation, or traditional image processing algorithms.
[0038] In a set of training results using a self-built dataset of weld seams, the best validation result achieved a mask precision of 0.96425, a recall of 0.96320, a mask mAP50 of 0.97280, and a mask mAP50-95 of 0.74600; the bounding box mAP50 was 0.98311, and the bounding box mAP50-95 was 0.91960. In comparison, in a set of training results using the same weld seam dataset, compared to the original YOLOv11-seg model, the mask mAP50-95 of this embodiment improved from 0.66591 to 0.74600, and the bounding box mAP50-95 improved from 0.83722 to 0.91960. The above results are used to illustrate the training effect of one embodiment, and the scope of protection is determined by the technical features described in the claims.
[0039] like Figure 4As shown, after obtaining one or more valid candidate instance masks, the system scales or maps each instance mask to the original image size and converts it into a binary mask according to a preset threshold. Small-area instances can be filtered by pixel area before or after conversion, and instances whose area reaches the minimum area threshold are processed further; the minimum area threshold can be set according to image resolution, weld width, or field of view size. Multiple instance masks that meet the conditions are combined into a merged mask through a pixel-by-pixel logical OR operation.
[0040] After the merged mask is formed, it undergoes 8-connected region labeling. The pixel area of each connected region is calculated, and the 8-connected foreground region with the largest area is selected as the maximum connected weld region. This maximum connected weld region is converted into a trajectory extraction mask with a foreground value of 255 and a background value of 0, which is used for subsequent outer contour extraction, corner correction, end trimming, and distance transform ridge coverage evaluation. If there is no valid foreground in the merged mask, trajectory extraction stops for that image, and the result of no valid weld trajectory detected is returned. This main region preservation process uses the maximum connected region as the main weld region, thereby reducing the risk of irrelevant regions being mistakenly connected and affecting the trajectory centerline.
[0041] During processing, the system can also read the original grayscale image. This grayscale image does not change the trajectory extraction mask itself, but is used for grayscale profile sampling and centroid correction near corners along the normal direction. For ease of debugging, the system can save diagnostic information such as the original binary mask, the cleaned main mask, the centerline overlay image, and the number of instances. The final trajectory point coordinates are based on the output of the trajectory generation module.
[0042] like Figure 4 As shown, after the trajectory extraction mask is determined, the system performs outer contour extraction on the mask to obtain a set of outer contour points arranged in contour order. If no outer contour is detected or the number of contour points is too small, trajectory extraction for that image is stopped. To reduce the impact of uneven density of original contour points on centerline calculation, the system uniformly samples the outer contour points according to a preset contour resampling step size. The resampling step size can be 2 pixels or adjusted according to image resolution and weld width.
[0043] In the resampled contour points, the system calculates the Euclidean distance between point pairs and determines the two points with the largest distance as reference points at both ends of the weld. To improve computational efficiency, candidate endpoints can be screened first based on the convex hull points, and then the farthest point pair can be found among the candidate endpoints. After determining the two endpoints, the system uses the endpoints as the starting and ending positions and traverses along the contour in both the forward and reverse directions to obtain two boundary paths connecting the same endpoint pair. The two boundary paths correspond to the outer contour boundaries on both sides of the weld area.
[0044] Subsequently, the system resamples the two boundary paths to the same number of points according to the cumulative arc length, creating a one-to-one correspondence between the boundary points on both sides. For the i-th pair of boundary points b1,i and b2,i, the average coordinate is taken as the centerline point pi, and all centerline points are sequentially arranged to form the geometric centerline of the weld. This contour splitting midpoint method places the centerline in the geometric middle between the two boundaries, directly generating an ordered centerline based on the corresponding midpoints of the two boundaries, which can reduce the possibility of pseudo-branches or inward bias in skeleton extraction at corners. After generating the initial centerline, the system can unify the path direction according to the x-coordinates of the first and last points or the preset welding direction; when the x-coordinate of the first point is greater than the x-coordinate of the last point under the default rule, the centerline point sequence can be reversed so that the output of similar images has a stable direction.
[0045] Moving average or local smoothing can be performed on the initial centerline. The smoothing window is odd-numbered; the larger the window length, the smoother the trajectory, but corner regions may be blunted. Therefore, the system continues to perform corner geometric correction after smoothing. Corner regions can be identified by the discrete curvature of adjacent vectors on the centerline. When the curvature of several consecutive points exceeds a preset threshold, the continuous region is marked as the corner influence range, and the centerline point with the largest curvature is taken as the corner vertex. Within the corner influence range, the system performs principal component analysis based on local centerline points and takes the direction corresponding to the smaller eigenvalue as the local normal. For the corner vertex, the scanning direction can be determined by combining the angle bisector relationship of the directions before and after the corner.
[0046] After determining the scanning direction, the system samples a grayscale profile in the original grayscale image along the normal direction, inverts the grayscale values, and calculates the weighted centroid to obtain the correction amount of the centerline point along the normal direction. If the corrected centerline point is still within the trajectory extraction mask, the corrected coordinates are used; if it is within the mask and meets the continuity constraint, the corrected coordinates are used; otherwise, the original coordinates are retained. This grayscale centroid correction can reduce the influence of reflections, shadows, jagged edges, or local mask deviations on the corner centerline position, and is especially suitable for situations where there is a grayscale difference between the weld and the background in the original image.
[0047] To evaluate whether geometric correction and end trimming disrupt the centerline's coverage of the weld's central region, the system performs a distance transformation on the trajectory extraction mask and selects pixels with higher distance values as distance ridge regions. Distance ridges represent areas with larger distance values during the distance transformation, typically located near the center of the mask's width. The system can statistically analyze the proportion of the centerline expansion area covering the distance ridge region, using this as a basis for comparing centerline quality before and after end trimming. If a trimming operation causes a coverage decrease exceeding a preset allowable amount, the centerline before trimming is retained.
[0048] like Figure 5As shown, after obtaining the centerline after angle correction, the system performs end trimming on both ends of the centerline. End trimming is not a simple truncation of a fixed length, but rather a judgment based on geometric features such as short branches at the ends, edge-off endpoints, pseudo-branches with abrupt angle changes, and end cap segments. For continuous approximately unidirectional line segments near the endpoints, the system can merge them inward from the endpoints to form branch segments; when the length of continuous short branches near the endpoints is less than a threshold and there is a significant turn in the subsequent main direction, the corresponding endpoint points are used as deletion candidates. For endpoints close to the mask edge or deviating from the local cross-sectional centerline, the system calculates the distance from the centerline point to the background boundary based on distance transformation, and scans the mask foreground region along the local normal to determine whether the endpoint deviates from the cross-sectional centerline; when the endpoint distance is too small or the offset is too large, it trims inward point by point.
[0049] For pseudo-branches with abrupt angle changes, the system examines local tangent direction changes within a short distance from both ends of the centerline. If the angle between the short end segment and the subsequent main direction exceeds a threshold, the short end segment is deleted as a pseudo-branchary candidate. For end cap tail segments, the system integrates end direction changes, distance transformation values, and distance changes from the endpoint to the mask boundary to identify short tail segments offset along the mask end cap edge and uses them as trimming candidates. A copy of the pre-trimming version is retained before each type of trimming is performed. When a trimming passes quality acceptance tests such as distance ridge coverage or adjacent point distance, the system uses the trimming result and continues to judge the next type of candidate with the updated endpoint. If the quality acceptance test fails, only the current trimming is rolled back, and the previously accepted geometric processing is not undone.
[0050] After completing corner correction and end trimming, the system obtains a sequence of centerline points for trajectory fitting. If the number of centerline points meets the trajectory output conditions and the total length of the line segments reaches the preset length, the system proceeds to the trajectory generation stage. For a centerline point sequence that meets the conditions, the system first deletes consecutive duplicate points and ensures that the parameter value monotonically increases when the cumulative arc length is used as the parameter. Subsequently, Savitzky-Golay filtering or a local polynomial method can be used to smooth the centerline coordinate sequence while keeping the first and last points unchanged. The smoothing window length is automatically adjusted according to the number of points, and the smoothing step is executed when the window length reaches the algorithm requirements.
[0051] After smoothing, the system performs cubic B-spline fitting on the centerline using the cumulative arc length as a parameter. When the number of points is insufficient for cubic fitting, the spline order can be reduced, linear interpolation can be used, or the origin sequence can be directly retained. After dense evaluation of the fitted curve, the system performs equal arc length resampling according to a preset pixel step size, ensuring that the trajectory curve points are evenly distributed along the weld direction. The first sampling step size can be 0.5 pixels, and the smoothing coefficient can be set according to the number of points and pixel jitter. For trajectories with obvious corners, the system can reduce the number of times the fitted curve crosses the inside of the corner by using endpoint preservation, a smaller smoothing coefficient, and corner neighborhood constraints.
[0052] When outputting welding trajectory points with approximately equal physical spacing, the system determines the secondary sampling interval based on the preset physical trajectory point spacing and pixel-to-physical scale ratio. Let the physical trajectory point spacing be Δs mm and the pixel-to-physical scale ratio be ρ mm / pixel, then the pixel spacing Δp for secondary sampling can be expressed as:
[0053]
[0054] The system resamples the fitted curve using equal arc lengths according to Δp, obtaining trajectory points with approximately the same physical spacing between adjacent points. When using proportional calibration, if the image point coordinates are (x, y) and the image origin or calibration reference point is (x0, y0), then its local physical coordinates can be expressed as:
[0055]
[0056] In other implementations, homography, camera intrinsic and extrinsic parameter calibration, or device coordinate mapping can also be used to convert image coordinates to workpiece plane coordinates. The output can record X, Y, preset Z coordinates, and cumulative arc length line by line; the Z coordinate is provided by the device trajectory preparation parameters. The number of verification points, coordinate range, and distance between adjacent points are checked before output.
[0057] like Figure 5 As shown, for long welds extending beyond the field of view of a single image, the displacements dx,j and dy,j of the j-th image relative to the previous position are recorded. The accumulated global offset is:
[0058]
[0059] Each local trajectory is converted into physical coordinates and a corresponding offset is added. The distances from the ends of the current trajectory to the end of the previous trajectory are compared. If necessary, the current trajectory is reversed to ensure that the sequence of the spliced trajectories is consistent with the welding direction. The displacement can be recorded by the acquisition platform or obtained from calibration relationships or image registration.
[0060] When adjacent local trajectories have overlapping coordinate ranges, the system can interpolate the overlapping points within a limited translation range and determine the alignment correction amount based on the median of the longitudinal difference, the root mean square residual, or other residual indices. To reduce the formation of erroneous low residuals from a small number of accidental intersections, the alignment search also considers the effective overlap length. After determining the alignment correction amount, the system accumulates it into subsequent trajectories and evaluates the smoothness of overlapping segments using the second-order difference with normalized point distances, retaining smoother overlapping trajectory segments and deleting duplicate parts. If the distance between adjacent points of a connection does not meet the preset conditions, interpolation can be performed within the connection neighborhood for transition; after splicing, the system re-smooths the merged trajectory and samples it with equal arc lengths.
[0061] During multi-image stitching, the system records the image sequence number, orientation marker, original offset, alignment correction, overlap area residual, and selected trajectory segment number. This information is used to check coordinate conversion and stitching quality; the final trajectory point coordinates are based on the merged resampling results. For welds that can be covered by a single image, the above stitching process can be omitted.
[0062] In terms of system implementation, the planar weld seam recognition and welding trajectory planning system can include functional modules such as image acquisition, candidate mask acquisition, mask processing, centerline extraction, geometric correction, trajectory generation, coordinate output, and multi-image stitching. These modules are used to sequentially complete the acquisition or reception of the planar weld seam image to be welded, candidate weld seam mask acquisition, thresholding and main area preservation, centerline generation, corner and end correction, trajectory smoothing fitting, physical coordinate transformation, and cross-view trajectory stitching. These modules can be located on the same computer or distributed across the image acquisition terminal, edge computing unit, and trajectory preparation terminal. Each module is logically divided and can be arranged independently of specific physical hardware. The candidate mask acquisition method and trajectory extraction program are replaceable. Intermediate processing results are used for algorithm process checking, and device execution control commands are generated by the coordinate output module.
[0063] The above embodiments are used to illustrate the technical solutions of the present invention, and the scope of protection is defined by the claims. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and the above modifications or substitutions fall within the scope of protection defined by the claims of the present invention.
Claims
1. A method for planar weld seam identification and welding trajectory planning in electron beam welding, characterized in that, The process includes the following steps: acquiring a planar workpiece image containing the planar weld to be welded; inputting the planar workpiece image into a YOLOV11-MCPG instance segmentation model to generate one or more candidate weld masks. The YOLOV11-MCPG instance segmentation model includes a feature extraction network, a feature fusion network, a detection prediction path, and a mask prototype enhancement path. The feature extraction network has a C2-type multi-level gated aggregation module at its deep layers. P3, P4, and P5 level features are input into the detection prediction path to output detection boxes, category information, and mask coefficients. P2 level features and additional P3 level features are input into the mask prototype enhancement path to generate an enhanced mask prototype. The enhanced mask prototype and the mask coefficients together generate the candidate weld mask. Candidate weld masks are selected based on area conditions. These selected masks are binarized and merged using a logical OR operation, retaining the largest connected weld region as the trajectory extraction mask. The outer contour of the trajectory extraction mask is extracted, and the two farthest contour points on the outer contour are determined as reference points at both ends of the weld. The outer contour is then split into two boundary paths based on these reference points. The two boundary paths are resampled with equal amounts, and the midpoints of the corresponding boundary points are taken to form the weld geometric centerline arranged along the weld extension direction. The weld geometric centerline is geometrically corrected, including moving average smoothing, corner grayscale centroid correction, and end burr trimming. The geometrically corrected centerline is then smoothed, fitted, and sampled with equal arc lengths to obtain a welding trajectory point sequence. Based on the pixel-physical coordinate conversion relationship, the welding trajectory point sequence is converted into a planar welding trajectory for use or import by electron beam welding equipment.
2. The method according to claim 1, characterized in that, The YOLOV11-MCPG instance segmentation model generates candidate weld masks by: the detection prediction path generating instance-level detection boxes, category information, and mask coefficients based on P3, P4, and P5 level features; the mask prototype enhancement path generating continuous detail prototypes based on P2 level features and additional P3 level features, and superimposing the continuous detail prototypes onto the base mask prototype in a residual manner to form an enhanced mask prototype; and combining the enhanced mask prototype with the mask coefficients to obtain instance-level candidate weld masks.
3. The method according to claim 1, characterized in that, The C2-style multi-level gated aggregation module divides the input features into a directly connected identity branch and a context branch containing at least one multi-level gated aggregation block after a first 1×1 convolution. The identity branch and the context branch are then concatenated and output via a second 1×1 convolution. The multi-level gated aggregation block includes a multi-level gated aggregation unit and a channel feedforward network. The multi-level gated aggregation unit stacks the centered features according to a learnable decomposition scale and multiplies the gated response element-wise with the multi-level depth convolution response. The multi-level depth convolution includes a 5×5 basic depth convolution, a 5×5 depth convolution with a dilation rate of 2, and a 7×7 depth convolution with a dilation rate of 3. The resulting multi-level responses are concatenated and projected using a 1×1 convolution before output. The channel feedforward network includes a channel-expanded 1×1 convolution, a 3×3 depth convolution, a single-channel feature decomposition, and a channel recovery 1×1 convolution. The multi-level gated aggregation unit and the channel feedforward network are output via residual connections with learnable scales.
4. The method according to claim 1, characterized in that, The mask prototype enhancement path is the Snake-LSK mask prototype enhancement path. This path generates detail prototypes for both P2-level features and additional P3-level features. Each level feature is processed by 3×3 local depthwise convolution, 1×11 stripe depthwise convolution, 11×1 stripe depthwise convolution, 5×5 depthwise convolution with a dilation rate of 2, and 3×3 depthwise convolution with a dilation rate of 3 to generate five candidate responses. A spatial weight map is generated based on the channel mean and channel maximum values, and the five candidate responses are normalized and weighted positionally using the Softmax function to obtain the detail prototypes for the corresponding levels. The detail prototypes obtained from the P2 and P3 levels are scale-aligned and dynamically fused. A directional continuity gate is generated based on the horizontal and vertical contexts, and a continuous residual is generated using 1×9 depthwise convolution, 9×1 depthwise convolution, and pointwise convolution. The continuous residual is modulated using the directional continuity gating and the edge gating based on the Sobel gradient magnitude to obtain a continuous detail prototype; the continuous detail prototype is superimposed on the base mask prototype by learnable prototype residual weights initialized to zero to form an enhanced mask prototype; during backpropagation, the gradients of the P2 level features and the additional P3 level features are transmitted back to the feature extraction network at a ratio of less than 1, wherein the ratio is 0.20 or set according to training stability.
5. The method according to claim 1, characterized in that, The process of selecting candidate weld masks based on area criteria, merging and retaining the largest connected weld region includes: scaling the candidate weld masks to the size of the planar workpiece image and binarizing them according to a threshold; selecting candidate weld masks with an area not less than the minimum area threshold as valid candidate weld masks; performing a logical OR operation on the valid candidate weld masks to form a merged mask; marking the merged mask with eight connected components, and selecting the connected component with the largest area as the trajectory extraction mask to separate the main weld region from the isolated noise region.
6. The method according to claim 1, characterized in that, Forming a weld geometric centerline arranged along the weld extension direction includes: extracting the outer contour of the trajectory extraction mask and uniformly sampling the outer contour points in contour order; determining the two farthest contour points as reference points at both ends of the weld based on the Euclidean distance between the contour sampling points; connecting the two reference points at both ends of the weld along the positive and negative directions of the contour to obtain two boundary paths; resampling the two boundary paths into the same number of points and averaging the coordinates of the corresponding points to form an ordered centerline located in the middle of the weld width and arranged along the weld extension direction.
7. The method according to claim 1, characterized in that, Geometric correction of the weld geometric centerline includes: performing moving average smoothing on the weld geometric centerline; identifying corner regions based on discrete curvature, estimating the normal in the corner regions using the local principal component direction or angle bisector direction, and sampling the original image grayscale profile along the normal to correct the centerline points near the corner using the grayscale centroid; trimming short branches at both ends of the centerline, offset endpoints close to the mask boundary, anachronistic pseudo-branches, and end cap segments; and selecting the end trimming results that pass quality acceptance based on the distance-transformed ridge coverage.
8. The method according to claim 1, characterized in that, The process of smoothing, fitting, and sampling the geometrically corrected centerline includes: performing Savitzky-Golay smoothing on the centerline coordinate sequence while preserving the beginning and end points; fitting the smoothed centerline points with a cubic B-spline according to the cumulative arc length parameter; resampling along the fitted curve with equal arc length at a preset pixel step size; and determining the output sampling interval based on the physical trajectory point spacing and the pixel-physical scale ratio to obtain a planar welding trajectory point sequence for use by electron beam welding equipment.
9. The method according to claim 1, characterized in that, When multiple planar workpiece images cover the weld seam to be welded, the acquisition displacement of each image is accumulated, and the local welding trajectory corresponding to each image is transformed to a unified coordinate system; the direction of the current local welding trajectory is determined according to the distance from the two ends of the current local welding trajectory to the end of the previous local welding trajectory; for adjacent local welding trajectories with overlapping coordinate ranges, the local alignment amount is determined according to the residual of the overlapping point within a preset translation range; the trajectory segment with higher smoothness is selected according to the second difference of the overlapping segment, and after merging with the trajectory segment outside the overlapping segment, it is sampled again with equal arc length to form a continuous planar welding trajectory across the field of view.
10. A planar weld seam recognition and welding trajectory planning system for electron beam welding, characterized in that, It includes an image acquisition unit, a processing unit, a storage unit, and a trajectory output interface; the processing unit is configured to perform the method described in any one of claims 1 to 9.