High-precision PCB defect detection method and system based on transformer structure optimization

By using a PCB defect detection method based on the Transformer structure and utilizing radial topological spacing and grayscale lookup tables, the problem of defect identification in the cavity area of ​​embedded passive components in multilayer printed circuit boards is solved. This method achieves high-precision defect detection and automated sorting, improving the stability and quality control of the production line.

CN122492650APending Publication Date: 2026-07-31EAST CHINA UNIV OF TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
EAST CHINA UNIV OF TECH
Filing Date
2026-05-13
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately distinguish between normal brightness variations in the cavity area of ​​embedded passive devices in multilayer printed circuit boards and actual metal residues or foreign object defects, resulting in a high false alarm rate and insufficient detection accuracy, which fails to meet the stability and consistency requirements of automated production lines.

Method used

A high-precision PCB defect detection method based on Transformer structure is adopted. By calculating radial topological spacing, generating distance-grayscale correlation dataset, constructing grayscale interval lookup table and generating defect binarization distribution map, defect identification is performed in combination with spatial position relationship, and sorting control instructions are generated for rejection and sorting.

Benefits of technology

It enables accurate defect identification in the cavity area of ​​embedded passive devices, reduces false alarm rate, improves detection accuracy and consistency, and ensures the stability and quality control level of automated production lines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122492650A_ABST
    Figure CN122492650A_ABST
Patent Text Reader

Abstract

This invention discloses a high-precision PCB defect detection method and system based on Transformer structure optimization, belonging to the field of image detection technology. This invention employs radial topological spacing calculation, using Pre-LN to first normalize the features input to the self-attention or feedforward neural network, then perform corresponding calculations, and finally directly establishes residual connections with the original input. This approach can stabilize the numerical distribution of input features in advance, reducing fluctuations before residual connections, resulting in smoother gradient propagation during deep Transformer training. It is more suitable for fine-grained feature learning of long sequences of PCB images, improving the model's convergence speed and deep training stability. When generating anomaly judgment criteria, an optimized Transformer model is introduced to learn the correlation between "radial topological spacing + grayscale value," thereby obtaining more stable and accurate anomaly judgment results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image detection technology, and in particular to a high-precision PCB defect detection method and system based on Transformer structure optimization. Background Technology

[0002] As electronic products move towards high-density miniaturization, printed circuit boards (PCBs) are increasingly adopting embedded passive device structures to improve wiring density and electrical performance. In the manufacturing process of these multilayer boards, a cavity structure is typically pre-formed within the inner core board, and passive devices such as capacitors or resistors are placed inside the cavity. Then, resin filling and lamination curing processes are used to form the integral board. This process creates a complex three-dimensional structure within a localized space, consisting of the device components, cavity sidewalls, and filling resin. During lamination curing, due to unavoidable gaps between the device edges and cavity sidewalls, the resin flows and cures within the confined space, easily forming unique surface morphologies in these areas. These morphologies exhibit significant brightness changes under low-angle lighting conditions. In actual production, when industrial cameras, in conjunction with automated optical inspection equipment, perform online inspection of these multilayer boards, it is often necessary to complete defect identification and sorting in this area under high-speed transmission conditions to ensure product quality and meet the cycle time requirements of large-scale production.

[0003] In the existing technology, the automatic optical inspection methods for the above-mentioned multilayer boards mostly rely on fixed grayscale thresholds, global comparison, or end-to-end discrimination based on deep learning models to identify defects. However, in the cavity area of ​​embedded passive devices, the brightness of the surface morphology formed by normal processes varies systematically at different spatial locations. The above methods are difficult to accurately distinguish between normal areas and real metal residues or foreign defects. They are prone to misjudging brightness changes that are inevitable in the process as defects, which leads to an increased false alarm rate. In order to avoid false alarms, it is often necessary to reduce the detection sensitivity, which in turn causes the missed detection of small real defects. It is difficult to meet the requirements of stability and consistency of automated production lines while ensuring detection accuracy. Summary of the Invention

[0004] The purpose of this invention is to address the shortcomings of existing technologies, such as the difficulty in accurately distinguishing normal areas from actual metal residues or foreign matter defects, and the tendency to misjudge brightness changes that are inevitable during the process as defects. This invention proposes a high-precision PCB defect detection method and system based on Transformer structure optimization.

[0005] To address the problems existing in the prior art, the present invention adopts the following technical solution: A high-precision PCB defect detection method based on Transformer structure optimization includes: S1. Calculate the radial topological spacing based on the original grayscale image of the PCB area to be tested; S2. Generate a distance-grayscale correlation dataset based on radial topological spacing; S3. Generate an equidistant rheological attribute set based on the distance-grayscale association dataset, and generate a grayscale interval lookup table based on the equidistant rheological attribute set; S4. Generate a binary distribution map of defects based on a gray-scale interval lookup table; S5. Based on the defect binarization distribution map, the multilayer PCB board under test is sorted and rejected.

[0006] Preferably, the radial topological spacing is calculated based on the original grayscale image of the PCB area to be tested, including: Locate the area of ​​the PCB to be tested in the multilayer PCB board; Obtain the original grayscale image of the PCB area to be tested; Edge detection is performed on the original grayscale image to obtain the physical contour boundaries of the embedded passive devices in the multilayer PCB board under test; The radial topological spacing is obtained by calculating the Euclidean distance between each pixel of the original grayscale image and the physical contour boundary.

[0007] Preferably, a distance-grayscale association dataset is generated based on radial topological spacing, including: Data pairs are constructed based on the radial topological spacing of pixels in the original grayscale image and the grayscale values ​​of pixels in the original grayscale image. All data pairs are aggregated to generate a distance-grayscale correlation dataset.

[0008] Preferably, an equidistant rheological attribute set is generated based on the distance-grayscale association dataset, including: Extracting unique radial topological spacing from a distance-grayscale association dataset; Using each unique radial topological spacing as the index key, retrieve all data pairs with the same radial topological spacing in the distance-grayscale association dataset; All data pairs with the same radial topological spacing are defined as the set of equidistant rheological properties.

[0009] Preferably, generating a grayscale range lookup table based on an equidistant set of rheological properties includes: Statistical distribution calculation is performed on the gray values ​​in the equidistant rheological property set to obtain the gray values ​​of the lower quantile and the upper quantile. Arrange all unique radial topological spacings in ascending order of their numerical values ​​to obtain the distance index sequence; Define the gray value of the lower quantile as the compliant gray value lower limit; Define the grayscale value of the upper quantile as the compliant grayscale upper limit; Combine the lower limit of compliance grayscale and the upper limit of compliance grayscale to form the target grayscale range; Each radial topological spacing in the distance index sequence is bound to the corresponding target grayscale interval to generate a grayscale interval lookup table.

