Battery tray welding defect detection method and device
Through the irradiation of multiple color light sources and image fusion, combined with edge detection and connectivity domain segmentation algorithm, the problem of welding defect detection in the prior art relying on subjective experience and environmental interference, achieving higher detection accuracy and efficiency.
Patent Information
- Application Number
- CN202411389458.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-02-28
AI Technical Summary
The prior art relies on the subjective experience of staff in battery tray welding defect detection, and the image recognition method fails to effectively consider environmental factors, resulting in inaccurate detection results.
The target battery tray image is obtained by irradiating multiple color light sources, and image fusion is performed to eliminate the influence of ambient light sources. Algorithms such as edge detection, connectivity domain segmentation and floating threshold are used to gradually screen out the final welding defect area.
It improves the accuracy of welding defect detection, reduces the workload of staff, and can more effectively identify and display welding defect areas.
Smart Images

Figure CN119540137A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field related to machine vision, and in particular to a method and device for detecting welding defects of a battery tray. Background Art
[0002] Battery tray welding defects can seriously affect the reliability and safety of the battery pack, so they need to be strictly controlled.
[0003] At present, welding defects of battery trays are usually determined by subjective observation by experienced staff. This method is more dependent on the experience level of the staff, has large fluctuations, and is not easy to control quality. Another method is to detect and report defects through image recognition, but the existing image recognition method is relatively simple and does not consider interference from environmental factors, which is prone to inaccurate detection results and cannot provide effective help to relevant staff. Summary of the invention
[0004] The purpose of the present invention is to solve at least one of the deficiencies of the prior art and to provide a method and device for detecting welding defects in a battery tray.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] Specifically, a battery tray welding defect detection method is proposed, including the following:
[0007] Illuminating the target battery tray by multiple color light sources and acquiring the target battery tray image under each color light, thereby obtaining a target battery tray image dataset;
[0008] Performing image fusion on the target battery tray image data set to obtain the optimal detection image, i.e., the first image;
[0009] Performing image preprocessing on the first image to obtain a grayscale image after tilt correction and noise removal is recorded as a second image;
[0010] Obtaining a third image by using an edge detection algorithm on the second image;
[0011] Find possible welding defect areas in the third image by connecting domain segmentation;
[0012] Based on the floating threshold method, the obvious non-welding defect area in the possible welding defect area is eliminated to obtain the rough welding defect area;
[0013] The roughness welding defect area is re-screened to remove the interference area to obtain the final welding defect area;
[0014] The final welding defect area is visualized for subsequent processing by staff.
[0015] Further, specifically, performing image fusion on the target battery tray image data set to obtain the optimal detection image, i.e., the first image, includes:
[0016] For any target battery tray image in the target battery tray image dataset, assume that the image is numbered i, convert it into grayscale to obtain its grayscale image, and calculate the average grayscale value of the whole image, which is ave_grey-i;
[0017] Traverse all the pixels of the grayscale image of i, and perform the grayscale value subtraction ave_grey-i operation on any pixel of the grayscale image of i. If there is a pixel with a negative grayscale value, its grayscale value is recorded as 0, and the grayscale image of i after the operation is obtained;
[0018] Repeat the above operation for all images in the target battery tray image dataset to obtain the grayscale image dataset after the operation;
[0019] For the same arbitrary pixel point of all images in the grayscale image data set after the operation, the average value of its grayscale value in each image in the grayscale image data set after the operation is taken as its final grayscale value, and then the optimal detection image, that is, the first image, is obtained.
[0020] Further, specifically, the preprocessing operation includes:
[0021] performing tilt correction and noise removal processing on the first image,
[0022] The tilt correction includes:
[0023] After performing tilt detection on the first image, a tilt angle is calculated, and finally the image is rotated according to the calculated tilt angle to complete the tilt correction;
[0024] De-noising The image after tilt correction is processed by a sophisticated noise reduction algorithm.
[0025] Further, specifically, obtaining a third image by using an edge detection algorithm on the second image includes:
[0026] The second image is processed by an edge detection algorithm based on a Sobel operator to obtain a third image.
[0027] Further, specifically, the possible welding defect area in the third image is found by connected domain segmentation, including:
[0028] Processing the third image by a preset binarization algorithm to obtain a binary image;
[0029] The connected image region obtained by processing the binary image based on the bwlabel function is the possible welding defect region.
[0030] Further, specifically, based on the floating threshold method, the obvious non-welding defect area in the possible welding defect area is eliminated to obtain the rough welding defect area, including:
[0031] Based on the regionprops function, the area of all possible welding defect regions is calculated to obtain the area of any possible welding defect region;
[0032] Calculate the average area of all possible welding defect areas and use it as a floating threshold;
[0033] The possible welding defect regions whose areas are smaller than the floating threshold are removed to obtain the remaining possible welding defect regions, which are the roughness welding defect regions.
[0034] Further, specifically, the roughness welding defect area is re-screened to remove the interference area to obtain the final welding defect area, including:
[0035] Calculating the average area of the remaining possible welding defect areas to obtain the average area of the remaining possible welding defect areas;
[0036] The average area of the remaining possible welding defect areas minus the error factor is used to obtain the discrimination value, wherein the error factor is a constant set artificially;
[0037] The possible welding defect areas whose areas are smaller than the discrimination value in the remaining possible welding defect areas are removed to obtain the final welding defect areas.
[0038] The present invention also provides a device for detecting welding defects of a battery tray, comprising the following:
[0039] An image data acquisition module is used to illuminate the target battery tray through multiple color light sources and respectively acquire the target battery tray image under each color light, thereby obtaining a target battery tray image data set;
[0040] An image fusion module, used for performing image fusion on a target battery tray image data set to obtain an optimal detection image, namely, a first image;
[0041] A preprocessing module, used for performing image preprocessing on the first image to obtain a grayscale image after tilt correction and noise removal as a second image;
[0042] An edge detection module, used for obtaining a third image by performing an edge detection algorithm on the second image;
[0043] A connected domain segmentation module, used to find possible welding defect areas in the third image by connected domain segmentation;
[0044] The first screening module is used to remove obvious non-welding defect areas in possible welding defect areas based on a floating threshold to obtain a rough welding defect area;
[0045] The second screening module is used to re-screen the roughness welding defect area and remove the interference area to obtain the final welding defect area;
[0046] The visualization and push module is used to visualize the final welding defect area for subsequent processing by staff.
[0047] The beneficial effects of the present invention are:
[0048] The present invention proposes a battery tray welding defect detection method and device, which first obtains a target detection image by irradiating with a combination of light sources of multiple colors, and then performs image fusion to obtain an optimal detection image, which can basically eliminate the influence of the light source in the environment; in addition, in the process of welding defect area detection, the interference area is screened out twice to reduce the influence of the interference welding defect area as much as possible, and the accurate welding defect area is found as much as possible, and then it is visualized to the staff, which greatly reduces the workload of the relevant staff and can greatly improve the accuracy of battery tray welding defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The above and other features of the present disclosure will become more apparent by describing in detail the embodiments shown in the accompanying drawings. The same reference numerals in the accompanying drawings of the present disclosure represent the same or similar elements. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure. For those skilled in the art, other accompanying drawings can be obtained based on these accompanying drawings without creative work. In the accompanying drawings:
[0050] Figure 1 Shown is a schematic diagram of a battery tray welding defect detection method of the present invention. DETAILED DESCRIPTION
[0051] The following will be combined with the embodiments and drawings to clearly and completely describe the concept, specific structure and technical effects of the present invention, so as to fully understand the purpose, scheme and effect of the present invention. It should be noted that the embodiments in this application and the features in the embodiments can be combined with each other without conflict. The same reference numerals used throughout the drawings indicate the same or similar parts.
[0052] Example 1, reference Figure 1 The present invention proposes a battery tray welding defect detection method, comprising the following steps:
[0053] Step 110, irradiating with multiple color light sources and acquiring the target battery tray image under each color light, thereby obtaining a target battery tray image data set;
[0054] Step 120, performing image fusion on the target battery tray image data set to obtain an optimal detection image, namely, a first image;
[0055] Step 130, performing image preprocessing on the first image to obtain a grayscale image after tilt correction and noise removal, which is recorded as a second image;
[0056] Step 140, obtaining a third image by using an edge detection algorithm on the second image;
[0057] Step 150, finding possible welding defect areas in the third image by connected domain segmentation;
[0058] Step 160: Eliminate obvious non-welding defect areas in possible welding defect areas based on a floating threshold to obtain a rough welding defect area;
[0059] Step 170, re-screening the roughness welding defect area to remove the interference area to obtain the final welding defect area;
[0060] Step 180: Visually display the final welding defect area to facilitate subsequent processing by staff.
[0061] In this embodiment 1, the target detection image is first obtained by illuminating with a combination of light sources of multiple colors, and then image fusion is performed to obtain the optimal detection image, which can basically eliminate the influence of the light source in the environment; in addition, during the welding defect area detection process, the interference area is screened out twice to minimize the influence of the interfering welding defect area, and the accurate welding defect area is found as much as possible, and then it is visualized to the staff, which greatly reduces the workload of the relevant staff and can greatly improve the accuracy of battery tray welding defect detection.
[0062] As a preferred embodiment of the present invention, specifically, performing image fusion on the target battery tray image data set to obtain the optimal detection image, i.e., the first image, includes:
[0063] For any target battery tray image in the target battery tray image dataset, assume that the image is numbered i, convert it into grayscale to obtain its grayscale image, and calculate the average grayscale value of the whole image, which is ave_grey-i;
[0064] Traverse all the pixels of the grayscale image of i, and perform the grayscale value subtraction ave_grey-i operation on any pixel of the grayscale image of i. If there is a pixel with a negative grayscale value, its grayscale value is recorded as 0, and the grayscale image of i after the operation is obtained;
[0065] Repeat the above operation for all images in the target battery tray image dataset to obtain the grayscale image dataset after the operation;
[0066] For the same arbitrary pixel point of all images in the grayscale image data set after the operation, the average value of its grayscale value in each image in the grayscale image data set after the operation is taken as its final grayscale value, and then the optimal detection image, that is, the first image, is obtained.
[0067] In the preferred real-time mode, the above-mentioned method is used to perform image fusion on the target battery tray image data set to obtain the optimal detection image, which can basically eliminate the influence of the light source in the environment.
[0068] As a preferred embodiment of the present invention, specifically, the pretreatment operation includes:
[0069] performing tilt correction and noise removal processing on the first image,
[0070] The tilt correction includes:
[0071] After performing tilt detection on the first image, a tilt angle is calculated, and finally the image is rotated according to the calculated tilt angle to complete the tilt correction;
[0072] De-noising The image after tilt correction is processed by a sophisticated noise reduction algorithm.
[0073] In this preferred embodiment, it is taken into consideration that the difference in shooting angles may cause the captured target battery tray image to be tilted, thereby resulting in low recognition efficiency and insufficient recognition accuracy, so corresponding processing is performed in the above manner.
[0074] The mature existing technologies that can be used in the process of tilt correction are introduced as follows:
[0075] 1. Tilt detection
[0076] Hough Transform: Find the main tilt direction by detecting the cumulative votes of straight edges in the image.
[0077] Radon Transform: Project the image to different angles and find the direction with the largest projection intensity, that is, the tilt direction.
[0078] Edge detection + straight line fitting: Use edge detection algorithms such as Canny to find the main edges in the image and fit a straight line to determine the tilt direction.
[0079] 2. Tilt angle calculation
[0080] Based on the line equation: Calculates the angle between the detected line and the horizontal direction.
[0081] Based on Radon transform: find the angle where the peak value in the Radon transform result is located, that is, the tilt angle.
[0082] 3. Image Rotation
[0083] Affine Transformation: Use a rotation matrix to rotate the image to a horizontal state.
[0084] Perspective Transformation: If the image has perspective distortion, it can be corrected using perspective transformation.
[0085] Specific steps example (using OpenCV): Based on Python
[0086] import cv2
[0087] import numpy as np
[0088] # Load the image
[0089] img = cv2.imread('image.jpg')
[0090] #1. Tilt detection
[0091] gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
[0092] edges=cv2.Canny(gray,50,150,apertureSize=3)
[0093] lines=cv2.HoughLinesP(edges,1,np.pi / 180,100,minLineLength=100,maxLineGap=10)
[0094] #2. Tilt angle calculation
[0095] if lines is not None:
[0096] for line in lines:
[0097] x1,y1,x2,y2=line[0]
[0098] angle=np.arctan2(y2-y1,x2-x1)*180 / np.pi
[0099] #...
[0100] else:
[0101] #Use other methods for tilt detection
[0102] #3. Image Rotation
[0103] M=cv2.getRotationMatrix2D((img.shape[1] / 2,img.shape[0] / 2),angle,1)
[0104] rotated_img=cv2.warpAffine(img,M,(img.shape[1],img.shape[0]))
[0105] # Display results
[0106] cv2.imshow("Rotated Image",rotated_img)
[0107] cv2.waitKey(0)
[0108] cv2.destroyAllWindows().
[0109] As a preferred embodiment of the present invention, specifically, obtaining a third image by using an edge detection algorithm on the second image includes:
[0110] The second image is processed by an edge detection algorithm based on a Sobel operator to obtain a third image.
[0111] In this preferred embodiment, accurate edge detection results can be obtained based on the classic Sobel operator in the above manner.
[0112] As a preferred embodiment of the present invention, specifically, finding possible welding defect areas in the third image by connected domain segmentation includes:
[0113] Processing the third image by a preset binarization algorithm to obtain a binary image;
[0114] The connected image region obtained by processing the binary image based on the bwlabel function is the possible welding defect region.
[0115] As a preferred embodiment of the present invention, specifically, based on the floating threshold method, the obvious non-welding defect area in the possible welding defect area is eliminated to obtain the rough welding defect area, including:
[0116] Based on the regionprops function, the area of all possible welding defect regions is calculated to obtain the area of any possible welding defect region;
[0117] Calculate the average area of all possible welding defect areas and use it as a floating threshold;
[0118] The possible welding defect regions whose areas are smaller than the floating threshold are removed to obtain the remaining possible welding defect regions, which are the roughness welding defect regions.
[0119] In this preferred embodiment, considering that there may be a group of noise points in the image that have not been de-noised by the filtering algorithm, the rough welding defect area is initially eliminated by the above method.
[0120] As a preferred embodiment of the present invention, specifically, the roughness welding defect area is re-screened to remove the interference area to obtain the final welding defect area, including:
[0121] Calculating the average area of the remaining possible welding defect areas to obtain the average area of the remaining possible welding defect areas;
[0122] The average area of the remaining possible welding defect areas minus the error factor is used to obtain the discrimination value, wherein the error factor is a constant set artificially;
[0123] The possible welding defect areas whose areas are smaller than the discrimination value in the remaining possible welding defect areas are removed to obtain the final welding defect areas.
[0124] In this preferred embodiment, considering that even if the noise point group that is not denoised by the filtering algorithm is removed by the above method, there may still be residual interference noise point groups, the above method is used for processing to ensure that the final welding defect area after processing is free of interference noise point groups as much as possible, thereby ensuring subsequent recognition efficiency and accuracy.
[0125] The present invention also provides a device for detecting welding defects of a battery tray, comprising the following:
[0126] An image data acquisition module is used to illuminate the target battery tray through multiple color light sources and respectively acquire the target battery tray image under each color light, thereby obtaining a target battery tray image data set;
[0127] An image fusion module, used for performing image fusion on a target battery tray image data set to obtain an optimal detection image, namely, a first image;
[0128] A preprocessing module, used for performing image preprocessing on the first image to obtain a grayscale image after tilt correction and noise removal as a second image;
[0129] An edge detection module, used for obtaining a third image by performing an edge detection algorithm on the second image;
[0130] A connected domain segmentation module, used to find possible welding defect areas in the third image by connected domain segmentation;
[0131] The first screening module is used to remove obvious non-welding defect areas in possible welding defect areas based on a floating threshold to obtain a rough welding defect area;
[0132] The second screening module is used to re-screen the roughness welding defect area and remove the interference area to obtain the final welding defect area;
[0133] The visualization and push module is used to visualize the final welding defect area for subsequent processing by staff.
[0134] In this embodiment 2, the following hardware preparations are also required:
[0135] *High-resolution industrial camera: captures clear images and identifies tiny defects. *Light source: provides sufficient and uniform light to avoid shadows and reflections. *Mechanical platform: fixes the camera and light source to ensure the stability of image acquisition. *Computer: processes image data and runs detection algorithms.
[0136] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of software functional modules.
[0137] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or system that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0138] Although the description of the present invention has been quite detailed and specifically describes several described embodiments, it is not intended to be limited to any of these details or embodiments or any particular embodiment, but should be regarded as providing a broad possible interpretation of these claims in view of the prior art by reference to the appended claims, thereby effectively covering the intended scope of the present invention. In addition, the above description of the present invention is based on the embodiments foreseeable by the inventor, and its purpose is to provide a useful description, and those non-substantial changes to the present invention that have not yet been foreseen may still represent equivalent changes to the present invention.
[0139] The above is only a preferred embodiment of the present invention. The present invention is not limited to the above implementation. As long as the technical effect of the present invention is achieved by the same means, it should belong to the protection scope of the present invention. Within the protection scope of the present invention, its technical scheme and / or implementation method can have various modifications and changes.
Claims
1. A battery tray welding defect detection method, characterized in that: Includes the following: Illuminating the target battery tray by multiple color light sources and acquiring the target battery tray image under each color light, thereby obtaining a target battery tray image dataset; Performing image fusion on the target battery tray image data set to obtain the optimal detection image, i.e., the first image; Performing image preprocessing on the first image to obtain a grayscale image after tilt correction and noise removal is recorded as a second image; Obtaining a third image by using an edge detection algorithm on the second image; Find possible welding defect areas in the third image by connecting domain segmentation; Based on the floating threshold method, the obvious non-welding defect area in the possible welding defect area is eliminated to obtain the rough welding defect area; The roughness welding defect area is re-screened to remove the interference area to obtain the final welding defect area; The final welding defect area is visualized for subsequent processing by staff.
2. A battery tray welding defect detection method according to claim 1, characterized in that: Specifically, the target battery tray image data set is subjected to image fusion to obtain the optimal detection image, i.e., the first image, including: For any target battery tray image in the target battery tray image dataset, assume that the image is numbered i, convert it into grayscale to obtain its grayscale image, and calculate the average grayscale value of the whole image, which is ave_grey-i; Traverse all the pixels of the grayscale image of i, and perform the grayscale value subtraction ave_grey-i operation on any pixel of the grayscale image of i. If there is a pixel with a negative grayscale value, its grayscale value is recorded as 0, and the grayscale image of i after the operation is obtained; Repeat the above operation for all images in the target battery tray image dataset to obtain the grayscale image dataset after the operation; For the same arbitrary pixel point of all images in the grayscale image data set after the operation, the average value of its grayscale value in each image in the grayscale image data set after the operation is taken as its final grayscale value, and then the optimal detection image, that is, the first image, is obtained.
3. A battery tray welding defect detection method according to claim 2, characterized in that: Specifically, the preprocessing operation includes: performing tilt correction and noise removal processing on the first image, The tilt correction includes: After performing tilt detection on the first image, a tilt angle is calculated, and finally the image is rotated according to the calculated tilt angle to complete the tilt correction; De-noising The image after tilt correction is processed by a sophisticated noise reduction algorithm.
4. A battery tray welding defect detection method according to claim 1, characterized in that: Specifically, obtaining a third image by using an edge detection algorithm on the second image includes: The second image is processed by an edge detection algorithm based on a Sobel operator to obtain a third image.
5. A battery tray welding defect detection method according to claim 1, characterized in that: Specifically, the possible welding defect areas in the third image are found by connecting domain segmentation, including: Processing the third image by a preset binarization algorithm to obtain a binary image; The connected image region obtained by processing the binary image based on the bwlabel function is the possible welding defect region.
6. A battery tray welding defect detection method according to claim 5, characterized in that: Specifically, based on the floating threshold method, the obvious non-welding defect area in the possible welding defect area is eliminated to obtain the rough welding defect area, including: Based on the regionprops function, the area of all possible welding defect regions is calculated to obtain the area of any possible welding defect region; Calculate the average area of all possible welding defect areas and use it as a floating threshold; The possible welding defect regions whose areas are smaller than the floating threshold are removed to obtain the remaining possible welding defect regions, which are the roughness welding defect regions.
7. A battery tray welding defect detection method according to claim 6, characterized in that: Specifically, the roughness welding defect area is re-screened to remove the interference area to obtain the final welding defect area, including: Calculating the average area of the remaining possible welding defect areas to obtain the average area of the remaining possible welding defect areas; The average area of the remaining possible welding defect areas minus the error factor is used to obtain the discrimination value, wherein the error factor is a constant set artificially; The possible welding defect areas whose areas are smaller than the discrimination value in the remaining possible welding defect areas are removed to obtain the final welding defect areas.
8. A device for detecting welding defects of a battery tray, characterized in that: Includes the following: An image data acquisition module is used to illuminate the target battery tray through multiple color light sources and respectively acquire the target battery tray image under each color light, thereby obtaining a target battery tray image data set; An image fusion module, used for performing image fusion on a target battery tray image data set to obtain an optimal detection image, namely, a first image; A preprocessing module, used for performing image preprocessing on the first image to obtain a grayscale image after tilt correction and noise removal as a second image; An edge detection module, used for obtaining a third image by performing an edge detection algorithm on the second image; A connected domain segmentation module, used to find possible welding defect areas in the third image by connected domain segmentation; The first screening module is used to remove obvious non-welding defect areas in possible welding defect areas based on a floating threshold to obtain a rough welding defect area; The second screening module is used to re-screen the roughness welding defect area and remove the interference area to obtain the final welding defect area; The visualization and push module is used to visualize the final welding defect area for subsequent processing by staff.