PCBA component detection method and system based on spatial independence and scale perception

By introducing spatial independence and scale awareness methods into PCBA component inspection, dividing the inspection grid cells and determining a unique target scale, the problems of low inspection accuracy and inference efficiency of small-sized components are solved, and efficient PCBA component inspection is achieved.

CN121304689BActive Publication Date: 2026-03-03无锡宇宁科技集团股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511886036.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-15
Publication Date
2026-03-03
Estimated Expiration
2045-12-15

AI Technical Summary

Technical Problem

Existing technologies for PCBA component inspection suffer from low accuracy and inference efficiency for small-sized components, especially in multi-scale inspection calculations where it is difficult to effectively reduce redundant calculations and meet the throughput requirements of real-time industrial inspection.

Method used

A detection method based on spatial independence and scale awareness is adopted. By acquiring a set of multi-scale feature maps, a probability heatmap of small targets is generated. The PCBA image to be inspected is divided into detection grid cells. Based on the spatial independence constraint of the grid cells, a unique target scale is determined. Component classification and boundary regression are performed only at this scale, reducing redundant calculations at multiple scales.

Benefits of technology

It improves the detection rate of small-sized components and the positioning robustness of large components, reduces redundant calculations in multi-scale detection, meets the real-time detection needs of PCBA production lines, and improves overall detection accuracy and inference efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121304689B_ABST
    Figure CN121304689B_ABST
Patent Text Reader

Abstract

The application discloses a PCBA element detection method and system based on spatial independence and scale perception, wherein the method comprises the following steps: acquiring a to-be-detected PCBA image, inputting a feature extraction network, and obtaining a multi-scale feature map set containing a high-resolution feature map and a low-resolution feature map; generating a small target probability heat map based on the high-resolution feature map; dividing the to-be-detected PCBA image into a plurality of detection grid units; calculating a grid scale judgment value based on the small target probability heat map corresponding to the detection grid unit, and determining a unique target scale for the detection grid unit from the multi-scale feature map set according to the grid scale judgment value; performing element classification and boundary regression only on the corresponding region of the unique target scale to obtain the candidate detection result of the grid unit, and performing overlap suppression and merging processing after collecting the candidate detection results of all the grid units, and outputting the final element detection result. The technical scheme of the application improves the overall detection precision and reasoning efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic component testing technology, and in particular to a PCBA component testing method, system, computer equipment, and storage medium based on spatial independence and scale perception. Background Technology

[0002] In PCBA (Printed Circuit Board Assembly) automated optical inspection (AOI) scenarios, there are many types of components, a wide range of sizes, and a high proportion of small-sized components. The inspection results need to meet both the positioning accuracy of millimeter / submillimeter level components and the constraints of production line cycle time on inference speed and computing power consumption. In existing technologies, one-stage object detection methods based on deep learning (such as detection frameworks based on multi-scale feature pyramids) typically output multi-scale feature maps through a backbone network and a feature fusion network, and perform parallel predictions on the entire feature map on multiple scale detection heads. Finally, non-maximum suppression is used to remove duplicate candidate boxes at different scales. To improve the detection rate of small objects, existing methods often introduce higher resolution detection layers, attention enhancement, or improved loss functions to enhance the feature representation and regression capabilities of small objects.

[0003] However, in PCBA component inspection, which is characterized by non-overlapping spatial layout of components and relatively consistent target size in local areas, the above-mentioned general strategy often still repeatedly performs multi-scale inspection calculations on the same spatial location, and generates competitive predictions and cross-scale interference between inspection heads of different scales. This makes it difficult to effectively reduce redundant multi-scale inspection calculations and stably meet the throughput requirements of industrial real-time inspection while ensuring the inspection accuracy of small-sized components. Summary of the Invention

[0004] The purpose of this application is to propose a PCBA component detection method, system, computer device, and storage medium based on spatial independence and scale awareness, so as to solve the technical problems of low detection accuracy and inference efficiency of small-sized components.

[0005] To address the aforementioned technical problems, this application provides a PCBA component detection method based on spatial independence and scale awareness, employing the following technical solution:

[0006] The PCBA image to be inspected is acquired and input into the feature extraction network to obtain a multi-scale feature map set containing high-resolution and low-resolution feature maps.

[0007] A small target probability heatmap is generated based on the high-resolution feature map, and the small target probability heatmap is spatially aligned with the PCBA image to be inspected.

[0008] The PCBA image to be inspected is divided into multiple detection grid units, and the corresponding region of each detection grid unit in the multi-scale feature map set is established.

[0009] For each of the detection grid units, under the premise of satisfying the spatial independence constraint, the grid scale determination value is calculated based on the small target probability heatmap corresponding to the detection grid unit, and a unique target scale is determined for the detection grid unit from the multi-scale feature map set accordingly.

[0010] Component classification and boundary regression are performed only on the corresponding region of the unique target scale to obtain the candidate detection results of the grid cell. After aggregating the candidate detection results of each grid cell, overlap suppression and merging processing are performed to output the final component detection results.

[0011] To address the aforementioned technical problems, this application also provides a PCBA component inspection system based on spatial independence and scale awareness, employing the following technical solution:

