A method for visual defect detection of automobile connectors

By performing edge detection and merging processing on the surface image of the automobile connector, screening the air-defect area with chain code values ​​and bending characteristics, and performing merging operations, the problem of low accuracy in extracting air-delayed areas in the prior art is solved, and higher detection accuracy is achieved.

CN118587187BActive Publication Date: 2025-03-11DONGGUAN JINLING ELECTRONICS CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410740175.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2025-03-11
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

The existing edge detection algorithm has the problem of low accuracy when extracting the trapped air areas of the car connector, which leads to the inability to completely extract the trapped air defect areas, affecting the accuracy of the detection results.

Method used

By acquiring the surface image of the car connector, performing edge detection to screen the initial edge line, and combining the endpoint position and grayscale similarity of the initial edge line, a suspected defect communication domain is obtained. Then, based on the discretosis degree and bending characteristics of the chain code value of the sub-edge curve, the air-drown defect area is screened out, and the spatial position distribution and defect evaluation value of the sub-edge curves of adjacent air-drown defect areas are combined to improve the accuracy of the extraction results.

Benefits of technology

Improves the accuracy of extraction of air defect areas of the automobile connector, ensuring the integrity and reliability of the test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587187B_ABST
    Figure CN118587187B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of defect detection technology, and specifically to a method for visual defect detection of automotive connectors. The method includes: obtaining a surface image of an automotive connector to be detected; performing edge detection on the surface image to screen initial edge lines; combining the positions between the endpoints of different initial edge lines and the similarity of grayscale, merging different initial edge lines to obtain a suspected defect connected domain; obtaining a defect evaluation value of the suspected defect connected domain based on the difference in the degree of discreteness of the overall chain code value of each sub-edge curve and the edge line to which it belongs, and judging whether the suspected defect connected domain is an air-trapped defect area based on the defect evaluation value; fusing the relative position distribution and defect evaluation values ​​of the sub-edge curves corresponding to different air-trapped defect areas in space, merging the corresponding air-trapped defect areas, and obtaining a target defect area. The present invention improves the accuracy of defect area extraction results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of defect detection, and in particular to a method for visual defect detection of automobile connectors. Background Art

[0002] The automotive connector is a functional component in the car. It builds a bridge of communication between blocked or isolated circuits in the circuit, so that the current can flow and the circuit's predetermined function can be realized. It is the basis for the stable operation of the car. People have higher and higher requirements for automobile safety, environmental protection, comfort and intelligence, and the application of automotive electronic products is also increasing, which has increased the demand for automotive connectors. Therefore, it is necessary to inspect the quality of automotive connectors.

[0003] During the production process of automobile connectors, if the gas in the mold cavity cannot be discharged from the injection mold in time or cannot be discharged from the injection mold, the rubber material will be prevented from continuing to fill, resulting in material shortage, burning, etc., which will cause air trapped defects and affect the quality of the product. Therefore, after the production of automobile connectors is completed, they are generally tested for air trapped defects. The existing method often uses edge detection algorithms to determine the closed interval to detect the visual defect. However, in complex situations, using this method may produce some edge curves that should be connected but are disconnected. This makes it impossible for this method to accurately extract the air trapped defect area, affecting the accuracy of the automobile connector defect detection results. Summary of the invention

[0004] In order to solve the problem that the existing edge detection algorithm has low accuracy when extracting the trapped air area of ​​the automobile connector, the purpose of the present invention is to provide a method for visual defect detection of automobile connectors. The technical solution adopted is as follows:

[0005] The present invention provides a method for visual defect detection of automobile connectors, the method comprising the following steps:

[0006] Acquire a surface image of an automobile connector to be inspected;

[0007] Performing edge detection on the surface image to screen initial edge lines; combining the positions of the endpoints of different initial edge lines and the similarity of grayscale to obtain a suspected defect connected domain;

[0008] According to the difference in the discreteness of the overall chain code value between each sub-edge curve and the edge line where it is located, the defect evaluation value of the suspected defect connected domain is obtained, and whether the suspected defect connected domain is a gas trapped defect area is determined based on the defect evaluation value; the sub-edge curve is obtained by dividing the edge line of the suspected defect connected domain based on the bending characteristics at different positions on the edge line of the suspected defect connected domain;

[0009] The relative position distribution of the sub-edge curves corresponding to different air-trapping defect regions in space and the defect evaluation values ​​are integrated, and the corresponding air-trapping defect regions are merged to obtain the target defect region.

[0010] Preferably, performing edge detection on the surface image to screen initial edge lines includes:

[0011] Edge detection is performed on the surface image, and an edge line including two endpoints is recorded as an initial edge line.

[0012] Preferably, combining the positions of the endpoints of different initial edge lines and the similarity of the grayscale to merge the different initial edge lines to obtain the suspected defect connected domain includes:

[0013] The endpoints in the neighborhood of the candidate endpoints are used as the endpoints to be combined of the candidate endpoints; combining the similarity of the fitting slope and gray value between the candidate endpoint and each endpoint to be combined, the candidate endpoint is connected with its corresponding endpoint to be combined to obtain a closed connected domain as the suspected defect connected domain;

[0014] The fitting slope is determined based on the position of the pixel points in the neighborhood of the candidate pixel point that are on the same initial edge line as the candidate pixel point;

