PCB circuit board defect detection method, device, equipment and storage medium
Through the multi-light source synchronous imaging model and multi-scale dynamic defect detection model, the problem of high dependence of PCB circuit board detection on light is solved, higher detection accuracy and environmental adaptability are achieved, and the ability to identify complex defects is improved.
Patent Information
- Application Number
- CN202411652034.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-11-19
AI Technical Summary
In the existing technology, PCB circuit board defect detection is highly dependent on light, and the detection results are significantly affected by the environment, resulting in reduced defect recognition accuracy.
A multi-light source synchronous imaging model and a multi-scale dynamic defect detection model are adopted. Through multi-light source fusion image optimization processing and feature extraction, combined with illumination balanced convolutional neural network and multi-scale temporal convolutional network, the environmental adaptability and accuracy of the detection system are improved.
It effectively reduces the effects of shadows and reflections under single light source imaging conditions, improves image clarity and detail richness, and significantly enhances the overall accuracy and reliability of PCB circuit board defect detection.
Smart Images

Figure CN119379662B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a PCB circuit board defect detection method, device, equipment and storage medium. Background Art
[0002] PCBs are key components in electronic products, and their quality directly impacts their performance and lifespan. However, during the PCB production process, due to various factors, such as improper operation or workmanship, defects such as poor solder joints, broken wires, corrosion, and oxidation may occur. If these issues are not discovered and corrected promptly, they can severely impact the reliability of electronic products.
[0003] One existing technique uses the YOLOv4 object detection algorithm and a Mylar image dataset to develop a Mylar recognition model to detect Mylar components on circuit board surfaces. This model then identifies defects by analyzing the Mylar's position, area, and internal features. This method utilizes single-light imaging and two-dimensional inspection, focusing primarily on visible defects on the circuit board surface. This approach can significantly improve the automation level of defect detection.
[0004] However, existing technologies are highly dependent on lighting, and detection results are significantly affected by the environment. Specifically, under single-light imaging conditions, the circuit board surface is prone to shadows, reflections, and unclear local details, resulting in reduced defect recognition accuracy. Summary of the Invention
[0005] The present invention provides a PCB circuit board defect detection method, device, equipment and storage medium to improve the environmental adaptability and detection accuracy of the detection system and enhance the ability to identify complex defects.
[0006] In a first aspect, in order to solve the above technical problems, the present invention provides a PCB circuit board defect detection method, comprising:
[0007] Obtain PCB circuit board image data;
[0008] Inputting the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fusion image;
[0009] Performing image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image;
[0010] Performing region division and feature extraction operations on the denoised grayscale image to obtain features of each region;
[0011] The features of each region are input into a pre-trained multi-scale dynamic defect detection model to obtain the PCB defect detection situation.
[0012] In an optional embodiment, the training process of the multi-light source synchronous imaging model includes:
[0013] Building a light-balancing convolutional neural network model based on the brightness distribution, reflection intensity, and edge detail features of the circuit board at different lighting angles, and training the light-balancing convolutional neural network model;
[0014] When the number of training times is greater than or equal to the preset maximum number of training times, or when the loss function value of the illumination balance convolutional neural network model is less than the preset loss threshold, the training is determined to be completed, and the trained illumination balance convolutional neural network model is used as a multi-light source synchronous imaging model.
[0015] In an optional embodiment, the training process of the multi-scale dynamic defect detection model includes:
[0016] Building a multi-scale temporal convolutional network model based on texture changes, edge curvature, area ratio of circuit board defects and morphological characteristics of defects at different scales, and training the multi-scale temporal convolutional network model;
[0017] When the number of training times is greater than or equal to the preset maximum number of training times, or when the loss function value of the multi-scale time convolutional network model is less than the preset loss threshold, the training is determined to be completed, and the trained multi-scale time convolutional network model is used as a multi-scale dynamic defect detection model.
[0018] In an optional embodiment, inputting the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fusion image includes:
[0019] Perform light source calibration and intensity calibration operations according to the PCB circuit board image data to obtain multi-light source intensity adjustment parameters;
[0020] Performing a light source adjustment operation on the PCB circuit board image data according to the multi-light source intensity adjustment parameter to obtain imaging data under multiple light sources;
[0021] An image fusion operation is performed based on the imaging data under the multiple light sources to obtain a multi-light source fused image.
[0022] In an optional embodiment, performing light source calibration and intensity calibration operations according to the PCB circuit board image data to obtain multiple light source intensity adjustment parameters includes:
[0023] The light intensity value of each pixel is obtained by the following formula:
[0024]
[0025] in is the pixel position The light intensity value at is the initial intensity of each light source, is the light intensity attenuation coefficient, It is light source to pixel position distance,
[0026]
[0027] in is the position of the i-th light source on the horizontal axis, is the position of the i-th light source on the ordinate, is the position of the i-th light source in the depth direction;
[0028] The multi-light source intensity adjustment parameter for each pixel is obtained by the following formula:
[0029]
[0030] in Indicates the Multi-light source intensity adjustment parameters for each pixel, is the preset uniform light intensity value, is the pixel position the brightness value of the pixel, is the initial intensity of the light source, is the attenuation coefficient, From the pixel To The distance of the light source, Yes all N light source at pixel location The total light intensity value on .
[0031] In an optional embodiment, inputting the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection status includes:
[0032] The similarity between the regional features and the defect features in the database is obtained by the following formula:
[0033]
[0034] in, The regional features and the defect features in the database The similarity of is the dimension of the feature vector, is the first feature vector of the current region elements, is the first defect feature vector in the database elements;
[0035] When the similarity is greater than a preset threshold value of any type of defect, it is determined to be a defect of that type;
[0036] The dynamic development trend evaluation value of defects is obtained through the following formula:
[0037]
[0038] in, is the evaluation value of the dynamic development trend of defects, Indicates at a point in time The potential risks and impacts of defects, Indicates at a point in time The potential risks and impacts of time defects, is the time interval, For time point The defect development trend function, Indicates the past Defect development trends over time, is the weight coefficient of each indicator for the evaluation value of the dynamic development trend of defects; the PCB defect detection status is obtained according to the evaluation value of the dynamic development trend of defects.
[0039] In an optional implementation manner, obtaining the PCB defect detection status according to the defect dynamic development trend evaluation value includes:
[0040] When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be slightly defective;
[0041] When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be moderately defective;
[0042] When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be seriously defective;
[0043] in, 、 They are the preset defect assessment low threshold and defect assessment medium threshold respectively.
[0044] In a second aspect, the present invention provides a PCB circuit board defect detection device, comprising:
[0045] A data acquisition module is used to acquire PCB circuit board image data;
[0046] A multi-light source imaging module is used to input the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fused image;
[0047] An image optimization module is used to perform image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image;
[0048] A feature extraction module is used to perform region division and feature extraction operations based on the denoised grayscale image to obtain features of each region;
[0049] The defect detection module is used to input the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain the PCB defect detection status.
[0050] In a third aspect, the present invention also provides an electronic device comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements any one of the above-mentioned PCB circuit board defect detection methods when executing the computer program.
[0051] In a fourth aspect, the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned PCB circuit board defect detection methods.
[0052] Compared with the existing technology, the present invention has the following beneficial effects: by adopting a multi-light source synchronous imaging model, the effects of shadows, reflections, etc. under single light source imaging conditions are effectively reduced, thereby obtaining a clearer and more detailed image. This model uses an illumination-balanced convolutional neural network to model illumination at different angles, and obtains the optimal multi-light source fusion image through training. Subsequently, the fused image is optimized, such as by noise reduction, to improve the accuracy of subsequent feature extraction. Finally, the processed image is input into a multi-scale dynamic defect detection model, and accurate classification is performed based on the changing characteristics of different defects in terms of texture, edge curvature, etc. This technical solution not only reduces the detection error caused by lighting conditions, but also improves the ability to identify subtle defects through multi-scale analysis, thereby significantly improving the overall accuracy and reliability of PCB circuit board defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 This is a flow chart of a PCB circuit board defect detection method provided by the first embodiment of the present invention;
[0054] Figure 2It is a structural schematic diagram of a PCB circuit board defect detection device provided by the second embodiment of the present invention. DETAILED DESCRIPTION
[0055] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0056] Reference Figure 1 The first embodiment of the present invention provides a PCB circuit board defect detection method, comprising the following steps:
[0057] S11, obtaining PCB circuit board image data;
[0058] S12, inputting the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fused image;
[0059] S13, performing image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image;
[0060] S14, performing region division and feature extraction operations based on the denoised grayscale image to obtain features of each region;
[0061] S15: Input the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection status.
[0062] In step S11, acquiring PCB image data is fundamental to accurate defect detection. Image data is more than just a simple image of the PCB surface; it contains multi-layered, multi-dimensional information that reflects the structure and potential defects of each component. Specifically, image data primarily includes the following aspects: resolution, grayscale values, color information, contrast, and signal-to-noise ratio. To ensure that this image data accurately reflects the actual condition of the PCB, the image acquisition process requires careful attention to imaging device parameter settings, the influence of the external lighting environment, and the stability of data storage.
[0063] First, resolution is a key performance indicator for image data. Defects on PCBs can be extremely subtle, such as tiny cracks, pinholes, and poor solder joints. High-resolution images can capture these details in greater detail. In practical applications, image resolution should match the size of the smallest defect on the PCB to ensure that the image does not blur or distort when magnified. Grayscale and color information are also crucial. Grayscale represents the brightness of different areas in an image, while color information, including data in RGB or other color spaces, helps distinguish the reflective properties of different materials on the PCB. PCBs typically consist of a variety of materials, such as metal and fiberglass, and each material exhibits significant variations in light. Accurately recording color and grayscale allows for more effective identification of material boundaries and structures such as solder joints, connecting lines, and substrate areas. During image acquisition, the sensor's white balance setting should be adjusted to ensure that the color information matches the actual PCB color to avoid subsequent misjudgments.
[0064] Contrast determines the ability to distinguish different areas within an image. High-contrast images clearly show the boundaries between different structures on the circuit board surface, facilitating observation and detection. Especially when detecting fine cracks or solder joint defects, sharp edges and high-contrast details improve algorithm recognition accuracy. Low-contrast images often blur these details, resulting in reduced detection accuracy. In actual acquisition, contrast can be improved by adjusting lighting intensity, sensor gain, or applying image enhancement algorithms.
[0065] The signal-to-noise ratio (SNR) is also a key parameter for acquiring image data. It represents the ratio between the effective signal (i.e., the image's true information) and the noise. Noise is caused by the sensor's operating state, external environmental interference, and circuit system fluctuations. It can cause random brightness variations or granular noise in certain areas of the image, affecting image quality. Images with a high SNR more accurately reflect the actual PCB surface conditions, without being affected by noise.
[0066] Furthermore, during the actual image data acquisition process, attention must be paid to image consistency and standardization. Consistency means that each captured image possesses identical characteristics such as brightness and contrast, ensuring consistent quality across PCB images from different batches or locations. Particularly in automated production lines, standardized image acquisition settings (such as fixed exposure time, lighting intensity, and acquisition angle) facilitate subsequent inspection models processing similar image data, reducing variability introduced by environmental factors and ensuring inspection stability.
[0067] After image data acquisition is complete, data storage and management also require attention. High-resolution images generate large amounts of data, especially in industrial environments. Inspection systems must process a large number of PCB images, placing high demands on storage and transmission. High-speed data transmission interfaces (such as USB 3.0 or Gigabit Ethernet) can effectively reduce latency and ensure smooth data transmission. Furthermore, the storage system should have sufficient capacity to support multiple inspections and backups for subsequent retrieval and analysis. Furthermore, the use of appropriate data compression and encoding technologies can reduce storage space without compromising image quality, ensuring stable system operation.
[0068] In step S12, the PCB image data is input into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fused image. This process aims to utilize the model's image optimization capabilities to reduce the effects of shadows, reflections, and other effects under single-light source imaging conditions. This model does not directly adjust the actual light source settings, but instead deeply optimizes the collected image data to achieve a more uniform and clear visual effect, allowing for more accurate detection of PCB defects. The multi-light source synchronous imaging model primarily relies on a pre-trained illumination-balanced convolutional neural network, leveraging the model's learning and optimization of image features to improve image adaptability and stability.
[0069] During the training phase of the multi-light source synchronous imaging model, the model learns from a large amount of multi-light source data to understand the brightness distribution, reflection intensity, and edge detail features of the PCB circuit board under different lighting angles. The core of the training is to enable the model to identify and effectively compensate for shadow areas and reflective areas in the image, so that images taken under a single light source are closer to the effect of multi-light source imaging. Specifically, the training process includes analyzing and balancing the brightness, color, and edge clarity of each pixel to ensure that the surface information of the circuit board can be truly restored during the data optimization process. During the training process, the convolutional neural network (CNN) uses the loss function value as a convergence indicator to continuously optimize the weights until the model can automatically compensate for shadow and reflection problems in different acquisition environments.
[0070] In practical applications, the model extracts and fuses multi-dimensional features from PCB image data through convolution and pooling operations to construct a rendering of the multi-light source effect. First, light source calibration and intensity calibration identify shadows and reflective areas based on the illumination distribution characteristics within the image. This approach allows the model to automatically detect the brightness distribution of different areas based on the image content, rather than relying on the actual light source configuration. Subsequently, the model combines multi-light source intensity adjustment parameters to enhance or attenuate brightness in areas with uneven illumination, resulting in a more uniform light intensity distribution within the image.
[0071] After completing the lighting equalization operation, the model performs image fusion. By simulating and weighting various lighting conditions, it rationally compensates for the characteristics of shadows and reflective areas, thereby generating a unified multi-light source effect image. During this process, the model balances the brightness and contrast of different areas of the image. Specifically, during fusion, the model analyzes the light intensity distribution at each pixel position in the image to obtain the multi-light source intensity adjustment parameters for each pixel point, and then adjusts the shadow and highlight areas to improve the overall clarity of the image.
[0072] It should be noted that the advantage of the multi-light source synchronous imaging model is that it improves the imaging quality through data-level optimization processing, making the circuit board image more suitable for subsequent defect detection steps.
[0073] In a preferred implementation, the training process of the multi-light source synchronous imaging model includes:
[0074] Building a light-balancing convolutional neural network model based on the brightness distribution, reflection intensity, and edge detail features of the circuit board at different lighting angles, and training the light-balancing convolutional neural network model;
[0075] When the number of training times is greater than or equal to the preset maximum number of training times, or when the loss function value of the illumination balance convolutional neural network model is less than the preset loss threshold, the training is determined to be completed, and the trained illumination balance convolutional neural network model is used as a multi-light source synchronous imaging model.
[0076] It should be noted that the training process of the illumination-balanced convolutional neural network model involves in-depth analysis of images of the circuit board surface under multi-angle lighting conditions to reduce interference such as shadows and reflections caused by imaging from a single light source. The model training first collects brightness distribution data for each pixel on the circuit board surface under different lighting conditions, including light intensity, angle, reflective properties, and detailed edge features. Through convolution operations, the model gradually learns the distribution of brightness on the circuit board surface under multiple light sources and extracts key features from the circuit board image through pooling layers. Based on these features, the model adjusts the weights layer by layer to establish brightness and contrast standards for the circuit board surface under ideal lighting conditions, thereby reproducing the effect of multiple light sources in the imaging data.
[0077] The training process uses a loss function as the basis for optimization. The loss function measures the difference between the brightness distribution of the model output and the target uniform lighting effect at each iteration. Initially, the model's processing of areas with different brightness distributions may be biased, resulting in large loss values. However, as the number of training cycles increases, the convolutional neural network gradually adjusts its internal weight distribution to better handle the brightness, contrast, and details of different areas on the circuit board surface. Specifically, during training, the model continuously reduces brightness differences in shadowed and reflective areas, enhancing the response to low-brightness details while balancing the reflection intensity of high-brightness areas, making the final output image closer to the ideal image under multi-light source conditions.
[0078] There are two stopping conditions during training: one is when training reaches the preset maximum number of training cycles, and the other is when the loss function value drops below the set loss threshold, indicating that the model has fully learned and optimized. If the number of training cycles has not reached the maximum, but the loss function is close to the ideal effect, it means that the model has mastered the ability to balance the effects of multiple light sources under the existing data conditions, avoiding overfitting. Ultimately, when the loss function reaches the threshold or the number of training cycles reaches the preset value, the model is considered to have completed training. At this point, the optimized illumination-balancing convolutional neural network model serves as the multi-light source synchronous imaging model for subsequent PCB circuit board image optimization processing, improving shadows and reflections that may be caused by single-light source imaging, and improving image quality and accuracy during defect detection.
[0079] In a preferred implementation, inputting the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fusion image includes:
[0080] Perform light source calibration and intensity calibration operations according to the PCB circuit board image data to obtain multi-light source intensity adjustment parameters;
[0081] Performing a light source adjustment operation on the PCB circuit board image data according to the multi-light source intensity adjustment parameter to obtain imaging data under multiple light sources;
[0082] An image fusion operation is performed based on the imaging data under the multiple light sources to obtain a multi-light source fused image.
[0083] It should be noted that light source calibration and intensity calibration are performed to analyze the brightness variations of different areas of the circuit board surface under different lighting conditions, thereby calculating and generating multi-light source intensity adjustment parameters. This process reads the light intensity values of each pixel in the PCB image data to identify the brightness characteristics of different areas, allowing for subsequent calibration of the lighting effects and achieving a more uniform light intensity across the image. Specifically, the calibration operation analyzes the brightness value of each pixel based on the image content, identifying shadows or reflective areas in the image that may be caused by a single light source, and generates adjustment parameters accordingly to balance the light intensity in these areas.
[0084] During the light source adjustment phase, the aforementioned multi-light source intensity adjustment parameters are applied to the image data. The model's optimization algorithm then selectively increases or decreases the brightness of each pixel, generating imaging data under multiple light sources. During this process, the system does not actually add or change light sources. Instead, it optimizes the lighting conditions of the captured image through an image-based brightness adjustment and compensation mechanism, simulating the effects of multiple light sources as closely as possible. This reduces shadows in the image and reduces areas of excessive brightness, resulting in an image with a more balanced contrast ratio.
[0085] Finally, image fusion is performed based on the multi-light imaging data after light source calibration. Image fusion further optimizes the multi-light effect by balancing the brightness of different areas and eliminating the contrast issues caused by a single light source. The fusion operation results in a multi-light fused image that significantly reduces the impact of surface shadows, reflections, and other factors on image quality, making the image more uniform and smooth, providing high-quality image data input for subsequent defect identification.
[0086] In a preferred implementation, performing light source calibration and intensity calibration operations based on the PCB circuit board image data to obtain multiple light source intensity adjustment parameters includes:
[0087] The light intensity value of each pixel is obtained by the following formula:
[0088]
[0089] in is the pixel position The light intensity value at is the initial intensity of each light source, is the light intensity attenuation coefficient, It is light source to pixel position distance,
[0090]
[0091] in is the position of the i-th light source on the horizontal axis, is the position of the i-th light source on the ordinate, is the position of the i-th light source in the depth direction;
[0092] The multi-light source intensity adjustment parameter for each pixel is obtained by the following formula:
[0093]
[0094] in Indicates the Multi-light source intensity adjustment parameters for each pixel, is the preset uniform light intensity value, is the pixel position the brightness value of the pixel, is the initial intensity of the light source, is the attenuation coefficient, From the pixel To The distance of the light source, Yes all N light source at pixel location The total light intensity value on .
[0095] It should be noted that in this preferred implementation, the multi-light source intensity adjustment parameters are generated by analyzing the light intensity values of each pixel in the image data, aiming to optimize the uniformity and detail expression of the image. In this process, the system first uses the formula The light intensity value at each pixel is calculated, and the distribution of light intensity values is derived by combining the initial intensity of each light source, the light intensity attenuation coefficient, and the distance from the light source to the pixel. Specifically, the light intensity attenuation coefficient describes the gradual decrease in light intensity with increasing distance; the distance factor reflects the relative position of each pixel position with respect to multiple light sources, helping the system build a more accurate light intensity distribution model, thereby better simulating the lighting effects of multi-light source imaging.
[0096] After obtaining the light intensity value of each pixel, through further analysis of these data, we can use The formula yields the multi-light source intensity adjustment parameters. This formula combines a preset uniform light intensity value as a reference standard, with which the brightness value of each pixel is compared, and again takes into account the light source intensity, attenuation coefficient, and the distance between each light source and the pixel. This dynamically adjusts the light intensity distribution at each pixel position, making the different brightness areas in the image more uniform and preventing the overbrightness or overdarkness caused by a single light source. The ultimate goal of this process is to rationally distribute light intensity across different areas of the image data, making the image brightness more spatially balanced, thereby effectively reducing the impact of problems such as shadows and reflections.
[0097] After obtaining the multi-light source intensity adjustment parameters, the system optimizes the brightness and contrast of the image based on these parameters, bringing the light intensity of each pixel closer to the preset uniform illumination effect, creating a unified lighting appearance. Ultimately, these multi-light source intensity adjustment parameters ensure that the image data more accurately reflects the actual condition of the circuit board surface, providing a clear and stable image foundation for subsequent defect detection.
[0098] In step S13, the multi-light source fusion image is optimized to generate a noise-reduced grayscale image. This process aims to improve the clarity and quality of the image through data preprocessing, providing a high-precision foundation for subsequent defect detection. In this step, when optimizing the multi-light source fusion image, a noise reduction algorithm is first used to remove any noise that may be present in the image. Sources of noise include electromagnetic interference during the shooting process, sensor instability, and image distortion caused by changes in lighting conditions. Noise reduction operations often use spatial filtering or frequency domain filtering algorithms, such as median filtering, mean filtering, and Gaussian filtering, to reduce the impact of random noise on image quality while preserving the texture and structural features of the circuit board surface.
[0099] After noise reduction, the image is converted to grayscale. This step simplifies the image data structure, allowing for a focused presentation of brightness information, facilitating subsequent feature extraction and detection. Converting a color image to grayscale removes any interference from color information on defect detection, focusing the inspection process on image brightness differences. This helps highlight subtle surface defects on the circuit board, such as cracks and corrosion spots, which manifest as brightness discontinuities or subtle texture variations in the image. Grayscale processing also reduces data redundancy, accelerating subsequent analysis.
[0100] It's important to note that denoising and grayscaling operations aren't just about removing noise and simplifying data; they also provide a unified and stable image input for defect detection. After denoising and grayscaling the multi-light source fusion image, the resulting denoised grayscale image maximizes the preservation of structural detail and brightness contrast on the circuit board surface, providing a better foundation for detection algorithms to identify subtle defects. By reducing unnecessary color information and noise interference, the denoised grayscale image can more effectively highlight surface defects during subsequent feature extraction and detection, laying a solid foundation for the accuracy and stability of the detection model.
[0101] In step S14, region segmentation and feature extraction are performed based on the denoised grayscale image. This aims to clearly separate different regions within the image so that the characteristic information of each region can be effectively identified during subsequent detection. Region segmentation is primarily based on the structural characteristics of the circuit board image. Typically, different regions on a circuit board have different textures or geometric features, so an edge detection algorithm can be used to separate different structures, components, or solder joints within the image. This segmentation method allows each component within the image, such as the circuit board, solder joints, and wires, to be separated into separate regions, ensuring a clear outline for each region and facilitating subsequent feature extraction.
[0102] After region division, the system performs feature extraction on each independent region to obtain feature data. The goal of feature extraction is to identify the main information of each region in the grayscale image, which includes texture, shape, edges, brightness contrast, etc. For example, the brightness changes and edge features of the solder joint area can be used to identify solder joint defects, while the continuity and directional features of the wire area can help detect wire breakage or wear. The feature extraction method is based on the statistical and geometric characteristics of the image. Through common calculation methods such as histogram analysis, gradient calculation and Gabor filtering, the characteristics of the spatial distribution of the grayscale image are further analyzed to accurately reflect the unique information of each region.
[0103] It's important to note that region segmentation and feature extraction are fundamental steps in image analysis. This process not only clearly delineates the different regions of a denoised grayscale image, but also extracts key features within each region, providing efficient data support for subsequent defect detection and classification. The feature data for each region obtained in this step serves as the basis for subsequent inspection and analysis, improving detection precision and classification accuracy.
[0104] In step S15, the core is to determine the presence and severity of various potential defects on the PCB board through feature matching and dynamic trend analysis. First, the system will calculate the similarity between the extracted regional features and the defect features stored in the database. To ensure the accuracy of the matching, this process is based on vector space similarity calculation, and the formula used measures the similarity between the current regional features and different defect samples in the database. Specifically, by comparing each element in the feature vector one by one, the overall similarity value between the regional features and the defect features in the database can be obtained. When the similarity is greater than the preset threshold for any defect type in the database, the system determines that the corresponding type of defect exists in the region. This vector comparison-based method can effectively improve the accuracy of defect identification and avoid misjudgments due to subtle differences in features.
[0105] The model also uses a dynamic defect development trend assessment formula to further analyze the potential risks and impacts of PCB defects over time. This assessment value represents the severity and potential impact of the defect at different moments in time. It integrates the defect development trend and impact value at a given point in time and calculates the dynamic development trend assessment value based on the time interval. The various weight coefficients in the formula reflect the contribution of different indicators in the assessment, facilitating a comprehensive consideration of the various dimensions of the defect. For example, by comparing the defect development trend at the current point in time with that over several past periods, it is possible to infer whether the defect is worsening, providing a reference for subsequent defect repair and maintenance.
[0106] In a preferred implementation, the training process of the multi-scale dynamic defect detection model includes:
[0107] Building a multi-scale temporal convolutional network model based on texture changes, edge curvature, area ratio of circuit board defects and morphological characteristics of defects at different scales, and training the multi-scale temporal convolutional network model;
[0108] When the number of training times is greater than or equal to the preset maximum number of training times, or when the loss function value of the multi-scale time convolutional network model is less than the preset loss threshold, the training is determined to be completed, and the trained multi-scale time convolutional network model is used as a multi-scale dynamic defect detection model.
[0109] It's important to note that the multi-scale dynamic defect detection model is trained using a multi-scale temporal convolutional network (MSTCN). This model is primarily designed to analyze the texture variations, edge curvature, area ratio, and morphological characteristics of PCB defects at different scales. This multi-scale analysis model training effectively adapts to the significant differences in the detailed features of PCB defects. For example, some defects may appear as obvious edge fractures at large scales but only as subtle texture changes at small scales. Therefore, by introducing a multi-scale convolutional structure, the model is able to capture features at different scales, ensuring its adaptability to different defect types.
[0110] During training, the multi-scale temporal convolutional network model extracts and learns defect feature information layer by layer, capturing the dynamic changes of defects through convolution operations in the temporal dimension. This temporal convolution-based training method simulates the gradual changes in morphological features of defects during inspection or use, enabling the model to not only identify static defects but also adapt to the evolution of defects in multi-frame image sequences, thereby gaining a more comprehensive understanding of the potential development direction of defects. The training process continues until the model reaches or exceeds the preset maximum number of training times, or the model's loss function value drops below the set loss threshold, indicating that the model has converged on the defect characteristics.
[0111] The loss function in this training process primarily measures the gap between the model's predictions and the actual labels. The optimization goal is to minimize this gap through iterative training. The optimized and trained multi-scale temporal convolutional network model can be used in practical applications as a multi-scale dynamic defect detection model. This model not only accurately detects the presence of PCB defects but also adapts to dynamic defects in complex environments, providing an efficient and reliable technical approach for PCB quality monitoring and defect management.
[0112] In a preferred implementation, inputting the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection information includes:
[0113] The similarity between the regional features and the defect features in the database is obtained by the following formula:
[0114]
[0115] in, The regional features and the defect features in the database The similarity of is the dimension of the feature vector, is the first feature vector of the current region elements, is the first defect feature vector in the database elements;
[0116] When the similarity is greater than a preset threshold value of any type of defect, it is determined to be a defect of that type;
[0117] The dynamic development trend evaluation value of defects is obtained through the following formula:
[0118]
[0119] in, is the evaluation value of the dynamic development trend of defects, Indicates at a point in time The potential risks and impacts of defects, Indicates at a point in time The potential risks and impacts of time defects, is the time interval, For time point The defect development trend function, Indicates the past Defect development trends over time, is the weight coefficient of each indicator for the evaluation value of the dynamic development trend of defects; the PCB defect detection status is obtained according to the evaluation value of the dynamic development trend of defects.
[0120] It's important to note that to better identify PCB defects, we determine and predict the development of defects by calculating the similarity between regional features and defect features in the database, as well as evaluating the dynamic development trend of defects. These formulas are designed based on the actual variation patterns of defect characteristics. Using mathematical methods, we quantify and capture the changing trends of defects at different points in time, facilitating real-time defect monitoring and risk assessment.
[0121] First, the similarity calculation formula The design of takes into account the difference between regional characteristics and known defect characteristics. The numerator of the formula It represents the sum of the element-by-element differences between the features of the area to be inspected and the defect features in the database, that is, the sum of the absolute values of these differences; this calculation method can directly reflect the difference between the current area and the reference defect. It is a normalization operation that standardizes the difference to the range of [0,1], thereby eliminating the influence of the numerical size of different dimensions of the feature vector and ensuring the comparability of the results. Through the 1-operation, the similarity value is finally made to more intuitively represent the degree of matching. The closer the similarity is to 1, the closer the regional characteristics are to the defect characteristics. This formula not only retains the difference amount, but also introduces the idea of normalization, so it can better adapt to the differences in feature vectors in different dimensions. Next, the defect dynamic development trend evaluation value formula There are three main parts to capture the temporal trend of defects: This part reflects the current time point and past time points The difference in defect severity captures the overall change in defects over a recent period. If the defect severity changes significantly over time, it indicates that the defect is rapidly expanding or worsening; if the change is small, it indicates that the defect is developing more slowly. This term further introduces the rate of defect growth, which is the change in defect severity per unit time. ,The “speed” of defect expansion can be quantified.,This is the key to evaluating the potential of defect propagation, and can provide the ,dynamic characteristics of defects in the time dimension. : This part is the cumulative integral, which takes into account the overall development trend of defects in the past period of time. The integral value can reflect the cumulative impact of the degree of defects within the historical time range, and help determine whether the development of defects has long-term or cyclical characteristics. During the detection process, the introduction of this part allows the system to "remember" the changes in defects over the past period of time, avoiding relying solely on instantaneous change values. Through the weighted combination of these three parts, the formula can more comprehensively capture the expansion trend of defects at the current time point and in the past time period. Weight coefficient 、 、 This provides flexibility for the model and allows it to be adjusted according to different application requirements. For example, when focusing on the immediate changes in defects, and It can be set to a higher value; if you pay more attention to the historical accumulation of defects, you can increase it appropriately. Finally, the weight obtained by calculation The value can quantify the dynamic development trend of defects at the current moment and provide a scientific basis for the detection and risk assessment of PCB board defects.
[0122] In a preferred implementation, obtaining the PCB defect detection status according to the defect dynamic development trend evaluation value includes:
[0123] When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be slightly defective;
[0124] When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be moderately defective;
[0125] When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be seriously defective;
[0126] in, 、 They are the preset defect assessment low threshold and defect assessment medium threshold respectively.
[0127] It should be noted that 、 They are the preset defect assessment low threshold and defect assessment medium threshold respectively. If the assessment value is less than , it indicates that the defect in this area is relatively minor and has little effect on the structure and function of the PCB. In this case, simple repair or observation can be performed; if the evaluation value is and If the evaluation value is greater than , it means that there are serious defects in this area, which may have a significant impact on the function and service life of the PCB and need to be scrapped.
[0128] To facilitate understanding of the present invention, some preferred embodiments of the present invention are further described below.
[0129] In one implementation, light source calibration and intensity calibration are performed based on PCB image data to generate multi-light source intensity adjustment parameters. This process utilizes a mathematical model to calculate the theoretical light intensity of each pixel in a multi-light source environment. The light source intensity is then adjusted based on the actual captured image data, simulating the effect of simultaneous multi-light source imaging. This approach significantly reduces shadows and reflections by optimizing the image's lighting conditions, improving image quality and providing a sound foundation for subsequent feature extraction and defect detection.
[0130] Another implementation approach leverages reinforcement learning techniques within a deep learning framework to dynamically adjust the lighting conditions of a multi-light source system. Specifically, a model is built that, based on current image quality feedback, such as contrast and clarity, autonomously determines the position and intensity of the light sources to achieve optimal imaging. This model continuously learns through interaction with the environment, gradually mastering strategies for generating optimal lighting patterns under varying conditions. This approach not only enables adaptive optimization of lighting conditions but also allows for continuous improvement over time to accommodate increasingly complex production environments.
[0131] The following describes the working process of the present invention using a common scenario as an example. Figure 2 , which is Figure 1 Schematic diagram of the working scenario of the method.
[0132] During the inspection phase of a PCB production line, as a PCB enters the inspection station, an industrial camera captures multi-angle images of its surface. These images are then fed into a pre-trained multi-light source synchronized imaging model. This model analyzes the brightness distribution characteristics of each area and automatically calculates the required light source intensity adjustment parameters. This optimizes the light intensity distribution in the image for a more uniform result and generates a multi-light source fused image, minimizing the effects of shadows and reflections.
[0133] The system then performs noise reduction and other optimization processing on the resulting multi-light source fusion image. Specifically, a series of filtering operations removes clutter and noise from the image, making the subtle solder joints, wiring, and other structures on the circuit board more distinct, providing high-quality visual data for subsequent analysis.
[0134] Next, the system performs feature extraction. The system uses the processed image to automatically segment different regions and extract defect-related features, such as texture and edge shape. These features are fed into a multi-scale dynamic defect detection model, which determines the defect type by comparing the current features with a database of known defect features. If the similarity exceeds a set threshold, the corresponding defect is determined to exist in that region.
[0135] The system also analyzes the expansion trend of defects over time. If the detected defect assessment value is greater than the preset maximum threshold, indicating that the defect will have a significant impact, the system will determine that the PCB is severely defective and will be scrapped. If the defect assessment value is less than the preset minimum threshold, the defect is minor and will not affect the function of the circuit board. Simple repair or observation can be performed. If the assessment value is between the minimum and maximum thresholds, it indicates that the defect has developed to a certain extent, affecting some functions of the PCB, and requires comprehensive repair or replacement.
[0136] In summary, the present invention achieves efficient and accurate detection of PCB circuit board defects through the collaborative work of the multi-light source synchronous imaging model and the multi-scale dynamic defect detection model.
[0137] Reference Figure 2 A second embodiment of the present invention provides a PCB circuit board defect detection device, comprising:
[0138] A data acquisition module is used to acquire PCB circuit board image data;
[0139] A multi-light source imaging module is used to input the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fused image;
[0140] An image optimization module is used to perform image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image;
[0141] A feature extraction module is used to perform region division and feature extraction operations based on the denoised grayscale image to obtain features of each region;
[0142] The defect detection module is used to input the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain the PCB defect detection status.
[0143] It should be noted that the PCB circuit board defect detection device provided in an embodiment of the present invention is used to execute all the process steps of the PCB circuit board defect detection method of the above embodiment. The working principles and beneficial effects of the two correspond one to one, and therefore will not be repeated here.
[0144] The embodiment of the present invention further provides a device. The device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a PCB circuit board defect detection program. When the processor executes the computer program, the steps in the above-mentioned PCB circuit board defect detection method embodiments are implemented, such as Figure 1 Alternatively, when the processor executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are realized, such as the feature extraction module.
[0145] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program in the device.
[0146] The device may be a computing device such as a desktop computer, laptop, PDA, or smart tablet. The device may include, but is not limited to, a processor and memory. Those skilled in the art will appreciate that the aforementioned components are merely examples of the device and do not constitute a limitation of the device. The device may include more or fewer components than those described above, or a combination of certain components, or different components. For example, the device may also include input / output devices, network access devices, buses, and the like.
[0147] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor. The processor is the control center of the device and connects various parts of the entire device using various interfaces and lines.
[0148] The memory can be used to store the computer programs and / or modules. The processor implements the various functions of the device by running or executing the computer programs and / or modules stored in the memory and accessing the data stored in the memory. The memory may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function or an image playback function); the data storage area may store data generated based on the use of the mobile phone (such as audio data, a phone book, etc.). Furthermore, the memory may include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.
[0149] If the module / unit integrated into the device is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention can implement all or part of the process steps in the above-mentioned method embodiments by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content of the computer-readable medium can be appropriately increased or decreased based on the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media does not include electric carrier signals and telecommunication signals.
[0150] It should be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art can understand and implement the present invention without inventive effort.
[0151] The specific embodiments described above further illustrate the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A PCB circuit board defect detection method, characterized in that: include: Obtain PCB circuit board image data; Inputting the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fusion image; Performing image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image; Performing region division and feature extraction operations on the denoised grayscale image to obtain features of each region; Inputting the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection status; The step of inputting the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fusion image includes: Perform light source calibration and intensity calibration operations according to the PCB circuit board image data to obtain multi-light source intensity adjustment parameters; Performing a light source adjustment operation on the PCB circuit board image data according to the multi-light source intensity adjustment parameter to obtain imaging data under multiple light sources; The light source calibration and intensity calibration operations are performed according to the PCB circuit board image data to obtain the multi-light source intensity adjustment parameters, including: The light intensity value of each pixel is obtained by the following formula: in is the pixel position The light intensity value at is the initial intensity of each light source, is the light intensity attenuation coefficient, It is light source to pixel position distance, in is the position of the i-th light source on the horizontal axis, is the position of the i-th light source on the ordinate, is the position of the i-th light source in the depth direction; The multi-light source intensity adjustment parameter for each pixel is obtained by the following formula: in Indicates the Multi-light source intensity adjustment parameters for each pixel, is the preset uniform light intensity value, is the pixel position the brightness value of the pixel, is the initial intensity of the light source, is the attenuation coefficient, From the pixel To The distance of the light source, is the total number of N light sources at the pixel position The total light intensity value on .
2. The PCB circuit board defect detection method according to claim 1, characterized in that: The training process of the multi-light source synchronous imaging model includes: Building a light-balancing convolutional neural network model based on the brightness distribution, reflection intensity, and edge detail features of the circuit board at different lighting angles, and training the light-balancing convolutional neural network model; When the number of training times is greater than or equal to the preset maximum number of training times, or when the loss function value of the illumination balance convolutional neural network model is less than the preset loss threshold, the training is determined to be completed, and the trained illumination balance convolutional neural network model is used as a multi-light source synchronous imaging model.
3. The PCB circuit board defect detection method according to claim 1, characterized in that: The training process of the multi-scale dynamic defect detection model includes: Building a multi-scale temporal convolutional network model based on texture changes, edge curvature, area ratio of circuit board defects and morphological characteristics of defects at different scales, and training the multi-scale temporal convolutional network model; When the number of training times is greater than or equal to the preset maximum number of training times, or when the loss function value of the multi-scale time convolutional network model is less than the preset loss threshold, the training is determined to be completed, and the trained multi-scale time convolutional network model is used as a multi-scale dynamic defect detection model.
4. The PCB circuit board defect detection method according to claim 1, characterized in that: Inputting the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection information includes: The similarity between the regional features and the defect features in the database is obtained by the following formula: in, The regional features and the defect features in the database The similarity of is the dimension of the feature vector, is the first feature vector of the current region elements, is the first defect feature vector in the database elements; When the similarity is greater than a preset threshold value of any type of defect, it is determined to be a defect of that type; The dynamic development trend evaluation value of defects is obtained through the following formula: in, is the evaluation value of the dynamic development trend of defects, Indicates at a point in time The potential risks and impacts of defects, Indicates at a point in time The potential risks and impacts of time defects, is the time interval, For time point The defect development trend function, Indicates the past Defect development trends over time, is the weight coefficient of each indicator for the evaluation value of the dynamic development trend of defects; the PCB defect detection status is obtained according to the evaluation value of the dynamic development trend of defects.
5. The PCB circuit board defect detection method according to claim 4, characterized in that: The PCB defect detection status obtained according to the defect dynamic development trend evaluation value includes: When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be slightly defective; When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be moderately defective; When the defect dynamic development trend evaluation value satisfies When the PCB board is judged to be seriously defective; in, 、 They are the preset defect assessment low threshold and defect assessment medium threshold respectively.
6. A PCB circuit board defect detection device, characterized in that: A method for detecting defects in a PCB circuit board according to any one of claims 1 to 5, comprising: A data acquisition module is used to acquire PCB circuit board image data; A multi-light source imaging module is used to input the PCB circuit board image data into a pre-trained multi-light source synchronous imaging model to obtain a multi-light source fused image; An image optimization module is used to perform image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image; A feature extraction module is used to perform region division and feature extraction operations based on the denoised grayscale image to obtain features of each region; The defect detection module is used to input the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain the PCB defect detection status.
7. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the method for detecting defects in a PCB circuit board according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the PCB circuit board defect detection method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Data processing method for integrated circuit manufacturing
CN113409251A
PCB (Printed Circuit Board) defect detection method based on improved Officient Det
CN116993660A