[0010] Preferably, generating a binary distribution map of defects based on a grayscale range lookup table includes: Based on the radial topological spacing and gray-level lookup table corresponding to the pixels in the original gray-level image, abnormal attribute marking is performed on the pixels to obtain rheological photometric mismatch points. Construct an initial matrix based on the original grayscale image; The element values ​​of the initial matrix are assigned based on the rheological photometric mismatch point; The initial matrix after assignment is image-encapsulated to obtain a binary distribution map of defects.

[0011] Preferably, the defect binarization distribution map is used to sort and reject PCB multilayer boards under test, including: Connectivity analysis was performed on the binary distribution map of defects to obtain a set of abnormal patches; Determine the centroid coordinates of each abnormal patch in the abnormal patch set in the image coordinate system of the original grayscale image; The physical and mechanical coordinates of the PCB multilayer board under test are obtained by performing a spatial mapping transformation on the centroid coordinates. Sorting control commands are generated based on physical mechanical coordinates; The multilayer PCB boards to be tested are rejected and sorted according to the sorting control instructions.

[0012] Preferably, the PCB multilayer board to be tested is rejected and sorted according to the sorting control command, including: According to the sorting control command, the timing of the action of the rejection actuator of the PCB multilayer board under test is triggered; Eliminate the force applied to the multilayer PCB board by the actuator; The PCB multilayer board to be tested is separated from the original transport path of the production line and introduced into the defective product collection area.

[0013] To address the aforementioned problems, this invention also provides a high-precision PCB defect detection system based on Transformer structure optimization, the system comprising: The spacing calculation module is used to calculate the radial topological spacing based on the original grayscale image of the PCB area under test; The association module is used to generate distance-grayscale association datasets based on radial topological spacing; The lookup table generation module is used to generate an equidistant rheological attribute set based on the distance-grayscale association dataset, and to generate a grayscale interval lookup table based on the equidistant rheological attribute set. The defect generation module is used to generate a binary distribution map of defects based on a gray-scale range lookup table. The rejection module is used to reject and sort multilayer PCB boards under test based on the defect binarization distribution map.

[0014] Compared with the prior art, the beneficial effects of the present invention are: 1. This invention calculates the spatial distance of the original grayscale image of the PCB area under test and introduces the radial topological spacing of the pixel relative to the physical contour of the embedded passive device. This transforms the traditional detection method based solely on grayscale intensity into an analysis method that combines spatial positional relationships. This provides a clear reference for normal brightness changes at different spatial positions, thereby accurately depicting the brightness distribution pattern formed by normal manufacturing processes within the cavity area of ​​the embedded passive device and avoiding misjudging such regular brightness changes as abnormal defects.

[0015] 2. This invention further constructs distance and grayscale correlation data based on radial topological spacing, and generates corresponding grayscale range lookup tables for different spacing positions, so that each pixel can match the corresponding compliant grayscale range according to its spatial position during the detection process, thereby achieving accurate identification of abnormal grayscale. This effectively overcomes the problem that the fixed threshold method cannot adapt to the brightness differences in different spatial regions, reduces the false alarm rate without reducing detection sensitivity, and improves the accuracy of identifying abnormal situations such as real metal residues or foreign objects.

[0016] 3. This invention generates a binary distribution map of defects and performs connected component analysis on abnormal regions to determine the spatial representative position of the abnormal regions in the image coordinate system. This position is then mapped to actual physical mechanical coordinates, thereby achieving precise linkage with the rejection mechanism of the automated production line. This enables the defect judgment results to be stably converted into executable sorting actions, effectively improving the inspection consistency and quality control level of multilayer PCB products. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings: Figure 1 This is a flowchart illustrating a high-precision PCB defect detection method based on Transformer structure optimization according to an embodiment of the present invention. Figure 2 This is a functional block diagram of a high-precision PCB defect detection system based on Transformer structure optimization provided in an embodiment of the present invention. Detailed Implementation

[0018] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0019] Example: This example provides a high-precision PCB defect detection method based on Transformer structure optimization. See [link to example]. Figure 1 Specifically, including: S1. Calculate the radial topological spacing based on the original grayscale image of the PCB area to be tested; In an embodiment of the present invention, the radial topological spacing is calculated based on the original grayscale image of the PCB area to be tested, including: Locate the area of ​​the PCB to be tested in the multilayer PCB board; Specifically, the preset coordinate information of the embedded passive device cavity recorded in the design file of the PCB multilayer board under test is first called. Then, the whole board image of the PCB multilayer board under test is acquired by industrial imaging equipment. Subsequently, the feature area corresponding to the embedded passive device cavity is identified in the whole board image. The identification of the feature area is based on the shape and size information of the cavity in the design file. The identified feature area is used as a reference, and a preset width is extended to the four sides of the reference area. The extended area is the PCB area under test. The preset width needs to cover the gap between the embedded passive device and the cavity sidewall and the surrounding normal substrate area.

[0020] Obtain the original grayscale image of the PCB area to be tested; Specifically, an industrial area array camera is used to target the pre-positioned PCB area under test. A low-angle ring light source is turned on to illuminate the area, with the incident angle of the light source set to be 30 to 45 degrees with the surface of the PCB area under test. The camera's exposure time is adjusted to clearly show the surface texture of the substrate, copper foil, and resin in the area. At the same time, the camera's gain parameter is set to a fixed value to avoid brightness fluctuations. Then, the camera is controlled to acquire images of the area, and the acquired color images are converted into single-channel images according to the brightness calculation rules. This single-channel image is the original grayscale image of the PCB area under test. The brightness calculation rule is to take the weighted average of the red channel value, green channel value, and blue channel value of each pixel in the color image, with the weights set to 0.299, 0.587, and 0.114, respectively.

[0021] Specifically, the PCB under test is a multilayer PCB containing embedded passive component cavities that undergoes quality inspection during actual production. This board is a solid board formed by lamination and other processes involving multiple layers of substrate, copper foil, and passive components embedded in the inner cavities. The PCB area under test is a localized area on the multilayer PCB under test that covers the embedded passive component cavities, the embedded passive components, and the gaps between the components and the cavity sidewalls—structures prone to defects. This area concentrates the structures requiring focused inspection. The original grayscale image is an image obtained by capturing the PCB area under test using an optical imaging device. This image presents the optical reflection characteristics of the PCB area surface using pixels with different grayscale values. The grayscale information of the pixels corresponds to the differences in optical reflection of the surface morphology and material of that area.

[0022] Edge detection is performed on the original grayscale image to obtain the physical contour boundaries of the embedded passive devices in the multilayer PCB board under test; Specifically, the original grayscale image is first subjected to Gaussian blurring. A blur kernel adapted to the image noise level is then used to perform convolution operations on the image to reduce random noise interference. Next, the Canny operator is used to extract edges from the blurred image. Low and high thresholds adapted to the grayscale difference level are set to extract all edge segments formed by abrupt grayscale changes in the image. Then, these edge segments are traversed, and closed edges that conform to the shape information of the embedded passive device recorded in the design file are selected. Finally, the selected closed edges are determined as the physical contour boundary of the embedded passive device in the multilayer PCB board under test.