[0015] The candidate endpoint is any endpoint on any initial edge line.

[0016] Preferably, the combining of the similarity of the fitting slope and the gray value between the candidate endpoint and each endpoint to be combined, connecting the candidate endpoint with its corresponding endpoint to be combined to obtain a closed connected domain, comprises:

[0017] Connect the candidate endpoints and the endpoints to be combined with the largest similarity to their feature vectors by straight lines to obtain a closed connected domain;

[0018] The feature vector is composed of the fitting slope and the gray value.

[0019] Preferably, the acquisition of the sub-edge curve includes:

[0020] Any pixel point on the edge line of the suspected defect connected domain is recorded as a point to be analyzed; on the edge line of the suspected defect connected domain, the normalized result of the difference between the fitting slopes of two pixel points adjacent to the point to be analyzed is used as the bending parameter of the point to be analyzed. If the bending parameter is greater than the preset bending threshold, the point to be analyzed is used as a segmentation point, the edge line of the suspected defect connected domain is segmented, and each curve obtained after the segmentation is completed is used as a sub-edge curve.

[0021] Preferably, obtaining the defect evaluation value of the suspected defect connected domain according to the difference in the discrete degree between each sub-edge curve and the overall chain code value of the edge line where it is located includes:

[0022] The edge line of any suspected defect connected domain is recorded as a candidate suspected defect edge;

[0023] Calculate the discrete degree of the chain code value of all pixels on each sub-edge curve on the candidate suspected defect edge and the discrete degree of the chain code value of all pixels on the candidate suspected defect edge; record the discrete degree of the chain code value of all pixels on each characteristic curve as the discrete degree of each characteristic curve, wherein the characteristic curve includes the candidate suspected defect edge and each sub-edge curve on the candidate suspected defect edge;

[0024] Dividing each sub-edge curve on the candidate suspected defect edge into a quasi-ellipse edge segment and a straight line edge segment based on the discrete degree;

[0025] The defect evaluation value of the corresponding suspected defect connected domain is obtained by combining the difference between the discrete degree of each sub-edge curve on the candidate suspected defect edge and the discrete degree of the candidate suspected defect edge, the discrete degree of the ellipse-like edge segment and the discrete degree of the straight edge segment. The difference in the discrete degree and the discrete degree of the straight edge segment are both positively correlated with the defect evaluation value, and the discrete degree of the ellipse-like edge segment is negatively correlated with the defect evaluation value.

[0026] Preferably, dividing each sub-edge curve on the candidate suspected defect edge into ellipse-like edge segments and straight line edge segments based on the discrete degree includes:

[0027] The sub-edge curve with a discrete degree greater than that of the candidate suspected defect edge is regarded as a quasi-ellipse edge segment, and the sub-edge curve with a discrete degree less than or equal to that of the candidate suspected defect edge is regarded as a straight line edge segment.

[0028] Preferably, judging whether the suspected defect connected domain is a gas-trapped defect region based on the defect evaluation value includes:

[0029] The suspected defect connected area with a defect evaluation value greater than a preset evaluation threshold is determined as the air trapped defect area.

[0030] Preferably, the merging of the relative position distribution of the sub-edge curves corresponding to different air-trapping defect regions in space and the defect evaluation values, and the merging operation of the corresponding air-trapping defect regions, comprises:

[0031] Any trapped gas defect region is recorded as the defect region to be analyzed, and other trapped gas defect regions that are closest to the defect region to be analyzed are recorded as the nearest neighbor defect regions of the defect region to be analyzed;

[0032] The two sub-edge curves with the closest distance among all the sub-edge curves corresponding to the defect area to be analyzed and all the sub-edge curves corresponding to the nearest neighbor defect area are recorded as the first characteristic curve and the second characteristic curve respectively;

[0033] Constructing pixel pairs based on the pixel points on the first characteristic curve and the second characteristic curve, wherein each pixel pair includes a pixel point on the first characteristic curve and a pixel point on the second characteristic curve; recording the distance between the two pixel points in each pixel pair as the distance value of each pixel pair;

[0034] The merging index of the defect area to be analyzed and the nearest neighbor defect area is obtained according to the similarity between the distance values ​​of adjacent pixel pairs, the difference in the fitting slopes of the two pixel points in each pixel pair, and the difference in the defect evaluation value between the defect area to be analyzed and the nearest neighbor defect area;

[0035] Whether to merge the defect area to be analyzed and the nearest neighbor defect area is determined based on the merging index.

[0036] Preferably, judging whether to merge the defect region to be analyzed and the nearest neighbor defect region based on the merge index includes:

[0037] If the merging index is greater than the preset merging threshold, the defect area to be analyzed and the nearest neighbor defect area are merged;

[0038] If the merging index is less than or equal to the preset merging threshold, the defect area to be analyzed and the nearest neighbor defect area are not merged.

[0039] The present invention has at least the following beneficial effects:

[0040] The present invention takes into account that when an edge detection algorithm is used to detect an air-trapping defect area in a surface image of an automobile connector, the edge lines of the detected air-trapping defect area may be broken, that is, the detected edge lines cannot form a complete connected domain, so the air-trapping defect area cannot be completely extracted. The present invention further analyzes the positions and grayscale similarities between the endpoints of different initial edge lines on the basis of edge detection of the surface image of the automobile connector to be detected, that is, in combination with the feature similarities of the endpoints of different broken edge lines, several initial edge line endpoints are connected to obtain a suspected defect connected domain, and then, in combination with the elliptical or elongated straight line features of the air-trapping defect area on the automobile connector, the air-trapping defect area is screened out from the suspected defect connected domain. Since the adjacent air-trapping defect areas screened out may belong to the same air-trapping defect area but are divided, in order to improve the accuracy of the air-trapping defect area extraction result, the relative position distribution of the sub-edge curves corresponding to different air-trapping defect areas in space and the defect evaluation values ​​are combined to merge the different air-trapping defect areas, thereby improving the accuracy of the air-trapping defect area extraction result. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0042] Figure 1 A flowchart of a method for visual defect detection of automotive connectors provided by an embodiment of the present invention;

[0043] Figure 2 A flow chart of a method for obtaining a gas-trapped defect region;

[0044] Figure 3 is a schematic diagram of the target defect area;

[0045] Figure 4 The figure is a structural block diagram of a visual defect detection system for automotive connectors. DETAILED DESCRIPTION

[0046] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined purpose of the invention, a method for visual defect detection of automotive connectors proposed in accordance with the present invention is described in detail below in conjunction with the accompanying drawings and preferred embodiments.

[0047] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0048] The specific scheme of the automotive connector visual defect detection method provided by the present invention is described in detail below with reference to the accompanying drawings.

[0049] An embodiment of a method for visual defect detection of automobile connectors:

[0050] The specific scenario targeted by this embodiment is: after the production of the automobile connector is completed, it needs to be inspected for defects. This embodiment will collect the surface image of the automobile connector and accurately extract the trapped air defect area based on the features presented in the surface image of the automobile connector.

[0051] This embodiment proposes a method for visual defect detection of automotive connectors. Figure 1 As shown, a method for visual defect detection of automobile connectors in this embodiment includes the following steps:

[0052] Step S1, obtaining a surface image of a vehicle connector to be inspected.

[0053] First, a camera is used to capture an RGB image of the surface of the automobile connector to be inspected, and then the collected RGB image of the surface of the automobile connector to be inspected is grayed and denoised to eliminate noise interference, and the processed image is recorded as the surface image of the automobile connector to be inspected. Graying and denoising of the image are prior arts and will not be described in detail here.

[0054] At this point, the surface image of the automobile connector to be inspected is obtained.

[0055] Step S2, edge detection is performed on the surface image to screen initial edge lines; based on the positions of the endpoints of different initial edge lines and the similarity of grayscale, different initial edge lines are merged to obtain a suspected defect connected domain.

[0056] The main reason for the air entrapment defect in automotive connectors is that during the filling process of the injection molded parts, air is pushed into the melt, causing air bubbles to be trapped in the plastic parts. Specifically, it will appear as an elliptical gas bubble. At the same time, due to the different air pressures inside and outside, a long and thin straight bubble may be squeezed out.

[0057] In this embodiment, the Canny edge detection algorithm is used to perform edge detection on the surface image of the automobile connector to be inspected, and multiple edge lines are obtained. Since air entrapment defects generally appear as elongated straight lines or elliptical shapes, in complex actual situations, it is impossible to segment the complete edge curve when performing edge detection on the surface image of the automobile connector to be inspected. Many edge curves will be broken or missing, resulting in the air entrapment area being unable to be completely and accurately extracted. Therefore, this embodiment first screens these edge lines, and then determines whether the broken edge curves belong to the same edge curve based on the position between the endpoints of the screened edge lines and the similarity of the grayscale values, and then obtains the corresponding connected domain. The Canny edge detection algorithm is a prior art and will not be described in detail here.

[0058] Specifically, an edge line with two endpoints is recorded as an initial edge line, that is, a plurality of initial edge lines are obtained.

[0059] Next, we will take any endpoint on any initial edge line as an example for analysis. The other endpoints on the edge line and all endpoints on other initial edge lines can be processed using the method provided in this embodiment. Any endpoint on any initial edge line is recorded as a candidate endpoint, and the least squares method is performed on these pixels based on the pixel points on the same initial edge line as the candidate pixel point and the position of the candidate pixel point in the preset first neighborhood of the candidate pixel point to obtain the fitting slope of the candidate pixel point. Among them, the preset first neighborhood of the candidate pixel point is to construct a window of a preset first size with the candidate pixel point as the center, and the area in the window except the location of the candidate pixel point is used as the preset first neighborhood of the candidate pixel point. The preset first size in this embodiment is 7×7. In specific applications, the implementer can set it according to the specific situation.

[0060] Since the pixels on the edge of the same trapped air defect present similar features in the image, the similarity of the shape features and grayscale features between the candidate endpoints and the endpoints in their neighborhood is combined to determine whether the corresponding endpoints can be connected, and then the endpoints that can be connected are connected to obtain a closed area. Specifically, the endpoints in the preset second neighborhood of the candidate endpoint are used as the endpoints to be combined of the candidate endpoint. The preset second neighborhood of the candidate pixel point is centered on the candidate pixel point, and a window of the preset second size is constructed. The area in the window except the location of the candidate pixel point is used as the preset second neighborhood of the candidate pixel point. The preset second size in this embodiment is 21×21. In specific applications, the implementer can set it according to the specific situation. The fitting slope and grayscale value of each endpoint constitute the feature vector of each pixel point, that is, each endpoint corresponds to a feature vector. The similarity between the feature vector of the candidate endpoint and each of its endpoints to be combined is calculated respectively, and the candidate endpoint and the endpoint to be combined with the greatest similarity to its feature vector are connected in a straight line, and the obtained closed connected domain is used as the suspected defect connected domain.

