A capacitor guide pin defect detection method, device, equipment and medium

CN122391758BActive Publication Date: 2026-10-09HEFEI EAGLE EYE INTELLIGENT ROBOT CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202610821911.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-09
Publication Date
2026-10-09
Estimated Expiration
2046-06-09

AI Technical Summary

Technical Problem

[0005]针对电容器导针缺陷检测主要依赖人工目视检查、检测速度难以匹配产线节拍、检测标准受主观判断影响、长时间作业易产生视觉疲劳导致漏检率上升、以及仅能从有限视角观察导致侧面缺陷容易漏检的技术问题,本申请提供一种电容器导针的缺陷检测方法、装置、设备及介质

Benefits of technology

1、通过三个同步触发的相机分别采集导针的全局图像和两个侧面局部图像,构建了全方位的视觉采集系统,有效解决了单一视角检测存在的盲区问题。针对不同视角图像的分辨率和成像特点,设计了输入图像宽度不同的分割模型,既保证了全局图像的检测维度和精度,又优化了侧面局部图像的处理效率,实现了检测精度与速度的平衡;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122391758B_ABST
    Figure CN122391758B_ABST
Patent Text Reader

Abstract

The application relates to a capacitor guide needle defect detection method, device and equipment and medium, and relates to the technical field of machine vision defect detection. The method comprises the following steps: acquiring a global image of the guide needle based on a first camera, acquiring a first side local image of the guide needle based on a second camera, and acquiring a second side local image of the guide needle based on a third camera; inputting the global image into a first segmentation model, inputting the first side local image into a second segmentation model, and inputting the second side local image into a third segmentation model; performing full-dimension defect detection based on the output of the first segmentation model, performing left-side view defect detection based on the output of the second segmentation model, and performing right-side view defect detection based on the output of the third segmentation model; and acquiring defect detection results of each detection item of the first segmentation model, the second segmentation model and the third segmentation model. The application realizes comprehensive and accurate detection of guide needle defects, and takes into account detection accuracy and speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of machine vision defect detection, and in particular to a method, apparatus, equipment and medium for defect detection of capacitor leads. Background Technology

[0002] In the field of electronic component manufacturing, the appearance quality of capacitor leads directly affects the electrical performance and reliability of capacitors. The types of defects that need to be inspected for leads are numerous, covering dimensional deviations in various parts such as A, B, E, and Y sections, as well as various appearance defects such as burrs, missing corners, delamination, and damage to the B section, with more than ten inspection items.

[0003] In existing technologies, the visual inspection of capacitor leads mainly relies on manual inspection. Inspectors must observe the shape of various parts of the lead and determine the presence of defects while the production line is running at high speed. However, manual inspection has several shortcomings: the inspection speed is difficult to match the production line pace, requiring manual inspection to be slowed down or becoming a bottleneck in the production line; the inspection standards are affected by subjective judgment, and different personnel may have inconsistent judgments on the same defect; after long periods of repetitive work, inspectors are prone to visual fatigue, leading to an increased rate of missed defects, especially the ability to identify minor defects such as burrs and missing corners, which decreases significantly with working time; in addition, manual inspection can only observe the lead from a limited perspective, making it difficult to simultaneously cover all critical parts above and below the lead, and defects seen from the side are easily missed.

[0004] Therefore, how to achieve high-precision, high-efficiency, and all-round automated detection of capacitor lead defects has become a technical problem that urgently needs to be solved in current production practice. Summary of the Invention

[0005] In view of the technical problems that capacitor conductor defect detection mainly relies on manual visual inspection, the detection speed is difficult to match the production line pace, the detection standards are affected by subjective judgment, long-term operation is prone to visual fatigue leading to increased missed detection rate, and the limited perspective of observation makes it easy to miss side defects, this application provides a defect detection method, device, equipment and medium for capacitor conductors.

[0006] Firstly, this application provides a method for detecting defects in capacitor leads, employing the following technical solution: A method for detecting defects in capacitor leads, comprising: The first camera captures a global image of the guide pin, the second camera captures a partial image of the first side of the guide pin, and the third camera captures a partial image of the second side of the guide pin. The first, second, and third cameras capture images simultaneously. The global image is input into the first segmentation model, the first side local image is input into the second segmentation model, and the second side local image is input into the third segmentation model; the first segmentation model, the second segmentation model, and the third segmentation model have the same network layer structure, and the input image width of the second segmentation model and the third segmentation model is half the input image width of the first segmentation model; Full-dimensional defect detection is performed based on the output of the first segmentation model, left-side visual defect detection is performed based on the output of the second segmentation model, and right-side visual defect detection is performed based on the output of the third segmentation model. The detection items for the left-side visual defect detection and the right-side visual defect detection are the same, and the detection items for the full-dimensional defect detection are more than those for the left-side visual defect detection or the right-side visual defect detection. For each common detection item, the detection results of the first segmentation model, the second segmentation model, and the third segmentation model are obtained respectively. When none of the three detection results detect a defect, the detection item is determined to be defect-free. When any one of the detection results detects a defect, the detection item is determined to be defective. The common detection item is a detection item included in all-dimensional defect detection, left-side visual defect detection, and right-side visual defect detection. For each single-view detection item, based on the detection result of the first segmentation model, it is determined whether the detection item has a defect; the single-view detection item is a detection item included in the full-dimensional defect detection, but not included in the left-side view defect detection and the right-side view defect detection.

[0007] Optionally, the first segmentation model, the second segmentation model, and the third segmentation model are all deep learning segmentation models. The segmentation heads of the first segmentation model, the second segmentation model, and the third segmentation model all include an upsampling module, which is composed of a series of multi-level transposed convolutional layers. The number of cascaded layers of the transposed convolutional layer in the upsampling module is determined based on the intersection of segmentation boundary accuracy constraints, time budget constraints, and multi-model consistency constraints. The number of cascaded layers is used to achieve sub-pixel level edge feature upsampling and restoration. The segmentation boundary accuracy constraint uses the average intersection-union ratio (IUU) of the segmentation mask and the annotation mask as a metric. The closer the average IUU is to 1, the higher the segmentation boundary accuracy.

[0008] Optionally, the segmentation boundary accuracy constraint is that the average intersection-union ratio reaches a preset threshold to meet the sub-pixel level measurement requirements of the guide needle target part size; the time budget constraint is a production line cycle time of 3 needles / s; the multi-model consistency constraint requires that each segmentation model share the same network structure definition and the same set of inference engine construction configuration; If the segmentation boundary accuracy constraint, time budget constraint, and multi-model consistency constraint are all satisfied simultaneously, then the upsampling module includes a first transposed convolutional layer and a second transposed convolutional layer connected in series. The first transposed convolutional layer expands the input feature map by a factor of 2, and the second transposed convolutional layer expands the output feature map of the first transposed convolutional layer by a factor of 2.

[0009] Optionally, the training methods for the first segmentation model, the second segmentation model, and the third segmentation model include: Obtain the first training dataset, and perform balanced annotation on each part of the guide needle and the defect area in the global image to obtain the first annotation dataset; A second training dataset is obtained, and the visible side view regions in the first and second side view local images are labeled to obtain a second labeled dataset. In the labeling of the visible side view regions, the labeling weight of the CP line region of the guide needle is higher than that of the A part region. The labeling weight of the corresponding regions of detection items that are not suitable for side view detection is reset to zero or not labeled. The first segmentation model is trained based on the first labeled dataset, and the second and third segmentation models are trained based on the second labeled dataset. The loss function of the first segmentation model is evenly configured for each detection item, and the loss functions of the second and third segmentation models have a higher weight for side-view detectable items than for side-view undetectable items.

