Plug-in quality detection method and system based on machine vision

By judging the plug-in quality based on machine vision-based agglomerative hierarchical clustering algorithm and DTW distance, the problem of high deployment cost of traditional detection methods in a diversified plug-in environment is solved, and efficient and accurate plug-in quality detection is achieved, which is suitable for rapid detection of different plug-in types.

CN120707565AActive Publication Date: 2025-09-26SUZHOU NUODAJIA AUTOMATION TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing technologies rely on templates and manual threshold strategies for plug-in quality detection, resulting in high deployment costs and impacting production efficiency in an environment with diverse product types and frequent updates.

Method used

A plug-in quality inspection method based on machine vision is adopted. The stitch area is extracted through the agglomerative hierarchical clustering algorithm. The grayscale value and position information of the pixel points are used to construct a position point sequence. The dynamic time warping (DTW) distance is combined to judge the stitch quality. The merging of clusters that do not belong to the same area is avoided, and the boundary line between the stitch and the shell is quickly extracted.

Benefits of technology

There is no need to rely on a large number of standard templates, which improves the accuracy and calculation efficiency of detection, adapts to different plug-in types, reduces system deployment costs, and improves the production efficiency of the production line.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120707565A_ABST
    Figure CN120707565A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to a plug-in quality detection method and system based on machine vision. The method comprises the steps of obtaining a plug-in image, extracting pin areas, constructing position point sequences based on pixel point positions in the pin areas, and judging the pin quality based on the similarity between the position point sequences. The method has the effects of reducing the deployment cost of the detection system and improving the production efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a plug-in quality detection method and system based on machine vision. Background Art

[0002] In the manufacturing process of electronic products such as display devices and industrial control panels, plug-ins are important structures for connecting the main control board and functional components for signal and power transmission. Their quality is directly related to the stability and reliability of the entire machine. Plug-ins usually include a plastic shell and a number of metal pins for electrical connection. Since the production process of plug-ins requires multiple steps such as stamping, injection molding, and assembly, they are easily affected by factors such as mold wear, equipment accuracy fluctuations, and operational errors, which can cause deformation problems such as bending, misalignment, or abnormal spacing of metal pins. If such deformation is not detected in time, it may lead to poor contact, abnormal signal transmission, or even functional failure of the entire machine. Currently, some public technologies have attempted to achieve automated detection of connector pins. For example, the Chinese patent application document with publication number CN114708262A discloses a visual inspection method for connector pins. This solution relies on a combination of template matching and threshold segmentation. First, by setting the ROI area and making a standard pin template, the pins in the inspection image are roughly located. Then, the image threshold segmentation is performed using the maximum inter-class variance method to obtain the pin feature area and calculate the coordinates of each pin center point. Finally, the weighted least squares method is used to fit a straight line to all pin center points, and whether there is an abnormality is determined based on the horizontal and vertical distances between the pins and the standard path.

[0003] When detecting pins in related technologies, it is necessary to rely on templates and manual threshold strategies. Templates need to be constructed based on standard images of products and manually configured according to different products. In the current production environment, product types and specifications are diverse. According to statistics, a complete automated equipment production line will involve more than 1,000 plug-ins. Moreover, with the advancement of technology, plug-ins are frequently updated, and the construction of plug-in templates requires a lot of time and cost, affecting production efficiency. Therefore, the traditional pin detection method has a high system deployment cost in the current environment with frequent product iterations and a wide variety of plug-ins, and is relatively inconvenient during use, affecting the overall production efficiency of the production line. Summary of the Invention

[0004] In order to reduce the deployment cost of the detection system and improve the production efficiency of the production line, this application provides a plug-in quality detection method and system based on machine vision.

[0005] In the first aspect, this application provides a plug-in quality detection method based on machine vision, which adopts the following technical solutions: A plug-in quality detection method based on machine vision includes the following steps: acquiring a plug-in image, extracting a stitch area, constructing a position point sequence based on the pixel position in each stitch area, and judging the stitch quality based on the similarity between each position point sequence; Among them, the step of extracting the stitch area includes: obtaining the position and grayscale value of each pixel in the plug-in image; clustering the pixels using an agglomerative hierarchical clustering algorithm based on the position and grayscale of each pixel, and for 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 difference in pixel point information and cluster centers in the two clusters to be merged; in response to the merging probability being greater than a preset merging threshold, stopping the cluster merging and obtaining the clustering result; extracting the boundary line between the stitch and the shell; determining the stitch cluster based on the position of the cluster center and the boundary line of each cluster in the clustering result, and using the stitch cluster as the stitch area.

