1. Introduction
The rapid development of China’s industry and the new energy vehicle sector has significantly expanded the production scale of vehicle traction battery packs. As the core energy storage component, the safety and reliability of the vehicle traction battery are crucial to the overall performance of electric vehicles. In the manufacturing process of the vehicle traction battery, a sealing nail is used to encapsulate the electrolyte injection hole after the electrolyte filling process. Laser welding is the final sealing step. However, due to contamination on the welding nozzle, fluctuations in laser power, or uncleaned stains on the welding area, defects such as burst points, incomplete welding, pinholes, and misalignment may occasionally appear on these small sealing nails. These defects directly threaten the safety and service life of the vehicle traction battery.

Traditional defect detection methods for sealing nails rely heavily on manual inspection or conventional 2D image algorithms. Manual inspection is inefficient, subjective, and prone to errors. Two-dimensional image algorithms, although automated, only exploit pixel intensity information and fail to capture the three-dimensional (3D) geometry of defects. They are also sensitive to lighting variations, reflection, and shadowing, leading to low accuracy and missed detection of small-scale defects. Conventional 3D point cloud defect detection algorithms based on handcrafted geometric features often suffer from low precision and are unable to detect small defects effectively.
Therefore, this research focuses on developing a point cloud deep learning-based defect detection method for sealing nails in the vehicle traction battery. The aim is to improve the detection accuracy, robustness, and automation level of sealing nail welding defects. The specific contributions are summarized as follows:
(1) An improved Random Sample Consensus (RANSAC) algorithm is proposed to extract the sealing nail welding area from the original point cloud data. This method reduces the interference from non-target regions such as the battery top cover and substrate. The local sampling strategy and misclassification point correction mechanism significantly improve the segmentation F1 score to 87.74%, outperforming traditional segmentation methods.
(2) A deep learning-based semantic segmentation network, named LGANet, is developed based on GACNet. A Local Graph Attention Filter (LGAF) module is proposed to model both spatial and feature information, and a Spatial Attention Graph Pooling module is designed to aggregate structural features. Compared with the baseline model, the class average intersection-over-union (mIoU) and class average accuracy (mAcc) are improved by 8.38% and 4.72%, respectively.
(3) To further enhance the detection capability for small-sized defects, a Cross-Attention-Based Cross Density Feature Fusion module is proposed. This module integrates multi-scale density features inside the graph pyramid, improving the detection IoU of burst points, molten beads, and pinholes by 1.89%, 4.66%, and 5.08%, respectively. Compared with the original GACNet, mIoU and mAcc are significantly enhanced by 10.4% and 8.24%.
(4) A software platform based on PyQt is developed for automatic sealing nail defect detection, providing visualized results and saved data files for non-specialists.
2. Sealing Nail Point Cloud Welding Area Extraction
2.1 Data Acquisition and Preprocessing
The point cloud data of the sealing nail in the vehicle traction battery were acquired using an LPC20 line laser scanning camera from OPT Machine Vision. The sensor emits a laser at 405 nm, with 3200 contour points. The measurement range includes a working distance of 23 mm, an X-axis range of 14.5 mm, and a Z-axis range of 5.2 mm. The acquired point cloud provides only XYZ coordinates without other attributes.
Preprocessing is essential before the defect detection step. The original point cloud contains noise caused by reflection instability, scanner errors, environmental interference, and vibration. To eliminate such outliers, a statistical filtering approach is applied. Given a point \(p_i\), its average distance to the k nearest neighbors is computed as:
\[
\tilde{d}_i = \frac{1}{k} \sum_{j=1}^{k} \sqrt{(x_i-x_{ij})^2+(y_i-y_{ij})^2+(z_i-z_{ij})^2}
\]
Supposing the average distances fit a normal distribution \(N(\mu,\sigma^2)\), the mean and standard deviation are:
\[
\mu = \frac{1}{n}\sum_{i=1}^{n}\tilde{d}_i
\]
\[
\sigma = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(\tilde{d}_i – \mu)^2}
\]
Points with \(\tilde{d}_i > \theta\sigma + \mu\) are considered outliers and removed.
2.2 Improved RANSAC for Welding Region Extraction
In the original point cloud of the sealing nail on a vehicle traction battery top cover, the target inspection regions include the sealing nail surface and its surrounding welding zone. Other areas, such as the battery can top surface and background substrate, should be excluded to improve the efficiency and accuracy of the subsequent deep learning model. The classic RANSAC algorithm randomly samples minimal subsets to fit plane models. However, the random sampling leads to low efficiency and unstable model fitting when the surfaces are smooth and densely distributed.
The improved RANSAC algorithm introduces a local sampling strategy. First, normal vectors for all points are estimated using k-d tree structures and principal component analysis. For a point \(p_i\), the covariance matrix with its neighbors is computed by:
\[
C = \frac{1}{n}\sum_{i=1}^{n}(p_i – \bar{p})(p_i – \bar{p})^T
\]
where \(\bar{p}\) is the centroid of the neighbor points. The eigenvector corresponding to the smallest eigenvalue of \(C\) is the normal vector. Then, a random point is selected, and its neighbors within a radius r are found. The average cosine value between all neighbor normals and the vertical vector \(n_v=(0,0,1)\) is computed:
\[
\gamma = \frac{1}{n}\sum_{i=1}^{n} n_v \cdot n_i
\]
If \(\gamma\) is greater than a pre-set threshold, the local region is likely on a horizontal planar surface. From this region, three points are randomly selected as the seed points to fit a plane. This local sampling avoids selecting seed points from noisy areas or steep transitions, such as weld edges or defects.
A misclassification correction mechanism is also applied. During multi-plane fitting, some interior points from one plane are wrongly assigned to another plane. For each point in the segmented plane set, its vertical distance to each candidate plane as well as its Euclidean distance to the plane centroid is evaluated. If both distances satisfy the given thresholds, the point is reclassified into the most appropriate plane based on the majority label of its neighbors.
Furthermore, a conservative inlier distance threshold may lead to over-segmentation, where one physical surface is split into many patches. To correct this, an Euclidean clustering procedure is performed on the segmented spatial patches. The clustering definition is based on the point-to-point proximity, and patches separated by less than the threshold are merged.
The final algorithm extracts two prominent planar patches: the top cover patch and the sealing nail patch. The patch with fewer points is the sealing nail patch. The centroid of the sealing nail surface is calculated, and the welding zone is determined as a circular ring region around the centroid with given inner and outer radii.

