A method for connector welding defect detection based on machine learning
By calculating the entropy change stability index, defect curvature extension coefficient and curvature grayscale mutual information in the connector welding defect image, the problem of low accuracy of connector welding defect detection in the prior art is solved, and the accurate detection of tin bead defects and short-circuit defects is achieved, and the accuracy and reliability of detection are improved.
Patent Information
- Application Number
- CN202410523641.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-28
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-04-28
AI Technical Summary
The model training set used for connector welding defect detection in the prior art has a large error, resulting in low accuracy in detecting connector welding defects. In particular, tin bead defects and short circuit defects are similar in appearance and difficult to accurately distinguish.
By obtaining the connector solder defect image, the entropy change stability index, defect curvature extension coefficient and curvature grayscale mutual information of the solder defect area are calculated, and these features are used to obtain the division threshold of defect types, thereby achieving accurate detection of tin bead defects and short-circuit defects.
It improves the accuracy of connector solder defect detection, can more effectively distinguish between tin bead defects and short-circuit defects, reduces errors, and improves the reliability of detection results.
Smart Images

Figure CN118552479B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image data processing, and in particular to a method for detecting connector welding defects based on machine learning. Background Art
[0002] In the electronics manufacturing industry, connectors are indispensable components of electronic devices. They are key components that ensure stable and reliable connections between electronic components. The welding quality of connectors plays a vital role in the performance and stability of products. As an important process in the connector assembly process, welding quality directly determines the performance and reliability of connectors. However, during the welding process, due to various reasons, such as improper welding parameters, welding material problems, equipment failure, etc., welding defects such as tin bead defects and short circuit defects may occur. These defects may not only affect the normal operation of the connector, but also cause equipment damage or safety hazards.
[0003] During the soldering process of connectors, tin bead defects and short circuit defects are two common soldering quality problems. Tin bead defects are usually caused by excessive soldering temperature, long soldering time or improper selection of soldering materials, which causes molten solder to form small ball-like structures where they should not appear. Short circuit defects may be caused by excessive molten solder during the soldering process, resulting in unnecessary connections between two solder joints that should be isolated. Both defects may lead to degradation of connector performance. Tin beads may cause poor connections, but they can usually be repaired by re-soldering or cleaning. The impact of tin beads on connectors may be relatively small; while short circuit defects weld two or more points that do not need to be connected together, causing the circuit to not work properly, which may cause the connector to fail or be damaged, and may even cause damage to the entire system. It usually requires a more complex repair process, and even requires the replacement of the connector or the redesign of the soldering process. Therefore, short circuit defects are usually more serious. Therefore, accurate detection of these two defects has become an urgent problem to be solved in the electronics manufacturing industry. However, due to the similarity of these two defects in appearance, the training set error of the connector soldering defect detection model is large, resulting in low accuracy in connector soldering defect detection. Summary of the invention
[0004] The present application provides a method for detecting connector welding defects based on machine learning to solve the problem of low detection accuracy of connector welding defects. The technical solution adopted is as follows:
[0005] An embodiment of the present application provides a method for detecting connector welding defects based on machine learning, the method comprising the following steps:
[0006] Acquire connector welding defect images;
[0007] Obtain the welding defect area of the connector welding defect area according to the edge features in the connector welding defect image; calculate the entropy change stability index of the welding defect area according to the local detail features of the welding defect area;
[0008] Obtain the curvature value of each pixel in the welding defect area, and obtain the defect curvature extension feature sequence of the welding defect area according to the curvature value of the pixel in the welding defect area; calculate the defect curvature extension coefficient of the welding defect area according to the defect curvature extension feature sequence of the welding defect area; calculate the welding defect feature change rate according to the grayscale change characteristics of the local area of each pixel in the welding defect area; calculate the curvature grayscale mutual information of the welding defect area according to the welding defect feature change rate, the defect curvature extension coefficient and the entropy change stability index of the welding defect area;
[0009] The threshold for dividing the defect types in the connector welding defect image is obtained according to the curvature grayscale mutual information of the welding area, and the defect detection result in the connector welding defect detection process is obtained based on the threshold for dividing the connector welding defect types.
[0010] Preferably, the method for obtaining the welding defect area of the connector welding defect area according to the edge features in the connector welding defect image is:
[0011] The connector welding defect image is taken as input, and all connected domains in the connector welding defect image are obtained using the edge detection algorithm and the connected domain analysis algorithm. The mean of the grayscale values of all pixels in the connected domain is calculated, and the connected domain corresponding to the maximum value of all the means is taken as the welding defect area.
[0012] Preferably, the method for calculating the entropy change stability index of the welding defect area according to the local detail features of the welding defect area is:
[0013] Taking the grayscale values of all pixels in the welding defect area as input, obtaining the grayscale co-occurrence matrix of the welding defect area at a preset angle, and calculating the entropy and contrast of each grayscale co-occurrence matrix respectively;
[0014] The cumulative result of the ratio of the contrast of the grayscale co-occurrence matrix corresponding to each preset angle in the welding defect area to the entropy of the grayscale co-occurrence matrix at all preset angles is used as the local change eigenvalue of the defect; the entropy change stability index of the welding defect area is calculated according to the local change eigenvalue of the defect in the welding defect area.
[0015] Preferably, the method for calculating the entropy change stability index of the welding defect area according to the defect local change characteristic value of the welding defect area is:
[0016] The entropy of the grayscale co-occurrence matrix corresponding to each preset angle in the welding defect area is taken as the numerator, the absolute value of the difference between the entropy of the grayscale co-occurrence matrix corresponding to each preset angle in the welding defect area and each other preset angle and 1 are taken as the denominator, and the cumulative result of the ratio of the numerator to the denominator at all preset angles and the defect local change characteristic value of the welding defect area are taken as the entropy change stability index of the welding defect area.
[0017] Preferably, the method of obtaining the curvature value of each pixel point in the welding defect area and obtaining the defect curvature extension feature sequence of the welding defect area according to the curvature value of the pixel point in the welding defect area is:
[0018] The coordinates of all pixels in the welding defect area are used as input to obtain the centroid of the welding defect area, and the characteristic division line segment of the welding defect area is obtained by connecting the centroid of the welding defect area with each edge pixel of the welding defect area. The sequence of all pixels on the characteristic division line segment in the order of the direction from the centroid to the edge pixel point is used as a characteristic division pixel point sequence of the welding defect area, and the Euclidean distance between each pixel in the welding defect area and each pixel in the characteristic division pixel point sequence is calculated;
[0019] For each pixel point in the welding defect area, the curvature of the circle with the centroid as the center and the Euclidean distance from the centroid to the pixel point as the radius is calculated as the curvature value of the pixel point, and the sequence composed of the curvature values of all pixels in the feature division pixel point sequence is taken as a defect curvature extension feature sequence of the welding defect area.
[0020] Preferably, the method for calculating the welding defect feature change rate according to the grayscale change characteristics of the local area of each pixel point in the welding defect area is:
[0021] A neighbor window of preset size is constructed with each pixel in the welding defect area as the center, and the absolute value of the difference between the grayscale value of each pixel in the welding defect area and each pixel in the neighbor window of the pixel is calculated, and the average of the accumulated results on each pixel neighbor window is calculated, and the average of the accumulated results on the welding defect area is taken as the welding defect characteristic change rate of the welding defect area.
[0022] Preferably, the method for calculating the defect curvature extension coefficient of the welding defect area according to the defect curvature extension feature sequence of the welding defect area is:
[0023] For each defect curvature extension feature sequence in the welding defect area, the difference between adjacent data in the defect curvature extension feature sequence is calculated, and the sum of all the differences is taken as the curvature extension change characteristic value of the defect curvature extension feature sequence; the sum of the curvature extension change characteristic values of all defect curvature extension feature sequences in the welding defect area is taken as the defect curvature extension coefficient of the welding defect area.
[0024] Preferably, the method for calculating the curvature grayscale mutual information of the welding defect area according to the welding defect characteristic change rate, defect curvature extension coefficient and entropy change stability index of the welding defect area is:
[0025] The product of the entropy change stability index of the welding defect area and the welding defect characteristic change rate of the welding defect area is taken as the numerator, the variance of any two defect curvature extension feature sequences in the welding defect area is calculated, the sum of the absolute value of the difference of the variance in the welding defect area and 1 is taken as the denominator, the ratio of the numerator to the denominator is taken as the first characteristic coefficient of the welding defect area, and the product of the first characteristic coefficient of the welding defect area and the defect curvature extension coefficient of the welding defect area is taken as the curvature grayscale mutual information of the welding defect area.
[0026] Preferably, the method for obtaining the threshold value for dividing defect types in the connector welding defect image according to the curvature grayscale mutual information of the welding area is:
[0027] A preset number of connector welding defect images are used as a training set, and a set consisting of the curvature grayscale mutual information of the welding defect areas in all the connector welding defect images in the training set is used as a connector welding defect type classification data set. The connector welding defect type classification data set is used as input, and a threshold segmentation algorithm is used to obtain the segmentation threshold of the connector welding defect type classification data set, and the segmentation threshold is used as the classification threshold of the defect types in the connector welding defect images.
[0028] Preferably, the method for obtaining the defect detection result in the connector welding defect detection process based on the classification threshold of the connector welding defect type is:
[0029] According to the comparison result of the curvature grayscale mutual information of the welding defect area in the connector welding defect image and the division threshold of the defect type in the connector welding defect image, the defect type of each connector welding defect image is marked, and the marked connector welding defect image is used as the updated training set. The convolutional neural network model is used for training, and the trained model is used as the connector welding defect detection model. The input is the obtained labeled connector welding defect image, and the connector welding defect detection model is used to obtain the detection result of the connector welding defect image.
[0030] The beneficial effects of the present application are: constructing an entropy change stability index by calculating the texture change differences in different directions of the welding defect area in the connector welding defect image, reflecting the grayscale distribution change characteristics of the welding defect area in the welding defect image through the entropy change stability index, calculating the defect curvature extension coefficient according to the curvature change characteristics of the pixel points from the centroid to the edge of the welding defect area in the welding defect image, calculating the curvature grayscale mutual information based on the entropy change stability index and the defect curvature extension coefficient, reflecting the degree of tin bead defect and short circuit defect characteristics of the welding defect area in the welding defect image through the curvature grayscale mutual information, avoiding the problem of inaccurate extraction of welding area defect characteristics, using the curvature grayscale mutual information to obtain the training set of the connector welding defect detection model, and using the connector welding defect detection model to obtain the detection results of the connector welding defects. The beneficial effects are that the tin bead defects and short circuit defects in the connector welding process are fully considered, a more accurate training set of the connector welding defect detection model is obtained, and the accuracy of connector welding defect detection using the connector welding defect detection model is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0032] Figure 1 A schematic diagram of a flow chart of a connector welding defect detection method based on machine learning provided in one embodiment of the present application;
[0033] Figure 2 A schematic diagram of an implementation process of obtaining detection results of connector welding defects provided in one embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0035] See also Figure 1 , which shows a flow chart of a connector welding defect detection method based on machine learning provided by an embodiment of the present application, the method comprising the following steps:
[0036] Step S001, obtaining a connector welding defect image.
[0037] On the connector welding production line, α (the empirical value is 300) samples with connector welding defects are obtained, and the samples are used as a training set for connector welding defect detection based on machine learning. A CCD industrial camera is used to obtain an image of the defective part of each sample in the training set, and the image is used as the original connector welding defect image of each sample; the original connector welding defect image of each sample is used as input, and a median filtering algorithm is used to obtain a preprocessed image of the original connector welding defect image of each sample, and the processed image is used as the connector welding defect image of each sample. The median filtering algorithm is a well-known technology, and the specific calculation process will not be repeated.
[0038] At this point, the connector welding defect image is acquired.
[0039] Step S002, obtaining a welding defect area according to the connector welding defect image; and calculating an entropy change stability index of the welding defect area according to texture features of the welding defect area.
[0040] Common defects in connector welding are tin bead defects and short circuit defects. Although these two defects have certain similarities in appearance, their degree of harm is different. How to accurately detect these two defects is of great significance for the cleaning and repair of connectors. The possibility of the defect being a tin bead defect or a short circuit defect in the welding defect image of each sample in the training set obtained by analyzing the grayscale distribution and pixel curvature characteristics of tin bead defects and short circuit defects is determined.
[0041] Specifically, taking the connector welding defect image of each sample as an example, the connector welding defect image is used as input, and the Canny edge detection algorithm and the connected domain analysis algorithm are used to obtain the connected domain in the connector welding defect image. The more solder materials there are at the welding position in the connector welding defect image, the larger the grayscale value of the pixel points in the corresponding area in the image. Therefore, if the location of the connected domain in the connector welding defect image is a tin ball defect and a short circuit defect, the grayscale value in the connected domain will be the largest compared to other areas. Therefore, the mean of the grayscale values of all pixels in each connected domain in the connector welding image is calculated, and the connected domain corresponding to the maximum value of all the means is taken as the welding defect area. The Canny edge detection algorithm and the connected domain analysis algorithm are well-known technologies, and the specific calculation process will not be repeated here.
[0042] Furthermore, since the tin bead is a sphere or a near-sphere, the grayscale value at the top of the tin bead is the highest, and the grayscale values around it decrease gradually. The tin bead has the geometric characteristics of a sphere, so the changes in grayscale values in different directions are consistent, and the grayscale changes on the tin bead are more drastic. A short circuit defect is usually an irregular shape with an uneven surface, so the grayscale changes of the short circuit defect are irregular and the grayscale changes are relatively gentle. Therefore, based on the above characteristics, a feature analysis is performed on the welding defect area in the connector welding defect image, and the analysis results reflect the degree to which the welding defect area in the connector welding defect image exhibits the characteristics of a tin bead defect and a short circuit defect.
[0043] Specifically, the grayscale values of all pixels in the welding defect area in the connector welding defect image are used as input to obtain the grayscale co-occurrence matrix of the welding defect area at 0°, 45°, 90° and 135°, and the entropy and contrast of the grayscale co-occurrence matrix of the welding defect area at 0°, 45°, 90° and 135° are calculated respectively. The calculation of the grayscale co-occurrence matrix and the entropy and contrast of the grayscale co-occurrence matrix are well-known technologies, and the specific process will not be repeated. The entropy change stability index of the welding defect area is calculated according to the difference in the grayscale change characteristics of the welding defect area. The specific calculation formula is as follows:
[0044]
[0045]
[0046] Where A represents the entropy change stability index of the welding defect area; B represents the local defect change characteristic value of the welding defect area; Ent i and Con i They represent the entropy and contrast of the gray-level co-occurrence matrix in the ith direction of the welding defect area; Ent j Represents the entropy of the gray level co-occurrence matrix in the jth direction of the welding defect area.
[0047] If the welding defect area is caused by solder bead defects, the gray value changes in the welding defect area d in all directions are consistent, so the entropy of the gray level co-occurrence matrix in the welding defect area d is small, that is, Ent i The value of is small, and the gray value difference in the welding defect area is large, then the contrast of the gray level co-occurrence matrix is also large, that is, Con i The value of is large, and the value of the local change characteristic value B of the calculated welding defect area is large; at the same time, the entropy of the gray level co-occurrence matrix in each direction in the welding defect area should be basically consistent, that is, the change rate between the entropy of the gray level co-occurrence matrix in each direction is small, and the calculated The larger the value of is, the larger the value of the entropy change stability index A of the calculated welding defect area is.
[0048] If the welding defect area is caused by a short circuit defect, the change of the gray value in the welding defect area is irregular, and the entropy of the gray level co-occurrence matrix in different directions in the welding defect area is large, that is, Ent i The larger the value of is, the smaller the gray value difference in the welding defect area is, and the smaller the contrast of the gray level co-occurrence matrix is, that is, Con i The smaller the value of is, the smaller the value of the local defect variation characteristic value of the calculated welding defect area is, and the greater the change in the entropy of the gray level co-occurrence matrix in each direction is, that is, The smaller the value of , the smaller the value of the calculated entropy change stability index A of the welding defect area.
[0049] At this point, the entropy change stability index of the welding defect area is obtained.
[0050] Step S003, obtaining the curvature of the pixel points in the welding defect area, and calculating the curvature grayscale mutual information of the welding defect area according to the entropy change stability index of the welding defect area and the curvature change characteristics of the welding defect area.
[0051] The entropy change stability index of the welding defect area is obtained by step S002. The entropy change stability index takes into account the distribution characteristics of the grayscale value. The significance of the tin bead defect and short circuit defect characteristics reflected by the welding defect area is analyzed by further combining the curvature change characteristics of the welding defect area. Since the tin bead defect characteristics are usually manifested as a high grayscale value at the top of the tin bead part, and the grayscale value around it gradually decreases, and the overall distribution is approximately circular. A line segment is obtained by connecting the center of the welding defect area with any point on the edge. From the outside to the inside, the curvature of each pixel point on the line segment gradually increases, and the grayscale value of each pixel point also gradually increases. The grayscale value difference on the tin bead is large, so the overall average grayscale change rate is large.
[0052] Furthermore, the characteristics of short-circuit defects are usually manifested as irregular shapes, which leads to a larger edge curvature of the short-circuit defect and a smaller and irregular curvature in the middle part; secondly, the grayscale value difference in the short-circuit defect is small, and the overall average grayscale change rate is also small. A line segment is obtained by connecting the center of the welding defect area with any point on the edge. On the line segment, all pixel points from the center of the welding defect area to the edge of the welding area meet the requirement that the curvature of the pixel points on the edge is larger, and the curvature of the remaining pixel points is smaller and irregular.
[0053] Specifically, all pixels in the welding defect area are used as input, and the coordinates of all pixels in the welding defect area are used as input to obtain the centroid of the welding defect area. The characteristic dividing line segment of the welding defect area is obtained by connecting the centroid of the welding defect area with each edge pixel in the welding defect area. The sequence of all pixels on the characteristic dividing line segment in the order of the direction from the centroid to the edge pixel is used as a characteristic dividing pixel sequence of the welding defect area, and the Euclidean distance between each pixel in the welding defect area and each pixel in the characteristic dividing pixel sequence is calculated. For each pixel in the welding defect area, the curvature of the circle obtained with the centroid as the center and the Euclidean distance between the centroid and the pixel as the radius is calculated as the curvature value of the pixel, and the sequence composed of the curvature values of all pixels in the characteristic dividing pixel sequence is used as a defect curvature extension characteristic sequence of the welding defect area. The specific process of obtaining the centroid and calculating the curvature is a well-known technology and will not be described in detail.
[0054] A δ×δ neighbor window is constructed with each pixel in the welding defect area as the center, where the empirical value of δ is 3. The absolute value of the difference between the grayscale value of each pixel in the welding defect area and each pixel in the pixel's neighbor window is calculated, and the average of the accumulated results on each pixel's neighbor window is taken as the welding defect feature change rate of the welding defect area.
[0055] Furthermore, the welding defect feature change rate is calculated according to the grayscale change characteristics of the local area of each pixel point in the welding defect area, the defect curvature extension coefficient of the welding defect area is calculated according to the defect curvature extension feature sequence of the welding defect area, and the curvature grayscale mutual information of the welding defect area is calculated based on the welding defect feature change rate, the defect curvature extension coefficient and the entropy change stability index. The specific calculation formula is as follows:
[0056]
[0057]
[0058]
[0059] Where, I represents the curvature grayscale mutual information of the welding defect area; A represents the entropy change stability index of the welding defect area; α represents the welding defect characteristic change rate of the welding defect area, g m represents the gray value of the mth pixel in the welding defect area, g m,n represents the gray value of the nth pixel in the neighboring window of the mth pixel in the welding defect area, N represents the number of pixels in the neighboring window of each pixel in the welding defect area, and M represents the number of pixels in the welding defect area; β represents the defect curvature extension coefficient of the welding defect area; and They represent the eth and e-1th data in the curvature extension feature sequence of the lth defect in the welding defect area respectively; E l represents the number of data in the lth defect curvature extension feature sequence in the welding defect area, P represents the number of defect curvature extension feature sequences in the welding defect area; Q p and Q k represent the curvature extension characteristic sequences of the pth and kth defects in the welding defect area, var(Q p ) and var(Q k ) represent Q p and Q k The variance of .
[0060] If the welding defect area is a tin bead defect, due to the large grayscale difference in the welding defect area, the greater the overall grayscale average change rate in the welding defect area, the greater the value of the calculated welding defect characteristic change rate α, and the curvature change reflected by the defect curvature extension feature sequence in the welding defect area is increasing, that is, the greater the calculated value of β, and because the shape of the tin bead defect is approximately spherical, the change of curvature in all directions in the welding area tends to be consistent, that is, |var(Q p )-var(Q k )| is larger, and when the welding area is a tin bead defect feature, the entropy change stability index A of the welding defect area calculated is larger, the curvature grayscale mutual information I of the welding defect area calculated is larger, and the significance of the tin bead defect feature of the welding defect area is higher.
[0061] If the welding defect area is a short circuit defect, since the grayscale distribution of the pixels in the welding defect area is irregular, but the grayscale change difference is small, the smaller the overall grayscale average change rate in the welding defect area is, the smaller the value of the calculated welding defect feature change rate α is; the curvature change reflected by the defect curvature extension feature sequence in the welding defect area is irregular, but the difference between the curvatures between the corresponding pixels of the elements in the defect curvature extension feature sequence is small, and the calculated β value is smaller; and since the curvature changes in different directions in the welding defect area are irregular, the calculated |var(Q p )-var(Q k The larger the value of )|, the smaller the value of the curvature grayscale mutual information I of the calculated welding defect area, and the higher the significance of the short-circuit defect characteristics exhibited by the welding defect area.
[0062] So far, the curvature grayscale mutual information of the welding defect area is obtained.
[0063] Step S004, obtaining the detection result of the connector welding defect according to the curvature grayscale mutual information of the welding defect area.
[0064] The set consisting of the curvature grayscale mutual information of the welding defect area in the connector welding defect image of all samples in the training set is used as the connector welding defect type classification data set, and the connector welding defect type classification data set is used as input. The Otsu threshold segmentation algorithm is used to obtain the segmentation threshold of the connector welding defect type classification data set, and the segmentation threshold is used as the classification threshold of the defect type in the connector welding defect image.
[0065] Furthermore, for each sample connector welding defect image in the training set, if the curvature grayscale mutual information of the welding defect area in the connector welding defect image is greater than or equal to the threshold for dividing the defect types in the connector welding defect image, the connector welding defect image is marked as a tin bead defect image; if the curvature grayscale mutual information of the welding defect area in the connector welding defect image is less than the threshold for dividing the defect types in the connector welding defect image, the connector welding defect image is marked as a short circuit defect image.
[0066] The marked result images of the welding defect areas in the connector welding defect images of all samples in the training set are used as the updated training set, and the convolutional neural network model is trained using the updated training set, wherein the loss function is the binary cross entropy loss, and the optimization algorithm is the Adam (Adaptive Moment Estimation) optimization algorithm. The specific training process of the convolutional neural network is a well-known technology and will not be repeated here. The trained model is used as a connector welding defect detection model, and the input is the obtained connector welding defect image without adding labels. The connector welding defect detection model is used to obtain the detection result of the connector welding defect, and the detection result includes that the connector welding defect is a tin bead defect and the connector welding defect is a short circuit defect. The specific implementation process of obtaining the detection result of the connector welding defect is as follows: Figure 2 shown.
[0067] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for detecting connector welding defects based on machine learning, characterized in that: The method comprises the following steps: Acquire connector welding defect images; Obtain the welding defect area of the connector welding defect area according to the edge features in the connector welding defect image; calculate the entropy change stability index of the welding defect area according to the local detail features of the welding defect area; Obtain the curvature value of each pixel in the welding defect area, and obtain the defect curvature extension feature sequence of the welding defect area according to the curvature value of the pixel in the welding defect area; calculate the defect curvature extension coefficient of the welding defect area according to the defect curvature extension feature sequence of the welding defect area; calculate the welding defect feature change rate according to the grayscale change characteristics of the local area of each pixel in the welding defect area; calculate the curvature grayscale mutual information of the welding defect area according to the welding defect feature change rate, the defect curvature extension coefficient and the entropy change stability index of the welding defect area; Obtaining a threshold for dividing defect types in the connector welding defect image according to the curvature grayscale mutual information of the welding area, and obtaining a classification detection result of defects in the connector welding defect detection process based on the threshold for dividing the connector welding defect types; The method for obtaining the entropy change stability index is: Taking the grayscale values of all pixels in the welding defect area as input, obtaining the grayscale co-occurrence matrix of the welding defect area at a preset angle, and calculating the entropy and contrast of each grayscale co-occurrence matrix respectively; The cumulative result of the ratio of the contrast of the gray level co-occurrence matrix corresponding to each preset angle in the welding defect area to the entropy of the gray level co-occurrence matrix at all preset angles is used as the defect local change characteristic value; the entropy change stability index of the welding defect area is calculated according to the defect local change characteristic value of the welding defect area; The method for obtaining the defect curvature extension feature sequence is: The coordinates of all pixels in the welding defect area are used as input to obtain the centroid of the welding defect area, and the characteristic division line segment of the welding defect area is obtained by connecting the centroid of the welding defect area with each edge pixel of the welding defect area. The sequence of all pixels on the characteristic division line segment in the order of the direction from the centroid to the edge pixel point is used as a characteristic division pixel point sequence of the welding defect area, and the Euclidean distance between each pixel in the welding defect area and each pixel in the characteristic division pixel point sequence is calculated; For each pixel point in the welding defect area, the curvature of the circle with the centroid as the center and the Euclidean distance from the centroid to the pixel point as the radius is calculated as the curvature value of the pixel point, and the sequence composed of the curvature values of all pixels in the feature division pixel point sequence is taken as a defect curvature extension feature sequence of the welding defect area.
2. The method for detecting connector welding defects based on machine learning according to claim 1, characterized in that: The method for obtaining the welding defect area of the connector welding defect area according to the edge features in the connector welding defect image is: The connector welding defect image is taken as input, and all connected domains in the connector welding defect image are obtained using the edge detection algorithm and the connected domain analysis algorithm. The mean of the grayscale values of all pixels in the connected domain is calculated, and the connected domain corresponding to the maximum value of all the means is taken as the welding defect area.
3. The method for detecting connector welding defects based on machine learning according to claim 1, characterized in that: The method for calculating the entropy change stability index of the welding defect area according to the defect local change characteristic value of the welding defect area is: The entropy of the grayscale co-occurrence matrix corresponding to each preset angle in the welding defect area is taken as the numerator, the absolute value of the difference between the entropy of the grayscale co-occurrence matrix corresponding to each preset angle in the welding defect area and each other preset angle and 1 are taken as the denominator, and the cumulative result of the ratio of the numerator to the denominator at all preset angles and the defect local change characteristic value of the welding defect area are taken as the entropy change stability index of the welding defect area.
4. The method for detecting connector welding defects based on machine learning according to claim 1, characterized in that: The method for calculating the welding defect feature change rate based on the grayscale change characteristics of the local area of each pixel point in the welding defect area is: A neighbor window of preset size is constructed with each pixel in the welding defect area as the center, and the absolute value of the difference between the grayscale value of each pixel in the welding defect area and each pixel in the neighbor window of the pixel is calculated, and the average of the accumulated results on each pixel neighbor window is calculated, and the average of the accumulated results on the welding defect area is taken as the welding defect characteristic change rate of the welding defect area.
5. The method for detecting connector welding defects based on machine learning according to claim 1, characterized in that: The method for calculating the defect curvature extension coefficient of the welding defect area according to the defect curvature extension feature sequence of the welding defect area is: For each defect curvature extension feature sequence in the welding defect area, the difference between adjacent data in the defect curvature extension feature sequence is calculated, and the sum of all the differences is taken as the curvature extension change characteristic value of the defect curvature extension feature sequence; the sum of the curvature extension change characteristic values of all defect curvature extension feature sequences in the welding defect area is taken as the defect curvature extension coefficient of the welding defect area.
6. The method for detecting connector welding defects based on machine learning according to claim 1, characterized in that: The method for calculating the curvature grayscale mutual information of the welding defect area according to the welding defect characteristic change rate, defect curvature extension coefficient and entropy change stability index of the welding defect area is: The product of the entropy change stability index of the welding defect area and the welding defect characteristic change rate of the welding defect area is taken as the numerator, the variance of any two defect curvature extension feature sequences in the welding defect area is calculated, the sum of the absolute value of the difference of the variance in the welding defect area and 1 is taken as the denominator, the ratio of the numerator to the denominator is taken as the first characteristic coefficient of the welding defect area, and the product of the first characteristic coefficient of the welding defect area and the defect curvature extension coefficient of the welding defect area is taken as the curvature grayscale mutual information of the welding defect area.
7. The method for detecting connector welding defects based on machine learning according to claim 1, characterized in that: The method for obtaining the threshold value for dividing defect types in the connector welding defect image according to the curvature grayscale mutual information of the welding area is: A preset number of connector welding defect images are used as a training set, and a set consisting of the curvature grayscale mutual information of the welding defect areas in all the connector welding defect images in the training set is used as a connector welding defect type classification data set. The connector welding defect type classification data set is used as input, and a threshold segmentation algorithm is used to obtain the segmentation threshold of the connector welding defect type classification data set, and the segmentation threshold is used as the classification threshold of the defect types in the connector welding defect images.
8. The method for detecting connector welding defects based on machine learning according to claim 1, characterized in that: The method for obtaining the defect detection result in the connector welding defect detection process based on the classification threshold of the connector welding defect type is: According to the comparison result of the curvature grayscale mutual information of the welding defect area in the connector welding defect image and the division threshold of the defect type in the connector welding defect image, the defect type of each connector welding defect image is marked, and the marked connector welding defect image is used as the updated training set. The convolutional neural network model is used for training, and the trained model is used as the connector welding defect detection model. The input is the obtained labeled connector welding defect image, and the connector welding defect detection model is used to obtain the detection result of the connector welding defect image.
Citation Information
Patent Citations
Pump body cold shut defect identification method and system based on image processing
CN114862862A
Bipolar power transistor surface breakdown defect detection method
CN115147414A