[0010] Optionally, the full-dimensional defect detection based on the output of the first segmentation model includes: Based on the first segmentation model, the A, E, B, Y, and CP line regions of the corresponding guide needle in the global image are segmented, as well as the defect regions of interlayer, straight line damage in B section, and damage in B section. Based on the fitting of the center line of region A, calculate the projection lengths of regions A, B, E, and Y on the center line of region A, and determine the corresponding dimensional deviations of each region; Calculate the distance between the upper and lower edges of region B as the diameter of region B, and determine the deviation of the diameter of region B. Calculate the distance between the coordinates of the end of the CP line and the coordinates of the top of section A as the total length of the guide needle, and determine the total length deviation; Calculate the perpendicular distance between the midpoint coordinates of the end of the CP line and the extension of the center line of part A to determine the bending defect of the CP line; Calculate the overlap between region Y and region B to determine weld protrusion defects; Within the longitudinal range defined by the upper and lower boundaries of the CP line, the lateral dimensions of the Y region are detected, and the presence of a missing corner region is determined based on the lateral dimensions. Calculate the distance difference between the upper and lower straight lines of parts A and B to determine the shoulder asymmetry defect; Calculate the area of ​​region A to determine the blade-shaped defect; Based on the segmentation results of the interlayer region, the B-section damage region, and the B-section straight-line damage region, the corresponding defects are determined.

[0011] Optionally, performing left-side visual defect detection based on the output of the second segmentation model, or performing right-side visual defect detection based on the output of the third segmentation model, includes: Based on the second segmentation model or the third segmentation model, the Y part and CP line regions of the guide needle, as well as the defect regions of the straight line damage and B part damage in the first side local image or the second side local image are segmented. Calculate the projection length of the Y part onto the center line of the CP line, and determine the size deviation of the Y part. The center line of the CP line is obtained by fitting the coordinates of the upper and lower edges of the CP line region. Calculate the overlap between region Y and region B to determine weld protrusion defects; Within the longitudinal range defined by the upper and lower boundaries of the CP line, the lateral dimensions of the Y region are detected, and the presence of a missing corner region is determined based on the lateral dimensions. Based on the segmentation results of the B-section damage area and the B-section straight line damage area, the corresponding defects are determined.

[0012] Optionally, before inputting the global image into the first segmentation model, the method further includes: Based on the grayscale statistics of the preset fixed region of interest in the global image, the surface reflectivity benchmark of the current batch of guide needles is calculated; Based on the surface reflectivity benchmark, the mask binarization threshold for post-segmentation processing is dynamically adjusted. Based on the adjusted mask binarization threshold, the mask probability map output by the first segmentation model is binarized to obtain the binarized masks for each guide needle location and defect region.

[0013] Secondly, this application provides a defect detection device for capacitor conductors, which adopts the following technical solution: A defect detection device for capacitor conductors, comprising: The acquisition module is used to acquire a global image of the guide pin based on a first camera, and to acquire a partial image of the first side of the guide pin based on a second camera and a partial image of the second side of the guide pin based on a third camera. The first camera, the second camera and the third camera are used for synchronous shooting. The input module is used to input the global image into the first segmentation model, input the first side local image into the second segmentation model, and input the second side local image into the third segmentation model; the first segmentation model, the second segmentation model, and the third segmentation model have the same network layer structure, and the input image width of the second segmentation model and the third segmentation model is half the input image width of the first segmentation model; The detection module is used to perform full-dimensional defect detection based on the output of the first segmentation model, perform left-side view defect detection based on the output of the second segmentation model, and perform right-side view defect detection based on the output of the third segmentation model. The detection items for the left-side view defect detection and the right-side view defect detection are the same, and the detection items for the full-dimensional defect detection are more than the detection items for the left-side view defect detection or the right-side view defect detection. The first determination module is used to obtain the detection results of the first segmentation model, the second segmentation model, and the third segmentation model for each common detection item. When none of the three detection results detect a defect, the detection item is determined to be defect-free. When any one of the detection results detects a defect, the detection item is determined to be defective. The common detection item is a detection item included in all-dimensional defect detection, left-side visual defect detection, and right-side visual defect detection. The second determination module is used to determine whether a single-view detection item has a defect based on the detection result of the first segmentation model for each single-view detection item; the single-view detection item is a detection item included in the full-dimensional defect detection but not included in the left-side view defect detection and the right-side view defect detection.

[0014] Thirdly, this application provides an electronic device that adopts the following technical solution: An electronic device includes a processor and a memory, wherein the processor is coupled to the memory; The processor is configured to execute a computer program stored in the memory, causing the electronic device to perform the method as described in any of the first aspects.

[0015] Fourthly, this application provides a computer-readable storage medium, which adopts the following technical solution: A computer-readable storage medium includes a computer program or instructions that, when executed on a computer, cause the computer to perform the method as described in any of the first aspects.

[0016] This invention provides a method, apparatus, device, and medium for detecting defects in capacitor leads, which has the following advantages: 1. A comprehensive visual acquisition system was constructed by acquiring global images and two side partial images of the guide pin using three synchronously triggered cameras, effectively solving the blind spot problem in single-view detection. Segmentation models with different input image widths were designed to address the resolution and imaging characteristics of images from different viewpoints. This ensured both the detection dimensionality and accuracy of the global image and optimized the processing efficiency of the side partial images, achieving a balance between detection accuracy and speed.

[0017] 2. By introducing a multi-level transposed convolutional layer cascaded upsampling module into the segmentation head, and determining the optimal number of cascaded layers based on production line cycle time constraints, the accuracy of the segmentation boundary is significantly improved while meeting real-time requirements, providing a reliable pixel-level foundation for subsequent dimensional measurements;

[0018] 3. Differentiated detection logic is designed for different perspectives. Multi-view fusion judgment is used for common detection items, and a dedicated model is used for single-view detection items. It can fully adapt to high-speed production cycle and meet the needs of industrial site for full-dimensional and high-precision detection of capacitor leads. Attached Figure Description

[0019] Figure 1 This is a flowchart illustrating a defect detection method for capacitor leads according to one embodiment of this application.

[0020] Figure 2 This is a schematic diagram of the guide pin area division according to one embodiment of this application.

[0021] Figure 3 This is a schematic diagram of a global image according to one embodiment of this application.

[0022] Figure 4 This is a schematic diagram of a partial side view of one embodiment of this application.

[0023] Figure 5 This is a schematic diagram of the segmentation head of the first segmentation model according to one embodiment of this application.

[0024] Figure 6 This is a schematic diagram of the segmentation head of the second or third segmentation model according to one embodiment of this application.

[0025] Figure 7 This is a structural block diagram of a defect detection device for capacitor leads according to one embodiment of this application.

[0026] Figure 8 This is a structural block diagram of an electronic device according to one embodiment of this application. Detailed Implementation

[0027] The principles and features of the present invention are described below. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.

[0028] The present application will be further described in detail below with reference to the accompanying drawings.

[0029] This application provides a method for detecting defects in capacitor leads. This method can be executed by a device, which can be a server or a terminal device. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal device can be a smartphone, tablet, desktop computer, etc., but is not limited to these.

[0030] like Figure 1 As shown, a defect detection method for capacitor leads, using an electronic device as the execution subject, is described in the following main process flow (steps S101 to S105): Step S101: Acquire a global image of the guide pin based on the first camera, and acquire a partial image of the first side of the guide pin based on the second camera and a partial image of the second side of the guide pin based on the third camera. The first camera, the second camera and the third camera are used for synchronous shooting.

[0031] In terms of hardware deployment, a proximity switch is provided in the detection area of ​​the capacitor guide pin. When the guide pin moves to the detection area with the conveying mechanism, the proximity switch is triggered, generating a trigger signal. It is easy to understand that the conveying mechanism may include a conveyor plate.

[0032] The trigger signal is simultaneously sent to the first camera, second camera, and third camera via a beam splitter or synchronization controller. This is easily understood as... Figure 2 As shown, the guide needle can be divided into sections A, E, B, Y, and CP line.

[0033] In this embodiment, the first camera can be a high-resolution area array camera with 12 megapixels, vertically arranged above the guide pin, such as... Figure 3 As shown, this is used to capture a top-down global image of the guide needle. The global image can cover all parts of the guide needle, including parts A, E, B, Y, and the CP line. The field of view can meet the measurement requirements of dimensions such as the total length L of the guide needle.

[0034] The second and third cameras can be 5-megapixel area-scan cameras, respectively positioned to the left and right of the first camera, such as... Figure 4 As shown, this is used to capture partial side images of the left or right side of the guide pin. Since the side view is mainly used to detect local details such as B-section defects and Y-section corner defects, it is not necessary to cover the entire length. Therefore, a camera with lower resolution and a smaller field of view can meet the requirements, while reducing hardware costs.

