PIN true position and flatness detection method based on CCD visual detection

By combining multi-reflection optical paths and a deep network model, the problem of insufficient accuracy and robustness in the reconstruction of the three-dimensional geometric parameters of PIN pins in CCD visual inspection is solved, achieving high-precision detection of PIN pin alignment and flatness, and enhancing the system's adaptability and detection accuracy.

CN121594760APending Publication Date: 2026-03-03SANSHUI YIPIN ELECTRICAL APPLIANCE ACCESSORIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610066371.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-19
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing CCD vision inspection technology lacks accuracy in reconstructing the three-dimensional geometric parameters of PIN pins and robustness in image processing. In particular, when faced with differences in workpiece surface material, fluctuations in ambient lighting, or manufacturing tolerances, it is difficult to effectively decouple axial offset and height deviation, affecting the evaluation of alignment and flatness.

Method used

The top and side views of the PIN pin are acquired simultaneously using a multi-reflection optical path. The initial three-dimensional geometric parameters are intelligently corrected by combining a deep network model. The top and side views of the PIN pin are acquired simultaneously during the visual inspection process using a multi-reflection optical path. The initial three-dimensional geometric parameters are intelligently corrected by adding a deep network model, which adaptively compensates for the effects of optical distortion, edge extraction deviation and environmental interference.

Benefits of technology

It enhances the 3D reconstruction accuracy and robustness of the vision inspection system, improves the detection accuracy of PIN pin alignment and flatness, and enhances the adaptability to environmental changes and workpiece surface differences.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121594760A_ABST
    Figure CN121594760A_ABST
Patent Text Reader

Abstract

The invention discloses a PIN true position and flatness detection method based on CCD visual inspection, and relates to the technical field of machine visual inspection. A carrying mechanism, a positioning jig and a CCD visual inspection camera are initialized to obtain an initialization result; a carrying mechanism is driven according to the initialization result, the workpiece with the PIN needle is fed into a positioning jig and clamped, and the workpiece with the stable posture is formed; based on the workpiece with the stable posture, a CCD visual inspection camera is controlled, and a top view image and a side view image of the workpiece are collected at the same time through multiple reflection light paths; extracting the two-dimensional features of the end part and the axis of each PIN from the PIN feature calibration image, and carrying out combined calculation to obtain the corrected three-dimensional geometric parameters of the PINs; top view and side view images of the PIN are synchronously obtained in the visual detection process through multiple reflection light paths, and the three-dimensional reconstruction precision and robustness of the visual detection system are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision inspection technology, and in particular to a method for detecting the alignment and flatness of PIN pins based on CCD vision inspection. Background Technology

[0002] In the field of precision electronic connector manufacturing, PIN pins, as key conductive and structural components, directly affect the electrical performance, mating life, and assembly reliability of products due to their alignment (i.e., the positional deviation of the axis relative to the reference plane) and flatness (i.e., the consistency of end height). In recent years, with the development of automated inspection technology, non-contact visual inspection methods based on machine vision have gradually replaced traditional contact probe measurements, becoming the mainstream process. Among them, CCD (Charge-Coupled Device) visual inspection systems, with their high resolution, high repeatability, and fast imaging capabilities, are widely used for online visual inspection of PIN pin geometric parameters. Existing visual inspection technologies have significant limitations in achieving accurate reconstruction of the three-dimensional geometric parameters of PIN pins: single-view or asynchronously acquired multi-view images struggle to effectively decouple axial offset and height deviation, leading to the coupling of alignment and flatness assessments and the accumulation of errors. Furthermore, traditional visual inspection image processing typically relies on fixed thresholds or empirical parameters for edge detection, which lacks robustness when faced with differences in workpiece surface material, fluctuations in ambient lighting, or image noise caused by manufacturing tolerances, thus affecting the accuracy of subsequent calibration and measurement. Summary of the Invention

[0003] In view of the aforementioned existing problems, the present invention is proposed.

[0004] Therefore, this invention provides a method for detecting the alignment and flatness of PIN pins based on CCD vision inspection, which solves the problems of insufficient accuracy in reconstructing the three-dimensional geometric parameters of PIN pins and insufficient robustness in image processing.

[0005] To solve the above-mentioned technical problems, the present invention provides the following technical solution: This invention provides a method for detecting the alignment and flatness of PIN pins based on CCD vision inspection. The method includes: initializing a transport mechanism, a positioning fixture, and a CCD vision inspection camera to obtain initialization results; driving the transport mechanism based on the initialization results to feed a workpiece with PIN pins into the positioning fixture and clamp it, forming a workpiece with a stable posture; controlling the CCD vision inspection camera based on the stable posture of the workpiece to simultaneously acquire top and side view images of the workpiece through multiple reflection light paths; performing denoising, distortion correction, and grayscale processing on the top and side view images, and combining this with calibration parameters obtained from the calibration target on the positioning fixture to obtain a PIN pin feature calibration image; extracting two-dimensional features of the ends and axes of each PIN pin from the PIN pin feature calibration image and performing joint calculations to obtain corrected three-dimensional geometric parameters for the PIN pins; calculating the alignment and end height deviation of each PIN pin based on the corrected three-dimensional geometric parameters to obtain alignment and flatness results; controlling the transport mechanism to sort the workpieces and recording the detection results.

[0006] As a preferred embodiment of the PIN pin alignment and flatness detection method based on CCD visual inspection described in this invention, the specific steps for obtaining the initialization result are as follows: Connect the power and air supply, check the safety components of the emergency stop button and access control switch, execute the origin reset action through the conveying mechanism and set the material picking position, material placing position and movement speed parameters of the conveying mechanism to obtain the picking and placing position parameters of the conveying mechanism; The clamping mechanism and limiting mechanism of the driving positioning fixture open and close in sequence, detect the position of the positioning pin, limiting surface and clamping part, and save the reference height parameter and reference plane parameter of the positioning fixture. Start the CCD vision inspection camera and its supporting illumination. Obtain the predetermined grayscale distribution by adjusting the focal length, aperture, exposure time and gain. Combine the reference height parameters and reference plane parameters of the positioning fixture to obtain the initial imaging parameters of the CCD vision inspection camera. The initialization result is composed of the pick-up and place position parameters of the conveying mechanism, the reference height parameters and reference plane parameters of the positioning fixture, and the initial imaging parameters of the CCD vision inspection camera.

