General battery appearance abnormity detection system based on visual identification

By dynamically hierarchically dividing the visual imaging sample set and iteratively training the anomaly detection network, the robustness problem of the battery appearance inspection system under changes in lighting and camera conditions is solved, achieving efficient detection and generalization capabilities for subtle anomalies.

CN121904003APending Publication Date: 2026-04-21杭州鸿途智慧能源技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
杭州鸿途智慧能源技术有限公司
Filing Date
2026-01-06
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing battery appearance inspection systems exhibit reduced robustness when faced with changes in lighting, differences in camera parameters, or product batch replacements, resulting in frequent false positives and false negatives. Furthermore, the static preset of the feature fusion strategy limits the generalization capability for detecting atypical or subtle anomalies.

Method used

By dynamically hierarchically dividing the visual imaging sample set, constructing a multi-level template reference structure, and combining illumination consistency correction and perspective distortion compensation, feature parsing and fusion are optimized. The anomaly detection network is iteratively trained, and the fusion constraint weights and network parsing granularity are dynamically adjusted to achieve adaptive detection under illumination and camera conditions.

Benefits of technology

It improves the consistency and reliability of the detection process, reduces the false positive rate, enhances the ability to distinguish subtle anomalies and generalize performance, and adapts to changes in different lighting environments and camera models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121904003A_ABST
    Figure CN121904003A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of industrial machine visual inspection, and discloses a general battery appearance anomaly detection system based on visual identification. According to the system, a standard appearance template is dynamically layered and divided according to imaging characteristics of a visual imaging sample set, and a multi-level template reference structure is established; geometric and texture features of the template are extracted and fused to generate basic fusion constraints, illumination correction and deformation compensation are carried out on the sample set, and then a spatial distribution model of surface features is constructed; and inputting the constraint and the model into an initialized anomaly judgment network for iterative training, dynamically adjusting the weight of the fusion constraint in the training, synchronously optimizing the analysis granularity of the network to the spatial distribution model, and finally obtaining a completely trained network. The system improves the accuracy, robustness and generalization ability of battery appearance defect detection in a complex imaging environment through adaptive template construction and collaborative optimization of constraint and analysis granularity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial machine vision inspection technology, specifically to a general battery appearance anomaly detection system based on visual recognition. Background Technology

[0002] In the field of industrial visual inspection, template-based battery appearance inspection is the mainstream method. Existing technologies typically rely on pre-generated static standard templates with fixed structures that are independent of the real-time imaging conditions on the production line. When faced with changes in lighting, differences in camera parameters, or product batch changes, static templates cannot adaptively adjust their comparison strategies, leading to decreased robustness of the inspection system and frequent false positives and false negatives.

[0003] In the model building phase, existing solutions typically treat feature extraction, fusion, and network training as separate processes. The fusion weights for geometric, texture, and other features are often manually preset and fixed, failing to integrate with the neural network's learning process. Simultaneously, the network's ability to analyze the complex feature distribution on the battery surface is relatively fixed. This separate, static processing paradigm makes it difficult for the model to dynamically optimize its discrimination criteria and perceptual precision based on actual data, thus limiting the system's ability to generalize detection of various defects, especially atypical or subtle anomalies.

[0004] There is a need for a detection system that can dynamically construct reference standards based on actual imaging conditions and can collaboratively optimize feature utilization strategies and model analytical capabilities during training. Summary of the Invention

[0005] The purpose of this invention is to provide a universal battery appearance anomaly detection system based on visual recognition to solve the problems mentioned in the background art.

[0006] To achieve the above objectives, the present invention provides a universal battery appearance anomaly detection system based on visual recognition, the system comprising: The template construction and layering module obtains a visual imaging sample set of general batteries and the corresponding standard appearance template. Based on the imaging features of the visual imaging sample set, the standard appearance template is dynamically layered to establish a multi-level template reference structure. The feature parsing and fusion module performs structured parsing on the multi-level template reference structure, extracts geometric constraint features and texture constraint features, and fuses the geometric constraint features and texture constraint features to generate basic fusion constraints. The sample preprocessing and modeling module performs illumination consistency correction and perspective distortion compensation on the visual imaging sample set to generate a preprocessed visual imaging sample set. Based on the preprocessed visual imaging sample set, a spatial distribution model of general battery surface features is constructed. The network training and optimization module inputs the basic fusion constraints and the spatial distribution model into the initialized anomaly detection network, and iteratively trains the anomaly detection network. During the iteration process, the constraint weights of the basic fusion constraints are dynamically adjusted, and the resolution granularity of the anomaly detection network for the spatial distribution model is optimized simultaneously to obtain a fully trained anomaly detection network. The system integration module integrates the multi-level template reference structure, the preprocessed visual imaging sample set, and the fully trained anomaly detection network to construct and deploy the general battery appearance anomaly detection system based on visual recognition.

[0007] Preferably, the step of dynamically dividing the standard appearance template into layers based on the imaging features of the visual imaging sample set includes: The standard appearance template is divided into a global mesh to obtain basic mesh units; The illumination distribution vector and surface curvature vector of each imaging sample are extracted from the visual imaging sample set, and the illumination distribution vector and surface curvature vector are combined to form a sample imaging feature vector; Calculate the global mean vector and global variance matrix of all sample imaging feature vectors, and based on the global mean vector and global variance matrix, calculate the visual saliency score of each basic grid cell in the standard appearance template; Based on the visual saliency score, the basic grid cells are clustered and divided, and basic grid cells with similar visual saliency scores are grouped into the same template level to form a multi-level template set; Each template level is assigned an independent feature extraction channel and a comparison threshold parameter, and the multi-level template set and the corresponding feature extraction channels and comparison threshold parameters are jointly constructed into the multi-level template reference structure.