[0035] Synchronous shooting ensures the consistency of the three images in the temporal dimension. That is, the three images capture the same guide pin at different perspectives at the same instant. This is the basis for subsequent multi-view fusion judgment and false detection elimination. If the shooting is not synchronized, it may cause image misalignment due to guide pin movement, making the multi-view coordinate mapping invalid.

[0036] Step S102: Input the global image into the first segmentation model, input the first side local image into the second segmentation model, and input the second side local image into the third segmentation model; the first segmentation model, the second segmentation model, and the third segmentation model have the same network layer structure, and the input image width of the second segmentation model and the third segmentation model is half the input image width of the first segmentation model.

[0037] This embodiment uses a deep learning-based segmentation model (such as the improved YOLO11 model) to perform semantic segmentation on the acquired images. Although the three segmentation models have the same network layer structure (i.e., they use the same feature extraction backbone network and segmentation head structure), the width of the input feature map is configured differently to adapt to input images of different resolutions and optimize inference speed.

[0038] The first camera captures a global image with a resolution of 12 megapixels, resulting in a large image size. The first segmentation model receives the entire width of the input image. In contrast, the second and third cameras capture local side images with a resolution of 5 megapixels, leading to relatively smaller image sizes. Forcibly enlarging the side images to the same size as the global image and inputting them into the model would not only introduce interpolation noise but also increase computational load, prolonging inference time and making it difficult to meet production line cycle time requirements.

[0039] Therefore, in this embodiment, the input image width of the second and third segmentation models is configured to be half that of the first segmentation model. This configuration allows the segmentation model to natively adapt to the resolution of the side image without additional image scaling preprocessing. It preserves the original pixel features of the side image while significantly reducing the computational load of the model, achieving a balance between detection accuracy and speed.

[0040] Step S103: Perform full-dimensional defect detection based on the output of the first segmentation model, perform left-side view defect detection based on the output of the second segmentation model, and perform right-side view defect detection based on the output of the third segmentation model. The detection items for the left-side view defect detection and the right-side view defect detection are the same, and the detection items for the full-dimensional defect detection are more than the detection items for the left-side view defect detection or the right-side view defect detection.

[0041] The first segmentation model performs full-dimensional detection based on the global image, covering a variety of detection items for the guide pin, including the size deviation of parts A, E, B, and Y, the diameter of part B, the total length of the guide pin, shoulder asymmetry, blade-shaped defects, as well as 14 types of defects such as interlayer, damage to part B, straight damage to part B, protruding solder joints (burrs), missing corners, and bent CP lines.

[0042] It is easy to understand that the interlayer is a separation defect in the aluminum substrate of the guide pin caused by impurities or air bubbles during the rolling process. In the image, it appears as a grayish-white strip-shaped or layered abnormal area along the length of the guide pin. The straight scratch in part B is a linear scratch on the surface of part B (cylindrical body) of the guide pin along the axial or circumferential direction, usually caused by foreign objects in the mold or friction during transmission. In the image, it appears as a thin, low-grayscale line area. The damage in part B is a non-linear local damage on the surface of part B, including pits, indentations, or local deformation. In the image, it appears as an irregular blocky low-grayscale area. The missing corner is the corner missing in part Y (weld joint connection) of the guide pin caused by stamping and shearing. In the image, this manifests as localized breaks or depressions in the contour of the part; weld protrusion (burrs) is caused by material bulging at the connection between part Y and part B due to welding overflow or stamping burrs, which appears as an abnormal extension of the part Y towards part B in the image; CP line bending is the arc or broken line deformation of the guide pin CP line (lead wire) deviating from the straight line reference, which appears as the curvature of the CP line center line exceeding the threshold in the image; knife-shaped defects are the end flattening or cutting deformation of part A due to abnormal stamping die, which appears as the area of ​​part A being significantly smaller than the normal value and the contour being knife-shaped; shoulder asymmetry is the asymmetry of the upper and lower transition areas at the connection between part A and part B (shoulder).

[0043] The second and third segmentation models perform detection based on local side images. Due to occlusion in the side view (e.g., part A appears tilted in the side view, making accurate length measurement difficult) and limited field of view (the end of the CP line and the top of part A cannot be seen simultaneously, making total length measurement impossible), they have fewer detection items than full-dimensional detection. The detection items for the left and right views are the same, mainly including defects that are clearly imaged and have obvious features in the side view, such as the size of part Y, protruding solder joints, missing corners, damage to part B, and straight-line damage to part B. By setting differentiated detection items, misjudgments caused by unreliable detection in the side view (e.g., measuring the length of a tilted part A) are avoided, thus improving the robustness of the detection system.

[0044] Step S104: For each common detection item, obtain the detection results of the first segmentation model, the second segmentation model and the third segmentation model for the detection item respectively. When none of the three detection results detect a defect, it is determined that the detection item is defect-free. When any detection result detects a defect, it is determined that the detection item has a defect. The common detection item is a detection item included in all-dimensional defect detection, left-side visual defect detection and right-side visual defect detection.

[0045] Common detection items refer to defect types that can be effectively identified from all three perspectives, such as Y-section dimensions, protruding solder joints, missing corners, and B-section damage. This embodiment uses an "OR" logic for these detection items. That is, if the model detects a defect in any of the first perspective (global), second perspective (left side), or third perspective (right side), the detection item is determined to have a defect. For example, a small scratch on the B-section surface might not be detected by the global perspective due to resolution limitations or lighting angle issues, but the side perspective might capture the reflective characteristics of the scratch, thus successfully detecting it.

[0046] Step S105: For each single-view detection item, based on the detection result of the first segmentation model, determine whether the detection item has a defect; the single-view detection item is a detection item included in the full-dimensional defect detection, but not included in the left-side view defect detection and the right-side view defect detection.

[0047] Single-view inspection items refer to items that can only be accurately detected from a global perspective, such as the dimensions of section A, section E, section B, section B diameter, total guide pin length, shoulder asymmetry, blade-shaped defects, and CP line bending. These inspection items rely on the complete contour projection of the guide pin or specific geometric relationships; a side view cannot provide effective inspection data. Therefore, for these items, the judgment is made solely based on the output of the first segmentation model.

[0048] This embodiment customizes differentiated model input widths and detection logic based on the imaging characteristics (resolution, field of view, geometric distortion) of different viewpoints, avoiding wasted computing power while ensuring the detection rate of key defects. Simultaneously, by combining the "OR" logic of common detection items with the dedicated judgment of single-viewpoint detection items, comprehensive coverage and accurate capture of guide pin defects are achieved.

[0049] In this embodiment, the first segmentation model, the second segmentation model, and the third segmentation model are deep learning segmentation models. The segmentation heads of the first segmentation model, the second segmentation model, and the third segmentation model all include an upsampling module, which is composed of a series of multi-level transposed convolutional layers.

[0050] Traditional segmentation models (such as the original YOLO 11 series) typically employ simple bilinear interpolation or single-layer transposed convolution for upsampling. When handling minute-sized measurement tasks such as capacitor leads, the segmentation boundaries often appear jagged or blurred, failing to meet sub-pixel-level measurement accuracy requirements. This embodiment uses an upsampling module composed of cascaded multi-level transposed convolutional layers. Utilizing the learnable parameter characteristics of transposed convolutional layers, it can learn finer edge features while gradually restoring the feature map resolution, thereby significantly improving the smoothness and accuracy of the segmentation boundaries.

[0051] Regarding the number of cascaded layers of the transposed convolutional layer in the upsampling module, this embodiment does not select them arbitrarily, but determines them based on the intersection of segmentation boundary accuracy constraints, time budget constraints, and multi-model consistency constraints. The number of cascaded layers that simultaneously satisfy the segmentation boundary accuracy constraints, time budget constraints, and multi-model consistency constraints is selected to achieve sub-pixel level edge feature upsampling and restoration.

