Automatic detection method of connector pins based on machine vision
Based on the automatic detection method based on machine vision, the polar pixels and twists and turns indexs in the pins image are analyzed, and the problem that the existing technology is difficult to identify the small flaws is solved, and the precise detection of the needle deficiency is achieved, which improves security.
Patent Information
- Application Number
- CN202411266650.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-09-11
AI Technical Summary
The existing pin quality detection methods are difficult to accurately identify small defects or defects with inconspicuous characteristics, resulting in connectors with crack defects being put into use, which may cause circuit short circuits, fires and other safety accidents.
Adopt the automatic detection method based on machine vision, analyze the linear reflective trend of the polar pixels in each connecting domain by obtaining the ash image of the needle, calculate the twisting index and the average consistency coefficient, build a scoring of cracks to achieve the cracks Precision detection of defects.
It achieves accurate detection of small defects and defects with unobvious features in pins, improves detection accuracy and avoids safety hazards.
Smart Images

Figure CN118781115B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image detection technology, and in particular to a method for automatically detecting connector pins based on machine vision. Background Art
[0002] With the advancement of intelligent manufacturing and industrialization, machine vision technology plays an indispensable role in the quality control of automated production lines. As a conductor device used to interconnect electrical circuits, connectors simplify the assembly process of electronic products and build a bridge for isolated circuits to communicate. Due to their easy installation, disassembly and maintenance, they are widely used in various electrical circuits. As an important component of the connector, the quality of the pin directly affects the stability and reliability of the entire electrical system.
[0003] Traditional pin quality inspection methods often rely on physical contact or fixed template comparison, which is difficult to meet the needs of modern production for high-precision, high-speed and large-scale online inspection. Although some existing pin quality inspection methods have achieved automated inspection, automated inspection methods can only detect pins with obvious defect characteristics. For small flaws or defects with less obvious characteristics, such as cracks caused by stress on the pins during the assembly process, the existing automated inspection algorithms cannot accurately identify them, resulting in connectors with crack defects being put into use. When a connector pin with a crack defect is connected to current, the effective conductive area at the crack will be reduced, the contact resistance will increase, and local hot spots will be formed. In the case of long-term use, severe overheating will also cause circuit short circuits, fires and other safety accidents. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides a connector pin automatic detection method based on machine vision to solve the existing problems.
[0005] The automatic detection method of connector pins based on machine vision in this application adopts the following technical solutions:
[0006] An embodiment of the present application provides a method for automatically detecting connector pins based on machine vision, the method comprising the following steps:
[0007] Obtain a connector pin grayscale image of the connector pin to be inspected, and use region segmentation to obtain each connected domain in the connector pin grayscale image;
[0008] Obtain the straight line reflection trend of each extreme pixel point in each connected domain according to the relationship between the gray values of the pixel points; obtain the tortuosity index according to the straight line reflection trend;
[0009] The monotonicity of the tortuosity index sequence and each fixed window is obtained according to the size relationship between the tortuosity indexes; the mean consistency coefficient of the tortuosity index sequence is obtained according to the size of the tortuosity index in the fixed window;
[0010] A crack presence score of the connector pin to be inspected is obtained according to the monotonicity degree and the mean consistency coefficient; a defect judgment value is obtained according to the crack presence score; and the connector pin to be inspected is inspected according to the defect judgment value.
[0011] Furthermore, the step of obtaining the straight line reflection trend of each extreme pixel point in each connected domain according to the relationship between the gray values of the pixel points includes:
[0012] For each connected domain in the grayscale image of the connector pin, all pixels with the largest grayscale values in the connected domain are taken as extreme pixel points; a square area with each extreme pixel point as the center and a side length of a preset side length is taken as a neighborhood window of each extreme pixel point; the mean and standard deviation of the grayscale values of each row of pixels in the neighborhood window are calculated;
[0013] Obtain the pixel value decreasing regularity index of each extreme pixel point in each connected domain according to the mean of the grayscale values of each row of pixel points in the neighborhood window of each extreme pixel point;
[0014] For the neighborhood window of each extreme pixel point in each connected domain, the row where the extreme pixel point is located in the neighborhood window is recorded as the center window row, the mean of all the standard deviations in the neighborhood window is calculated, and the difference between the mean and the standard deviation of the pixel points in the center window row in the neighborhood window is calculated as the first difference, and the sum of the first difference and the pixel value decreasing law exponent of the extreme pixel point is taken as the straight line reflection trend of each extreme pixel point in each connected domain.
[0015] Furthermore, the method for obtaining the pixel value decreasing law index is:
[0016] For each extreme pixel point in each connected domain, the mean of the grayscale values of all pixels in the middle row of the neighborhood window of the extreme pixel point is taken as the central grayscale mean;
[0017] For the neighborhood window of extreme pixel points, each row above the middle row is used as the upper neighborhood row in the neighborhood window, each row below the middle row is used as the lower neighborhood row in the neighborhood window, and the upper neighborhood row and the lower neighborhood row symmetrical based on the central row are used as a pair of symmetrical neighborhood rows;
[0018] Calculate the mean of the grayscale values of the pixels of each upper neighborhood row as the upper neighborhood grayscale mean of each upper neighborhood row, calculate the mean of the grayscale values of the pixels of each lower neighborhood row as the lower neighborhood grayscale mean of each lower neighborhood row, calculate the ratio of the central grayscale mean to the grayscale mean of each upper neighborhood row as the second ratio of each upper neighborhood row, and calculate the ratio of the central grayscale mean to the grayscale mean of each lower neighborhood row as the third ratio of each lower neighborhood row;
[0019] For each symmetric neighborhood row, the absolute value of the difference between the second ratio of the upper neighborhood row and the third ratio of the lower neighborhood row is calculated as the first absolute value of the difference; and the sum of all the first absolute values of the difference in the neighborhood window of the extreme pixel point is used as the pixel value decreasing law index of each extreme pixel point in each connected domain.
[0020] Further, the obtaining of the tortuosity index according to the straight line reflection trend includes:
[0021] According to the straight line reflection trend, the pin connected domain in the gray image of the connector pin is obtained; the edge pixel points in the pin connected domain are obtained using the edge detection algorithm;
[0022] Use a curve fitting algorithm to fit all edge pixels to obtain a fitting curve;
[0023] For each edge pixel point on the fitting curve, a tangent line of the fitting curve is drawn on the edge pixel point, the angle between the tangent lines of any two adjacent edge pixel points is obtained, and the radian value corresponding to the angle is calculated;
[0024] The tortuosity index is positively correlated with the arc value, and negatively correlated with the Euclidean distance between any two adjacent edge pixel points.
[0025] Further, the method of obtaining the pin connected domain in the grayscale image of the connector pin according to the straight line reflection trend includes:
[0026] For each connected domain, if the number of extreme pixel points in the connected domain is 1, the preset value is used as the internal reflection consistency of each connected domain;
[0027] If the number of extreme pixel points in the connected domain is greater than 1, the mean of the straight-line reflection trends of all extreme pixel points in the connected domain is calculated, the absolute value of the difference between the straight-line reflection trend of each extreme pixel point in the connected domain and the mean is calculated, and the mean of all the absolute values of the difference in the connected domain is taken as the internal reflection consistency of each connected domain;
[0028] The connected domain with the minimum internal reflection consistency is regarded as the pin connected domain.
[0029] Further, the step of obtaining the monotonicity of the tortuosity index sequence and each fixed window according to the magnitude relationship between the tortuosity indexes includes:
[0030] Sort the tortuosity indexes between any two adjacent edge pixel points on the fitting curve in order to construct a tortuosity index sequence;
[0031] Divide the meander index sequence into a preset number of subsequences, and take the maximum value in each subsequence as the local maximum value in the meander index sequence;
[0032] Construct a fixed window with a preset length, wherein the preset length is an odd number, place each local maximum at the center of the fixed window, and a window consisting of a preset number of elements before the local maximum in the fixed window is a left window of the local maximum, and a window consisting of a preset number of elements after the local maximum is a right window of the local maximum;
[0033] For the left window of each fixed window, the difference between each element in the left window and its next adjacent element is calculated as the fourth difference of each element, the maximum value between the fourth difference of each element and the number 0 is obtained as the left maximum value of each element, and the sum of all the left maximum values in the left window is calculated as the first sum;
[0034] For the right window of each fixed window, calculate the difference between the next adjacent element of each element in the right window and each element as the fifth difference of each element, obtain the maximum value between the fifth difference of each element and the number 0 as the right maximum value of each element, and calculate the sum of all the right maximum values in the right window as the second sum;
[0035] The sum of the first sum value and the second sum value is used as the monotonicity of each fixed window.
[0036] Further, the method for obtaining the mean consistency coefficient is:
[0037] For each fixed window of the meander index sequence, the mean of the meander index of the left window of the fixed window is calculated as the first meander index, and the mean of the meander index of the right window of the fixed window is calculated as the second meander index;
[0038] For all fixed windows in the meander index sequence, the mean of the first meander means of the left windows of all fixed windows is calculated as the left meander mean, and the mean of the second meander means of the right windows of all fixed windows is calculated as the right meander mean;
[0039] For each fixed window of the meander index sequence, the absolute value of the difference between the first meander mean of the fixed window and the left meander mean is calculated as the first meander difference absolute value, and the absolute value of the difference between the second meander mean of the fixed window and the right meander mean is calculated as the second meander difference absolute value;
[0040] The mean consistency coefficient is positively correlated with the absolute value of the first inflection difference, and is positively correlated with the absolute value of the second inflection difference.
[0041] Further, the method of obtaining the crack presence score of the connector pin to be tested according to the monotonicity and the mean consistency coefficient includes:
[0042] Calculate the sum of the monotonicity of all fixed windows in the pin connectivity domain, calculate the result of an exponential function with a natural constant as the base and the sum as the exponent, and calculate the product of the calculation result and the mean consistency coefficient of the tortuosity index sequence in the pin connectivity domain as the crack presence score of the connector pin to be tested.
[0043] Further, the step of obtaining a defect determination value according to the crack existence score includes:
[0044] The same method as the crack existence score of the connector pin to be inspected is used to calculate the crack existence score of the pin connected domain in the connector pin grayscale image of the connector pin of qualified quality as the qualified crack existence score;
[0045] The normalized value of the absolute value of the difference between the crack presence score of the connector pin to be inspected and the qualified crack presence score is calculated as the defect judgment value.
[0046] Further, the testing of the connector pin to be tested according to the defect determination value includes:
[0047] If the defect judgment value is greater than the preset threshold, it is determined that a crack defect has occurred in the connector pin; otherwise, the connector pin is of qualified quality and no crack defect has occurred.
[0048] This application has at least the following beneficial effects:
[0049] This application analyzes the material difference between the pin and the connector housing, builds internal reflective consistency based on the reflective features of different materials and pins, and more accurately locates the pin connectivity domain in the connector pin. The tortuosity index is built based on the curve fitted by the edge pixel points of the pin connectivity domain, and then a fixed window is created by analyzing the features of the pin top, and the monotonicity and mean consistency coefficient of the fixed window are built. Based on this, a crack existence score is built, which achieves accurate detection of crack defects and makes up for the deficiency of existing algorithms that can only detect defects with obvious features but cannot accurately detect crack defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0051] Figure 1 A flowchart of a method for automatically detecting connector pins based on machine vision provided in one embodiment of the present application;
[0052] Figure 2 A defect determination value acquisition flow chart provided for one embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to further explain the technical means and effects adopted by the present application to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation method, structure, features and effects of the automatic detection method of connector pins based on machine vision proposed in the present application in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0054] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
[0055] The specific scheme of the automatic detection method of connector pins based on machine vision provided by the present application is described in detail below with reference to the accompanying drawings.
[0056] An embodiment of the present application provides a method for automatically detecting connector pins based on machine vision. Specifically, the following method for automatically detecting connector pins based on machine vision is provided. Figure 1 , the method comprises the following steps:
[0057] Step S001, collecting connector pin images through a CCD camera, and preprocessing the collected images.
[0058] A CCD camera is used to capture the connector pin image of the connector pin to be inspected, and the acquired image is preprocessed. Since some interference noise is inevitable during the image capture and transmission process, this noise will not only reduce the image quality, but also block the key features in the image, affecting the subsequent image processing. Therefore, in order to reduce noise interference and improve image quality, this embodiment uses median filtering to perform denoising on the connector pin image.
[0059] The connector pin image after noise removal is converted into a grayscale image, which is recorded as connector pin grayscale image A. Then, Canny edge detection is used to perform edge detection on the connector pin grayscale image A to obtain edge pixel points in the connector pin grayscale image A.
[0060] Since the grayscale value of the pin is usually quite different from that of the connector housing and the background area, the 5 pixels with the largest grayscale value, the 5 pixels with the smallest grayscale value, and the 5 pixels with the grayscale value equal to the average grayscale value of the image in the connector pin grayscale image A are used as initial seed points. During the growth process, for each growth point and the surrounding adjacent points, the opposite of the grayscale value difference between the two pixels is calculated as the similarity value, and then the obtained similarity value is normalized. When the normalized similarity value is lower than the similarity threshold, the growth is stopped. In this embodiment, the similarity threshold is 0.9. The connected domains of the connector pin grayscale image A are obtained to complete the preprocessing of the image.
[0061] The region growing algorithm and the Canny edge detection algorithm are well-known technologies and will not be described in detail here.
[0062] Step S002, construct the internal reflective consistency through the reflective features of the pin and the connector shell, and locate the pin area; then construct the tortuosity index according to the curve fitted by the edge pixel points of the pin area; then create a fixed window according to the characteristics of the pin top, and construct the monotonicity and mean consistency coefficient of the fixed window, and finally construct a crack existence score to judge the possibility of crack existence.
[0063] In the design of electronic connectors, in order to ensure the effective transmission of current and the stable transmission of signals, the pins are usually made of metal materials with good conductivity, such as brass and copper alloys. The surfaces of these metal materials are usually characterized by high smoothness to reduce contact resistance, improve current transmission efficiency and signal integrity; at the same time, the highly smooth surface can also help the connector reduce friction during the plug-in and unplug process, prevent the pins from wearing too quickly, and extend the service life. Therefore, in the images taken with a CCD camera, the degree of reflection on the pin surface is relatively consistent and continuous. In contrast, non-conductive materials such as plastic shells used to fix the pins and provide support in the connector mainly limit the current inside the pins, effectively preventing short circuits and other safety hazards. Due to differences in physical properties, the degree of reflection of non-conductive materials in the image is quite different from that of metal pins, and the consistency of their reflection is poor.
[0064] By analyzing the reflective characteristics of the pins and non-conductive materials, it is noted that the metal pins with smooth surfaces will have a relatively obvious horizontal, continuous, straight reflective strip, while the non-conductive materials have poor reflective effects and it is difficult to form a continuous reflective strip on their surface.
[0065] Taking the i-th connected domain in the grayscale image of the connector pin as an example, there may be pixels in the connected domain with the same grayscale value and all of them are maximum values. The grayscale values of all pixels in the i-th connected domain are traversed and all pixels with the largest grayscale values are taken as the extreme pixel points of the i-th connected domain. For each extreme pixel point, a square neighborhood window with a side length of aa is constructed with each extreme pixel point as the center. In this embodiment, the value of aa is 5.
[0066] In this embodiment, the extreme pixel point Take the extreme pixel point as an example. The neighborhood window of is recorded as neighborhood window R, and each row of the neighborhood window R from top to bottom is recorded as window row R1, R2, R3, R4, and R5, among which window row R3 is taken as the central window row of the neighborhood window.
[0067] If the connected domain i is the connected domain where the pin is located, then the extreme pixel point It must be located on the reflective strip. Since the reflective strip of the connected domain where the pin is located is a horizontal straight line, the grayscale value difference between all pixels in window row R3 is very small, and the standard deviation of the grayscale value of all pixels in window row R3 is obtained; similarly, the standard deviation of the grayscale value of pixels in window rows R1, R2, R4, and R5 can be obtained.
[0068] At the same time, as the distance from the center window row R3 increases, that is, when the pixel moves from R3 to R1 or R5, the grayscale value of the pixel shows a regular decreasing trend, and the decreasing trend has a large similarity, that is, the grayscale value of the pixel in R3 is the largest, and then decreases upward and downward respectively with a certain trend. The pixel value decreasing regularity index of each extreme pixel in each connected domain is calculated, and the acquisition method is as follows:
[0069] For each extreme pixel point in each connected domain, the mean of the grayscale values of all pixels in the middle row of the neighborhood window of the extreme pixel point is taken as the central grayscale mean.
[0070] For the neighborhood window of extreme pixel points, the rows above the middle row are used as upper neighborhood rows in the neighborhood window, the rows below the middle row are used as lower neighborhood rows in the neighborhood window, and the upper neighborhood rows and lower neighborhood rows symmetrical based on the central row are used as a pair of symmetric neighborhood rows.
[0071] The mean of the grayscale values of the pixels of each upper neighboring row is calculated as the upper neighboring grayscale mean of each upper neighboring row, the mean of the grayscale values of the pixels of each lower neighboring row is calculated as the lower neighboring grayscale mean of each lower neighboring row, the ratio of the central grayscale mean to the grayscale mean of each upper neighboring row is calculated as the second ratio of each upper neighboring row, and the ratio of the central grayscale mean to the grayscale mean of each lower neighboring row is calculated as the third ratio of each lower neighboring row.
[0072] For each symmetric neighborhood row, the absolute value of the difference between the second ratio of the upper neighborhood row and the third ratio of the lower neighborhood row is calculated as the first absolute value of the difference; and the sum of all the first absolute values of the difference in the neighborhood window of the extreme pixel point is used as the pixel value decreasing law index of each extreme pixel point in each connected domain.
[0073] Furthermore, the linear reflection trend of each extreme pixel point in each connected domain is obtained according to the pixel value decreasing law index, and the acquisition method is:
[0074] For the neighborhood window of each extreme pixel point in each connected domain, the row where the extreme pixel point is located in the neighborhood window is recorded as the center window row, the mean of all the standard deviations in the neighborhood window is calculated, and the difference between the mean and the standard deviation of the pixel points in the center window row in the neighborhood window is calculated as the first difference, and the sum of the first difference and the pixel value decreasing law exponent of the extreme pixel point is taken as the straight line reflection trend of each extreme pixel point in each connected domain.
[0075] Specifically, if the connected domain i is a pin-connected domain, then the pixel point It must be located on the reflective strip, then the grayscale value of the center window row R3 in the upper and lower directions decreases more consistently, and the value of the pixel value decreasing law index is smaller. At the same time, because the reflective strip on the pin area is distributed in a horizontal straight line state, if the difference in the grayscale value of the pixel points in R3 is smaller, it will also lead to a smaller difference in the grayscale value of the pixel points in R1, R2, R4, and R5, that is, the standard deviation of the grayscale value is smaller, and the value of the straight-line reflective trend is also smaller. At this time, the smaller the value of the straight-line reflective trend, the greater the possibility that the neighborhood window R is located on the reflective strip in the pin.
[0076] Traverse and calculate the linear reflection trend of all extreme pixel points in each connected domain. Obtain the internal reflection consistency of each connected domain. The acquisition method is:
[0077] For each connected domain, the mean of the straight-line reflection trends of all extreme pixel points is calculated as the first mean, the absolute value of the difference between the straight-line reflection trend of each extreme pixel point and the first mean is calculated as the second absolute value of the difference, and the mean of all the second absolute values of the difference in each connected domain is calculated as the second mean.
[0078] For each connected domain, if the number of extreme pixel points in the connected domain is 1, the preset value is used as the internal reflection consistency of each connected domain; if the number of extreme pixel points in the connected domain is greater than 1, the second mean is used as the internal reflection consistency of each connected domain.
[0079] If the connected domain i is a pin connected domain, then according to the metal reflective characteristics of the pin, the extreme pixel point must be located on the reflective strip, and because the surface of the pin is smooth and has no obvious texture features, the straight-line reflective trend value of the extreme pixel point on the reflective strip is relatively consistent, and the value of the internal reflective consistency is small; because the surface of the non-conductive material is not smooth and is not made of metal, the reflective effect is not good and a continuous reflective strip cannot be formed. Therefore, the value difference of the straight-line reflective trend between each extreme pixel point in the connected domain of the non-conductive material is large.
[0080] At this point, the internal reflection consistency of the connected domain is obtained, and the difference between the pin connected domain and other connected domains can be accurately distinguished. The internal reflection consistency of all connected domains is traversed and calculated. The connected domain with the smallest internal reflection consistency value is the pin connected domain.
[0081] By analyzing the difference in features between the pin edge and the crack edge, it is found that the edge profile of the pin has a high degree of consistency and regularity. Therefore, when performing curve fitting on the pixel points on the pin edge, the degree of curvature between adjacent data points on the curve corresponding to adjacent pixel points of the pin body will show a relatively significant similarity. Even at the top of the pin, the degree of curvature changes, but there will be a certain regularity. On the contrary, the crack edge shows the characteristics of distortion and irregularity, with many turning points around it. Therefore, the degree of curvature between adjacent data points on the curve corresponding to adjacent pixel points of the crack will show a relatively significant difference.
[0082] The position coordinates of all edge pixels in the pin connectivity domain in the connector pin grayscale image are used as input, where the origin of the coordinate system is the center point of the connector pin grayscale image, and a curve fitting algorithm is used to fit all edge pixels to obtain a fitting curve. The least squares method is a well-known technique and will not be described in detail in this embodiment. The least squares method is used in this embodiment, and the implementer may select other curve fitting algorithms according to actual conditions.
[0083] Take any edge pixel point B on the curve as the current sampling point, and take the previous edge pixel point adjacent to edge pixel point B as the previous sampling point A of edge pixel point B. Draw the tangents of the previous sampling point A and the current sampling point B on the fitting curve, and obtain the angle between the tangents of the previous sampling point A and the sampling point B. Calculate the tortuosity index from the previous sampling point A to the current sampling point B, and the method for obtaining it is:
[0084] For each edge pixel point on the fitting curve, a tangent line of the fitting curve is drawn on the edge pixel point, the angle between the tangent lines of any two adjacent edge pixel points is obtained, and the radian value corresponding to the angle is calculated.
[0085] For each edge pixel point on the fitting curve, a tangent line of the fitting curve is drawn on the edge pixel point, the angle between the tangent lines of any two adjacent edge pixel points is obtained, and the radian value corresponding to the angle is calculated.
[0086] The tortuosity index is positively correlated with the arc value, and negatively correlated with the Euclidean distance between any two adjacent edge pixel points.
[0087] It should be noted that the positive correlation may be a multiplication, addition, or idempotent relationship of an exponential function, and the negative correlation may be a division, subtraction, or the like, which may be determined based on actual conditions and will not be elaborated in this application.
[0088] Specifically, the present application proposes an embodiment, which is as follows:
[0089] The ratio of the arc value to the Euclidean distance between any two adjacent edge pixel points is calculated as the tortuosity index between any two adjacent edge pixel points.
[0090] At this time, when the value of the tortuosity index is large, it means that the angle of the curve turning within the distance between sampling points A and B changes greatly, so the tortuosity index of this section is high; if the value of the tortuosity index is small, it means that the curve between sampling points A and B is relatively straight, and the tortuosity index is low.
[0091] Since the top of the pin is usually sharp, the tortuosity index value in the pin top area is relatively large, and reaches the maximum at the top. At the same time, the tortuosity index near the pin top also shows regularity: when transitioning from the main part of the pin to the top, the tortuosity index will show a gradual increase trend; and after crossing the top and returning to the main part, it will follow a certain regularity to decrease; when calculating the tortuosity index of a pin top area, there is only one local maximum value, and the value of the current point is greater than the values of the previous point and the next point.
[0092] All the tortuosity indices on the fitting curve are sorted in order to construct a tortuosity index sequence.
[0093] Divide the tortuosity index sequence into subsequences, in this embodiment The value of is 10, and the maximum value in each subsequence is taken as the local maximum value in the tortuosity index sequence.
[0094] With each local maximum as the center, a fixed window of length v is constructed. In this embodiment, the value of v is 21. Each local maximum is placed at the center of the fixed window. The first 10 positions of the fixed window are the left window of the local maximum, and the last ten positions are the right window of the local maximum. When the number of elements in the left window or the right window is less than 10, zeros are added to the window to make up 10 elements.
[0095] If the pin does not have a crack defect, then according to the change characteristics of the tortuosity index at the top of the pin, in all fixed windows, the element data values of the left window of the local maximum value have an increasing law, and the element data values of the right window have a decreasing law; and because the tortuosity index corresponding to the crack is large and has no regular distribution, it will not have monotonicity on one or both sides of the fixed window. Take the hth fixed window as an example, calculate the monotonicity of its window, and the method of obtaining it is:
[0096] For the left window of each fixed window, the difference between each element in the left window and its next adjacent element is calculated as the fourth difference of each element, the maximum value between the fourth difference of each element and the number 0 is obtained as the left maximum value of each element, and the sum of all the left maximum values in the left window is calculated as the first sum.
[0097] For the right window of each fixed window, the difference between the next adjacent element of each element in the right window and each element is calculated as the fifth difference of each element, the maximum value between the fifth difference of each element and the number 0 is obtained as the right maximum value of each element, and the sum of all the right maximum values in the right window is calculated as the second sum.
[0098] The sum of the first sum value and the second sum value is used as the monotonicity of each fixed window.
[0099] If the value of the monotonicity of the fixed window is 0, it proves that the left and right windows in the fixed window are monotonic, which is consistent with the zigzag index distribution characteristics corresponding to the top of the pin; if the value of the monotonicity of the fixed window is not 0, it means that there is no monotonicity on one side of a fixed window, which is consistent with the crack characteristics.
[0100] Traverse all fixed windows, calculate the monotonicity of each window, and record the sum of the monotonicity of all windows as the first monotonic sum value.
[0101] Since the size of each pin on a connector is the same, the mean of the left window of all fixed windows should have a large consistency. Similarly, the mean of the right window should also have a large consistency. The mean consistency coefficient of the zigzag index sequence is calculated as follows:
[0102] For each fixed window of the meander index sequence, the mean of the meander index of the left window of the fixed window is calculated as the first meander index, and the mean of the meander index of the right window of the fixed window is calculated as the second meander index.
[0103] For all fixed windows in the zigzag index sequence, the mean of the first zigzag means of the left windows of all fixed windows is calculated as the left zigzag mean, and the mean of the second zigzag means of the right windows of all fixed windows is calculated as the right zigzag mean.
[0104] For each fixed window of the meander index sequence, the absolute value of the difference between the first meander mean of the fixed window and the left meander mean is calculated as the first meander difference absolute value, and the absolute value of the difference between the second meander mean of the fixed window and the right meander mean is calculated as the second meander difference absolute value.
[0105] The mean consistency coefficient is positively correlated with the absolute value of the first inflection difference, and is positively correlated with the absolute value of the second inflection difference.
[0106] It should be noted that the positive correlation relationship can be an idempotent relationship of multiplication, addition, or exponential function, which can be determined based on actual conditions and will not be elaborated in this application.
[0107] Specifically, the present application proposes an embodiment, the method is:
[0108] The sum of the absolute values of all the first meandering differences in the meandering index sequence is calculated as the first meandering sum, the sum of the absolute values of all the second meandering differences in the meandering index sequence is calculated as the second meandering sum, and the mean of the first meandering sum and the second meandering sum is taken as the mean consistency coefficient of the meandering index sequence.
[0109] If the value of the mean consistency coefficient of the tortuosity index sequence is smaller, it means that the mean consistency on the left side and the mean consistency on the right side of all fixed windows are higher, which is consistent with the distribution characteristics of the tortuosity index at the top of the pin; if the value of the mean consistency coefficient of the tortuosity index sequence is larger, it means that in the fixed window, the mean on the left or right side is significantly different from the mean of other fixed windows, which is consistent with the distribution characteristics of the tortuosity index corresponding to the crack.
[0110] The crack existence score is constructed by the monotonicity degree and the mean consistency coefficient. The acquisition method is:
[0111] The crack existence score is positively correlated with the first monotonic sum value and is positively correlated with the mean consistency coefficient.
[0112] It should be noted that the positive correlation may be a multiplication, addition, or idempotent relationship of an exponential function, and the negative correlation may be a division, subtraction, or the like, which may be determined based on actual conditions and will not be elaborated in this application.
[0113] Specifically, the present application proposes an embodiment, the method is:
[0114] A calculation result of an exponential function with the natural constant e as the base and the first monotonic sum as the exponent is calculated, and a product of the calculation result and the mean consistency coefficient is calculated as a crack presence score of the connector pin to be detected.
[0115] Specifically, if there is no defect on the edge of the pin, then according to the zigzag index distribution characteristics corresponding to the top of the pin, the value of the first monotonic sum is 0, the mean consistency coefficient is small, and the value of the crack presence score of the connector pin to be tested is small; if a crack exists, the value of the crack presence score of the connector pin to be tested is large.
[0116] Step S003 , detecting connector pins in combination with the grayscale image of standard connector pins.
[0117] In order to achieve more accurate detection of the grayscale image of the connector pin, this embodiment will perform analysis based on connector pins of qualified quality.
[0118] By using the calculation principle and calculation formula of the crack existence score in the present embodiment, the crack existence score of the pin connected domain in the connector pin grayscale image of the connector pin with qualified quality is calculated as the qualified crack existence score.
[0119] Construct the defect judgment value, and obtain it by:
[0120] The normalized value of the absolute value of the difference between the crack existence score of the pin connected domain and the qualified crack existence score is calculated as the defect judgment value.
[0121] Among them, the defect judgment value acquisition flow chart is as follows Figure 2 shown.
[0122] When the defect judgment value When the value is greater than the threshold of 0.5, it is determined that a crack defect has occurred in the connector pin and the connector needs to be repaired, thereby realizing automatic detection of the connector pin. The value of the threshold can be set by the implementer according to the actual situation.
[0123] It should be noted that the above sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above is a description of a specific embodiment of this specification. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0124] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0125] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Modifications to the technical solutions recorded in the aforementioned embodiments, or equivalent replacement of some of the technical features therein, do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for automatically detecting connector pins based on machine vision, characterized in that: The method comprises the following steps: Obtain a connector pin grayscale image of the connector pin to be inspected, and use region segmentation to obtain each connected domain in the connector pin grayscale image; Obtain the straight line reflection trend of each extreme pixel point in each connected domain according to the relationship between the gray values of the pixel points; obtain the tortuosity index according to the straight line reflection trend; The monotonicity of the tortuosity index sequence and each fixed window is obtained according to the size relationship between the tortuosity indexes; the mean consistency coefficient of the tortuosity index sequence is obtained according to the size of the tortuosity index in the fixed window; A crack presence score of the connector pin to be inspected is obtained according to the monotonicity degree and the mean consistency coefficient; a defect judgment value is obtained according to the crack presence score; and the connector pin to be inspected is inspected according to the defect judgment value.
2. The method for automatic detection of connector pins based on machine vision according to claim 1, characterized in that: The step of obtaining the straight line reflection trend of each extreme pixel point in each connected domain according to the relationship between the gray values of the pixel points includes: For each connected domain in the grayscale image of the connector pin, all pixels with the largest grayscale values in the connected domain are taken as extreme pixel points; a square area with each extreme pixel point as the center and a side length of a preset side length is taken as a neighborhood window of each extreme pixel point; the mean and standard deviation of the grayscale values of each row of pixels in the neighborhood window are calculated; Obtain the pixel value decreasing regularity index of each extreme pixel point in each connected domain according to the mean of the grayscale values of each row of pixel points in the neighborhood window of each extreme pixel point; For the neighborhood window of each extreme pixel point in each connected domain, the row where the extreme pixel point is located in the neighborhood window is recorded as the center window row, the mean of all the standard deviations in the neighborhood window is calculated, and the difference between the mean and the standard deviation of the pixel points in the center window row in the neighborhood window is calculated as the first difference, and the sum of the first difference and the pixel value decreasing law exponent of the extreme pixel point is taken as the straight line reflection trend of each extreme pixel point in each connected domain.
3. The method for automatic detection of connector pins based on machine vision according to claim 2, characterized in that: The method for obtaining the pixel value decreasing law index is: For each extreme pixel point in each connected domain, the mean of the grayscale values of all pixels in the middle row of the neighborhood window of the extreme pixel point is taken as the central grayscale mean; For the neighborhood window of extreme pixel points, each row above the middle row is used as the upper neighborhood row in the neighborhood window, each row below the middle row is used as the lower neighborhood row in the neighborhood window, and the upper neighborhood row and the lower neighborhood row symmetrical based on the central row are used as a pair of symmetrical neighborhood rows; Calculate the mean of the grayscale values of the pixels of each upper neighborhood row as the upper neighborhood grayscale mean of each upper neighborhood row, calculate the mean of the grayscale values of the pixels of each lower neighborhood row as the lower neighborhood grayscale mean of each lower neighborhood row, calculate the ratio of the central grayscale mean to the grayscale mean of each upper neighborhood row as the second ratio of each upper neighborhood row, and calculate the ratio of the central grayscale mean to the grayscale mean of each lower neighborhood row as the third ratio of each lower neighborhood row; For each symmetric neighborhood row, the absolute value of the difference between the second ratio of the upper neighborhood row and the third ratio of the lower neighborhood row is calculated as the first absolute value of the difference; and the sum of all the first absolute values of the difference in the neighborhood window of the extreme pixel point is used as the pixel value decreasing law index of each extreme pixel point in each connected domain.
4. The method for automatic detection of connector pins based on machine vision according to claim 1, characterized in that: The step of obtaining the tortuosity index according to the straight line reflection trend includes: According to the straight line reflection trend, the pin connected domain in the gray image of the connector pin is obtained; the edge pixel points in the pin connected domain are obtained using the edge detection algorithm; Use a curve fitting algorithm to fit all edge pixels to obtain a fitting curve; For each edge pixel point on the fitting curve, a tangent line of the fitting curve is drawn on the edge pixel point, the angle between the tangent lines of any two adjacent edge pixel points is obtained, and the radian value corresponding to the angle is calculated; The tortuosity index is positively correlated with the arc value, and negatively correlated with the Euclidean distance between any two adjacent edge pixel points.
5. The method for automatic detection of connector pins based on machine vision according to claim 4, characterized in that: The method of obtaining the pin connected domain in the grayscale image of the connector pin according to the straight line reflection trend includes: For each connected domain, if the number of extreme pixel points in the connected domain is 1, the preset value is used as the internal reflection consistency of each connected domain; If the number of extreme pixel points in the connected domain is greater than 1, the mean of the straight-line reflection trends of all extreme pixel points in the connected domain is calculated, the absolute value of the difference between the straight-line reflection trend of each extreme pixel point in the connected domain and the mean is calculated, and the mean of all the absolute values of the difference in the connected domain is taken as the internal reflection consistency of each connected domain; The connected domain with the minimum internal reflection consistency is regarded as the pin connected domain.
6. The method for automatic detection of connector pins based on machine vision according to claim 4, characterized in that: The step of obtaining the monotonicity of the tortuosity index sequence and each fixed window according to the size relationship between the tortuosity indexes includes: Sort the tortuosity indexes between any two adjacent edge pixel points on the fitting curve in order to construct a tortuosity index sequence; Divide the meander index sequence into a preset number of subsequences, and take the maximum value in each subsequence as the local maximum value in the meander index sequence; Construct a fixed window with a preset length, wherein the preset length is an odd number, place each local maximum at the center of the fixed window, and a window consisting of a preset number of elements before the local maximum in the fixed window is a left window of the local maximum, and a window consisting of a preset number of elements after the local maximum is a right window of the local maximum; For the left window of each fixed window, the difference between each element in the left window and its next adjacent element is calculated as the fourth difference of each element, the maximum value between the fourth difference of each element and the number 0 is obtained as the left maximum value of each element, and the sum of all the left maximum values in the left window is calculated as the first sum; For the right window of each fixed window, calculate the difference between the next adjacent element of each element in the right window and each element as the fifth difference of each element, obtain the maximum value between the fifth difference of each element and the number 0 as the right maximum value of each element, and calculate the sum of all the right maximum values in the right window as the second sum; The sum of the first sum value and the second sum value is used as the monotonicity of each fixed window.
7. The method for automatic detection of connector pins based on machine vision according to claim 6, characterized in that: The method for obtaining the mean consistency coefficient is: For each fixed window of the meander index sequence, the mean of the meander index of the left window of the fixed window is calculated as the first meander index, and the mean of the meander index of the right window of the fixed window is calculated as the second meander index; For all fixed windows in the meander index sequence, the mean of the first meander means of the left windows of all fixed windows is calculated as the left meander mean, and the mean of the second meander means of the right windows of all fixed windows is calculated as the right meander mean; For each fixed window of the meander index sequence, the absolute value of the difference between the first meander mean of the fixed window and the left meander mean is calculated as the first meander difference absolute value, and the absolute value of the difference between the second meander mean of the fixed window and the right meander mean is calculated as the second meander difference absolute value; The mean consistency coefficient is positively correlated with the absolute value of the first inflection difference, and is positively correlated with the absolute value of the second inflection difference.
8. The method for automatic detection of connector pins based on machine vision according to claim 1, characterized in that: The method of obtaining the crack existence score of the connector pin to be inspected according to the monotonicity degree and the mean consistency coefficient includes: Calculate the sum of the monotonicity of all fixed windows in the pin connectivity domain, calculate the result of an exponential function with a natural constant as the base and the sum as the exponent, and calculate the product of the calculation result and the mean consistency coefficient of the tortuosity index sequence in the pin connectivity domain as the crack presence score of the connector pin to be tested.
9. The method for automatic detection of connector pins based on machine vision according to claim 1, characterized in that: The step of obtaining a defect determination value according to the crack existence score includes: The same method as the crack existence score of the connector pin to be inspected is used to calculate the crack existence score of the pin connected domain in the connector pin grayscale image of the connector pin of qualified quality as the qualified crack existence score; The normalized value of the absolute value of the difference between the crack presence score of the connector pin to be inspected and the qualified crack presence score is calculated as the defect judgment value.
10. The method for automatic detection of connector pins based on machine vision according to claim 1, characterized in that: The testing of the connector pin to be tested according to the defect determination value comprises: If the defect judgment value is greater than the preset threshold, it is determined that a crack defect has occurred in the connector pin; otherwise, the connector pin is of qualified quality and no crack defect has occurred.
Citation Information
Patent Citations
Connector crack defect intelligent detection method based on machine vision
CN118154586A
Connector welding defect detection method based on machine learning
CN118552479A