Method for detecting negative face defects of cylindrical dry batteries based on machine vision
Patent Information
- Application Number
- CN202310933553.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-27
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2043-07-27
AI Technical Summary
然而,数据集标注的质量对最终算法实现的效果影响较大
[0054](1)本发明能够识别由于电池表面划痕、凹陷、脱皮、缺口、卷边皱、卷边三角、负极盖倾斜和密封圈外漏等问题引起的缺陷情况,且识别效果好;
Smart Images

Figure CN116840241B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision digital image processing, specifically a method for detecting defects on the negative electrode surface of cylindrical dry cell batteries based on machine vision. Background Technology
[0002] In battery production, defect detection plays a crucial role at every stage. Currently, some dry cell battery manufacturing lines still rely on manual visual inspection for sealed battery quality testing and classification, which is labor-intensive, costly, and increasingly unsuitable for current production conditions. Machine vision technology, as an automated inspection technology, offers significant advantages such as safety, stability, continuous operation, and adaptability to harsh environments. Currently, machine vision technology is beginning to be applied in industrial automation scenarios, resulting in numerous innovations and applications of battery appearance defect detection algorithms, primarily categorized into two types: machine vision-based and neural network-based methods.
[0003] The basic workflow of machine vision-based methods includes image segmentation, morphological processing, and feature value calculation. However, most existing algorithms address defects such as scratches and dents on the battery's exterior. In addition, other problems exist in actual battery production, such as peeling at the battery opening, gaps, rolled edges, triangular rolled edges, tilted negative electrode caps, and leaking sealing rings. These defects are more likely to occur and have a greater impact on the production process. Furthermore, most algorithms are based on images acquired under specific imaging conditions, making them difficult to reproduce in real-world applications. Moreover, these algorithms lack robustness analysis for potential problems in actual production. In battery production, oil contamination on the production line can affect the quality of battery defect detection, potentially leading to a sharp increase in false positives during large-scale production inspections.
[0004] Neural network-based battery defect detection methods offer the advantage of significantly reducing image preprocessing compared to machine vision-based methods, enabling rapid algorithm design and deployment. However, these advantages rely heavily on obtaining large-scale, manually collected and labeled battery datasets beforehand. The quality of the labeled dataset significantly impacts the final algorithm's performance. In practice, challenges arise such as insufficient data quantity, poor data quality, and uneven distribution of good and bad samples, leading to poor training results. Ultimately, the algorithm's operational efficiency and detection accuracy still fall short of factory production requirements. Summary of the Invention
[0005] This invention proposes a machine vision-based method for detecting defects on the negative electrode surface of cylindrical dry cell batteries.
[0006] The technical solution to achieve the objective of this invention is: a method for detecting defects on the negative electrode surface of a cylindrical dry cell based on machine vision, the specific steps of which are as follows:
[0007] Step 1: Correct the camera parameters;
[0008] Step 2: Acquire a global image of the negative electrode surface of the battery, and perform preprocessing and Hough transform on the global image to identify and remove deformed battery sample images;
[0009] Step 3: Perform defect detection on the negative electrode surface of the battery. The defect detection includes appearance defect detection as well as scratch and pit detection.
[0010] Preferably, the specific method for correcting camera parameters is as follows:
[0011] Step 1.1: Take multiple images of the ceramic calibration plate from different directions to ensure that the calibration plate is fully displayed and the edges are clear;
[0012] Step 1.2: The Harris corner detection algorithm is used to automatically obtain the position of the corner of the ceramic calibration plate, and the initial integer corner coordinates are optimized with sub-pixel precision to obtain the coordinates of all corner positions;
[0013] Step 1.3: Calculate the camera imaging distortion parameters and obtain the corrected image.
[0014] Preferably, the specific method for acquiring a global image of the battery's negative electrode surface is as follows:
[0015] Batteries are transported using a turntable.
[0016] The camera and photoelectric trigger switch are fixed to the side of the turntable, respectively.
[0017] Each time the battery passes the photoelectric trigger, it triggers a photoelectric signal. After a time delay, the camera captures a global image of the battery's negative electrode surface.
[0018] Preferably, the specific method for preprocessing and performing Hough transform on the global image is as follows:
[0019] The complete image captured by the camera is preprocessed for edge extraction to obtain image edge feature information;
[0020] Histograms are used to count the number of relevant pixels, and pixels are retained according to a certain ratio. The center coordinates (x, y, y) of the remaining pixels are then calculated. c ,y c );
[0021] Obtain the coordinates (x) of all battery center points used for Hough transform retrieval s ,y s The set of )
[0022]
[0023] In the formula, [r min ,r max [ ] represents the range of turntable r;
[0024] For each edge feature point in the image, calculate the possible center positions of the circles around the edge feature point and store them in an accumulator array;
[0025] Find the circle that repeats the most times in the accumulator array;
[0026] Based on a set threshold, circles with a repetition count exceeding the threshold are selected, and the center and radius information of the circles are obtained. Circles with radii not falling within the range [r...]. min ,r max Samples between [ ] were identified and determined to be unqualified battery samples;
[0027] The remaining battery sample images are cropped to obtain new images based on the calculated center and radius.
[0028] Preferably, the specific method for detecting appearance defects is as follows:
[0029] The remaining images from step 2 are divided into annular and inner circular regions based on different radii;
[0030] The annular region is stretched into a rectangle of length m and width n, represented as an image.
[0031] Image X is smoothed and equalized using a convolution kernel. Perform a convolution operation on the smoothed and equalized image to obtain matrix Z and the convolution kernel. Given a matrix Z with length and width L, the element in the i-th row and j-th column is as follows:
[0032]
[0033] Among them, w uv This represents the parameter values in the u-th row and v-th column of the convolution kernel K, x i-u+1,j-v+1 This represents each value in image X that participates in the convolution operation;
[0034] Calculate the average gradient grad of matrix Z;
[0035] The average gradient grad of matrix Z is compared with a pre-set threshold. If the average gradient grad is greater than the threshold, the texture is considered to change drastically and is judged as a sample with an appearance defect.
[0036] Preferably, the specific method for scratch and pit detection is as follows:
[0037] The inner circular region of the remaining image from step 2 is filtered.
[0038] Let the threshold for binarization be t, the average gray level of the background be u1(t), the average gray level of the target be u2(t), the proportion of the background in the image be w1(t), and the proportion of the target in the image be w2(t). Then the distance d from the background pixel to the target is... 12 (t), the distance d from the target pixel to the background 21 The inter-class distance between the target pixel and the background pixel is defined as d(t), specifically:
[0039]
[0040] Optimal threshold t best for:
[0041]
[0042] The filtered image is binarized using the optimal threshold to obtain the binarized image B; then, the binarized image B is subjected to erosion processing.
[0043] The connected regions of the image after the erosion operation were statistically analyzed using a two-pass scanning method.
[0044] The second largest connected region S area2 With set threshold Comparison, when the second largest connected region S area2 Greater than the set threshold It was determined that there might be scratches, pits, or oil stains;
[0045] Perform morphological feature calculations on the connected regions to obtain the coordinates (x, y) of the leftmost end of the connected region. left ,y left ) and the rightmost coordinate (x right ,y right ), calculate the aspect ratio r of the connected region. area The aspect ratio r of the connected region area With the set threshold r area_threshold Comparison: If the aspect ratio r of the connected region is... area Below the threshold r area_threshold If it is not oil, it is considered an oil stain; otherwise, it is considered a scratch.
[0046] Preferably, the specific method for statistically analyzing the connected regions of the image after the erosion operation using a two-pass scanning method is as follows:
[0047] Starting from the top left corner of the image, traverse each pixel. For each foreground pixel, check the pixels to its left and above. If the pixels to its left and above are both background pixels, mark the current pixel as a new connected region and assign it a new label value. If the pixels to its left and above belong to the same connected region, mark the current pixel as part of that connected region. If the pixels to its left and above belong to different connected regions, mark the current pixel as one of the connected regions and record the equivalence relationship between the two connected regions.
[0048] Using the equivalence relation table obtained from the first scan, merge the connected component labels that have equivalence relations;
[0049] By iterating through the equivalence relation table, the labels of connected components with equivalence relations are merged.
[0050] Repeat the merging process until all equivalence relations have been processed.
[0051] The image is labeled with connected components processed by equivalence relations, and each pixel of the image is scanned again;
[0052] For each foreground pixel, its label value is updated to the label value of the final connected region to which it belongs.
[0053] Compared with the prior art, the significant advantages of this invention are:
[0054] (1) The present invention can identify defects caused by scratches, dents, peeling, gaps, curled edges, curled triangles, tilting of negative electrode cover and leakage of sealing ring on battery surface, and the identification effect is good;
[0055] (2) The present invention provides a solution to the problem of oil stains adhering to the battery surface on the production line interfering with detection.
[0056] The present invention will now be described in further detail with reference to the accompanying drawings. Attached Figure Description
[0057] Figure 1 This is a flowchart of a machine vision-based method for detecting defects on the negative electrode surface of cylindrical dry cell batteries. Detailed Implementation
[0058] A machine vision-based method for detecting defects on the negative electrode surface of cylindrical dry cell batteries first adjusts camera parameters, primarily including camera calibration and grayscale correction. During operation, after the battery triggers a signal, the camera captures a global image of the battery. Image preprocessing enhances the distinction between the battery and the background, followed by a Hough transform to obtain the battery's center and radius. In this step, based on factory production process analysis of battery dimensions, batteries with substandard dimensions are directly identified as defective samples, and a high-potential signal indicating a defect is transmitted to the factory's main control system. For the remaining samples, images excluding the background are cropped based on the battery's center and radius for further analysis. In the final battery negative electrode surface defect detection process, after acquiring the negative electrode surface image and performing some preprocessing, the image is divided into an annular portion and an inner circle based on defect distribution characteristics. For the annular portion, texture, color, and morphological features are calculated; for the inner circle portion, pits and scratches are detected. In the above operations, if any part has a defect characteristic index exceeding the set threshold, the sample will be judged as unqualified. If all indicators are within the set acceptable sample range, the sample will be judged as acceptable.
[0059] A machine vision-based method for detecting defects on the negative electrode surface of cylindrical dry cell batteries includes three steps: camera parameter correction, image capture of the negative electrode surface, and defect detection. These steps are as follows:
[0060] Step 1: Correct camera parameters
[0061] Camera imaging can be divided into four steps: rigid body transformation, perspective projection, distortion correction, and image digitization. Due to imperfections in lens manufacturing, each lens exhibits some degree of irregular refraction. Therefore, in industrial inspection tasks, it is necessary to calibrate different cameras to adjust camera parameters and reduce image distortion.
[0062] Step 1.1: Take multiple images of the ceramic calibration plate from different directions to ensure that the calibration plate is fully presented and the edges are clear.
[0063] Step 1.2: The Harris corner detection algorithm is used to automatically obtain the position of the corner of the ceramic calibration plate, and the initial integer corner coordinates are optimized with sub-pixel precision to finally obtain the position coordinates of all corners.
[0064] Step 1.3: Calculate the camera imaging distortion parameters and obtain the corrected image.
[0065] The distortion coefficients of an image consist of two parts: radial distortion (k1, k2, k3) and tangential distortion (p1, p2). For a point P(X, Y, Z) in the camera coordinate system, the correct position of this point on the pixel plane can be found using these five distortion coefficients:
[0066] Step 1.3.1: Project the 3D spatial point onto the normalized image plane. Let its normalized coordinates be [x, y]. T .
[0067] Step 1.3.2: Correct radial and tangential distortion for points on the normalized plane. Based on the coordinates of the corner points, establish multiple sets of equations and solve for the unknowns k1, k2, k3, p1, p2, which are the parameters of radial and tangential distortion.
[0068]
[0069] Step 1.3.3: Project the corrected point onto the pixel plane using the intrinsic parameter matrix to obtain the correct position of the point on the image.
[0070] Step 2: Acquire a global image of the negative electrode surface of the battery, and perform preprocessing and Hough transform on the global image;
[0071] Considering the battery movement pattern and switch trigger sensitivity, a switch-delay-triggered camera method is used to acquire images of the battery's negative electrode surface. The factory production line uses a turntable to transport batteries. Magnets, spaced at fixed intervals, attract batteries to the outermost part of the turntable. The camera and photoelectric trigger switch are fixed at different positions on the production line. Each time a battery passes the photoelectric trigger, a photoelectric signal is activated, and the camera takes an image after a time delay t. The time T for one revolution of the production line, the turntable radius r, and the arc length l between the battery and the camera are used to calculate the set delay t for the camera.
[0072]
[0073] Due to limitations in battery manufacturing processes and production line stability, the position of the battery's negative electrode surface in the global image still suffers from pixel-level errors.
[0074] First, edge extraction preprocessing is performed on the complete image captured by the camera to obtain image edge feature information. Then, according to the battery process specifications provided by the factory, the range of the turntable r is limited to [r]. min ,r max Further, histograms are used to count the number of relevant pixels, pixels are retained according to a certain proportion, and the center coordinates (x, y) of the remaining pixels are calculated. c ,y cSpecifically, pixels are sorted according to their grayscale values, and pixels with grayscale values greater than a set threshold are retained. The median of the horizontal and vertical coordinates of these pixels is then calculated. Next, the coordinates (x, y, y) of all battery center points used for Hough transform retrieval can be obtained. s ,y s The set of )
[0075]
[0076] Assume the standard equation of the circle is (x - x0). 2 +(y-y0) 2 =r 2 The Hough transform requires the values of three parameters (x0, y0, r) to determine the location of a circular target. Let θ be the angle between the x-axis and the line connecting the center of the circle to a point (x, y) on the circumference, where 0° ≤ θ < 360°, then we have:
[0077]
[0078] For each edge feature point in the image, the possible center positions of circles around that point are calculated and stored in an accumulator array, which is achieved by iterating through all possible center positions and radii. The circle with the highest repetition frequency is found in the accumulator array. Finally, circles with a repetition frequency higher than a set threshold are filtered out.
[0079] Under the constraint of the search region, the Hough transform can quickly obtain the center and radius information of the battery, directly filtering out battery samples with severe appearance deformation, i.e., those whose radius is not within [r...]. min ,r max The remaining battery samples are selected from those between [the specified range] and pre-determined as unqualified. Finally, the complete images of the remaining battery samples are cropped according to the calculated center and radius to obtain new images.
[0080] Step 3: Perform defect detection on the negative electrode surface of the battery.
[0081] Step 3.1: Visual Defect Inspection
[0082] Peeling at the battery opening, gaps, rolled edges, rolled edges with triangular shapes, and exposed sealing rings are some of the defects that appear in the battery ring area. Even when these defects are present, some battery samples do not show obvious deformation. However, the appearance of these defective samples differs drastically from that of standard samples.
[0083] Since the battery ring shape is circular, the remaining sample-cropped battery image is first divided into two regions, an outer ring and an inner ring, based on different radii. Then, the ring region is stretched into a rectangle with length m and width n, represented as an image. Next, image X is smoothed and equalized to enhance image contrast. Then, a convolution kernel is applied. A matrix Z is obtained by performing a convolution operation on the smoothed and equalized image (a matrix with length and width L). This method is described by the following formula:
[0084]
[0085] The convolution operation performs a pointwise multiplication of the convolution kernel with the input image and then sums the results. Where w uv The parameter value of the convolution kernel K with index (u,v) is x. i-u+1,j-v+1 This represents each value in image X that participates in the convolution operation. Here, u and v represent the u-th row and v-th column of the matrix, respectively.
[0086] Then, the average gradient grad of matrix Z is calculated as the output, where avg is a function for calculating the average value.
[0087] Z grad =avg∑Z i,j
[0088] Finally, based on the preset threshold and Z grad The comparison results show that if the value is greater than the threshold, the texture change is considered to be drastic, and therefore the sample is judged to be an appearance defect sample.
[0089] Step 3.2: Scratch and pit detection
[0090] The main algorithms for scratch and pit detection include image enhancement techniques such as filtering, binarization, and erosion, as well as statistical analysis of information related to the minimum connected regions.
[0091] Because the inner circular area of the battery is rough, shadows will appear in the image after the ring light source is used for illumination. This will affect the algorithm's ability to extract scratches and surface features. Therefore, it is necessary to first use median filtering to process the image to remove this effect.
[0092] Next, the optimal threshold t required for binarization is determined. best Assuming the binarization threshold is t, the average gray level of the background is u1(t), the average gray level of the target is u2(t), the proportion of the background in the image is w1(t), and the proportion of the target in the image is w2(t), then the distance d from the background pixel to the target is... 12 (t), the distance d from the target pixel to the background 21 The inter-class spacing between the target pixel and the background pixel is defined as d(t), and the parameter definition is shown in the following formula.
[0093]
[0094] Therefore, the optimal threshold t can be obtained by calculating it using the following formula. best .
[0095]
[0096] After obtaining the binarized image B, several dilation or erosion operations are performed on image B.
[0097] Based on the preprocessed binarized image, the connected regions of the image are statistically analyzed using the Two-Pass scanning method. The specific process is as follows:
[0098] 1. First scan
[0099] ① Starting from the top left corner of the image, iterate through each pixel. For each foreground pixel (pixel value 255), check the pixels to its left and above.
[0100] ② If the pixels on the left and above are background pixels (pixel value 0), then mark the current pixel as a new connected region and assign a new label value.
[0101] ③ If the pixels on the left and above belong to the same connected region, then mark the current pixel as part of that connected region.
[0102] ④ If the pixels on the left and above belong to different connected regions, mark the current pixel as one of the connected regions and record the equivalence relationship between the two connected regions.
[0103] 2. Handling of equivalence relations
[0104] ①Use the equivalence relation table obtained from the first scan to merge the connected region labels that have equivalence relations.
[0105] ② By iteratively traversing the equivalence relation table, the labels of connected regions with equivalence relations are merged.
[0106] ③ Repeat the merging process until all equivalence relations have been processed.
[0107] 3. Second scan
[0108] ① Label the image using the connected components processed by equivalence relations, and then scan each pixel of the image again.
[0109] ② For each foreground pixel, update its label value to the label value of its final connected region.
[0110] After the second scan, the final connected component labeled image is obtained. The second largest connected component S is then selected. area2 Set threshold S area_thresholdTo determine whether a sample is unqualified, the second largest connected region S... area2 Greater than the set threshold S area_threshold The results can be categorized into two types: pitting defects and the possibility of oil stains or scratches.
[0111] Next, the morphological features of the connected regions are calculated, and a threshold is set to distinguish between oil stains and scratches. After statistically analyzing and obtaining the connected regions, the coordinates of the leftmost end of each region (x, y, y) can be obtained. left ,y left ) and the rightmost coordinate (x right ,y right ), calculate the aspect ratio r of the connected region. area The calculation formula is as follows.
[0112]
[0113] Set threshold r area_threshold Filter by two categories: oil stains and scratches. If the value is below the threshold r... area_threshold If it is not oil, it is considered an oil stain; otherwise, it is considered a scratch.
[0114] Finally, samples containing scratch and pit features were deemed unqualified, while samples containing oil stain features were deemed qualified.
[0115] This invention implements a battery defect detection algorithm that integrates image acquisition, processing, and algorithm analysis. It has high accuracy and can identify defects caused by issues such as scratches, dents, peeling, gaps, rolled edges, rolled triangles, tilted negative electrode caps, and leakage of the sealing ring. It also provides a strategy to address issues caused by interference from dirt during the production process.
Claims
1. A method for detecting defects on the negative electrode surface of a cylindrical dry cell based on machine vision, characterized in that, The specific steps are as follows: Step 1: Correct the camera parameters; Step 2: Acquire a global image of the negative electrode surface of the battery, and perform preprocessing and Hough transform on the global image to identify and remove deformed battery sample images; Step 3: Perform defect detection on the negative electrode surface of the battery. The defect detection includes visual defect detection as well as scratch and pit detection. The specific method is as follows: The remaining images from step 2 are then filtered. Set the threshold for binarization processing to... The average gray level of the background area is The target's average gray level is The background portion occupies a certain percentage of the image. The proportion of the target portion in the image is Then the distance from the background pixel to the target is... Distance from target pixel to background The inter-class spacing between the target pixel and the background pixel is defined as follows: Specifically: Optimal threshold for: The filtered image is binarized using the optimal threshold to obtain the binarized image. ; Image after binarization Perform corrosion treatment; The connected regions of the image after the erosion operation are counted using a two-pass scanning method. The specific method is as follows: Starting from the top left corner of the image, iterate through each pixel. For each foreground pixel, check the pixels to its left and above. If the pixels to its left and above are background pixels, mark the current pixel as a new connected region and assign it a new label value. If the pixels to the left and above belong to the same connected region, then mark the current pixel as part of that connected region; if the pixels to the left and above belong to different connected regions, then mark the current pixel as one of the connected regions and record the equivalence relationship between the two connected regions. Using the equivalence relation table obtained from the first scan, merge the connected component labels that have equivalence relations; By iterating through the equivalence relation table, the labels of connected components with equivalence relations are merged. Repeat the merging process until all equivalence relations have been processed. The image is labeled with connected components processed by equivalence relations, and each pixel of the image is scanned again; For each foreground pixel, update its label value to the label value of its final connected region; The second largest connected region With set threshold Comparison, when the second largest connected region Greater than the set threshold It was determined that there might be defects such as pits, scratches, or oil stains. Perform morphological feature calculations on the connected regions to obtain the coordinates of the leftmost end of the connected regions. and the rightmost coordinate Calculate the aspect ratio of the connected region. The aspect ratio of the connected region With set threshold Comparison, if the aspect ratio of the connected regions Below the threshold If it is not oil, it is considered an oil stain; otherwise, it is considered a scratch.
2. The method for detecting defects on the negative electrode surface of a cylindrical dry cell based on machine vision according to claim 1, characterized in that, The specific method for correcting camera parameters is as follows: Step 1.1: Take multiple images of the ceramic calibration plate from different directions to ensure that the calibration plate is fully displayed and the edges are clear; Step 1.2: The Harris corner detection algorithm is used to automatically obtain the position of the corner of the ceramic calibration plate, and the initial integer corner coordinates are optimized with sub-pixel precision to obtain the coordinates of all corner positions; Step 1.3: Calculate the camera imaging distortion parameters and obtain the corrected image.
3. The method for detecting defects on the negative electrode surface of a cylindrical dry cell based on machine vision according to claim 1, characterized in that, The specific method for acquiring a global image of the battery's negative electrode surface is as follows: Batteries are transported using a turntable. The camera and photoelectric trigger switch are fixed to the side of the turntable, respectively. Each time the battery passes the photoelectric trigger, it triggers a photoelectric signal. After a time delay, the camera captures a global image of the battery's negative electrode surface.
4. The method for detecting defects on the negative electrode surface of a cylindrical dry cell based on machine vision according to claim 1, characterized in that, The specific methods for preprocessing and performing Hough transform on the global image are as follows: The complete image captured by the camera is preprocessed for edge extraction to obtain image edge feature information; Histograms are used to count the number of relevant pixels, pixels are retained according to a certain ratio, and the center coordinates of the remaining pixels are calculated. ; Obtain the coordinates of all battery center points for Hough transform retrieval. The set of: In the formula, For turntable Scope; For each edge feature point in the image, calculate the possible center positions of the circles around the edge feature point and store them in an accumulator array; Find the circle that repeats the most times in the accumulator array; Based on a set threshold, circles with a repetition count exceeding the threshold are filtered out. The center and radius information of these circles are obtained, and circles with radii not exceeding the threshold are then filtered out. The samples in between were identified and determined to be unqualified battery samples; The remaining battery sample images are cropped to obtain new images based on the calculated center and radius.
5. The method for detecting defects on the negative electrode surface of a cylindrical dry cell based on machine vision according to claim 1, characterized in that, The specific methods for detecting appearance defects are as follows: The remaining images from step 2 are divided into annular and inner circular regions based on different radii; The annular region is stretched into a rectangle of length m and width n, represented as an image. ; For images Smoothing and equalization are performed using convolutional kernels. Perform convolution operations on the smoothed and equalized image to obtain a matrix. convolution kernel Let L be a matrix with both length and width. The element in the i-th row and j-th column is specifically: in, This represents the parameter values in the u-th row and v-th column of the convolution kernel K. Representing an image Each value in the convolution operation; Calculate the average gradient of matrix Z ; The average gradient of matrix Z Compared with a preset threshold, if the average gradient If the value exceeds the threshold, the texture is considered to have changed drastically and is judged as a sample with an appearance defect.
Citation Information
Patent Citations
Photovoltaic cell defect online detection method and system based on machine vision
CN113834816A