[0007] As a preferred embodiment of the CCD vision-based method for detecting the alignment and flatness of PIN pins according to the present invention, the specific steps for forming a workpiece with stable posture are as follows: Based on the material picking position parameters saved in the initialization results, drive the conveying mechanism to move to the material picking position in the feeding area, perform suction and clamping actions on the workpiece with PIN pins, and grab the workpiece with PIN pins. Based on the feeding position and movement speed parameters saved in the initialization results, the conveying mechanism is controlled to move the workpiece above the positioning fixture, and the termination position of the conveying mechanism is adjusted according to the reference plane parameters of the positioning fixture to align the workpiece with the positioning fixture. The control and handling mechanism lowers the workpiece aligned with the positioning fixture onto the reference plane of the positioning fixture, and drives the positioning fixture to press and limit the workpiece shell, resulting in a workpiece with stable posture.

[0008] As a preferred embodiment of the CCD vision inspection-based method for detecting the alignment and flatness of PIN pins according to the present invention, the specific steps for acquiring the top view image and side view image of the workpiece are as follows. Based on the workpiece with stable posture, the focal length, aperture, exposure time and gain of the CCD vision inspection camera are adjusted according to the imaging parameters in the initialization result, and the illumination source corresponding to the multi-reflection optical path is turned on to obtain the CCD vision inspection camera and multi-reflection optical path in the state to be acquired. The CCD vision inspection camera, which controls the state to be acquired, issues an exposure command. The top and side views of the workpiece, which are imaged through multiple reflection optical paths, are simultaneously projected onto the imaging surface of the CCD vision inspection camera to obtain the original image signal. The original image signal is converted from analog to digital and cached in the memory of an industrial computer according to a pixel array format. The pixel segments corresponding to different reflection paths are marked as top view images and side view images, respectively.

[0009] As a preferred embodiment of the PIN pin alignment and flatness detection method based on CCD visual inspection described in this invention, the denoising, distortion correction, and grayscale processing of the top view image and the side view image refer to performing noise suppression processing on the top view image and the side view image respectively, followed by pixel coordinate remapping processing to obtain the distortion-corrected top view image and the distortion-corrected side view image, and then performing grayscale normalization and brightness equalization processing to obtain the preprocessed top view image and the preprocessed side view image.

[0010] As a preferred embodiment of the PIN pin alignment and flatness detection method based on CCD visual inspection described in this invention, the specific steps for obtaining the PIN pin feature calibration image are as follows: The outline of the calibration target on the positioning fixture is identified in the preprocessed top view image and the preprocessed side view image. The pixel coordinates of the feature points of the calibration target are extracted and corresponded with the spatial coordinates of the calibration target on the positioning fixture. The internal and external parameters and distortion coefficients in the top view direction and the side view direction are solved to obtain the calibration parameters. Geometric correction and region cropping are performed on regions in the preprocessed top view image and preprocessed side view image using calibration parameters, and the correspondence and storage are performed to obtain PIN pin feature calibration images; the PIN pin feature calibration images include region top view images and region side view images.

[0011] As a preferred embodiment of the CCD vision-based detection method for pin alignment and flatness according to the present invention, the specific steps for extracting two-dimensional features of each pin tip and axis from the pin feature calibration image and performing joint calculation are as follows: Extract the pin tip contour from the top view image of the region and fit the end center point and axis projection direction. Extract the pin tip edge point and side contour from the side view image of the region and fit the side view axis projection direction. Output two-dimensional feature data. By using calibration parameters, the top-view two-dimensional feature data and the side-view two-dimensional feature data are unified into the workpiece coordinate system and jointly solved to obtain the initial three-dimensional geometric parameters of the PIN needle.

[0012] As a preferred embodiment of the PIN pin alignment and flatness detection method based on CCD vision inspection described in this invention, the specific steps for obtaining the corrected three-dimensional geometric parameters of the PIN pin are as follows: The top view image region and the side view image region are combined with the initial 3D geometric parameters of the PIN needle to form a joint feature vector, which is then input into the deep network model. A deep network model is used to jointly analyze the PIN pin feature calibration image region and the initial three-dimensional geometric parameters of the PIN pin, outputting the PIN pin three-dimensional position correction, axis direction correction, and end height correction, which are then superimposed on the initial three-dimensional geometric parameters of the PIN pin to generate the PIN pin corrected three-dimensional geometric parameters.

[0013] As a preferred embodiment of the PIN pin alignment and flatness detection method based on CCD vision inspection described in this invention, the specific steps for obtaining the alignment and flatness results are as follows: Read the theoretical reference coordinate system, theoretical PIN position, and theoretical PIN axis direction of the PIN array in the product design drawings. Map the three-dimensional coordinates of the bottom reference point and end reference point of the PIN to the theoretical reference coordinate system to calculate the position deviation. Calculate the angle deviation between the three-dimensional direction of the PIN axis and the theoretical PIN axis direction to obtain the alignment result. The three-dimensional coordinates of all PIN pin end reference points are fitted to a reference plane, and the distance from each PIN pin end reference point to the reference plane is calculated as the end height deviation. The difference between the maximum end height deviation and the minimum end height deviation is calculated to obtain the flatness result.

[0014] As a preferred embodiment of the PIN pin alignment and flatness detection method based on CCD visual inspection described in this invention, the specific steps for recording the detection results are as follows: The positional accuracy result and the flatness result are compared with the upper limit of the positional accuracy tolerance and the upper limit of the flatness tolerance given in the product design drawings to obtain the workpiece judgment result; Based on the workpiece judgment result, a sorting instruction is generated and output to the conveying mechanism. The conveying mechanism takes the workpiece out from the positioning fixture and sends it to the good product collection position according to the workpiece judgment result, thus obtaining the sorted workpiece. The alignment result, flatness result and workpiece judgment result are written into the inspection record to form the inspection result.

[0015] The beneficial effects of this invention are as follows: by using multiple reflection optical paths to simultaneously acquire the top and side view images of the PIN pin during the visual inspection process, adding a deep network model to intelligently correct the initial three-dimensional geometric parameters, deeply integrating the image features obtained from visual inspection with the geometric solution results, adaptively compensating for the influence of factors such as optical distortion, edge extraction deviation and environmental interference on the accuracy of visual inspection, thereby enhancing the three-dimensional reconstruction accuracy and robustness of the visual inspection system. Attached Figure Description

[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a flowchart of a method for detecting the alignment and flatness of PIN pins based on CCD vision inspection.

[0018] Figure 2 This is a flowchart of the initialization process.

[0019] Figure 3 This is a flowchart for workpiece handling and image acquisition.

[0020] Figure 4 A flowchart for generating two-dimensional feature data. Detailed Implementation

[0021] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0022] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0023] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0024] Reference Figures 1-4 This is one embodiment of the present invention, which provides a method for detecting the alignment and flatness of a PIN pin based on CCD visual inspection, comprising the following steps: S1. Initialize the handling mechanism, positioning fixture, and CCD vision inspection camera to obtain the initialization results.