[0061] Among them, the similarity between two feature vectors is expressed by cosine similarity, and can also be expressed by the negative correlation normalized result of Manhattan distance, the negative correlation normalized result of Minkowski distance, the negative correlation normalized result of dynamic time warping distance, or by Jaccard similarity coefficient, etc., among which, the larger the cosine similarity, the greater the similarity between the two feature vectors, which means that the two feature vectors are more similar; the smaller the Manhattan distance, the greater the similarity between the two feature vectors, which means that the two feature vectors are more similar; the smaller the Minkowski distance, the greater the similarity between the two feature vectors, which means that the two feature vectors are more similar; the smaller the dynamic time warping distance, the greater the similarity between the two feature vectors, which means that the two feature vectors are more similar; the larger the Jaccard similarity coefficient, the greater the similarity between the two feature vectors, which means that the two feature vectors are more similar.

[0062] In this embodiment, cosine similarity is used to characterize the similarity between two feature vectors, that is, the cosine similarity between the two feature vectors is taken as the similarity between the two feature vectors.

[0063] So far, multiple suspected defect connected domains have been obtained.

[0064] Step S3, obtaining the defect evaluation value of the suspected defect connected domain according to the difference in the discrete degree of the overall chain code value between each sub-edge curve and the edge line where it is located, and judging whether the suspected defect connected domain is an air trapped defect area based on the defect evaluation value; the sub-edge curve is obtained by dividing the edge line of the suspected defect connected domain based on the bending features at different positions on the edge line of the suspected defect connected domain.

[0065] The reason for the trapped air defect in the automotive connector is that when the injection molded part is filled, the air is pushed into the melt, which is specifically manifested as elliptical bubbles on the surface, and a small segment of thin bubbles may extend around it, and the grayscale value inside it varies greatly and unevenly. Therefore, if the suspected defect connected domain shows that there may be individual turning points on the entire smooth edge curve, and after the turning point, there is a thin straight line segment area, and the grayscale value in the internal pixel neighborhood varies greatly and irregularly, it means that the suspected defect connected domain may belong to the trapped air defect area. Based on this, the trapped air area will be screened according to the difference in the discrete degree of the overall chain code value between each sub-edge curve and the edge line where it is located.

[0066] Step S31 , dividing the edge line of the suspected defect connected domain based on the bending features at different positions on the edge line of the suspected defect connected domain to obtain sub-edge curves.

[0067] When an air-trapped defect occurs in an automotive connector, elliptical gas bubbles or long, thin, linear bubbles are formed. Therefore, these two situations are first distinguished to improve the accuracy of subsequent extraction results of the air-trapped defect area.

[0068] Specifically, any pixel point on the edge line of the suspected defect connected domain is recorded as a point to be analyzed; on the edge line of the suspected defect connected domain, the normalized result of the difference between the fitting slopes of two pixel points adjacent to the point to be analyzed is used as the bending parameter of the point to be analyzed, and if the bending parameter is greater than a preset bending threshold, the point to be analyzed is used as a segmentation point. The normalization can be processed by the maximum and minimum value normalization method, which is a prior art and will not be described in detail here.

[0069] By using the above method, all pixel points on the edge line of the suspected defect connected domain are analyzed respectively to obtain multiple segmentation points, and the edge line of the suspected defect connected domain is segmented using the segmentation points, and each curve obtained after the segmentation is completed is used as a sub-edge curve.

[0070] Among them, the difference in the fitting slopes can be characterized by the absolute value of the difference between the two fitting slopes, or by the square of the difference between the two fitting slopes, etc. This embodiment uses the absolute value of the difference between the two fitting slopes to characterize their difference, that is, the absolute value of the difference between the two fitting slopes is taken as the difference between the two fitting slopes.

[0071] At this point, the above method is used to divide the edge line of each suspected defect connected domain into multiple sub-edge curves.

[0072] Step S32, obtaining a defect evaluation value of the suspected defect connected domain according to the difference in the discrete degree between each sub-edge curve and the overall chain code value of the edge line where it is located, and judging whether the suspected defect connected domain is a gas trapped defect area based on the defect evaluation value.

[0073] The edge line of any suspected defect connected domain is recorded as a candidate suspected defect edge; the discrete degree of the 8-chain code value of all pixels on each sub-edge curve on the candidate suspected defect edge and the discrete degree of the 8-chain code value of all pixels on the candidate suspected defect edge are calculated respectively.

[0074] The degree of dispersion of 8-chain code values ​​can be characterized by indicators such as variance, standard deviation, range, and coefficient of variation. The larger the variance of the 8-chain code value, the greater the dispersion of the 8-chain code value; the larger the standard deviation of the 8-chain code value, the greater the dispersion of the 8-chain code value; the larger the range of the 8-chain code value, the wider the data range of the 8-chain code value, that is, the greater the dispersion of the 8-chain code value; the larger the coefficient of variation, the higher the relative dispersion of the 8-chain code value.