[0008] Preferably, the extraction of geometric constraint features and texture constraint features includes: For each template level in the multi-level template reference structure, a preset geometric feature operator is invoked, including an edge gradient operator and a contour curvature operator, to extract the geometric feature map of each template level; Principal component decomposition is performed on the geometric feature map of each template level to obtain the principal geometric feature vector corresponding to each template level, and the principal geometric feature vector constitutes the geometric constraint feature; In parallel, for each template level in the multi-level template reference structure, a preset texture feature operator is invoked, which includes a local binary mode operator and a gray-level co-occurrence matrix operator, to extract the texture feature map of each template level. Texture primitive encoding is performed on the texture feature map of each template level to obtain the texture encoding sequence corresponding to each template level, and the texture encoding sequence constitutes the texture constraint feature.

[0009] Preferably, the step of fusing the geometric constraint features and texture constraint features to generate basic fusion constraints includes: For each template level, a feature mapping table is established between the main geometric feature vector and the texture encoding sequence. The feature mapping table records the correspondence between the dimension of the main geometric feature vector and the encoding of the texture encoding sequence. According to the feature mapping table, the main geometric feature vector and the texture encoding sequence are concatenated into tensors to generate a fused feature tensor for each template level; The fused feature tensor of each template level is normalized, and the covariance matrix between the normalized fused feature tensors of all template levels is calculated. Based on the covariance matrix, the stability weight of the fusion feature at each template level is calculated. The normalized fusion feature tensor is then weighted and fused according to the stability weight to generate the basic fusion constraint.

[0010] Preferably, the step of performing illumination consistency correction and perspective distortion compensation on the visual imaging sample set to generate a preprocessed visual imaging sample set includes: For each visual imaging sample in the visual imaging sample set, estimate its global illumination histogram and local illumination gradient field; Based on the global illumination histogram and the local illumination gradient field, an illumination correction function is constructed. The illumination correction function is then used to perform global illumination equalization and local illumination compensation on the visual imaging sample to obtain the illumination-corrected imaging sample. The corner positions of the general-purpose battery in the illumination-corrected imaging sample are detected, and the projection transformation matrix is ​​calculated based on the standard corner positions of the standard appearance template. The projection transformation matrix is ​​used to perform perspective transformation on the illumination-corrected imaging sample to correct the deformation caused by the shooting angle, thereby generating the preprocessed visual imaging sample set.

[0011] Preferably, the step of constructing a spatial distribution model of general battery surface features based on the preprocessed visual imaging sample set includes: Feature point detection and description are performed on the preprocessed visual imaging sample set, and scale-invariant feature transformation descriptors are extracted for each visual imaging sample. Based on the scale-invariant feature transformation descriptor, feature matching and alignment are performed on all visual imaging samples, mapping multiple visual imaging samples to a unified three-dimensional coordinate framework. Under the unified three-dimensional coordinate framework, the general battery surface is reconstructed by triangulation to obtain a three-dimensional mesh model of the battery surface; At each vertex of the three-dimensional mesh model, the feature descriptors corresponding to it in all visual imaging samples are aggregated to form a multi-dimensional feature vector. A mapping relationship from the three-dimensional mesh vertex to the multi-dimensional feature vector is established. The three-dimensional mesh model and the mapping relationship together constitute the spatial distribution model of the general battery surface features.

[0012] Preferably, the iterative training of the anomaly detection network includes: In each iteration, a batch of samples is sampled from the preprocessed visual imaging sample set, and the batch of samples is input into the anomaly detection network to obtain a preliminary anomaly probability map of the batch of samples. Local spatial features corresponding to the batch samples are extracted from the spatial distribution model, and the local spatial features are concatenated with the preliminary anomaly probability map to generate an enhanced feature map. The enhanced feature map is constrained using the basic fusion constraints to generate a constraint loss value, and the difference loss value between the preliminary anomaly probability map and the true annotation of the batch samples is calculated at the same time. The constraint loss value and the difference loss value are weighted and summed to obtain the total loss value. The parameters of the anomaly detection network are updated by backpropagation based on the total loss value, and the constraint weight coefficients of the basic fusion constraint are updated at the same time.

[0013] Preferably, the dynamic adjustment of the constraint weights of the basic fusion constraints includes: In each iteration of training, monitor the contribution ratio of the constraint loss value of the basic fusion constraint to the total loss value; Calculate the moving average and gradient of the contribution ratio over the most recent iterations; When the moving average is lower than the preset lower threshold, or when the change gradient shows a negative trend, the constraint weight of the basic fusion constraint is increased by a preset step size. When the moving average is higher than the preset upper limit threshold and the change gradient shows a positive trend, the constraint weight of the basic fusion constraint is reduced by a preset step size.

[0014] Preferably, the synchronous optimization of the anomaly detection network's analytical granularity for the spatial distribution model includes: During iterative training, the area of ​​the response region of the anomaly detection network to the local spatial features is recorded; Based on the changing trend of the response region area, the dilation rate of the convolutional layers in the anomaly detection network is dynamically adjusted. An attention gating mechanism is added to the intermediate layer of the anomaly detection network. The attention gating mechanism takes the local spatial features as input and generates a spatial attention weight map. The spatial attention weight map is multiplied element-wise with the intermediate feature map of the anomaly detection network to focus on key regions in the spatial distribution model, thereby optimizing the resolution granularity.

[0015] Preferably, the step of using the basic fusion constraints to perform constraint calculations on the enhanced feature map to generate constraint loss values, and simultaneously calculating the difference loss value between the preliminary anomaly probability map and the true annotations of the batch samples, includes: The predicted geometric features and predicted texture features corresponding to the multi-level template reference structure are decoded from the enhanced feature map; Calculate the first feature distance between the predicted geometric feature and the geometric constraint feature in the basic fusion constraint, and the second feature distance between the predicted texture feature and the texture constraint feature in the basic fusion constraint, respectively. The first feature distance and the second feature distance are multiplied by the corresponding constraint weights of the basic fusion constraints in the current iteration, and then summed to obtain the constraint loss value; The preliminary anomaly probability map is compared pixel by pixel with the true labeled map of the batch samples, and the cross-entropy loss is calculated as the preliminary difference loss. The overlap between the regions identified as anomalous in the preliminary anomaly probability map and the real anomalous regions in the true annotation map is calculated, and the intersection-union ratio penalty coefficient is calculated based on the overlap. The initial difference loss is multiplied by the cross-union ratio penalty coefficient to obtain the final difference loss value.