[0006] The beneficial effect is that the stitching regions in the plug-in image are extracted and the similarity of the position point sequences formed by the coordinates of the pixel points in the stitching regions is compared to determine whether the stitching is deformed. Under normal circumstances, the stitching regions are parallel, so the position point sequences corresponding to each stitching region have high similarity. If the stitching is deformed, the similarity of the position point sequences will decrease, and this characteristic can be used to determine whether the stitching is defective.

[0007] An agglomerative hierarchical clustering algorithm is used to extract the stitch regions, and a merging probability determination mechanism is introduced during the clustering process. By analyzing the differences between the pixels and cluster centers of the two clusters to be merged, the merge probability is determined. This determines whether the two clusters should be merged in the agglomerative hierarchical clustering algorithm. This prevents clusters belonging to different regions from being forcibly merged, improving the accuracy of stitch region extraction. The stitch regions are then quickly extracted using the boundary between the shell and stitch regions, improving computational efficiency.

[0008] Optionally, the step of obtaining the merging probability of two clusters to be merged based on the difference in pixel point information and cluster centers in the two clusters to be merged includes: obtaining the absolute difference in the grayscale values ​​of the pixel points at the cluster centers of the two clusters to be merged; taking the inverse of the absolute difference in the grayscale values ​​as the initial probability; analyzing the difference in the number of pixel points and gradient direction in the two clusters to be merged, optimizing the initial probability, and obtaining the merging probability.

[0009] 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: smaller grayscale differences indicate greater structural similarity, and larger reciprocals indicate a stronger desire for merging. Conversely, smaller grayscale differences indicate that the two clusters may belong to different physical regions, and the merging probability should be reduced. This reciprocal mapping mechanism expresses a significant tendency toward structural differentiation in a simple computational manner, achieving a good balance between algorithmic efficiency and intuitive judgment. Pixel-level structural information is then introduced to modify the initial probabilities, further enhancing the accuracy of merging probability judgments.

[0010] Optionally, the steps of analyzing the differences in the number of pixel points and gradient directions in the two clusters to be merged and optimizing the initial probability include: calculating the cluster difference based on the difference in the number of pixel points in the two clusters to be merged and the difference in gradient directions in the clusters to be merged; in response to the cluster difference being less than or equal to a preset difference threshold, taking the product of the cluster difference and the initial probability as the merging probability; in response to the cluster difference 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 the historical clusters to be merged, and taking the product of the distance difference and the initial probability as the merging probability.

[0011] The beneficial effect is as follows: In this method, the cluster difference between the two clusters to be merged is first compared based on the number of pixels in the clusters to be merged and the gradient direction of the pixels. If the number of pixels in the two clusters to be merged and the grayscale values ​​of the pixels at the cluster centers are significantly different, it means that the two clusters are inconsistent in quantity and grayscale, which further indicates that the two clusters belong to different areas in the plug-in. For example, the shell and the stitches, if these two areas are not merged without control, will lead to a decrease in the accuracy of the final detection. Therefore, the cluster difference is used to adjust the initial probability, and the merging probability is obtained after reducing the initial probability, which inhibits the merging of clusters. When the number and grayscale of the two clusters to be merged are similar, it means that the two clusters to be merged may belong to the same type of structure, for example, both are stitch areas. However, if the two areas each represent a stitch, then the two areas cannot be merged. Therefore, the distance difference is obtained by analyzing the distance between the two clusters and the distance of the historical clusters to be merged, and then the initial probability is optimized based on the distance difference to obtain the merging probability.

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

[0013] The beneficial effects are: setting the initial probability as the preset merging threshold allows the preset merging threshold to change dynamically without the need for manual setting of empirical parameters, thereby improving system stability and cross-product adaptability, and is especially suitable for manufacturing scenarios with a wide variety of plug-ins and frequent updates.

