Machine Vision-Based Plug-in Quality Inspection Method and System

By using machine vision-based agglomerative hierarchical clustering algorithm and DTW distance judgment, the pin region in the plug-in image is extracted, which solves the problem of high deployment cost of traditional detection methods in diverse plug-in environments and achieves efficient and accurate plug-in quality detection.

CN120707565BActive Publication Date: 2025-10-31SUZHOU NUODAJIA AUTOMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511163688.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-20
Publication Date
2025-10-31
Estimated Expiration
2045-08-20

AI Technical Summary

Technical Problem

Existing technologies rely on templates and manual threshold strategies for plugin quality inspection, resulting in high deployment costs and impacting production efficiency in environments with diverse product types and frequent updates.

Method used

A machine vision-based plug-in quality inspection method is adopted. The pin region is extracted by agglomerative hierarchical clustering algorithm. The position point sequence is constructed by using the position and grayscale information of the pixels. The dynamic time warping (DTW) distance is combined to judge the pin quality, avoiding forced merging of clusters that do not belong to the same region, and quickly extracting the pin region.

Benefits of technology

It eliminates the need to rely on a large number of standard templates, improves adaptability to different plugins, saves production time, and increases production efficiency and testing accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120707565B_ABST
    Figure CN120707565B_ABST
Patent Text Reader

Abstract

This application relates to the field of image processing technology, and in particular to a method and system for inspecting the quality of plug-ins based on machine vision. The method includes acquiring plug-in images, extracting pin regions, constructing a sequence of position points based on the pixel positions in each pin region, and determining pin quality based on the similarity between the position point sequences. This application has the effect of reducing the deployment cost of the inspection system and improving production efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a method and system for plug-in quality inspection based on machine vision. Background Technology

[0002] In the manufacturing process of electronic products such as display devices and industrial control panels, connectors, as crucial structures connecting the main control board and functional components for signal and power transmission, directly affect the stability and reliability of the entire device. Connectors typically consist of a plastic housing and several metal pins for electrical connections. Because the manufacturing process of connectors involves multiple steps such as stamping, injection molding, and assembly, they are susceptible to deformation problems such as mold wear, equipment precision fluctuations, and operational errors, leading to bending, misalignment, or abnormal spacing of the metal pins. If these deformations are not detected in time, they may result in poor contact, abnormal signal transmission, or even complete device malfunction. Currently, some publicly available technologies attempt to automate the detection of connector pins. For example, Chinese patent application CN114708262A discloses a visual inspection method for connector pins. This method relies on a combination of template matching and threshold segmentation. First, by setting ROI regions and creating standard pin templates, the pins in the detection image are coarsely located. Then, the image is thresholded using the maximum inter-class variance method to obtain the pin feature regions and calculate the coordinates of the center point of each pin. Finally, the weighted least squares method is used to fit straight lines to all pin center points, and the presence of anomalies is determined based on the horizontal and vertical distances between the pins and the standard path.

[0003] In current technologies, pin inspection relies on templates and manual thresholding strategies. Templates need to be built based on standard product images and manually configured for different products. In today's production environments, product types and specifications are diverse. It is estimated that a complete automated production line involves over 1000 different components. Furthermore, with technological advancements, components are frequently updated, and building component templates is time-consuming, impacting production efficiency. Therefore, traditional pin inspection methods are costly to deploy in today's environment of frequent product iterations and numerous component types, and are inconvenient to use, affecting the overall production line efficiency. Summary of the Invention

[0004] To reduce the deployment cost of inspection systems and improve production line efficiency, this application provides a machine vision-based method and system for inspecting the quality of plug-in components.

[0005] Firstly, this application provides a machine vision-based plug-in quality inspection method, employing the following technical solution:

[0006] A machine vision-based plug-in quality detection method includes the following steps: acquiring a plug-in image, extracting the pin region, constructing a position point sequence based on the pixel positions in each pin region, and judging the pin quality based on the similarity between the position point sequences.