[0025] S1.1. Connect the power and air supply, check the safety components of the emergency stop button and access control switch, execute the origin reset action through the conveying mechanism and set the material picking position, material placing position and movement speed parameters of the conveying mechanism to obtain the picking and placing position parameters of the conveying mechanism.

[0026] Specifically, after connecting the power and air supply, the on / off status of the emergency stop button and access control switch safety components are checked sequentially to confirm that the emergency stop button is in the released state and the access control switch is in the closed allowable state. After the safety status is confirmed, the transport mechanism is controlled to perform the origin reset action, so that each motion axis of the transport mechanism returns to the mechanical zero point position. The cumulative position error is eliminated by the origin reset result. Based on the completion of the origin reset, the material picking position, material placing position and movement speed parameters of the transport mechanism are set one by one according to the spatial layout of the production station. The material picking position corresponds to the spatial position of the workpiece in the feeding area, the material placing position corresponds to the loading position of the positioning fixture, and the movement speed parameter is used to limit the running speed and acceleration of the transport mechanism during the material picking, moving and placing process to ensure the stability of the workpiece during the transport process. The material picking position, material placing position and movement speed parameters are saved as the picking and placing position parameters of the transport mechanism.

[0027] S1.2. The clamping mechanism and limiting mechanism of the driving positioning fixture perform opening and closing actions in sequence, detect the position of the positioning pin, limiting surface and clamping part, and save the reference height parameters and reference plane parameters of the positioning fixture.

[0028] Specifically, after the origin of the conveying mechanism is reset and the pick-up and put-down position parameters of the conveying mechanism are obtained, the clamping mechanism and the limiting mechanism of the positioning fixture are driven in sequence to perform opening and closing actions. Through the opening and closing actions, the positioning pin, the limiting surface and the clamping part move completely to their respective working positions in a workless state. The relative positional relationship between the positioning pin and the limiting surface is detected, and the pressing stroke and contact position of the clamping part are detected at the same time. After the position detection is completed, the relative height relationship between the top of the positioning pin and the reference surface of the positioning fixture is determined as the reference height parameter of the positioning fixture, and the geometric relationship of multiple limiting surfaces in space is determined as the reference plane parameter of the positioning fixture.

[0029] It should be noted that the reference surface of the positioning fixture is a geometric plane on the positioning fixture that serves as a reference for the placement height and posture of the workpiece. It is used to unify the spatial reference of the workpiece during the inspection process. It is determined by the coplanar structure formed by the bearing surface, the limiting surface, or multiple support points when the positioning fixture is in a workpiece-free state. After the clamping mechanism and the limiting mechanism of the positioning fixture perform the opening and closing action, the relative positional relationship of the positioning pin, the limiting surface, and the bearing contact surface is detected. The plane that can stably bear the workpiece and has consistent repeatability is determined as the reference surface of the positioning fixture.

[0030] S1.3. Start the CCD visual inspection camera and its supporting illumination. Obtain the predetermined grayscale distribution by adjusting the focal length, aperture, exposure time and gain. Combine the reference height parameters and reference plane parameters of the positioning fixture to obtain the initial imaging parameters of the CCD visual inspection camera.

[0031] Specifically, the CCD visual inspection camera is activated and its corresponding illumination is turned on, allowing the CCD visual inspection camera to image the positioning fixture when it is unloaded and the fixture is in a reference state. By adjusting the focal length of the CCD visual inspection camera, the surface of the positioning fixture and the outline of the calibration target are clearly imaged. Then, the aperture is adjusted, along with the exposure time and gain, to ensure that the grayscale distribution of the reference surface area of ​​the positioning fixture and the calibration target area in the top and side view images is distinguishable, while avoiding significant overexposure or underexposure. Grayscale statistics are performed on the top and side view images respectively, and grayscale histograms are generated. Based on the bimodal or multimodal characteristics of the target and background regions in the gray-scale histogram distribution, an adaptive threshold determination method is used to determine the gray-scale threshold, including the maximum inter-class variance method or the bimodal valley search method. This allows the gray-scale threshold to be automatically adjusted with changes in exposure time, gain, and illumination to stably segment the target contour. The current focal length, aperture, exposure time, and gain are used as imaging parameters. Combined with the reference height and reference plane parameters of the positioning fixture, the correspondence between the imaging plane of the CCD vision inspection camera and the spatial position of the positioning fixture is established to obtain the initial imaging parameters of the CCD vision inspection camera.

[0032] S1.4. The initialization result is formed by combining the pick-up and place position parameters of the conveying mechanism, the reference height parameters and reference plane parameters of the positioning fixture, and the initial imaging parameters of the CCD vision inspection camera.

[0033] Specifically, the pick-up and place position parameters of the conveying mechanism are used as the basis for the spatial transfer information of the workpiece between the feeding area and the positioning fixture. The reference height parameters and reference plane parameters of the positioning fixture are used as spatial reference information to limit the placement height and posture of the workpiece. The initial imaging parameters of the CCD vision inspection camera are used as the basis for the imaging conditions when acquiring subsequent top and side view images. The three types of parameters are summarized and stored according to a unified parameter structure, so that the movement position of the conveying mechanism, the spatial reference of the positioning fixture, and the imaging relationship of the CCD vision inspection camera remain consistent in the same inspection process, thus jointly constituting the initialization result.

[0034] S2. Drive the conveying mechanism according to the initialization result, send the workpiece with PIN pins into the positioning fixture and clamp it to form a workpiece with stable posture.

[0035] S2.1. Based on the material picking position parameters saved in the initialization results, drive the conveying mechanism to move to the material picking position in the feeding area, perform suction and clamping actions on the workpiece with PIN pins, and grab the workpiece with PIN pins.

[0036] Specifically, the material picking position parameters saved in the initialization result are read, and the conveying mechanism is controlled to move along the motion trajectory to the material picking position in the feeding area according to the material picking position parameters, so that the material picking end of the conveying mechanism is in a graspable spatial alignment state with the workpiece with PIN pins. After the spatial alignment is completed, the conveying mechanism is driven to perform suction and clamping actions, so that the suction component forms a negative pressure adsorption on the workpiece or the clamping component clamps and holds the workpiece. After the suction and clamping actions are completed, the displacement sensor is triggered to detect the displacement change of the material picking end of the conveying mechanism. The displacement sensor detection results can be used to determine whether the workpiece with PIN pins has moved synchronously with the material picking end of the conveying mechanism, confirming that the workpiece with PIN pins has been reliably grasped by the conveying mechanism, and outputting the workpiece reliably grasped by the conveying mechanism.

[0037] S2.2. Based on the feeding position and movement speed parameters saved in the initialization results, control the conveying mechanism to move the workpiece above the positioning fixture, and adjust the termination position of the conveying mechanism according to the reference plane parameters of the positioning fixture to align the workpiece with the positioning fixture.