[0023] The radial topological spacing is obtained by calculating the Euclidean distance between each pixel of the original grayscale image and the physical contour boundary.

[0024] Specifically, first, each pixel in the original grayscale image is traversed, and the horizontal and vertical coordinates of each pixel in the image plane are recorded. Then, for each pixel, all points on the physical contour boundary are traversed, and the straight-line distance between the pixel and each point on the boundary is calculated. The calculation method is the square root of the sum of the squares of the differences between the horizontal and vertical coordinates of the pixel and the boundary point. Then, the minimum value among all the distances calculated for the pixel is selected, and this minimum value is taken as the distance value of the corresponding pixel relative to the physical contour boundary. Finally, the distance values ​​of all pixels are arranged in order according to their positions in the original grayscale image to form a distance matrix with the same size as the original grayscale image. Each value in this distance matrix is ​​the radial topological spacing of the corresponding pixel.

[0025] Specifically, edge detection refers to identifying regions in the original grayscale image where grayscale values ​​change abruptly. These regions correspond to the boundary transition between the embedded passive device entity and the surrounding filling resin in the multilayer PCB board under test. The physical contour boundary is the two-dimensional projection boundary of the embedded passive device entity in the multilayer PCB board under test, obtained through edge detection. This boundary represents the actual physical edge of the embedded passive device within the board in the image. Euclidean distance calculation refers to the operation of calculating the straight-line distance between each pixel in the original grayscale image and the nearest point on the physical contour boundary. This distance reflects the spatial relationship between the PCB area position corresponding to the pixel and the physical edge of the embedded passive device. The radial topological spacing is the value obtained through Euclidean distance calculation. This value represents the radial spatial offset of the PCB area position corresponding to each pixel in the original grayscale image relative to the physical edge of the embedded passive device. Its magnitude corresponds to the physical distribution position of this position in the gap between the embedded passive device and the cavity sidewall.

[0026] S2. Generate a distance-grayscale correlation dataset based on radial topological spacing; In an embodiment of the present invention, a distance-grayscale association dataset is generated based on radial topological spacing, including: Data pairs are constructed based on the radial topological spacing of pixels in the original grayscale image and the grayscale values ​​of pixels in the original grayscale image. Specifically, first, each pixel in the original grayscale image is traversed, and the position information of each pixel in the image is recorded. Then, for each pixel, the radial topological spacing corresponding to the pixel is extracted from the corresponding distance matrix based on its position information. At the same time, the grayscale value corresponding to the pixel is extracted from the original grayscale image based on the same position information. Subsequently, the extracted radial topological spacing and grayscale value of the pixel are associated one by one to form an information unit containing the spatial offset attribute and optical reflection attribute of the pixel. This information unit is the data pair of the corresponding pixel.

[0027] All data pairs are aggregated to generate a distance-grayscale correlation dataset.

[0028] Specifically, the process involves iterating through all the pre-constructed data pairs corresponding to all pixels in the original grayscale image, and sequentially incorporating each data pair into a pre-defined set container. During the incorporation process, the correspondence between each data pair and the corresponding pixel position information is maintained. After all the data pairs of all pixels have been incorporated, the data in the set container is organized so that each entry in the set contains the correlation information between the radial topological spacing of the pixel and the grayscale value. The organized set is the distance-grayscale correlation dataset.

[0029] Specifically, a data pair refers to an information unit formed by associating and combining two attribute information corresponding to the same pixel in the original grayscale image. One attribute is the radial topological spacing corresponding to the pixel, which reflects the spatial offset relationship between the PCB area position corresponding to the pixel and the physical edge of the embedded passive device. The other attribute is the grayscale value corresponding to the pixel, which corresponds to the optical reflection characteristics of the surface material at the PCB area position. The distance-grayscale association dataset refers to the set formed by summarizing and integrating the above data pairs corresponding to all pixels in the original grayscale image. This set covers the association information between the spatial offset relationship and the optical reflection characteristics corresponding to all positions in the PCB area under test, providing a basic sample for subsequent analysis of the normal optical characteristics of this area.

[0030] S3. Generate an equidistant rheological attribute set based on the distance-grayscale association dataset, and generate a grayscale interval lookup table based on the equidistant rheological attribute set; In an embodiment of the present invention, an equidistant rheological attribute set is generated based on a distance-grayscale correlation dataset, including: Extracting unique radial topological spacing from a distance-grayscale association dataset; Specifically, the process first iterates through each data pair in the distance-grayscale correlation dataset, extracting the corresponding radial topological spacing information from each pair. Simultaneously, an empty information list is created to store the extracted spacings. During extraction, for each radial topological spacing to be stored, it is compared with the spacing already stored in the information list. If the spacing does not exist in the information list, it is added; otherwise, the storage operation is skipped. After iterating through all data pairs, the information list contains the unique radial topological spacings extracted from the distance-grayscale correlation dataset.

[0031] Using each unique radial topological spacing as the index key, retrieve all data pairs with the same radial topological spacing in the distance-grayscale association dataset; Specifically, a unique radial topological spacing is first selected as the current index key. Then, each data pair in the distance-grayscale association dataset is traversed, and the radial topological spacing contained in each data pair is extracted and compared with the current index key. If the radial topological spacing contained in the data pair matches the current index key, the data pair is added to the temporary set corresponding to the current index key; otherwise, the next data pair is traversed. After traversing all data pairs, the temporary set stores all data pairs with the radial topological spacing corresponding to the current index key. Then, the next unique radial topological spacing is selected as the new index key, and the above retrieval operation is repeated until all unique radial topological spacings have been retrieved.

[0032] All data pairs with the same radial topological spacing are defined as the set of equidistant rheological properties.

[0033] Specifically, the unique radial topological spacing refers to the radial topological spacings with non-repeating values ​​selected from the distance-grayscale correlation dataset. These spacings correspond to the unique spatial offset of different locations within the PCB area under test relative to the physical edge of the embedded passive device. Each spacing represents a type of region in the same spatial location. The index key refers to the identification information used for each unique radial topological spacing, which allows the location of the corresponding related data content in the distance-grayscale correlation dataset.

[0034] Specifically, the equidistant rheological property set refers to the set formed by integrating all data pairs with the same radial topological spacing in the distance-grayscale correlation dataset. This set covers the optical reflection characteristics of all regions at the same spatial offset position and can reflect the optical performance law corresponding to the material rheological properties at that spatial position.