[0075] In this embodiment, the variance of the 8-chain code value is used to characterize the discreteness of the 8-chain code value, that is, the variance of the 8-chain code value is used as its corresponding discreteness.

[0076] Since trapped air defects generally appear in the shape of an elongated straight line or an elliptical shape, the curvature of the pixel positions on the edge line of the straight trapped air defect area is not large, while the curvature of the pixel positions on the edge line of the elliptical trapped air defect area is large. Therefore, the sub-edge curve with a degree of discreteness greater than the discreteness of the candidate suspected defect edge is taken as a quasi-elliptical edge segment, and the sub-edge curve with a degree of discreteness less than or equal to the discreteness of the candidate suspected defect edge is taken as a straight edge segment. That is, the sub-edge curves on the candidate suspected defect edge are divided into two categories based on the degree of discreteness, namely, quasi-elliptical edge segments and straight edge segments.

[0077] The discrete degree of the 8-chain code values ​​of all pixels on each characteristic curve is recorded as the discrete degree of each characteristic curve, and the characteristic curve includes the candidate suspected defect edge and each sub-edge curve on the candidate suspected defect edge.

[0078] The defect evaluation value of the corresponding suspected defect connected domain is obtained by combining the difference between the discrete degree of each sub-edge curve on the candidate suspected defect edge and the discrete degree of the candidate suspected defect edge, the discrete degree of the ellipse-like edge segment and the discrete degree of the straight edge segment. The difference in the discrete degree and the discrete degree of the straight edge segment are both positively correlated with the defect evaluation value, and the discrete degree of the ellipse-like edge segment is negatively correlated with the defect evaluation value.

[0079] Among them, a positive correlation means that the dependent variable will increase as the independent variable increases, and the dependent variable will decrease as the independent variable decreases. The specific relationship can be a multiplication relationship, an addition relationship, or the power of an exponential function. A negative correlation means that the dependent variable will decrease as the independent variable increases, and the dependent variable will increase as the independent variable decreases. It can be a subtraction relationship, a division relationship, etc., which is determined by actual applications. The difference in the degree of dispersion can be represented by the absolute value of the difference between the two degrees of dispersion, or by the square of the difference between the two degrees of dispersion, etc.

[0080] In this embodiment, a specific calculation formula for the defect evaluation value is given, and the defect evaluation value of the i-th suspected defect connected domain can be expressed as:

[0081]

[0082] Among them, P i represents the defect evaluation value of the ith suspected defect connected domain, C represents the number of straight edge segments of the ith suspected defect connected domain, and D represents the number of ellipse-like edge segments of the ith suspected defect connected domain. Indicates the degree of discreteness of the ath sub-edge curve of the i-th suspected defect connected domain, represents the degree of discreteness of the edge line of the i-th suspected defect connected domain, C+D represents the number of sub-edge curves of the i-th suspected defect connected domain, Indicates the degree of discreteness of the cth straight line edge segment of the i-th suspected defect connected domain, represents the discrete degree of the d-th ellipse-like edge segment of the i-th suspected defect connected domain, sigmoid() represents the normalization function, || represents the absolute value sign, and λ1 represents the preset first adjustment parameter.

[0083] In this embodiment, a preset first adjustment parameter is introduced into the calculation formula of the defect evaluation value in order to prevent the denominator from being 0. In this embodiment, the preset first adjustment parameter is 0.01. In specific applications, the implementer can set it according to the specific situation. It is used to reflect the difference between the degree of discreteness of the straight edge segments of the ith suspected defect connected domain and the overall degree of discreteness of the edge lines of the ith suspected defect connected domain. The larger the value, the greater the difference between the two, and the more likely the suspected defect connected domain is to be a defect area. The greater the difference between the degree of discreteness of the straight edge segments of the ith suspected defect connected domain and the overall degree of discreteness of the edge lines of the ith suspected defect connected domain, the greater the degree of discreteness of the straight edge segments, and the smaller the degree of discreteness of the ellipse-like edge segments, the more likely the ith suspected defect connected domain is to be a gas trapped defect area, that is, the greater the defect evaluation value of the ith suspected defect connected domain.

[0084] By using the above method, the defect evaluation value of each suspected defect connected domain can be obtained. The larger the defect evaluation value, the greater the possibility that the corresponding suspected defect connected domain is a gas-trapped defect region. Therefore, in this embodiment, the suspected defect connected domain with a defect evaluation value greater than a preset evaluation threshold is determined as a gas-trapped defect region. In this embodiment, the preset evaluation threshold is 0.6. In specific applications, the implementer can set it according to specific circumstances.

[0085] So far, the trapped gas defect areas have been screened based on the defect evaluation values, such as Figure 2 As shown in FIG. 1 , this figure is a flow chart of a method for obtaining an air-trapping defect region. It should be noted that if there is no air-trapping defect region, it means that the automobile connector to be inspected does not have an air-trapping defect, and there is no need to perform step S4 on it.

[0086] Step S4, integrating the relative position distribution of the sub-edge curves corresponding to different air-trapping defect regions in space and the defect evaluation values, performing a merging operation on the corresponding air-trapping defect regions, and obtaining a target defect region.