[0007] The steps for extracting the pin region include: obtaining the position and grayscale value of each pixel in the plug-in image; using agglomerative hierarchical clustering algorithm to cluster the pixels based on their position and grayscale values; for any two clusters to be merged corresponding to any iteration in the clustering process, obtaining the merging probability of the two clusters based on the pixel information and the difference in cluster centers; stopping cluster merging when the merging probability is greater than a preset merging threshold and obtaining the clustering result; extracting the boundary line between the pin and the shell; determining the pin cluster based on the position of the cluster center and the boundary line of each cluster in the clustering result, and using the pin cluster as the pin region.

[0008] The beneficial effect is as follows: By extracting the stitch regions from the plugin image and comparing the similarity of the position point sequences formed by the coordinates of pixels within these regions, it is possible to determine whether stitch deformation exists. Normally, the stitch regions are parallel, resulting in a high degree of similarity between the corresponding position point sequences. If the stitches are deformed, the similarity of the position point sequences decreases, thus allowing for the identification of any defects in the stitches.

[0009] A cohesive hierarchical clustering algorithm is employed to extract the pin region, and a merging probability judgment mechanism is introduced during the clustering process. The merging probability is obtained by analyzing the differences in pixels and cluster centers between two clusters to be merged. This mechanism determines whether the two clusters should be merged in the cohesive hierarchical clustering algorithm, avoiding forced merging of clusters that do not belong to the same region and improving the accuracy of pin region extraction. Then, the pin region is quickly extracted using the boundary line between the shell region and the pin region, improving computational efficiency.

[0010] Optionally, the steps for obtaining the merging probability of two clusters to be merged based on the pixel information and the difference in cluster centers include: obtaining the absolute difference in grayscale values ​​of the pixels at the cluster centers of the two clusters to be merged; using the reciprocal of the absolute difference in grayscale values ​​as the initial probability; analyzing the differences in the number of pixels and gradient direction in the two clusters to be merged, optimizing the initial probability, and obtaining the merging probability.

[0011] The beneficial effect is that using the reciprocal of the absolute difference in grayscale values ​​as the initial probability reflects the positive correlation between structural similarity and cluster merging: the smaller the grayscale difference, the more similar the structures; the larger the reciprocal, the stronger the merging intention. Conversely, a larger reciprocal indicates that the two clusters may belong to different physical regions, and the merging probability should be reduced. This reciprocal mapping mechanism expresses a significant structural differentiation tendency in a simple calculation, achieving a good balance between algorithm efficiency and intuitive judgment. Then, pixel-level structural information is introduced to correct the initial probability, further enhancing the accuracy of the merging probability judgment.

[0012] Optionally, the steps of analyzing the differences in the number of pixels and gradient direction in the two clusters to be merged and optimizing the initial probability include: calculating the clustering difference degree based on the differences in the number of pixels and gradient direction in the two clusters to be merged; in response to the clustering difference degree being less than or equal to a preset difference threshold, using the product of the clustering difference degree and the initial probability as the merging probability; in response to the clustering difference degree being greater than the preset difference threshold, obtaining the distance difference based on the distance between the two clusters to be merged and the difference between historical clusters to be merged, and using the product of the distance difference and the initial probability as the merging probability.

[0013] The beneficial effects are as follows: In this method, the clustering difference between two clusters to be merged is first compared based on the number of pixels and the gradient direction of the pixels. If the number of pixels and the gray value of the pixels at the cluster center differ significantly between the two clusters, it indicates that the two clusters are inconsistent in both quantity and gray value, suggesting that they belong to different regions in the plugin. For example, the shell and the pin; merging these two regions without control would lead to a decrease in the final detection accuracy. Therefore, the clustering difference is used to adjust the initial probability, and the merging probability is obtained by reducing the initial probability, thus suppressing the merging of clusters. When the number and gray value of two clusters to be merged are similar, it indicates that the two clusters may belong to the same type of structure, such as both being pin regions. However, if these two regions each represent a pin, they still cannot be merged. Therefore, the distance difference is obtained by analyzing the distance between the two clusters and the distance of historical clusters to be merged, and then the initial probability is optimized based on the distance difference to obtain the merging probability.