[0035] Specifically, the radial topological spacing directly reflects the spatial offset relationship between the PCB area position corresponding to the pixel in the original grayscale image and the physical edge of the embedded device. Positions with the same radial topological spacing mean that they are in the same spatial region at a distance equivalent to the edge of the device. These regions correspond to the same source positions within the confined gap between the device and the cavity sidewall. During the resin lamination and curing process, the resin in these equivalent spatial regions is subject to the same degree of asymmetric boundary constraint between the smooth end electrode of the device and the rough copper wall of the cavity. The flow resistance, volume shrinkage amplitude, and surface tension effect of the resin remain uniform. As a result, the physical characteristics such as the geometric slope and surface morphology of the resin asymmetric cured wedge structure have homology. The grayscale values ​​contained in the data pairs are the surface optical reflection properties of the region corresponding to this type of wedge structure. Integrating these data pairs with the same radial topological spacing into an equidistant rheological property set can completely and accurately carry the corresponding law of resin rheological behavior and optical characteristics under the same equivalent spatial position. This provides a standardized analysis unit for distinguishing the normal optical performance of the resin asymmetric cured wedge structure with good process from the abnormal optical characteristics of malignant defects based on this law.

[0036] It should be noted that the resin asymmetric curing wedge structure is a resin-cured structure that naturally forms within the confined gap between the embedded device and the cavity sidewall during the lamination and curing process of a multilayer board containing embedded passive devices. Its formation originates from the asymmetric boundary constraint—the smooth fixation of the device's end electrodes and the rough, sloping copper wall of the cavity—after the resin fills the gap. During curing, differences in resin flow resistance and volume shrinkage in different regions, coupled with the dominant role of surface tension, prevent the resin from forming a flat surface, ultimately resulting in a wedge shape with a specific slope and asymmetric morphology. This structure is hidden at the edge of the macroscopic resin depression region, and its geometry and surface characteristics are jointly determined by the resin's rheological behavior and curing shrinkage. Its unique slope and surface morphology have a specific impact on the light reflection path of optical detection.

[0037] In an embodiment of the present invention, generating a grayscale range lookup table based on an equidistant set of rheological properties includes: Statistical distribution calculation is performed on the gray values ​​in the equidistant rheological property set to obtain the gray values ​​of the lower quantile and the upper quantile. Specifically, first, all data pairs contained in the current equidistant rheological property set are traversed, and the corresponding gray values ​​are extracted from each data pair. These gray values ​​are then organized into a numerical list, and the gray values ​​in the numerical list are sorted in ascending order to obtain an ordered gray value sequence. Next, a quantile ratio adapted to the process characteristics of embedded passive devices is selected, and the position corresponding to the lower quantile point is calculated. This position is the product of the length of the ordered gray value sequence and the lower quantile ratio. Based on this position, the corresponding gray value is extracted from the ordered gray value sequence, which is the gray value of the lower quantile point. Then, the corresponding upper quantile ratio is selected, and the position corresponding to the upper quantile point is calculated in the same way, and the corresponding gray value is extracted, which is the gray value of the upper quantile point.

[0038] Arrange all unique radial topological spacings in ascending order of their numerical values ​​to obtain the distance index sequence; Specifically, all unique radial topological spacings are first organized into a temporary spacing list. Then, the first spacing in the temporary spacing list is selected as the initial comparison benchmark. The benchmark is compared with the values ​​of other spacings in the list in turn. If the value of a spacing is less than the value of the benchmark, the spacing is moved in front of the benchmark. If the value of a spacing is greater than the value of the benchmark, the spacing is moved behind the benchmark. This comparison and adjustment operation is repeated until all spacings in the temporary spacing list are arranged in ascending order of value. At this point, the temporary spacing list is the distance index sequence.

[0039] Specifically, statistical distribution calculation refers to the calculation of data distribution characteristics for all gray values ​​within the same equidistant rheological property set. This operation determines the normal optical reflection range boundary of the resin asymmetric cured wedge structure at the equivalent spatial location by analyzing the central tendency and dispersion of the gray values. The lower quantile gray value is the value obtained by statistical distribution calculation that is located at a lower proportion of the gray value distribution. This value corresponds to the lowest brightness of the optical reflection of the normal resin structure surface at the equivalent spatial location. The upper quantile gray value is the value obtained by statistical distribution calculation that is located at a higher proportion of the gray value distribution. This value corresponds to the highest brightness of the optical reflection of the normal resin structure surface at the equivalent spatial location. The distance index sequence is a sequence formed by arranging all non-repeating radial topological spacings in ascending order of value. This sequence organizes different equivalent spatial locations in an orderly manner according to their distance from the edge of the device, providing an orderly identification basis for subsequently associating the normal gray range of each location.

[0040] Define the gray value of the lower quantile as the compliant gray value lower limit; Define the grayscale value of the upper quantile as the compliant grayscale upper limit; Specifically, the above steps involve directly identifying the grayscale value of the lower quantile point corresponding to each equidistant rheological property set as the compliant lower limit of grayscale for the equivalent spatial location indicated by the corresponding radial topological spacing. This operation is based on the fact that the grayscale value of the lower quantile point is a value with a low proportion in the grayscale value distribution within the set, representing the minimum reasonable brightness of optical reflection of the benign structure at that location. Subsequently, the grayscale value of the upper quantile point corresponding to the same equidistant rheological property set is identified as the compliant upper limit of grayscale for the corresponding location. This upper quantile point grayscale value is a value with a high proportion in the grayscale value distribution within the set, corresponding to the highest reasonable brightness of optical reflection of the benign structure at that location. The logic behind these two sequential steps is that the grayscale values ​​within the equidistant rheological property set correspond to the normal optical performance of the resin asymmetric cured wedge structure at the same equivalent spatial location. Defining the lower limit first and then the upper limit provides a complete boundary division of the reasonable optical reflection range at that location, providing a clear quantitative constraint for the subsequent construction of the target grayscale interval, ensuring that the compliant optical characteristics of each equivalent spatial location can be accurately defined.

[0041] Combine the lower limit of compliance grayscale and the upper limit of compliance grayscale to form the target grayscale range; Specifically, first determine the current radial topology spacing, find the compliant grayscale lower limit and compliant grayscale upper limit associated with the radial topology spacing, then take the value of the compliant grayscale lower limit as the starting value of the range and the value of the compliant grayscale upper limit as the ending value of the range, and associate the starting value and the ending value in ascending order to form a continuous range. This range is the target grayscale interval corresponding to the radial topology spacing. Repeat this operation for each radial topology spacing to obtain the target grayscale interval corresponding to each radial topology spacing.

[0042] Each radial topological spacing in the distance index sequence is bound to the corresponding target grayscale interval to generate a grayscale interval lookup table.

[0043] Specifically, first, each radial topological spacing in the distance index sequence is traversed. For each traversed radial topological spacing, its corresponding target grayscale interval is found. Then, the radial topological spacing is used as identification information to establish a one-to-one correspondence with the corresponding target grayscale interval. After all radial topological spacings have been associated with their corresponding target grayscale intervals, these association information are arranged into an ordered set of entries according to the order of the distance index sequence. Each entry contains a radial topological spacing and its corresponding target grayscale interval. This set of entries is the grayscale interval lookup table.