[0014] Optionally, the ratio of the mean of the distances of the clusters that have been merged historically to the distance between the two clusters to be merged is used as the distance difference.

[0015] The beneficial effect is that the distance between the current clusters to be merged is compared with the distance between the previously merged clusters. If the distance between the two clusters to be merged is greater than the distance between the previously merged clusters, the distance difference will be less than 1, and the initial probability value will be reduced to obtain the merge probability, thus suppressing the merging of the two clusters to be merged.

[0016] Optionally, the step of extracting the boundary line between the stitches and the shell includes: taking the cluster with the largest number of pixel points in the clustering results as the shell cluster; any two pixel points in the shell cluster constitute a matching point pair, based on the position of the pixel points, taking the Euclidean distance between the two pixel points in the matching point pair as the point pair distance, extracting the pixel points in the matching point pair with the largest point pair distance, and connecting the pixel points in pairs to obtain the shell edge line; calculating the preferred degree based on the distance between the edge line and the cluster center of other clusters except the shell cluster, and taking the dividing line with the largest preferred degree as the boundary line.

[0017] The beneficial effect is as follows: Analyzing the plug-in structure shows that the shell area accounts for the largest area, so the cluster with the largest number of pixels is selected as the shell cluster. Then, from the shell cluster, matching point pairs with the largest distance are selected. Based on the plug-in's quadrilateral structure, if the distance between two pixels is the largest, then these two pixels must be located at the corners of the shell area. The dividing line is then determined based on the corner pixels, and the preferred degree of the dividing line is determined based on the distance from the other clusters, thereby determining the boundary between the shell and the stitch area.

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

[0019] Optionally, the step of determining the stitch cluster based on the position of the cluster center and the boundary line of each cluster in the clustering results includes: obtaining a linear equation of the boundary line, for any cluster, substituting the horizontal coordinate of the cluster center of the cluster into the linear equation, obtaining the equation value, comparing the equation value with the vertical coordinate of the cluster center, and in response to the equation value being greater than the vertical coordinate of the cluster center, determining that the cluster is a stitch area.

[0020] Optionally, the step of judging the quality of stitches based on the similarity between each position point sequence includes: for any two stitches forming a stitch pair, obtaining the DTW distance of the position point sequence corresponding to the two stitches in each stitch pair, taking the inverse of the mean of the DTW distance as the similarity between each stitch, and determining that the plug-in is unqualified in response to the similarity between each stitch being less than a preset quality coefficient.

[0021] The beneficial effect is that the dynamic time warping (DTW) distance is used to measure the structural similarity between stitches, and the inverse of the DTW mean is used as the similarity indicator. The plug-in is then compared with a preset quality coefficient to determine whether it is qualified. This solution fully utilizes the global spatial sequence information of the stitches in terms of morphology and structure.

[0022] Secondly, this application provides a plug-in quality inspection system based on machine vision, which adopts the following technical solutions: The plug-in quality detection system based on machine vision includes a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, the plug-in quality detection method based on machine vision is implemented.

[0023] The beneficial effect is that the above-mentioned plug-in quality detection method based on machine vision is generated into a computer program and stored in a memory so as to be loaded and executed by a processor, thereby making a system based on the memory and the processor convenient to use.

[0024] This application has the following technical effects: By extracting the pin regions from the plug-in image and comparing the similarity of position point sequences constructed from the coordinates of multiple pin regions, this method can achieve quality inspection of the pin regions. Compared to traditional inspection technologies, this method does not rely on a large number of standard templates, saving production time and improving adaptability to different plug-ins. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is a flow chart of the method for detecting plug-in quality based on machine vision in this application.

[0026] Figure 2 This is a method flow chart of step S1 of the plug-in quality detection method based on machine vision in this application.

[0027] Figure 3 This is a flow chart of a method for obtaining the merging probability of two clusters to be merged in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The embodiment of the present application discloses a plug-in quality detection method based on machine vision, which obtains a plug-in image and extracts each stitch area in the plug-in. A position point sequence is constructed based on the coordinates of the pixel points in the stitch area, and the stitch quality is judged according to the similarity of each position point sequence. Under normal circumstances, multiple stitches are parallel to each other, and the corresponding position point sequences have a high similarity. If a stitch is deformed, the stitch area will no longer be parallel, which will affect the similarity between the position point sequences. Therefore, the quality of the stitches can be monitored based on this feature. This method is no longer based on a template image, so there is no need to construct a template image when facing a variety of products, which saves time and improves production efficiency.