[0012] The acquisition module is used to acquire the PCBA image to be inspected, input it into the feature extraction network, and obtain a multi-scale feature map set containing high-resolution feature maps and low-resolution feature maps.

[0013] A generation module is used to generate a small target probability heatmap based on the high-resolution feature map, wherein the small target probability heatmap is spatially aligned with the PCBA image to be inspected.

[0014] The segmentation module is used to divide the PCBA image to be inspected into multiple detection grid units and establish the corresponding region of each detection grid unit in the multi-scale feature map set.

[0015] The calculation module is used to calculate the grid scale determination value for each detection grid unit based on the small target probability heatmap corresponding to the detection grid unit, under the premise of satisfying the spatial independence constraint, and thereby determine a unique target scale for the detection grid unit from the multi-scale feature map set.

[0016] The output module is used to perform element classification and boundary regression only on the corresponding region of the unique target scale to obtain the candidate detection results of the grid cell, and after aggregating the candidate detection results of each grid cell, perform overlap suppression and merging processing to output the final element detection results.

[0017] To address the aforementioned technical problems, this application also provides a computer device that employs the following technical solution:

[0018] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the PCBA component detection method based on spatial independence and scale awareness as described above.

[0019] To address the aforementioned technical problems, this application also provides a computer-readable storage medium, employing the technical solution described below:

[0020] A computer-readable storage medium storing computer-readable instructions, which, when executed by a processor, implement the steps of the PCBA component detection method based on spatial independence and scale awareness as described above.

[0021] Compared with the prior art, the embodiments of this application have the following main advantages:

[0022] The PCBA component detection method disclosed in this application, based on spatial independence and scale awareness, introduces a small target probability heatmap on top of multi-scale feature maps and determines a unique target scale according to the detection grid unit. This allows small-sized components to be detected preferentially on high-resolution features, while medium- and large-sized components are detected on low-resolution features, thus balancing the detection rate of small components with the robustness of large component localization. Each grid unit performs classification and regression operations only at one scale, significantly reducing redundant calculations at the same spatial location across multiple scales, reducing cross-scale interference, improving overall detection accuracy and inference efficiency, and adapting to the real-time detection needs of PCBA production lines. Attached Figure Description

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

[0024] Figure 1 This is a flowchart of an embodiment of the PCBA component detection method based on spatial independence and scale awareness according to this application;

[0025] Figure 2 This is a schematic diagram of a structure of an embodiment of the PCBA component inspection system based on spatial independence and scale perception according to this application;

[0026] Figure 3 This is a schematic diagram of the structure of one embodiment of the computer device according to this application. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0028] refer to Figure 1 The diagram illustrates a flowchart of an embodiment of the PCBA component detection method based on spatial independence and scale awareness according to this application. The PCBA component detection method based on spatial independence and scale awareness includes the following steps:

[0029] Step S101: Obtain the PCBA image to be inspected, input it into the feature extraction network, and obtain a multi-scale feature map set containing high-resolution feature maps and low-resolution feature maps.

[0030] In this embodiment, the electronic device running on the PCBA component detection method based on spatial independence and scale awareness can send or receive data via wired or wireless connections. It should be noted that the aforementioned wireless connection methods may include, but are not limited to, 3G / 4G / 5G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra wideband) connections, and other currently known or future-developed wireless connection methods.

[0031] In this embodiment, the PCBA image to be inspected is first acquired. This image can be obtained by an AOI camera on the production line under fixed lighting conditions. The image contains the appearance areas of various mounted components to be inspected. The PCBA image can be preprocessed, such as distortion correction, brightness normalization, or noise suppression, before being fed into the feature extraction network. The feature extraction network is a deep neural network used to extract multi-level semantic information from the image. It can employ a detection network front-end containing a backbone network and a feature fusion structure. Its output is a set of multi-scale feature maps. High-resolution feature maps refer to feature maps with denser spatial sampling and a smaller downsampling factor compared to the original image (e.g., 1 / 8 scale of the original image). They retain more detailed textures and are suitable for characterizing small-sized components such as resistors, capacitors, and small-package ICs. Low-resolution feature maps refer to feature maps with a larger downsampling factor (e.g., 1 / 16 or 1 / 32 scale of the original image). They have stronger semantic information and a larger receptive field, making them suitable for characterizing medium-to-large-sized components such as connectors, large-package chips, and shielding covers. Thus, the multi-scale feature map set possesses both fine-grained spatial details and high-level semantic information, providing a foundation for the detection of components of different sizes.

[0032] Step S102: Generate a small target probability heatmap based on the high-resolution feature map, wherein the small target probability heatmap is spatially aligned with the PCBA image to be inspected.