[0044] Specifically, the compliant grayscale lower limit is the value determined by the grayscale value of the lower quantile corresponding to the equidistant rheological property set. It represents the lowest reasonable range of optical reflection brightness of the surface of a benign structure such as a resin asymmetric curing wedge structure at the equivalent spatial position indicated by the corresponding radial topological spacing. The compliant grayscale upper limit is the value determined by the grayscale value of the upper quantile corresponding to the equidistant rheological property set. It represents the highest reasonable range of optical reflection brightness of the surface of a benign structure such as a resin asymmetric curing wedge structure at the equivalent spatial position indicated by the corresponding radial topological spacing. The target grayscale interval is the range jointly formed by the compliant grayscale lower limit and the compliant grayscale upper limit corresponding to the same radial topological spacing. This range covers the normal optical reflection brightness range of a benign structure at the corresponding equivalent spatial position and is the basis for distinguishing between normal optical performance and abnormal optical characteristics at this position. The grayscale interval lookup table is a table formed by associating each radial topological spacing in the distance index sequence with its corresponding target grayscale interval. This table integrates the normal optical reflection brightness range at different equivalent spatial positions and can directly provide the basis for querying the compliant grayscale interval corresponding to each position for subsequent detection.

[0045] Specifically, the equidistant rheological property set clearly defines the normal grayscale value distribution pattern of benign structures such as resin asymmetric curing wedge structures at the equivalent spatial location corresponding to the same radial topological spacing. Based on this set, a grayscale interval lookup table is generated, which can systematically integrate the compliant lower and upper grayscale limits of each equivalent spatial location and establish an ordered query association by binding it with the distance index sequence. This avoids the false alarms or missed detections caused by the inability of traditional fixed threshold detection to adapt to the differences in grayscale characteristics of different spatial locations. In subsequent detection processes, the corresponding target grayscale interval can be quickly located according to the radial topological spacing of the pixel to be detected, and the actual grayscale value of the pixel can be directly compared to see if it is within the compliant range. This allows for efficient and accurate determination of whether the location is a benign resin asymmetric curing wedge structure or a malignant defect such as copper slag residue, providing a standardized and queryable grayscale reference for the detection process and ensuring the consistency and accuracy of the detection results.

[0046] S4. Generate a binary distribution map of defects based on a gray-scale interval lookup table; In an embodiment of the present invention, generating a binary distribution map of defects based on a grayscale range lookup table includes: Based on the radial topological spacing and gray-level lookup table corresponding to the pixels in the original gray-level image, abnormal attribute marking is performed on the pixels to obtain rheological photometric mismatch points. Specifically, each pixel in the original grayscale image is traversed. First, the radial topological spacing corresponding to the pixel is extracted from the corresponding distance matrix. Then, the target grayscale interval bound to it is retrieved in the grayscale interval lookup table through the radial topological spacing. At the same time, the actual grayscale value of the pixel in the original grayscale image is extracted. Then, the actual grayscale value is compared with the compliant lower grayscale limit and compliant upper grayscale limit of the retrieved target grayscale interval. If the actual grayscale value is less than the compliant lower grayscale limit or greater than the compliant upper grayscale limit, it indicates that the optical reflection characteristics of the pixel deviate from the normal rheological optical characteristics of the resin asymmetric curing wedge structure with good process under the corresponding equivalent spatial position. Then, the pixel is marked as a pixel with abnormal attributes. Such pixels that are confirmed to deviate from the normal range after comparison are rheological photometric mismatch points.

[0047] Specifically, rheological photometric mismatch points refer to pixels in the original grayscale image whose actual grayscale value does not fall within the target grayscale range after the corresponding target grayscale range is matched in the grayscale lookup table based on the radial topological spacing of the pixel. The optical reflection characteristics of these points deviate from the standard optical characteristics exhibited by a benign resin asymmetric cured wedge structure under normal rheological behavior at the corresponding equivalent spatial location. Their abnormal grayscale values ​​originate from localized material or structural distortions caused by malignant defects such as copper slag residue and foreign matter. They are the core identifiers of defect locations in PCB multilayer boards, directly reflecting that the process state at that location deviates from the physical laws of normal lamination and curing.

[0048] Construct an initial matrix based on the original grayscale image; Specifically, the steps for constructing an initial matrix based on the original grayscale image are as follows: First, determine the number of pixel rows and columns of the original grayscale image. Use the number of pixel rows of the original grayscale image as the number of rows of the matrix to be constructed, and use the number of pixel columns of the original grayscale image as the number of columns of the matrix to be constructed. Create an empty matrix with the same number of rows and columns as the original grayscale image. Then, assign a uniform initial default value to each element in the empty matrix so that the position of each element in the matrix corresponds one-to-one with the position of each pixel in the original grayscale image, thus completing the construction of the initial matrix.

[0049] The element values ​​of the initial matrix are assigned based on the rheological photometric mismatch point; Specifically, first, all the identified rheometric mismatch points are traversed, and the horizontal and vertical coordinates of each point in the original grayscale image are obtained one by one. The coordinates are mapped to the row and column indices of the initial matrix. The element in the initial matrix that matches the index is found, and the value of the element is modified to 1. For the positions in the original grayscale image that are not marked as rheometric mismatch points, the corresponding elements in the initial matrix are kept unchanged with the initial value of 0. The assignment and adjustment of all elements in the initial matrix are completed.

[0050] The initial matrix after assignment is image-encapsulated to obtain a binary distribution map of defects.

[0051] Specifically, the value of each element in the initial matrix after assignment is mapped to the brightness state of the image pixel. The element with a value of 1 is set to a brightness value with obvious visual differentiation, and the element with a value of 0 is set to another type of brightness value. According to the row and column arrangement order of the initial matrix, the brightness values ​​corresponding to all elements are combined in sequence into a pixel array with the same size as the original grayscale image. Then, the pixel array is converted into a visual image format. This image is a defect binarization distribution map that can intuitively present the distribution of defect locations.

[0052] Specifically, the initial matrix refers to a matrix structure constructed with the same pixel arrangement and size as the original grayscale image, containing the same number of pixels. Each element in the matrix corresponds to the position of a pixel in the original grayscale image, providing a carrier for recording the attribute status of the pixel later. The assignment processing refers to assigning specific values ​​to the elements at the corresponding positions in the initial matrix based on the location information of the rheological photometric mismatch points. The matrix elements corresponding to the rheological photometric mismatch points are assigned values ​​that are different from those corresponding to normal pixels, thereby distinguishing abnormal pixels from normal pixels in the original grayscale image. The defect binarization distribution map refers to encapsulating the initial matrix after the assignment processing in image form, converting the elements with different values ​​in the matrix into corresponding image pixel brightness, forming an image containing only two brightness states. One state corresponds to normal pixels, and the other state corresponds to rheological photometric mismatch points, which can intuitively present the distribution of defect locations.

