Battery accessories quality inspection method and system based on machine vision
Through improved binary graph algorithm and grayscale processing, the problem of position offset and depth matching error in battery accessories detection is solved, the accuracy and robustness of the detection are improved, and stable detection in different scenarios is achieved.
Patent Information
- Application Number
- CN202411509170.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-10-28
AI Technical Summary
Traditional manual detection methods cannot meet the efficient and accurate quality control needs of battery accessories in large-scale production environments, and existing machine vision technologies are prone to ignore position offset and depth matching errors in battery accessories quality detection, affecting detection accuracy.
Using the improved binary graph algorithm, the vertex matrix is constructed by obtaining the four vertex positions and depth values of the battery accessories image, and the Hungarian algorithm or KM algorithm is used to match it, adjust the image position to align the standard images, combined with grayscale processing and medium Value filtering reduces noise and ensures the stability of the detection results.
It improves the accuracy and robustness of battery accessories quality detection, reduces position offset and depth matching errors, enhances the reliability and adaptability of detection, and ensures stable detection results in different scenarios.
Smart Images

Figure CN119027422B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and more specifically, to a battery accessory quality detection method and system based on machine vision. Background Art
[0002] In modern industry, quality control of battery accessories is a key link to ensure battery performance and reliability. With the popularity of electric vehicles and renewable energy equipment, the continuous advancement of battery technology has also increased the manufacturing accuracy and quality requirements of battery accessories. Battery accessories usually include battery housings, terminals, separators and other components, and their accuracy and surface quality directly affect the safety, life and performance of the battery. Therefore, in the large-scale production and high-speed production environment on the production line, traditional manual inspection methods can no longer meet the needs of efficient and accurate quality control.
[0003] With the development of computer vision technology, machine vision has become an effective tool for solving these problems. In the field of machine vision, it is often necessary to solve problems such as feature matching, image registration, and target tracking. These problems can be solved by bipartite graph algorithms. In a weighted bipartite graph, the weight of the edge represents the cost or benefit. Common weighted bipartite graph algorithms include the Hungarian algorithm, the KM algorithm, and the minimum cost maximum flow algorithm. They find the optimal match by weight optimization, with the goal of minimizing or maximizing the total weight. These algorithms are widely used in scenarios such as task allocation and resource scheduling.
[0004] The patent application document with application publication number CN110220910A discloses a lithium battery comprehensive quality online monitoring system and method based on machine vision. The patent application document discloses a lithium battery comprehensive quality online monitoring system based on machine vision, including: an image acquisition module for acquiring images of lithium batteries at multiple angles; a data transmission module; an image processing module for processing images transmitted by the data transmission module; an analysis module for analyzing the lithium battery features extracted by the image processing module to find out quality defects; a display module; and also discloses a lithium battery comprehensive quality online monitoring method based on machine vision, which acquires images of lithium batteries at multiple angles, processes the images, extracts the features of lithium batteries, analyzes the features of lithium batteries, and finds out quality defects. However, the above technical solution relies solely on a single feature analysis, and often ignores the problems of position offset and depth matching errors in battery accessory quality inspection, which may affect the accuracy of the inspection process. Summary of the invention
[0005] In order to solve the problem raised in the above background technology that reliance on simple mechanical measurement and visual inspection often leads to low accuracy in quality inspection of battery accessories, the present invention provides solutions in the following aspects.
[0006] In a first aspect, the present invention provides a battery accessory quality detection method based on machine vision, comprising:
[0007] Get the size The image of the battery accessory to be detected and the positions of the four vertices of the image are used to determine the preset windows of each vertex; wherein the four vertices are respectively located in different preset windows; the depth values of the pixels in the four preset windows in the image are determined; all the depth values in each preset window constitute a vertex matrix; the improved bipartite graph algorithm is used to match the vertex matrices of the battery accessory image to be detected with the standard vertex matrices of the standard battery accessory image to obtain four matrix pairs; each standard vertex matrix is composed of the depth values of the pixels in each preset window in the standard battery accessory image; based on the matrix pairs, the positions of the vertices of the battery accessory image to be detected are adjusted to correspond to the positions of the vertices of the standard battery accessory image; in response to the difference between the depth values of the pixels at the corresponding positions in the standard battery accessory image and the adjusted battery accessory image to be detected being less than or equal to a set threshold, the battery accessory to be detected is normal, otherwise, the battery accessory to be detected is defective; wherein the weight in the improved bipartite graph algorithm is: the similarity between each standard vertex matrix and each vertex matrix, the similarity is positively correlated with the depth value of the pixels in the corresponding standard vertex matrix, and negatively correlated with the size of the preset window and the depth value of the pixels in the corresponding vertex matrix.
[0008] The above technical solution solves the problem of detection error caused by image position offset and depth information mismatch during the quality inspection of battery accessories. By setting up preset windows at the four vertices of the image, the key boundary area can be accurately located, thereby reducing the overall calculation amount and matching complexity. At the same time, an improved bipartite graph algorithm is used to match the vertex matrix of the image to be inspected and the standard image, and adjustments are made based on the pixel depth value in the preset window to ensure that the vertex positions of the two are aligned. By comparing the depth value difference between the corresponding pixel points in the adjusted image and the standard image, it is determined whether the battery accessories have defects.
[0009] Furthermore, the similarity is:
[0010] ;
[0011] In the formula, Represents the vertex matrix and the vertex matrix The similarity between Indicates the size of the preset window. Represented in the vertex matrix Middle Line The depth value of the column, Represented in the vertex matrix Middle Line The depth value of the column, represents an empirical constant, and .
[0012] The above technical solution uses a similarity formula to accurately match the vertex matrices of the standard battery accessories and the battery accessories to be tested. By calculating the depth value difference of the corresponding pixel points of the two matrices and introducing the adjustment of the window size, it can effectively measure the similarity of the two images in the vertex area, improve the detection accuracy of subtle differences in battery accessories, and thus reduce misjudgment caused by position offset or deformation, making the detection results more robust and reliable.
[0013] Furthermore, it also includes obtaining an image of a historical battery accessory with a positional offset, setting a plurality of preset windows of different sizes to match the image, calculating the accuracy of matching the image under preset windows of different sizes, and responding that the preset window with the highest accuracy is the optimal preset window; the accuracy is:
[0014] ;
[0015] In the formula, Indicated in The matching accuracy under the preset window size, Indicated in The correct number of preset window sizes is matched. Indicated in The number of matching errors for a preset window size.
[0016] The above technical solution collects images of historical battery accessories with position offsets, calculates the matching accuracy under different window sizes, and effectively reduces the matching error by adjusting the window size, thereby improving the robustness and flexibility of the matching and ensuring that stable and reliable detection results can be obtained in various complex scenarios.
[0017] Furthermore, the bipartite graph algorithm is a Hungarian algorithm or a KM algorithm.
[0018] The above technical solution uses the Hungarian algorithm or the KM algorithm as a bipartite graph algorithm to match the vertex matrices of the standard battery accessories and the battery accessories to be tested. The Hungarian algorithm and the KM algorithm are efficient and globally optimal in solving matching problems, and can ensure that the optimal matching combination is quickly found in a variety of matching scenarios, thereby improving the accuracy and robustness of the entire battery accessory quality inspection process.
[0019] Furthermore, the image of the battery accessory to be detected and the positions of the four vertices of the image are obtained by a three-dimensional camera.
[0020] Furthermore, based on the matrix pair, the positions of each vertex of the battery accessory image to be detected are adjusted to correspond to the positions of each vertex of the standard battery accessory image, specifically: the translation matrix, scaling matrix and rotation matrix in the matrix pair are extracted, and the translation matrix, scaling matrix and rotation matrix are formed into an affine transformation matrix, and the battery accessory image to be detected is translated, scaled and rotated by using the affine transformation matrix, so that the positions of each vertex of the battery accessory image to be detected correspond to the positions of each vertex of the standard battery accessory image.
[0021] The above technical solution solves the image alignment problem caused by the position, scale and rotation differences between the battery accessory image to be inspected and the standard image. By extracting the translation, scaling and rotation matrices and forming an affine transformation matrix, the image to be inspected is adjusted accordingly to ensure that its vertex position is aligned with the standard image, thereby improving the accuracy and consistency of accessory quality inspection.
[0022] Furthermore, the method also includes gray-scaling and median filtering the standard battery accessory image and the battery accessory image to be detected.
[0023] In a second aspect, the present invention provides a battery accessory quality inspection system based on machine vision, comprising a memory and a processor, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, any one of the above-mentioned battery accessory quality inspection methods based on machine vision is implemented.
[0024] The beneficial effects of the present invention are:
[0025] The present invention obtains the four vertex positions of the image to be detected and the standard image and the depth values of the pixel points, constructs a vertex matrix, and uses an improved bipartite graph algorithm for matching, thereby accurately handling the position offset problem in the detection process. Using depth value detection instead of traditional two-dimensional image detection allows the three-dimensional shape differences of battery accessories to be negatively projected, thereby improving the accuracy of quality detection. By setting preset windows of different sizes and selecting the optimal window based on the matching accuracy, it can adapt to the detection needs of battery accessories of different sizes and shapes. In order to further improve the matching accuracy, the affine transformation matrix is used to translate, scale and rotate the image at the same time to ensure the consistency of the image geometric position. In addition, grayscale processing and median filtering reduce image noise and interference, ensure the stability and accuracy of the detection results, and thus comprehensively improve the reliability and adaptability of battery accessory quality detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0027] Figure 1 is a flowchart schematically showing a battery accessory quality detection method based on machine vision according to an embodiment of the present invention;
[0028] Figure 2 is a schematic diagram schematically illustrating matching vertex matrix pairs by a bipartite graph algorithm according to an embodiment of the present invention;
[0029] Figure 3 It is a structural block diagram schematically showing a battery accessory quality detection system based on machine vision according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0031] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0032] An embodiment of a battery accessory quality detection method based on machine vision.
[0033] like Figure 1 As shown, the flow chart of the battery accessory quality detection method based on machine vision in an embodiment of the present invention includes the following steps:
[0034] S1: Obtain an image of the battery accessory to be detected and the positions of the four vertices of the image, and determine a preset window for each vertex.
[0035] In one embodiment, first, a three-dimensional camera is used to obtain images of standard battery accessories and images of battery accessories to be tested respectively; after image acquisition, the images are extracted in size of The positions of the four vertices in the standard battery accessory image and the image of the battery accessory to be detected are used to determine the preset windows of each vertex; wherein the four vertices are respectively located in different preset windows, and the size of the preset window can be set to 3×3 pixels, and of course can also be set according to actual conditions.
[0036] In another embodiment, the standard battery accessory image and the battery accessory image to be detected are subjected to grayscale processing and median filtering. By converting the color image into a grayscale image, the data volume is reduced and the processing efficiency is improved, while the color interference is reduced, making the key shape and depth information more prominent. The median filter removes noise, retains edge features, and improves image clarity and algorithm robustness.
[0037] S2: Determine the depth values of the pixels in four preset windows in the image; and construct a vertex matrix with all the depth values in each preset window.
[0038] In one embodiment, the depth values of the pixels in the four preset windows in the image are first determined, specifically: the three-dimensional structure of the surface of the battery accessory is captured by structured light scanning, and image data and corresponding depth values are generated. Then, for each preset window, the two-dimensional position and depth value of each pixel are extracted; the two-dimensional position of each pixel can be represented by its row and column coordinates in the image, for example, for the first pixel in the upper left corner of the preset window, its coordinates are represented as (0,0); after obtaining the position and depth values of all pixels in the preset window, the corresponding vertex matrix is constructed based on the position and depth values; the vertex matrix not only contains the depth value of each pixel, but also reflects its spatial position in the preset window, thereby providing the necessary basic data for subsequent matching and analysis. This method ensures the effective use of depth information in image processing and provides a more accurate basis for subsequent quality inspection.
[0039] For example, four vertex matrices in the standard battery accessory image and four vertex matrices in the battery accessory image to be detected are constructed respectively. Each vertex matrix represents the depth distribution of the pixel points in the preset window area; wherein the vertex matrix is constructed in such a way that for each pixel point in the preset window, the pixel points are arranged into a matrix according to the order of their two-dimensional coordinates in the image, such as row and column indices.
[0040] Assume that the depth value of a pixel point in a preset window area is , , , , , , , , ;in, Represents the depth value of the first row and first column of the pixel in the preset window area. According to the two-dimensional coordinate order of the pixel points in the image, the depth values of all the pixels in the preset window area form a vertex matrix. The vertex matrix corresponding to the preset window is .
[0041] S3: using an improved bipartite graph algorithm to match each vertex matrix of the battery accessory image to be detected with each standard vertex matrix of the standard battery accessory image to obtain four matrix pairs.
[0042] In one example, the bipartite graph algorithm may be the Hungarian algorithm or the KM algorithm.
[0043] For example, taking the Hungarian algorithm as an example, the improved Hungarian algorithm is used to match the four vertex matrices in the standard battery accessory image and the four vertex matrices in the battery accessory image to be detected to obtain four matrix pairs. Among them, the weights in the improved Hungarian algorithm are: the similarity between each standard vertex matrix and each vertex matrix, the similarity is positively correlated with the depth value of the pixel point in the corresponding standard vertex matrix, and negatively correlated with the size of the preset window and the depth value of the pixel point in the corresponding vertex matrix; the similarity is:
[0044] ;
[0045] In the formula, Represents the vertex matrix and the vertex matrix The similarity between Indicates the size of the preset window. Represented in the vertex matrix Middle Line The depth value of the column, Represented in the vertex matrix Middle Line The depth value of the column, represents an empirical constant, which can be taken as 1, and .
[0046] For example, assuming that the preset window size is 3×3 pixels, that is, =3, vertex matrix of the standard battery accessory image , the vertex matrix of the battery accessory image to be detected , Take the value as 1, substitute the data in the above vertex matrix into the above similarity formula, and you can get the vertex matrix and the vertex matrix Similarly, the similarity between other two matrix pairs can be calculated.
[0047] like Figure 2 As shown, a schematic diagram of a bipartite graph algorithm for matching vertex matrix pairs in an embodiment of the present invention includes: four vertex matrices in a standard battery accessory image , , , and the four vertex matrices in the battery accessory image to be detected , , , , Represents the vertex matrix and the vertex matrix The similarity between Represents the vertex matrix and the vertex matrix The similarity between Represents the vertex matrix and the vertex matrix The similarity between Represents the vertex matrix and the vertex matrix The similarity between .
[0048] The quality inspection of battery accessories also includes obtaining images of historical battery accessories with positional displacement, setting a plurality of preset windows of different sizes to match the images, calculating the accuracy of matching the images under preset windows of different sizes, and responding to the preset window with the highest accuracy as the optimal preset window; the above accuracy is:
[0049] ;
[0050] In the formula, Indicated in The matching accuracy under the preset window size, Indicated in The correct number of preset window sizes is matched. Indicated in The number of matching errors for a preset window size.
[0051] For example, the matching results of the battery accessory images with positional displacement in the historical battery accessories under different windows are collected, and the correct matching is represented as: Under a preset window size, the vertex matrix of the battery accessory image to be detected is successfully matched with the vertex matrix of the standard battery accessory image, that is, when the depth value difference of the corresponding pixel points in the two matrices is less than or equal to the set threshold, the match of the preset window is considered correct; when it is greater than the set threshold, the match of the preset window is considered incorrect.
[0052] Assume that the correct number of matches is obtained under the first window size of 3×3 pixels , the number of matching errors ; Match the correct number in the second window size of 5×5 pixels , the number of matching errors ; The correct number of matches in the third window size of 7×7 pixels , the number of matching errors ; Substitute the above formula to calculate the accuracy of each window:
[0053] ; ; ;
[0054] By comparing the accuracies of different window sizes, we can draw the following conclusions: the accuracy of the first window size is 72%, the second window size has the highest accuracy of 83.3%, and the accuracy of the third window size is 75%. In this example, the second window size has the highest accuracy and is therefore selected as the optimal preset window size.
[0055] S4: Based on the matrix, adjust the vertex position of the battery accessory image to be inspected to make it correspond to the vertex position of the standard image; when the difference in the depth value of the pixel point at the corresponding position does not exceed the set threshold, the battery accessory is judged to be normal, otherwise it is defective.
[0056] In one embodiment, based on the matrix pair, the positions of the vertices of the battery accessory image to be detected are adjusted to correspond to the positions of the vertices of the standard battery accessory image, specifically:
[0057] The translation matrix, scaling matrix and rotation matrix in the matrix pair are extracted, and the above matrices are used to represent the offset, scale difference and rotation angle of the image to be detected relative to the standard image. The translation matrix, scaling matrix and rotation matrix constitute an affine transformation matrix. The battery accessory image to be detected is translated, scaled and rotated by the affine transformation matrix, so that the position of each vertex of the battery accessory image to be detected corresponds to the position of each vertex of the standard battery accessory image, thereby ensuring the consistency of the geometric position of the image to be detected and the standard image, and providing a basis for subsequent quality inspection.
[0058] The above threshold value may be set to 0.3, and of course, it may be determined according to actual conditions.
[0059] Exemplarily, if the difference in depth value between the pixel points at corresponding positions in the standard battery accessory image and the rotated and adjusted battery accessory image to be detected is 0.1, which is less than the set threshold value of 0.3, then the image to be detected is determined to be of normal quality.
[0060] The solution of the present invention effectively solves the problem of inaccurate detection in the quality inspection of battery accessories. By obtaining the depth value of the image vertices and applying the improved bipartite graph algorithm to match the vertex matrix, the solution successfully overcomes the problem of inaccurate matching caused by position offset in the traditional method. The introduction of the depth value ensures the accurate detection of the three-dimensional shape of the battery accessories and significantly improves the detection accuracy. At the same time, the solution sets preset windows of various sizes and automatically selects the optimal window based on the matching accuracy, thereby enhancing the flexibility and applicability of the detection method. When adjusting the image position, by extracting the translation, scaling and rotation matrices and performing affine transformation, the accurate correspondence between the image to be detected and the standard image in geometric position is ensured. In addition, the solution also introduces graying and median filtering processing to reduce the influence of noise and image interference on the detection results. Overall, the above technical solution effectively solves the problems of insufficient accuracy, position matching error and noise processing in the traditional battery accessory detection method, optimizes the quality detection process, and improves reliability.
[0061] Battery accessories quality inspection system based on machine vision implementation example:
[0062] like Figure 3 As shown, a structural block diagram of a battery accessory quality detection system based on machine vision according to an embodiment of the present invention includes a processor and a memory.
[0063] The present invention also provides a battery accessory quality detection system based on machine vision. Figure 3 As shown, the system includes a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, the battery accessory quality detection method based on machine vision described above in the present invention is implemented.
[0064] The battery accessory quality inspection system based on machine vision also includes other components familiar to those skilled in the art, such as a communication interface, and their settings and functions are known in the art, so they will not be described in detail here.
[0065] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus or device. For example, a computer-readable storage medium may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc., or any other medium that can be used to store the required information and can be accessed by an application, a module, or both. Any such computer storage medium may be part of a device or accessible or connectable to a device. Any application or module described in the present invention may be implemented using computer-readable / executable instructions that may be stored or otherwise maintained by such a computer-readable medium.
[0066] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0067] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A battery accessory quality inspection method based on machine vision, characterized in that: include: Get the size The image of the battery accessory to be detected and the positions of the four vertices of the image are used to determine the preset windows of each vertex; wherein the four vertices are respectively located in different preset windows; Determine the depth values of the pixels in four preset windows in the image; form a vertex matrix with all the depth values in each preset window; Using an improved bipartite graph algorithm, each vertex matrix of the battery accessory image to be inspected is matched with each standard vertex matrix of the standard battery accessory image to obtain four matrix pairs; each standard vertex matrix is composed of the depth values of the pixel points in each preset window in the standard battery accessory image; Based on the matrix pair, the positions of the vertices of the battery accessory image to be detected are adjusted to correspond to the positions of the vertices of the standard battery accessory image, specifically: Extracting the translation matrix, scaling matrix and rotation matrix from the matrix pair, forming an affine transformation matrix from the translation matrix, scaling matrix and rotation matrix, and performing translation, scaling and rotation adjustment on the image of the battery component to be inspected by using the affine transformation matrix, so that the position of each vertex of the image of the battery component to be inspected corresponds to the position of each vertex of the standard battery component image; In response to the difference between the depth values of the pixels at the corresponding positions in the standard battery assembly image and the adjusted battery assembly image to be inspected being less than or equal to a set threshold, the battery assembly to be inspected is normal, otherwise, the battery assembly to be inspected is defective; The weight in the improved bipartite graph algorithm is: the similarity between each standard vertex matrix and each vertex matrix, and the similarity is: ; In the formula, Represents the vertex matrix and the vertex matrix The similarity between Indicates the size of the preset window. Represented in the vertex matrix Middle Line The depth value of the column, Represented in the vertex matrix Middle Line The depth value of the column, represents an empirical constant, and ; It also includes obtaining a historical image of a battery accessory having a positional offset, setting a plurality of preset windows of different sizes to match the image, calculating the accuracy of the image matching under the preset windows of different sizes, and responding that the preset window with the highest accuracy is the optimal preset window; The accuracy is: ; In the formula, Indicated in The matching accuracy under the preset window size, Indicated in The correct number of preset window sizes is matched. Indicated in The number of matching errors for a preset window size.
2. The battery accessory quality detection method based on machine vision according to claim 1, characterized in that: The bipartite graph algorithm is the Hungarian algorithm or the KM algorithm.
3. The battery accessory quality detection method based on machine vision according to claim 1, characterized in that: The image of the battery accessory to be inspected and the positions of the four vertices of the image are acquired through a three-dimensional stereo camera.
4. The battery accessory quality detection method based on machine vision according to claim 1, characterized in that: The method also includes grayscale processing and median filtering processing on the standard battery accessory image and the battery accessory image to be detected.
5. The battery accessories quality inspection system based on machine vision is characterized by: It includes a memory and a processor, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the battery accessory quality detection method based on machine vision as described in any one of claims 1 to 4 is implemented.