2.3 Experimental Results of Segmentation
To validate the performance of the proposed segmentation method, experiments are carried out on 196 preprocessed sealing nail point clouds from the vehicle traction battery production line. The evaluation metrics include Precision, Recall, and F1-score, which are defined as:
\[
P = \frac{TP}{TP+FP}, \quad R = \frac{TP}{TP+FN}, \quad F1 = 2\times \frac{PR}{P+R}
\]
Comparative results are listed in the following table.
| Algorithm | Time (s) | Precision (%) | Recall (%) | F1 score (%) |
|---|---|---|---|---|
| Traditional RANSAC | 6.82 | 76.24 | 82.19 | 79.10 |
| Region growing | 8.73 | 83.10 | 81.57 | 82.33 |
| Euclidean clustering | 3.45 | 36.23 | 99.73 | 53.15 |
| Proposed method | 6.14 | 82.44 | 93.76 | 87.74 |
The proposed method achieves the highest F1 score, effectively extracting the sealing nail and welding area for subsequent defect detection.
3. Deep Learning Based Defect Detection
3.1 Defect Types and Dataset Construction
The collected defect dataset from the vehicle traction battery contains two types of sealing nails: flat nails and concave nails. In this work, defects are classified into five categories: burst, pit, molten bead, warpage, and pinhole. Burst and molten bead are protruding defects, while pit and pinhole are concave defects. Warpage indicates a global tilt or partial offset of the sealing nail relative to the cover. The dataset consists of 929 original samples, including 271 normal samples and 658 defective samples. To enlarge the dataset and improve generalization, multiple data augmentation techniques are used:
Random rotation around the z-axis:
\[
\begin{bmatrix}
x’ \\ y’ \\ z’
\end{bmatrix}
=
\begin{bmatrix}
\cos\theta & -\sin\theta & 0 \\
\sin\theta & \cos\theta & 0 \\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
x \\ y \\ z
\end{bmatrix}
\]
Translation along the x-axis:
\[
\begin{bmatrix}
x’ \\ y’ \\ z’
\end{bmatrix}
=
\begin{bmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
x \\ y \\ z
\end{bmatrix}
+
\begin{bmatrix}
t_x \\ 0 \\ 0
\end{bmatrix}
\]
Horizontal flip with respect to \(x=t\):
\[
\begin{bmatrix}
x’ \\ y’ \\ z’
\end{bmatrix}
=
\begin{bmatrix}
-1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
x \\ y \\ z
\end{bmatrix}
+
\begin{bmatrix}
2t \\ 0 \\ 0
\end{bmatrix}
\]
Uniform scaling:
\[
\begin{bmatrix}
x’ \\ y’ \\ z’
\end{bmatrix}
=
\begin{bmatrix}
s_x & 0 & 0 \\
0 & s_y & 0 \\
0 & 0 & s_z
\end{bmatrix}
\begin{bmatrix}
x \\ y \\ z
\end{bmatrix}
\]
After augmentation, the total number of samples is 2787. Details are listed below.
| Category | Normal | Burst | Pit | Molten bead | Warpage | Pinhole |
|---|---|---|---|---|---|---|
| Number | 655 | 406 | 271 | 248 | 316 | 361 |
The dataset is split into training (2257 samples), validation (251 samples), and testing (279 samples) sets.
3.2 Local Graph Attention Filter
To solve the issue of confusing coordinate space and feature space information, a Local Graph Attention Filter module is proposed to model the correlation between local points. The graph is built with vertices \(\mathcal{V}\) and edges \(\mathcal{E}\). For a central point \(p_i\), the neighbor set \(\mathcal{N}(i)\) is constructed using radius search followed by k nearest neighbor sampling. A learnable correlation matrix \(C\) is computed by:
\[
C_{ij} = \phi_q(x_i) – \phi_k(x_i-x_j)
\]
where \(x_i\) and \(x_j\) are the feature vectors of corresponding points, and \(\phi_q\), \(\phi_k\) are linear projections. The spatial relation is encoded with a distance-based adjacency matrix:
\[
\hat{A}_{ij} = A_{ij} \cdot \exp\left(-\left\|p_i-p_j\right\|^2\right)
\]
\[
A’ = D^{-1/2}\hat{A}D^{-1/2}
\]
Here, \(D\) is the degree matrix, and a learnable spatial offset is defined as:
\[
\sigma_{ij} = M_p(p_i-p_j)
\]
where \(M_p\) is an MLP. The attention logits become:
\[
e_{ij} = M_e (C_{ij} \cdot A’_{ij})
\]
After normalizing by softmax:
\[
a_{ij} = \frac{\exp(e_{ij})}{\sum_{l\in\mathcal{N}(i)} \exp(e_{il})}
\]
The output features are then obtained by:
\[
y_i = \psi(x_i) + \sum_{j\in\mathcal{N}(i)} a_{ij} \odot \left(\phi_v(x_i-x_j)+\sigma_{ij}\right)
\]
where \(\psi\) is a nonlinear transformation and \(\phi_v\) is another linear projection.
3.3 Spatial Attention Graph Pooling
Motivated by the need to emphasize spatial information during downsampling, a Spatial Attention Graph Pooling module is proposed. Let \(p_i\) be the coordinates of the \(i\)-th sampled point after farthest point sampling, and \(p_j\) be one of its neighbors in the original dense graph. The spatial attention weight is computed as:
\[
\hat{w}_{ij} = M_w (\varphi_q(p_i) – \varphi_k(p_j))
\]
\[
r_{ij} = \frac{\exp(\hat{w}_{ij})}{\sum_{l\in\mathcal{N}(i)} \exp(\hat{w}_{il})}
\]
where \(M_w\) is an MLP, and \(\varphi_q\), \(\varphi_k\) are linear functions. The graph pooling operation aggregates neighbor features via:
\[
F_i = \sum_{j\in\mathcal{N}(i)} r_{ij} \odot \varphi_v(F_{ij})
\]
where \(F_{ij}\) denotes the feature of the \(j\)-th neighbor associated with the \(i\)-th point.
3.4 Loss Function
To address the extreme class imbalance in the point cloud, the cross-entropy loss is improved by weighted terms. The weight vector is computed as:
\[
\hat{w} = \left[\left(\frac{n_{max}}{n_1}\right)^{1/2}, \left(\frac{n_{max}}{n_2}\right)^{1/2}, \ldots, \left(\frac{n_{max}}{n_k}\right)^{1/2}\right]
\]
\[
w_i = \frac{\hat{w}_i}{\sum_{j=1}^{k} \hat{w}_j}
\]
where \(n_{max}\) is the number of points in the largest category and \(n_i\) is the number of points in category \(i\). The final loss function is:
\[
Loss = -\sum_{i=1}^{k} w_i \log \frac{\exp(x_i)}{\sum_{l=1}^{k}\exp(x_l)} y_i
\]
3.5 Cross-Density Feature Fusion
In the graph pyramid network, the shallow layers preserve high-density point cloud features and rich local details, while deeper layers contain low-density point cloud features with rich semantic context. To improve the detection performance on small-scale defects such as pinholes, molten beads, and bursts, a Cross-Attention-Based Cross Density Feature Fusion module is introduced.
Let layer \(l\) be the central feature layer. The higher-density feature from layer \(l-1\) and the lower-density feature from layer \(l+1\) are selected as key and value sources. The central features of layer \(l\) act as queries. The module first uses k nearest neighbor to construct the corresponding neighbor sets \(\mathcal{N}_{l-1}(i)\) and \(\mathcal{N}_{l+1}(i)\). The enhanced feature from the higher-density branch is:
\[
y_{l-1,i} = \sum_{j\in\mathcal{N}_{l-1}(i)} \rho\left(\chi_q(x_l) \cdot \chi_k^{l-1}(x_{l-1})\right) \cdot \chi_v^{l-1}(x_{l-1})
\]
The enhanced feature from the lower-density, more semantic branch is:
\[
y_{l+1,i} = \sum_{j\in\mathcal{N}_{l+1}(i)} \rho\left(M(\chi_q(x_l) – \chi_k^{l+1}(x_{l+1}))\right) \odot \chi_v^{l+1}(x_{l+1})
\]
In the above, \(\chi_q\), \(\chi_k\) and \(\chi_v\) are linear projections, \(\rho\) is the softmax function, and \(M\) is an MLP for vector attention. Finally, the three enhanced features (original, upsampled detail, and downsampled semantic) are concatenated and passed through an MLP to produce the output fused feature \(F\).
3.6 Evaluation Metrics
Overall accuracy (OA) is defined as:
\[
OA = \frac{\sum_{i=1}^{k} n_{ii}}{\sum_{i=1}^{k}\sum_{j=1}^{k} n_{ij}}
\]
Class mean accuracy is:
\[
mAcc = \frac{1}{k}\sum_{i=1}^{k} \frac{n_{ii}}{\sum_{j=1}^{k} n_{ij}}
\]
Class IoU is:
\[
IoU_i = \frac{P_{i,pred} \cap P_{i,true}}{P_{i,pred} \cup P_{i,true}}
\]
Mean IoU is:
\[
mIoU = \frac{1}{k}\sum_{i=1}^{k} \frac{n_{ii}}{\sum_{j=1}^{k}n_{ij} + \sum_{j=1}^{k}(n_{ji} – n_{ii})}
\]
3.7 Training Configurations
| Parameter | Value |
|---|---|
| Epochs | 300 |
| Batch size | 8 |
| Number of input points | 16384 |
| Optimizer | AdamW |
| Initial learning rate | 0.01 |
| Learning rate schedule | Multi-step decay |
| GPU | NVIDIA RTX 4070 |
| PyTorch version | 2.2.1 |
3.8 Comparison with Other Networks
A comparative study is carried out with several representative state-of-the-art point cloud semantic segmentation networks. The test dataset contains point clouds of the sealing nail from the vehicle traction battery assembly process. The results are shown in the following table.
| Model | OA (%) | mAcc (%) | mIoU (%) | Burst IoU (%) | Pit IoU (%) | Molten beads IoU (%) | Warpage IoU (%) | Pinhole IoU (%) |
|---|---|---|---|---|---|---|---|---|
| LGANet + CDF | 99.13 | 96.20 | 81.25 | 80.06 | 71.91 | 75.99 | 89.89 | 70.03 |
| GACNet | 96.68 | 87.96 | 70.85 | 56.88 | 67.52 | 54.64 | 87.93 | 59.37 |
| PointNet | 82.66 | 72.46 | 45.74 | 28.33 | 30.01 | 21.53 | 62.64 | 34.95 |
| PointNet++ | 89.33 | 84.65 | 62.67 | 47.91 | 59.32 | 42.37 | 81.64 | 46.53 |
| PTv1 | 98.77 | 90.96 | 72.83 | 68.54 | 62.83 | 58.37 | 89.67 | 58.37 |
| PTv3 | 99.03 | 94.96 | 75.13 | 77.32 | 67.98 | 60.44 | 89.17 | 56.21 |
| OA-CNN | 98.72 | 91.13 | 74.04 | 64.89 | 66.91 | 64.87 | 88.37 | 60.04 |
The proposed LGANet+CDF model outperforms other models on all major metrics, especially on small defects such as burst, molten bead, and pinhole. This validates the superiority of the proposed design in detecting subtle geometric defects of the sealing nail in the vehicle traction battery application.
To evaluate the generalization ability of the proposed model, experiments are performed on a public sewer defect dataset S3DSS. The results are given below.
| Model | LGANet | DLNet | PointNeXt | DeepGCN | DGCNN | PointNet++ |
|---|---|---|---|---|---|---|
| OA (%) | 98.94 | 97.51 | 96.25 | 83.96 | 82.96 | 83.42 |
| mF1 score (%) | 95.33 | 87.26 | 73.55 | 41.73 | 44.36 | 42.31 |
| mIoU (%) | 91.12 | 79.24 | 65.64 | 32.68 | 28.29 | 32.22 |
| Spalling IoU | 86.84 | 64.51 | 2.02 | 3.58 | 1.06 | 0.00 |
| Blockage IoU | 95.74 | 94.90 | 95.28 | 59.64 | 51.36 | 30.27 |
| Corrosion IoU | 80.38 | 42.28 | 29.17 | 1.82 | 8.99 | 17.32 |
| Misalign IoU | 93.84 | 87.88 | 80.07 | 9.65 | 5.63 | 25.55 |
| Deposit IoU | 91.33 | 77.82 | 68.40 | 40.09 | 16.75 | 66.94 |
| Displace IoU | 95.68 | 89.18 | 85.07 | 30.18 | 23.17 | 18.53 |
| RubberRing IoU | 86.32 | 79.84 | 68.83 | 31.54 | 34.85 | 8.07 |
The improved LGANet achieves higher accuracy on this public benchmark, indicating strong generalization ability of the proposed architecture.
3.9 Ablation Studies
Ablation experiments are designed to isolate the contribution of each proposed module. First, the effects of the Local Graph Attention Filter and Spatial Attention Graph Pooling are evaluated.
| Model | LGAF | SAG Pooling | OA (%) | mAcc (%) | mIoU (%) |
|---|---|---|---|---|---|
| GACNet | × | × | 96.68 | 87.96 | 70.85 |
| GACNet+LGAF | √ | × | 97.38 | 90.14 | 77.17 |
| GACNet+SAG Pooling | × | √ | 97.96 | 88.95 | 74.81 |
| LGANet | √ | √ | 99.47 | 92.68 | 79.23 |
The second ablation study examines the contribution of different information flows within the cross-density feature fusion architecture.
| Down-flow | Up-flow | Burst IoU (%) | Pit IoU (%) | Molten beads IoU (%) | Warpage IoU (%) | Pinhole IoU (%) |
|---|---|---|---|---|---|---|
| LGANet | × | 78.17 | 72.17 | 71.33 | 91.61 | 64.95 |
| LGANet-CDF(a) | √ | 79.63 | 71.24 | 74.31 | 87.64 | 71.37 |
| LGANet-CDF(b) | × | 76.62 | 73.81 | 71.12 | 92.94 | 63.14 |
| LGANet-CDF | √ | 80.06 | 71.91 | 75.99 | 89.89 | 70.03 |
The third ablation study explores the impact of applying feature fusion at different levels of the graph pyramid. The architectures are labeled (a), (b), (c), (d), and (e), where (a) denotes the basic LGANet and (d) is the final LGANet-CDF.
| Architecture | mAcc (%) | mIoU (%) | ΔmIoU (%) |
|---|---|---|---|
| a (baseline LGANet) | 92.68 | 79.23 | – |
| b | 92.32 | 78.96 | -0.27 |
| c | 94.03 | 80.11 | +0.88 |
| d (LGANet-CDF) | 96.20 | 81.25 | +2.02 |
| e | 94.97 | 80.69 | +1.46 |
The final LGANet-CDF design achieves the best mIoU improvement of 2.02% over the base LGANet, confirming the necessity of using both bottom-up and top-down feature fusion within the pyramid structure.
3.10 Robustness on Sparse Point Clouds
To verify robustness under varying point densities, random sampling is applied to the input point clouds during testing. The model is evaluated with point counts from 16384 down to 2048. When the number of points is reduced from 16384 to 4096, the accuracy of LGANet+CDF stays within a 2% decrease. Compared with other methods, the proposed network consistently achieves the highest mAcc at all sampling densities, proving great stability across different point cloud resolutions.
4. Software Platform Development
4.1 Platform Architecture
Based on the PyQt framework, a software platform is developed for the automatic inspection of the sealing nail defects in the vehicle traction battery. The platform uses PyCharm as the development environment. Its interface includes both operation buttons and visualization windows. The left region displays the input point cloud converted into a depth image, while the right display window shows the detection result after the deep learning inference.
4.2 Functions and Tests
The main interface of the software is shown in the following figure. The software contains five function buttons: “Select Weight”, “Select Point Cloud”, “Fit Weld Bead”, “Detect”, and “Save Defect Data”. The user first chooses a trained network weight file with extension .pth. Then the user selects one point cloud data file in .txt format. The depth image is rendered and shown on the left. The software provides a manual input for the inner and outer radii of the weld zone. When the user clicks “Fit Weld Bead”, the sealing nail’s center is calculated and the weld region is highlighted with a green translucent color. Then, clicking “Detect” runs the deep learning model. If defects are found, the software marks the corresponding defect points with distinct colors. For the warpage defect, because the entire sealing nail body is distorted, no welding-region segmentation is necessary; the defect detection can be directly performed on the whole point cloud. Finally, the user can click “Save Defect Data” to export the detected defect type, number of defects, and additional comments into a txt file stored in the same directory as the input point cloud.
The software is designed to be user-friendly, enabling workers without deep learning expertise to conveniently inspect sealing nail defects on the production floor.
5. Conclusion and Outlook
In this paper, a comprehensive method for sealing nail welding defect detection on the vehicle traction battery is developed using point cloud deep learning. The work consists of several major parts. An improved RANSAC algorithm is first presented for extracting the sealing nail and the welding region from raw laser-scanned point clouds, removing interference from background surfaces. A deep learning semantic segmentation model LGANet is designed by incorporating the Local Graph Attention Filter and the Spatial Attention Graph Pooling, which greatly improves the ability to identify defect morphology and boundaries. Furthermore, a Cross-Density Feature Fusion module based on cross-attention is introduced to fuse multi-density features within the graph pyramid. This module specifically enriches the semantic representation of small-scale defects, increasing detection rates for burst, molten bead, and pinhole defects. Extensive comparative and ablation experiments demonstrate that the proposed network achieves superior accuracy over other state-of-the-art point cloud segmentation models, both on the sealing nail dataset and a public sewer dataset. Finally, a PyQt-based detection software platform is implemented to achieve automated inspection and visualization of the sealing nail defects, helping to improve the production efficiency and safety of the vehicle traction battery.
Future research directions include expanding the dataset with more varying industrial environments and using generative methods to synthesize rare defect samples. The inference speed can be further improved by applying lightweight network structures and model distillation. Multi-modal fusion using both 2D intensity images and 3D point clouds could provide complementary information, increasing accuracy even more. Online learning and adaptive model update mechanisms can also be developed to handle the changing defect patterns that appear when the welding process drifts, preserving the long-term reliability of the detection system in vehicle traction battery manufacturing lines.