[0016] Compared with the prior art, the beneficial effects of the present invention are: The standard appearance template is dynamically layered based on the imaging characteristics of the visual imaging samples, automatically adapting the template's hierarchical structure to the characteristics of the actual acquired images. This dynamic construction mechanism can respond in real time to changes in imaging conditions, making the detection reference standard itself adaptable. Therefore, the system can maintain a stable comparison benchmark even when facing different lighting environments, camera models, or image resolutions, improving the consistency and reliability of the detection process and reducing misjudgments caused by imaging fluctuations.

[0017] During the training of the anomaly detection network, the dynamic adjustment of the basic fusion constraint weights and the optimization of the network's analytical granularity of the spatial distribution model are performed simultaneously. This co-optimization process ensures that the feature fusion strategy is no longer a static preset, but rather a parameter that evolves autonomously according to the training objective. The network also autonomously adjusts the analytical granularity of the surface feature model. This coupled training mechanism enables the model to more accurately balance the contributions of different feature cues and deepen its understanding of complex surface structures, thereby enhancing its ability to distinguish subtle anomaly patterns and improving its generalization performance for unseen defect types. Attached Figure Description

[0018] Figure 1 This is a schematic diagram illustrating the working principle of the universal battery appearance anomaly detection system based on visual recognition described in this invention. Figure 2 A flowchart for dynamically dividing a standard appearance template into layers; Figure 3 The flowchart is generated based on the fusion constraints. Detailed Implementation

[0019] 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.

[0020] Please see Figure 1 This invention provides a general battery appearance anomaly detection system based on visual recognition. The system includes: a template construction and layering module that acquires a visual imaging sample set of a general battery and its corresponding standard appearance templates, and dynamically layers the standard appearance templates according to the imaging features of the sample set, thereby establishing a multi-level template reference structure. A feature parsing and fusion module performs structured parsing on the multi-level template reference structure, extracts geometric constraint features and texture constraint features, and fuses them to generate basic fusion constraints. A sample preprocessing and modeling module simultaneously performs illumination consistency correction and perspective distortion compensation on the visual imaging sample set to obtain a preprocessed visual imaging sample set, and constructs a spatial distribution model of the surface features of the general battery based on this. A network training and optimization module inputs the obtained basic fusion constraints and spatial distribution model into an initialized anomaly detection network for iterative training. During the training process, the constraint weights of the basic fusion constraints are dynamically adjusted, and the resolution granularity of the network for the spatial distribution model is simultaneously optimized, ultimately obtaining a fully trained anomaly detection network. A system integration module integrates the aforementioned multi-level template reference structure, the preprocessed visual imaging sample set, and the fully trained anomaly detection network to complete the construction and deployment of the entire detection system.

[0021] In one embodiment of the present invention, see [reference] Figure 2 The standard appearance template is divided into basic grid cells through global meshing. The illumination distribution vector and surface curvature vector of each imaging sample are extracted from the visual imaging sample set, and these are combined to form the sample imaging feature vector. The global mean vector and global variance matrix of all sample imaging feature vectors are calculated, and the visual saliency score of each basic grid cell in the standard appearance template is calculated based on the global mean vector and global variance matrix. The basic grid cells are clustered according to the visual saliency scores, grouping basic grid cells with similar visual saliency scores into the same template level, forming a multi-level template set. An independent feature extraction channel and comparison threshold parameter are assigned to each template level, and the multi-level template sets, along with the corresponding feature extraction channels and comparison threshold parameters, are used to construct a multi-level template reference structure.

[0022] In practical implementation, the template construction and layering operations of the vision-based general battery appearance anomaly detection system can be implemented in a production line scenario targeting the appearance inspection of cylindrical lithium batteries. The visual imaging sample set contains thousands of multi-angle images of qualified batteries collected from different production lines and under different lighting conditions. The standard appearance template is a high-resolution, defect-free reference image of a battery acquired under standard lighting and orthogonal viewing angles. In practical implementation, the standard appearance template is divided into a global grid, dividing the entire image into several regularly sized basic grid units, each representing a local area of ​​the battery surface.

[0023] In some embodiments, features are extracted from each imaging sample in the visual imaging sample set. The overall brightness distribution of the imaging sample is calculated to form an illumination distribution vector. Simultaneously, the curvature change of the battery surface is estimated through 3D reconstruction or grayscale information to form a surface curvature vector. The illumination distribution vector and the surface curvature vector are combined to form a sample imaging feature vector characterizing the imaging conditions of the sample. It can be understood that after processing all samples in the visual imaging sample set, a set of sample imaging feature vectors will be obtained. The global mean vector and global variance matrix of this set of vectors are calculated, and these two statistics are used to measure the average imaging characteristics and dispersion of the entire sample set. Based on the global mean vector and global variance matrix, a visual saliency score is calculated for each basic grid cell in the standard appearance template. The visual saliency score quantitatively describes the stability or saliency of the grid cell under multi-sample imaging conditions. The formula for calculating the visual saliency score is: in: Indicates the first Visual saliency score of each basic grid unit It is a feature vector derived from the statistical analysis of visual imaging sample sets and associated with the location of that grid cell. It is the global mean vector. It is the global variance matrix. Represents the transpose matrix. This represents the inverse matrix.

[0024] In practice, clustering is performed on all basic grid cells based on the calculated visual saliency scores. Basic grid cells with similar visual saliency scores mean they exhibit similar behavior patterns under various imaging conditions and are therefore grouped into the same template level. For example, the scores of flat cylindrical areas of a battery may be similar and clustered into one class, while the scores of areas with complex injection holes or poles at the top of the battery may differ significantly and be grouped into another class, thus forming a template set containing multiple levels. It is understood that assigning independent feature extraction channels and comparison threshold parameters to each template level is necessary. The feature extraction channel specifies the algorithm or parameter set used when extracting features from the image region at that level, while the comparison threshold parameter defines the tolerance range for determining whether a feature is abnormal at that level. Finally, the multi-level template set and its corresponding feature extraction channels and comparison threshold parameters are jointly constructed into the multi-level template reference structure, which provides a hierarchical benchmark for subsequent feature analysis and anomaly comparison.