[0038] Specifically, the loading position and motion speed parameters saved in the initialization results are read, and the conveying mechanism is controlled to switch between acceleration, constant speed and deceleration during the conveying process according to the motion speed parameters. This is to move the workpiece along the predetermined path to the vicinity of the loading position above the positioning fixture while maintaining the stability of the workpiece gripping state. After the conveying mechanism reaches the vicinity of the loading position, the spatial target position of the conveying mechanism is determined according to the loading position parameters. The termination position of the conveying mechanism is adjusted in combination with the reference plane parameters of the positioning fixture to make the outer reference of the workpiece shell form a spatial alignment relationship with the positioning pin and limiting surface of the positioning fixture. At the same time, the workpiece maintains a pre-reserved loading distance matching the reference plane of the positioning fixture in the height direction. After completing the alignment and termination position correction, the workpiece aligned with the positioning fixture is output.

[0039] S2.3. Based on the workpiece of the alignment and positioning fixture, the control and transport mechanism lowers the workpiece of the alignment and positioning fixture onto the reference plane of the positioning fixture, and drives the positioning fixture to press and limit the workpiece shell to obtain a workpiece with stable posture.

[0040] Specifically, the control conveying mechanism moves the workpiece aligned with the positioning fixture in a slow, vertical direction, gradually lowering it so that the bottom surface of the workpiece shell gradually contacts the reference plane of the positioning fixture. After contact is established, it continues to be lowered to the final position, so that the workpiece shell is fitted and positioned with the positioning pin and limiting surface of the positioning fixture. After the workpiece reaches the reference plane of the positioning fixture and is fitted and positioned, the clamping mechanism of the positioning fixture is driven to perform a clamping action, so that the clamping part forms a surface contact or line contact with the workpiece shell. At the same time, the limiting mechanism of the positioning fixture is driven to perform a limiting action, so that the limiting surface forms a lateral constraint with the workpiece shell, thereby restricting the workpiece from moving in the plane and rotating around the vertical direction. After the clamping and limiting actions are completed, the clamping state is maintained without release, and the clamping mechanism and limiting mechanism of the positioning fixture jointly maintain the stability of the workpiece position and posture, outputting a workpiece with a stable posture.

[0041] S3. Based on the workpiece with stable posture, control the CCD vision inspection camera to simultaneously acquire the top view image and side view image of the workpiece through multiple reflection light paths.

[0042] S3.1. Based on the workpiece with stable posture, adjust the focal length, aperture, exposure time and gain of the CCD vision inspection camera according to the imaging parameters in the initialization result, and turn on the illumination source corresponding to the multi-reflection optical path to obtain the CCD vision inspection camera and multi-reflection optical path in the state to be acquired.

[0043] Specifically, the imaging parameters in the initialization results are read, and the CCD vision inspection camera is sequentially adjusted for focal length, aperture, exposure time, and gain according to these parameters. This ensures that the imaging clarity, light intake, exposure, and signal amplification of the CCD vision inspection camera meet the imaging conditions defined by the initialization results. Focal length adjustment ensures that the stable workpiece is clearly imaged on the CCD vision inspection camera's imaging surface. Aperture adjustment matches the brightness of the accompanying illumination and controls the depth of field. Exposure time setting controls the light integration amount for a single acquisition. Gain setting amplifies the acquired signal. The illumination source corresponding to the multi-reflection optical path is turned on, providing imaging illumination conditions for the stable workpiece in both top and side views. The multi-reflection optical path is then in a working state that can simultaneously guide top and side light rays to the CCD vision inspection camera's imaging surface, thus obtaining the CCD vision inspection camera and multi-reflection optical path in the state to be acquired.

[0044] S3.2. Control the CCD vision inspection camera in the acquisition state to issue an exposure command, and project the top view light and side view light of the workpiece through multi-reflection light path imaging onto the imaging surface of the CCD vision inspection camera at the same time to obtain the original image signal.

[0045] Specifically, an exposure command is sent to the CCD vision inspection camera, causing the CCD vision inspection camera to start image acquisition according to the exposure time and gain. During the exposure period, the workpiece with a stable posture is illuminated. The reflected light from the workpiece surface forms a top-view light propagation path and a side-view light propagation path in the multi-reflection light path. The top-view light directly reaches the imaging surface of the CCD vision inspection camera through the top-view light propagation path, while the side-view light reaches the imaging surface of the CCD vision inspection camera after being refracted by a mirror or prism through the side-view light propagation path. The top-view light and the side-view light are simultaneously projected onto the imaging surface of the CCD vision inspection camera within the same exposure time window, forming photoelectric signals corresponding to the top-view and side-view angles on the imaging surface of the CCD vision inspection camera. The photoelectric signals are output as the original image signal in the form of continuous electrical signals.

[0046] S3.3. Perform analog-to-digital conversion on the original image signal and cache it in the memory of the industrial computer according to the pixel array format. Mark the pixel segments corresponding to different reflection paths as top view images and side view images respectively.

[0047] Specifically, the original image signal is input into the analog-to-digital converter (ADC). When the original image signal is input, it is a time-varying analog voltage signal. The ADC first samples and holds the original image signal, keeping the analog voltage constant for a short period at each sampling time. Then, within each sample-and-hold period, the ADC quantizes the constant analog voltage, mapping it to a corresponding digital code value. The quantization process divides the amplitude of the analog voltage into multiple discrete levels and outputs binary codes corresponding to these discrete levels. Simultaneously, the ADC synchronously samples according to the pixel readout timing of the CCD vision inspection camera, processing each row of pixels... The digital code values ​​are output in row and column order and written into the memory of the industrial computer to form a grayscale value matrix consistent with the pixel array of the CCD vision inspection camera. The converted grayscale value matrix is ​​then organized in row and column order into an image cache in pixel array format and written into the memory of the industrial computer. Based on the fixed imaging layout of the multi-reflection light path on the imaging surface of the CCD vision inspection camera, the pixel array in the memory of the industrial computer is divided into regions. The imaging area formed by the top-view light propagation path is marked as the top view image segment, and the imaging area formed by the side-view light propagation path is marked as the side view image segment. The top view image is extracted from the top view image segment, and the side view image is extracted from the side view image segment.

[0048] S4. Denoise, correct distortion, and process grayscale on the top and side view images, and obtain calibration parameters by combining them with the calibration target on the positioning fixture to obtain the PIN needle feature calibration image.

[0049] S4.1. Denoising, distortion correction, and grayscale processing of top and side view images refer to performing noise suppression processing on the top and side view images respectively, followed by pixel coordinate remapping processing to obtain the distortion-corrected top and side view images, and then performing grayscale normalization and brightness equalization processing to obtain the preprocessed top and side view images.