[0087] Considering that the same air-trapping defect region may be divided, it is necessary to determine whether to merge adjacent air-trapping defect regions to obtain a complete and accurate air-trapping defect region.

[0088] Any trapped air defect region is recorded as the defect region to be analyzed, and other trapped air defect regions that are closest to the defect region to be analyzed are recorded as the nearest neighbor defect regions of the defect region to be analyzed; in this embodiment, the distance between the center points of the two defect regions is recorded as the distance between the two defect regions. The two sub-edge curves that are closest to all sub-edge curves corresponding to the defect region to be analyzed and all sub-edge curves corresponding to the nearest neighbor defect region are recorded as the first characteristic curve and the second characteristic curve, respectively; pixel point pairs are constructed based on the pixel points on the first characteristic curve and the second characteristic curve, wherein each pixel point pair includes a pixel point on the first characteristic curve and a pixel point on the second characteristic curve. The specific construction process of pixel pairs is: the first pixel point on the first characteristic curve and the first pixel point on the second characteristic curve constitute a pixel pair, the second pixel point on the first characteristic curve and the second pixel point on the second characteristic curve constitute a pixel pair, the third pixel point on the first characteristic curve and the third pixel point on the second characteristic curve constitute a pixel pair, and so on, to obtain multiple pixel pairs. It should be noted that: the number of pixel pairs formed by the two trapped air defect areas is the minimum number of pixel points in the first characteristic curve and the second characteristic curve. For example: the number of pixels on the first characteristic curve is 53, and the number of pixels on the second characteristic curve is 48, then the number of pixel pairs formed by the defect area to be analyzed and the nearest neighbor defect area is 48.

[0089] The distance between the two pixels in each pixel pair is recorded as the distance value of each pixel pair; according to the similarity between the distance values ​​of adjacent pixel pairs, the difference in the fitting slopes of the two pixels in each pixel pair, and the difference in the defect evaluation value between the defect area to be analyzed and the nearest neighbor defect area, the merging index of the defect area to be analyzed and the nearest neighbor defect area is obtained.

[0090] In this embodiment, the combined index of the defect region to be analyzed and the nearest neighbor defect region can be expressed as:

[0091]

[0092] Among them, Z represents the merging index of the defect area to be analyzed and the nearest neighbor defect area, R represents the number of pixel pairs formed by the defect area to be analyzed and its nearest neighbor defect area, and l r It represents the distance value of the rth pixel pair formed by the defect area to be analyzed and its nearest neighbor defect area, l r+1 Indicates the distance value of the r+1th pixel pair formed by the defect area to be analyzed and its nearest neighbor defect area, Δk r It represents the difference in the fitting slopes of the two pixels in the rth pixel pair formed by the defect area to be analyzed and its nearest neighbor defect area, ΔP represents the difference in the defect evaluation value between the defect area to be analyzed and the nearest neighbor defect area, || represents the absolute value sign, and e represents a natural constant.

[0093] In this embodiment, the process of obtaining the difference between the fitting slopes of the two pixels in the r-th pixel pair is as follows: the absolute value of the difference between the fitting slopes of the two pixels in the r-th pixel pair is used as the difference between the fitting slopes of the two pixels in the r-th pixel pair. The process of obtaining the difference between the defect evaluation value of the defect area to be analyzed and the nearest neighbor defect area is as follows: the absolute value of the difference between the defect evaluation value of the defect area to be analyzed and the defect evaluation value of the nearest neighbor defect area of ​​the defect area to be analyzed is used as the difference between the defect evaluation value of the defect area to be analyzed and the nearest neighbor defect area.

[0094] |l r -l r+1 | represents the difference in distance between the rth pixel pair and the r+1th pixel pair. The smaller the value, the more similar the distance between the two adjacent pixel pairs is. It is used to measure the similarity of the distance between two pixel pairs. Characterizes the cumulative sum of the distance differences between every two adjacent pixel pairs, and is used to reflect the similarity of the distance values ​​of adjacent pixel pairs. The smaller the value is, the more similar the distance values ​​of adjacent pixel pairs are, that is, the more evenly the pixels in the pixel pairs are distributed in the image; when the difference in the fitting slopes of the two pixels in the pixel pair is smaller, the difference in the defect evaluation value between the defect area to be analyzed and the nearest neighbor defect area is smaller, and the distance value of the adjacent pixel pairs is smaller, it means that the similarity of the corresponding two trapped air defect areas is higher, and they should be merged more, that is, the merging index of the defect area to be analyzed and the nearest neighbor defect area is larger.

[0095] By adopting the above method, the merging index of each trapped air defect area and its nearest neighboring trapped air defect area can be obtained. The larger the merging index is, the more likely the corresponding two trapped air defect areas are to belong to the same trapped air defect area. Based on this, if the merging index is greater than the preset merging threshold, the corresponding two defect areas are merged, and the area obtained after the merging is recorded as the target defect area. The specific merging process is: each sub-edge curve corresponding to one of the two defect areas and each sub-edge curve corresponding to the other defect area are calculated respectively. When the distance is minimized, the corresponding two sub-edge areas are recorded as target curves, and the endpoints of the target curves are connected, wherein the two line segments obtained by the connection do not intersect, such as Figure 3 As shown, the figure is a schematic diagram of the target defect area, wherein 1 in the figure represents one of the trapped air defect areas, 2 in the figure is the trapped air defect area that is the nearest neighbor to one of the defect areas, 3 and 4 in the figure represent two target curves, and 5 and 6 in the figure represent the line segments connecting the two defect areas. If the merging index is less than or equal to the preset merging threshold, the defect area to be analyzed and the nearest neighbor defect area will not be merged. The connected domain obtained by the final merging is taken as the target defect area, that is, the final trapped air defect area. The merging threshold of this embodiment is 0.65. In specific applications, the implementer can set it according to the specific situation.