[0052] The segmentation boundary accuracy constraint uses the average intersection-over-union (IoU) ratio of the segmentation mask and the annotation mask as a metric. A higher IoU ratio (closer to 1) indicates higher segmentation boundary accuracy. This constraint requires that the upsampled segmentation boundary meet the sub-pixel level measurement requirements of the guide pin target area. The time budget constraint stipulates that the total image processing time for a single guide pin cannot exceed the production line cycle time; otherwise, it will lead to production line stoppages or missed detections. When the first, second, and third segmentation models are executed in parallel, the total time is taken as the maximum single-frame time of the three models. This constraint is rigidly determined by the production rhythm and cannot be circumvented by slowing down the production line or adding inspection stations. The multi-model consistency constraint requires that the first, second, and third segmentation models must share the same network structure definition, and based on this definition, TensorRT engines adapted to their respective input sizes must be built. Hybrid architectures with different numbers of layers are prohibited. Maintaining multiple model structures in the industrial environment is not allowed; otherwise, it will introduce engineering risks such as chaotic version management, incorrect post-processing parameter adaptation, and a surge in on-site debugging complexity.

[0053] As a specific implementation method, the structure of the segmentation head of the first segmentation model is as follows: Figure 5 As shown, the structure of the segmentation head of the second or third segmentation model is as follows: Figure 6 As shown. The segmentation boundary accuracy constraint is that the average intersection-union ratio reaches a preset threshold to meet the sub-pixel level measurement requirements of the guide pin target area size; the time budget constraint is a production line cycle time of 3 pins / s; the multi-model consistency constraint requires that each segmentation model share the same network structure definition and the same inference engine construction configuration. The same inference engine construction configuration means that the three models use the same optimization parameters (e.g., the same workspace size and the same optimization level) to build the engine.

[0054] If the segmentation boundary accuracy constraint, time budget constraint, and multi-model consistency constraint are all satisfied, the upsampling module includes a first transposed convolutional layer and a second transposed convolutional layer connected in series. The first transposed convolutional layer expands the input feature map by a factor of 2, and the second transposed convolutional layer expands the output feature map of the first transposed convolutional layer by a factor of 2.

[0055] Under the combined effect of the above triple constraints, experiments were conducted on three upsampling configurations: Group 1 consisted of a single-layer ConvTranspose2d (2×2, stride=2), Group 2 consisted of two cascaded ConvTranspose2d (2×2, stride=2) layers, and Group 3 consisted of three cascaded ConvTranspose2d (2×2, stride=2) layers. Taking the single-frame inference time for different configurations as an example, the independent running data of the first segmentation model included: Group 1, output size 112×608 (in pixels), single-frame inference time 60.76ms; Group 2, output size 224×1216, single-frame inference time 93.24ms; Group 3, output size 448×2432, single-frame inference time 401.75ms. The independent running data for the second and third segmentation models include: Group 1, output size 112×304, single-frame inference time 13.24ms, mIOU 0.9333; Group 2, output size 224×608, single-frame inference time 21.09ms, mIOU 0.9504; Group 3, output size 448×1216, single-frame inference time 54.05ms, mIOU 0.9580. It is easy to understand that this output size refers to the spatial resolution (height × width) of the segmentation mask.

[0056] If a three-level transposed convolutional layer configuration is used for 8x upsampling, although the segmentation accuracy is slightly higher, the increase in the number of cascaded layers leads to an increase in computational load and a longer inference time per frame. In addition to the time for image acquisition, data transmission and post-processing, the total time will far exceed the production line cycle time of 3 lines / second, which will make it impossible to keep up with the production line speed, resulting in missed detections or production line slowdown, and failing to meet the time budget constraint.

[0057] Furthermore, the first segmentation model can be cascaded in two stages to adapt to the high time consumption of 12-megapixel images, while the second and third segmentation models are cascaded in three stages to improve the segmentation accuracy of 5-megapixel local images. The single-frame time of the three-stage cascade of the second and third segmentation models is 54.05ms, and the total time of parallel operation of the three models is still taken as 93.24ms of the first segmentation model, satisfying the clock constraint; and the mIOU of the second and third segmentation models can be improved from 0.9504 to 0.9580. However, this hybrid architecture violates the multi-model consistency constraint for the following reasons: The three segmentation models need to maintain two sets of network structure definitions, two sets of TensorRT engine construction configurations, and two sets of post-processing parameter adaptation logic. Any update to the segmentation model (such as expansion of defect types or increase in training data) requires verification of both sets of structures, which doubles the complexity of version management. The mIOU gain of the second and third segmentation models from two levels to three levels is only 0.0076 (a relative improvement of 0.8%). However, this gain does not constitute a qualitative change in sub-pixel level measurement scenarios. The 0.9504 of the two-level configuration already meets the tolerance requirements for geometric measurements such as the diameter of part B. The 0.9580 of the three-level configuration does not bring about new detectable defect types or an improvement in measurement accuracy. On-site engineers need to understand and operate two different segmentation model configurations. When troubleshooting, they need to distinguish whether the problem is with the first segmentation model or the second / third segmentation model, which increases the difficulty of debugging and the risk of downtime.

[0058] In contrast, the two-stage transposed convolutional layer (2x + 2x, a total of 4x upsampling) scheme selected in this embodiment first performs preliminary spatial expansion of the deep feature map to restore the approximate contour information; the second transposed convolutional layer further refines the edge features on this basis, so that the segmentation boundary is smooth enough to meet the measurement accuracy requirements, while controlling the computational complexity, reserving sufficient time window for subsequent geometric calculations and logical judgments, and adapting to the high-speed production line cycle of 3 lines / s.

[0059] This embodiment previously verified a single-layer large stride (stride=4) upsampling scheme (Group4), whose output size is the same as the two-level cascaded scheme (224×1216), but the edge quality is inferior to the cascaded scheme. Specifically: the kernel size of the single-layer large stride is 4×4, which requires a 4-fold spatial expansion in one step. The kernel parameters need to learn two tasks simultaneously: position determination and detail interpolation, which is difficult to optimize and prone to chessboard artifacts. Each layer in the cascaded, small-step structure has a kernel size of 2×2, requiring only a 2x expansion in learning. The first layer focuses on approximate location recovery, while the second layer focuses on detailed interpolation optimization. This task decomposition reduces the fitting difficulty of each layer. A nonlinear activation function is inserted between the two layers, enabling the network to perform two independent nonlinear transformations. For slender targets with extremely high aspect ratios, such as guide needles, this provides the necessary nonlinear capacity to accurately fit the edge curvature.

[0060] Therefore, a two-stage cascade is not simply two single-layer stacks, but a structural design with different mathematical properties. Even with the same output size, the edge reconstruction quality of the cascaded structure is systematically superior to that of a single-layer structure with a large stride.

[0061] It is easy to understand that when the production line cycle time is less than 3 units / s, the two-stage transposed convolutional layer scheme (2x + 2x, a total of 4x upsampling) selected in this embodiment can also meet the requirements.

[0062] In this embodiment, since the three segmentation models process images with significantly different viewpoints, resolutions, and detection tasks, using a uniform dataset and training strategy would lead to a decrease in the performance of the segmentation models at specific viewpoints. For example, if the second segmentation model is trained using a side view image containing a large number of A-section dimension annotations, the segmentation model will have difficulty converging due to the tilt distortion of the A-section in the side view, and it will be prone to false detections during inference. Therefore, this embodiment adopts a differentiated training strategy.

[0063] Specifically, the training process includes the following steps: First, obtain the first training dataset, and perform balanced annotation on each part of the guide needle and the defect area in the global image to obtain the first annotation dataset.

[0064] The first training dataset was derived from a large number of historical global images captured by the first camera. From a global perspective, the images of all parts are relatively clear, with no obvious viewpoint occlusion or distortion. The model needs to learn all features in a balanced manner, so balanced annotation was performed. Balanced annotation means that during the annotation process, all parts of the guide pin (such as A, E, B, Y, and CP lines) and various defects (such as interlayer, straight-line damage in B section, and damage in B section) are given equal attention and annotation accuracy.

[0065] Next, a second training dataset is obtained, and the visible side view regions in the first and second side view local images are labeled to obtain a second labeled dataset. In the labeling of the visible side view regions, the labeling weight of the CP line region is higher than that of the A region, and the labeling weight of the corresponding regions of detection items that are not suitable for side view detection is reset to zero or not labeled.

[0066] The second training dataset consists of side-view local images captured by the second and third cameras. The imaging characteristics of the guide pin are significantly different from those from the global viewpoint. For example... Figure 4 As shown, the field of view of the side partial image is concentrated on the tip area of ​​the guide needle, with parts A, B and Y occupying the main part of the image.