[0050] Specifically, after obtaining the top view and side view images, noise suppression processing is first performed on the top view and side view images respectively. Spatial domain filtering is used to reduce random noise, isolated bright spots, and background texture interference, making the grayscale transition of the PIN pin edge more continuous. After completing the noise suppression processing, distortion correction is performed on the top view and side view images according to the distortion parameters of the corresponding lens of the CCD vision inspection camera. The edge curvature and scale drift caused by radial and tangential distortion are eliminated by pixel coordinate remapping, so that the geometric relationship of the top view and side view images is consistent with the spatial reference of the positioning fixture. After completing the distortion correction, grayscale processing is performed on the top view and side view images. Grayscale normalization and brightness equalization are used to adjust the grayscale dynamic range and local brightness distribution, so that the grayscale distribution of the top view and side view images meets the needs of subsequent calibration target recognition and PIN pin contour extraction, and the preprocessed top view image and preprocessed side view image are output respectively.

[0051] It should be noted that distortion parameters are a set of parameters describing the degree of geometric distortion generated during the imaging process of a CCD vision inspection camera lens. Distortion parameters typically include radial distortion parameters and tangential distortion parameters. Radial distortion parameters are used to describe barrel or pincushion distortion caused by the symmetry of the lens optical axis, while tangential distortion parameters are used to describe asymmetric distortion caused by lens mounting eccentricity or tilt. Distortion parameters originate from the camera calibration process. After mapping the pixel coordinates of the calibration target feature points in the preprocessed top view image and the preprocessed side view image to the spatial coordinates of the calibration target on the positioning fixture, the intrinsic parameters, extrinsic parameters, and distortion parameters are simultaneously solved through camera calibration calculations.

[0052] S4.2. Identify the outline of the calibration target on the positioning fixture in the preprocessed top view image and the preprocessed side view image, extract the pixel coordinates of the feature points of the calibration target, and match them with the spatial coordinates of the calibration target on the positioning fixture. Solve for the intrinsic and extrinsic parameters and distortion coefficients in the top view direction and the side view direction to obtain the calibration parameters.

[0053] Specifically, the calibration target region on the positioning fixture is obtained from the preprocessed top view image and the preprocessed side view image, respectively. The calibration target contour is obtained through grayscale threshold segmentation and filtering. For example, in the preprocessed top view image, the pixel grayscale values ​​are statistically analyzed to form a grayscale histogram distribution. When the calibration target region and the background region show obvious separation in the grayscale histogram distribution, an adaptive grayscale threshold determination method is used to select the grayscale threshold. The preprocessed top view image is then binarized, so that pixels with grayscale values ​​greater than the grayscale threshold are identified as candidate calibration target pixels, and pixels with grayscale values ​​less than the grayscale threshold τ are identified as background pixels. After binarization, connected component filtering is performed on the candidate calibration target pixels, and the area is retained. The closed contour of the calibration target is obtained by connecting regions whose shape features match the calibration target. The edge of the calibration target contour is refined to extract calibration target feature points in the form of corner points, center points, or intersection points. Then, the pixel coordinates of the calibration target feature points are obtained by sub-pixel corner point extraction or sub-pixel center point extraction. After obtaining the pixel coordinates of the calibration target feature points, the pixel coordinates of the calibration target feature points are matched one-to-one with the calibration target spatial coordinates of the positioning fixture according to the calibration target number. The geometric relationship between the pixel coordinates and the spatial coordinates of the positioning fixture is established for the top view direction and the side view direction respectively. The intrinsic parameters, extrinsic parameters and distortion coefficients of the top view direction and the side view direction are solved by camera calibration calculation to obtain the calibration parameters.

[0054] It should be noted that the grayscale threshold is obtained based on the grayscale distribution characteristics in the preprocessed top view image and the preprocessed side view image. After performing grayscale statistics on the preprocessed top view image and the preprocessed side view image, the frequency of each grayscale level in the corresponding image is first calculated to form a grayscale histogram distribution. Then, based on the bimodal or multimodal characteristics of the calibration target area and the background area in the grayscale histogram distribution, the boundary position between different grayscale peaks is selected as the example value of the grayscale threshold: In the grayscale histogram distribution of the preprocessed top view image, the grayscale of the background area is concentrated in the example value of 30 to 70, and the grayscale of the calibration target area is concentrated in the example value of 160 to 220. The grayscale threshold can be taken as the boundary position of 120 between the two sets of grayscale peaks.

[0055] S4.3. Use calibration parameters to perform geometric correction and region cropping on the regions in the preprocessed top view image and preprocessed side view image, and perform correspondence and storage to obtain the PIN needle feature calibration image.

[0056] Specifically, geometric correction is performed on the preprocessed top view image and the preprocessed side view image respectively. The pixel coordinates are remapped by anti-distortion and perspective correction using the intrinsic parameters, extrinsic parameters and distortion coefficients in the calibration parameters. At the same time, a fixed correspondence is established between the imaging scale and the spatial scale in the top view direction and the side view direction. The position range of the workpiece in the preprocessed top view image and the preprocessed side view image is determined according to the reference plane parameters of the positioning fixture. According to the arrangement order of the PIN array, the image regions containing the ends of each PIN pin and the surrounding background are extracted from the geometrically corrected preprocessed top view image and the geometrically corrected preprocessed side view image. The image regions are matched one-to-one according to the PIN pin number. The top view image region and the side view image region corresponding to the same PIN pin number are associated and stored. The associated storage result is output as a PIN pin feature calibration image. The PIN pin feature calibration image includes the region top view image and the region side view image.

[0057] S5. Extract the two-dimensional features of each pin tip and axis from the pin feature calibration image and perform joint calculation to obtain the corrected three-dimensional geometric parameters of the pin.

[0058] S5.1. Extract the pin tip contour from the top view image of the region and fit the end center point and axis projection direction. Extract the pin tip edge point and side contour from the side view image of the region and fit the side view axis projection direction. Output two-dimensional feature data.

[0059] Specifically, edge detection and contour extraction are performed on the pin tip region in the top-view corresponding image of the region. By shape fitting the extracted closed end contour, the geometric center position of the pin tip contour is determined, and the end contour center point is used as the pin tip center point in the top-view direction. At the same time, the projection direction of the pin tip axis in the top-view direction is fitted according to the long axis direction of the end contour or the distribution trend of adjacent contour points. In the side-view corresponding image of the region, edge extraction is performed on the pin tip and the side of the pin body to obtain the pin tip edge point set and the side contour of the pin body. By straight line fitting the side contour, the projection direction of the pin tip axis in the side-view direction is determined, and the position of the end center point in the side-view direction is determined simultaneously. The coordinates of the end center point and the axis projection direction parameters obtained in the top-view direction and the coordinates of the end center point and the axis projection direction parameters obtained in the side-view direction are sorted and output to form two-dimensional feature data.