[0096] So far, the method provided in this embodiment has been used to complete the detection of the air trapping defect of the automobile connector to be detected.

[0097] This embodiment takes into account that when an edge detection algorithm is used to detect air-trapped defect areas in the surface image of an automobile connector, the edge lines of the detected air-trapped defect areas may be broken, that is, the detected edge lines cannot form a complete connected domain, so the air-trapped defect areas cannot be completely extracted. This embodiment, based on edge detection of the surface image of the automobile connector to be detected, further analyzes the positions and grayscale similarities between the endpoints of different initial edge lines, that is, in combination with the feature similarities of the endpoints of different broken edge lines, several initial edge line endpoints are connected to obtain a suspected defect connected domain, and then the air-trapped defect areas on the automobile connector are screened out from the suspected defect connected domain in combination with the elliptical or elongated straight line features of the air-trapped defect areas. Since the adjacent air-trapped defect areas screened out may belong to the same air-trapped defect area but are divided, in order to improve the accuracy of the air-trapped defect area extraction results, the relative position distribution of the sub-edge curves corresponding to different air-trapped defect areas in space and the defect evaluation values ​​are combined to merge the different air-trapped defect areas, thereby improving the accuracy of the air-trapped defect area extraction results.

[0098] In other embodiments, a system for visual defect detection of automotive connectors is provided, which includes an image acquisition module, a suspected defect connected domain acquisition module, an air-trapped defect region screening module, and a target defect region extraction module. Figure 4 As shown in the figure, this is a structural block diagram of a visual defect detection system for automotive connectors.

[0099] An image acquisition module, used for acquiring a surface image of the automobile connector to be inspected;

[0100] A suspected defect connected domain acquisition module is used to perform edge detection on the surface image to screen initial edge lines; based on the positions of the endpoints of different initial edge lines and the similarity of grayscale, different initial edge lines are merged to obtain a suspected defect connected domain;

[0101] The air-trapping defect area screening module is used to obtain the defect evaluation value of the suspected defect connected domain according to the difference in the discrete degree of the overall chain code value between each sub-edge curve and the edge line where it is located, and judge whether the suspected defect connected domain is an air-trapping defect area based on the defect evaluation value; the sub-edge curve is obtained by dividing the edge line of the suspected defect connected domain based on the bending characteristics at different positions on the edge line of the suspected defect connected domain;

[0102] The target defect area extraction module is used to fuse the relative position distribution of the sub-edge curves corresponding to different trapped air defect areas in space and the defect evaluation values, merge the corresponding trapped air defect areas, and obtain the target defect area.

[0103] When the system is running, the computer executes the above-mentioned related steps to implement a method for visual defect detection of automobile connectors provided in the above-mentioned embodiment.

[0104] In other embodiments, a device is provided, including a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, so that the device executes the above-mentioned automotive connector visual defect detection method. The device can be a chip, a component or a module, and the chip can include a connected processor and a memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute the automotive connector visual defect detection method provided in the above embodiment.

[0105] In other embodiments, a computer program product is also provided. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement a method for visual defect detection of automotive connectors provided in the above-mentioned embodiment.

[0106] In other embodiments, a computer-readable storage medium is also provided, in which a computer program code is stored. When the computer program code is run on a computer, the computer executes the above-mentioned related method steps to implement a method for visual defect detection of automotive connectors provided in the above-mentioned embodiment.

[0107] Among them, the provided systems, devices, computer program products, and computer-readable storage media are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.