[0029] Reference Figure 1 The plug-in quality detection method based on machine vision includes steps S1 and S2.

[0030] Step S1: Obtain the plug-in image and extract the pin area.

[0031] Reference Figure 2 , step S1 includes steps S11 to S15.

[0032] S11: Obtain the position and grayscale value of each pixel in the plug-in image.

[0033] During the plug-in production process, the plug-ins are transported on a conveyor belt on the plug-in production line. An industrial camera positioned directly above the conveyor belt photographs the plug-ins on the conveyor belt, capturing a raw image of the plug-ins. This image is then preprocessed to produce a preprocessed image. In this embodiment, the preprocessing steps include median filtering for denoising and grayscale conversion. In other embodiments, denoising methods such as mean filtering and Gaussian filtering can be used. The maximum inter-class variance method is used to determine an image segmentation threshold. The image is segmented based on the segmentation threshold, and the plug-in region in the preprocessed image is extracted to produce a plug-in image.

[0034] The grayscale value and position coordinates of each pixel in the plug-in image are obtained and normalized. The normalization method can be a maximum-minimum normalization method, which is a conventional technical means in this field and will not be described here.

[0035] S12: Cluster the pixels using an agglomerative hierarchical clustering algorithm based on the position and grayscale of each pixel. For any two clusters to be merged corresponding to an iteration in the clustering process, the merging probability of the two clusters to be merged is obtained based on the difference in pixel information and cluster centers in the two clusters to be merged.

[0036] Traditional agglomerative hierarchical clustering algorithms are a bottom-up strategy. They first treat each object as a cluster, calculate the distance between any two clusters, and merge the two clusters with the smallest distance. They then repeatedly calculate the distance between any two clusters and merge them again. The distance between clusters is typically calculated using the distance between the closest points within the cluster (i.e., the Euclidean distance calculated based on location coordinates and grayscale) or the average distance between points in the clusters.

[0037] When this method is applied to image processing, since actual plug-in products usually have multiple pins that are neatly arranged and close together, during clustering based on the agglomerative hierarchical clustering algorithm, there may be two clusters to be merged that are two pin regions. In this case, it is necessary to distinguish between them to avoid merging two different pin regions.

[0038] 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 according to the difference between the two clusters to be merged, and whether the two clusters to be merged should be merged is determined based on the merging probability.

[0039] Reference Figure 3 The step of obtaining the merging probability of two clusters to be merged includes: step S121-step S122.

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

[0041] For two clusters to be merged, the absolute difference of the grayscale values ​​of the pixels corresponding to the cluster centers of the two clusters to be merged is compared. The larger the absolute difference, the less likely it is that the two clusters to be merged belong to the same area. Therefore, the reciprocal of the absolute difference is used as the initial probability.

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

[0043] The steps of analyzing the differences in the number of pixel points and gradient directions in the two clusters to be merged and optimizing the initial probability include: calculating the cluster difference based on the difference in the number of pixel points in the two clusters to be merged and the difference in the gradient directions in the clusters to be merged; in response to the cluster difference being less than or equal to a preset difference threshold, taking the product of the cluster difference and the initial probability as the merging probability; in response to the cluster difference 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 the historical clusters to be merged, and taking the product of the distance difference and the initial probability as the merging probability.

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

[0045] Then, the gradient directions of the pixels in the two clusters to be merged are obtained, and the mean of the corresponding gradient directions in the two clusters to be merged is obtained. The normalized result of the absolute difference between the two means is used as the gradient direction difference of the two clusters to be merged.

[0046] There is no specific requirement for the order in which the gradient direction difference and the quantity difference are calculated. In other embodiments, the gradient direction difference can be calculated first and then the quantity difference. After the gradient direction and quantity differences are calculated, the quantity difference and the gradient direction difference are combined to obtain the clustering difference. Both the quantity difference and the gradient equation difference are positively correlated with the clustering difference.