[0014] Optionally, the initial probabilities of the two clusters to be merged can be used as a preset merging threshold.

[0015] The beneficial effects are: setting the initial probability to a preset merging threshold allows the preset merging threshold to change dynamically, eliminating the need for manual setting of empirical parameters, improving system stability and cross-product adaptability, and making it especially suitable for manufacturing scenarios with a wide variety of plugins and frequent updates.

[0016] Optionally, the distance difference can be calculated as the ratio of the mean distance between historically merged clusters to the distance between two clusters to be merged.

[0017] The beneficial effect is that it mainly compares the distance between the two clusters to be merged with the distance between the clusters that have been merged in the past. If the distance between the two clusters to be merged is greater than the distance between the two clusters that have been merged in the past, the distance difference will be less than 1, which will reduce the initial probability value to obtain the merging probability and inhibit the merging of the two clusters to be merged.

[0018] Optionally, the step of extracting the boundary line between the pin and the shell includes: taking the cluster with the most pixels in the clustering results as the shell cluster; any two pixels in the shell cluster form a matching point pair; based on the position of the pixels, the Euclidean distance between the two pixels in the matching point pair is taken as the point pair distance; extracting the pixels in the matching point pair with the largest point pair distance; connecting the pixels in pairs to obtain the shell edge line; calculating the optimization degree based on the distance between the edge line and the cluster centers of other clusters besides the shell cluster; and taking the dividing line with the highest optimization degree as the boundary line.

[0019] The beneficial effects are as follows: Analysis of the plugin's structure shows that the shell region occupies the largest area. Therefore, the cluster with the most pixels is selected as the shell cluster. Then, the matching point pairs with the largest distance are selected from the shell clusters. Based on the plugin's quadrilateral structure, if two pixels are maximally far apart, these two pixels must be located at the corners of the shell region. Subsequently, the dividing line is determined based on the corner pixels, and the optimality of the dividing line is determined based on its distance from other clusters, thereby determining the boundary line between the shell and the pin region.

[0020] Optionally, for each dividing line, the sum of the vertical distances from the dividing line to other clusters except the shell cluster is taken as the total distance, and the optimization degree of the dividing line is obtained based on the total distance. The total distance is negatively correlated with the optimization degree.

[0021] Optionally, the step of determining the pin cluster based on the position of the cluster center and the boundary line of each cluster in the clustering results includes: obtaining the linear equation of the boundary line; for any cluster, substituting the x-coordinate of the cluster center of the cluster into the linear equation to obtain the equation value; comparing the equation value with the y-coordinate of the cluster center; and determining that the cluster is the pin region if the equation value is greater than the y-coordinate of the cluster center.

[0022] Optionally, the steps for judging the quality of pins based on the similarity between the sequence of each position point include: for any two pins forming a pin pair, obtaining the DTW distance between the position point sequences corresponding to the two pins in each pin pair, taking the reciprocal of the mean of the DTW distance as the similarity between each pin, and determining that the plug-in is unqualified if the similarity between each pin is less than a preset quality coefficient.

[0023] The beneficial effects are as follows: Dynamic Time Warping (DTW) distance is used to measure the structural similarity between pins, and the reciprocal of the DTW mean is used as a similarity index. The quality of the plug-in is determined by comparing it with a preset quality coefficient. This scheme makes full use of the global spatial sequence information of the pins in terms of morphology and structure.

[0024] Secondly, this application provides a machine vision-based component quality inspection system, which adopts the following technical solution:

[0025] The machine vision-based component quality inspection system includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the machine vision-based component quality inspection method described above.