[0033] In this embodiment, after obtaining a multi-scale feature map set, a small target probability heatmap is generated based on the high-resolution feature map. The small target probability heatmap is a two-dimensional probability distribution map spatially aligned with the PCBA image to be inspected. It characterizes the probability of small-sized components appearing at each spatial location. "Alignment" means that each location in the heatmap can be mapped to a corresponding pixel region in the PCBA image to be inspected. In implementation, a lightweight prediction branch can be introduced onto the high-resolution feature map, such as a heatmap generation network composed of several convolutional layers. This network performs position-by-position calculations on the high-resolution feature map and outputs a single-channel or multi-channel probability map. The output is then normalized to between 0 and 1 using a sigmoid function, thus increasing the heatmap value and indicating a higher likelihood that the location contains a small-sized component region. Taking a typical PCBA as an example, 0402 / 0603 resistors and capacitors typically appear as small, dense rectangular texture blocks in the image, and the heatmap shows a higher response in these areas. Around large chips or connectors, the heatmap response is relatively low, providing a basis for subsequent scale selection.

[0034] Step S103: Divide the PCBA image to be inspected into multiple detection grid units, and establish the corresponding region of each detection grid unit in the multi-scale feature map set.

[0035] In this embodiment, the PCBA image to be inspected is divided into multiple detection grid units, and the corresponding region of each detection grid unit in a multi-scale feature map set is established. Here, a detection grid unit is a spatial unit obtained by dividing the entire image according to a preset grid size. For example, the image is divided into blocks using a fixed pixel size or a fixed number of grids. Each grid unit covers a rectangular area in the image, serving as the smallest decision unit for subsequent detection and scale selection. The "corresponding region" refers to the feature region corresponding to the same grid unit on feature maps of different resolutions. The mapping relationship can be determined by the downsampling ratio. For example, when the high-resolution feature map is 1 / 8 scale relative to the original image, the pixel area covered by one grid unit in the original image can be mapped to a corresponding region on the high-resolution feature map; when the low-resolution feature map is 1 / 16 or 1 / 32 scale, its corresponding region can also be obtained proportionally. By establishing this mapping relationship, it is possible to ensure that after scale determination for the same grid unit, the region requiring detection calculation is accurately located on the feature map at the selected scale.

[0036] Step S104: For each detection grid unit, under the premise of satisfying the spatial independence constraint, calculate the grid scale determination value based on the small target probability heatmap corresponding to the detection grid unit, and determine a unique target scale for the detection grid unit from the multi-scale feature map set accordingly.

[0037] In this embodiment, after completing the mesh division and mapping, for each detection mesh unit, under the premise of satisfying the spatial independence constraint, the mesh scale determination value is calculated based on the small target probability heatmap corresponding to the mesh unit, and a unique target scale is determined from the multi-scale feature map set accordingly. Here, the spatial independence constraint is an engineering prior for PCBA component layout; that is, under common mounting rules, the physical space occupied by components does not overlap, and there is usually no situation where two components overlap and occupies the same position in the same area. Therefore, each mesh unit can be regarded as a relatively independent detection area, and the scale path selection is performed accordingly. The mesh scale determination value is used to quantify the degree of dominance of small-sized components within the mesh unit. It can be obtained from the statistical results of the corresponding area of ​​the small target probability heatmap for that mesh unit, such as calculating the average, maximum, or weighted average of the heatmap area. A larger determination value indicates that the mesh is more likely to be dominated by small-sized components. Based on this judgment value, scale selection rules can be set to match the process and image resolution. For example, when the judgment value exceeds a preset threshold, the unique target scale of the grid cell is determined as a high-resolution feature map to retain sufficient detail for the boundary localization of small components; when the judgment value does not exceed the preset threshold, the unique target scale is determined as a low-resolution feature map to utilize stronger semantics and a larger receptive field for robust detection of medium and large components. For instance, for a region with dense resistors and capacitors on a PCBA, the thermal statistics are usually high, and the unique target scale of this region will be determined as a high-resolution layer, thus avoiding missed detection of small components due to space compression on the low-resolution layer; while for regions containing connectors or large packaged chips, the thermal statistics are low, and the unique target scale of this region will be determined as a low-resolution layer, thereby reducing redundant calculations on the high-resolution layer and improving overall throughput.

[0038] Step S105: Perform element classification and boundary regression only on the corresponding region of the unique target scale to obtain the candidate detection results of the grid cell, and after aggregating the candidate detection results of each grid cell, perform overlap suppression and merging processing to output the final element detection results.

[0039] In this embodiment, after determining the unique target scale for each detection grid cell, component classification and boundary regression are performed only in the corresponding region of that unique target scale to obtain the candidate detection results for that grid cell. Component classification refers to determining the category of candidate targets, such as the confidence level of categories like output resistors, capacitors, integrated circuits, and connectors. Boundary regression refers to predicting the position and size parameters of the target in the image, such as the center coordinates, width, height, or corner coordinates of the output bounding box, enabling the location of the circumscribed rectangle of the component in the PCBA image to be inspected. Since each grid cell performs the above calculations only at one scale, other scales do not need to be predicted in parallel in the corresponding region of that grid cell, thereby reducing multi-scale repeated detection and mutual interference at the same spatial location. Subsequently, the candidate detection results obtained from all detection grid cells are aggregated, and overlap suppression and merging processing are performed to output the final component detection results. The overlap suppression and merging process employs methods such as non-maximum suppression to filter and retain candidate boxes that are spatially highly overlapping and of the same category, avoiding duplicate output. Simultaneously, for candidate boxes of the same element that cross grid boundaries, the optimal box can be merged or retained based on the degree of overlap and confidence level, ensuring that the final output element detection results are consistent across the entire image and can be used for subsequent AOI judgment and positioning alignment. Through this process, a detection mechanism that assigns a unique detection scale per grid cell is implemented, based on the premise of using heatmaps for scale awareness. This allows small-sized elements to receive high-resolution detail support first, while non-small-sized elements are detected at low-resolution layers. This reduces redundant computation in multi-scale detection while maintaining detection accuracy and meeting the speed and stability requirements of industrial scenarios.

