Connector pin defect detection method and system based on image processing
By using grayscale characteristic values and fluctuation degree values in the grayscale image of the connector for binary classification, combined with the positional relationship of the target rectangle, the problem of difficulty in accurately detecting connector pin defects in the prior art is solved, and higher detection accuracy and reliability are achieved.
Patent Information
- Application Number
- CN202510600984.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-06-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art is difficult to accurately detect defects in pins in connectors in different scenarios, especially because threshold division is difficult to effectively distinguish between pin parts and housing parts.
By obtaining the grayscale image of the connector pin area, the grayscale characteristic value of the pixel point is determined, and the fluctuation degree value of the pixel row is used for binary classification to determine the pin pixel row. Then, the target edge intersecting the pin pixel row is determined from the grayscale image, the distance between the center of the target rectangle of the pin pixel row to the longitudinal distance and the center of the adjacent target rectangle is calculated, and the defect degree value is calculated to determine whether the pin has a defect.
Accurate distinction between pin and housing pixel rows in the connector pin area is achieved, and the accuracy and reliability of pin defect detection is improved.
Smart Images

Figure CN120147303A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of image data processing, and in particular, to a method and system for detecting connector pin defects based on image processing. Background Art
[0002] A connector is an electronic component that can achieve electrical connection between two components in a circuit. There are pins on the socket of the connector, and the pins in one component can cooperate with the slots in the other component for inserting the pins to achieve electrical connection between the two components.
[0003] Pins are usually made of copper, copper alloy or other conductive metals. Pins can provide good electrical conductivity and corrosion resistance, and can simultaneously achieve electrical connection, signal transmission and mechanical fixation between components in the circuit, ensuring stable connection between different electronic devices or components.
[0004] When installing or removing the connection between two components by the connector, the pins in the connector may be bent or broken due to excessive external force; frequent plugging and unplugging of the connector may also cause wear on the contact surface between the pins and the socket; the pins of the connector may also become loose due to vibration or thermal cycling.
[0005] A connector with defective pins will affect or make it difficult to effectively achieve electrical connection between two components. For example, when the charging interface or charger where the pins are located supplies power to a device, the power supply to the device will decrease or the power supply to the device will be directly disconnected. Therefore, it is necessary to detect the possible defects in the pins of the connector.
[0006] Since the brightness of the pins of the connector is higher than that of the housing part in the connector, in the related art, threshold segmentation can be performed on the surface image of the pins of the connector to determine the detection of possible defects in the pins of the connector. However, threshold segmentation may be difficult to effectively distinguish between the pin part and the housing part in different scenarios. Therefore, it is difficult to accurately detect the defects in the pins of the connector. Summary of the Invention
[0007] To overcome the problem that it is difficult to accurately detect the defects in the pins of the connector in the related art, this application provides a method and system for detecting connector pin defects based on image processing.
[0008] According to the first aspect of the embodiments of the present application, a method for detecting defects of connector pins based on image processing is provided, including: obtaining a grayscale image of the pin area of the connector to be detected, and determining the grayscale feature value of the pixel points in the grayscale image; the grayscale feature value is used to characterize the significance degree of the pixel points in the grayscale image, and the pins in the pin area are arranged horizontally; determining the variance of the distances between adjacent edge pixel points in the pixel rows of the grayscale image, and using the average value of the grayscale feature values of the pixel points in the pixel rows to adjust the variance of the distances to obtain the fluctuation degree value of the pixel rows; using the fluctuation degree value of the pixel rows to perform binary classification on the pixel rows of the grayscale image, determining the pin pixel rows in the grayscale image, and determining the target edge intersecting with the pin pixel rows from the grayscale image, and taking the minimum circumscribed rectangle of the target edge as the target rectangle; according to the longitudinal distance from the center of the target rectangle of the pin pixel row to the pin pixel row, and the distance between the centers of the adjacent target rectangles corresponding to the pin pixel rows, determining the defect degree value of the grayscale image to determine whether there are defects in the pins in the pin area.
[0009] It can better distinguish between the pixel rows including pins and the pixel rows all being the housing in the pin area, so as to determine whether there are defects in the pins of the connector.
[0010] Optionally, the grayscale feature value of the pixel points is determined in the following manner: for the target pixel point in the grayscale image, subtracting the grayscale value of the target pixel point from the average grayscale value of the grayscale image to obtain a difference value, and determining the ratio of the difference value to the maximum grayscale value in the grayscale image; using the sigmoid function to normalize the ratio to obtain the grayscale feature value of the target pixel point.
[0011] Optionally, using the average value of the grayscale feature values of the pixel points in the pixel row to adjust the variance of the distances to obtain the fluctuation degree value of the pixel row includes: , where T is the fluctuation degree value of the pixel row, exp is the exponential function with the natural constant as the base, is the variance of the distances between adjacent edge pixel points in the pixel row, a is a first positive number, W is the number of pixel points in the pixel row of the grayscale image, is the variance of the grayscale feature values of the pixel points in the pixel row, is a second positive number, is the average value of the grayscale feature values of the pixel points in the pixel row.
[0012] Optionally, the pixel rows of the grayscale image are dichotomized using the fluctuation degree values of the pixel rows to determine the pin pixel rows in the grayscale image, including: clustering the fluctuation degree values of different pixel rows to obtain two clustered categories; taking the category with a higher average value of the fluctuation degree values among the two obtained clustered categories as the target category where the pins are located, and taking the pixel rows corresponding to the fluctuation degree values belonging to the target category as the pin pixel rows in the grayscale image.
[0013] In this way, by clustering the pixel rows with fluctuation degree values in the grayscale image, the distinction between the pin pixel rows and non-pin pixel rows in the grayscale image is realized, which is convenient for determining whether there are defects in the pins in the grayscale image.
[0014] Optionally, the pixel rows of the grayscale image are dichotomized using the fluctuation degree values of the pixel rows to determine the pin pixel rows in the grayscale image, including: taking the pixel rows with fluctuation degree values greater than a preset fluctuation degree threshold in the grayscale image as the pin pixel rows in the grayscale image; the preset fluctuation degree threshold is determined according to the ranking information of the fluctuation degree values of different pixel rows in the grayscale image.
[0015] Optionally, the defect degree value of the grayscale image is determined by the following method: determining the longitudinal offset feature value of the pins in the grayscale image according to the vertical distance from the center of the target rectangle of the pin pixel rows in the grayscale image to the pin pixel rows; determining the lateral offset feature value of the pins in the grayscale image according to the distance between the centers of the adjacent target rectangles corresponding to the pin pixel rows in the grayscale image; the lateral offset feature value is used to characterize the difference degree of the distances between the adjacent target rectangles corresponding to the pin pixel rows; taking the product of the longitudinal offset feature value and the lateral offset feature value as the defect degree value of the grayscale image.
[0016] In this way, by determining the offsets of the pins in the grayscale image in the longitudinal and lateral directions respectively, the defect degree value of the grayscale image is determined, and the defect degree value can more effectively characterize the degree of abnormality of the pins in the connector.
[0017] Optionally, the longitudinal offset feature value is determined by the following method: , where is the longitudinal offset feature value, is to take the maximum value, H is the number of pin pixel rows in the grayscale image, is the number of target rectangles corresponding to the t-th pin pixel row, is the ordinate of the center of the j-th target rectangle corresponding to the t-th pin pixel row, is the ordinate of the t-th pin pixel row, is to take the absolute value.
[0018] In this way, the obtained longitudinal offset eigenvalue can better characterize the degree of longitudinal offset of the pins in the connector, so as to realize the automatic identification of defects at the initial stage when there are abnormalities in the pins of the connector.
[0019] Optionally, the lateral offset eigenvalue is determined by the following method: , where is the lateral offset eigenvalue, max is to take the absolute value, H is the number of pixel rows of the pins in the grayscale image, exp is the exponential function with the natural constant as the base, and are respectively the minimum and maximum values of the distances between the centers of the adjacent target rectangles corresponding to the t-th pixel row of the pins, and are respectively the minimum and maximum values of the aspect ratios of the target rectangles corresponding to the t-th pixel row of the pins, is the fluctuation degree value of the t-th pixel row of the pins.
[0020] Optionally, determining whether there are defects in the pins in the pin area includes: when the defect degree value is greater than or equal to a preset defect degree threshold, determining that there are defects in the pins in the pin area; or, when the defect degree value is less than the preset defect degree threshold, determining that there are no defects in the pins in the pin area.
[0021] In this way, it is possible to simply and effectively determine whether there are defective pins in the connector according to the defect degree value of the grayscale image.
[0022] According to the second aspect of the embodiments of the present application, a connector pin defect detection system based on image processing is provided, including: a processor and a memory, the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the steps of the connector pin defect detection method based on image processing provided in the first aspect of the present application are implemented.
[0023] The technical solutions provided by the embodiments of the present application may include the following beneficial effects: determining the fluctuation degree value of the pixel rows in the grayscale image of the pin area of the connector, and using the fluctuation degree value of the pixel rows to perform binary classification on the pixel rows of the grayscale image to determine the pixel rows of the pins in the grayscale image, which can better distinguish between the pixel rows including the pins and the pixel rows all being the housing in the pin area; determining the target edge intersecting with the pixel rows of the pins from the grayscale image, and taking the minimum circumscribed rectangle of the target edge as the target rectangle; according to the longitudinal distance from the center of the target rectangle of the pixel row of the pins to the pixel row of the pins, and the distances between the centers of the adjacent target rectangles corresponding to the pixel row of the pins, determining the defect degree value of the grayscale image, which can more accurately determine whether there are defects in the pins in the pin area by using the defect degree value.
[0024] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and do not limit this application. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 is a flowchart of a method for detecting connector pin defects based on image processing shown according to an exemplary embodiment; Figure 2 is a schematic structural diagram of a system for detecting connector pin defects based on image processing shown according to an exemplary embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0026] First, a brief introduction to the application scenario of the embodiments of this application is given. In the application scenario of this application, since the brightness of the connector pins is higher than that of the housing part in the connector, in the related art, threshold segmentation can be used to determine the connector pins and determine whether there are defects in the connector pins. However, it is difficult to effectively determine the pins in different connectors through threshold segmentation. Therefore, it is difficult to accurately detect the defects of the pins in the connector.
[0027] To solve the above technical problems, the embodiments of this application provide a method and system for detecting connector pin defects based on image processing. Figure 1 is a flowchart of a method for detecting connector pin defects based on image processing shown according to an exemplary embodiment, as Figure 1 shown, the method includes the following steps.
[0028] In step S101, a grayscale image of the pin area of the connector to be detected is obtained, and the grayscale feature values of the pixel points in the grayscale image are determined.
[0029] An image acquisition device can be used to collect images along the direction where the connector pins are located to obtain a grayscale image of the pin area of the connector to be detected. In the grayscale image, the pins in the pin area are arranged horizontally.
[0030] The pins in the connector usually show a relatively regular arrangement when there are no defects; for example, the horizontal distances between different pins in the same row of the connector are relatively consistent, or the vertical distances between different pins in the same column of the connector are relatively consistent.
[0031] To facilitate the detection of pin defects in the pin area, when collecting images, the arrangement direction of the connector pins can be placed parallel to the horizontal direction; or, the collected image can be rotated or cropped so that the pins in the obtained grayscale image are arranged horizontally in the pin area.
[0032] Among them, the pins in the pin area are arranged horizontally, which means that compared with the number of pins in the same column where the pins are located, the number of pins in the same row where the pins are located is larger.
[0033] The gray feature value of a pixel point in a grayscale image is used to characterize the significance degree of the pixel point in the grayscale image; compared with the housing part of the connector, the pins in the connector have a higher brightness, so that the significance degree of the pins in the grayscale image is higher than that of the housing part in the grayscale image; the gray feature value of a pixel point in the grayscale image can characterize the probability that the pixel point belongs to a pin.
[0034] In one embodiment, the gray feature value of a pixel point is determined in the following manner: for a target pixel point in the grayscale image, subtract the gray value of the target pixel point from the average gray value of the grayscale image to obtain a difference value, and determine the ratio of the difference value to the maximum gray value in the grayscale image; use the sigmoid function to normalize the ratio to obtain the gray feature value of the target pixel point.
[0035] Subtracting the gray value of the target pixel point from the average gray value of the grayscale image to obtain a difference value and determining the ratio of the difference value to the maximum gray value in the grayscale image can eliminate the influence of the difference in the gray scale range of different images on the comparison result, so that the gray feature value can adapt to a more diverse gray scale range. Therefore, it is convenient to use the gray feature value to more stably reflect the significance degree of the pixel point in the grayscale image in more diverse scenarios.
[0036] By the ratio of the difference value to the maximum gray value in the grayscale image, it can be ensured that the ratio is less than or equal to, and using the sigmoid function to normalize the ratio can ensure that the value after normalization is within the range of 0 to 1, ensuring the comparability of the gray feature values.
[0037] For example, for a pixel point whose pixel value in the grayscale image is less than the average gray value, the pixel point is more likely to be a pixel point where the housing part of the connector is located in the grayscale image. A smaller difference value can be determined for the pixel point, so as to determine a smaller gray feature value. Therefore, a smaller gray feature value can be determined for a pixel point with a lower probability of belonging to a pin in the grayscale image.
[0038] In this way, by comparing the gray value of the pixel point with the average gray value in the grayscale image, the obtained gray feature value can reflect the relative size of the gray value of the pixel point and the gray level of the grayscale image. Compared with the gray value of the pixel point, the gray feature value of the pixel point can better characterize the probability that the pixel point belongs to a pin.
[0039] In step S102, the variance of the distances between adjacent edge pixel points in a pixel row of the grayscale image is determined, and the average value of the grayscale feature values of the pixel points in the pixel row is used to adjust the variance of the distances to obtain the fluctuation degree value of the pixel row.
[0040] When there are no abnormalities such as bending or breakage in the pins of the connector, the distances between adjacent pins of the connector are highly consistent; for example, for a row including 10 pins in the connector, the distances between any two of the 10 pins are usually equal.
[0041] Taking the first 3 pins among the 10 pins as an example, when there are no abnormalities in the first 3 pins among the 10 pins, the distance from the first pin to the second pin among the 10 pins is usually equal to the distance from the second pin to the third pin among the 10 pins.
[0042] When there are abnormalities in the first 3 pins among the 10 pins, the distance from the first pin to the second pin among the 10 pins may be greater than or less than the distance from the second pin to the third pin among the 10 pins.
[0043] A pixel row in the grayscale image includes multiple pixel points located in the same row. In the grayscale image of the pins of the connector, since the pixel row where the pins are located may simultaneously include the pixel points where the pins are located and the pixel points where the housing part is located, and the grayscale feature values of the pixel points where the pins are located are higher than the grayscale feature values of the pixel points where the housing part is located, therefore, the grayscale feature value of the pixel row where the pins are located is higher than the grayscale feature value of the pixel row where the housing is located, and the difference between the grayscale feature values of different pixel points in the pixel row where the pins are located is higher than the difference between the grayscale feature values of different pixel points in the pixel row where the housing part is located.
[0044] Since the difference between the grayscale feature values of different pixel points in the pixel row where the pins are located is higher, and the grayscale feature value of the pixel row where the pins are located is higher, therefore, the average value of the grayscale feature values of the pixel points in the pixel row can be used to adjust the variance of the distances, further increasing the difference between the pixel row where the pins are located and the pixel row where the housing part is located, so as to more easily determine the pixel row where the pins are located from the grayscale image.
[0045] In one embodiment, using the average value of the grayscale feature values of the pixel points in the pixel row to adjust the variance of the distances to obtain the fluctuation degree value of the pixel row includes: , where T is the fluctuation degree value of the pixel row, exp is the exponential function with the natural constant as the base, is the variance of the distances between adjacent edge pixel points in the pixel row, a is a first positive number, and W is the number of pixel points in the pixel row of the grayscale image. is the variance of the gray feature values of the pixel points in the pixel row, is a second positive number, is the average value of the gray feature values of the pixel points in the pixel row.
[0046] The first positive number and the second positive number can be set according to actual needs; for example, the first positive number can be between 7 and 10, and the second positive number can be between 2 and 4.
[0047] There is usually a certain interval between adjacent pins in the connector, so that the pixel row where the pin is located in the grayscale image includes both the pin and the housing part of the connector, and the gray value of the pixel point where the pin is located in the grayscale image is higher than the gray value of the pixel point where the housing part is located. Therefore, the edge in the grayscale image is more likely to be the edge where the pin is located in the grayscale image, making the distance between the edges in the grayscale image more likely to correspond to the distance between the pins in the grayscale image.
[0048] Since the distance between the edges in the grayscale image is more likely to correspond to the distance between the pins in the grayscale image, the consistency of the distance between adjacent edges in the grayscale image can characterize the probability that there are no abnormalities such as missing or bent pins in the connector.
[0049] Since the variance of the distance between adjacent edge pixels in the pixel row of the grayscale image is negatively correlated with the consistency of the distance between adjacent edges in the grayscale image, the variance of the distance between adjacent edge pixels in the pixel row of the grayscale image can characterize the probability that there are abnormalities such as missing or bent pins in the connector.
[0050] Therefore, the average value of the gray feature values of the pixel points in the pixel row of the image and the variance of the gray feature values can be used to adjust the variance of the distance in the pixel row to obtain the fluctuation degree value of the pixel row. Compared with the difference between the variance of the distance between adjacent edge pixels in the pin pixel row of the grayscale image and the variance of the distance between adjacent edge pixels in the housing part pixel row of the grayscale image, the difference between the fluctuation degree value of the pin pixel row of the grayscale image and the fluctuation degree value of the housing pixel row of the grayscale image is greater. Through the fluctuation degree value of the pixel row, it is possible to better distinguish between the pixel row where the pin is located and the pixel row where the housing is located.
[0051] Since the distance between adjacent pins in the same row has higher periodicity, when the variance of the distance between adjacent edge pixels in the pixel row is smaller, the periodicity of the distance between edge pixels in the pixel row is stronger, and the pixel row is more likely to be the pixel row where the pin is located in the grayscale image.
[0052] Compared with the pixel row where the housing with black color is located, the gray-scale feature values of the pixel row where the pins are located are more diverse. Therefore, the degree of difference in the gray-scale feature values of the pixel points in the pixel row where the pins are located is higher. Therefore, the higher the degree of difference in the gray-scale feature values of the pixel points in the pixel row, the more likely the pixel row is the pixel row where the pins are located in the grayscale image.
[0053] The larger the average value of the gray-scale feature values of the pixel points in the pixel row, the more likely the pixel row is the pixel row where the pins are located in the grayscale image; in the embodiments of the present application, is used as the exponential term, and the average value of the gray-scale feature values of the pixel points in the pixel row is larger, and a smaller value of can be determined.
[0054] It can be the result of normalizing the variance of the gray-scale feature values of the pixel points in the pixel row to the range of 0 to 1, so that takes a value between 0 and 1. When using a smaller exponential term to perform an exponential operation on the base term within the range of 0 to 1, the value of the obtained exponential operation result is larger. Therefore, when the average value of the gray-scale feature values of the pixel points in the pixel row is larger, a larger value of the fluctuation degree can be determined, and a higher fluctuation degree value is determined for the pixel row with a higher probability of belonging to the pins.
[0055] In this way, by using the average value of the gray-scale feature values of the pixel points in the pixel row to adjust the variance of the distance to obtain the fluctuation degree value of the pixel row, the contrast between the pixel row where the pins are located and the pixel row where the housing is located in the grayscale image can be further improved, so as to distinguish between the pixel row where the pins are located and the pixel row where the housing is located in the grayscale image.
[0056] In step S103, the pixel rows of the grayscale image are binary-classified by using the fluctuation degree value of the pixel row, the pin pixel rows in the grayscale image are determined, and the target edge intersecting with the pin pixel rows is determined from the grayscale image, and the minimum circumscribed rectangle of the target edge is used as the target rectangle.
[0057] Since the fluctuation degree value of the pixel row where the pins are located in the grayscale image is different from the fluctuation degree value of the pixel row where the housing of the grayscale image is located, therefore, by using the fluctuation degree value of the pixel row, all the pixel rows of the grayscale image can be binary-classified to obtain the pin pixel rows and non-pin pixel rows in the grayscale image. The non-pin pixel rows include the pixel rows where all the pixel points are of the housing part, and the pin pixel rows refer to the pixel rows including at least one pixel point of the pins.
[0058] In one embodiment, binary classification is performed on the pixel rows of a grayscale image using the fluctuation degree values of the pixel rows to determine the pin pixel rows in the grayscale image, including: clustering the fluctuation degree values of different pixel rows to obtain two clustered categories; taking the category with a higher average value of the fluctuation degree values among the two obtained clustered categories as the target category where the pins are located, and taking the pixel rows corresponding to the fluctuation degree values belonging to the target category as the pin pixel rows in the grayscale image.
[0059] The clustering of the fluctuation degree values of different pixel rows can be achieved through clustering algorithms such as the K-means clustering algorithm, hierarchical clustering algorithm, and mean shift clustering, clustering multiple fluctuation degree values of all pixel rows in the corresponding grayscale image into two categories.
[0060] Since the fluctuation degree value of the pixel row where the pins are located is higher than that of the pixel row where the housing is located, therefore, the category with a higher fluctuation degree value among the two obtained clustered categories can be taken as the category where the pin pixel rows in the grayscale image are located to determine the pin pixel rows in the grayscale image.
[0061] In this way, by clustering the pixel rows with fluctuation degree values in the grayscale image, the pin pixel rows in the grayscale image can be determined to check whether there are defects in the pins in the grayscale image.
[0062] In one embodiment, binary classification is performed on the pixel rows of a grayscale image using the fluctuation degree values of the pixel rows to determine the pin pixel rows in the grayscale image, including: taking the pixel rows with fluctuation degree values greater than a preset fluctuation degree threshold in the grayscale image as the pin pixel rows in the grayscale image; the preset fluctuation degree threshold is determined according to the ranking information of the fluctuation degree values of different pixel rows in the grayscale image.
[0063] For example, the preset fluctuation degree threshold can refer to the fluctuation degree values ranked in the top 20% to top 30% in the grayscale image to achieve the screening of the pixel rows with higher fluctuation degree values in the grayscale image.
[0064] Since the fluctuation degree value of the pixel row where the pins are located in the grayscale image is greater than that of the pixel row where the housing is located, therefore, taking the pixel rows with fluctuation degree values greater than the preset fluctuation degree threshold in the grayscale image as the pin pixel rows in the grayscale image can simply and effectively determine the pin pixel rows from the grayscale image to check whether there are defects in the pins of the connector.
[0065] Since there are differences in the grayscale values between the pins and the housing in the grayscale image, and the pins appear as individual circles or rectangles in the grayscale image, the edges determined from the grayscale image of the connector are more likely to correspond to the pins in the grayscale image. By determining the target edges that intersect the pixel rows of the pins from the grayscale image, these edges can be analyzed in the same pixel row.
[0066] To facilitate the user in inserting and removing the pins of the connector, the sizes of the different pins set in the connector usually have a high degree of consistency. When there are no bends or missing pins in the connector, the shapes of the pins shown in the grayscale image have a high degree of consistency. Therefore, taking the minimum bounding rectangle of the target edge as the target rectangle, the target rectangle can reflect the shape characteristics of the pins, and the target rectangle can be used to further determine whether there are any abnormalities in the pins in the grayscale image.
[0067] In step S104, according to the vertical distance from the center of the target rectangle of the pin pixel row to the pin pixel row, and the distance between the centers of the adjacent target rectangles corresponding to the pin pixel row, the defect degree value of the grayscale image is determined to determine whether there are any defects in the pins in the pin area.
[0068] When there are no abnormalities in the pins of the connector, the distances between adjacent pins in the connector have a high degree of consistency; while when there are abnormalities in the pins of the connector, the pins of the connector may have lateral offsets, vertical offsets or be missing, resulting in a reduction in the original consistency of the distances between adjacent pins in the connector. Therefore, it is possible to determine whether there are any defects in the pins at least according to the vertical distance from the center of the target rectangle of the pin pixel row to the pin pixel row.
[0069] In one embodiment, the defect degree value of the grayscale image is determined in the following manner: according to the vertical distance from the center of the target rectangle of the pin pixel row in the grayscale image to the pin pixel row, the vertical offset feature value of the pins in the grayscale image is determined; according to the distance between the centers of the adjacent target rectangles corresponding to the pin pixel row in the grayscale image, the lateral offset feature value of the pins in the grayscale image is determined; the lateral offset feature value is used to characterize the degree of difference in the distances between the adjacent target rectangles corresponding to the pin pixel row; the product of the vertical offset feature value and the lateral offset feature value is taken as the defect degree value of the grayscale image.
[0070] When there are abnormalities in the pins of the connector, the pins may be offset in at least one of the lateral and vertical directions, or the pins may be missing, resulting in a change in the distance between two adjacent pins. Therefore, the lateral offset feature value and the vertical offset feature value of the pins in the grayscale image can be determined, and thus the defect degree value of the grayscale image can be determined according to the lateral offset feature value and the vertical offset feature value of the pins in the grayscale image.
[0071] The longitudinal offset feature value of the pin in the grayscale image is used to characterize the degree of offset of the pin in the grayscale image in the longitudinal direction; the lateral offset feature value of the pin in the grayscale image can be used to characterize the degree of offset of the pin in the grayscale image in the lateral direction.
[0072] In this way, by determining the longitudinal offset feature value and the lateral offset feature value of the pin in the grayscale image, and taking the product of the longitudinal offset feature value and the lateral offset feature value as the defect degree value of the grayscale image, the defect degree value can more effectively characterize the degree of abnormality of the pin in the connector.
[0073] In one embodiment, the longitudinal offset feature value is determined by the following method: , where is the longitudinal offset feature value, is to take the maximum value, H is the number of rows of pin pixels in the grayscale image, is the number of target rectangles corresponding to the t-th row of pin pixels, is the ordinate of the center of the j-th target rectangle corresponding to the t-th row of pin pixels, is the ordinate of the t-th row of pin pixels, is to take the absolute value.
[0074] Comparing the ordinate of the center of the target rectangle corresponding to the row of pin pixels with the ordinate of the row of pin pixels can reflect the longitudinal distance from the center of the target rectangle of the row of pin pixels in the grayscale image to the row of pin pixels; the greater the longitudinal distance from the center of the target rectangle of the row of pin pixels in the grayscale image to the row of pin pixels, the deeper the degree of longitudinal offset of the row of pin pixels.
[0075] Taking the ordinate of the center of the j-th target rectangle corresponding to the t-th row of pin pixels as the denominator can achieve the normalization processing of the calculation result, and in the embodiments of the present application, taking the maximum value of different value results can capture the longitudinal offset situation of the row of pin pixels with the most serious longitudinal offset in the grayscale image, and can realize the identification of defects at the early stage when there is an abnormality in the pins of the connector, which helps to process the connector with abnormal pins as early as possible.
[0076] In this way, the obtained longitudinal offset feature value can better characterize the degree of offset of the pin in the connector in the longitudinal direction, and through the maximum value function, it helps to realize the automatic identification of defects at the initial stage when there is an abnormality in the pins of the connector.
[0077] In one embodiment, the lateral offset feature value is determined by the following method: , where is the horizontal offset eigenvalue, max is to take the absolute value, H is the number of stitch pixel rows in the grayscale image, and exp is the exponential function with the natural constant as the base. and are respectively the minimum and maximum values of the distances between the centers of adjacent target rectangles corresponding to the t-th stitch pixel row. and are respectively the minimum and maximum values of the aspect ratios of the target rectangles corresponding to the t-th stitch pixel row. is the fluctuation degree value of the t-th stitch pixel row.
[0078] For the stitch pixel rows selected from all pixel rows of the grayscale image, the fluctuation degree value of the stitch pixel row can characterize the degree to which the fluctuations of the stitches in the stitch pixel row are periodic; the greater the degree to which the fluctuations of the stitches in the stitch pixel row are periodic, the lower the degree of abnormality of the stitches in the stitch pixel row. Therefore, the smaller the fluctuation degree value of the stitch pixel row, the higher the degree of abnormality of the stitches in the stitch pixel row, and a higher horizontal offset eigenvalue can be determined for the stitch pixel row.
[0079] Since the target rectangle corresponding to the stitch pixel row can reflect the shape characteristics of a certain stitch located in the stitch pixel row; through the aspect ratio of the target rectangle corresponding to the stitch pixel row, the shape characteristics of the stitches located in the stitch pixel row can be reflected; the aspect ratios of different target rectangles corresponding to the same stitch pixel row may be different.
[0080] By the ratio of the minimum value of the aspect ratios of the target rectangles corresponding to the stitch pixel row to the maximum value of the aspect ratios of the target rectangles corresponding to the stitch pixel row, the consistency of the shape characteristics of different target rectangles corresponding to the same stitch pixel row can be reflected, thereby reflecting the consistency of the shape characteristics of different stitches located in the same stitch pixel row.
[0081] The higher the consistency of the shape characteristics of different stitches in the same stitch pixel row, the lower the degree of horizontal offset in the stitch pixel row, and the lower the probability or degree of abnormality of the stitches in the stitch pixel row. Therefore, a smaller horizontal offset eigenvalue can be determined.
[0082] The distance between the centers of adjacent target rectangles corresponding to the stitch pixel row can reflect the distance between adjacent stitches in the same stitch pixel row; by the ratio between the minimum value of the distances between the centers of adjacent target rectangles corresponding to the stitch pixel row and the maximum value of the distances between the centers of adjacent target rectangles corresponding to the stitch pixel row, the consistency of the distances between adjacent stitches in the same stitch pixel row can be reflected.
[0083] The higher the consistency of the distances between adjacent pins in the same pin pixel row, the lower the degree or probability of lateral offset of the pins located in the same pin pixel row, and a smaller lateral offset eigenvalue can be determined.
[0084] By operating on the maximum value in the lateral offset eigenvalue, the pin pixel row with the most obvious abnormality in the horizontal direction in the grayscale image can be found, so as to timely detect the abnormality existing in the pins of the connector.
[0085] In this way, through the distance between the centers of adjacent target rectangles corresponding to the pin pixel row and the aspect ratio of the target rectangle corresponding to the pin pixel row, the consistency of the distances between adjacent pins in the pin pixel row and the consistency of the shape features of different pins can be combined, so as to better evaluate the abnormality existing in the horizontal direction of the pins in the pin pixel row by using the lateral offset eigenvalue.
[0086] In one embodiment, determining whether there are defects in the pins in the pin area includes: when the defect degree value is greater than or equal to the preset defect degree threshold, determining that there are defects in the pins in the pin area; or, when the defect degree value is less than the preset defect degree threshold, determining that there are no defects in the pins in the pin area.
[0087] Since the defect degree value is determined according to the lateral offset eigenvalue and the longitudinal offset eigenvalue of the grayscale image, the defect degree value can better characterize the degree of abnormality of the pins in the connector. When the defect degree value is greater than or equal to the preset defect degree threshold, it indicates that at least one pin in the connector has a defect. In order to facilitate timely processing of the defective pins, it can be determined that there are defective pins in the connector of the pin.
[0088] Since the defect degree value is determined according to the pin with the highest probability of having a defect in the grayscale image, when the defect degree value is less than the preset defect degree threshold, it indicates that the pin with the highest probability of having a defect also has no defect, and it can be determined that there are no defects in the pins in the pin area.
[0089] The preset defect degree threshold can be determined according to actual needs; for example, when the value range of the defect degree value is between 0 and 1, the preset defect degree threshold can be between 0.4 and 0.6.
[0090] In this way, when determining the defect degree value according to the grayscale image of the pins of the connector, it is possible to simply and effectively determine whether there are defective pins in the connector, so as to process the defective pins and prevent the connector with defective pins from being put into use.
[0091] Figure 2It is a schematic structural diagram of a connector pin defect detection system 1000 based on image processing shown according to an exemplary embodiment. Refer to Figure 2 , the connector pin defect detection system 1000 based on image processing includes: a processor 1100 and a memory 1200. The memory 1200 stores computer program instructions, and when the computer program instructions are executed by the processor 1100, all or part of the steps of the connector pin defect detection method based on image processing in the present application are implemented.
[0092] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include well-known common general knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and embodiments are only regarded as exemplary.
[0093] It should be understood that the present application is not limited to the exact structure already described and shown in the drawings, and various modifications and changes can be made without departing from its scope.
Claims
1. A connector pin defect detection method based on image processing, characterized in that: include: Obtaining a grayscale image of the pin area of the connector to be inspected, and determining grayscale feature values of pixels in the grayscale image; The grayscale feature value is used to characterize the prominence of a pixel point in a grayscale image, and the stitches in the stitch area are arranged in a horizontal direction; Determine the variance of the distance between adjacent edge pixels in a pixel row of the grayscale image, and adjust the variance of the distance using the average value of the grayscale characteristic values of the pixels in the pixel row to obtain a fluctuation degree value of the pixel row; The pixel rows of the grayscale image are classified into two categories using the fluctuation degree values of the pixel rows, the stitch pixel rows in the grayscale image are determined, and the target edge intersecting with the stitch pixel rows is determined from the grayscale image, and the minimum circumscribed rectangle of the target edge is used as the target rectangle; The defect degree value of the grayscale image is determined based on the longitudinal distance from the center of the target rectangle of the stitch pixel row to the stitch pixel row, and the distance between the centers of adjacent target rectangles corresponding to the stitch pixel row, so as to determine whether the stitches in the stitch area are defective.
2. The connector pin defect detection method based on image processing according to claim 1, characterized in that: The grayscale eigenvalue of a pixel is determined in the following way: For a target pixel in the grayscale image, subtract the grayscale value of the target pixel from the average grayscale value of the grayscale image to obtain a difference, and determine the ratio of the difference to the maximum grayscale value in the grayscale image; The ratio is normalized using a sigmoid function to obtain the grayscale feature value of the target pixel.
3. The connector pin defect detection method based on image processing according to claim 1, characterized in that: The average value of the grayscale characteristic value of the pixel points in the pixel row is used to adjust the variance of the distance to obtain the fluctuation degree value of the pixel row, including: , T is the fluctuation value of the pixel row, exp is an exponential function with a natural constant as the base, is the variance of the distances between adjacent edge pixels in a pixel row, a is the first positive number, W is the number of pixels in a pixel row of the grayscale image, is the variance of the grayscale eigenvalues of the pixels in the pixel row, is the second positive number, is the average value of the grayscale eigenvalues of the pixels in the pixel row.
4. The connector pin defect detection method based on image processing according to claim 1, characterized in that: The pixel rows of the grayscale image are classified into two categories using the fluctuation degree values of the pixel rows to determine the stitch pixel rows in the grayscale image, including: Cluster the fluctuation degree values of different pixel rows to obtain two clustered categories; The category with a higher average value of the fluctuation degree of the two categories obtained after clustering is taken as the target category where the stitches are located, and the pixel rows corresponding to the fluctuation degree values belonging to the target category are taken as the stitch pixel rows in the grayscale image.
5. The connector pin defect detection method based on image processing according to claim 1, characterized in that: The pixel rows of the grayscale image are classified into two categories using the fluctuation degree values of the pixel rows to determine the stitch pixel rows in the grayscale image, including: The pixel rows in the grayscale image whose fluctuation degree values are greater than a preset fluctuation degree threshold are used as stitch pixel rows in the grayscale image; the preset fluctuation degree threshold is determined based on ranking information of fluctuation degree values of different pixel rows in the grayscale image.
6. The connector pin defect detection method based on image processing according to claim 1, characterized in that: The defect level value of the grayscale image is determined in the following way: Determine a longitudinal offset characteristic value of the stitch in the grayscale image according to a longitudinal distance from a center of a target rectangle of the stitch pixel row in the grayscale image to the stitch pixel row; Determine a lateral offset characteristic value of the stitches in the grayscale image according to the distance between the centers of adjacent target rectangles corresponding to the stitch pixel rows in the grayscale image; The lateral offset feature value is used to characterize the degree of difference in distance between adjacent target rectangles corresponding to the stitch pixel rows; The product of the longitudinal offset eigenvalue and the lateral offset eigenvalue is used as the defect degree value of the grayscale image.
7. The connector pin defect detection method based on image processing according to claim 6, characterized in that: The longitudinal offset characteristic value is determined as follows: ,in, is the longitudinal offset characteristic value, To obtain the maximum value, H is the number of pin pixel rows in the grayscale image, is the number of target rectangles corresponding to the t-th stitch pixel row, is the ordinate of the center of the jth target rectangle corresponding to the tth stitch pixel row, is the ordinate of the t-th stitch pixel row, To take the absolute value.
8. The connector pin defect detection method based on image processing according to claim 6, characterized in that: The lateral offset characteristic value is determined as follows: ,in, is the lateral offset eigenvalue, max is the absolute value, H is the number of stitch pixel rows in the grayscale image, exp is the exponential function with the natural constant as the base, as well as are the minimum and maximum distances between the centers of adjacent target rectangles corresponding to the t-th stitch pixel row, as well as are the minimum and maximum values of the aspect ratio of the target rectangle corresponding to the t-th stitch pixel row, respectively. is the fluctuation degree value of the tth stitch pixel row.
9. The connector pin defect detection method based on image processing according to claim 1, characterized in that: Determine if there are any defects in the stitching in the stitching area, including: When the defect level value is greater than or equal to the preset defect level threshold, it is determined that the stitches in the stitch area are defective; or, when the defect level value is less than the preset defect level threshold, it is determined that the stitches in the stitch area are not defective.
10. A connector pin defect detection system based on image processing, characterized in that: 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 connector pin defect detection method based on image processing according to any one of claims 1 to 9 is implemented.