[0026] The beneficial effect is that the above-mentioned machine vision-based plug-in quality inspection method is generated into a computer program and stored in the memory so that it can be loaded and executed by the processor. Thus, the system can be made according to the memory and processor, which is convenient to use.

[0027] This application has the following technical advantages:

[0028] By extracting the pin regions from the plugin image and comparing the similarity of position point sequences constructed from the coordinates of multiple pin regions, the quality of the pin regions can be detected. Compared to traditional detection techniques, this method does not rely on a large number of standard templates, saving production time and improving adaptability to different plugins. Attached Figure Description

[0029] Figure 1 This is a flowchart of the plug-in quality inspection method based on machine vision proposed in this application.

[0030] Figure 2 This is a flowchart of step S1 of the machine vision-based plug-in quality inspection method of this application.

[0031] Figure 3 This is a flowchart of a method for obtaining the merging probability of two clusters to be merged in an embodiment of this application. Detailed Implementation

[0032] This application discloses a machine vision-based component quality inspection method. The method acquires component images and extracts pin regions from the component. A sequence of position points is constructed based on the coordinates of pixels within the pin regions, and the pin quality is determined by the similarity of these position point sequences. Normally, multiple pins are parallel to each other, resulting in high similarity between their corresponding position point sequences. If a pin is deformed, the pin regions will no longer be parallel, affecting the similarity between the position point sequences. Therefore, this characteristic can be used to monitor pin quality. This method eliminates the need for template images when dealing with diverse products, saving time and improving production efficiency.

[0033] Reference Figure 1 The machine vision-based plug-in quality inspection method includes steps S1-S2.

[0034] Step S1: Obtain the plugin image and extract the pin area.

[0035] Reference Figure 2 Step S1 includes steps S11-S15.

[0036] S11: Obtain the position and grayscale value of each pixel in the plugin image.

[0037] During the component manufacturing process, components are conveyed on a conveyor belt on the component production line. An industrial camera positioned directly above the conveyor belt photographs the components on the conveyor belt, acquiring raw images of the components. These images are then preprocessed to obtain preprocessed images. In this embodiment, the preprocessing operations include median filtering for noise reduction and grayscale conversion. In other embodiments, noise reduction methods may include mean filtering, Gaussian filtering, etc. An image segmentation threshold is obtained using the Otsu's method. Based on this threshold, the component region in the preprocessed image is extracted, resulting in the component image.

[0038] The grayscale value and position coordinates of each pixel in the plugin image are obtained and then normalized. The normalization method can be min-max normalization, which is a common technique in this field and will not be elaborated here.

[0039] S12: Based on the position and gray level of each pixel, the agglomerative hierarchical clustering algorithm is used to cluster the pixels. For any two clusters to be merged corresponding to any iteration in the clustering process, the merging probability of the two clusters to be merged is obtained according to the pixel information and the difference in the cluster centers of the two clusters to be merged.

[0040] Traditional agglomerative hierarchical clustering algorithms employ a bottom-up strategy. First, each object is treated as a cluster. The distance between any two clusters is calculated, and the two clusters with the smallest distance are merged. This process is repeated, calculating the distance between any two clusters and merging them again. For the distance between clusters, the distance between the nearest points within a cluster (i.e., Euclidean distance calculated based on location coordinates and grayscale) or the average distance between points in the cluster is typically used.

[0041] When this method is applied to image processing, the pins of actual plug-in products are usually multiple, neatly arranged, and close together. Therefore, during the clustering process based on the agglomerative hierarchical clustering algorithm, there may be two clusters to be merged that are actually two pin regions. Such cases need to be distinguished to avoid merging two different pin regions.

[0042] Therefore, in the clustering process, for each group of clusters to be merged, the merging probability of the two clusters to be merged is calculated based on the difference between the two clusters to be merged, and the merging probability is used to determine whether the two clusters to be merged should be merged.