[0040] This application introduces a small target probability heatmap based on multi-scale feature maps and determines a unique target scale according to the detection grid unit. This allows small-sized components to be detected preferentially on high-resolution features, while medium- and large-sized components are detected on low-resolution features, thus balancing the detection rate of small components with the robustness of large component localization. Each grid unit performs classification and regression operations only at one scale, significantly reducing redundant calculations at the same spatial location across multiple scales, reducing cross-scale interference, improving overall detection accuracy and inference efficiency, and adapting to the real-time detection needs of PCBA production lines.

[0041] In some optional implementations of this embodiment, after the steps of dividing the PCBA image to be inspected into multiple detection grid units and establishing the corresponding region of each detection grid unit in the multi-scale feature map set, the method further includes:

[0042] The scale prior rule is obtained based on the bounding box size statistics of the labeled elements in the training samples. The scale prior rule divides the element size into at least a small size interval and a non-small size interval, and associates them with the high-resolution feature map and the low-resolution feature map respectively.

[0043] When determining the unique target scale, the scale prior rule and the grid scale determination value are used as input to output the unique target scale of the detection grid cell.

[0044] In this embodiment, the scale prior rule can be statistically obtained from the bounding box dimensions of labeled elements in the training samples. For example, the area or shorter side length of the bounding box can be used as the size measure. Elements whose size falls within a preset small size range are considered "small-sized elements," and the remaining elements are considered "non-small-sized elements." Correlation relationships are established with high-resolution feature maps and low-resolution feature maps, respectively. When actually determining the unique target scale of a detection grid cell, not only is the grid scale determination value obtained based on the small target probability heatmap of the grid cell used, but the above-mentioned scale prior rule is also used as a common input: for example, when the grid scale determination value shows that the grid may be dominated by small-sized elements and the scale prior indicates that the proportion of small-sized elements in the plate type is relatively high, the high-resolution feature map is output as the unique target scale; when the grid scale determination value is low and the scale prior indicates that the region is more likely to have non-small-sized elements, the low-resolution feature map is output as the unique target scale. Taking a PCBA containing a large number of 0402 resistors and capacitors and a small number of large connectors as an example, when the dense grid of resistors and capacitors has a large heat map statistical value and the prior supports small size dominance, it will be stably routed to a high-resolution feature map, thereby improving the positioning accuracy of small components. On the other hand, when the grid where the connectors are located supports non-small size dominance in the prior, it tends to be routed to a low-resolution feature map to obtain a larger receptive field and reduce high-resolution redundant calculations.

[0045] This application constructs scale prior rules by utilizing the size statistics of labeled elements in training samples, and jointly performs scale selection with grid scale determination values. This allows scale routing decisions to no longer solely rely on the current image response, but rather combine the adaptation relationships of different sized elements at various scales in historical data. This maintains consistency and interpretability in scale selection under different plate types and operating conditions, reduces the impact of occasional noise on single-frame decisions, and enables small and non-small elements to be routed more stably to their respective suitable feature scales, further improving detection robustness.

[0046] In some optional implementations of this embodiment, the step of calculating a grid scale determination value based on the small target probability heatmap corresponding to the detection grid unit, under the premise of satisfying spatial independence constraints, and determining a unique target scale for the detection grid unit from the multi-scale feature map set accordingly, includes:

[0047] For each detection grid unit, the mean value and the number of peaks of the probability heatmap region corresponding to the small target are calculated. The number of peaks is used to characterize the density of small target response within the detection grid unit.

[0048] The grid scale determination value is generated by combining the mean value of the region with the number of peak values ​​according to a preset combination rule.

[0049] In this embodiment, to ensure that the grid scale determination value reflects not only the "intensity of small targets" but also the "density of small target responses," the regional mean and the number of peaks are calculated for the heatmap region corresponding to each detection grid unit. The regional mean is used to characterize the overall small target probability level of the grid, and the number of peaks is used to characterize the number of "hot spots" with high local responses within the grid. Peaks can be defined as local maxima; for example, a point in the heatmap region that satisfies the condition that "its value is greater than its surrounding neighborhood and exceeds the peak threshold" is counted as a peak. Subsequently, the regional mean and the number of peaks are combined according to a preset combination rule to generate the grid scale determination value, such as using weighted summation, piecewise mapping, or determining the number of peaks first and then correcting the mean. This makes grids with "high mean and moderate number of peaks" more consistent with the situation dominated by a single or a few small elements, while grids with "high mean but too many peaks" are more likely to correspond to dense small element regions or texture noise regions. Taking a row of parallel-mounted resistor arrays as an example, its thermal map area may have multiple discrete hot spots, with the number of peaks being significantly higher than that of ordinary grids. In this case, the grid scale judgment value can be designed to maintain a preference for high-resolution detection, while providing a "density" basis for subsequent spatial independence consistency judgment, thereby reducing the risk of mistaking dense areas for single component areas.