[0025] In one embodiment of the present invention, see [reference] Figure 3For each template level in the multi-level template reference structure, preset geometric feature operators, including edge gradient operators and contour curvature operators, are invoked to extract the geometric feature map of each template level. Principal component decomposition is performed on the geometric feature map of each template level to obtain the principal geometric feature vector corresponding to each template level. The principal geometric feature vector constitutes the geometric constraint feature. In parallel, for each template level in the multi-level template reference structure, preset texture feature operators, including local binary mode operators and gray-level co-occurrence matrix operators, are invoked to extract the texture feature map of each template level. Texture primitive encoding is performed on the texture feature map of each template level to obtain the texture encoding sequence corresponding to each template level. The texture encoding sequence constitutes the texture constraint feature. For each template level, a feature mapping table is established between the principal geometric feature vector and the texture encoding sequence. The feature mapping table records the correspondence between the dimension of the principal geometric feature vector and the encoding of the texture encoding sequence. Based on the feature mapping table, the main geometric feature vector and texture encoding sequence are concatenated into tensors to generate a fused feature tensor for each template level. The fused feature tensor for each template level is normalized, and the covariance matrix among the normalized fused feature tensors of all template levels is calculated. Based on the covariance matrix, the stability weights of the fused features at each template level are calculated. The normalized fused feature tensors are then weighted and fused according to these stability weights to generate the basic fusion constraints.

[0026] In practical implementation, the feature parsing and fusion module operates on the constructed multi-level template reference structure. In an example scenario for detecting dents and stains on the surface of a pouch battery, the multi-level template reference structure includes different template levels for flat battery surfaces, edge bends, and laser welding texture areas. For each template level in the multi-level template reference structure, the system calls preset geometric feature operators. These preset geometric feature operators explicitly include edge gradient operators and contour curvature operators. The edge gradient operator calculates the gradient magnitude and direction of image pixels to capture boundary information, and the contour curvature operator analyzes the degree of curvature of the edge contour lines, thereby extracting the geometric feature map of each template level. The geometric feature map stores the quantitative information of the shape and structure of the region in matrix form. Principal component decomposition (PCD) is performed on the geometric feature map of each template level. This is a mathematical method for dimensionality reduction and feature extraction. By calculating eigenvectors and eigenvalues ​​and retaining the most important variance information, the principal geometric feature vectors corresponding to each template level are obtained. The principal geometric feature vectors of all template levels together constitute the geometric constraint features of the system.

[0027] In some embodiments, for each template level in a multi-level template reference structure, the system invokes a preset texture feature operator, which explicitly includes a local binary mode operator and a gray-level co-occurrence matrix operator. The local binary mode operator generates texture encoding by comparing the gray values ​​of a pixel with its neighbors, while the gray-level co-occurrence matrix operator describes the texture by statistically analyzing the probability of gray values ​​appearing in pixel pairs with specific positional relationships in the image, thereby extracting the texture feature map for each template level. Texture primitive encoding is performed on the texture feature map of each template level, classifying the patterns in the texture feature map into a finite number of primitive categories and forming a sequence, resulting in the texture encoding sequence corresponding to each template level. The texture encoding sequences of all template levels together constitute the texture constraint features of the system. It can be understood that establishing a feature mapping table between the principal geometric feature vector and the texture encoding sequence for each template level is a prerequisite for subsequent fusion. The feature mapping table records the correspondence between each dimension of the principal geometric feature vector and a specific encoding interval or pattern in the texture encoding sequence. This relationship is predefined based on prior knowledge or statistical analysis.

[0028] In practice, based on the feature mapping table, the main geometric feature vector and texture encoding sequence are concatenated into tensors to generate a fused feature tensor for each template level. A tensor is a multi-dimensional array data structure capable of simultaneously accommodating feature information from different sources. The fused feature tensor for each template level is normalized by scaling the values ​​to a uniform scale, such as zero mean and unit variance. Then, the covariance matrix among the normalized fused feature tensors of all template levels is calculated. The covariance matrix reflects the degree of linear correlation between features at different levels. Based on the covariance matrix, the stability weight of the fused feature at each template level is calculated. The stability weight characterizes the consistency and reliability of the features at that level within the overall context.

[0029] In one embodiment of the present invention, for each visual imaging sample in the visual imaging sample set, its global illumination histogram and local illumination gradient field are estimated. An illumination correction function is constructed based on the global illumination histogram and local illumination gradient field. This function is then used to perform global illumination equalization and local illumination compensation on the visual imaging samples, resulting in illumination-corrected imaging samples. The corner positions of the general-purpose battery in the illumination-corrected imaging samples are detected, and a projection transformation matrix is ​​calculated based on the standard corner positions of the standard appearance template. The projection transformation matrix is ​​used to perform perspective transformation on the illumination-corrected imaging samples to correct deformation caused by the shooting angle, generating a preprocessed visual imaging sample set. Feature point detection and description are performed on the preprocessed visual imaging sample set, and a scale-invariant feature transformation descriptor is extracted for each visual imaging sample. Based on the scale-invariant feature transformation descriptor, feature matching and alignment are performed on all visual imaging samples, mapping multiple visual imaging samples to a unified three-dimensional coordinate framework. Under this unified three-dimensional coordinate framework, the surface of the general-purpose battery is reconstructed using triangular meshing, resulting in a three-dimensional mesh model of the battery surface. At each vertex of the 3D mesh model, the corresponding feature descriptors in all visual imaging samples are aggregated to form a multi-dimensional feature vector. A mapping relationship from the 3D mesh vertex to the multi-dimensional feature vector is established. The 3D mesh model and the mapping relationship together constitute a spatial distribution model of general battery surface features.