[0043] Reference Figure 3 The steps to obtain the merging probability of two clusters to be merged include: steps S121-S122.

[0044] S121: Obtain the absolute difference of the gray values ​​of the pixels at the cluster centers of the two clusters to be merged, and use the reciprocal of the absolute difference of the gray values ​​as the initial probability.

[0045] For two clusters to be merged, compare the absolute difference in gray values ​​of the pixels corresponding to the cluster centers of the two clusters. The larger the absolute difference, the less likely the two clusters are to belong to the same region. Therefore, the reciprocal of the absolute difference is used as the initial probability.

[0046] S122: Analyze the differences in the number of pixels and gradient direction between the two clusters to be merged, optimize the initial probability, and obtain the merging probability.

[0047] The steps for optimizing the initial probability by analyzing the differences in the number of pixels and gradient direction between two clusters to be merged include: calculating the clustering difference degree based on the differences in the number of pixels and gradient direction between the two clusters to be merged; if the clustering difference degree is less than or equal to a preset difference threshold, using the product of the clustering difference degree and the initial probability as the merging probability; if the clustering difference degree is greater than the preset difference threshold, obtaining the distance difference based on the distance between the two clusters to be merged and the difference between historical clusters to be merged, and using the product of the distance difference and the initial probability as the merging probability.

[0048] In the step of calculating the cluster difference based on the difference in the number of pixels in two clusters to be merged and the difference in gradient direction in the clusters to be merged, the number of pixels in the two clusters to be merged is first counted, the difference in the number of pixels in the two clusters to be merged is compared, and the normalized result of the absolute difference in the number of pixels in the two clusters to be merged is taken as the difference in the number of pixels between the two clusters to be merged.

[0049] Subsequently, the gradient directions of pixels in the two clusters to be merged are obtained, and the mean of the corresponding gradient directions in each of the two clusters is also obtained. The normalized result of the absolute difference between the two means is taken as the gradient direction difference between the two clusters to be merged.

[0050] There are no special requirements for the calculation order of gradient direction difference and quantity difference; in other embodiments, the gradient direction difference can be calculated first, followed by the quantity difference. After the gradient direction and quantity differences are calculated, the clustering dissimilarity is obtained by combining the quantity difference and gradient direction difference. Both the quantity difference and the gradient equation difference are positively correlated with the clustering dissimilarity.

[0051] Specifically, the formula for calculating cluster dissimilarity can be expressed as:

[0052] In the formula, This indicates the clustering dissimilarity between two clusters to be merged; Indicates the clusters to be merged The number of pixels in the middle; Indicates the clusters to be merged The number of pixels in the middle; Indicates the clusters to be merged The mean of the gradient direction of the middle pixel; Indicates the clusters to be merged The mean of the gradient direction of the middle pixel; This represents the maximum value of the gradient direction of pixels in two clusters to be merged, and is used to normalize the absolute difference of the mean gradient direction. This represents the total number of pixels in the plugin image, used to normalize the absolute difference in the number of pixels.

[0053] This formula primarily reflects the differences between two clusters to be merged through two dimensions: the number of pixels and the gradient direction. This is known as the cluster dissimilarity. A higher dissimilarity indicates that the two clusters are more likely to belong to different regions. For example, in a real product, the shell area and pin area of ​​a plug-in are connected and may be spatially close, but their pixel counts and gradient directions can differ significantly. Therefore, focusing on the number of pixels and gradient direction can reduce the occurrence of such situations and decrease erroneous merging.

[0054] When the cluster difference is less than or equal to a preset difference threshold, the product of the cluster difference and the initial probability is used as the merging probability; when the cluster difference is greater than the preset difference threshold, the distance difference is obtained based on the distance between the two clusters to be merged and the difference between the historical clusters to be merged, and the product of the distance difference and the initial probability is used as the merging probability.

