A battery surface defect detection method based on image recognition
Patent Information
- Application Number
- CN202611017944.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-09
- Publication Date
- 2026-10-13
- Estimated Expiration
- 2046-07-09
AI Technical Summary
[0004]然而,该传统检测方法仅依赖单一节点的单次成像结果进行判断,无法有效关联同一电池在不同生产或流转节点下的外观连续性信息,从而不能从工艺演进或时间维度反映缺陷的真实发展趋势,最终难以提前识别处于早期阶段的隐蔽性缺陷及具有潜在演化风险的表面异常,逐渐无法满足高安全等级电池产品对检测精准性与前瞻性的需求
(1)、改进尺度不变特征转换算法适配电池生产多检测节点的场景需求,解决了传统单次成像检测中缺乏跨节点关联的问题,其能有效建立同一电池在不同生产流转节点下的表面区域对应关系,弱化光照、反光等偶然因素对检测结果的干扰,为后续从工艺演进角度分析缺陷演化趋势提供稳定的结构支撑,适配多节点连续检测的工业场景需求。
Smart Images

Figure CN122530216B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of battery surface defect detection technology, specifically to a battery surface defect detection method based on image recognition. Background Technology
[0002] With the popularization of electronic devices, soft-pack lithium-ion batteries have become core power supply devices due to their advantages such as high energy density and flexible design. Surface defects (such as micro-cracks in the shell, local bulges, etc.) can affect the safety and service life of the battery. Therefore, surface defect detection in the production process has become a key link to ensure product quality. In industrial scenarios, battery surface defects often exhibit small size and low contrast characteristics, and are subject to interference from aluminum-plastic film reflection and production noise, which puts forward strict requirements on the accuracy and anti-interference ability of detection technology.
[0003] In the field of existing battery surface defect detection, the most widely used method is static detection based on single-image recognition. This method uses an industrial camera to take a single image of the battery surface at a fixed detection node in the production or circulation process. The acquired image is then preprocessed and its features are analyzed. Based on whether abnormal appearance features (such as grayscale abrupt changes, irregular contours, etc.) appear in the image, it is directly determined whether there are defects on the battery surface, providing a basis for subsequent quality screening.
[0004] However, this traditional detection method relies solely on a single imaging result from a single node for judgment, and cannot effectively correlate the appearance continuity information of the same battery at different production or circulation nodes. Therefore, it cannot reflect the true development trend of defects from the perspective of process evolution or time dimension, and ultimately it is difficult to identify hidden defects in the early stage and surface anomalies with potential evolution risks in advance. Gradually, it cannot meet the requirements of high safety level battery products for detection accuracy and foresight. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a battery surface defect detection method based on image recognition to solve the problems existing in the background technology.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a battery surface defect detection method based on image recognition, comprising the following steps: Step S1: Collect surface images of defective batteries and extract features to obtain defect evolution feature vectors. Cluster the defect evolution feature vectors using a clustering algorithm to obtain evolution discrimination criteria. Step S2: Acquire real-time battery surface images, and perform feature matching on the real-time battery surface images using an improved scale-invariant feature transformation algorithm to obtain the homography matrix; Step S3: Input the real-time battery surface image into the improved Faster R-CNN model, output the bounding box coordinates, determine the abnormal region based on the bounding box coordinates, extract features from the real-time battery surface image based on the homography matrix within the abnormal region, obtain the real-time evolution feature vector, and determine the evolution consistency of the abnormal region based on the evolution discrimination benchmark and the real-time evolution feature vector to obtain the evolution consistency determination result. Step S4: Construct a defect evolution feature template library, extract evolution consistency feature vectors based on the evolution consistency judgment results, perform similarity matching between the evolution consistency feature vectors and the evolution feature template library to obtain the defect type, and realize defect detection on the battery surface.
[0007] Preferably, the step of acquiring surface images of defective batteries and extracting features to obtain defect evolution feature vectors includes the following specific steps: Images of the defective battery surface are acquired and preprocessed to obtain preprocessed defective battery surface images. From these preprocessed images, evolutionary features of each defective region are extracted to obtain a defect evolution feature vector. This defect evolution feature vector includes contour similarity, expansion rate, and boundary continuity coefficient. The formula for calculating the boundary continuity coefficient is as follows: ; in, Let k be the set of defect boundary pixels at the k-th detection node. and These represent the horizontal and vertical gradient magnitudes of the defect region at the (k-1)th detection node. For boundary continuity coefficients, and Let (r,c) represent the gradient magnitudes in the horizontal and vertical directions of the defect region under the k-th detection node, and (r,c) represent the coordinates at the defect boundary.
[0008] Preferably, the specific steps for clustering the defect evolution feature vectors using a clustering algorithm to obtain the evolution discrimination criterion are as follows: The defect evolution feature vectors are clustered using the K-means clustering algorithm. The number of clusters is determined based on the number of defect types. The objective function of K-means clustering is: ; in, For the first The set of feature vectors of class defects For the first Clustering centers of feature vectors of class defects For feature vectors With cluster center The square of the Euclidean distance, is the objective function for K-means clustering, and s is the defect type index; By iteratively optimizing and minimizing the objective function J, the evolutionary feature cluster centers corresponding to the s-th type of defect are obtained. ; Clustering centers for evolutionary features corresponding to type s defects Calculate the set of feature vectors belonging to the s-th type of defect. All sample feature vectors and evolutionary feature cluster centers The standard deviation of the Euclidean distance is used to set a baseline threshold. Thus, the evolutionary discrimination criteria were obtained.
[0009] Preferably, the acquisition of real-time battery surface images, and the matching of features in the real-time battery surface images using an improved scale-invariant feature transformation algorithm to obtain a homography matrix, includes the following steps: Real-time battery surface images are acquired and preprocessed to obtain preprocessed real-time battery surface images. Edge detection and corner detection are performed on the preprocessed real-time battery surface image to obtain a set of corner points. ; Feature points are extracted from the preprocessed real-time battery surface image to obtain a SIFT feature point set. ; Set of corner points and Feature point set By merging and filtering, a set of fused feature points is obtained. ; An improved GLOH descriptor is generated for the fused feature points, and the set of descriptors corresponding to the fused feature points is obtained by dimensionality reduction using PCA. For adjacent detection nodes Extract the fused feature point set and its corresponding descriptor subset respectively, and perform feature matching on the descriptor subset to obtain matching point pairs; Based on the matching point pairs, the homography matrix H is obtained by using the RANSAC algorithm.
[0010] Preferably, the step of generating improved GLOH descriptors for the fused feature points and obtaining the descriptor set corresponding to the fused feature points through PCA dimensionality reduction includes the following steps: The improved GLOH descriptor generation process is as follows: A 30×30 pixel descriptor window is constructed in polar coordinates, centered on the fused feature point. This window is divided into 17 concentric circular sub-regions by radius. The gradient magnitude and direction of each pixel within each sub-region are calculated. The gradient direction is divided into 8 intervals. The sum of the gradient magnitudes in each gradient direction for each sub-region is calculated to generate the initial descriptor vector. ; The PCA dimensionality reduction process involves selecting fusion feature points from historical battery samples and constructing a feature matrix. Calculate the covariance matrix Σ of the eigenvalues, solve for the eigenvalues and corresponding eigenvectors of the covariance matrix Σ, and construct the projection matrix by selecting the eigenvectors corresponding to the first 64 largest eigenvalues. , the initial descriptor vector Multiplying by the projection matrix yields the dimensionality-reduced descriptor. , for dimensionality reduction descriptors L2 normalization is performed to obtain the descriptor subset corresponding to each fused feature point. .
[0011] Preferably, the step of inputting a real-time battery surface image into an improved Faster R-CNN model, outputting bounding box coordinates, and determining anomaly regions based on the bounding box coordinates includes the following steps: An improved Faster R-CNN model is constructed and trained to obtain a trained improved Faster R-CNN model. Real-time battery surface images are input into the trained improved Faster R-CNN model, which outputs the confidence score *s* and bounding box coordinates for each candidate region in the image. A confidence threshold is then set. When s≥ When this happens, the candidate region is determined to be an abnormal region and is denoted as [missing information]. ; For the abnormal region of node k Through homography matrix Mapping to the (k-1)th node yields the mapped region. ,Will As input to the candidate region at node k-1 of the improved Faster R-CNN model, the model outputs the anomaly region corresponding to that node. Repeat this process to obtain the tracking results of the same abnormal region at all detection nodes. .
[0012] Preferably, the construction of the improved Faster R-CNN model is as follows: The improved Faster R-CNN model is as follows: A feature pyramid network is introduced into the ResNet101 backbone network to obtain a fused feature map. - In the fusion feature map The formula for calculating the feature correlation in the horizontal and vertical directions using the embedded cross-attention module is as follows: ; ; in, and These are the row index and column index of the query feature map, respectively. and These are the row and column indices of the key feature map, respectively. To query the feature vectors of all rows in the v-th column of feature map Q, The transpose of the eigenvector in the u-th column of the key feature map K. and These are the correlation coefficients in the horizontal and vertical directions, respectively. To query feature map Q, the first... The feature vectors of all columns of the row, For the key feature map K, the first Transpose of row eigenvectors This is a vector dot product operation; right and Applying the softmax function along the channel dimension yields the horizontal attention weights. and vertical attention weights Then it is integrated with the value feature map V to obtain the enhanced feature map after incorporating the attention mechanism. ; ROI Align is used to uniformly divide the candidate region into small units. Sampling points are set in each small unit. The pixel value of the sampling points is calculated by bilinear interpolation. Max pooling is performed on the sampling points of each small unit to obtain a fixed-size feature map. The anchor box size of the RPN is optimized by K-means clustering, and the width w and height h of the bounding boxes of all annotated anomaly regions are counted to obtain the set of bounding box sizes. Set the number of clusters and use a distance formula based on the intersection-union ratio: ,in, For a single bounding box, As cluster center, The intersection-union ratio of the bounding box and the cluster center is used to iteratively optimize the cluster center, and finally obtain the optimized anchor box size.
[0013] Preferably, within the abnormal region, feature extraction is performed on the real-time battery surface image based on the homography matrix to obtain a real-time evolution feature vector. Based on the evolution discrimination benchmark and the real-time evolution feature vector, evolution consistency is determined for the abnormal region to obtain an evolution consistency determination result. This includes the following specific steps: Within the abnormal region, the contour point set of each node's abnormal region is extracted using the chain code method, and the contour similarity is calculated to form a contour stability feature sequence. ; Calculate the area of the abnormal region for each node. The expansion rate is obtained, forming an expansion trend characteristic sequence. Extract the boundary gradient values of the abnormal regions of each node, calculate the boundary continuity coefficient, and form a boundary continuity feature sequence. ; Calculate the grayscale value of all pixels within the abnormal region of each node, and then calculate the average grayscale value. and gray variance Forming a gray-scale mean feature sequence and gray-scale variance feature sequence The extracted four types of evolutionary feature sequences are integrated into a real-time evolutionary feature vector. ; Calculate the profile stability index Specifically, the mean of the contour stability feature sequence is set to a threshold. ; Calculate the grayscale consistency index Set threshold Calculate the location continuity index and set a threshold. Calculate the real-time evolution feature vector Euclidean distance from the cluster centers of various defects in the evolutionary discrimination criterion ; The final evolutionary consistency determination result is as follows: when an abnormal region simultaneously meets the following two conditions, it is considered to have defect evolutionary consistency: , There exists a certain type of defect benchmark that makes ∈ If the abnormal region appears only in a single node or does not meet any of the above conditions, it is determined to be a non-evolutionary anomaly.
[0014] Preferably, the construction of the defect evolution feature template library and the extraction of evolutionary consistency feature vectors based on the evolutionary consistency determination results specifically involve: A defect evolution feature template library was constructed, which was divided into 5 types of templates according to common defect types on the battery surface. Each type of template corresponds to no less than 100 historical samples. All samples were confirmed by manual re-inspection and physicochemical analysis, and have complete evolution data of 4 detection nodes. For historical samples of each type of defect, the contour stability feature sequence, morphological expansion trend feature sequence, and boundary continuity feature sequence are extracted respectively. K-means clustering is used to calculate the cluster center of the feature sequence of this type of sample, which serves as the standard feature sequence of the template, thus obtaining the standard sequence of contour stability features. Standard sequence of morphological expansion trend characteristics and standard sequences of boundary continuity characteristics ; Calculate the standard deviation of the Euclidean distance between the feature sequence of each class of samples and the cluster center, and set the template's fault tolerance threshold range as []. -1.5 , +1.5 The tolerance threshold range of the contour stability feature sequence was calculated respectively. ], the fault tolerance threshold range of the morphological expansion trend characteristic sequence [ The fault tolerance threshold range for boundary continuity feature sequences. ]; Templates for the five types of defects are stored in a structure of defect type-standard sequence-tolerance threshold range to obtain a defect evolution feature template library. Based on the evolution consistency determination results, evolution consistency feature vectors are extracted from surface regions that are determined to have evolution consistency. .
[0015] Preferably, the step of performing similarity matching between the evolutionary consistent feature vector and the evolutionary feature template library to obtain the defect type specifically involves: Verify whether each dimension of the feature sequence to be matched falls within the fault tolerance threshold range of the corresponding template. If a template meets the fault tolerance threshold of the above three types of feature sequences, then the template is a candidate template for the region to be matched. If no template meets the threshold, it is initially judged as an "atypical defect" and enters the subsequent overall similarity verification. If multiple templates meet the threshold, they are all included in the candidate template set. For each template in the candidate template set, the similarity between the feature vector to be matched and the standard feature sequence of the template is calculated using weighted Euclidean distance. ; Set a similarity threshold Tsim; when the region to be matched is similar to a candidate template... If the similarity is less than or equal to Tsim, then the template is determined to be a successful match with the region to be matched. When the region to be matched is successfully matched with at least one template in the candidate template set, the defect type corresponding to the template with the lowest similarity is selected, the region is determined to be a "real defect", and the defect type is recorded.
[0016] This invention provides a battery surface defect detection method based on image recognition, involving machine learning and deep learning technologies, which has the following beneficial effects: (1) Improved scale-invariant feature transformation algorithm adapts to the scenario requirements of multiple detection nodes in battery production. It solves the problem of lack of cross-node correlation in traditional single imaging detection. It can effectively establish the surface area correspondence of the same battery under different production flow nodes, weaken the interference of accidental factors such as illumination and reflection on the detection results, and provide stable structural support for subsequent analysis of defect evolution trends from the perspective of process evolution. It adapts to the industrial scenario requirements of continuous detection of multiple nodes.
[0017] (2) The basic Faster R-CNN model addresses the pain points of traditional static detection being prone to false positives and false negatives. It can quickly screen out the suspected abnormal areas of each node and clarify the candidate range of defects. With the help of the previous foundation of cross-node association, the model avoids the judgment bias caused by image noise or random anomalies of a single node, laying a solid foundation for subsequent accurate positioning and evolutionary analysis, and meeting the core needs of efficient initial screening and reduced false positive rate in industrial production.
[0018] (3) The improved Faster R-CNN model, which integrates FPN and cross-attention mechanism, further overcomes the problem that traditional methods are difficult to identify early hidden defects on the basis of the initial screening of the basic model. Multi-scale feature fusion enhances the feature extraction capability of small-sized, low-contrast defects. Attention mechanism effectively suppresses background interference, making the abnormal area more accurate. It can capture surface anomalies with potential evolution risks in advance, significantly improving the accuracy and foresight of detection, and meeting the detection requirements of high-safety-level batteries. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart of the steps of a battery surface defect detection method based on image recognition proposed in this invention; Figure 2 This is a step hierarchy diagram of obtaining the evolution consistency determination result in a battery surface defect detection method based on image recognition proposed in this invention; Figure 3 This is a step hierarchy diagram of obtaining defect types in a battery surface defect detection method based on image recognition proposed in this invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] Please see Figures 1-3 The present invention provides a technical solution: a method for detecting surface defects in batteries based on image recognition.
[0023] Step S1: Collect surface images of defective batteries and extract features to obtain defect evolution feature vectors. Cluster the defect evolution feature vectors using a clustering algorithm to obtain evolution discrimination criteria. Select no fewer than 500 battery samples from historical production processes that have been confirmed to have surface defects through manual re-inspection and physicochemical analysis. These samples should cover typical defect types such as microcracks in the casing, local bulges, corrosion marks, foreign matter adhesion, and early processing defects. The number of samples for each defect type should be no less than 80 to ensure statistical significance. The samples should contain complete production flow records, clearly indicating the timestamps of each sample at each testing node (e.g., after electrode forming, after packaging, after 3 days of storage, after transportation simulation, etc.). The time interval between two adjacent consecutive testing nodes (i.e., key process nodes that connect the preceding and following processes in the production flow) should be set to 2-4 hours according to the battery production process. The transportation simulation node should use a standard vibration table to simulate the transportation environment (vibration frequency 5-10Hz, duration 30 minutes).
[0024] For each sample, the defective battery surface image at each detection node is uniformly preprocessed. First, a 5×5 median filter is used to remove noise from the production environment. Then, histogram equalization is used to enhance the contrast between the defective area and the background, resulting in the preprocessed defective battery surface image.
[0025] For the preprocessed defective battery surface image, feature extraction is performed on the evolution characteristics of each defect region to obtain a defect evolution feature vector. Specifically, the defect evolution feature vector is as follows: Defect region contour stability characteristics: The contour of the defect region at each detection node is extracted using the chain code method to obtain the contour point set. Where the superscript k represents the k-th detection node (k=1,2,...,M, where M is the total number of detection nodes), and N is the total number of contour points, contour similarity is defined to characterize contour stability, and the formula for calculating contour similarity is: ; in, Let q be the coordinates of the q-th point of the defect profile under the (k-1)-th detection node. Let p be the coordinates of the p-th point of the defect profile under the k-th detection node. For contour similarity, The coordinates are the center coordinates of the contour.
[0026] The numerator is the sum of the minimum Euclidean distances between the contour points of the k-th node and the (k-1)-th node, and the denominator is the average distance between the contour points of the k-th node. The value range is [0,1], and the closer it is to 0, the stronger the contour stability. When the value is less than 0.1, the contour is considered to be in a stable state.
[0027] Calculate the area of the defect region under each detection node. The unit is pixels. The connected component area calculation method is used to count the total number of pixels within the defective region whose grayscale values meet a preset threshold (automatically obtained through the Otsu algorithm), and the expansion rate is defined. The formula representing the trend of morphological expansion is: ; in, The time interval between the (k-1)th detection node and the kth detection node is expressed in hours. Let the area be the defect region at the k-th detection node. Let the area be the defect region at the (k-1)th detection node. For expansion rate.
[0028] The value is a real number; a positive number indicates defect expansion, a negative number indicates defect contraction (such as foreign matter falling off), and 0 indicates no change in area. When the value is greater than 0.05, the defect is considered to have a significant tendency to expand.
[0029] Defect boundary continuity characteristics: Extract the boundary gradient value of the defect region under each detection node. The boundary gradient is calculated using the Sobel operator. The formulas for calculating the horizontal and vertical gradients are as follows: ; ; Where f(r,c) is the gray value of the coordinates (r,c) at the defect boundary. and Let (r,c) be the horizontal and vertical gradient magnitudes of the defect region under the k-th detection node, and (r,c) be the coordinates at the defect boundary. By processing the defect region contour point set with the Zhang-Suen fast parallel thinning algorithm, and by iteratively deleting non-skeleton pixels on the contour edge (satisfying the rule of "not destroying contour connectivity and not deleting endpoint pixels"), a defect edge containing only a single pixel is finally obtained. The coordinates of all pixels on this edge are the coordinates at the defect boundary.
[0030] It should be noted that the defect boundary is based on the defect contour, and the boundary coordinates are all derived from the refinement and screening of the contour point set. Without the contour point set, it is impossible to accurately locate the boundary position. The contour point set is the "raw material" for boundary extraction, and the boundary is the "refined result" of the contour point set.
[0031] Define boundary continuity coefficients The calculation formula is: ; in, Given the set of defect boundary pixels at the k-th detection node, the boundary is defined using Canny edge detection. and These represent the horizontal and vertical gradient magnitudes of the defect region at the (k-1)th detection node. This is the boundary continuity coefficient.
[0032] The numerator is the sum of the gradient magnitudes of the current node's boundary, the denominator is the sum of the gradient magnitudes of the previous node's boundary, and the boundary continuity coefficient is... The value range is [0, +∞). Values close to 1 indicate strong boundary continuity. When 0.8 < When the value is less than 1.2, the defect boundary is determined to be in a continuous and stable state.
[0033] For each historical defect sample, its defect evolution feature vector at the k-th detection node is: .
[0034] The defect evolution feature vectors are clustered using the K-means clustering algorithm to obtain the evolution discrimination criterion. The number of clusters K is set according to the number of defect types (equal to the number of defect types, such as K=5 for 5 types of defects). The objective function of K-means clustering is: ; in, For the first The set of feature vectors of class defects For the first Clustering centers of feature vectors of class defects For feature vectors With cluster center The square of the Euclidean distance, is the objective function for K-means clustering, and s is the defect type index.
[0035] By iteratively optimizing and minimizing the objective function J, the evolutionary feature cluster centers of various defects are obtained. .
[0036] Clustering centers for evolutionary features corresponding to type s defects Calculate the set of feature vectors belonging to the s-th type of defect. The feature vectors of all samples and the cluster centers of that class Euclidean distance standard deviation Set a baseline threshold (Based on the 3σ principle, covering more than 95% of normal evolutionary samples), the final evolutionary discrimination benchmark includes cluster centers of evolutionary features of various defects. and corresponding threshold range The baseline is stored in the form of a feature vector matrix, where the row index is the defect type, the column index is the evolution feature dimension, and the elements are the cluster center value and threshold boundary.
[0037] Select 10% of historical defect samples as the validation set, and match the evolutionary feature vectors of the validation set samples with the constructed evolutionary discrimination benchmark: calculate the sample feature vectors and each cluster center. The Euclidean distance, if the distance falls within the threshold range of a certain type of defect. If the sample's evolutionary characteristics are consistent with the defect benchmark, the verification must meet the following conditions: the matching accuracy of each type of defect is not less than 90%, the mismatch rate (matching to a non-corresponding defect class) is not higher than 5%, and the missed match rate (not matching to any defect class) is not higher than 3%. If the above indicators are not met, the sample screening stage is returned, the number of samples of the corresponding defect type is increased, or the feature extraction parameters are optimized (such as adjusting the median filter window size and the number of clusters K), and the feature extraction and benchmark construction steps are re-executed until the benchmark verification is passed, forming the final evolutionary discrimination benchmark that can be used for subsequent detection.
[0038] Step S2: Acquire real-time battery surface images, and perform feature matching on the real-time battery surface images using an improved scale-invariant feature transformation algorithm to obtain the homography matrix; Based on the battery production and distribution processes, four core testing nodes are pre-set, namely: Node (1 hour after electrode packaging is completed), node (After being stored and left to stand for 12 hours), node (Vibration parameters after simulated transportation vibration: frequency 8Hz, duration 30 minutes), nodes (Final inspection before leaving the factory) The imaging area of each node must completely cover the battery surface (including the front, sides and corner transition areas) to ensure that there are no blind spots in the inspection.
[0039] All detection nodes use the same imaging equipment and environmental parameters, specifically: Hikvision MV-CA050-10GC industrial area array camera (CMOS sensor, resolution 2448×2048, pixel size 3.45μm×3.45μm), 16mm focal length HF16HA-1B lens, and four white strip light sources arranged in a 45° surround illumination (brightness adjusted to 800lx to avoid overexposure due to reflection from the aluminum-plastic film). During imaging, the battery is fixed on a high-precision stage with a stage repeatability accuracy ≤±0.1mm to ensure the consistency of the battery's spatial position at different nodes.
[0040] The imaging is triggered by photoelectric sensors. When the battery reaches the preset position of each detection node, the sensor sends a signal to trigger the camera to take a picture and obtain a real-time image of the battery surface. Each image is accompanied by a timestamp and a unique battery identification code, which facilitates subsequent cross-node data association and traceability.
[0041] The preprocessing process is completely consistent with step S1 to ensure uniform image quality: First, noise in the production environment is removed by 5×5 median filtering. Then, histogram equalization is used to enhance the contrast between battery surface defects and the background. Finally, all images are uniformly scaled to a resolution of 2448×2048 pixels. The preprocessed real-time battery surface image must meet the following requirements: grayscale value range [0,255], grayscale difference between defect area and background ≥30, and no obvious noise interference (noise pixel ratio ≤0.5%), so as to provide a stable image foundation for subsequent feature extraction.
[0042] Using any two adjacent detection nodes as processing units, an improved scale-invariant feature transformation algorithm is used to perform feature matching on real-time battery surface images to obtain a homography matrix. The core process consists of four steps: feature point extraction, feature point description, feature matching, and region mapping, as detailed below: Canny edge detection is performed on the preprocessed real-time battery surface image. First, the image is smoothed using a Gaussian filter (standard deviation set to 1.6, based on the battery surface texture smoothing requirements). Then, pixel gradient magnitude and direction are calculated, and edge refinement is achieved through non-maximum suppression. Finally, a double-threshold method is used to filter strong edge pixels. The double threshold is set to... =50、 =100, the value is determined based on the reflective properties of the aluminum-plastic film on the battery surface and the grayscale variation range of the defect edge: the gradient amplitude is greater than... The pixels with strong edges are between and Pixels connected to strong edges are considered weak edges. All strong edge pixels are included in the initial edge pixel set as the core skeleton of the defect edge. Each weak edge pixel is traversed. If the pixel has an 8-neighborhood connection with a strong edge pixel (i.e., strong edge pixels exist in the top, bottom, left, right, and diagonal directions), it is determined to be an extension of the real defect edge and included in the initial edge pixel set. If it is an isolated weak edge pixel (without neighboring strong edge pixels), it is determined to be noise interference and is removed. The initial edge pixel set is then checked for connectivity. Duplicate pixels and isolated endpoints of non-closed segments are deleted (i.e., the end pixels of edge fragments composed of edge pixels that do not form a complete closed contour and are only scattered short lines or discontinuous line segments). The remaining pixels are sorted in a clockwise direction, and the final edge pixel set E is output.
[0043] Perform SUSAN corner detection within the edge pixel set E, using a circular template with a radius of 3 pixels (a circular coverage area extending 3 pixels outward from the center pixel, containing a total of 37 pixels). Calculate the grayscale difference between each pixel within the template and the center pixel, and define a similar pixel counting function: ; in, The center pixel coordinates of the template The grayscale value of the pixels within the template. The grayscale value of the center pixel. The contrast threshold is set to 20. This value adapts to the range of grayscale variations on the battery surface and avoids false detections caused by reflections. This is a function for counting similar pixels.
[0044] Count the total number of similar pixels within the template Define the corner response function: ; in, Using a geometric threshold, based on a circular template pixel count set to 15, corner points with drastic local grayscale changes are filtered out. Corner response function This represents the total number of similar pixels within the template.
[0045] when When a value is greater than 0 and is a maximum value within its 8-neighborhood, it is determined to be a corner feature point and denoted as the corner point set. .
[0046] Feature point extraction using the traditional SIFT algorithm is performed on the preprocessed image. The core objective is to obtain a set of feature points that are scale-invariant, rotation-invariant, and illumination-invariant. This is adapted to address the imaging scale, angular deviations, and uneven illumination caused by aluminum-plastic film reflections in images from different detection nodes during battery production. This lays the foundation for establishing cross-detection node correlations of the battery surface region in subsequent improvements to the SIFT algorithm. The specific steps are as follows: The preprocessed image is used as the 0th layer of the 0th group of a Gaussian pyramid. Six Gaussian pyramids are generated by sequentially performing Gaussian blur and 2x downsampling on the image. Within each group, six layers of images at different scales are generated by changing the standard deviation of the Gaussian kernel, forming a Differential Gaussian Pyramid (DOG). The pixels of each layer of the DOG image are traversed and compared with those of the same scale. Pixel comparisons were performed on 8-neighborhood and 9-neighborhood at adjacent scales to select scale-space extrema as candidate keypoints. The Taylor expansion extrema of each candidate keypoint were calculated to accurately determine its sub-pixel coordinates. Low-contrast candidate points were eliminated (a low-contrast threshold of 0.04 was set, determined based on the grayscale difference between battery surface defects and the background). Candidate points with excessively strong edge responses were also removed, resulting in precisely located keypoints. The gradient magnitude and direction of each keypoint's neighboring pixels were calculated, dividing the gradient direction into 8 intervals (covering the 0°-360° gradient range). The cumulative gradient magnitude within each interval was calculated, and the direction corresponding to the maximum value was used as the primary direction of the keypoint. If a direction had a cumulative value exceeding 80% of the maximum value, it was used as a secondary direction. Finally, the SIFT feature point set was obtained. .
[0047] Set of corner points and Feature point set The merging process involves the following steps: First, the corner point set and the SIFT feature point set are directly merged to form an initial merged feature point set containing both types of feature points. Then, all feature points (including corner points and SIFT feature points) within the initial merged feature point set are deduplicated. The Euclidean distance *d* between any two feature points is calculated, and a deduplication threshold of 5 pixels is set (based on the feature point density on the battery surface and the scale of the defect region). If *d* < 5 pixels (the deduplication threshold set based on the feature point density on the battery surface), the feature point with the higher response value is retained (the corner point response value is the difference in similar pixel counts output by the SUSAN algorithm, and the SIFT feature point response value is the scale-space extreme value). Duplicate feature points with lower response values are removed, ultimately resulting in a fused feature point set. q represents the total number of feature points after fusion.
[0048] Improved GLOH descriptor generation: using fused feature points Centered on a central point, a 30×30 pixel descriptor window is constructed in polar coordinates and divided into 17 concentric circular sub-regions (3 annular regions + a central region; the annular regions are further subdivided by angle). The gradient magnitude and gradient direction of each pixel within each sub-region are calculated. The gradient direction is divided into 8 intervals (each interval is 45°). The cumulative sum of the gradient magnitudes in each gradient direction for each sub-region is calculated to generate the initial descriptor vector. The improved GLOH descriptor generation aims to construct feature description vectors with high discriminativeness, rotation invariance, and anti-interference properties for fused feature points. The final generated initial descriptor vector can accurately represent the unique features of each fused feature point, providing a reliable feature matching basis for subsequent solving of the homography matrix and establishing the correlation between battery surface regions across detection nodes.
[0049] A feature matrix was constructed by selecting fusion feature points from 2000 historical battery samples. Calculate the covariance matrix of the characteristic matrix: ,in, The mean vector of the characteristic matrix. The characteristic matrix, Let be the covariance matrix of the characteristic matrix.
[0050] Find the eigenvalues and corresponding eigenvectors of the covariance matrix Σ, and construct the projection matrix by selecting the eigenvectors corresponding to the first 64 largest eigenvalues. , the initial descriptor vector Multiplying by the projection matrix yields a 64-dimensional reduced descriptor: .
[0051] The dimensionality-reduced descriptors are then subjected to L2 normalization to ensure the scale consistency of the feature vectors. Ultimately, each fused feature point corresponds to a 64-dimensional normalized descriptor. .
[0052] For adjacent detection nodes and Extract the fused feature point set separately and generate a standardized descriptor subset. and ,calculate Each descriptor in Euclidean distances of all descriptors in the set: ; in, This is the standardized descriptor subset corresponding to the m-th feature point of the k-th detection node. This is the standardized descriptor subset corresponding to the nth feature point of the (k-1)th detection node. for The d-th element in for The d-th element, for Each descriptor in The Euclidean distance of all descriptors in the set, where m and n are the feature point indices and d is the feature dimension index.
[0053] Set matching threshold =0.4 (based on historical sample matching error statistics, covering 95% of true matching pairs), if < Then determine For matching point pairs, let's denot the matching set. .
[0054] Based on matching point pairs The RANSAC algorithm is used to solve for the homography matrix H, which is used to describe the nodes. and The spatial mapping relationship between them, RANSAC algorithm parameter settings: number of iterations N=1000 (to ensure the optimal set of interior points is found), interior point threshold =2 pixels (based on the reprojection error tolerance set by the camera imaging accuracy), the homography matrix satisfies: ; in,( , ) is a node pixel coordinates, ( , ) is mapped to the node pixel coordinates, It is a homography matrix.
[0055] Using the homography matrix H, the nodes The battery surface area is mapped pixel by pixel to the node. This achieves a one-to-one correspondence between the same physical surface region and different nodes, for the nodes. any surface region in Its node The corresponding area This ensures that cross-node regions are comparable in spatial structure, providing a continuous regional correlation basis for subsequent evolution trend analysis.
[0056] The regional association results of adjacent nodes are validated, with two core indicators set: the proportion of effective matching point pairs (interior points) to the total number of matching point pairs is ≥30% (based on the distribution density of feature points on the battery surface); and the average reprojection error of all interior points is ≤1.5 pixels. If the above indicators are not met, the contrast threshold of SUSAN corner detection is readjusted. or feature matching threshold Repeat the feature extraction, description and matching process until the association result is verified, and finally output the cross-node region association mapping relationship between each adjacent node.
[0057] Step S3: Input the real-time battery surface image into the improved Faster R-CNN model, output the bounding box coordinates, determine the abnormal region based on the bounding box coordinates, extract features from the real-time battery surface image based on the homography matrix within the abnormal region, obtain the real-time evolution feature vector, and determine the evolution consistency of the abnormal region based on the evolution discrimination benchmark and the real-time evolution feature vector to obtain the evolution consistency determination result. The real-time battery surface image is input into the improved Faster R-CNN model, and the abnormal region is output. The specific steps are as follows: To address the challenges of locating small, low-contrast defects on battery surfaces, coupled with significant background glare interference, an improved Faster R-CNN model is constructed. Its core function is the accurate localization of abnormal regions on the battery surface within a single detection node. Multi-dimensional improvements enhance localization accuracy, adapting to defect detection requirements. Basic Faster R-CNN model configuration: The backbone network uses ResNet101, containing 5 convolutional modules (Conv1-Conv5), where Conv2-Conv5 contain 3, 4, 23, and 3 residual blocks respectively; the initial anchor box size of the Region Generation Network (RPN) is set to {128², 256², 512²}, with an aspect ratio of {1:2, 1:1, 2:1}; the ROI Pooling layer scales the region of interest to 7×7 pixels; both the classification and regression branches use fully connected layers (1024 hidden neurons), outputting the confidence score (0-1) of the abnormal region and the bounding box correction parameters.
[0058] The improved Faster R-CNN model specifically includes the following four dimensions: Introducing a Feature Pyramid Network (FPN) into the ResNet101 backbone network enables multi-scale feature fusion: Bottom-up feature extraction: The feature maps output by Conv1-Conv5 are denoted as follows: (Resolution 1224×1024) (612×512) (306×256) (153×128) (77×64), where ~ Each layer is an effective feature layer, containing both shallow detail information and deep semantic information.
[0059] Top-down feature fusion: for Dimensionality reduction was obtained through 1×1 convolution. (256 channels), then obtained by 2x upsampling. , compared with the dimension reduction after 1×1 convolution Fusion Similarly, After upsampling and Fusion , After upsampling and Fusion Finally, for - Perform 3×3 convolutions separately to eliminate upsampling aliasing, and obtain the final fused feature map. - This covers the needs for extracting defect features at multiple scales.
[0060] Feature map after FPN fusion (Intermediate-scale feature layer) Embedded with a cross-shaped attention module to enhance defect feature response and suppress background reflection interference: right The query feature map Q, key feature map K, and value feature map V are generated by 1×1 convolution, each with a dimension of 306×256×128 (the number of channels is reduced to decrease the amount of computation).
[0061] The formula for calculating the correlation between features in the horizontal and vertical directions is: ; ; in, and These are the row index and column index of the query feature map, respectively. and These are the row and column indices of the key feature map, respectively. To query the feature vectors of all rows in the v-th column of feature map Q, The transpose of the eigenvector in the u-th column of the key feature map K. and These are the horizontal and vertical correlation coefficients, respectively, representing the correlation strength of features at different locations. To query feature map Q, the first... The feature vectors of all columns of the row, For the key feature map K, the first Transpose of row eigenvectors This is a vector dot product operation.
[0062] It should be noted that, In the middle, the first " The first "" indicates that all rows in that column are retrieved, and the second "" indicates that all rows in that column are retrieved. "Indicates taking all channels, The first colon (:) indicates retrieving all rows of pixels in the u-th column of the key feature map K, and the second colon (:) indicates retrieving all channel features. In the middle, the first " The first "" indicates that all columns in that row are retrieved, and the second "" indicates that all columns in that row are retrieved. "Indicates taking all channels, The first colon ":" indicates that the key feature map K is retrieved. The second colon represents all column pixels of the row, indicating that all channel features are taken.
[0063] right and Applying the softmax function along the channel dimension yields the horizontal attention weights. and vertical attention weights Then integrate it with the value feature map V: ; in, To enhance the feature map after incorporating the attention mechanism, residual connections are used to preserve the original feature information and strengthen the feature response of defective regions. For horizontal attention weights, For vertical attention weights.
[0064] Replacing ROI Pooling with ROI Align avoids double quantization errors and improves the localization accuracy of small-sized anomaly regions. The candidate region retains floating-point coordinate precision and is uniformly divided into 7×7 small units. Each small unit has 4 sampling points. The pixel value of the sampling points is calculated by bilinear interpolation. Max pooling is performed on the 4 sampling points of each small unit to obtain a fixed-size feature map of 7×7×256, which is used for subsequent classification and regression.
[0065] The anchor frame size of the RPN is optimized using K-means clustering to adapt to the morphological characteristics of battery surface defects. By statistically analyzing the bounding box widths (w) and heights (h) of all labeled outlier regions in the training set, a set of bounding box dimensions can be obtained. .
[0066] The number of clusters is set to 5 (determined based on the common size distribution of battery defects), and a distance formula based on the intersection-union ratio (IOU) is used: ,in, For a single bounding box, As cluster center, This is the intersection-union ratio of the bounding box and the cluster center.
[0067] The cluster centers are iteratively optimized until the change in cluster centers is less than 0.01, resulting in 5 optimized anchor box sizes. The initial anchor boxes of the base model are then replaced with the optimized anchor boxes obtained from the clustering, thereby improving the accuracy of RPN in generating candidate regions for battery defects.
[0068] A training dataset was constructed, which included cross-node images of 500 historical defect samples from step S1 (each sample has 4 nodes, for a total of 2000 images) and 1000 cross-node images of defect-free batteries (as negative samples). All images were processed uniformly according to the preprocessing standards of step S2, and abnormal regions (boundary box coordinates and defect type labels) were labeled using Labelme software. The dataset was divided into a training set (2400 images) and a validation set (600 images) in an 8:2 ratio.
[0069] The optimizer uses SGD with a batch size of 8, an initial learning rate of 0.001, a momentum parameter of 0.9, a weight decay coefficient of 0.0005, and 400 training iterations. The learning rate linearly decays to 0.0001 in the first 100 iterations and remains stable in the last 300 iterations. The training loss function is a weighted sum of classification loss (cross-entropy loss) and regression loss (smoothing L1 loss), with all weight coefficients set to 1.0.
[0070] Train the improved Faster R-CNN model. After training, perform performance validation on the validation set. The model must meet the following requirements: average precision (mAP) for anomaly detection ≥ 83%, recall for small defects (area ≤ 100 pixels²) ≥ 78%, and ensure the model's accurate detection of battery surface defects and cross-node tracking capabilities.
[0071] The real-time battery surface images of each detection node are input into the trained improved Faster R-CNN model, which outputs the confidence score s and bounding box coordinates of each candidate region in the image. Set confidence threshold =0.7 (Based on validation set statistics, the accuracy of initial screening of abnormal regions is ≥85% at this threshold), when s≥ When this happens, the candidate region is determined to be an abnormal region and is denoted as [missing information]. The superscript k represents the kth detection node (k=1,2,3,4). denoted as the confidence level of the abnormal region at the k-th detection node.
[0072] For the abnormal region of node k Through the homography matrix of step S2 Mapping to the (k-1)th node yields the mapped region. ,Will As input to the candidate region at node k-1 of the improved Faster R-CNN model, the model outputs the anomaly region corresponding to that node. This process associates the same abnormal region with adjacent nodes, and repeats to obtain the tracking results of the same abnormal region across all detection nodes. .
[0073] Within the abnormal region, features are extracted from the real-time battery surface image based on the homography matrix to obtain a real-time evolution feature vector. The specific steps are as follows: Region contour stability features: The contour point set of each node's abnormal region is extracted using the chain code method, and the contour similarity is calculated to form a contour stability feature sequence. ; Defect morphology expansion trend characteristics: Calculate the area of the abnormal region at each node. The expansion rate is obtained, forming an expansion trend characteristic sequence. ; Defect boundary continuity features: Extract the boundary gradient value of the abnormal region of each node, calculate the boundary continuity coefficient, and form a boundary continuity feature sequence. .
[0074] Gray-scale distribution characteristics: Statistically analyze the gray-scale values of all pixels within the abnormal region of each node, and calculate the average gray-scale value. and gray variance Forming a gray-scale mean feature sequence and gray-scale variance feature sequence .
[0075] The extracted four types of evolutionary feature sequences are integrated into a real-time evolutionary feature vector. This provides a quantitative basis for subsequent consistency determination that is comparable to the benchmark.
[0076] Based on the evolutionary discrimination benchmark and real-time evolutionary feature vector, the evolutionary consistency of abnormal regions is determined, and the evolutionary consistency determination results are as follows: Define contour stability index Specifically, this refers to the mean of the contour stability feature sequence. This index reflects the stability of the contour shape; the smaller the value, the stronger the stability. A threshold is set. =0.15.
[0077] The formula for calculating the grayscale consistency index is: ; in, Let be the average grayscale value of the abnormal region at node k. For grayscale variance, This is an indicator of grayscale consistency. The total number of detection nodes; the closer to 1, the stronger the consistency of grayscale distribution. A threshold is set. =0.8.
[0078] The formula for calculating the location continuity index is: ; , ; , ; in, and This represents the offset of the center coordinates of the abnormal regions of adjacent nodes. and Let the coordinates be the center coordinates of the abnormal region at node k. and Let the coordinates be the center coordinates of the abnormal region at node k-1. This is a location continuity indicator, which reflects the degree of location continuity of anomaly areas. A threshold is set. =5 pixels.
[0079] Calculate real-time evolutionary feature vectors Euclidean distances to the cluster centers of various defects in the evolutionary discrimination criterion of step S1: ; Where d is the feature dimension index. for The d-th element, The d-th element is the cluster center of the s-th type of defect. For feature vectors Euclidean distance from the cluster centers of various defects in the evolutionary discrimination criterion.
[0080] If a certain type of defect benchmark threshold exists... , making ∈ If the evolutionary characteristics of the abnormal region match the known defect evolution patterns, then it is determined that the evolutionary characteristics of the abnormal region match the known defect evolution patterns.
[0081] The final evolutionary consistency determination result is as follows: when an abnormal region simultaneously meets the following two conditions, it is considered to have defect evolutionary consistency: , There exists a certain type of defect benchmark that makes ∈ If the abnormal area appears only at a single node, or does not meet any of the above conditions, it is determined to be a non-evolutionary anomaly (such as accidental reflection or temporary foreign object attachment).
[0082] Step S4: Construct a defect evolution feature template library, extract evolution consistency feature vectors based on the evolution consistency judgment results, perform similarity matching between the evolution consistency feature vectors and the evolution feature template library to obtain the defect type, and realize defect detection on the battery surface.
[0083] Based on the historical defect sample library and evolutionary feature data from step S1, an evolutionary feature template library covering typical defect types on the battery surface is constructed to provide a standardized reference for the confirmation of real defects. The template library must be completely consistent with the evolution discrimination benchmark in step S1 and the evolutionary feature dimensions extracted in step S3. The specific steps are as follows: The battery surface defects are divided into 5 types of templates (micro-cracks in the casing, local bulges, corrosion marks, foreign matter adhesion, and early processing defects). Each type of template corresponds to the screening of no less than 100 historical defect samples (to ensure that the samples cover different production batches and process conditions). All samples are confirmed by manual re-inspection and physicochemical analysis, and have complete evolution data of 4 detection nodes.
[0084] For each type of defect in the historical samples, extract the three types of evolutionary feature sequences defined in step S3 (contour stability feature sequence, morphological expansion trend feature sequence, and boundary continuity feature sequence).
[0085] For each type of defect with three evolutionary feature sequences, K-means clustering (with k=1 clusters, meaning each defect type corresponds to one core template) is used to calculate the cluster centers of the feature sequences of that type of sample. These cluster centers serve as the standard feature sequences for the templates, thus yielding the standard sequences of contour stability features. Standard sequence of morphological expansion trend characteristics and standard sequences of boundary continuity characteristics .
[0086] Simultaneously calculate the standard deviation of the Euclidean distance between the feature sequence of each class of samples and the cluster center, and set the fault tolerance threshold range of the template to [ -1.5 , +1.5 ], ( and The mean and standard deviation of the feature sequences are calculated based on the 3σ principle, covering 93.3% of normal evolution samples, balancing tolerance and accuracy. The tolerance threshold range of the contour stability feature sequences is then obtained. ], the fault tolerance threshold range of the morphological expansion trend characteristic sequence [ The fault tolerance threshold range for boundary continuity feature sequences. ].
[0087] The templates for the five types of defects are stored in a structure of "defect type - standard feature sequence - fault tolerance threshold" to form a defect evolution feature template library.
[0088] Based on the evolutionary consistency determination results, the surface regions determined to have evolutionary consistency in step S3 are extracted as having evolutionary consistency feature vectors. (where superscript) The feature sequence representing the region to be matched is matched one by one with all templates in the template library. The core mechanism achieves accurate matching through a dual mechanism of "feature sequence dimensional matching + overall similarity calculation". First, verify whether each dimension of the feature sequence to be matched falls within the fault tolerance threshold range of the corresponding template. If a template meets the fault tolerance threshold of the above three types of feature sequences, then the template is a candidate template for the region to be matched. If no template meets the threshold, it is initially judged as an "atypical defect" and enters the subsequent overall similarity verification. If multiple templates meet the threshold, they are all included in the candidate template set Tcand.
[0089] For each template in the candidate template set, the similarity between the feature vector to be matched and the standard feature sequence of the template is calculated using weighted Euclidean distance (the weighting coefficient is set based on feature importance: contour stability weight). =0.4, weight of pattern expansion trend =0.35, boundary continuity weight =0.25 (based on experimental statistics, contour stability contributes the most to defect type differentiation). The similarity formula is: ; in, The distance between the stability feature sequence of the contour to be matched and the standard template sequence is Euclidean distance. The Euclidean distance between the extended trend feature sequence of the pattern to be matched and the standard template sequence is calculated. Let Euclidean distance be the boundary continuity feature sequence to be matched and the standard template sequence. The similarity between the feature vector to be matched and the standard feature sequence of the template is given. As the contour stability weight, To extend the trend weight of the pattern, For boundary continuity weights, The smaller the value, the more consistent the evolution pattern of the region to be matched is with that of the template.
[0090] Based on the template library validation set (containing 50 defect samples of various types, not used in template construction), a similarity threshold Tsim=0.2 was set (at this threshold, the matching accuracy is ≥92%, and the missed match rate is ≤2.5%). If the similarity between the region to be matched and a candidate template is... If the value is less than or equal to Tsim, then the template is considered to have successfully matched the region to be matched.
[0091] If the region to be matched successfully matches at least one template in the candidate template set, the defect type corresponding to the template with the lowest similarity is selected, and the region is determined to be a "real defect," and the defect type is recorded; if the region to be matched has no candidate templates (dimension-by-dimension matching failed), but the overall similarity is similar to that of a certain template, the defect type is recorded. If the similarity is ≤0.25 (relaxing the threshold to cover real defects in atypical evolution), it is judged as "real defect - atypical evolution"; if the similarity of all templates is greater than 0.25, it is judged as "false evolutionary consistency region" (such as false evolutionary features caused by process fluctuations).
[0092] For areas identified as genuine defects, the "key feature fit" between their evolutionary feature vector and the template is further verified. For each type of defect, one key evolutionary feature is defined (e.g., the key feature for microcracks in the shell is "a continuously positive morphological expansion trend with a stable growth rate," and the key feature for local bulges is "high contour stability and strong boundary continuity"). The formula for calculating the key feature fit is: ; in, These are the key feature values of the region to be matched. The key eigenvalues of the template are ϵ=0.01, which is used to avoid local minima where the denominator is 0. This refers to the key feature fit.
[0093] Set the key feature fit threshold Tfit=0.15, when If the value is less than or equal to Tfit, the match is confirmed to be valid; otherwise, the consistency between the template and the feature to be matched needs to be rechecked, and if necessary, step S1 should be backtracked to optimize the template library.
[0094] The final output includes the determination results of the actual defects, including the coordinates of the defect area (based on the boundary box of the abnormal area in step S3), the defect type (or atypical evolution), the matching template number, the similarity value, and the key feature fit value, providing a clear basis for battery quality assessment.
[0095] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, the phrase "comprising an element defined as..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0096] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for detecting surface defects in batteries based on image recognition, characterized in that: Includes the following steps: Step S1: Collect surface images of defective batteries and extract features to obtain defect evolution feature vectors. Cluster the defect evolution feature vectors using a clustering algorithm to obtain evolution discrimination criteria. Step S2: Acquire real-time battery surface images, and perform feature matching on the real-time battery surface images using an improved scale-invariant feature transformation algorithm to obtain the homography matrix; Step S3: Input the real-time battery surface image into the improved Faster R-CNN model, output the bounding box coordinates, determine the abnormal region based on the bounding box coordinates, extract features from the real-time battery surface image based on the homography matrix within the abnormal region, obtain the real-time evolution feature vector, and determine the evolution consistency of the abnormal region based on the evolution discrimination benchmark and the real-time evolution feature vector to obtain the evolution consistency determination result. Step S4: Construct a defect evolution feature template library, extract evolution consistency feature vectors based on the evolution consistency judgment results, perform similarity matching between the evolution consistency feature vectors and the evolution feature template library to obtain the defect type, and realize defect detection on the battery surface.
2. The battery surface defect detection method based on image recognition according to claim 1, characterized in that: The process of acquiring surface images of defective batteries and extracting features to obtain defect evolution feature vectors includes the following specific steps: The surface image of the defective battery is acquired, and the surface image of the defective battery is preprocessed to obtain a preprocessed surface image of the defective battery. The evolution characteristics of each defective region in the preprocessed surface image of the defective battery are extracted to obtain a defect evolution feature vector. The defect evolution feature vector includes contour similarity, expansion rate and boundary continuity coefficient. The formula for calculating the boundary continuity coefficient is as follows: ; in, Let k be the set of defect boundary pixels at the k-th detection node. and These represent the horizontal and vertical gradient magnitudes of the defect region under the (k-1)th detection node. For boundary continuity coefficients, and Let (r,c) represent the gradient magnitudes in the horizontal and vertical directions of the defect region under the k-th detection node, and (r,c) represent the coordinates at the defect boundary.
3. The battery surface defect detection method based on image recognition according to claim 2, characterized in that: The specific steps for clustering the defect evolution feature vectors using a clustering algorithm to obtain the evolution discrimination criterion are as follows: The defect evolution feature vectors are clustered using the K-means clustering algorithm. The number of clusters is determined based on the number of defect types. The objective function of K-means clustering is: ; in, For the first The set of feature vectors of class defects For the first Clustering centers of feature vectors of class defects For feature vectors With cluster center The square of the Euclidean distance, is the objective function for K-means clustering, and s is the defect type index; By iteratively optimizing and minimizing the objective function J, the evolutionary feature cluster centers corresponding to the s-th type of defect are obtained. ; Clustering centers for evolutionary features corresponding to type s defects Calculate the set of feature vectors belonging to the s-th type of defect. All sample feature vectors and evolutionary feature cluster centers Standard deviation of Euclidean distance Set a baseline threshold Thus, the evolutionary discrimination criteria were obtained.
4. The battery surface defect detection method based on image recognition according to claim 3, characterized in that: The process of acquiring real-time battery surface images and performing feature matching on these images using an improved scale-invariant feature transformation algorithm to obtain a homography matrix includes the following steps: Real-time battery surface images are acquired and preprocessed to obtain preprocessed real-time battery surface images. Edge detection and corner detection are performed on the preprocessed real-time battery surface image to obtain a set of corner points. ; Feature points are extracted from the preprocessed real-time battery surface image to obtain a SIFT feature point set. ; Set of corner points and Feature point set By merging and filtering, a set of fused feature points is obtained. ; An improved GLOH descriptor is generated for the fused feature points, and the set of descriptors corresponding to the fused feature points is obtained by dimensionality reduction using PCA. For adjacent detection nodes, extract the fused feature point set and the corresponding descriptor subset respectively, and perform feature matching on the descriptor subset to obtain matching point pairs; Based on the matching point pairs, the homography matrix H is obtained by using the RANSAC algorithm.
5. The battery surface defect detection method based on image recognition according to claim 4, characterized in that: The process of generating improved GLOH descriptors for fused feature points and obtaining the descriptor set corresponding to the fused feature points through PCA dimensionality reduction includes the following steps: The improved GLOH descriptor generation process is as follows: A 30×30 pixel descriptor window is constructed in polar coordinates, centered on the fused feature point. This window is divided into 17 concentric circular sub-regions by radius. The gradient magnitude and direction of each pixel within each sub-region are calculated. The gradient direction is divided into 8 intervals. The sum of the gradient magnitudes in each gradient direction for each sub-region is calculated to generate the initial descriptor vector. ; The PCA dimensionality reduction process involves selecting fusion feature points from historical battery samples and constructing a feature matrix. Calculate the covariance matrix Σ of the feature matrix, solve for the eigenvalues and corresponding eigenvectors of the covariance matrix Σ, and select the eigenvectors corresponding to the first 64 largest eigenvalues to construct the projection matrix. , the initial descriptor vector Multiplying by the projection matrix yields the dimensionality-reduced descriptor. , for dimensionality reduction descriptors L2 normalization is performed to obtain the descriptor subset corresponding to each fused feature point. .
6. The battery surface defect detection method based on image recognition according to claim 5, characterized in that: The process of inputting a real-time battery surface image into an improved Faster R-CNN model, outputting bounding box coordinates, and determining abnormal regions based on these coordinates includes the following steps: An improved Faster R-CNN model is constructed and trained to obtain a trained improved Faster R-CNN model. Real-time battery surface images are input into the trained improved Faster R-CNN model, which outputs the confidence score *s* and bounding box coordinates for each candidate region in the image. A confidence threshold is then set. When s≥ When this happens, the candidate region is determined to be an abnormal region and is denoted as [missing information]. ; For the abnormal region of the k-th node Through homography matrix Mapping to the (k-1)th node yields the mapped region. ,Will As input to the candidate region at node k-1 of the improved Faster R-CNN model, the model outputs the anomaly region corresponding to that node. Repeat this process to obtain the tracking results of the same abnormal region at all detection nodes. .
7. The battery surface defect detection method based on image recognition according to claim 6, characterized in that: The improved Faster R-CNN model is constructed as follows: The improved Faster R-CNN model is as follows: A feature pyramid network is introduced into the ResNet101 backbone network to obtain a fused feature map. - In the fusion feature map The formula for calculating the feature correlation in the horizontal and vertical directions using the embedded cross-attention module is as follows: ; ; in, and These are the row index and column index of the query feature map, respectively. and These are the row and column indices of the key feature map, respectively. To query the feature vectors of all rows in the v-th column of feature map Q, The transpose of the eigenvector in the u-th column of the key feature map K. and These are the correlation coefficients in the horizontal and vertical directions, respectively. To query feature map Q, the first... The feature vectors of all columns of the row, For the key feature map K, the first Transpose of row eigenvectors This is a vector dot product operation; right and Applying the softmax function along the channel dimension yields the horizontal attention weights. and vertical attention weights Then it is integrated with the value feature map V to obtain the enhanced feature map after incorporating the attention mechanism. ; ROI Align is used to uniformly divide the candidate region into small units. Sampling points are set in each small unit. The pixel value of the sampling points is calculated by bilinear interpolation. Max pooling is performed on the sampling points of each small unit to obtain a fixed-size feature map. The anchor box size of the RPN is optimized by K-means clustering, and the width w and height h of the bounding boxes of all annotated anomaly regions are counted to obtain the set of bounding box sizes. Set the number of clusters and use a distance formula based on the intersection-union ratio: ,in, For a single bounding box, As cluster center, The intersection-union ratio of the bounding box and the cluster center is used to iteratively optimize the cluster center, and finally obtain the optimized anchor box size.
8. The battery surface defect detection method based on image recognition according to claim 7, characterized in that: Within the abnormal region, feature extraction is performed on the real-time battery surface image based on the homography matrix to obtain a real-time evolution feature vector. Based on the evolution discrimination benchmark and the real-time evolution feature vector, the evolution consistency of the abnormal region is determined to obtain the evolution consistency determination result, including the following specific steps: Within the abnormal region, the contour point set of each node's abnormal region is extracted using the chain code method, and the contour similarity is calculated to form a contour stability feature sequence. ; Calculate the area of the abnormal region for each node. The expansion rate is obtained, forming an expansion trend characteristic sequence. Extract the boundary gradient values of the abnormal regions of each node, calculate the boundary continuity coefficient, and form a boundary continuity feature sequence. ; Calculate the grayscale value of all pixels within the abnormal region of each node, and then calculate the average grayscale value. and gray variance Forming a gray-scale mean feature sequence and gray-scale variance feature sequence The extracted four types of evolutionary feature sequences are integrated into a real-time evolutionary feature vector. ; Calculate the profile stability index Specifically, the mean of the contour stability feature sequence is set to a threshold. ; Calculate the grayscale consistency index Set threshold ; Calculate the location continuity index and set a threshold. Calculate the real-time evolution feature vector Euclidean distance from the cluster centers of various defects in the evolutionary discrimination criterion ; The final evolutionary consistency determination result is as follows: when an abnormal region simultaneously meets the following two conditions, it is considered to have defect evolutionary consistency: , ; There exists a certain type of defect benchmark, which makes ∈ ; If an abnormal region appears only in a single node or does not meet any of the above conditions, it is determined to be a non-evolutionary anomaly.
9. The battery surface defect detection method based on image recognition according to claim 8, characterized in that: The construction of the defect evolution feature template library, and the extraction of evolution consistency feature vectors based on the evolution consistency determination results, specifically involves: A defect evolution feature template library was constructed, which was divided into 5 types of templates according to common defect types on the battery surface. Each type of template corresponds to no less than 100 historical samples. All samples were confirmed by manual re-inspection and physicochemical analysis, and have complete evolution data of 4 detection nodes. For historical samples of each type of defect, contour stability feature sequence, morphological expansion trend feature sequence, and boundary continuity feature sequence are extracted respectively. K-means clustering is used to calculate the cluster center of the feature sequence of each type of sample, which serves as the standard feature sequence of the template, thus obtaining the standard sequence of contour stability features. Standard sequence of morphological expansion trend characteristics and standard sequences of boundary continuity characteristics ; Calculate the standard deviation of the Euclidean distance between the feature sequence of each class of samples and the cluster center, and set the template's fault tolerance threshold range as []. -1.5 , +1.5 The tolerance threshold range of the contour stability feature sequence was calculated respectively. ], the fault tolerance threshold range of the morphological expansion trend characteristic sequence [ The fault tolerance threshold range for boundary continuity feature sequences. ]; Templates for the five types of defects are stored in a structure of defect type-standard sequence-tolerance threshold range to obtain a defect evolution feature template library. Based on the evolution consistency determination results, evolution consistency feature vectors are extracted from surface regions that are determined to have evolution consistency. .
10. The battery surface defect detection method based on image recognition according to claim 9, characterized in that: The step of matching the evolutionary consistent feature vector with the evolutionary feature template library based on similarity to obtain the defect type is as follows: Verify whether each dimension of the feature sequence to be matched falls within the fault tolerance threshold range of the corresponding template. If a template meets the fault tolerance threshold of the above three types of feature sequences, then the template is a candidate template for the region to be matched. If no template meets the threshold, it is initially judged as "atypical defect" and enters the subsequent overall similarity verification. If multiple templates meet the threshold, they are all included in the candidate template set. For each template in the candidate template set, the similarity between the feature vector to be matched and the standard feature sequence of the template is calculated using weighted Euclidean distance. ; Set a similarity threshold Tsim; when the region to be matched is similar to a candidate template... If the similarity is less than or equal to Tsim, then the template is determined to be a successful match with the region to be matched. When the region to be matched is successfully matched with at least one template in the candidate template set, the defect type corresponding to the template with the lowest similarity is selected, the region is determined to be a "real defect", and the defect type is recorded.
Citation Information
Patent Citations
Computer mainboard quality detection method and system based on artificial intelligence
CN121682084A
Battery system fault detection method and system
CN122131171A