[0030] In the implementation, the sample preprocessing and modeling module operates within a scenario of multi-view appearance inspection of square lithium batteries. The visual imaging sample set comprises original battery images acquired from multiple fixed industrial cameras, exhibiting uneven illumination and viewing angle differences. Specifically, illumination analysis is performed on each visual imaging sample in the set to estimate its global illumination histogram, which describes the distribution probability of pixels at different gray levels throughout the image. Simultaneously, a local illumination gradient field is calculated, characterizing local brightness fluctuations by calculating the gray-level changes within the neighborhood of each pixel. An illumination correction function is constructed based on the global illumination histogram and the local illumination gradient field. This function is a mathematical mapping designed to map pixel values ​​under non-uniform illumination to their corresponding values ​​under ideal uniform illumination. Global illumination equalization is performed on the visual imaging samples using the illumination correction function, adjusting the gray-level distribution of the entire image to approximate a standard distribution. Simultaneously, local illumination compensation is performed, smoothing and compensating for areas with drastic changes in the local illumination gradient field, resulting in the illumination-corrected imaging sample.

[0031] In some embodiments, the four corner positions of the square lithium battery in the illumination-corrected imaging sample are detected. These corner positions are obtained using a Harris corner detector or a contour-based polygon fitting method. Based on predefined standard corner positions in a standard appearance template, a projection transformation matrix is ​​calculated to map the current image corners to these standard positions. The projection transformation matrix is ​​a 3x3 homogeneous coordinate transformation matrix, and its calculation involves solving a system of linear equations. The illumination-corrected imaging sample is then subjected to a perspective transformation using the projection transformation matrix. This perspective transformation projects the coordinates of each pixel in the original image onto a new standard viewpoint plane through matrix multiplication, correcting trapezoidal distortion or rotational deformation caused by the camera's shooting angle. This ultimately generates a preprocessed visual imaging sample set. It can be understood that the visual imaging sample set processed in this way exhibits higher consistency in illumination and geometry.

[0032] In practical implementation, a spatial distribution model of general battery surface features is constructed based on the preprocessed visual imaging sample set. Feature point detection and description are performed on the preprocessed visual imaging sample set using a scale-invariant feature transform descriptor algorithm. This algorithm extracts the scale-invariant feature transform descriptor set for each visual imaging sample by detecting extreme points in the Gaussian difference space and generating feature vectors with scale and rotation invariance. Based on the scale-invariant feature transform descriptors, feature matching and alignment are performed on all visual imaging samples. Matching point pairs between different images are found by calculating the Euclidean distance between descriptors, and the transformation relationship between images is estimated using a random sampling consensus algorithm. Multiple visual imaging samples are mapped to a unified three-dimensional coordinate frame, with the physical center of the battery as the origin. Under this unified three-dimensional coordinate frame, the general battery surface is reconstructed using triangular meshing. Triangular meshing reconstruction uses the Delaunay triangulation algorithm or a point cloud-based surface reconstruction algorithm to discretize the battery surface into a three-dimensional mesh model composed of a large number of connected triangular facets. Each vertex of the three-dimensional mesh model corresponds to a three-dimensional spatial point on the battery surface.

[0033] In practical implementation, at each vertex of the 3D mesh model, the feature descriptors corresponding to that vertex in all visual imaging samples are aggregated. These feature descriptors originate from all image viewpoints that can observe the 3D point. The aggregation operation involves calculating the statistical features of these descriptors, such as the mean vector or principal components, to form a multi-dimensional feature vector representing the appearance of that vertex. A mapping relationship from 3D mesh vertices to multi-dimensional feature vectors is established. This mapping relationship is implemented through a lookup table or function; given the coordinates of a 3D vertex, its associated multi-dimensional feature vector can be retrieved. The 3D mesh model and the mapping relationship from 3D mesh vertices to multi-dimensional feature vectors together constitute a spatial distribution model of general battery surface features. This model fully expresses the standard appearance features of each 3D location point on the battery surface. The process of the projection transformation matrix acting on the image plane coordinates in perspective transformation can be represented by the following formula: in: These are the homogeneous coordinates of a pixel on the original image plane. It is the calculated 3x3 projection transformation matrix. These are the transformed homogeneous coordinates, and their corresponding standard image plane coordinates are... .

[0034] In one embodiment of the present invention, in each iteration, a batch of samples is sampled from the preprocessed visual imaging sample set, and the batch of samples is input into the anomaly detection network to obtain a preliminary anomaly probability map of the batch of samples. Local spatial features corresponding to the batch of samples are extracted from the spatial distribution model, and the local spatial features are concatenated with the preliminary anomaly probability map to generate an enhanced feature map. Constraint calculations are performed on the enhanced feature map using basic fusion constraints to generate constraint loss values, and the difference loss value between the preliminary anomaly probability map and the ground truth annotations of the batch of samples is calculated simultaneously. Predicted geometric features and predicted texture features corresponding to the multi-level template reference structure are decoded from the enhanced feature map. A first feature distance between the predicted geometric features and the geometric constraint features in the basic fusion constraints, and a second feature distance between the predicted texture features and the texture constraint features in the basic fusion constraints are calculated, respectively. The first feature distance and the second feature distance are multiplied by the corresponding constraint weights of the basic fusion constraints in the current iteration, and then summed to obtain the constraint loss value. The preliminary anomaly probability map is compared pixel by pixel with the ground truth annotation map of the batch of samples, and the cross-entropy loss is calculated as the preliminary difference loss. The overlap between regions identified as anomalous in the preliminary anomaly probability map and genuine anomalous regions in the ground truth map is calculated, and the Cross-Union Ratio (CIRR) penalty coefficient is calculated based on the overlap. The preliminary difference loss is multiplied by the CIRR penalty coefficient to obtain the final difference loss value. The constraint loss value and the difference loss value are weighted and summed to obtain the total loss value. The parameters of the anomaly detection network are updated based on the total loss value through backpropagation, and the constraint weight coefficients of the basic fusion constraints are updated simultaneously.