[0055] If the clustering dissimilarity is large, it indicates that the two clusters to be merged may belong to different regions. Therefore, in this embodiment, the preset dissimilarity threshold is set to 0.6. When the clustering dissimilarity is greater than 0.6, the initial probability is optimized using the clustering dissimilarity. In this embodiment, the product of the clustering dissimilarity and the initial probability is used as the merging probability.

[0056] When the clustering difference is small, it indicates that the number of pixels and gradient directions in the two clusters to be merged are similar, suggesting they may belong to two different pin regions, or they may indeed belong to regions that should be merged. To accurately distinguish between these two situations, the two clusters to be merged need to be analyzed again.

[0057] In the process of clustering using agglomerative hierarchical analysis, the merging of clusters is mainly based on the distance between two clusters. Therefore, in this embodiment, the difference between the distance between the two clusters to be merged and the mean distance between multiple groups of clusters to be merged in the historical clustering process is compared to determine whether the two clusters to be merged need to be merged.

[0058] Specifically, the ratio of the mean distance between the clusters to be merged in history to the distance between the two clusters to be merged is taken as the distance difference, and the product of the distance difference and the initial probability is taken as the merging probability.

[0059] In real-world images, if pixels in two clusters to be merged belong to the same region, then the two clusters should be spatially adjacent. However, if the two clusters belong to different pin regions, although the distance between the pins is also small, it is still significantly different from the case of adjacent clusters. Therefore, in the above method, if the two clusters to be merged belong to different pin regions, the distance between the two clusters to be merged will inevitably be much greater than the distance between previously merged clusters, resulting in a lower final merging probability. Consequently, subsequent merging can be stopped based on the merging probability.

[0060] S13: In response to the merging probability being greater than the preset merging threshold, stop merging clusters and obtain the clustering results.

[0061] In this embodiment, the preset merging threshold is equal to the initial probability, which means that the preset merging threshold is dynamically changing. The strategy of dynamically terminating the merging is used to adaptively cluster the pixels, improve the accuracy of clustering, and facilitate the handling of dynamic changes of various plugin types.

[0062] In conjunction with step S12, when the cluster difference is greater than the preset difference threshold, since normalization is performed during the calculation of the cluster difference, the value of the cluster difference is usually less than 1. Therefore, in other embodiments, the merging of clusters can be stopped directly when the cluster difference is greater than the preset difference threshold.

[0063] S14: Extract the boundary line between the pin and the outer shell.

[0064] In this embodiment, the main application scenario involves a rectangular overall structure, with the pins of the captured plug-in image located below the housing. The number of pins is typically eight or more. Analysis of the plug-in's structure reveals a clear boundary line between the pins and the housing; extracting this boundary line allows for accurate and rapid acquisition of the pin area.

[0065] The steps for extracting the boundary line between the pin and the shell include: taking the cluster with the most pixels in the clustering results as the shell cluster; forming a matching point pair between any two pixels in the shell cluster; taking the Euclidean distance between the two pixels in the matching point pair as the point pair distance based on the position of the pixels; extracting the pixels in the matching point pair with the largest point pair distance; and connecting the pixels in pairs to obtain the edge line of the shell; calculating the optimization degree based on the distance between the edge line and the cluster centers of other clusters besides the shell cluster; and taking the dividing line with the highest optimization degree as the boundary line.

[0066] In the plug-in structure, one end of the pin is embedded inside the shell and occupies a large area. Therefore, the cluster with the most pixels is taken as the shell cluster. Meanwhile, the plug-in shell generally has a regular shape, typically a quadrilateral. For a quadrilateral, the distance between pixels located at opposite corners is the largest. Therefore, calculating the Euclidean distance between each pair of pixel coordinates can effectively extract pixels located at the corners of the shell region. In this embodiment, the two pairs of pixels with the largest and second largest Euclidean distances are taken as corner pixels. Any two of the four corner pixels can form a boundary line.

