A pin needle detection method based on machine vision
Patent Information
- Application Number
- CN202610860954.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-15
- Publication Date
- 2026-09-25
AI Technical Summary
[0006]本申请提供一种基于机器视觉的PIN针检测方法,旨在解决现有技术中前后排PIN针针尖在垂直投影方向存在部分重叠时,后排PIN针状态难以准确检测的技术问题
本申请通过以单件前排PIN针的实测轮廓建立随行基准,并基于灰度梯度连续性和结构力学传递规律进行双重调整,将前排PIN针的个体差异和形变干扰从后排PIN针的检测中剥离;同时采用轮廓相伴偏移量、灰度重心偏移量和投影重叠率变异度三种物理意义相互正交的参数进行联合判定,并配合前排自检阈值自适应和多帧一致性校验,使得在前后排PIN针针尖部分重叠的情况下,仍能对后排PIN针的存在状态和位置状态进行准确判定,有效解决了传统视觉检测方法在目标交叠场景下失效或误报率高的问题。
Smart Images

Figure CN122820565A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision inspection technology, specifically a PIN pin detection method based on machine vision. Background Technology
[0002] Pin arrays are critical structural components in electronic components such as connectors and relays, and the accuracy of their pin tip positioning directly affects the reliability of electrical connections. Due to the effects of stamping processes, injection molding shrinkage, and assembly stress, pins are prone to tilting, bending, twisting, or missing parts, requiring full inspection before leaving the factory.
[0003] Existing machine vision inspection methods typically acquire top-view images of a pin array, extract the outline of each pin through image segmentation, and then compare their positions with a standard template. This method requires that the outlines of each pin in the image be clearly separated and do not overlap.
[0004] In actual testing, due to limitations in camera field of view, working distance, and array density, the tips of the front and rear rows of pins often partially overlap in the vertical projection direction. Existing methods face challenges such as: continuous grayscale transitions in the overlapping areas making image segmentation difficult; the globally fixed benchmark being susceptible to batch fluctuations in the front row of pins; and insufficient robustness of a single judgment dimension when contour information is incomplete, making it difficult to distinguish different deformation modes.
[0005] Therefore, a detection method is needed that can accurately determine the presence and position of the rear row of PIN pins even when the tips of the front and rear rows of PIN pins overlap. Summary of the Invention
[0006] This application provides a PIN detection method based on machine vision, which aims to solve the technical problem in the prior art that the state of the rear row of PIN pins is difficult to detect accurately when the tips of the front and rear rows of PIN pins partially overlap in the vertical projection direction.
[0007] To achieve the above objectives, this application adopts the following technical solution: A machine vision-based PIN detection method includes: Acquire a grayscale image of the pin array to be detected in the vertical direction; in the pin array, the tips of the front row pins and the rear row pins partially overlap in the vertical projection direction; From the vertical grayscale image, identify the first projection area of the front row PIN needle tip on the horizontal plane, and identify the second projection area of the rear row PIN needle tip on the horizontal plane; the overlapping part of the first projection area and the second projection area is determined as the overlapping projection area; A following reference is established based on the measured contour shape of the first projection area. On the one hand, the following reference is adjusted according to the continuity of gray-scale gradient between the first projection area and the second projection area within the transition zone of the contour boundary of the overlapping projection area. On the other hand, the deformation type of the front row PIN pins is identified based on the deviation information of the measured contour shape of the first projection area from the pre-set standard contour shape. The following reference is compensated according to the structural mechanical transmission law corresponding to the deformation type to obtain the adjusted following reference. The offset feature parameters of the second projection region relative to the adjusted following reference are obtained; the offset feature parameters include at least two of the following: contour-related offset, gray-scale centroid offset of overlapping regions, and projection overlap rate variability. The offset feature parameters are compared with a pre-set standard offset threshold range to determine the presence and / or position of the rear PIN pins. When the offset feature parameter exceeds the standard offset threshold range, the offset feature parameter is recorded as a defect feature vector, and the defect determination result is output.
[0008] In one embodiment, the establishment of the accompanying benchmark includes: The measured contour shape of the first projection area is approximated by an ellipse to obtain its major axis direction, minor axis length and geometric center position; Using the geometric center position as the reference center and the major axis direction as the lateral reference direction, a local position reference system is established, consisting of a lateral reference axis and a longitudinal reference axis; the lateral reference axis and the longitudinal reference axis are perpendicular to each other; the local position reference system is the accompanying reference.
[0009] In one embodiment, the process of adjusting the grayscale gradient continuity includes: A sampling point is selected within the transition zone of the contour boundary of the overlapping projection area, and a grayscale profile curve is extracted along the local approximation direction at the sampling point; the local approximation direction is obtained by the direction of the line connecting the current sampling point and its adjacent sampling points. Determine the smoothness and continuity of the grayscale profile curve in the transition section between the first projection region and the second projection region; When the transition segment does not meet the pre-set smooth continuity conditions, the local coordinate orientation of the accompanying reference is adjusted until the transition segment meets the smooth continuity conditions.
[0010] In one embodiment, the deformation type includes overall tilting, root bending, and tip torsion. For the overall tilted type, the structural mechanics transmission law is as follows: the overall tilted posture of the front row of PIN pins is transmitted through the plastic matrix in an approximately rigid manner, causing the parallel offset of the rear row of PIN pins. For the root-bending type, the structural mechanics transmission law is as follows: the root bending of the front row of PIN pins causes the gradual offset of the rear row of PIN pins through the local elastic deformation of the plastic matrix in a non-uniform transmission manner. For the tip-twisting type, the structural mechanics transmission law is as follows: the tip twist of the front row PIN pins causes the rotational displacement of the rear row PIN pins through the shear deformation of the plastic matrix in an angular transmission manner.
[0011] In one embodiment, compensating the accompanying baseline includes: Based on the structural mechanics transmission law corresponding to the deformation type, the expected impact of the deformation type on the second projection area is calculated; Using the reverse compensation conditions corresponding to the expected impact results, the local coordinate orientation of the following reference is compensated and adjusted to obtain the adjusted following reference.
[0012] In one embodiment, the contour-related offset is obtained by point-by-point offset; the process of obtaining the point-by-point offset is as follows: In the local position reference system of the adjusted accompanying reference, multiple reference edge points are selected at set intervals along the contour edge of the adjusted accompanying reference. For each reference edge point, its vertical extension direction is obtained; on the contour boundary of the second projection area, the corresponding edge point located in the vertical extension direction and spatially closest to the reference edge point is searched; Obtain the positional deviation direction and positional deviation magnitude between each reference edge point and its corresponding edge point; integrate the positional deviation directions and positional deviation magnitudes of all reference edge points to form the contour-related offset.
[0013] In one embodiment, the grayscale centroid offset of the overlapping region is obtained by the relative positional offset between the centroids of the high-reflectivity area and the low-reflectivity area; the process of obtaining the centroids of the high-reflectivity area and the low-reflectivity area is as follows: Within the area enclosed by the contour boundary of the overlapping projection area, the grayscale value distribution of each pixel position is statistically analyzed. Pixel areas with gray values higher than a pre-set brightness threshold are defined as high reflectivity areas, and pixel areas with gray values lower than a pre-set darkness threshold are defined as low reflectivity areas. The average position of all pixels in the high reflectivity area is obtained and used as the centroid of the high reflectivity area; the average position of all pixels in the low reflectivity area is obtained and used as the centroid of the low reflectivity area.
[0014] In one embodiment, the variability of the projection overlap rate is obtained from the difference in the segment overlap ratio; the process for obtaining the difference in the segment overlap ratio is as follows: The adjusted local position reference system of the accompanying reference is divided into four azimuth regions according to the lateral reference axis and the longitudinal reference axis; The proportion of the pixel area of the overlapping projection region in each directional region to the total pixel area of that directional region is obtained, and the segment overlap ratio of each of the four directional regions is obtained. Find the highest and lowest percentages from the four segment overlap percentages; use the difference between the highest and lowest percentages as the projection overlap rate variability.
[0015] In one embodiment, the determination of the existence state and the location state is as follows: When the offset of the contour is lower than the preset missing threshold, it is determined that the rear row of PIN pins is missing; When the offset of the contour is lower than the preset normal threshold, and the offset of the gray-scale centroid of the overlapping area is lower than the preset normal posture threshold, and the projection overlap rate variation is absent or lower than the preset uniform threshold, it is determined that the rear row of PIN pins exists and is in a normal position. When the offset of the contour exceeds the preset normal threshold, or the offset of the gray-scale centroid of the overlapping area exceeds the preset normal posture threshold, or the variability of the projection overlap rate exists and exceeds the preset uniform threshold, it is determined that the rear row of PIN pins exists but the position is abnormal.
[0016] In one embodiment, the method further includes: After the adjusted reference is obtained, the measured contour shape of the first projection area is compared with the pre-set standard contour shape to obtain the position deviation information of the front row PIN pins, and then the existence state and position state of the front row PIN pins are determined; the position state includes overall translation type, rotation type and scaling type. When the position of the current row of PIN pins is in an overall translational state, the standard offset threshold range is adjusted by overall translation. When the current row of PIN pins is in a rotating state, the standard offset threshold range is adjusted by angular rotation. When the position status of the current row of PIN pins is in scaling mode, the standard offset threshold range is adjusted by scaling. Before outputting the defect determination result, the offset feature parameters are calculated for multiple frames of vertical grayscale images acquired at different acquisition angles for the same PIN array; the offset feature parameters obtained from each of the multiple frames are compared for consistency; when the deviation between the offset feature parameters of the multiple frames is within a pre-set consistency range, the defect determination result is output; when the deviation between the offset feature parameters of the multiple frames exceeds the pre-set consistency range, the current detection result of the rear row of PINs is marked as suspicious, and a supplementary acquisition process is triggered.
[0017] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects: This application establishes a reference standard based on the measured contour of a single front row pin, and makes dual adjustments based on the continuity of gray-level gradient and the law of structural mechanical transmission to separate the individual differences and deformation interference of the front row pins from the detection of the rear row pins. At the same time, it uses three physically orthogonal parameters—contour-associated offset, gray-level centroid offset, and projection overlap rate variation—for joint judgment, and combines front row self-inspection threshold adaptation and multi-frame consistency verification. This enables accurate determination of the existence and position of the rear row pins even when the tips of the front and rear row pins overlap, effectively solving the problem of failure or high false alarm rate of traditional visual detection methods in target overlapping scenarios. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of the method of the present invention. Detailed Implementation
[0019] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Obtain a vertical grayscale image of the PIN array to be detected; in the PIN array, the tips of the front row PINs and the rear row PINs partially overlap in the vertical projection direction.
[0021] Specifically, the vertical grayscale image is acquired using an industrial camera and a coaxial light source. The industrial camera is a Baslerac A3800-10gm area array camera with a resolution of 3840x2748 pixels, paired with a 35mm fixed-focus lens, and a working distance set at 150-200mm, preferably 180mm. The coaxial light source is positioned along the optical axis of the lens, with a brightness set at 70%-90% of its rated power, preferably 80%.
[0022] With this configuration, the camera's field of view can simultaneously cover the tip area of multiple rows of pin arrays, and the coaxial light source can suppress specular reflection on the surface of the metal pin tip. While ensuring the overall brightness of the image, it also allows the outline boundaries of the front and rear rows of pins in the overlapping area to maintain a recognizable grayscale transition, providing a high-contrast image foundation for the subsequent establishment of the reference.
[0023] Traditional visual inspection methods generally require that the targets being inspected be completely separated and non-overlapping in the image, which limits their application in high-density pin array detection. This application overcomes the dependence of traditional methods on target separation by acquiring vertical grayscale images with partial overlap and subsequently processing the overlapping areas using a following reference method. Simultaneous detection of front and rear rows of pins can be achieved with single-view acquisition, reducing the hardware configuration requirements for multiple cameras or multiple views.
[0024] From the vertical grayscale image, identify the first projection area of the front row PIN needle tip on the horizontal plane and the second projection area of the rear row PIN needle tip on the horizontal plane; the overlapping part of the first projection area and the second projection area is determined as the overlapping projection area.
[0025] The identification of the first and second projection regions employs an adaptive thresholding segmentation combined with morphological filtering. Specifically, after Gaussian smoothing of the vertical grayscale image, Otsu's adaptive thresholding method is used for binarization to obtain the foreground region. The foreground region is sequentially opened (using a 3x3 circular kernel as the structuring element) and closed (using a 5x5 circular kernel as the structuring element) to remove noise points and connect broken areas. Ellipse fitting is performed on the connected components, retaining those with a major-minor axis ratio between 1.5 and 4.0 and an area between 200 and 2000 square pixels as candidate regions for pin tip projection. Based on prior arrangement rules (front row pins are located in the lower region of the image, and rear row pins are located in the upper region), the candidate regions are divided into a first projection region and a second projection region. The first and second projection regions are represented by pixel coordinates in the image coordinate system, and their overlapping part is determined by pixel-level logical AND operations, forming the overlapping projection region. By combining ellipse fitting and prior arrangement rules, even if the tips of the front and rear rows of pins partially overlap in the projection, the mixed connected components can still be accurately separated into independent first and second projection regions, providing reliable region boundaries for subsequent separate processing of the front and rear rows of pins.
[0026] Establish a reference datum based on the measured contour shape of the first projection area; On the one hand, the accompanying reference is adjusted based on the continuity of gray-level gradient between the first and second projection areas within the transition zone of the overlapping projection areas. On the other hand, based on the deviation information of the measured contour shape of the first projection area from the pre-set standard contour shape, the deformation type of the front row PIN pins is identified, and the accompanying reference is compensated according to the structural mechanical transmission law corresponding to the deformation type to obtain the adjusted accompanying reference.
[0027] The dual adjustment of the accompanying reference is performed in sequence: first, the grayscale gradient continuity is adjusted to obtain the accompanying reference after one adjustment; then, the structural mechanical compensation adjustment is performed on the accompanying reference after one adjustment to obtain the accompanying reference after adjustment.
[0028] In one embodiment, the establishment of the accompanying reference includes: approximating the measured contour shape of the first projection area with an ellipse to obtain its major axis direction, minor axis length and geometric center position; using the geometric center position as the reference center and the major axis direction as the lateral reference direction, establishing a local position reference system composed of a lateral reference axis and a longitudinal reference axis; the lateral reference axis and the longitudinal reference axis are perpendicular to each other; the local position reference system is the accompanying reference.
[0029] Specifically, the ellipse approximation uses the least squares fitting method to obtain the major axis length *a*, minor axis length *b*, major axis direction angle *theta*, and geometric center coordinates (xc, yc). The lateral reference axis is along the major axis, and the longitudinal reference axis is along the minor axis, with the two orthogonal at the origin (xc, yc). A reference datum is established using the measured profile shape, rather than a fixed global coordinate system. This allows the datum to adapt to individual differences and variations in the placement of the front-row pins, improving tolerance to pin position fluctuations in mass production batches.
[0030] Because existing technologies typically use fixed templates or global coordinates for position comparison, this application uses the measured contour of the front row of pins as the reference, and establishes the detection reference system on the object being tested itself. Even if there are normal positional fluctuations in the front row of pins within a batch, they will not be misjudged as defects in the rear row of pins. The detection sensitivity is transformed from "absolute positional accuracy" to "relative positional consistency", which significantly reduces the false alarm rate caused by fluctuations in incoming materials.
[0031] In one embodiment, the process of adjusting grayscale gradient continuity includes: selecting sampling points within the transition zone of the contour boundary of the overlapping projection region, and extracting grayscale profile curves along the local approximation direction at the sampling point; the local approximation direction is obtained by the direction of the line connecting the current sampling point and its adjacent sampling points; determining the smooth continuity of the grayscale profile curve in the transition segment between the first projection region and the second projection region; when the transition segment does not meet the preset smooth continuity conditions, adjusting the local coordinate orientation of the accompanying reference until the transition segment meets the smooth continuity conditions.
[0032] It should be understood that the sampling point selection interval is 3-5 pixels, preferably 4 pixels. The grayscale profile curve extraction method is as follows: taking the current sampling point as the center, extend 10-15 pixels (preferably 12 pixels) to both sides along the local approximation direction, and perform bilinear interpolation sampling with a step size of 0.5 pixels to obtain a one-dimensional grayscale sequence I(n). The smooth continuity condition is: the first derivative of the grayscale value in the transition segment is continuous and there are no abrupt changes, and the absolute value of the second derivative is less than the pre-set threshold Tg.
[0033] Industrial cameras output 12-bit grayscale images with a dynamic range of 0-4095. The typical amplitude of grayscale changes during transitions is 200-500 grayscale levels, completed within a 10-20 pixel width. The theoretical value of the second derivative is approximately 1-5 grayscale levels per pixel squared. Setting Tg to 10 grayscale levels per pixel squared provides twice the margin for a normal transition while suppressing false transitions caused by noise. For 8-bit cameras, Tg should be adjusted accordingly to 0.6 grayscale levels per pixel squared.
[0034] The method to achieve "continuous first derivative with no abrupt change points" in the discrete domain is as follows: Perform first-order difference on the gray-level sequence I(n) to obtain deltaI(n) = I(n) - I(n-1), and calculate the change in adjacent differences delta2I(n) = deltaI(n) - deltaI(n-1). When the absolute value of delta2I(n) is greater than twice Tg, the point is determined to be an abrupt change point in the first derivative. It is required that the number of abrupt change points within the transition segment is zero.
[0035] When the above conditions are not met, the local coordinate orientation of the accompanying reference is adjusted. Specifically, the horizontal and vertical reference axes are rotated around the geometric center position (xc, yc), with the rotation amount determined iteratively by the gradient descent method. To avoid local optima, the initial iteration value is the standard profile major axis direction angle thetastd, and the search range is limited to thetastd ±30 degrees. If it exceeds this range, it is judged as an abnormal posture and the adjustment is terminated. The iteration formula is thetak+1 = thetak minus eta multiplied by the partial derivative of J with respect to theta, where J is the sum of squares of the second derivatives of gray levels in the transition segment, eta is 0.5 degrees, and the iteration terminates when the absolute value of the difference between two adjacent thetas is less than 0.1 degrees or the maximum number of iterations of 50 is reached.
[0036] The local coordinate orientation angle of the following reference after one adjustment is thetaprime = theta plus the rotation amount. When there is a grayscale jump in the transition segment, it indicates that the local coordinate orientation of the following reference deviates from the actual needle tip arrangement direction. By performing gradient descent search in the neighborhood of the standard direction with the geometric center as the rotation center, the grayscale profile is restored to smooth continuity, and the following reference can be aligned with the actual spatial posture of the rear row of PIN needles, avoiding the distortion of subsequent offset calculation caused by the reference direction deviation.
[0037] Existing technologies typically segment or fit grayscale images directly when processing overlapping regions, attempting to separate front and rear targets from the mixed signal. This often fails when there is severe overlap. This application does not directly separate overlapping regions. Instead, it uses the continuity of grayscale gradients as a constraint to adjust the orientation of the accompanying reference in reverse, aligning it with the actual posture of the rear row of pins. This transforms the "separation target" into an "alignment reference," achieving indirect measurement of the rear row of pin positions while maintaining the overlapping state, thus avoiding the impact of segmentation errors on detection accuracy.
[0038] In one embodiment, the deformation types include overall tilting, root bending, and tip torsion. For the overall tilt type, the structural mechanics transmission law is as follows: the overall tilt posture of the front row of pins is transmitted through the plastic matrix in an approximately rigid manner, causing the parallel offset of the rear row of pins; for the root bending type, the structural mechanics transmission law is as follows: the root bending of the front row of pins is transmitted through the local elastic deformation of the plastic matrix in a non-uniform manner, causing the gradual offset of the rear row of pins; for the tip torsion type, the structural mechanics transmission law is as follows: the tip torsion of the front row of pins is transmitted through the shear deformation of the plastic matrix in an angular manner, causing the rotational displacement of the rear row of pins.
[0039] In one embodiment, compensating for the accompanying reference includes: calculating the expected impact of the deformation type on the second projection area according to the structural mechanics transmission law corresponding to the deformation type; and compensating and adjusting the local coordinate orientation of the accompanying reference with the reverse compensation conditions corresponding to the expected impact to obtain the adjusted accompanying reference.
[0040] The standard profile shape is the ellipse fitting parameters of the pre-calibrated defect-free PIN needle tip, including the standard major axis length astd, the standard minor axis length bstd, the standard major axis direction angle thetastd, and the standard geometric center coordinates (xcstd, ycstd). The calibration method of the standard profile shape is the same as the calibration method of the standard offset threshold range described in claim 10: select no less than 100 PIN needle array samples that have been manually inspected and confirmed to be qualified, perform ellipse fitting on the front row PIN needle tip of each sample, and calculate the mean values of astd, bstd, thetastd, xcstd, and ycstd as the standard profile shape parameters.
[0041] Deviation information includes: major axis direction angle deviation deltatheta=thetaprime minusthetastd, major-minor axis ratio deviation deltaab=a divided by b minus astd divided by bstd, and geometric center offset deltad equals the square root of the difference between xc and xcstd plus the square root of the difference between yc and ycstd.
[0042] The rules for determining the deformation type are as follows: The aforementioned thresholds were obtained through statistical calibration of no fewer than 50 defective samples that were manually inspected and categorized. The calibration process involved manually determining the deformation type (overall tilt / root bending / tip twisting) of the front row pins of each sample, while simultaneously recording their ellipse fitting parameters. The optimal threshold for each parameter was determined through ROC curve analysis, ensuring that the misjudgment rate for all three deformation types was below 5%. When the absolute value of deltatheta was greater than 5 degrees, deltaab was less than 0.1, and deltad was greater than 5 pixels, it was determined to be an overall tilt type. When deltaab is greater than 0.15 and the angle between the geometric center offset direction and the major axis direction is greater than 45 degrees, it is judged as root bending type; when the absolute value of deltatheta is greater than 8 degrees and deltaab is greater than 0.2, it is judged as tip torsion type. When the parameter characteristics of the sample simultaneously meet two or more judgment conditions, it is judged as tip torsion type according to the deltatheta priority principle and as root bending type according to the deltaab priority principle, so as to reduce the misjudgment of composite deformation.
[0043] The reverse compensation condition refers to reversing the expected impact result to offset the transmission interference of front row PIN deformation on the detection of rear row PINs.
[0044] For the overall tilted type, the plastic substrate is simplified as a rigid body. The tilt angle of the front row of PIN pins, deltatheta, causes the bottom surface of the substrate to tilt, and the rear row of PIN pins undergoes rigid body translation along with the substrate. Let the substrate height be H (determined by the PIN pin array design drawing, typically 8-12mm). From geometric relationships, the expected parallel offset of the rear row of PIN pins is obtained as follows: deltayexpect = H multiplied by tan(deltatheta); This formula is based on the small deformation assumption (deltatheta is less than 10 degrees, corresponding to the conventional small deformation judgment standard in mechanics of materials). At this time, tan(deltatheta) is approximately equal to deltatheta (radians), with an error of less than 0.5%. The compensation adjustment is as follows: the longitudinal reference axis of the accompanying datum after the first adjustment is translated by a negative deltayexpect, that is, the ordinate of the datum center after compensation is yc2 = yc minus deltayexpect.
[0045] For root-bending type, the plastic matrix is simplified as a Winkler elastic foundation beam, and the PIN root bends under the action of lateral force. Let the elastic modulus of the matrix be E, the moment of inertia of the section be I, and the foundation coefficient be kw. Then the differential equation of the deflection curve is EI multiplied by the fourth derivative of y with respect to x plus kw multiplied by y equals 0, and the envelope of the solution is in the form of exponential decay.
[0046] The PIN needle root is embedded inside the plastic matrix. The displacement and rotation of the root section in the matrix are constrained and treated as a fixed-support boundary condition, i.e., y=0 and dy / dx=0 at x=0. The expected asymptotic offset of the rear PIN needle is: deltayexpect(x)=deltad multiplied by (1 minus the negative x of e divided by L). In the formula, x is the longitudinal coordinate along the needle tip (x=0 at the root, x=H at the needle tip). This longitudinal coordinate is obtained by mapping the longitudinal reference axis of the accompanying reference in the image coordinate system. The mapping ratio is determined by the camera calibration parameters (pixel size = sensor size / resolution, typical value is about 3.45μm / pixel). L is the fourth root of (4EI divided by kW) as the attenuation length. For a typical PBT plastic matrix (E=2-3GPa, cross-sectional width w=1.5mm, height h=2mm, then I=w multiplied by h cubed and divided by 12 equals 1.0mm to the power of 4; taking the basic coefficient kw=50N per mm square, this value is obtained by finite element inversion calibration of the stress-strain curve of the matrix material in the elastic segment combined with the geometric parameters of the PIN needle array, with no less than 20 calibrated samples), substituting into the formula, we get L equal to (4 multiplied by 2.5 multiplied by 10 cubed MPa multiplied by 1.0mm to the power of 4 divided by 50N per mm square), approximately equal to 3.76mm), with a typical value of 3-5mm. The compensation adjustment is as follows: the contour edge points of the accompanying reference are non-uniformly translated by a negative deltayexpect(x).
[0047] For the tip-twist type, the plastic matrix is simplified as a cylinder subjected to torque, and the twist angle obtained by the rear row of PIN pins is: deltathetaexpect = k multiplied by deltatheta; where k equals Gp multiplied by Jp divided by Gb multiplied by Jb, which is the shear transfer coefficient, Gp is the PIN needle shear modulus (typical value 79 GPa, steel), Jp is the PIN needle polar moment of inertia, Gb is the matrix shear modulus (typical value 0.8-1.2 GPa, PBT plastic), and Jb is the matrix equivalent polar moment of inertia.
[0048] The equivalent diameter Db of the substrate is taken as the minimum outer circle diameter of the effective load-bearing area of the plastic substrate around the root of a single PIN pin. This effective load-bearing area is a local area centered on the center of the PIN pin root, covering the boundary between the PIN pin and the adjacent substrate, and is measured from design drawings or images. For a standard 2x8 PIN pin array, the diameter of this local area is about 2-4 mm. Db=2 mm is taken as the equivalent circle diameter to simplify the calculation of torsional stiffness.
[0049] Let the pin diameter dp = 0.5 mm and the equivalent substrate diameter Db = 2 mm. Then Jp equals pi multiplied by dp to the power of 4 divided by 32, which equals 6.14 multiplied by 10 to the power of -3 mm to the power of 4. Jb equals pi multiplied by Db to the power of 4 divided by 32, which equals 1.57 mm to the power of 4. Taking Gp = 79 GPa and Gb = 1.0 GPa, substituting these values, we get k is approximately equal to 0.31. Considering the local compliance correction coefficient alpha = 2.0-2.6 at the contact surface between the substrate and the PIN (obtained from finite element calibration, the calibration method is as follows: a three-dimensional solid model containing a single PIN and the surrounding substrate is established, the contact surface between the PIN and the substrate is bound with constraints, the bottom surface of the substrate is fixed, a torque load is applied to the top of the PIN, and the compliance correction coefficient is obtained by comparing the torsion angle calculated by finite element with the theoretical rigid body torsion angle; the mesh uses second-order tetrahedral elements, the local mesh in the contact area is locally refined to 0.05mm, the calibration samples cover 3 different substrate batches, each batch has no less than 5 pieces, and the average value of alpha is taken as the correction coefficient), after correction, k is equal to alpha multiplied by 0.31, which is 0.62-0.81, consistent with the experimental calibration value of 0.6-0.8. The compensation adjustment is: the accompanying reference is rotated around its geometric center by a negative deltathetaexpect, that is, the major axis direction angle after compensation is theta2 = thetaprime minus deltathetaexpect.
[0050] The adjusted local coordinate orientation angle of the following reference is theta2, and the geometric center position is (xc2, yc2), which is obtained by superimposing the gradient continuity adjustment and structural mechanics compensation adjustment as described above. The deformation of the front row of pins is mapped to the expected influence on the rear row of pins through the structural mechanics transmission law. Then, the following reference is adjusted in reverse compensation mode. The following reference can reflect "the ideal position that the rear row of pins should have if the front row of pins is defect-free". The deformation interference of the front row of pins is separated from the detection of the rear row of pins, which improves the independence and accuracy of the condition determination of the rear row of pins.
[0051] Existing visual inspection methods typically treat the front and rear pins as independent targets, ignoring their structural mechanical coupling relationship through the plastic matrix. This application utilizes the structural mechanical transfer law between the deformation type of the front pins and the positional offset of the rear pins to transform the measured deformation information of the front pins into a compensation amount for the accompanying reference, rather than simply treating the deformation of the front pins as a detection error or discarding the sample. This "deformation-based" compensation strategy allows for accurate detection of the rear pins even if there is significant deformation in the front pins, expanding the adaptability of the inspection method to fluctuations in incoming material quality and avoiding the over-inspection problem of scrapping the entire piece due to slight deformation of the front pins.
[0052] Obtain the offset characteristic parameters of the second projection region relative to the adjusted accompanying reference; the offset characteristic parameters include at least two of the following: contour-accompanying offset, gray-scale centroid offset of overlapping regions, and projection overlap rate variability.
[0053] In one embodiment, the profile-related offset is obtained by point-by-point offset. The process of obtaining the point-by-point offset is as follows: In the local position reference system of the adjusted accompanying reference, multiple reference edge points are selected at set intervals along the profile edge of the adjusted accompanying reference; for each reference edge point, its vertical extension direction is obtained; on the profile boundary of the second projection area, the corresponding edge point located in the vertical extension direction and spatially closest to the reference edge point is searched; the positional deviation direction and positional deviation magnitude between each reference edge point and its corresponding edge point are obtained; the positional deviation direction and positional deviation magnitude of all reference edge points are integrated together to form the profile-related offset.
[0054] The selection interval for reference edge points is 2-4 pixels, preferably 3 pixels. The method for determining the vertical extension direction is as follows: For the i-th reference edge point Pi, take its two preceding and following two adjacent points, and fit the local tangent direction using the least squares method; the vertical direction will then be orthogonal to it. On the contour boundary of the second projection region, perform a one-dimensional search along the vertical direction within a search range of ±20 pixels, and find the point Qi with the smallest Euclidean distance to Pi as the corresponding edge point. When no contour boundary point of the second projection region is found within the search range, the reference edge point is marked as an isolated point and does not participate in the calculation of the contour-related offset; when the same corresponding edge point is matched by multiple reference edge points simultaneously, retain the pair with the smallest distance, and re-match the remaining reference edge points on the remaining contour boundary points until all reference edge points have completed a one-to-one match or are marked as isolated points.
[0055] The positional deviation magnitude *di* is equal to the distance between *Pi* and *Qi*, and the positional deviation direction *phii* is the directional angle from *Pi* to *Qi*. The profile-related offset is represented by a vector set {(di,phii)}, where the *di* corresponding to isolated points does not participate in the ensemble mean and variance calculations. When calculating *dbar*, only the number of valid matching points *Neff* is counted, and *dbar* equals the sum of all valid *di* divided by *Neff*. Using a point-by-point offset method instead of a simple center-point offset can capture the local deformation details of the second projection area profile, providing higher sensitivity to non-rigid deformations such as bending and torsion of the rear PIN pins.
[0056] Traditional methods typically use centroid offset or template matching degree as position criteria, which are difficult to reflect local deformation information of the contour. This application establishes a point-by-point correspondence between the reference edge point and the measured edge point, decomposing the position offset into the deviation magnitude and deviation direction of the contour normal. Even if the rear row of PIN pins undergoes non-uniform bending (such as gradual offset caused by root bending), it can be identified through the spatial distribution pattern of the accompanying offset, rather than being simply judged as "positional abnormality", providing a more refined data granularity for defect root cause analysis.
[0057] In one embodiment, the gray-scale centroid offset of the overlapping region is obtained by the relative positional offset between the centroids of the high-reflectivity region and the low-reflectivity region. The process of obtaining the centroids of the high-reflectivity region and the low-reflectivity region is as follows: Within the area enclosed by the contour boundary of the overlapping projection region, the gray-scale value distribution of each pixel position is statistically analyzed; pixel regions with gray-scale values higher than a pre-set high-brightness threshold are identified as high-reflectivity regions, and pixel regions with gray-scale values lower than a pre-set dark-area threshold are identified as low-reflectivity regions; the average position of all pixel positions in the high-reflectivity region is obtained as the centroid of the high-reflectivity region; the average position of all pixel positions in the low-reflectivity region is obtained as the centroid of the low-reflectivity region.
[0058] The highlight threshold Th equals the average grayscale value of the overlapping area muo plus 1.2 times the standard deviation of the grayscale value of the overlapping area sigmao, and the shadow threshold Tl equals muo minus 1.0 times sigmao. The centroids Gh and Gl of the high-reflectivity area and the low-reflectivity area are the average coordinates of all pixel positions in their respective areas, respectively, and the grayscale centroid offset Goffset of the overlapping area equals Gh minus Gl. Utilizing the specular reflection properties of the metal pin tip surface, the overlapping area is divided into a high-reflectivity area and a low-reflectivity area. The relative offset of their centroids reflects the attitude change of the rear pins in the overlapping area, providing effective positional information even without clear outline boundaries, thus enhancing adaptability to severely overlapping scenes.
[0059] When the front and rear rows of pins severely overlap and the contour boundaries are difficult to extract accurately, traditional contour-based position measurement methods will fail. This application utilizes the specular reflection characteristics of metal pin tips to transform the grayscale distribution of the overlapping area into a centroid shift between high-reflectivity and low-reflectivity areas, converting "contour measurement" into "grayscale centroid measurement." Even when contour information is missing, the position detection capability can still be maintained, effectively complementing the contour-related offset. The synergy between the two ensures that the detection method has stable detection performance across a continuous range from slight to severe overlap.
[0060] In one embodiment, the projection overlap rate variability is obtained from the difference in segment overlap ratios. The process of obtaining the difference in segment overlap ratios is as follows: the local position reference system of the adjusted accompanying reference is divided into four directional regions according to the horizontal reference axis and the vertical reference axis; the proportion of the pixel area of the overlapping projection region in each directional region to the total pixel area of that directional region is obtained, and the segment overlap ratio of each of the four directional regions is obtained; the highest and lowest proportions are found from the four segment overlap ratios; the degree of difference between the highest and lowest proportions is taken as the projection overlap rate variability.
[0061] It should be noted that the four directional regions are the first quadrant (xprime > 0, yprime > 0), the second quadrant (xprime < 0, yprime > 0), the third quadrant (xprime < 0, yprime < 0), and the fourth quadrant (xprime > 0, yprime < 0), where (xprime, yprime) are the coordinates in the local position reference frame. The segment overlap ratio Rk is equal to the overlap area in the k-th quadrant divided by the total area in the k-th quadrant, where k = 1, 2, 3, 4.
[0062] The variability of projected overlap, Voverlap, is equal to the maximum value minus the minimum value among the four Rk values, ranging from 0 to 1. A Voverlap of 0 indicates uniform overlap across all four quadrants, while a Voverlap approaching 1 indicates that the overlap height is concentrated in a specific quadrant. Decomposing the overlapping area by quadrant and comparing the overlap ratio differences in each quadrant can reflect the directional offset trend of the rear pins relative to the front pins, thereby distinguishing different deformation modes such as parallel offset and rotational displacement, and improving the interpretability of defect types.
[0063] The contour offset reflects the "distance deviation" of the rear row of pins relative to the accompanying reference, the gray-scale centroid offset of the overlapping area reflects the "brightness center offset," and the projection overlap rate variability reflects the "orientation distribution offset." These three parameters characterize the state of the rear row of pins from three independent dimensions: geometric contour, optical characteristics, and spatial distribution. Their physical meanings are orthogonal to each other, resulting in low information redundancy and strong complementarity during joint judgment, thus improving the reliability and anti-interference ability of the judgment results.
[0064] The offset characteristic parameters are compared with a pre-set standard offset threshold range to determine the presence and / or position of the rear PIN pins.
[0065] In one embodiment, the determination of the presence and position states is as follows: when the contour offset is lower than a preset missing threshold, the rear row of pins is determined to be missing; when the contour offset is lower than a preset normal threshold, and the gray-scale centroid offset of the overlapping area is lower than a preset normal attitude threshold, and the projection overlap rate variation is absent or lower than a preset uniform threshold, the rear row of pins is determined to be present and in a normal position; when the contour offset exceeds a preset normal threshold, or the gray-scale centroid offset of the overlapping area exceeds a preset normal attitude threshold, or the projection overlap rate variation exists and exceeds a preset uniform threshold, the rear row of pins is determined to be present but in an abnormal position.
[0066] The standard offset threshold range was obtained by statistical calibration of no less than 100 PIN pin array samples that were confirmed to be qualified by manual inspection.
[0067] Specifically, for qualified samples, the offset characteristic parameters are obtained according to the aforementioned steps, and the Shapiro-Wilk normality test is performed on each parameter. When the p-value is greater than 0.05, the normal distribution hypothesis is accepted, and the threshold is set using the mu plus 3 times sigma method; if the normality does not hold, a non-parametric method is used (taking the 99th percentile as the upper limit of the threshold).
[0068] The missing threshold Tm is equal to 0.8 multiplied by the minimum value of the acceptable sample's dbar; the normal threshold (contour offset) Tnd is equal to the mean of dbar plus 3 times the standard deviation of dbar; the pose normal threshold Tng is equal to the mean of the absolute value of Goffset plus 3 times the standard deviation of the absolute value of Goffset; the uniform threshold Tvu is equal to the mean of Voverlap plus 3 times the standard deviation of Voverlap. Typical value ranges are: Tm = 2-4 pixels, Tnd = 6-10 pixels, Tng = 4-8 pixels, Tvu = 0.10-0.20.
[0069] In actual detection, the offset feature parameters include all three parameters mentioned above, namely, simultaneously calculating the contour-related offset, the gray-level centroid offset of the overlapping area, and the variability of the projection overlap rate, and performing joint judgment according to the above judgment rules. By adopting a multi-parameter joint judgment strategy and cross-validating the three offset feature parameters, the probability of misjudgment caused by noise interference of a single parameter is reduced, and the judgment of missing parameters and positional anomalies has higher confidence.
[0070] The three offset feature parameters are judged from three dimensions: geometric, optical, and distribution. Their joint logic uses an "AND" relationship to determine normal (normal only if all conditions are met) and an "OR" relationship to determine abnormal (abnormal if any condition is exceeded). This "strict entry, lenient exit" judgment strategy makes the admission standards for normal parts strict and the identification sensitivity of abnormal parts high. In production line inspection, it can effectively balance the missed detection rate and false alarm rate, and avoid releasing defective parts or rejecting qualified parts by mistake.
[0071] When the offset feature parameter exceeds the standard offset threshold range, the offset feature parameter is recorded as a defect feature vector, and the defect judgment result is output.
[0072] The defect feature vector is F = (dbar, standard deviation of dbar, absolute value of Goffset, Voverlap, Cdefect), where Cdefect belongs to {missing, abnormal location} and is the defect category code. Integrating the multidimensional offset feature parameters into the defect feature vector not only outputs a binary judgment result, but also provides quantitative data support for subsequent quality traceability and process analysis.
[0073] In one embodiment, after the adjusted following reference is obtained, the measured contour shape of the first projection area is compared with the pre-set standard contour shape to obtain the position deviation information of the front row PIN pins, and then the existence state and position state of the front row PIN pins are determined; the position state includes overall translation type, rotation type and scaling type.
[0074] The comparison of positional deviation information includes: geometric center offset deltad, major axis orientation angle deviation deltatheta, and major and minor axis scaling ratio s equal to (a divided by b) divided by (astd divided by bstd). When deltad is greater than 5 pixels and the absolute value of deltatheta is less than 3 degrees and 0.95 is less than s and less than 1.05, it is determined to be a global translation type; when the absolute value of deltatheta is greater than 5 degrees and 0.95 is less than s and less than 1.05, it is determined to be a rotation type; when 0.85 is less than s and less than 0.95 or 1.05 is less than s and less than 1.15, it is determined to be a scaling type. Performing a self-check on the front row of pins before detecting the rear row of pins can promptly detect abnormalities in the front row of pins, avoiding misjudgments of the rear row of pins due to abnormalities in the front row.
[0075] When the current row of PIN pins is in a translational state, the standard offset threshold range is adjusted by overall translation; when the current row of PIN pins is in a rotational state, the standard offset threshold range is adjusted by angular rotation; when the current row of PIN pins is in a scaling state, the standard offset threshold range is adjusted by proportional scaling.
[0076] The threshold adjustment method is as follows: For overall translation type, the position-related thresholds (Tm, Tnd, Tng) are all shifted by a negative deltadvec, where deltadvec = (xc minus xcstd, yc minus ycstd); for rotation type, the local position reference frame and all orientation angle parameters are rotated by a negative deltatheta; for scaling type, the pixel distance thresholds are multiplied by 1 and divided by s. The standard offset threshold range is adaptively adjusted according to the actual position state of the front row PIN pins. The threshold can dynamically track changes in the attitude of the front row PIN pins, ensuring detection sensitivity while avoiding false alarms from the rear row PIN pins caused by normal batch fluctuations in the front row PIN pins.
[0077] Traditional methods typically use fixed threshold values. When the front row of pins shifts or rotates due to material fluctuations, the fixed threshold can lead to inaccurate judgment criteria for the rear row of pins. This application identifies the positional state type of the front row of pins and applies a similar geometric transformation (translation / rotation / scaling) to the threshold. The threshold "follows" the posture changes of the front row of pins, transforming the "absolute threshold" into a "relative threshold." Normal positional fluctuations of the front row of pins are then excluded from the defect judgment of the rear row of pins, significantly reducing false alarms caused by insufficient material consistency.
[0078] In one embodiment, before outputting the defect determination result, offset feature parameters are calculated for multiple frames of vertical grayscale images acquired at different acquisition angles for the same PIN array; the offset feature parameters obtained from each of the multiple frames are compared for consistency; when the deviation between the offset feature parameters of the multiple frames is within a pre-set consistency range, the defect determination result is output; when the deviation between the offset feature parameters of the multiple frames exceeds the pre-set consistency range, the current detection result of the rear row of PINs is marked as suspicious, and a supplementary acquisition process is triggered.
[0079] Different acquisition angles are achieved by rotating the PIN array around the normal direction of its tip plane via a rotating platform.
[0080] The rotating platform includes a vacuum adsorption base and a stepper motor. The PIN needle array is adsorbed onto the upper surface of the vacuum adsorption base. The upper surface of the vacuum adsorption base is provided with positioning pins, and the plastic substrate of the PIN needle array is provided with corresponding positioning holes. The positioning pins and positioning holes cooperate to achieve the initial alignment of the normal direction of the needle tip plane with the rotation axis. After alignment, fine adjustment is made by the leveling screw under the base until the geometric center offset of each frame of the image during rotation is less than 0.5 pixels.
[0081] A stepper motor drives the vacuum adsorption base to rotate around a vertical axis, which coincides with the normal direction of the needle tip plane.
[0082] The optical axis of the industrial camera is fixed and perpendicular to the pin tip plane, remaining unchanged during rotation. The angle interval is set to 15-30 degrees, preferably 20 degrees, with a total of 3-5 frames, preferably 4 frames. The angle interval is chosen because when the rotation angle is less than 15 degrees, the grayscale distribution of the overlapping area of the front and rear rows of pins does not change significantly at different angles, making it difficult to effectively distinguish between systematic errors and random interference. When the rotation angle is greater than 30 degrees, the projection position of the rear PIN pins in the image may shift significantly, exceeding the search range and causing matching failure. A 20-degree interval, captured in 4 frames (0°, 20°, 40°, 60°), ensures that the grayscale distribution of the overlapping areas between each frame is significantly different, while keeping the offset of the rear PIN pin projection position within the search range of ±20 pixels.
[0083] Since the rotation axis coincides with the normal of the needle tip plane, the needle tip plane remains perpendicular to the optical axis during rotation, allowing for the acquisition of vertical grayscale images at different angles without adjusting the camera posture.
[0084] The consistency range is defined as follows: the maximum deviation between the average offset values of the contours of each frame is less than 3 pixels, and the maximum deviation between the gray-scale centroid offset values of overlapping areas is less than 4 pixels. When the consistency of multiple frames is not met, a supplementary acquisition process is triggered: an intermediate angle is inserted between the acquired angles (e.g., if 0° and 20° have been acquired, then 10° is acquired), with 2-3 supplementary frames. The offset feature parameters of the supplementary frames are compared with the original frames again. If the consistency of at least 3 frames between the supplementary frames and the original frames meets the requirements, the judgment result is output. Otherwise, it is marked as "detection failed" and transferred to manual re-inspection. By comparing the consistency of multiple frames of images, misjudgments caused by interference factors such as accidental reflections or dust obstruction during a single acquisition can be eliminated. Suspicious results are marked and supplementary acquisition is triggered instead of directly outputting defect judgment, which reduces the production line downtime rate and scrap rate.
[0085] Single-frame image detection is susceptible to interference from random factors, while multi-frame, full-angle detection significantly increases detection time. This application employs a rotation acquisition strategy of "few frames, large angle intervals," using consistency comparison of 3-5 frames to screen suspicious results. Supplementary acquisition is triggered only when consistency is not met, rather than performing multi-frame detection on all samples. This dual mechanism of rapid initial screening and suspicious re-examination ensures detection reliability while keeping the average detection time within an acceptable range, balancing production line cycle time requirements with detection accuracy requirements.
[0086] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A PIN detection method based on machine vision, characterized in that, include: Acquire a grayscale image of the pin array to be detected in the vertical direction; in the pin array, the tips of the front row pins and the rear row pins partially overlap in the vertical projection direction; From the vertical grayscale image, identify the first projection area of the front row PIN needle tip on the horizontal plane, and identify the second projection area of the rear row PIN needle tip on the horizontal plane; the overlapping part of the first projection area and the second projection area is determined as the overlapping projection area; Establish a reference datum based on the measured contour shape of the first projection area; The following reference is adjusted based on the continuity of the gray-level gradient between the first projection region and the second projection region within the transition zone of the outline boundary of the overlapping projection region; Based on the deviation information of the measured contour shape of the first projection area from the pre-set standard contour shape, the deformation type of the front row PIN pins is identified, and the accompanying reference is compensated according to the structural mechanical transmission law corresponding to the deformation type to obtain the adjusted accompanying reference. The offset feature parameters of the second projection region relative to the adjusted following reference are obtained; the offset feature parameters include at least two of the following: contour-related offset, gray-scale centroid offset of overlapping regions, and projection overlap rate variability. The offset feature parameters are compared with a pre-set standard offset threshold range to determine the presence and / or position of the rear PIN pins. When the offset feature parameter exceeds the standard offset threshold range, the offset feature parameter is recorded as a defect feature vector, and the defect determination result is output.
2. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The establishment of the accompanying benchmarks includes: The measured contour shape of the first projection area is approximated by an ellipse to obtain its major axis direction, minor axis length and geometric center position; Using the geometric center position as the reference center and the major axis direction as the lateral reference direction, a local position reference system is established, consisting of a lateral reference axis and a longitudinal reference axis; the lateral reference axis and the longitudinal reference axis are perpendicular to each other; the local position reference system is the accompanying reference.
3. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The process for adjusting the grayscale gradient continuity includes: A sampling point is selected within the transition zone of the contour boundary of the overlapping projection area, and a grayscale profile curve is extracted along the local approximation direction at the sampling point; the local approximation direction is obtained by the direction of the line connecting the current sampling point and its adjacent sampling points. Determine the smoothness and continuity of the grayscale profile curve in the transition section between the first projection region and the second projection region; When the transition segment does not meet the pre-set smooth continuity conditions, the local coordinate orientation of the accompanying reference is adjusted until the transition segment meets the smooth continuity conditions.
4. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The deformation types include overall tilting, root bending, and tip torsion. For the overall tilted type, the structural mechanics transmission law is as follows: the overall tilted posture of the front row of PIN pins is transmitted through the plastic matrix in an approximately rigid manner, causing the parallel offset of the rear row of PIN pins. For the root-bending type, the structural mechanics transmission law is as follows: the root bending of the front row of PIN pins causes the gradual offset of the rear row of PIN pins through the local elastic deformation of the plastic matrix in a non-uniform transmission manner. For the tip-twisting type, the structural mechanics transmission law is as follows: the tip twist of the front row PIN pins causes the rotational displacement of the rear row PIN pins through the shear deformation of the plastic matrix in an angular transmission manner.
5. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The compensation for the accompanying benchmark includes: Based on the structural mechanics transmission law corresponding to the deformation type, the expected impact of the deformation type on the second projection area is calculated; Using the reverse compensation conditions corresponding to the expected impact results, the local coordinate orientation of the following reference is compensated and adjusted to obtain the adjusted following reference.
6. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The contour offset is obtained by point-by-point offset; the process of obtaining the point-by-point offset is as follows: In the local position reference system of the adjusted accompanying reference, multiple reference edge points are selected at set intervals along the contour edge of the adjusted accompanying reference. For each reference edge point, its vertical extension direction is obtained; on the contour boundary of the second projection area, the corresponding edge point located in the vertical extension direction and spatially closest to the reference edge point is searched; Obtain the positional deviation direction and positional deviation magnitude between each reference edge point and its corresponding edge point; integrate the positional deviation directions and positional deviation magnitudes of all reference edge points to form the contour-related offset.
7. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The grayscale centroid offset of the overlapping area is obtained by the relative positional offset between the centroids of the high-reflectivity area and the low-reflectivity area; the process of obtaining the centroids of the high-reflectivity area and the low-reflectivity area is as follows: Within the area enclosed by the contour boundary of the overlapping projection area, the grayscale value distribution of each pixel position is statistically analyzed. Pixel areas with gray values higher than a pre-set brightness threshold are defined as high reflectivity areas, and pixel areas with gray values lower than a pre-set darkness threshold are defined as low reflectivity areas. The average position of all pixels in the highly reflective area is obtained and used as the centroid of the highly reflective area; The average position of all pixels in the low-reflectivity area is obtained and used as the centroid of the low-reflectivity area.
8. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The variability of the projection overlap rate is obtained from the difference in the segment overlap ratio; the process of obtaining the difference in the segment overlap ratio is as follows: The adjusted local position reference system of the accompanying reference is divided into four azimuth regions according to the lateral reference axis and the longitudinal reference axis; The proportion of the pixel area of the overlapping projection region in each directional region to the total pixel area of that directional region is obtained, and the segment overlap ratio of each of the four directional regions is obtained. Find the highest and lowest overlap ratios among the four segments; The degree of difference between the highest and lowest percentages is used as the projection overlap rate variability.
9. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The existence state and location state are determined as follows: When the offset of the contour is lower than the preset missing threshold, it is determined that the rear row of PIN pins is missing; When the offset of the contour is lower than the preset normal threshold, and the offset of the gray-scale centroid of the overlapping area is lower than the preset normal posture threshold, and the projection overlap rate variation is absent or lower than the preset uniform threshold, it is determined that the rear row of PIN pins exists and is in a normal position. When the offset of the contour exceeds the preset normal threshold, or the offset of the gray-scale centroid of the overlapping area exceeds the preset normal posture threshold, or the variability of the projection overlap rate exists and exceeds the preset uniform threshold, it is determined that the rear row of PIN pins exists but the position is abnormal.
10. The PIN pin detection method based on machine vision according to claim 1, characterized in that, The method further includes: After the adjusted reference is obtained, the measured contour shape of the first projection area is compared with the pre-set standard contour shape to obtain the position deviation information of the front row PIN pins, and then the existence state and position state of the front row PIN pins are determined; the position state includes overall translation type, rotation type and scaling type. When the position of the current row of PIN pins is in an overall translational state, the standard offset threshold range is adjusted by overall translation. When the current row of PIN pins is in a rotating state, the standard offset threshold range is adjusted by angular rotation. When the position status of the current row of PIN pins is in scaling mode, the standard offset threshold range is adjusted by scaling. Before outputting the defect determination result, the offset feature parameters are calculated for multiple frames of vertical grayscale images acquired at different acquisition angles for the same PIN array; the offset feature parameters obtained from each of the multiple frames are compared for consistency; when the deviation between the offset feature parameters of the multiple frames is within a pre-set consistency range, the defect determination result is output; when the deviation between the offset feature parameters of the multiple frames exceeds the pre-set consistency range, the current detection result of the rear row of PINs is marked as suspicious, and a supplementary acquisition process is triggered.