[0035] In practice, the iterative training of the network training and optimization module is performed in a project targeting the detection of dents and scratches on the surface of cylindrical lithium-ion batteries. The preprocessed visual imaging sample set contains calibrated battery surface images, the spatial distribution model has been pre-established, and the basic fusion constraints have been generated by the feature parsing and fusion module. In each training iteration, a batch of samples is randomly sampled from the preprocessed visual imaging sample set. The batch of samples contains multiple battery images and their pixel-level ground truth annotations. The batch of samples is input into the initialized anomaly detection network, which is a convolutional neural network with an encoder-decoder structure. The encoder extracts multi-scale features, and the decoder progressively samples and fuses features to output a preliminary anomaly probability map of the same size as the input image. Each pixel value in the preliminary anomaly probability map represents the probability of an appearance anomaly at that location.

[0036] In some embodiments, local spatial features corresponding to batch samples are extracted from the spatial distribution model. The extraction process is based on the projection relationship between the image in the batch samples and the three-dimensional grid of the spatial distribution model, obtaining the multi-dimensional feature vector at the three-dimensional grid vertex associated with each pixel of the image, forming a local spatial feature map. The local spatial feature map is concatenated with the preliminary anomaly probability map output by the anomaly detection network, connecting the data of the two feature maps along the channel dimension to generate an enhanced feature map with richer information. The enhanced feature map is constrained using the basic fusion constraints to generate a constraint loss value, and the difference loss value between the preliminary anomaly probability map and the true annotation of the batch samples is calculated simultaneously. The predicted geometric features and predicted texture features corresponding to the multi-level template reference structure are decoded from the enhanced feature map. The decoding operation is implemented through an additional convolutional layer, mapping the enhanced feature map to a space with the same dimension as the geometric constraint features and texture constraint features in the basic fusion constraints. The first feature distance between the predicted geometric features and the geometric constraint features in the basic fusion constraints, and the second feature distance between the predicted texture features and the texture constraint features in the basic fusion constraints are calculated respectively. The feature distance is calculated using Euclidean distance or cosine distance. The first feature distance and the second feature distance are multiplied by the corresponding constraint weights of the basic fusion constraints in the current iteration. The constraint weights of the basic fusion constraints are two independent learnable parameters or coefficients that are dynamically adjusted according to the policy. The results are then summed to obtain the constraint loss value.

[0037] In practice, the preliminary anomaly probability map is compared pixel-by-pixel with the true labeled map of the batch samples. The true labeled map is a binary image that marks the actual defect areas. Cross-entropy loss is calculated as the preliminary difference loss; the cross-entropy loss function compares the difference between the predicted probability distribution and the true distribution at each pixel. Regions identified as abnormal in the preliminary anomaly probability map are statistically analyzed, and the determination is made by setting a threshold to adjust the probability. Figure 2 The overlap between the binary region and the actual anomaly region in the labeled image is calculated. The overlap is obtained by calculating the ratio of the intersection area to the union area of ​​the two binary regions. An intersection-union ratio (IURR) penalty coefficient is calculated based on the overlap; this coefficient is a factor used to amplify or reduce the initial difference loss. The initial difference loss is multiplied by the IURR penalty coefficient to obtain the final difference loss value. The constraint loss value and the difference loss value are weighted and summed to obtain the total loss value used for this iteration. The backpropagation algorithm is then executed based on the total loss value to calculate the gradients of the parameters of each layer of the anomaly detection network. The optimizer is used to update the parameters of the anomaly detection network, and the constraint weight coefficients of the basic fusion constraints are also updated. It can be understood that the constraint weight coefficients of the basic fusion constraints are considered trainable parameters and updated along with the network during training. The feature correspondence of a batch containing four samples during processing is shown in Table 1. Table 1: Correspondence Table of Batch Sample Processing Features Crossover and union penalty coefficient The calculation formula is: in: This represents the intersection-union penalty coefficient. It is a preset scaling factor greater than zero. Preliminary anomaly probability Figure 2 The cross-union ratio between the valued region and the actual outlier region in the true labeled map.

[0038] In one embodiment of the present invention, during each training iteration, the contribution ratio of the constraint loss value of the basic fusion constraint to the total loss value is monitored. The moving average and gradient of the contribution ratio over the most recent iterations are calculated. When the moving average is lower than a preset lower threshold, or the gradient shows a negative trend, the constraint weight of the basic fusion constraint is increased by a preset step size. When the moving average is higher than a preset upper threshold, and the gradient shows a positive trend, the constraint weight of the basic fusion constraint is decreased by a preset step size. During iterative training, the area of ​​the response region of the anomaly detection network to local spatial features is recorded. Based on the changing trend of the response region area, the inflation rate of the convolutional layers in the anomaly detection network is dynamically adjusted. An attention gating mechanism is added to the intermediate layer of the anomaly detection network. The attention gating mechanism takes local spatial features as input and generates a spatial attention weight map. The spatial attention weight map is multiplied element-wise with the intermediate feature map of the anomaly detection network to focus on key regions in the spatial distribution model, thereby optimizing the analytical granularity.

[0039] In practice, dynamically adjusting the constraint weights of the basic fusion constraints and simultaneously optimizing the analytical granularity of the anomaly detection network for the spatial distribution model are performed in a scenario targeting the detection of minor weld penetrations and dummy weld points in the tab welding area of ​​a pouch battery. The training process uses a preprocessed visual imaging sample set containing thousands of labeled images. In each iteration of training, the contribution ratio of the constraint loss value of the basic fusion constraints to the total loss value is monitored. This contribution ratio is calculated by dividing the constraint loss value by the total loss value. The moving average and gradient of the contribution ratio over the most recent iterations are calculated. The moving average is obtained by taking the arithmetic mean of the contribution ratios within a fixed-size historical window, and the gradient is obtained by calculating the difference between the current moving average and the moving average of the previous window.