[0060] S5.2. Using calibration parameters, the top-view two-dimensional feature data and the side-view two-dimensional feature data are unified into the workpiece coordinate system and jointly solved to obtain the initial three-dimensional geometric parameters of the PIN needle.

[0061] Specifically, the intrinsic and extrinsic parameters and distortion coefficients corresponding to the top and side views are read from the calibration parameters. Coordinate inverse calculation is performed on the top and side view 2D feature data, converting them from their respective pixel coordinate systems to spatial constraint information in the workpiece coordinate system referenced by the positioning fixture's reference plane. The projection position of the end center point of the same PIN pin in the top view direction and the projection direction of its axis are jointly calculated, as well as the projection position of the end center point of the same PIN pin in the side view direction. The three-dimensional direction of the PIN pin axis in the workpiece coordinate system is determined through spatial linear intersection and minimum error fitting. Simultaneously, based on the top and side views... The three-dimensional coordinates of the PIN pin end reference point are calculated based on the spatial correspondence of the end center point in the view direction. The three-dimensional coordinates of the PIN pin bottom reference point are then obtained by back-calculation along the three-dimensional axis. The three-dimensional coordinates of the PIN pin axis, the end reference point, and the bottom reference point are combined and output as the initial three-dimensional geometric parameters of the PIN pin. The three-dimensional coordinates of the PIN pin end reference point are the three-dimensional coordinates of the PIN pin end center point in the workpiece coordinate system obtained by jointly solving the top view two-dimensional feature data and the side view two-dimensional feature data. The three-dimensional coordinates of the PIN pin bottom reference point are the three-dimensional coordinates of the PIN pin bottom reference point in the workpiece coordinate system obtained by back-calculation along the three-dimensional axis of the PIN pin from the end reference point three-dimensional coordinates.

[0062] S5.3. Combine the top view image region and the side view image region with the initial three-dimensional geometric parameters of the PIN needle to form a joint feature vector, and input it into the deep network model.

[0063] Specifically, the top view image region and side view image region corresponding to the PIN needle number are combined with the initial three-dimensional geometric parameters of the PIN needle. The top view image region and side view image region are used to characterize the actual imaging characteristics of the PIN needle tip and needle body under different viewpoints. The initial three-dimensional geometric parameters of the PIN needle are used to characterize the spatial position and axial direction of the PIN needle obtained through geometric reconstruction. The top view image region and side view image region are stitched together according to the image arrangement, and the initial three-dimensional geometric parameters of the PIN needle are parameterized according to the corresponding PIN needle order. The combination result is then used as the input content of the deep network model and fed into the deep network model.

[0064] S5.4. Use a deep network model to jointly analyze the PIN pin feature calibration image region and the initial three-dimensional geometric parameters of the PIN pin, output the PIN pin three-dimensional position correction amount, axis direction correction amount and end height correction amount, and superimpose them on the initial three-dimensional geometric parameters of the PIN pin to generate the PIN pin corrected three-dimensional geometric parameters.

[0065] Specifically, the deep network model jointly analyzes the correspondence between the pin tip morphology features in the top view image region, the pin body tilt features in the side view image region, and the initial three-dimensional geometric parameters of the pin. Through multi-layer feature mapping, it comprehensively evaluates the imaging features and geometric reconstruction errors, and outputs the three-dimensional position correction, axial direction correction, and end height correction for each pin. The three-dimensional position correction is used to correct the spatial position deviation of the pin in the workpiece coordinate system, the axial direction correction is used to correct the angular deviation of the pin axis, and the end height correction is used to correct the reconstruction error of the pin tip in the height direction. The three-dimensional position correction is superimposed on the spatial position parameter in the initial three-dimensional geometric parameters of the pin, the axial direction correction is superimposed on the axial direction parameter in the initial three-dimensional geometric parameters of the pin, and the end height correction is superimposed on the end height parameter in the initial three-dimensional geometric parameters of the pin to generate the corrected three-dimensional geometric parameters of the pin.

[0066] It should be noted that the deep network model training is based on offline collected samples. Each training sample contains a top view image region and a side view image region consistent with the actual detection process. The difference between the real three-dimensional geometric parameters and the initial three-dimensional geometric parameters of the PIN needle obtained by geometric reconstruction through high-precision contact measurement is used as a supervision label. The parameters of the deep network model are gradually optimized in multiple rounds of iterative training to obtain the trained deep network model. The deep network model consists of an input feature layer, an image feature extraction layer, a geometric feature mapping layer, a feature fusion layer, and a correction output layer connected sequentially. Each layer transmits information in a fixed order and forms a hierarchical constraint relationship. The input feature layer receives the top view image region, the side view image region, and the initial three-dimensional geometric parameters of the PIN corresponding to the same pin. The image feature extraction layer performs convolution operations and feature mapping on the top view image region and the side view image region, respectively. The geometric feature mapping layer performs parameter unrolling and scale normalization on the initial three-dimensional geometric parameters of the PIN. The feature fusion layer concatenates and weights the top view features and side view features output by the image feature extraction layer with the geometric features output by the geometric feature mapping layer. The correction output layer regresses and outputs the three-dimensional position correction, axial direction correction, and end height correction of the PIN based on the fused feature results.

[0067] S6. Calculate the alignment and end height deviation of each pin based on the three-dimensional geometric parameters of the pin correction, obtain the alignment and flatness results, control the conveying mechanism to sort the workpieces, and record the inspection results.

[0068] S6.1. Read the theoretical reference coordinate system, theoretical PIN position, and theoretical PIN axis direction of the PIN array in the product design drawings. Map the three-dimensional coordinates of the bottom reference point and end reference point of the PIN to the theoretical reference coordinate system to calculate the position deviation. Calculate the angle deviation between the three-dimensional direction of the PIN axis and the theoretical PIN axis direction to obtain the alignment result.

[0069] Specifically, the theoretical reference coordinate system, theoretical pin position, and theoretical pin axis direction of the pin array corresponding to the workpiece in the product design drawing are read. The theoretical reference coordinate system is used as a spatial reference reference. The three-dimensional coordinates of the bottom reference point and the three-dimensional coordinates of the end reference point of each pin are mapped to unify the spatial position information in the three-dimensional geometric parameters of the pin correction to the theoretical reference coordinate system. By comparing the difference between the actual position of the bottom reference point and the end reference point of the pin in the theoretical reference coordinate system and the theoretical pin position, the positional deviation of the pin in the planar and spatial directions is calculated. At the same time, based on the three-dimensional direction of the pin axis obtained from the three-dimensional geometric parameters of the pin correction, the angular deviation between the three-dimensional direction of the pin axis and the corresponding theoretical pin axis direction in the product design drawing is calculated. The positional deviation and angular deviation are summarized according to the pin number to form the alignment result.