[0067] Although the visible length of the CP line in the side view is limited, its visible segment presents as a short straight line with clear straight-line characteristics and stable edge gradients. Furthermore, this short straight-line segment maintains a fixed spatial distance from the top of part A within the manufacturing tolerance range. From the side view, part A appears as a tilted ellipse with blurred boundaries, making it impossible to fit a reliable center line; part B has a diameter step, and its upper and lower edges are not parallel; part E is too short, resulting in insufficient sampling points. Therefore, using the visible segment of the CP line as the straight-line geometric reference from the side view, its segmentation accuracy directly determines the accuracy of the Y-section dimension measurement and the determination of weld point protrusion defects.

[0068] Based on this, this embodiment sets the label weight of the CP line region to a relatively high value (e.g., 1.5 times the weight) to guide the segmentation model to focus on learning the accurate segmentation of the visible segment of the CP line, ensuring the reliability of the subsequent fitting of the CP line center line. Conversely, part A appears as a tilted ellipse from a side view, with its boundaries often blurred and its length varying drastically with the guide needle's posture. Forcing the model to learn the precise boundary of part A would lead to overfitting or incorrect feature memory. Therefore, in this embodiment, the label weight of the part A region can be reduced (e.g., set to 0.5 times the weight), or even ignored in some extreme viewpoint samples, forcing the model not to rely on unreliable features of part A.

[0069] In addition, for inspection items that are not suitable for side-view inspection, such as shoulder asymmetry, knife-shaped defects, and CP line bending, these defects may be obscured in the side view or the imaging features may be completely different from the global view. Forced training will introduce noise. In this embodiment, a strategy of setting the weights to zero or not labeling is adopted.

[0070] For example, the determination of shoulder asymmetry defects relies on the distance difference between the upper and lower straight lines of sections A and B. However, from a side view, the upper and lower edges of sections A and B often overlap or are distorted by projection, making it impossible to calculate an effective distance difference. Therefore, when constructing the second training dataset, for these defect areas, their weights are reset to 0 during the loss function calculation. This forces the model to ignore the features of these areas and focus on learning side-visible features such as the size of the Y section, weld protrusion, and damage to section B.

[0071] Finally, the first segmentation model is trained based on the first labeled dataset, and the second and third segmentation models are trained based on the second training dataset. The loss function of the first segmentation model is evenly configured for each detection item, while the loss functions of the second and third segmentation models have higher weights for side-view detectable items than for side-view undetectable items.

[0072] During the training of the segmentation model, the design of the loss function directly determines the convergence direction of the model. For the first segmentation model, the loss weight of the loss function for all detection items is set to 1.0 to ensure that the model learns a balanced range of defects. For the second and third segmentation models, differentiated weights are configured according to the aforementioned annotation strategy.

[0073] For example, a specific loss function weight configuration scheme can be as follows: when the detection item is the A-section region, the weight of the first segmentation model can be 1.0, and the weight of the second / third segmentation model can be 0.2; when the detection item is the CP line region, the weight of the first segmentation model can be 1.0, and the weight of the second / third segmentation model can be 1.5; when the detection item is shoulder asymmetry, the weight of the first segmentation model can be 1.0, and the weight of the second / third segmentation model can be 0.0.

[0074] Through the differentiated training strategies described above, this embodiment enables the first segmentation model to focus on comprehensive detection across the global dimension, while the second and third segmentation models focus on capturing details from the side view. This targeted training approach not only improves the segmentation accuracy of the models from their respective viewpoints, but more importantly, it avoids false detections caused by viewpoint limitations (for example, the side model will not falsely report shoulder asymmetry due to the tilt of the A-section), significantly enhancing the robustness of the entire detection system.

[0075] In this embodiment, after obtaining the output results of the segmentation model, differentiated geometric calculation and judgment strategies can be adopted for different perspectives.

[0076] For full-dimensional defect detection, it is performed based on the output of the first segmentation model. The performance of full-dimensional defect detection based on the output of the first segmentation model includes: Based on the first segmentation model, the A, E, B, Y, and CP line regions of the guide pin, as well as the defect regions of interlayer, straight line damage in B, and damage in B, are segmented in the global image. Based on the fitting of the center line of the A region, the projected lengths of the A, B, E, and Y regions on the center line of the A region are calculated, and the dimensional deviations of each region are determined. The distance between the upper and lower edges of the B region is calculated as the diameter of the B region, and the diameter deviation of the B region is determined. The distance between the coordinates of the end of the CP line and the coordinates of the top of the A region is calculated as the total length of the guide pin, and the total length deviation is determined. The C... The perpendicular distance between the midpoint coordinates of the end of line P and the extension of the center line of section A is used to determine the bending defect of line CP; the overlap relationship between section Y and section B is calculated to determine the protruding weld point defect; within the longitudinal range defined by the upper and lower boundaries of line CP, the lateral dimensions of section Y are detected, and the presence of a missing corner area is determined based on the lateral dimensions; the distance difference between the upper and lower straight lines of section A and section B is calculated to determine the asymmetric shoulder defect; the area of ​​section A is calculated to determine the blade-shaped defect; and the corresponding defects are determined based on the segmentation results of the interlayer area, the damaged area of ​​section B, and the straight damaged area of ​​section B.

[0077] Specifically, the first segmentation model performs semantic segmentation on the global image and outputs pixel-level masks for each part of the guide pin. Based on the first segmentation model, the corresponding A, E, B, Y, and CP line regions of the guide pin in the global image, as well as the defect regions of the interlayer, straight line damage in B, and damage in B, are segmented.

[0078] For the detection of dimensional defects, this embodiment employs a measurement method based on centerline projection. The specific steps are as follows: A centerline is fitted to the A region. Since the guide pin appears as a slender rod in the global image, the A region segmentation result is two approximately parallel edge lines. This embodiment uses a column-by-column scanning method to obtain the upper and lower edge coordinates of each column in the A region, and calculates their average value as the center trajectory point of that column.

[0079] The least squares method is used to fit a straight line to all center trajectory points to obtain the center line of section A. This center line serves as the reference axis of the guide needle, effectively eliminating measurement errors caused by slight tilting of the guide needle. The projected lengths of sections A, B, E, and Y on the center line of section A are calculated to determine the corresponding dimensional deviations of each section.

[0080] Specifically, the leftmost and rightmost endpoints of each region are obtained and projected onto the center line of region A. The Euclidean distance between the projected points is calculated, which is the length of that region. For example, the length of region A is the projected distance of region A onto the center line. The calculated length value is compared with a preset tolerance range; if it exceeds the tolerance range, it is determined to be a dimensional deviation defect. Similarly, the distance between the upper and lower edges of region B is calculated as the diameter of region B, and the diameter deviation of region B is determined. Using the method of calculating the vertical distance between the upper and lower edges can accurately reflect the cylindricity characteristics of region B.

[0081] For the total length of the guide needle, this embodiment calculates the distance between the midpoint coordinates of the end of the CP line and the top coordinates of the A section as the total length of the guide needle, and determines the total length deviation. Since the end of the CP line and the top of the A section are located at the two ends of the guide needle, the overall length of the guide needle can be accurately characterized by calculating the distance between these two points.

[0082] For guide pin bending detection, this embodiment calculates the vertical distance between the midpoint coordinates of the end of the CP line and the extension line of the center line of part A. If the vertical distance is greater than the preset threshold, there is a CP line bending defect, and an alarm can be triggered and the machine can be stopped.

[0083] For appearance defects, this embodiment designs a targeted geometric judgment algorithm. For example, for a solder joint protrusion defect, the overlap relationship between the Y region and the B region is calculated to determine if the solder joint protrusion defect is present. Specifically, if the Y region extends beyond the B region in the extension direction, and the excess length is greater than a preset threshold, it is determined to be a solder joint protrusion. The excess length refers to the difference between the first distance between the outermost point of the B region closest to the Y region and the center line of the A region, and the second distance between the outermost point of the Y region and the center line of the A region.