[0067] Based on the plugin's structure, pins constitute the largest proportion of all clusters. For example, a plugin with eight pins might only have 10-13 clusters in the clustering results, comprising the eight pin regions, one shell region, and three to four regions corresponding to characters or other structures on the shell. The boundary line is closest to the pin regions; therefore, the optimality of each dividing line can be calculated by the distance between the dividing line and the clusters, and the dividing line with the highest optimality can be selected as the boundary line.

[0068] Specifically, the formula for calculating the degree of preference can be expressed as: In the formula, Indicates the first The optimality of the dividing line; Indicates the first The dividing line and the first The vertical distance between the cluster centers of each cluster; This represents the total number of clusters other than the shell cluster; Indicates An exponential function with base 0.

[0069] S15: Based on the position of the cluster center and boundary line of each cluster in the clustering results, determine the pin cluster and use the pin cluster as the pin region.

[0070] Obtain the linear equation of the boundary line. For any cluster, substitute the x-coordinate of the cluster center into the linear equation to obtain the equation value. Compare the equation value with the y-coordinate of the cluster center. If the equation value is greater than the y-coordinate of the cluster center, determine that the cluster is a pin region.

[0071] The boundary line can be represented by a linear equation. The clusters below the boundary line are the clusters corresponding to the pin regions. Therefore, by substituting the x-coordinates of the cluster centers corresponding to each cluster into the linear equation, the location of the clusters can be determined, thus enabling the extraction of the clusters corresponding to the pin regions.

[0072] S2: Construct a position point sequence based on the pixel positions in each pin region, and determine the pin quality based on the similarity between the position point sequences.

[0073] For any two pins that form a pin pair, obtain the DTW distance of the position point sequence corresponding to the two pins in each pin pair, and take the reciprocal of the mean of the DTW distance as the similarity between each pin. If the similarity between each pin is less than the preset quality coefficient, the plug-in is determined to be unqualified.

[0074] In constructing the position point sequence, the coordinates of all pixels in the pin area are first extracted, and then arranged in ascending order of coordinates to form the position point sequence. This can also be understood as starting from the bottom left pixel of the pin area, arranging the position coordinates of pixels sequentially from left to right and from bottom to top. For example, if there are six pixels in a pin area with coordinates (1,2), (2,2), (1,3), (3,2), (2,3), and (3,3), then the corresponding position point sequence is: {(1,2), (1,3), (2,2), (2,3), (3,2), (3,3)}.

[0075] The smaller the DTW distance between the cluster position point sequences of two pin regions, the closer the shapes and arrangements of the two sequences are, indicating that there is no deformation in the two pin regions and the quality is good. Conversely, the larger the DTW distance between the cluster position point sequences of two pin regions, the more different the shapes and arrangements of the two sequences are, meaning that the two pin regions have undergone deformation (such as bending, offset, or uneven spacing), and the quality is poor. In this embodiment, the preset quality coefficient is 0.4. When the calculated similarity of the pin regions is less than 0.4, it indicates that the current plug-in pin is unqualified.

[0076] This application also discloses a machine vision-based component quality inspection system, including a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the machine vision-based component quality inspection method according to this application.

[0077] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.

[0078] The above are all preferred embodiments of this application, and are not intended to limit the scope of protection of this application. Therefore, all equivalent changes made in accordance with the structure, shape and principle of this application should be covered within the scope of protection of this application.

Claims