[0070] It should be noted that the expression for calculating the positional deviation of the PIN pins is: ; in, This indicates the positional deviation of the PIN pins. This represents the coordinate value of the actual PIN pin tip reference point along the X-axis in the theoretical reference coordinate system. This represents the coordinate value of the theoretical PIN pin position along the X-axis in the theoretical reference coordinate system. This represents the coordinate value of the actual PIN pin tip reference point along the Y-axis in the theoretical reference coordinate system. This represents the coordinate value of the theoretical PIN pin position along the Y-axis in the theoretical reference coordinate system.

[0071] The expression for calculating the angular deviation between the PIN pin axis directions is: ; in, Indicates the deviation of the included angle of the PIN pin axis direction. This represents the vector of the theoretical PIN needle axis direction. This represents the three-dimensional direction vector of the PIN needle axis. This represents the magnitude of the vector along the axis of the theoretical PIN needle. This represents the magnitude of the three-dimensional direction vector of the PIN needle axis.

[0072] S6.2. Fit the three-dimensional coordinates of all PIN pin end reference points to a reference plane, and calculate the distance from each PIN pin end reference point to the reference plane as the end height deviation. Calculate the difference between the maximum and minimum end height deviations to obtain the flatness result.

[0073] Specifically, the three-dimensional coordinates of all PIN pin end reference points are traversed and treated as a single spatial point set. A plane least squares fitting method is used to obtain a reference plane that can characterize the overall height trend of the PIN pin ends. The distance from the three-dimensional coordinates of each PIN pin end reference point to the reference plane is calculated and recorded as the end height deviation. The normal direction of the reference plane is determined by the positive height direction of the workpiece coordinate system. The distances of the three-dimensional coordinates of the PIN pin end reference points located on the positive height direction side of the reference plane are taken as positive values, and the distances of the three-dimensional coordinates of the PIN pin end reference points located on the negative height direction side of the reference plane are taken as negative values. After obtaining all end height deviations, the maximum end height deviation and the minimum end height deviation are selected and the difference is calculated. The difference represents the height deviation bandwidth of all PIN pin end reference points relative to the reference plane and is used as a flatness index. The end height deviation set and the flatness index are summarized and output as the flatness result.

[0074] S6.3. Compare the positional accuracy result and flatness result with the upper limit of the positional accuracy tolerance and the upper limit of the flatness tolerance given in the product design drawings to obtain the workpiece judgment result.

[0075] Specifically, the upper limits of the alignment tolerance and flatness tolerance corresponding to the workpiece are read from the product design drawings. The alignment value of each pin in the alignment result is compared with the upper limit of the alignment tolerance. At the same time, the flatness index obtained from the flatness result is compared with the upper limit of the flatness tolerance given in the product design drawings. After completing the alignment and flatness comparisons, the comparison results are comprehensively judged. When neither the alignment nor the flatness result exceeds the corresponding upper limit of tolerance, the workpiece is judged as a qualified workpiece. When either the alignment or flatness result exceeds the corresponding upper limit of tolerance, the workpiece is judged as an unqualified workpiece, and the workpiece judgment result is output.

[0076] It should be noted that the upper limit of the positive positioning tolerance is the maximum allowable position and orientation deviation of the PIN pin relative to the theoretical reference coordinate system. It is used to limit the allowable offset range of the PIN pin relative to the theoretical PIN pin position and the theoretical PIN pin axis direction after assembly. The upper limit of the flatness tolerance is the maximum allowable dispersion limit of the ends of multiple PIN pins in the height direction. It is used to limit the height bandwidth formed by all the ends of the PIN pins relative to the same reference plane.

[0077] S6.4. Generate a sorting instruction based on the workpiece judgment result and output it to the conveying mechanism. The conveying mechanism takes the workpiece out of the positioning fixture and sends it to the good product collection position according to the workpiece judgment result to obtain the sorted workpiece. Write the alignment result, flatness result and workpiece judgment result into the inspection record to form the inspection result.

[0078] Specifically, the system reads the corresponding qualified or unqualified status from the workpiece judgment result and uses this status as the basis for sorting decisions. It determines the type of sorting action to be performed, generates a corresponding sorting instruction, and outputs the instruction to the transport mechanism. The transport mechanism then executes the pick-and-place action according to the instruction, reliably gripping and removing the workpiece from the positioning fixture. After the workpiece is removed, based on the qualified or unqualified status in the workpiece judgment result, the transport mechanism sends the workpiece to the good or defective product collection location matching the workpiece judgment result, thus completing the workpiece sorting and obtaining the sorted workpiece. The system also correlates and organizes the alignment result, flatness result, and workpiece judgment result with the workpiece, and writes them into the inspection record according to the workpiece inspection sequence to form the inspection result.

[0079] In summary, this invention enhances the 3D reconstruction accuracy and robustness of the visual inspection system by simultaneously acquiring top and side view images of the PIN pin during the visual inspection process using multiple reflection optical paths, adding a deep network model to intelligently correct the initial 3D geometric parameters, deeply fusing the image features obtained from visual inspection with the geometric solution results, and adaptively compensating for the impact of factors such as optical distortion, edge extraction deviation, and environmental interference on the accuracy of visual inspection.

[0080] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for detecting the alignment and flatness of PIN pins based on CCD visual inspection, characterized in that: include, Initialize the handling mechanism, positioning fixture, and CCD vision inspection camera, and obtain the initialization results; Based on the initialization results, the conveying mechanism is driven to send the workpiece with PIN pins into the positioning fixture and clamp it to form a workpiece with stable posture. Based on a workpiece with stable posture, a CCD vision inspection camera is controlled to simultaneously acquire top and side view images of the workpiece through multiple reflection optical paths. The top and side view images are denoised, distorted, and processed for grayscale. The calibration parameters are obtained by combining the calibration target on the positioning fixture to obtain the PIN needle feature calibration image. Two-dimensional features of each pin tip and axis are extracted from the pin feature calibration image and jointly solved to obtain the corrected three-dimensional geometric parameters of the pin. The alignment and end height deviation of each pin are calculated based on the three-dimensional geometric parameters of the pin correction, and the alignment and flatness results are obtained. The conveying mechanism is then controlled to sort the workpieces and the test results are recorded.