[0084] For corner defect detection, within the longitudinal range defined by the upper and lower boundaries of the CP line, multiple sets of lateral distance samples are taken along the guide needle axis in the Y-section area to obtain multiple sets of Y-section lateral distance values. The upper and lower boundaries of the CP line are determined by the coordinates of the upper and lower edges of the CP line area, forming a longitudinal constraint interval. If any set of lateral distance values ​​in the calculated minimum and maximum distances is less than the corresponding preset threshold, or if the ratio of the maximum distance to the minimum distance exceeds a multiple threshold, then a corner defect is determined to exist. The corresponding preset threshold and multiple threshold can be pre-calibrated based on the statistical distribution of the normal guide needle Y-section dimensions and process tolerance requirements.

[0085] For shoulder asymmetry defects, the distance difference between the upper and lower straight lines of parts A and B is calculated to determine the shoulder asymmetry defect. Specifically, the upper and lower straight lines of parts A and B are fitted respectively. Based on the center line of part A, the distance between the upper edge of part A and the upper edge of part B, and the distance between the lower edge of part A and the lower edge of part B are calculated. If the difference between the two distances exceeds a threshold, it indicates that there is shoulder asymmetry.

[0086] For blade-shaped defects, calculate the area of ​​region A to determine if a blade-shaped defect exists. If the area of ​​region A is less than the lower limit of the normal threshold, it indicates that region A is missing, and the defect is determined to be a blade-shaped defect.

[0087] For defects such as interlayer, B-section damage, and straight-line damage in the B-section, the determination is made directly based on the area or length characteristics of the segmented region.

[0088] For side-view defect detection, left-side view defect detection is performed based on the output of the second segmentation model, or right-side view defect detection is performed based on the output of the third segmentation model. Due to the imaging characteristics of the side view, part A of the guide pin appears as a tilted ellipse in the image, with blurred edges and a length that changes drastically with the pose, making it impossible to accurately fit the center line. Therefore, in this embodiment, the center line of the CP line is used instead of the center line of part A.

[0089] In this embodiment, left-side view defect detection is performed based on the output of the second segmentation model, or right-side view defect detection is performed based on the output of the third segmentation model. This includes: segmenting the Y-section and CP-line regions of the corresponding guide pin in the first or second side partial image based on the second or third segmentation model, as well as the defect regions of the straight line damage and B-section damage in the B-section; calculating the projection length of the Y-section on the center line of the CP-line, determining the size deviation of the Y-section, wherein the center line of the CP-line is obtained by fitting the coordinates of the upper and lower edges of the CP-line region; calculating the overlap relationship between the Y-section region and the B-section region, determining the solder joint protrusion defect; detecting the lateral dimension of the Y-section region within the longitudinal range defined by the upper and lower boundaries of the CP-line, and determining whether there is a missing corner region based on the lateral dimension; and determining the corresponding defect based on the segmentation results of the B-section damage region and the straight line damage region in the B-section.

[0090] Specifically, based on the second or third segmentation model, the A, E, B, Y, and CP line regions of the guide needle in the local image of the first or second side can be segmented, as well as the defect areas of the interlayer, the straight line damage in the B section, and the damage in the B section. However, for the A, E, B, and interlayer regions with large errors, relevant defect detection calculations can be omitted. The Y and CP line regions, as well as the straight line damage in the B section and the damage in the B section, can also be segmented. It is easy to understand that when the second or third segmentation model does not segment the detection items such as the A, E, and B sections, the weight of the loss function of the corresponding detection items that do not need to be segmented can be set to zero.

[0091] From a side view, the CP line (leader) appears as a clear, slender line with stable and distinct edge features. This embodiment first extracts the coordinates of the upper and lower edges of the CP line region and then uses the least squares method to fit the center line of the CP line. This center line of the CP line highly coincides with the actual axis of the guide pin in the side projection, and therefore can be used as the reference axis from the side view.

[0092] Based on this reference axis, the projected length of the Y-section on the center line of the CP line is calculated, and the dimensional deviation of the Y-section is determined. Since the Y-section is located at the end of the CP line, its image is clear from the side view, and its size can be accurately measured by the projection method.

[0093] Similarly, calculate the overlap between the Y region and the B region to determine the weld protrusion defect. Here, the excess length refers to the difference between the third distance between the outermost point of the B region closest to the Y region and the center line of the CP line, and the fourth distance between the outermost point of the Y region and the center line of the CP line.

[0094] The process of detecting missing corners from the side view is the same as that of the missing corner detection in the first segmentation model mentioned above, and will not be repeated here.

[0095] For the B-section injury area and the B-section linear injury area, the determination is made directly based on the segmentation results.

[0096] The side view has fewer inspection items than the full-dimensional inspection. For example, the side view cannot detect the dimensions of part A, part E, part B, the diameter of part B, the total length of the guide pin, shoulder asymmetry, blade defects, CP line bending, etc.

[0097] During the defect detection process, this embodiment also employs a priority-based short-circuit detection mechanism. Specifically, each defect detection is performed sequentially from high to low according to a preset alarm priority. The alarm priorities from high to low are: interlayer, straight-line damage in section B, damage in section B, protruding solder joint (burr), knife-shaped defect, missing corner, shoulder asymmetry, diameter of section B, dimension of section B, dimension of section E, dimension of section A, dimension of section Y, total length of guide pin, and bending of CP line. During the detection process, once a defect is detected in the current priority detection item, the detection result is immediately returned and the execution of subsequent detection items is terminated; lower priority defects are no longer detected.

[0098] The full-dimensional inspection covers all key dimensions and appearance indicators of the guide pin, ensuring comprehensive inspection; the side-view inspection focuses on details and defects visible from the side, and solves the problem of missing reference by using the CP line center straight line replacement strategy, ensuring the accuracy of inspection.

[0099] In this embodiment, before inputting the global image into the first segmentation model, adaptive reflectivity correction is also included to eliminate false detections and missed detections caused by differences in surface reflectivity between different batches of aluminum guide pins. Specifically: Based on the grayscale statistics of a fixed region of interest in the global image, the surface reflectivity benchmark of the current batch of guide pins is calculated; based on the surface reflectivity benchmark, the mask binarization threshold of the post-segmentation processing is dynamically adjusted; based on the adjusted mask binarization threshold, the mask probability map output by the first segmentation model is binarized to obtain the binarized mask of each guide pin part and defect region.

[0100] Since the guide pin is positioned at a fixed location in the detection station after being triggered by the proximity switch, its imaging position in the global image is highly consistent. In this embodiment, a fixed region of interest (ROI) containing the main body of the guide pin A is pre-defined in the global image.

[0101] Perform grayscale statistics on a fixed ROI to calculate the surface reflectivity benchmark for the current batch of guide pins. The formula for calculating the surface reflectivity benchmark R is expressed as: R = μ / (σ+k) Where μ is the mean gray level within a fixed ROI, σ is the standard deviation of gray levels within a fixed ROI, and k is a minimum positive value to prevent division by zero.

[0102] Based on the surface reflectivity benchmark R, the mask binarization threshold T for post-segmentation processing is dynamically determined. A base threshold T1, a high reflectivity threshold R1, a low reflectivity threshold R2, an adjustment range ΔT, an upper threshold T2, and a lower threshold T3 are set. The mapping logic for the binarization threshold T is as follows:

[0103] When the surface reflectivity benchmark R is higher than the high reflectivity threshold R1, it indicates that the surface reflectivity of the current batch of guide pins is strong. In this case, the binarization threshold T is lowered to avoid the bright reflective areas being misjudged as background during mask segmentation, resulting in missed detections. When the surface reflectivity benchmark R is lower than the low reflectivity threshold R2, it indicates that the surface of the current batch of guide pins has deep oxidation or low reflectivity. In this case, the binarization threshold T is increased to avoid the oxidized dark areas being misjudged as foreground defects during mask segmentation, resulting in false detections. The upper threshold T2 and the lower threshold T3 are used to truncate and protect the dynamically adjusted thresholds, preventing extreme batches from causing excessive mask expansion or complete disappearance.

[0104] For example, the basic threshold T1 can be 0.5, the adjustment range ΔT can be 0.15, the upper threshold T2 can be 0.65, and the lower threshold T3 can be 0.35; the high reflectivity threshold R1 and the low reflectivity threshold R2 can be obtained based on the offline calibration of the guide needles in normal batches.