[0050] This application calculates both the regional mean and the number of peaks for the small target probability heatmap region of each detection grid, incorporating both the overall small target response intensity and the local response density into the grid scale determination value. This allows the scale determination to identify both regions dominated by a single or a small number of small elements and regions with dense small elements or texture interference. This more accurately distinguishes regions with different spatial distribution characteristics, avoiding misclassification of noise or texture as regions dominated by small elements, thus improving the accuracy of scale selection and reducing the risk of false detections and false negatives in dense areas.

[0051] In some optional implementations of this embodiment, the step of calculating a grid scale determination value based on the small target probability heatmap corresponding to the detection grid unit, under the premise of satisfying spatial independence constraints, and determining a unique target scale for the detection grid unit from the multi-scale feature map set accordingly, further includes:

[0052] An entry threshold and an exit threshold are set for the grid scale determination value, and a hysteresis update is performed on the unique target scale based on the entry threshold and the exit threshold;

[0053] After the delayed update, a freeze window constraint is applied to the unique target scale so that the same detection grid cell maintains the unique target scale unchanged in multiple consecutive detection frames.

[0054] In this embodiment, to improve the stability of grid scale selection during continuous detection, hysteresis and frozen window constraints can be introduced during the process of determining a unique target scale for each detection grid cell. Hysteresis updates are implemented by setting entry and exit thresholds. The entry threshold triggers a switch from a low-resolution feature map to a high-resolution feature map, and the exit threshold triggers a switch from a high-resolution feature map back to a low-resolution feature map. The entry and exit thresholds are set to different values ​​to avoid back-and-forth jitter in the critical region. The frozen window constraint is used to maintain the unique target scale of the detection grid cell unchanged for multiple consecutive detection frames after a scale switch is completed. Here, "detection frame" can correspond to multiple frames of images continuously acquired on the production line, such as adjacent images of the same PCBA being captured by a camera at a fixed frequency during the movement of the conveyor belt, or continuous exposure images of the same area under different light sources / angles. Taking a grid located at the transition boundary between small components and large chips as an example, due to reflection and texture changes, the thermal statistics fluctuate around the threshold. Hysteresis and frozen windows can prevent the grid from frequently switching between the two scales, thereby reducing both redundant calculations and missed detections and false detections caused by scale fluctuations.

[0055] This application avoids frequent switching between two scales in continuous detection by setting entry and exit thresholds for the grid scale determination value and employing hysteresis updates, combined with a frozen window constraint. This mechanism keeps the unique target scale stable within a certain time window, which helps suppress scale jitter caused by boundary conditions, small noise, and illumination fluctuations, thereby improving the continuity and reliability of the detection results in the time dimension, while reducing the additional computational overhead caused by frequent switching.

[0056] In some optional implementations of this embodiment, the steps of performing element classification and boundary regression only on the corresponding region of the unique target scale to obtain the candidate detection results of the grid cell, and then performing overlap suppression and merging processing after aggregating the candidate detection results of each grid cell to output the final element detection results, further include:

[0057] A binary gated mask is generated based on the unique target scale for the multi-scale feature map set, and the binary gated mask is applied to the input features of the detection head at each scale.

[0058] Component classification and boundary regression calculations are performed only on the corresponding regions indicated as valid by the binary gated mask, while the component classification and boundary regression calculations are skipped for the corresponding regions not indicated as valid.

[0059] In this embodiment, to fulfill the computational constraint of "performing element classification and boundary regression only in the region corresponding to the unique target scale" and further reduce redundant computations at non-selected scales, a binary gated mask for a multi-scale feature map set can be generated based on the unique target scale. This binary gated mask is then applied to the input features of the detection head at each scale. The binary gated mask can be generated according to the corresponding region of the detection grid cell on the feature map at each scale. For the scale determined as the unique target scale, its corresponding region is marked as valid, while the corresponding regions at other scales are marked as invalid. When performing element classification and boundary regression, the detection head only performs convolution / prediction calculations on the valid regions. For invalid regions, "computational clipping" is achieved by masking, skipping calculations, or outputting empty results. For example, when a grid is routed to a high-resolution feature map, the corresponding region of that grid on the low-resolution feature map is set as invalid in the gated mask. The low-resolution detection head no longer performs classification and regression calculations on that region, thereby avoiding repeated predictions of the same spatial location at different scales and reducing the generation of cross-scale competing boxes.

[0060] This application generates a binary gated mask based on a unique target scale and applies it to a multi-scale feature map set. This allows the detection head to perform classification and regression only within the selected scale and corresponding region, skipping detection computation for unselected scale regions. This gating mechanism structurally implements the computational constraint of a unique path at the grid level, significantly reducing the computational load of the multi-scale detection head on redundant regions, lowering memory and computing power consumption, and reducing repeated predictions of the same spatial location at different scales. This helps improve the model's real-time performance and the consistency of prediction results.