2. The method for detecting the alignment and flatness of PIN pins based on CCD visual inspection as described in claim 1, characterized in that: The specific steps to obtain the initialization result are as follows: Connect the power and air supply, check the safety components of the emergency stop button and access control switch, execute the origin reset action through the conveying mechanism and set the material picking position, material placing position and movement speed parameters of the conveying mechanism to obtain the picking and placing position parameters of the conveying mechanism; The clamping mechanism and limiting mechanism of the driving positioning fixture open and close in sequence, detect the position of the positioning pin, limiting surface and clamping part, and save the reference height parameter and reference plane parameter of the positioning fixture. Start the CCD vision inspection camera and its supporting illumination. Obtain the predetermined grayscale distribution by adjusting the focal length, aperture, exposure time and gain. Combine the reference height parameters and reference plane parameters of the positioning fixture to obtain the initial imaging parameters of the CCD vision inspection camera. The initialization result is composed of the pick-up and place position parameters of the conveying mechanism, the reference height parameters and reference plane parameters of the positioning fixture, and the initial imaging parameters of the CCD vision inspection camera.

3. The method for detecting the alignment and flatness of PIN pins based on CCD visual inspection as described in claim 1, characterized in that: The specific steps for forming a workpiece with stable attitude are as follows. Based on the material picking position parameters saved in the initialization results, drive the conveying mechanism to move to the material picking position in the feeding area, perform suction and clamping actions on the workpiece with PIN pins, and grab the workpiece with PIN pins. Based on the feeding position and movement speed parameters saved in the initialization results, the conveying mechanism is controlled to move the workpiece above the positioning fixture, and the termination position of the conveying mechanism is adjusted according to the reference plane parameters of the positioning fixture to align the workpiece with the positioning fixture. The control and handling mechanism lowers the workpiece aligned with the positioning fixture onto the reference plane of the positioning fixture, and drives the positioning fixture to press and limit the workpiece shell, resulting in a workpiece with stable posture.

4. The method for detecting the alignment and flatness of PIN pins based on CCD visual inspection as described in claim 1, characterized in that: The specific steps for acquiring the top and side view images of the workpiece are as follows. Based on the workpiece with stable posture, the focal length, aperture, exposure time and gain of the CCD vision inspection camera are adjusted according to the imaging parameters in the initialization result, and the illumination source corresponding to the multi-reflection optical path is turned on to obtain the CCD vision inspection camera and multi-reflection optical path in the state to be acquired. The CCD vision inspection camera, which controls the state to be acquired, issues an exposure command. The top and side views of the workpiece, which are imaged through multiple reflection optical paths, are simultaneously projected onto the imaging surface of the CCD vision inspection camera to obtain the original image signal. The original image signal is converted from analog to digital and cached in the memory of an industrial computer according to a pixel array format. The pixel segments corresponding to different reflection paths are marked as top view images and side view images, respectively.

5. The method for detecting the alignment and flatness of PIN pins based on CCD vision inspection as described in claim 4, characterized in that: The denoising, distortion correction, and grayscale processing of the top and side view images refer to performing noise suppression processing on the top and side view images respectively, followed by pixel coordinate remapping processing to obtain the distortion-corrected top and side view images, and then performing grayscale normalization and brightness equalization processing to obtain the preprocessed top and side view images.

6. The method for detecting the alignment and flatness of PIN pins based on CCD vision inspection as described in claim 5, characterized in that: The specific steps for obtaining the PIN pin feature calibration image are as follows. The outline of the calibration target on the positioning fixture is identified in the preprocessed top view image and the preprocessed side view image. The pixel coordinates of the feature points of the calibration target are extracted and corresponded with the spatial coordinates of the calibration target on the positioning fixture. The internal and external parameters and distortion coefficients in the top view direction and the side view direction are solved to obtain the calibration parameters. Geometric correction and region cropping are performed on regions in the preprocessed top view image and preprocessed side view image using calibration parameters, and the correspondence and storage are performed to obtain PIN pin feature calibration images; the PIN pin feature calibration images include region top view images and region side view images.

7. The method for detecting the alignment and flatness of PIN pins based on CCD vision inspection as described in claim 6, characterized in that: The specific steps for extracting two-dimensional features of each PIN pin tip and axis from the PIN pin feature calibration image and performing joint calculation are as follows: Extract the pin tip contour from the top view image of the region and fit the end center point and axis projection direction. Extract the pin tip edge point and side contour from the side view image of the region and fit the side view axis projection direction. Output two-dimensional feature data. By using calibration parameters, the top-view two-dimensional feature data and the side-view two-dimensional feature data are unified into the workpiece coordinate system and jointly solved to obtain the initial three-dimensional geometric parameters of the PIN needle.

8. The method for detecting the alignment and flatness of PIN pins based on CCD visual inspection as described in claim 1, characterized in that: The specific steps for obtaining the corrected three-dimensional geometric parameters of the PIN pin are as follows. The top view image region and the side view image region are combined with the initial 3D geometric parameters of the PIN needle to form a joint feature vector, which is then input into the deep network model. A deep network model is used to jointly analyze the PIN pin feature calibration image region and the initial three-dimensional geometric parameters of the PIN pin, outputting the PIN pin three-dimensional position correction, axis direction correction, and end height correction, which are then superimposed on the initial three-dimensional geometric parameters of the PIN pin to generate the PIN pin corrected three-dimensional geometric parameters.

9. The method for detecting the alignment and flatness of PIN pins based on CCD visual inspection as described in claim 1, characterized in that: The specific steps to obtain the orthogonality and flatness results are as follows. Read the theoretical reference coordinate system, theoretical PIN position, and theoretical PIN axis direction of the PIN array in the product design drawings. Map the three-dimensional coordinates of the bottom reference point and end reference point of the PIN to the theoretical reference coordinate system to calculate the position deviation. Calculate the angle deviation between the three-dimensional direction of the PIN axis and the theoretical PIN axis direction to obtain the alignment result. The three-dimensional coordinates of all PIN pin end reference points are fitted to a reference plane, and the distance from each PIN pin end reference point to the reference plane is calculated as the end height deviation. The difference between the maximum end height deviation and the minimum end height deviation is calculated to obtain the flatness result.

10. The method for detecting the alignment and flatness of PIN pins based on CCD vision inspection as described in claim 1, characterized in that: The specific steps for recording the detection results are as follows: The positional accuracy result and the flatness result are compared with the upper limit of the positional accuracy tolerance and the upper limit of the flatness tolerance given in the product design drawings to obtain the workpiece judgment result; Based on the workpiece judgment result, a sorting instruction is generated and output to the conveying mechanism. The conveying mechanism takes the workpiece out from the positioning fixture and sends it to the good product collection position according to the workpiece judgment result, thus obtaining the sorted workpiece. The alignment results, flatness results, and workpiece judgment results are written into the inspection record to form the inspection results.