[0105] In the post-processing stage of the model, when the first segmentation model, the second segmentation model, or the third segmentation model binarizes the mask probability map output by each detection instance, the pixel values ​​of each pixel in the mask probability map activated by the sigmoid activation function are compared with the binarization threshold T. Pixels greater than the binarization threshold T are judged as foreground, and pixels less than or equal to the binarization threshold T are judged as background, thereby obtaining the binarized mask of each guide needle part and defect area.

[0106] For the second or third segmentation model, since the exposure parameters and imaging conditions of the second and third cameras are the same as those of the first camera, and the reflective properties of the materials of the same batch of guide pins are the same, the second or third segmentation model uses the same binarization threshold T calculated by the first segmentation model for post-masking processing; or, in the side local image, a fixed ROI corresponding to the A-part main body is preset separately, the reflectivity benchmark is calculated independently and the threshold is determined to adapt to the imaging differences of the side view.

[0107] In the specific detection scenario of capacitor guide pins, the segmentation failure itself encodes deterministic physical damage information. Different types of segmentation failures correspond to different types of structural damage, which can be reinterpreted as defect diagnosis signals rather than algorithm limitations.

[0108] In this embodiment, when the segmentation result of the first segmentation model on the expected visible part of the guide needle meets the segmentation failure judgment condition, the defect is not directly inferred, but a secondary verification process is triggered. The secondary verification process includes cross-view verification and feature-level verification.

[0109] Cross-view verification reuses the segmentation results of the calculated second and third segmentation models to cross-validate the region. If the second and third segmentation models can still identify the region, it is confirmed that the region still exists physically; if the second and third segmentation models cannot identify it either, it is confirmed that the region is also undetectable from the side view.

[0110] Feature-level verification extracts grayscale statistical features (including grayscale mean and grayscale variance) of the expected region in the global image and compares them with the grayscale feature benchmark of a known normal aluminum surface. If the grayscale statistical features of the expected region are consistent with the aluminum surface features (grayscale mean and variance are within the range of normal aluminum surface features), then the region is determined to contain aluminum physical content; if they are consistent with the background features (grayscale mean is close to the background grayscale, and variance is extremely low), then the region is determined not to contain aluminum physical content. The grayscale feature benchmark includes the grayscale mean and grayscale standard deviation of region A corresponding to the above surface reflectivity benchmark calculation process.

[0111] In this embodiment, segmentation failure can be further divided into two failure modes with different physical semantics, including: a first failure mode where the boundary is unidentifiable, and a second failure mode where the region is completely undetected.

[0112] The first failure mode refers to a situation where the first segmentation model outputs a mask region for that part, but the boundary accuracy of this mask region does not meet the preset geometric measurement conditions, meaning it cannot fit the center line of that part or extract the coordinates of the upper and lower edges. The first failure mode indicates that the part still exists physically, but its shape has undergone serious anomalies (such as cracking or severe tilting), causing the model to be unable to accurately describe its shape.

[0113] The second failure mode refers to a situation where the first segmentation model fails to output a mask region for that part. The second failure mode indicates that the part is physically completely missing (e.g., broken or fractured), causing the model to be unable to detect any trace of its existence.

[0114] For the first failure mode, if cross-view verification confirms that the part is still identifiable, a high-confidence structural deformation signal is generated; if cross-view verification does not confirm but feature-level verification shows the presence of aluminum physical content, a medium-confidence structural deformation signal is generated; if neither verification provides valid evidence, a low-confidence signal awaiting review is generated.

[0115] For the second failure mode, if the feature-level verification shows that the grayscale features of the expected area are consistent with the background, a high-confidence structural missing signal is generated; if the feature-level verification shows that the grayscale features are consistent with the reference part of the aluminum surface, a medium-confidence structural missing signal is generated; if the feature-level verification result is unclear, a low-confidence signal to be verified is generated.

[0116] The establishment of the above-mentioned secondary verification process relies on the domain-specific constraints unique to the capacitor pin detection scenario, including: the proximity switch has confirmed the presence of the pin, eliminating the possibility that the segmentation failure is due to the absence of the pin; the pin is formed by stamping, ensuring that all parts are present simultaneously, eliminating the possibility that missing parts are normal design features; the global view should fully present all parts of the pin, eliminating the possibility that the segmentation failure is due to viewpoint obstruction; the pin is made of aluminum, and its surface has optical properties that are significantly different from the background, allowing grayscale features to serve as auxiliary evidence for judging physical existence.

[0117] This embodiment adopts a differentiated handling strategy for different confidence levels. For example, a high-confidence structural deformation signal triggers an alarm and outputs a re-inspection command; a high-confidence structural missing signal triggers an alarm and outputs a rejection command; a medium-confidence signal triggers the corresponding type of alarm and outputs a re-inspection command; and a low-confidence signal awaiting review triggers a awaiting review alarm and outputs a manual review command.

[0118] Based on the same technical concept, this application also provides a defect detection device for capacitor leads, such as... Figure 7 As shown, the defect detection device 200 for the capacitor guide pin mainly includes: The acquisition module 201 is used to acquire a global image of the guide pin based on a first camera, and to acquire a partial image of the first side of the guide pin based on a second camera and a partial image of the second side of the guide pin based on a third camera. The first camera, the second camera and the third camera are used for synchronous shooting. The input module 202 is used to input the global image into the first segmentation model, input the first side local image into the second segmentation model, and input the second side local image into the third segmentation model; the first segmentation model, the second segmentation model, and the third segmentation model have the same network layer structure, and the input image width of the second segmentation model and the third segmentation model is half the input image width of the first segmentation model; The detection module 203 is used to perform full-dimensional defect detection based on the output of the first segmentation model, perform left-side view defect detection based on the output of the second segmentation model, and perform right-side view defect detection based on the output of the third segmentation model. The detection items for the left-side view defect detection and the right-side view defect detection are the same, and the detection items for the full-dimensional defect detection are more than the detection items for the left-side view defect detection or the right-side view defect detection. The first determination module 204 is used to obtain the detection results of the first segmentation model, the second segmentation model and the third segmentation model for each common detection item. When none of the three detection results detect a defect, the detection item is determined to be defect-free. When any one of the detection results detects a defect, the detection item is determined to be defective. The common detection item is a detection item included in all-dimensional defect detection, left-side visual defect detection and right-side visual defect detection. The second determination module 205 is used to determine whether a single-view detection item has a defect based on the detection result of the first segmentation model for each single-view detection item; the single-view detection item is a detection item included in the full-dimensional defect detection but not included in the left-side view defect detection and the right-side view defect detection.

[0119] Based on the same technical concept, this application also provides an electronic device, such as... Figure 8 As shown, the electronic device 300 includes a processor 301 and a memory 302, and may further include one or more of an information input / output (I / O) interface 303, a communication component 304, and a communication bus 305.

[0120] The processor 301 controls the overall operation of the electronic device 300 to complete all or part of the steps in the aforementioned defect detection method for capacitor leads. The memory 302 stores various types of data to support the operation of the electronic device 300. This data may include, for example, instructions for any application or method operating on the electronic device 300, as well as application-related data. The memory 302 can be implemented using any type of volatile or non-volatile storage device or a combination thereof.

[0121] I / O interface 303 provides an interface between processor 301 and other interface modules, such as keyboards, mice, and buttons. These buttons can be virtual or physical. Communication component 304 is used to test wired or wireless communication between electronic device 300 and other devices.

[0122] The communication bus 305 may include a path for transmitting information between the aforementioned components. The communication bus 305 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc.

[0123] The electronic device 300 may be implemented by one or more controllers, microcontrollers, microprocessors or other electronic components to perform the defect detection method for capacitor leads given in the above embodiments.

[0124] Electronic device 300 may include, but is not limited to, mobile terminals and fixed terminals such as digital TVs, desktop computers, etc., and may also be servers, etc.

[0125] Based on the same technical concept, this application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described defect detection method for capacitor leads.

[0126] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0127] The terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0128] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0129] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.

Claims