[0061] In some optional implementations of this embodiment, before the steps of performing element classification and boundary regression only on the corresponding region of the unique target scale to obtain the candidate detection results of the grid cell, and then performing overlap suppression and merging processing after aggregating the candidate detection results of each grid cell to output the final element detection results, the method further includes:

[0062] Based on the number of peak values ​​and the candidate detection results, a spatial independence consistency determination is performed on each detection grid unit. The spatial independence consistency determination includes at least one of the following conflict determination conditions:

[0063] Within the same detection grid cell, the number of candidate boxes for the candidate detection results is greater than a first quantity threshold;

[0064] Between adjacent detection grid cells, the intersection-union ratio of candidate boxes belonging to two adjacent grid cells is greater than the first overlap threshold;

[0065] For candidate box pairs that satisfy the first overlap threshold, the absolute value of their classification confidence difference is less than the first difference threshold.

[0066] When the conflict determination condition is met, the target detection grid cell that triggers the conflict is identified, and the unique target scale of the target detection grid cell is switched to the alternative scale. The element classification and boundary regression are re-executed only for the target detection grid cell in the corresponding region of the alternative scale to update the candidate detection results of the target detection grid cell.

[0067] In this embodiment, to ensure the reliability of grid-level unique path detection based on spatial independence constraints in complex regions, a spatial independence consistency determination can be added before aggregating candidate detection results from each grid cell and performing overlap suppression and merging processing. This determination, along with the peak count and candidate detection results, is used for conflict detection. The spatial independence consistency determination can include at least one of the following verifiable conflict determination conditions: First, within the same detection grid cell, the number of candidate boxes in the candidate detection results is greater than a first quantity threshold, used to identify multiple competing candidates within a single grid cell; Second, between adjacent detection grid cells, the intersection-union ratio of candidate boxes belonging to two adjacent grid cells is greater than a first overlap threshold, used to identify repeated predictions across grid boundaries; Third, for candidate box pairs that satisfy the first overlap threshold, the absolute value of their classification confidence difference is less than a first difference threshold, used to identify uncertain situations where "two candidates are equally credible but conflict with each other." When the conflict determination condition is met, the target detection grid cell that triggered the conflict is identified, and the unique target scale of that target detection grid cell is switched to a candidate scale. Component classification and boundary regression are then re-executed only for the corresponding region of that target detection grid cell at the candidate scale to update the candidate detection results of that grid. Taking a small packaged IC located at the grid boundary as an example, the initial detection may output highly overlapping candidate boxes with similar confidence levels in two adjacent grids. After triggering the intersection-union ratio and confidence difference threshold conditions, one of the grids can be switched to a more suitable candidate scale for local re-inspection, thereby outputting more consistent location boxes and reducing the uncertainty during subsequent merging.

[0068] This application introduces a spatial independence consistency determination method, utilizing factors such as the number of candidate frames, the overlap relationship between adjacent candidate frames, and the confidence difference to perform conflict detection on the detection grid. This method can automatically identify anomalies that are inconsistent with the spatial independence of PCBA components. The target detection grid that triggers the conflict is switched to an alternative scale for local re-inspection. This automatically corrects the initial detection results in component boundary areas, densely packed areas, or complex reflective areas, reducing the probability of duplicate and missed detections and improving the reliability and consistency of the overall detection results.

[0069] In some optional implementations of this embodiment, before the step of switching the unique target scale of the target detection grid cell to an alternative scale, the method further includes:

[0070] The target detection grid unit is subdivided into multiple sub-grid units, and the corresponding region of each sub-grid unit in the multi-scale feature map set is established;

[0071] For each of the sub-grid cells, the grid scale determination value is calculated and the unique target scale is determined. The element classification and boundary regression are re-executed only in the region corresponding to the unique target scale of each sub-grid cell, instead of re-examining the alternative scales of the target detection grid cell.

[0072] In this embodiment, to further improve the spatial resolution capability of conflict areas, before switching the unique target scale of the target detection grid unit to the alternative scale, the target detection grid unit can be further subdivided into multiple sub-grid units, and the corresponding region of each sub-grid unit in the multi-scale feature map set can be established. Subsequently, the grid scale determination value is calculated for each sub-grid unit and the unique target scale is determined for each. Component classification and boundary regression are re-executed only in the region corresponding to the unique target scale of each sub-grid unit, thereby replacing the alternative scale of the original target detection grid unit with a finer-grained spatial unit for re-inspection. Taking a densely packed resistor and capacitor region as an example, a single large grid may trigger a conflict due to the large number of peaks. Directly switching the alternative scale may still fail to clearly separate adjacent components. After subdividing the grid into multiple sub-grids, the heat map statistics and scale selection corresponding to each sub-grid are closer to the actual local layout, allowing the sub-grids to be routed to a more suitable scale for detection, thereby improving the separation and localization consistency of dense areas without expanding the re-inspection range.

[0073] This application refines the scale selection and detection granularity of conflict areas from a single grid to the sub-grid level by subdividing the grid into multiple sub-grids before switching to alternative scales. This subdivision mechanism can improve spatial resolution and scale adaptability in local areas, and is particularly suitable for densely populated small component areas and complex boundary areas. While limiting the additional computational range, it further improves the separation and positioning accuracy of local detection, thereby improving the overall PCBA component detection quality.