[0053] Specifically, generating a binary distribution map of defects is a crucial step in achieving efficient and accurate defect detection in multilayer boards containing embedded passive components. Previously, rheological photometric mismatch points were marked using a grayscale lookup table. These points were scattered throughout the original grayscale image, and their corresponding defect information was obscured by background noise and grayscale variations in normal areas, making it difficult to directly identify the location, range, shape, and quantity of defects. Binarization, however, maps the specific values ​​representing rheological photometric mismatch points in the initial matrix to the initial default values ​​representing normal pixels, respectively, into two significantly different brightness states. This greatly simplifies the image information dimensions, completely eliminates irrelevant interference, and makes the defect areas stand out clearly. This distribution map not only intuitively presents the spatial distribution characteristics of defects but also provides a standardized image carrier for subsequent quantitative analysis of defects, such as area calculation, quantity statistics, and morphological judgment. It effectively avoids the subjectivity and misjudgment risks of manual visual inspection, while also adapting to the automated inspection needs of industrial production lines, ensuring the consistency, reliability, and efficiency of defect detection results, and providing direct evidence for subsequent process optimization and quality control.

[0054] S5. Based on the defect binarization distribution map, the multilayer PCB board under test is sorted and rejected.

[0055] In an embodiment of the present invention, the process of rejecting and sorting multilayer PCB boards under test based on a defect binarization distribution map includes: Connectivity analysis was performed on the binary distribution map of defects to obtain a set of abnormal patches; Specifically, each pixel in the defect binarization distribution map is traversed first, and the value corresponding to each pixel is checked to see if it is a preset value representing an anomaly. When a pixel with the preset value is found, its position is marked, and the pixel values ​​of its four adjacent positions (up, down, left, and right) are also the preset value. All adjacent pixels with the preset value are aggregated into a continuous region. Each newly discovered continuous region is assigned a unique identifier to distinguish different regions. After traversing all pixels, all continuous regions with identifiers are integrated into a set, which is the abnormal patch set.

[0056] It should be noted that the process of generating the preset values ​​representing anomalies is as follows: First, the limitations of the original Transformer for this task are clarified. Its fully self-attention mechanism exhibits a quadratic increase in computational complexity due to the hundreds of thousands of pixel sequences in the PCB grayscale image. Furthermore, the Post-LN structure is prone to gradient vanishing when stacked deeply, making it difficult to stably learn pixel-level fine-grained features. To address this, the attention mechanism is optimized by replacing fully self-attention with a hybrid mechanism combining local window attention and cross-window sparse attention. Specifically, the image is divided into non-overlapping local windows of 16×16 pixels, and the full attention is calculated within each window. This involves calculating the attention weights of each pixel within a window relative to other pixels within the window. Then, for the edge pixels (row 2, column 2) of each window, the attention weights are calculated for their corresponding edge pixels in adjacent windows. Non-edge pixels are not subject to cross-window attention calculations. This limits the attention calculation to local areas and adjacent edges, reducing computational cost while preserving local pixel relationships and feature interactions with neighboring regions. Next, the hierarchical structure is optimized by changing the original Transformer's Post-LN structure to a Pre-LN structure. Specifically, layer normalization is performed at the input of each self-attention layer before attention calculation and residual connections are made. The same process is repeated at the input of the feedforward neural network layer. The process involves layer normalization, followed by linear transformation and activation operations. A 1e-5 weight decay term is added to the residual connection branches to alleviate the gradient vanishing problem in deep training and improve the training stability of models with more than 24 layers. Next, positional encoding is optimized by linearly mapping the horizontal, vertical, and radial topological distances of each pixel to vectors of the same dimension. These vectors are then element-wise summed and fused using the GELU activation function to generate a joint positional encoding that includes both spatial location and topological association. This encoding serves as the positional embedding input for the Transformer, allowing the model to capture both pixel spatial distribution and topological distance features. Finally, the feedforward layer structure is optimized by replacing the original fully connected layers with deep... The degree-separable convolutional layer first transforms the channel dimension of the input features through a 1×1 convolution, then extracts the local features of each channel through a 3×3 depthwise convolution, and finally restores the channel dimension through a 1×1 convolution. This design compresses the parameter scale to about 1 / 8 of the original fully connected layer while enhancing the ability to capture local gray-level changes in pixels, adapting to the local feature distribution of defective pixels in PCB images. After optimizing the Transformer structure through the above steps, the radial topological spacing and gray-level values ​​in the training data are used as the input sequence, and the pixel attribute labels are used as the output target for training, enabling the model to learn the corresponding feature patterns to generate preset values ​​representing anomalies.

[0057] Specifically, Post-LN and Pre-LN are two structural variants of Transformer that combine layer normalization and residual connections. The core difference lies in the position of layer normalization in the residual process: Post-LN first performs the computation of the self-attention or feedforward neural network, then performs a residual connection between the computation result and the original input, and finally performs layer normalization on the connected result. With this structure, when the model has a deep number of layers, the computation result before the residual connection is prone to numerical fluctuations, which can easily lead to gradient vanishing during gradient propagation. It has poor stability in deep model training for long pixel sequence tasks of PCB images. Pre-LN, on the other hand, first performs layer normalization on the features input to the self-attention or feedforward neural network, then performs the corresponding computation, and then directly performs a residual connection with the original input. This method can stabilize the numerical distribution of the input features in advance, reduce fluctuations before the residual connection, and make gradient propagation smoother during deep Transformer training. It is more suitable for fine-grained feature learning of long sequences of PCB images and can improve the convergence speed and deep training stability of the model.

[0058] Determine the centroid coordinates of each abnormal patch in the abnormal patch set in the image coordinate system of the original grayscale image; Specifically, for each abnormal patch in the abnormal patch set, first extract the horizontal and vertical coordinates of all pixels contained in the patch in the original grayscale image coordinate system. Then, sum the horizontal coordinates of all pixels in the patch and divide the sum by the number of pixels contained in the patch to obtain the horizontal average coordinate. In the same way, sum the vertical coordinates of all pixels and divide by the number of pixels to obtain the vertical average coordinate. The coordinate value obtained by combining the horizontal average coordinate and the vertical average coordinate is the centroid coordinate of the abnormal patch in the original grayscale image coordinate system. Repeat this operation for each abnormal patch to obtain the centroid coordinates of all abnormal patches.

[0059] Specifically, connected component analysis refers to the operation of adjacency determination and aggregation of pixels with the same brightness state in the defect binarized distribution map. Adjacent pixels representing anomalies in the defect binarized distribution map are combined into regions with continuous ranges. The abnormal patch set refers to the set of all such continuous abnormal regions obtained after connected component analysis, with each region corresponding to a concentrated defect location. Centroid coordinates refer to the coordinate values ​​that represent the center position of each abnormal patch in the abnormal patch set, calculated based on the horizontal and vertical coordinates of all pixels contained in the patch in the original grayscale image coordinate system.