[0040] In some embodiments, when the moving average is below a preset lower threshold, or the gradient shows a negative trend, the constraint weights of the basic fusion constraint are increased by a preset step size. The preset lower threshold is a small value between 0 and 1, and a negative trend means the gradient is less than zero. When the moving average is above a preset upper threshold, and the gradient shows a positive trend, the constraint weights of the basic fusion constraint are decreased by a preset step size. The preset upper threshold is a value higher than the lower threshold, and a positive trend means the gradient is greater than zero. It can be understood that this adjustment mechanism aims to maintain a moderate supervisory role for the basic fusion constraint throughout the training process, avoiding its influence being too weak or too strong. During iterative training, the area of ​​the response region of the anomaly detection network to local spatial features is recorded. The area of ​​the response region is obtained by thresholding the output feature map of a specified convolutional layer in the anomaly detection network and calculating the total number of pixels in the activated region.

[0041] In practice, the dilation rate of convolutional layers in the anomaly detection network is dynamically adjusted based on the changing trend of the response region area. The changing trend of the response region area is determined by observing its direction of increase or decrease within a certain number of iterations. The dilation rate of the convolutional layer controls the interval between sampling points when the convolutional kernel processes the feature map; adjusting the dilation rate directly changes the size of the network's receptive field. The specific operation of dynamically adjusting the dilation rate can be guided by the ratio of the response region area to the response region area of ​​adjacent network layers, and the adjustment formula is: in: This indicates that the dilation rate of the convolutional layer is expected to be adjusted in the next iteration. This indicates the dilation rate of the convolutional layer in the current iteration cycle. It is a positive scaling factor. It is the area of ​​the response region of the current recording layer (the direct downstream layer of the layer to be adjusted). It is the area of ​​the response region of the adjacent upstream layer of the current recording layer.

[0042] In practical implementation, an attention gating mechanism is added to the intermediate layer of the anomaly detection network. This mechanism takes local spatial features as input, extracted from the spatial distribution model and aligned with the size of the feature map in the intermediate layer. The attention gating mechanism typically includes convolutional layers and activation functions to generate a spatial attention weight map. Each pixel value in the spatial attention weight map is between 0 and 1, representing the importance of the corresponding spatial location. The spatial attention weight map is then multiplied element-wise with the intermediate feature map of the anomaly detection network. Element-wise multiplication means directly multiplying the two values ​​at corresponding positions. This operation reduces the weight of features in non-critical regions and amplifies the weight of features in critical regions, thus forcing the network to focus more on key regions in the spatial distribution model during training. Key regions typically correspond to areas with high rates of appearance defects or complex structures, thereby optimizing the resolution granularity.

[0043] It should be noted that, in this document, relational terms such as "first" and "second" are used only 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 process, method, article, or apparatus.

[0044] 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 universal battery appearance anomaly detection system based on visual recognition, characterized in that, include: The template construction and layering module obtains a visual imaging sample set of general batteries and the corresponding standard appearance template. Based on the imaging features of the visual imaging sample set, the standard appearance template is dynamically layered to establish a multi-level template reference structure. The feature parsing and fusion module performs structured parsing on the multi-level template reference structure, extracts geometric constraint features and texture constraint features, and fuses the geometric constraint features and texture constraint features to generate basic fusion constraints. The sample preprocessing and modeling module performs illumination consistency correction and perspective distortion compensation on the visual imaging sample set to generate a preprocessed visual imaging sample set. Based on the preprocessed visual imaging sample set, a spatial distribution model of general battery surface features is constructed. The network training and optimization module inputs the basic fusion constraints and the spatial distribution model into the initialized anomaly detection network, and iteratively trains the anomaly detection network. During the iteration process, the constraint weights of the basic fusion constraints are dynamically adjusted, and the analytical granularity of the anomaly detection network for the spatial distribution model is optimized simultaneously to obtain a fully trained anomaly detection network. The system integration module integrates the multi-level template reference structure, the preprocessed visual imaging sample set, and the fully trained anomaly detection network to construct and deploy the general battery appearance anomaly detection system based on visual recognition.

2. The universal battery appearance anomaly detection system based on visual recognition as described in claim 1, characterized in that, The dynamic hierarchical division of the standard appearance template based on the imaging features of the visual imaging sample set includes: The standard appearance template is divided into a global mesh to obtain basic mesh units; The illumination distribution vector and surface curvature vector of each imaging sample are extracted from the visual imaging sample set, and the illumination distribution vector and surface curvature vector are combined to form a sample imaging feature vector; Calculate the global mean vector and global variance matrix of all sample imaging feature vectors, and based on the global mean vector and the global variance matrix, calculate the visual saliency score of each basic grid cell in the standard appearance template; Based on the visual saliency score, the basic grid cells are clustered and divided, and basic grid cells with similar visual saliency scores are grouped into the same template level to form a multi-level template set; Each template level is assigned an independent feature extraction channel and a comparison threshold parameter, and the multi-level template set and the corresponding feature extraction channels and comparison threshold parameters are used to construct the multi-level template reference structure.

3. The universal battery appearance inspection system based on visual recognition as described in claim 2, characterized in that, The extraction of geometric constraint features and texture constraint features includes: For each template level in the multi-level template reference structure, a preset geometric feature operator is invoked, including an edge gradient operator and a contour curvature operator, to extract the geometric feature map of each template level; Principal component decomposition is performed on the geometric feature map of each template level to obtain the principal geometric feature vector corresponding to each template level, and the principal geometric feature vector constitutes the geometric constraint feature; In parallel, for each template level in the multi-level template reference structure, a preset texture feature operator is invoked, which includes a local binary mode operator and a gray-level co-occurrence matrix operator, to extract the texture feature map of each template level. Texture primitive encoding is performed on the texture feature map of each template level to obtain the texture encoding sequence corresponding to each template level, and the texture encoding sequence constitutes the texture constraint feature.