[0074] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).

[0075] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0076] Further reference Figure 2 As a response to the above Figure 1 To implement the method shown, this application provides an embodiment of a PCBA component inspection system based on spatial independence and scale awareness. This system embodiment is similar to... Figure 1 Corresponding to the method embodiments shown, the system can be specifically applied to various electronic devices.

[0077] like Figure 2 As shown, the PCBA component inspection system 200 based on spatial independence and scale awareness described in this embodiment includes: an acquisition module 201, a generation module 202, a partitioning module 203, a calculation module 204, and an output module 205. Wherein:

[0078] The acquisition module 201 is used to acquire the PCBA image to be inspected, input it into the feature extraction network, and obtain a multi-scale feature map set containing high-resolution feature maps and low-resolution feature maps.

[0079] The generation module 202 is used to generate a small target probability heatmap based on the high-resolution feature map, wherein the small target probability heatmap is spatially aligned with the PCBA image to be inspected.

[0080] The segmentation module 203 is used to divide the PCBA image to be inspected into multiple detection grid units and establish the corresponding region of each detection grid unit in the multi-scale feature map set;

[0081] The calculation module 204 is used to calculate the grid scale determination value for each detection grid unit based on the small target probability heatmap corresponding to the detection grid unit, under the premise of satisfying the spatial independence constraint, and thereby determine a unique target scale for the detection grid unit from the multi-scale feature map set.

[0082] The output module 205 is used to perform element classification and boundary regression only on the corresponding region of the unique target scale to obtain the candidate detection results of the grid cell, and after aggregating the candidate detection results of each grid cell, perform overlap suppression and merging processing to output the final element detection results.

[0083] The PCBA component detection system based on spatial independence and scale awareness provided in this embodiment of the invention can realize all the processes of the PCBA component detection method based on spatial independence and scale awareness in the above embodiments. The functions and technical effects of each module in the device are the same as those of the PCBA component detection method based on spatial independence and scale awareness in the above embodiments, and will not be repeated here.

[0084] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 3 , Figure 3 This is a basic structural block diagram of the computer device in this embodiment.

[0085] The computer device 3 includes a memory 31, a processor 32, and a network interface 33 that are interconnected via a system bus. It should be noted that only the computer device 3 with components 31-33 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0086] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.

[0087] The memory 31 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 31 may be an internal storage unit of the computer device 3, such as the hard disk or memory of the computer device 3. In other embodiments, the memory 31 may also be an external storage device of the computer device 3, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 3. Of course, the memory 31 may also include both the internal storage unit and its external storage device of the computer device 3. In this embodiment, the memory 31 is typically used to store the operating system and various application software installed on the computer device 3, such as computer-readable instructions for PCBA component inspection methods based on spatial independence and scale awareness. In addition, the memory 31 can also be used to temporarily store various types of data that have been output or will be output.

[0088] In some embodiments, the processor 32 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. The processor 32 is typically used to control the overall operation of the computer device 3. In this embodiment, the processor 32 is used to execute computer-readable instructions stored in the memory 31 or to process data, for example, to execute the computer-readable instructions of the PCBA component detection method based on spatial independence and scale awareness.

[0089] The network interface 33 may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device 3 and other electronic devices.

[0090] This application also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the PCBA component detection method based on spatial independence and scale awareness as described above.

[0091] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0092] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for detecting PCBA components based on spatial independence and scale perception, characterized in that, The method comprises the following steps: obtaining a to-be-detected PCBA image, inputting a feature extraction network, and obtaining a multi-scale feature map set comprising a high-resolution feature map and a low-resolution feature map; generating a small target probability heat map based on the high-resolution feature map, wherein the small target probability heat map is spatially aligned with the to-be-detected PCBA image; dividing the to-be-detected PCBA image into a plurality of detection grid units and establishing corresponding regions of the detection grid units in the multi-scale feature map set; obtaining a scale prior rule based on the size statistics of the bounding boxes of the labeled elements in the training samples, wherein the scale prior rule at least divides the element size into a small size interval and a non-small size interval, and respectively associates the high-resolution feature map and the low-resolution feature map; when determining the unique target scale, the scale prior rule and the grid scale judgment value are jointly input to output the unique target scale of the detection grid unit; for each detection grid unit, based on the small target probability heat map corresponding to the detection grid unit, a grid scale judgment value is calculated under the premise of satisfying the spatial independence constraint, and the unique target scale of the detection grid unit is determined from the multi-scale feature map set according to the grid scale judgment value, specifically comprising: calculating the regional mean value and the peak value number of the small target probability heat map region corresponding to each detection grid unit, wherein the peak value number is used to represent the small target response density in the detection grid unit; the regional mean value and the peak value number are combined according to a preset combination rule to generate the grid scale judgment value; the entering threshold and the exiting threshold are set for the grid scale judgment value, and the hysteresis update is performed on the unique target scale based on the entering threshold and the exiting threshold; after hysteresis update, a freezing window constraint is applied to the unique target scale, so that the unique target scale of the same detection grid unit remains unchanged in a plurality of continuous detection frames; only in the corresponding region of the unique target scale, element classification and boundary regression are performed to obtain the candidate detection result of the grid unit, and after collecting the candidate detection results of each grid unit, overlap suppression and merging processing are performed to output the final element detection result.