[0060] The physical and mechanical coordinates of the PCB multilayer board under test are obtained by performing a spatial mapping transformation on the centroid coordinates. Specifically, spatial mapping transformation refers to the operation of converting the coordinates in the image coordinate system into the position coordinates corresponding to the actual physical dimensions of the PCB multilayer board based on the positional correspondence between the original grayscale image and the PCB multilayer board under test. The physical mechanical coordinates refer to the specific position coordinates of the defects on the actual entity of the PCB multilayer board under test obtained after the spatial mapping transformation, which can be directly used to locate the defect area on the PCB multilayer board.

[0061] Specifically, at least three non-collinear calibration markers are pre-selected within the effective detection area of ​​the PCB multilayer board to be tested. The physical coordinates of each calibration marker on the PCB entity are obtained using precision measurement tools. These coordinates are consistent with the mechanical positioning dimension of the PCB production equipment. Simultaneously, these calibration markers are accurately located in the original grayscale image using contour fitting or template matching. The pixel coordinates in the corresponding image coordinate system are read. The pixel coordinates of each set of calibration markers are matched one-to-one with the physical coordinates. The least squares method is used to solve for the spatial mapping transformation matrix containing scaling, rotation, and translation parameters. Then, the centroid coordinates of each abnormal patch are extracted. These coordinates are the horizontal and vertical pixel values ​​in the image coordinate system. The horizontal and vertical pixel values ​​of the centroid coordinates are substituted into the spatial mapping transformation matrix. The corresponding horizontal and vertical physical coordinates are obtained through matrix operations. The coordinate values ​​formed by the combination of the two are the physical and mechanical coordinates of the PCB multilayer board to be tested corresponding to the abnormal patch.

[0062] Sorting control commands are generated based on physical mechanical coordinates; Specifically, the physical and mechanical coordinates of all defects on the multilayer PCB under test are first extracted to determine the lateral and longitudinal physical positions of each defect on the PCB. Simultaneously, the real-time transmission speed data from the production line system is read, and the physical distance between the sorting actuator and the current position of the PCB is measured. The precise time it takes for the defective board to reach the effective operating area of ​​the sorting actuator is calculated by dividing the physical distance by the transmission speed, thus determining the timing parameters for triggering the command. Next, the thickness, weight, and other specifications of the PCB are obtained. Combined with the physical and mechanical coordinates, the edge distance of the defect area is determined, and the appropriate action point of the push rod in the sorting actuator is matched. Based on the PCB weight, the preset thrust range is queried, and a thrust value that ensures separation without damaging the PCB is selected. Simultaneously, the stroke and speed of the push rod extension are set. The stroke must be sufficient to completely push the PCB away from the original transmission path, and the speed must be compatible with the transmission speed to avoid collisions. Subsequently, the timing parameters trigger time, motion parameters thrust value extension stroke extension speed, position parameters corresponding to defects physical and mechanical coordinates and push rod action points are integrated. According to the instruction coding format that the sorting actuator can recognize, the starting identifier parameter fields and verification identifiers are arranged in sequence. The parameter fields must clearly define the motion instruction details corresponding to each physical and mechanical coordinate. The verification identifier is generated by performing logical operations on all parameters to ensure the accuracy of instruction transmission. Finally, they are combined to form a complete sorting control instruction.

[0063] Specifically, the sorting control command refers to a command generated based on the physical and mechanical coordinates of the defects in the PCB multilayer board under test, integrating defect location information, execution action type, action timing parameters, and actuator operating parameters. This command can be recognized and responded to by the sorting actuator on the PCB production line, guiding the actuator to accurately locate the defective PCB multilayer board according to the physical and mechanical coordinates, and execute the preset separation action in a timing sequence adapted to the production line's transmission speed. By controlling parameters such as push rod extension force and guide angle, the defective board is smoothly separated from the original transmission path, while the qualified board is guided to continue transmission along the original path. Ultimately, this achieves automated differentiation and processing of defective and qualified boards, providing accurate and efficient execution basis for production line quality control and adapting to the automation needs of large-scale production.

[0064] The multilayer PCB boards to be tested are rejected and sorted according to the sorting control instructions.

[0065] In an embodiment of the present invention, the sorting and rejection of the multilayer PCB board to be tested according to the sorting control command includes: According to the sorting control command, the timing of the action of the rejection actuator of the PCB multilayer board under test is triggered; Specifically, the action trigger time node and the start signal parameter of the rejection actuator contained in the sorting control instruction are first read. The parameter is matched with the action logic of the rejection actuator. After confirming that the rejection actuator is in a standby ready state, the time deviation between the trigger action and the position of the PCB multilayer board is calculated by combining the real-time moving speed of the PCB multilayer board to be tested on the production line transmission path. The start trigger signal is sent to the rejection actuator according to the time node specified in the instruction, and the transmission path running status at the trigger time is recorded synchronously, thereby completing the precise triggering of the rejection actuator action sequence.

[0066] Eliminate the force applied to the multilayer PCB board by the actuator; Specifically, based on the real-time position of the PCB multilayer board under test on the production line conveying path, the push rod component of the rejection actuator is adjusted so that the working end face of the push rod is parallel to the side of the PCB multilayer board, and the point of action is located on the side of the PCB multilayer board away from the center of the conveying path. Then, based on the thickness and weight parameters of the PCB multilayer board, the output thrust value of the push rod is set. When the PCB multilayer board moves to the effective working area of ​​the push rod, the push rod is controlled to extend in a horizontal direction perpendicular to the conveying direction, so that the end face of the push rod is in stable contact with the side of the PCB multilayer board, and the set thrust is continuously applied until the edge of the PCB multilayer board is removed from the support track of the original conveying path.

[0067] The PCB multilayer board to be tested is separated from the original transport path of the production line and introduced into the defective product collection area.

[0068] Specifically, after the push rod applies a pushing force to cause the edge of the PCB multilayer board to detach from the support track of the original transmission path, the PCB multilayer board is guided to slide along the inclined direction of the guide plate by means of the inclined guide plate preset on the side of the transmission path. The inclined angle of the guide plate must be adapted to the direction of the push force of the push rod, and its end must be seamlessly connected with the entrance of the defective product collection area. After the PCB multilayer board is completely detached from the support structure of the original transmission path, it slides into the flexible buffer tray in the defective product collection area by its own gravity along the guide plate. The flexible pad on the surface of the buffer tray can prevent the PCB multilayer board from being damaged when it comes into contact with the collection area, thereby completing the separation of the PCB multilayer board under test from the original transmission path and the introduction into the defective product collection area.