[0047] Specifically, the calculation formula of cluster difference can be expressed as: Where, Indicates the clustering difference between the two clusters to be merged; Indicates the clusters to be merged The number of pixels in ; Indicates the clusters to be merged The number of pixels in ; Indicates the clusters to be merged The mean value of the gradient direction of the pixel in ; Indicates the clusters to be merged The mean value of the gradient direction of the pixel in ; Indicates the maximum value of the gradient direction of the pixels in the two clusters to be merged, and is used to normalize the absolute difference of the mean gradient direction values; Indicates the total number of pixels in the plug-in image, used to normalize the absolute difference in the number of pixels.

[0048] This formula primarily reflects the difference between the two clusters to be merged, using differences in pixel count and gradient direction, known as cluster dissimilarity. A greater cluster dissimilarity indicates that the two clusters to be merged are more likely to belong to different regions. For example, in a real product, the outer shell and pin area of ​​a plug-in are connected and spatially close, but they differ significantly in pixel count and gradient direction. Therefore, using these dimensions can mitigate these differences and reduce the likelihood of incorrect merging.

[0049] In response to the cluster difference being 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; in response to the cluster difference being 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.

[0050] If the cluster difference is large, it indicates that the two clusters to be merged may belong to different regions. Therefore, in this embodiment, the preset difference threshold is set to 0.6. When the cluster difference is greater than 0.6, the cluster difference is used to optimize the initial probability. In this embodiment, the product of the cluster difference and the initial probability is used as the merger probability.

[0051] When the cluster difference is small, it means that the number of pixels and gradient directions in the two clusters to be merged are similar, and they may belong to two different stitch regions, or they may belong to the region that should be merged. To accurately distinguish between the above two situations, it is necessary to analyze the two clusters to be merged again.

[0052] In the process of using the Agglomerative Hierarchy Analysis Process (AHP) clustering, cluster merging is primarily based on the distance between the two clusters. Therefore, in this embodiment, the difference between the distance between the current 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.

[0053] Specifically, the ratio of the mean of the historical distances of the clusters to be merged to the distances of 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.

[0054] In real-world images, if the pixels in two clusters to be merged belong to the same region, then the two clusters should appear adjacent in space. However, if the two clusters to be merged belong to different stitch regions, although the distance between stitches is also small, it is still significantly different from the case where the clusters are adjacent. Therefore, in the above method, if the two clusters to be merged belong to different stitch regions, then the current distance between the two clusters to be merged must be much greater than the distance between the previously merged clusters, resulting in a lower final merging probability. The merging can then be stopped based on the merging probability.

[0055] S13: In response to the merging probability being greater than the preset merging threshold, the cluster merging is stopped and a clustering result is obtained.

[0056] In this embodiment, the preset merging threshold is equal to the initial probability, that is, the preset merging threshold here is dynamically changing, and the pixel points are adaptively clustered using the dynamic termination merging strategy to improve the accuracy of clustering and facilitate the response to dynamic changes of various plug-in types.

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

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

[0059] In the primary application scenario of this embodiment, the plug-in has an overall rectangular structure, and the pins of the plug-in image captured are located below the housing. The number of pins is generally greater than eight. Analysis of the plug-in structure reveals a clear boundary between the pins and the housing. Extracting this boundary allows for accurate and rapid capture of the pin area.

[0060] The step of extracting the boundary line between the stitches and the shell includes: taking the cluster with the largest number of pixel points in the clustering results as the shell cluster; any two pixel points in the shell cluster constitute a matching point pair, based on the position of the pixel points, taking the Euclidean distance between the two pixel points in the matching point pair as the point pair distance, extracting the pixel points in the matching point pair with the largest point pair distance, and connecting the pixel points in pairs to obtain the edge line of the shell; calculating the preference based on the distance between the edge line and the cluster center of other clusters except the shell cluster, and taking the segmentation line with the largest preference as the boundary line.