2. The method of claim 1, wherein, In the step of only performing element classification and boundary regression on the corresponding region of the unique target scale to obtain the candidate detection result of the grid unit, and after collecting the candidate detection results of each grid unit, performing overlap suppression and merging processing to output the final element detection result, the step further comprises: generating a binary gating mask for the multi-scale feature map set based on the unique target scale, and applying the binary gating mask to the detection head input features of each scale; only for the corresponding region indicated as valid by the binary gating mask, element classification and boundary regression calculation are performed, and the element classification and boundary regression calculation is skipped for the corresponding region not indicated as valid.

3. The method of claim 1, wherein the method is based on spatial independence and scale perception of PCBA components. Before the step of only performing element classification and boundary regression on the corresponding region of the unique target scale to obtain the candidate detection result of the grid unit, and after collecting the candidate detection results of each grid unit, performing overlap suppression and merging processing to output the final element detection result, the step further comprises: performing a spatial independence consistency determination on each detection grid cell based on the peak number and the candidate detection result, the spatial independence consistency determination including at least any one of the following conflict determination conditions: in the same detection grid cell, the number of candidate boxes of the candidate detection result is greater than a first quantity threshold; between adjacent detection grid cells, the intersection over union of candidate boxes respectively belonging to two adjacent grid cells is greater than a first overlap threshold; for a candidate box pair satisfying the first overlap threshold, the absolute value of the difference in classification confidence is less than a first difference threshold; when the conflict determination condition is met, determining a target detection grid cell triggering a conflict, switching the unique target scale of the target detection grid cell to an alternative scale, and re-executing the element classification and boundary regression in the corresponding area of the alternative scale only for the target detection grid cell to update the candidate detection result of the target detection grid cell.

4. The method of claim 3, wherein the method is based on spatial independence and scale perception of PCBA components. Before the step of switching the unique target scale of the target detection grid cell to an alternative scale, the system further includes: subdividing the target detection grid cell into a plurality of sub-grid cells and establishing the corresponding area of each sub-grid cell in the multi-scale feature map set; calculating the grid scale determination value for each sub-grid cell and determining the unique target scale for each sub-grid cell, and re-executing the element classification and boundary regression only in the corresponding area of the unique target scale of each sub-grid cell to replace the re-inspection of the alternative scale of the target detection grid cell.

5. A PCBA component detection system based on spatial independence and scale perception, characterized in that, comprising: an acquisition module configured to acquire a to-be-detected PCBA image, input a feature extraction network, and obtain a multi-scale feature map set including a high-resolution feature map and a low-resolution feature map; a generation module configured to generate a small target probability heat map based on the high-resolution feature map, the small target probability heat map being spatially aligned with the to-be-detected PCBA image; a division module configured to divide the to-be-detected PCBA image into a plurality of detection grid cells and establish the corresponding area of each detection grid cell in the multi-scale feature map set; a calculation module configured to, for each detection grid cell, calculate a grid scale determination value based on the small target probability heat map corresponding to the detection grid cell under the premise of satisfying a spatial independence constraint, and determine a unique target scale for the detection grid cell from the multi-scale feature map set based on the grid scale determination value; an output module configured to perform element classification and boundary regression only on the corresponding area of the unique target scale to obtain the candidate detection result of the grid cell, and perform overlap suppression and merging processing after collecting the candidate detection results of all grid cells to output a final element detection result; the system is further configured to: obtain a scale prior rule based on the size statistics of the bounding boxes of the labeled elements in the training samples, the scale prior rule at least dividing the element size into a small size interval and a non-small size interval, and respectively associating the high-resolution feature map and the low-resolution feature map; The scale prior rule is taken as an input together with the grid scale decision value to output the unique target scale of the detection grid cell when the unique target scale is determined; The number of peak values is calculated for the region mean value of the small target probability heat map region corresponding to each detection grid cell, and the number of peak values is used to represent the small target response density in the detection grid cell; The region mean value and the number of peak values are taken as inputs to generate the grid scale decision value according to a preset combination rule; The grid scale decision value is set with an entry threshold value and an exit threshold value, and the unique target scale is executed with a hysteresis update based on the entry threshold value and the exit threshold value; After the hysteresis update, a freezing window constraint is applied to the unique target scale, so that the unique target scale remains unchanged in a plurality of continuous detection frames for the same detection grid cell.

6. A computer device, comprising: The memory stores computer readable instructions, and the processor executes the computer readable instructions to realize the steps of the PCBA element detection method based on spatial independence and scale perception according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer readable instructions, and the processor executes the computer readable instructions to realize the steps of the PCBA element detection method based on spatial independence and scale perception according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Small target detection method based on scale perception label distribution and context enhancement

    CN120147802A

  • Text detection model training method and apparatus, text region determination method and apparatus, and text content determination method and apparatus

    WO2020221298A1