[0069] To verify the detection performance of the method of this invention, a comparative experiment was conducted on multilayer PCBs containing embedded passive components. The experiment selected 1000 multilayer PCBs with process-related brightness variations (including 200 samples containing actual metal residues and foreign object defects) from the production line. The traditional fixed grayscale threshold detection method, the conventional Transformer end-to-end detection method, and the method of this invention were used for detection. The results showed that the defect identification accuracy of the method of this invention reached 99.2%, with a false alarm rate of only 0.3% and a false negative rate of 0.5%. In comparison, the traditional fixed grayscale threshold detection method had an identification accuracy of 82.5%, a false alarm rate of 15.8%, and a false negative rate of 12.2%; the conventional Transformer end-to-end detection method had an identification accuracy of 94.8%, a false alarm rate of 3.1%, and a false negative rate of 2.3%. The method of this invention takes only 0.8 seconds to inspect a single PCB, which meets the inspection cycle requirements of high-speed transmission in industrial production lines. In the training of a 24-layer deep Transformer model, the convergence speed is improved by 40% compared with the conventional Transformer method, the fluctuation of the loss value during the model training process is reduced by 65%, and the stability of deep training is significantly improved. This fully demonstrates that the method of this invention has significant advantages in detection accuracy, detection efficiency and model training stability. It can effectively solve the problems of high false alarm rate, high false negative rate and unstable deep training in the prior art, and is suitable for the automated inspection needs of large-scale PCB production.

[0070] like Figure 2 The diagram shown is a functional block diagram of a high-precision PCB defect detection system based on Transformer structure optimization provided in an embodiment of the present invention.

[0071] In this embodiment, the functions of each module / unit are as follows: The spacing calculation module is used to calculate the radial topological spacing based on the original grayscale image of the PCB area under test; The association module is used to generate distance-grayscale association datasets based on radial topological spacing; The lookup table generation module is used to generate an equidistant rheological attribute set based on the distance-grayscale association dataset, and to generate a grayscale interval lookup table based on the equidistant rheological attribute set. The defect generation module is used to generate a binary distribution map of defects based on a gray-scale range lookup table. The rejection module is used to reject and sort multilayer PCB boards under test based on the defect binarization distribution map.

[0072] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A high-precision PCB defect detection method based on Transformer structure optimization, characterized in that, Includes the following steps: S1. Calculate the radial topological spacing based on the original grayscale image of the PCB area to be tested; S2. Generate a distance-grayscale correlation dataset based on radial topological spacing; S3. Generate an equidistant rheological attribute set based on the distance-grayscale association dataset, and generate a grayscale interval lookup table based on the equidistant rheological attribute set; S4. Generate a binary distribution map of defects based on a gray-scale interval lookup table; S5. Based on the defect binarization distribution map, the multilayer PCB board under test is sorted and rejected.

2. The high-precision PCB defect detection method based on the Transformer structure optimization according to claim 1, characterized in that, The radial topological spacing is calculated based on the original grayscale image of the PCB area under test, including: Locate the area of ​​the PCB to be tested in the multilayer PCB board; Obtain the original grayscale image of the PCB area to be tested; Edge detection is performed on the original grayscale image to obtain the physical contour boundaries of the embedded passive devices in the multilayer PCB board under test; The radial topological spacing is obtained by calculating the Euclidean distance between each pixel of the original grayscale image and the physical contour boundary.

3. The high-precision PCB defect detection method based on Transformer structure optimization according to claim 1, characterized in that, A distance-grayscale association dataset is generated based on radial topological spacing, including: Data pairs are constructed based on the radial topological spacing of pixels in the original grayscale image and the grayscale values ​​of pixels in the original grayscale image. All data pairs are aggregated to generate a distance-grayscale correlation dataset.

4. The high-precision PCB defect detection method based on Transformer structure optimization according to claim 1, characterized in that, An equidistant rheological attribute set is generated based on the distance-grayscale association dataset, including: Extracting unique radial topological spacing from a distance-grayscale association dataset; Using each unique radial topological spacing as the index key, retrieve all data pairs with the same radial topological spacing in the distance-grayscale association dataset; All data pairs with the same radial topological spacing are defined as the set of equidistant rheological properties.

5. The high-precision PCB defect detection method based on Transformer structure optimization according to claim 1, characterized in that, A grayscale range lookup table is generated based on an equidistant set of rheological properties, including: Statistical distribution calculation is performed on the gray values ​​in the equidistant rheological property set to obtain the gray values ​​of the lower quantile and the upper quantile. Arrange all unique radial topological spacings in ascending order of their numerical values ​​to obtain the distance index sequence; Define the gray value of the lower quantile as the compliant gray value lower limit; Define the grayscale value of the upper quantile as the compliant grayscale upper limit; Combine the lower limit of compliance grayscale and the upper limit of compliance grayscale to form the target grayscale range; Each radial topological spacing in the distance index sequence is bound to the corresponding target grayscale interval to generate a grayscale interval lookup table.

6. The high-precision PCB defect detection method based on Transformer structure optimization according to claim 1, characterized in that, A binary distribution map of defects is generated based on a gray-scale interval lookup table, including: Based on the radial topological spacing and gray-level lookup table corresponding to the pixels in the original gray-level image, abnormal attribute marking is performed on the pixels to obtain rheological photometric mismatch points. Construct an initial matrix based on the original grayscale image; The element values ​​of the initial matrix are assigned based on the rheological photometric mismatch point; The initial matrix after assignment is image-encapsulated to obtain a binary distribution map of defects.

7. The high-precision PCB defect detection method based on Transformer structure optimization according to claim 1, characterized in that, Based on the defect binarization distribution map, the PCB multilayer board under test is sorted and rejected, including: Connectivity analysis was performed on the binary distribution map of defects to obtain a set of abnormal patches; Determine the centroid coordinates of each abnormal patch in the abnormal patch set in the image coordinate system of the original grayscale image; The physical and mechanical coordinates of the PCB multilayer board under test are obtained by performing a spatial mapping transformation on the centroid coordinates. Sorting control commands are generated based on physical mechanical coordinates; The multilayer PCB boards to be tested are rejected and sorted according to the sorting control instructions.

8. The high-precision PCB defect detection method based on Transformer structure optimization according to claim 7, characterized in that, According to the sorting control instructions, the multilayer PCB boards to be tested are rejected and sorted, including: According to the sorting control command, the timing of the action of the rejection actuator of the PCB multilayer board under test is triggered; Eliminate the force applied to the multilayer PCB board by the actuator; The PCB multilayer board to be tested is separated from the original transport path of the production line and introduced into the defective product collection area.

9. A high-precision PCB defect detection system based on Transformer structure optimization, characterized in that, The system includes: The spacing calculation module is used to calculate the radial topological spacing based on the original grayscale image of the PCB area to be tested. The association module is used to generate distance-grayscale association datasets based on radial topological spacing; The lookup table generation module is used to generate an equidistant rheological attribute set based on the distance-grayscale association dataset, and to generate a grayscale interval lookup table based on the equidistant rheological attribute set. The defect generation module is used to generate a binary distribution map of defects based on a gray-scale range lookup table. The rejection module is used to reject and sort multilayer PCB boards under test based on the defect binarization distribution map.