[0061] In the plug-in structure, one end of the pin is embedded in the shell and occupies a large area, so the cluster with the largest number of pixels is used as the shell cluster. At the same time, the plug-in shell generally has a regular shape, usually a quadrilateral. For a quadrilateral, the distance between the pixels located at the diagonal corners of the quadrilateral is the largest, so the Euclidean distance between the pixel position coordinates is calculated based on the coordinates of the pixel points to effectively extract the pixels located at the corners in the shell area. In this embodiment, the two pairs of pixels with the largest and second largest Euclidean distances are used as corner pixels. Any two of the four corner pixels can form a sideline when connected.

[0062] Depending on the plug-in's structure, pins make up the largest proportion of all clusters. For example, a plug-in with eight pins might only have 10 to 13 clusters in the clustering results, each consisting of eight pin regions, one shell region, and three to four regions corresponding to characters or other structures on the shell. Since the boundary line is the smallest distance from the pin region, the preference of each segment can be calculated based on the distance between the segment line and the cluster. The segment line with the highest preference is then selected as the boundary line.

[0063] Specifically, the calculation formula of the preference can be expressed as: Where, Indicates the The preference of the dividing lines; Indicates the The dividing line and The vertical distance between the cluster centers of the clusters; represents the total number of clusters other than the shell cluster; Indicates An exponential function with base .

[0064] S15: determining a stitch cluster based on the positions of the cluster centers and the boundary lines of the clusters in the clustering results, and using the stitch cluster as the stitch area.

[0065] Obtain the linear equation of the boundary line. For any cluster, substitute the horizontal coordinate of the cluster center of the cluster into the linear equation to obtain the equation value. Compare the equation value with the vertical coordinate of the cluster center. In response to the equation value being greater than the vertical coordinate of the cluster center, determine that the cluster is a stitch area.

[0066] The boundary line can be represented by a linear equation. The clusters below the boundary line are the clusters corresponding to the stitch area. Therefore, the horizontal coordinates of the cluster centers corresponding to each cluster are substituted into the linear equation to determine the position of the cluster and extract the clusters corresponding to the stitch area.

[0067] S2: constructing a position point sequence based on the pixel position in each stitch area, and judging the stitch quality based on the similarity between each position point sequence.

[0068] For any two pins forming a pin pair, the DTW distance of the position point sequence corresponding to the two pins in each pin pair is obtained, and the inverse of the mean of the DTW distance is used as the similarity between the pins. In response to the similarity between the pins being less than the preset quality coefficient, the plug-in is determined to be unqualified.

[0069] In the process of constructing the position point sequence, the coordinates of all pixels in the stitch area are first extracted, and then arranged from small to large based on the coordinates to form a position point sequence. It can also be understood as starting from the pixel corresponding to the lower left corner of the stitch area, and arranging the position coordinates of the pixels from left to right and from bottom to top. For example, there are six pixels in a stitch area, and the coordinates of the six pixels are: (1,2), (2,2), (1,3), (3,2), (2,3), (3,3), then the corresponding position point sequence is: {(1,2), (1,3), (2,2), (2,3), (3,2), (3,3)}.

[0070] A smaller DTW distance between two pin region cluster point sequences indicates similar shapes and arrangements, indicating good quality. A larger DTW distance indicates dissimilar shapes and arrangements, suggesting deformation (such as bending, offset, or uneven spacing) between the two pin regions, indicating poor quality. In this embodiment, the preset quality coefficient is 0.4. If the calculated pin region similarity is less than 0.4, the current plug-in pin is unqualified.

[0071] An embodiment of the present application also discloses a plug-in quality detection system based on machine vision, including a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, the plug-in quality detection method based on machine vision according to the present application is implemented.

[0072] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface. The configuration and functions of these components are known in the art and will not be described in detail here.

[0073] The above are all preferred embodiments of the present application, and are not intended to limit the scope of protection of the present application. Therefore, any equivalent changes made based on the structure, shape, and principle of the present application should be included in the scope of protection of the present application.

Claims