4. The universal battery appearance anomaly detection system based on visual recognition as described in claim 3, characterized in that, The process of fusing the geometric constraint features and texture constraint features to generate basic fused constraints includes: For each template level, a feature mapping table is established between the main geometric feature vector and the texture encoding sequence. The feature mapping table records the correspondence between the dimension of the main geometric feature vector and the encoding of the texture encoding sequence. According to the feature mapping table, the main geometric feature vector and the texture encoding sequence are concatenated into tensors to generate a fused feature tensor for each template level; The fused feature tensor of each template level is normalized, and the covariance matrix between the normalized fused feature tensors of all template levels is calculated. Based on the covariance matrix, the stability weight of the fusion feature at each template level is calculated. The normalized fusion feature tensor is then weighted and fused according to the stability weight to generate the basic fusion constraint.

5. The universal battery appearance anomaly detection system based on visual recognition as described in claim 1, characterized in that, The step of performing illumination consistency correction and perspective distortion compensation on the visual imaging sample set to generate a preprocessed visual imaging sample set includes: For each visual imaging sample in the visual imaging sample set, estimate its global illumination histogram and local illumination gradient field; Based on the global illumination histogram and the local illumination gradient field, an illumination correction function is constructed. The illumination correction function is then used to perform global illumination equalization and local illumination compensation on the visual imaging sample to obtain the illumination-corrected imaging sample. The corner positions of the general-purpose battery in the illumination-corrected imaging sample are detected, and the projection transformation matrix is ​​calculated based on the standard corner positions of the standard appearance template. The projection transformation matrix is ​​used to perform perspective transformation on the illumination-corrected imaging sample to correct the deformation caused by the shooting angle, thereby generating the preprocessed visual imaging sample set.

6. The universal battery appearance anomaly detection system based on visual recognition as described in claim 5, characterized in that, The step of constructing a spatial distribution model of general battery surface features based on the preprocessed visual imaging sample set includes: Feature point detection and description are performed on the preprocessed visual imaging sample set, and scale-invariant feature transformation descriptors are extracted for each visual imaging sample. Based on the scale-invariant feature transformation descriptor, feature matching and alignment are performed on all visual imaging samples, mapping multiple visual imaging samples to a unified three-dimensional coordinate framework. Under the unified three-dimensional coordinate framework, the surface of a general battery is reconstructed by triangulation to obtain a three-dimensional mesh model of the battery surface. At each vertex of the three-dimensional mesh model, the feature descriptors corresponding to it in all visual imaging samples are aggregated to form a multi-dimensional feature vector. A mapping relationship from the three-dimensional mesh vertex to the multi-dimensional feature vector is established. The three-dimensional mesh model and the mapping relationship together constitute the spatial distribution model of the general battery surface features.

7. The universal battery appearance anomaly detection system based on visual recognition as described in claim 1, characterized in that, The iterative training of the anomaly detection network includes: In each iteration, a batch of samples is sampled from the preprocessed visual imaging sample set, and the batch of samples is input into the anomaly detection network to obtain a preliminary anomaly probability map of the batch of samples. Local spatial features corresponding to the batch samples are extracted from the spatial distribution model, and the local spatial features are concatenated with the preliminary anomaly probability map to generate an enhanced feature map. The enhanced feature map is constrained using the basic fusion constraints to generate a constraint loss value, and the difference loss value between the preliminary anomaly probability map and the true annotation of the batch samples is calculated at the same time. The constraint loss value and the difference loss value are weighted and summed to obtain the total loss value. The parameters of the anomaly detection network are updated by backpropagation based on the total loss value, and the constraint weight coefficients of the basic fusion constraint are updated at the same time.

8. A universal battery appearance anomaly detection system based on visual recognition as described in claim 7, characterized in that, The dynamic adjustment of the constraint weights of the basic fusion constraints includes: In each iteration of training, monitor the contribution ratio of the constraint loss value of the basic fusion constraint to the total loss value; Calculate the moving average and gradient of the contribution ratio over the most recent iterations; When the moving average is lower than the preset lower threshold, or when the change gradient shows a negative trend, the constraint weight of the basic fusion constraint is increased by a preset step size. When the moving average is higher than the preset upper limit threshold and the change gradient shows a positive trend, the constraint weight of the basic fusion constraint is reduced by a preset step size.

9. A universal battery appearance anomaly detection system based on visual recognition as described in claim 7, characterized in that, The synchronous optimization of the anomaly detection network's analytical granularity for the spatial distribution model includes: During iterative training, the area of ​​the response region of the anomaly detection network to the local spatial features is recorded; Based on the changing trend of the response region area, the dilation rate of the convolutional layers in the anomaly detection network is dynamically adjusted. An attention gating mechanism is added to the intermediate layer of the anomaly detection network. The attention gating mechanism takes the local spatial features as input and generates a spatial attention weight map. The spatial attention weight map is multiplied element-wise with the intermediate feature map of the anomaly detection network to focus on key regions in the spatial distribution model, thereby optimizing the resolution granularity.

10. A universal battery appearance anomaly detection system based on visual recognition as described in claim 7, characterized in that, The step of using the basic fusion constraints to perform constraint calculations on the enhanced feature map to generate constraint loss values, and simultaneously calculating the difference loss values ​​between the preliminary anomaly probability map and the true annotations of the batch samples, includes: The predicted geometric features and predicted texture features corresponding to the multi-level template reference structure are decoded from the enhanced feature map; Calculate the first feature distance between the predicted geometric feature and the geometric constraint feature in the basic fusion constraint, and the second feature distance between the predicted texture feature and the texture constraint feature in the basic fusion constraint, respectively. The first feature distance and the second feature distance are multiplied by the corresponding constraint weights of the basic fusion constraints in the current iteration, and then summed to obtain the constraint loss value; The preliminary anomaly probability map is compared pixel by pixel with the true labeled map of the batch samples, and the cross-entropy loss is calculated as the preliminary difference loss. The overlap between the regions identified as anomalous in the preliminary anomaly probability map and the real anomalous regions in the true annotation map is calculated, and the intersection-union ratio penalty coefficient is calculated based on the overlap. The initial difference loss is multiplied by the cross-union ratio penalty coefficient to obtain the final difference loss value.