[0108] It should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for visual defect detection of automotive connectors, characterized in that: The method comprises the following steps: Acquire a surface image of an automobile connector to be inspected; Performing edge detection on the surface image to screen initial edge lines; combining the positions of the endpoints of different initial edge lines and the similarity of grayscale to obtain a suspected defect connected domain; According to the difference in the discreteness of the overall chain code value between each sub-edge curve and the edge line where it is located, the defect evaluation value of the suspected defect connected domain is obtained, and whether the suspected defect connected domain is a gas trapped defect area is determined based on the defect evaluation value; the sub-edge curve is obtained by dividing the edge line of the suspected defect connected domain based on the bending characteristics at different positions on the edge line of the suspected defect connected domain; The relative position distribution of the sub-edge curves corresponding to different trapped air defect regions in space and the defect evaluation values ​​are integrated, and the corresponding trapped air defect regions are merged to obtain the target defect region; The performing edge detection on the surface image to select an initial edge line comprises: Performing edge detection on the surface image, and recording an edge line including two endpoints as an initial edge line; The method combines the positions of the endpoints of different initial edge lines and the similarity of the grayscale to merge the different initial edge lines to obtain the suspected defect connected domain, including: The endpoints in the neighborhood of the candidate endpoints are used as the endpoints to be combined of the candidate endpoints; combining the similarity of the fitting slope and gray value between the candidate endpoint and each endpoint to be combined, the candidate endpoint is connected with its corresponding endpoint to be combined to obtain a closed connected domain as the suspected defect connected domain; The fitting slope is determined based on the position of the pixel points in the neighborhood of the candidate pixel point that are on the same initial edge line as the candidate pixel point; The candidate endpoint is any endpoint on any initial edge line; The acquisition of the sub-edge curve includes: Any pixel point on the edge line of the suspected defect connected domain is recorded as a point to be analyzed; on the edge line of the suspected defect connected domain, the normalized result of the difference between the fitting slopes of two pixel points adjacent to the point to be analyzed is used as the bending parameter of the point to be analyzed, and if the bending parameter is greater than a preset bending threshold, the point to be analyzed is used as a segmentation point, the edge line of the suspected defect connected domain is segmented, and each curve obtained after the segmentation is completed is used as a sub-edge curve; The defect evaluation value of the suspected defect connected domain is obtained according to the difference in the discrete degree between each sub-edge curve and the overall chain code value of the edge line where it is located, including: The edge line of any suspected defect connected domain is recorded as a candidate suspected defect edge; Calculate the discrete degree of the chain code value of all pixels on each sub-edge curve on the candidate suspected defect edge and the discrete degree of the chain code value of all pixels on the candidate suspected defect edge; record the discrete degree of the chain code value of all pixels on each characteristic curve as the discrete degree of each characteristic curve, wherein the characteristic curve includes the candidate suspected defect edge and each sub-edge curve on the candidate suspected defect edge; Dividing each sub-edge curve on the candidate suspected defect edge into a quasi-ellipse edge segment and a straight line edge segment based on the discrete degree; The defect evaluation value of the corresponding suspected defect connected domain is obtained by combining the difference between the discrete degree of each sub-edge curve on the candidate suspected defect edge and the discrete degree of the candidate suspected defect edge, the discrete degree of the ellipse-like edge segment and the discrete degree of the straight edge segment, wherein the difference in the discrete degree and the discrete degree of the straight edge segment are both positively correlated with the defect evaluation value, and the discrete degree of the ellipse-like edge segment is negatively correlated with the defect evaluation value; The step of dividing each sub-edge curve on the candidate suspected defect edge into ellipse-like edge segments and straight line edge segments based on the discrete degree includes: The sub-edge curve with a discrete degree greater than that of the candidate suspected defect edge is regarded as a quasi-ellipse edge segment, and the sub-edge curve with a discrete degree less than or equal to that of the candidate suspected defect edge is regarded as a straight line edge segment.

2. The method for visual defect detection of automotive connectors according to claim 1, characterized in that: The step of combining the similarity of the fitting slope and the gray value between the candidate endpoint and each endpoint to be combined, and connecting the candidate endpoint with its corresponding endpoint to be combined to obtain a closed connected domain includes: Connect the candidate endpoints and the endpoints to be combined with the largest similarity to their feature vectors by straight lines to obtain a closed connected domain; The feature vector is composed of the fitting slope and the gray value.

3. The method for visual defect detection of automotive connectors according to claim 1, characterized in that: The determining whether the suspected defect connected domain is a gas trapped defect region based on the defect evaluation value includes: The suspected defect connected area with a defect evaluation value greater than a preset evaluation threshold is determined as the air trapped defect area.

4. The method for visual defect detection of automotive connectors according to claim 1, characterized in that: The step of fusing the relative position distribution of the sub-edge curves corresponding to different air-trapping defect regions in space and the defect evaluation values, and performing a merging operation on the corresponding air-trapping defect regions, includes: Any trapped gas defect region is recorded as the defect region to be analyzed, and other trapped gas defect regions that are closest to the defect region to be analyzed are recorded as the nearest neighbor defect regions of the defect region to be analyzed; The two sub-edge curves with the closest distance among all the sub-edge curves corresponding to the defect area to be analyzed and all the sub-edge curves corresponding to the nearest neighbor defect area are recorded as the first characteristic curve and the second characteristic curve respectively; Constructing pixel pairs based on the pixel points on the first characteristic curve and the second characteristic curve, wherein each pixel pair includes a pixel point on the first characteristic curve and a pixel point on the second characteristic curve; recording the distance between the two pixel points in each pixel pair as the distance value of each pixel pair; The merging index of the defect area to be analyzed and the nearest neighbor defect area is obtained according to the similarity between the distance values ​​of adjacent pixel pairs, the difference in the fitting slopes of the two pixel points in each pixel pair, and the difference in the defect evaluation value between the defect area to be analyzed and the nearest neighbor defect area; Whether to merge the defect area to be analyzed and the nearest neighbor defect area is determined based on the merging index.

5. The method for visual defect detection of automotive connectors according to claim 4, characterized in that: The determining whether to merge the defect area to be analyzed and the nearest neighbor defect area based on the merging index includes: If the merging index is greater than the preset merging threshold, the defect area to be analyzed and the nearest neighbor defect area are merged; If the merging index is less than or equal to the preset merging threshold, the defect area to be analyzed and the nearest neighbor defect area are not merged.

Citation Information

Patent Citations

  • Injection molding part surface defect analysis method and system based on machine vision

    CN114565614A