1. A method for detecting defects in capacitor conductors, characterized in that, include: The first camera captures a global image of the guide pin, the second camera captures a partial image of the first side of the guide pin, and the third camera captures a partial image of the second side of the guide pin. The first, second, and third cameras capture images simultaneously. The global image is input into the first segmentation model, the first side local image is input into the second segmentation model, and the second side local image is input into the third segmentation model; the first segmentation model, the second segmentation model, and the third segmentation model have the same network layer structure, and the input image width of the second segmentation model and the third segmentation model is half the input image width of the first segmentation model; Full-dimensional defect detection is performed based on the output of the first segmentation model, left-side visual defect detection is performed based on the output of the second segmentation model, and right-side visual defect detection is performed based on the output of the third segmentation model. The detection items for the left-side visual defect detection and the right-side visual defect detection are the same, and the detection items for the full-dimensional defect detection are more than those for the left-side visual defect detection or the right-side visual defect detection. For each common detection item, the detection results of the first segmentation model, the second segmentation model, and the third segmentation model are obtained respectively. When none of the three detection results detect a defect, the detection item is determined to be defect-free. When any one of the detection results detects a defect, the detection item is determined to be defective. The common detection item is a detection item included in all-dimensional defect detection, left-side visual defect detection, and right-side visual defect detection. For each single-view detection item, based on the detection result of the first segmentation model, it is determined whether the detection item has a defect; the single-view detection item is a detection item included in the full-dimensional defect detection, but not included in the left-side view defect detection and the right-side view defect detection. The first, second, and third segmentation models are all deep learning segmentation models. The segmentation heads of these models all include an upsampling module, which is composed of cascaded transposed convolutional layers. The number of cascaded transposed convolutional layers in the upsampling module is determined based on the intersection of segmentation boundary accuracy constraints, time budget constraints, and multi-model consistency constraints. This number of cascaded layers is used to achieve sub-pixel-level edge feature upsampling and restoration. The segmentation boundary accuracy constraint is measured by the average intersection-union ratio (IU) of the segmentation mask and the labeled mask; the closer the IU is to 1, the higher the segmentation boundary accuracy. Before inputting the global image into the first segmentation model, the method further includes: calculating the surface reflectance reference of the current batch of guide needles based on the grayscale statistics of the preset fixed region of interest in the global image; and dynamically adjusting the mask binarization threshold of the post-segmentation processing based on the surface reflectance reference. In the post-processing stage of the model, based on the adjusted mask binarization threshold, the mask probability map output by the first segmentation model is binarized to obtain the binarized masks of each guide needle part and defect area.

2. The method according to claim 1, characterized in that, The segmentation boundary accuracy constraint is that the average intersection-union ratio reaches a preset threshold to meet the sub-pixel level measurement requirements of the target part size of the guide pin; the time budget constraint means that the total image processing time of a single guide pin cannot exceed the production line cycle time; the multi-model consistency constraint requires that each segmentation model share the same network structure definition and the same set of inference engine construction configuration. If the segmentation boundary accuracy constraint, time budget constraint, and multi-model consistency constraint are all satisfied simultaneously, then the upsampling module includes a first transposed convolutional layer and a second transposed convolutional layer connected in series. The first transposed convolutional layer expands the input feature map by a factor of 2, and the second transposed convolutional layer expands the output feature map of the first transposed convolutional layer by a factor of 2.

3. The method according to claim 1, characterized in that, The training methods for the first segmentation model, the second segmentation model, and the third segmentation model include: Obtain the first training dataset, and perform balanced annotation on each part of the guide needle and the defect area in the global image to obtain the first annotation dataset; A second training dataset is obtained, and the visible side view regions in the first and second side view local images are labeled to obtain a second labeled dataset. In the labeling of the visible side view regions, the labeling weight of the CP line region of the guide needle is higher than that of the A part region. The labeling weight of the corresponding regions of detection items that are not suitable for side view detection is reset to zero or not labeled. The first segmentation model is trained based on the first labeled dataset, and the second and third segmentation models are trained based on the second labeled dataset. The loss function of the first segmentation model is evenly configured for each detection item, and the loss functions of the second and third segmentation models have a higher weight for side-view detectable items than for side-view undetectable items.

4. The method according to claim 3, characterized in that, The output of the first segmentation model is used to perform full-dimensional defect detection, including: Based on the first segmentation model, the A, E, B, Y, and CP line regions of the corresponding guide needle in the global image are segmented, as well as the defect regions of interlayer, straight line damage in B section, and damage in B section. Based on the fitting of the center line of region A, calculate the projection lengths of regions A, B, E, and Y on the center line of region A, and determine the corresponding dimensional deviations of each region; Calculate the distance between the upper and lower edges of region B as the diameter of region B, and determine the deviation of the diameter of region B. Calculate the distance between the coordinates of the end of the CP line and the coordinates of the top of section A as the total length of the guide needle, and determine the total length deviation; Calculate the perpendicular distance between the midpoint coordinates of the end of the CP line and the extension of the center line of part A to determine the bending defect of the CP line; Calculate the overlap between region Y and region B to determine weld protrusion defects; Within the longitudinal range defined by the upper and lower boundaries of the CP line, the lateral dimensions of the Y region are detected, and the presence of a missing corner region is determined based on the lateral dimensions. Calculate the distance difference between the upper and lower straight lines of part A and part B to determine the shoulder asymmetry defect; Calculate the area of ​​region A to determine the blade-shaped defect; Based on the segmentation results of the interlayer region, the B-section damage region, and the B-section straight-line damage region, the corresponding defects are determined.

5. The method according to claim 3, characterized in that, The step of performing left-side visual defect detection based on the output of the second segmentation model, or performing right-side visual defect detection based on the output of the third segmentation model, includes: Based on the second segmentation model or the third segmentation model, the Y part and CP line regions of the guide needle, as well as the defect regions of the straight line damage and B part damage in the first side local image or the second side local image are segmented. Calculate the projection length of the Y part onto the center line of the CP line, and determine the size deviation of the Y part. The center line of the CP line is obtained by fitting the coordinates of the upper and lower edges of the CP line region. Calculate the overlap between region Y and region B to determine weld protrusion defects; Within the longitudinal range defined by the upper and lower boundaries of the CP line, the lateral dimensions of the Y region are detected, and the presence of a missing corner region is determined based on the lateral dimensions. Based on the segmentation results of the B-section damage area and the B-section straight line damage area, the corresponding defects are determined.

6. A defect detection device for a capacitor conductor for implementing the method of any one of claims 1 to 5, characterized in that, include: The acquisition module is used to acquire a global image of the guide pin based on a first camera, and to acquire a partial image of the first side of the guide pin based on a second camera and a partial image of the second side of the guide pin based on a third camera. The first camera, the second camera and the third camera are used for synchronous shooting. The input module is used to input the global image into the first segmentation model, input the first side local image into the second segmentation model, and input the second side local image into the third segmentation model; the first segmentation model, the second segmentation model, and the third segmentation model have the same network layer structure, and the input image width of the second segmentation model and the third segmentation model is half the input image width of the first segmentation model; The detection module is used to perform full-dimensional defect detection based on the output of the first segmentation model, perform left-side view defect detection based on the output of the second segmentation model, and perform right-side view defect detection based on the output of the third segmentation model. The detection items for the left-side view defect detection and the right-side view defect detection are the same, and the detection items for the full-dimensional defect detection are more than the detection items for the left-side view defect detection or the right-side view defect detection. The first determination module is used to obtain the detection results of the first segmentation model, the second segmentation model, and the third segmentation model for each common detection item. When none of the three detection results detect a defect, the detection item is determined to be defect-free. When any one of the detection results detects a defect, the detection item is determined to be defective. The common detection item is a detection item included in all-dimensional defect detection, left-side visual defect detection, and right-side visual defect detection. The second determination module is used to determine whether a single-view detection item has a defect based on the detection result of the first segmentation model for each single-view detection item; the single-view detection item is a detection item included in the full-dimensional defect detection but not included in the left-side view defect detection and the right-side view defect detection.

7. An electronic device, characterized in that, It includes a processor and a memory, wherein the processor is coupled to the memory; The processor is configured to execute a computer program stored in the memory, causing the electronic device to perform the method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, Includes a computer program or instructions that, when run on a computer, cause the computer to perform the method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Static arc contact workpiece defect detection processing method based on image detection identification

    CN118052791A