1. A machine vision-based component quality inspection method, characterized in that, The plugin image is acquired, the pin regions are extracted, and a position point sequence is constructed based on the pixel positions in each pin region. The pin quality is judged based on the similarity between the position point sequences, including: for any two pins forming a pin pair, the DTW distance of the position point sequences corresponding to the two pins in each pin pair is obtained, and the reciprocal of the mean of the DTW distance is used as the similarity between each pin. If the similarity between each pin is less than a preset quality coefficient, the plugin is determined to be unqualified. The steps for extracting the pin region include: obtaining the position and grayscale value of each pixel in the plugin image; clustering the pixels using agglomerative hierarchical clustering algorithm based on the position and grayscale value of each pixel; for any two clusters to be merged corresponding to any iteration in the clustering process, obtaining the merging probability of the two clusters to be merged based on the pixel information and the difference in the cluster centers, including: obtaining the absolute difference in grayscale values ​​of the pixels at the cluster centers of the two clusters to be merged; using the reciprocal of the absolute difference in grayscale values ​​as the initial probability; analyzing the differences in the number of pixels and gradient direction in the two clusters to be merged, optimizing the initial probability, and obtaining the merging probability; In response to a merging probability greater than a preset merging threshold, cluster merging is stopped, and clustering results are obtained; the boundary line between the pin and the shell is extracted; the pin cluster is determined based on the position of the cluster center and the boundary line of each cluster in the clustering results, and the pin cluster is used as the pin region.

2. The machine vision-based plug-in quality inspection method according to claim 1, characterized in that, The steps for optimizing the initial probability by analyzing the differences in the number of pixels and gradient direction between two clusters to be merged include: calculating the clustering difference degree based on the differences in the number of pixels and gradient direction between the two clusters to be merged; if the clustering difference degree is less than or equal to a preset difference threshold, using the product of the clustering difference degree and the initial probability as the merging probability; if the clustering difference degree is greater than the preset difference threshold, obtaining the distance difference based on the distance between the two clusters to be merged and the difference between historical clusters to be merged, and using the product of the distance difference and the initial probability as the merging probability.

3. The machine vision-based plug-in quality inspection method according to claim 1, characterized in that, The initial probabilities of the two clusters to be merged are used as the preset merging threshold.

4. The machine vision-based plug-in quality inspection method according to claim 2, characterized in that, The distance difference is defined as the ratio of the mean distance between clusters that have been merged in the past to the distance between two clusters to be merged.

5. The machine vision-based plug-in quality inspection method according to claim 1, characterized in that, The steps for extracting the boundary line between the pin and the shell include: taking the cluster with the most pixels in the clustering results as the shell cluster; forming a matching point pair between any two pixels in the shell cluster; taking the Euclidean distance between the two pixels in the matching point pair as the point pair distance based on the pixel position; extracting the pixels in the matching point pair with the largest point pair distance; and drawing lines connecting the pixels in pairs to obtain the shell edge line; calculating the optimization degree based on the distance between the edge line and the cluster centers of other clusters besides the shell cluster; and taking the dividing line with the highest optimization degree as the boundary line. The formula for calculating the degree of preference is expressed as follows: In the formula, Indicates the first The optimality of the dividing line; Indicates the first The dividing line and the first The vertical distance between the cluster centers of each cluster; This represents the total number of clusters other than the shell cluster; Indicated by An exponential function with base 0.

6. The machine vision-based plug-in quality inspection method according to claim 5, characterized in that, For each dividing line, the sum of the vertical distances from the dividing line to all other clusters except the shell cluster is taken as the total distance. The optimization degree of the dividing line is obtained based on the total distance, and the total distance is negatively correlated with the optimization degree.

7. The machine vision-based plug-in quality inspection method according to claim 1, characterized in that, The steps for determining the pin cluster based on the location of the cluster center and boundary line of each cluster in the clustering results include: obtaining the linear equation of the boundary line; for any cluster, substituting the x-coordinate of the cluster center into the linear equation to obtain the equation value; comparing the equation value with the y-coordinate of the cluster center; and determining that the cluster is the pin region if the equation value is greater than the y-coordinate of the cluster center.

8. A machine vision-based component quality inspection system, characterized in that, include: A processor and a memory, the memory storing computer program instructions that, when executed by the processor, implement the machine vision-based plug-in quality inspection method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Visual inspection method for connector pins

    CN114708262A

  • Connector pin detection method based on image features

    CN117372435A

  • Intelligent detection method and system for shaft forgings

    CN119399209A