1. A plug-in quality detection method based on machine vision, characterized in that: Obtain the plug-in image, extract the stitch area, construct a position point sequence based on the pixel position in each stitch area, and judge the stitch quality based on the similarity between each position point sequence; Among them, the step of extracting the stitch area includes: obtaining the position and grayscale value of each pixel in the plug-in image; clustering the pixels using an agglomerative hierarchical clustering algorithm based on the position and grayscale of each pixel, and for 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 difference in pixel point information and cluster centers in the two clusters to be merged; in response to the merging probability being greater than a preset merging threshold, stopping the cluster merging and obtaining the clustering result; extracting the boundary line between the stitch and the shell; determining the stitch cluster based on the position of the cluster center and the boundary line of each cluster in the clustering result, and using the stitch cluster as the stitch area.

2. The plug-in quality detection method based on machine vision according to claim 1, characterized in that: The steps of obtaining the merging probability of two clusters to be merged based on the difference in pixel information and cluster centers of the two clusters to be merged include: obtaining the absolute difference in the grayscale values ​​of the pixels at the cluster centers of the two clusters to be merged; taking the inverse of the absolute difference in the grayscale values ​​as the initial probability; analyzing the difference in the number of pixels and gradient direction in the two clusters to be merged, optimizing the initial probability, and obtaining the merging probability.

3. The plug-in quality detection method based on machine vision according to claim 1, characterized in that: The steps of analyzing the differences in the number of pixel points and gradient directions in the two clusters to be merged and optimizing the initial probability include: calculating the cluster difference based on the difference in the number of pixel points in the two clusters to be merged and the difference in the gradient directions in the clusters to be merged; in response to the cluster difference being less than or equal to a preset difference threshold, taking the product of the cluster difference and the initial probability as the merging probability; in response to the cluster difference 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 the historical clusters to be merged, and taking the product of the distance difference and the initial probability as the merging probability.

4. The plug-in quality detection method based on machine vision according to claim 2, characterized in that: The initial probability of the two clusters to be merged is used as the preset merging threshold.

5. The plug-in quality detection method based on machine vision according to claim 3, characterized in that: The ratio of the mean distance of the clusters that have been merged historically to the distance between the two clusters to be merged is taken as the distance difference.

6. The plug-in quality detection method based on machine vision according to claim 1, characterized in that: The step of extracting the boundary line between the stitches and the shell includes: taking the cluster with the largest number of pixel points in the clustering results as the shell cluster; any two pixel points in the shell cluster constitute a matching point pair, based on the position of the pixel points, taking the Euclidean distance between the two pixel points in the matching point pair as the point pair distance, extracting the pixel points in the matching point pair with the largest point pair distance, and connecting the pixel points in pairs to obtain the shell edge line; calculating the preference based on the distance between the edge line and the cluster center of other clusters except the shell cluster, and taking the segmentation line with the largest preference as the boundary line.

7. The plug-in quality detection method based on machine vision according to claim 6, characterized in that: For each segmentation line, the sum of the vertical distances from the segmentation line to the clusters other than the shell cluster is taken as the total distance. The preference of the segmentation line is obtained based on the total distance, and the total distance is negatively correlated with the preference.

8. The plug-in quality detection method based on machine vision according to claim 1, characterized in that: The steps of determining the stitch cluster based on the positions of the cluster centers and the boundary lines of each cluster in the clustering results include: obtaining a linear equation of the boundary line, substituting the abscissa of the cluster center of any cluster into the linear equation, obtaining the equation value, comparing the equation value with the ordinate of the cluster center, and determining that the cluster is a stitch area in response to the equation value being greater than the ordinate of the cluster center.

9. The plug-in quality detection method based on machine vision according to claim 1, characterized in that: The step of judging the quality of stitches based on the similarity between each position point sequence includes: for any two stitches forming a stitch pair, obtaining the DTW distance of the position point sequence corresponding to the two stitches in each stitch pair, taking the inverse of the mean of the DTW distance as the similarity between each stitch, and determining that the plug-in is unqualified in response to the similarity between each stitch being less than a preset quality coefficient.

10. The plug-in quality detection system based on machine vision is characterized by: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the plug-in quality detection method based on machine vision according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Connector pin detection method based on image features

    CN117372435A

  • Intelligent detection method and system for shaft forgings

    CN119399209A

  • Automobile connector pin detection method and system based on machine vision

    CN120147318A

  • Automobile part positioning method and system for numerical control machine tool machining

    CN120318313A

  • Personalized federal learning method based on evolution clustering

    CN120338139A