PCB (Printed Circuit Board) defect detection method, device, equipment and storage medium
Through the multi -light source synchronization imaging model and lighting balanced convolutional neural network, the problem of low detection accuracy of PCB circuit board defect detection under a single light source imaging conditions is solved, and higher detection accuracy and reliability are achieved.
Patent Information
- Application Number
- CN202411652034.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-11-19
AI Technical Summary
In the prior art, under the conditions of a single light source imaging, the defect detection results of PCB circuit boards are significantly affected by the environment, resulting in a decrease in the accuracy of defect recognition.
The multi -light source synchronization imaging model is adopted, and the light of different angles is modeling the light from different angles through the lighting balanced convolutional neural network to generate a multi -light source fusion image, and the image is optimized. The noise reduction gray image is to improve the accuracy of the feature extraction.
Effectively reduce the effects of shadows and reflection under the conditions of a single light source, improve the clarity and richness of the image, and significantly improve the overall accuracy and reliability of the PCB circuit board defect detection.
Smart Images

Figure CN119379662A_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] At present, PCB circuit boards are one of the key components of electronic products, and their quality directly affects the performance and life of electronic products. However, during the production process of PCB circuit boards, due to various reasons, such as improper operation or process defects, the circuit boards may have defects such as poor solder joints, wire breakage, corrosion, oxidation, etc. If these problems are not discovered and corrected in time, they will have a serious impact on the reliability of electronic products.
[0003] In one existing technology, a Mylar sheet recognition model is established by using the YOLOv4 target detection algorithm and the Mylar sheet image dataset to detect the Mylar sheet components on the surface of the circuit board, and then the defects are judged by analyzing the position, area and internal characteristics of the Mylar sheet. This method uses single light source imaging and two-dimensional detection, mainly focusing on the dominant defects on the surface of the circuit board, and can improve the automation level of defect detection to a certain extent.
[0004] However, the existing technology has the problem of high dependence on lighting and significant impact of the environment on the detection results. Specifically, under the condition of single light source imaging, 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: Get 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; According to the denoised grayscale image, performing region division and feature extraction operations to obtain features of each region; The features of each region are input into a pre-trained multi-scale dynamic defect detection model to obtain the PCB defect detection situation.
[0007] In an optional implementation, the training process of the multi-light source synchronous imaging model includes: Building a light-balanced 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-balanced 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.
[0008] In an optional implementation, the training process of the multi-scale dynamic defect detection model includes: A multi-scale temporal convolutional network model is constructed based on texture changes, edge curvature, area ratio of circuit board defects and morphological characteristics of defects at different scales, and the multi-scale temporal convolutional network model is trained; 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.
[0009] In an optional implementation, 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 multiple light source intensity adjustment parameters; According to the multi-light source intensity adjustment parameter, a light source adjustment operation is performed on the PCB circuit board image data to obtain imaging data under multiple light sources; An image fusion operation is performed according to the imaging data under the multiple light sources to obtain a multi-light source fused image.
[0010] In an optional implementation, 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: 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 The 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 of each pixel is obtained by the following formula: in Indicates 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 .
[0011] In an optional implementation, the inputting the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection conditions 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 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 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 by the following formula: in, is the defect dynamic development trend evaluation value, Indicates at a point in time When the potential risks and impacts of defects are 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 a weight coefficient of each indicator for the evaluation value of the dynamic development trend of defects; and the PCB defect detection situation is obtained according to the evaluation value of the dynamic development trend of defects.
[0012] In an optional implementation manner, obtaining the PCB defect detection status 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 severely defective; in, , They are respectively the preset defect assessment low threshold and the defect assessment middle threshold.
[0013] In a second aspect, the present invention provides a PCB circuit board defect detection device, comprising: A data acquisition module is used to acquire PCB circuit board image data; A multi-light source imaging module, used for 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; An image optimization module, used for performing image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image; A feature extraction module, used to perform region division and feature extraction operations according to 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.
[0014] In a third aspect, the present invention further 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.
[0015] In a fourth aspect, the present invention further provides a computer-readable storage medium, wherein 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 any one of the above-mentioned PCB circuit board defect detection methods.
[0016] Compared with the prior art, 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 illumination 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
[0017] Figure 1 It is a schematic diagram of the process flow of a PCB circuit board defect detection method provided by the first embodiment of the present invention; Figure 2 It is a schematic diagram of the structure of a PCB circuit board defect detection device provided in the second embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] Reference Figure 1 The first embodiment of the present invention provides a PCB circuit board defect detection method, comprising the following steps: S11, obtaining PCB circuit board image data; S12, 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; S13, performing image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image; S14, performing region division and feature extraction operations according to the denoised grayscale image to obtain features of each region; S15, inputting the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection status.
[0020] In step S11, obtaining PCB circuit board image data is the basic work for accurate defect detection of the circuit board. Image data is not just a simple picture of the circuit board surface, but contains multi-level and multi-dimensional information to reflect the structure and potential defects of each part of the circuit board. Specifically, the image data mainly contains the following information: resolution, gray value, color information, contrast and signal-to-noise ratio. In order to ensure that these image data can accurately reflect the actual situation of the circuit board, special attention should be paid to the parameter settings of the imaging equipment, the influence of the external light environment and the stability of data storage during the image acquisition process.
[0021] First of all, resolution is one of the core indicators of image data. Defects on PCB circuit boards can be very small, such as small cracks, pinholes, poor solder joints, etc., and high-resolution images can capture these details more carefully. In practical applications, the image resolution should match the size of the smallest defect on the circuit board to ensure that the image will not be blurred and distorted after magnification. Grayscale and color information are also very important. Grayscale is used to represent the brightness information of different areas in the image, while color information contains data in RGB or other color spaces, which can help distinguish the reflective properties of different materials on the circuit board. PCB circuit boards usually include a variety of materials such as metal and fiberglass, and the performance of each material under light is quite different. Through the accurate recording of color and grayscale, the boundaries between materials can be more effectively distinguished, and structures such as solder joints, connecting lines, and substrate areas can be identified. During the image acquisition process, the white balance setting of the sensor needs to be adjusted to keep the color information consistent with the color on the actual circuit board to avoid subsequent misjudgment.
[0022] Contrast determines the ability to distinguish different areas in an image. Images with high contrast can more clearly show the boundaries between different structures on the surface of the circuit board, making it easier to observe and detect. Especially in the detection of fine cracks or solder joint defects, clear edges and high-contrast details can improve the accuracy of algorithm recognition. Low-contrast images tend to blur these details, resulting in reduced detection accuracy. In actual acquisition, the contrast can be improved by adjusting the light intensity, the gain value of the sensor, or applying an image enhancement algorithm.
[0023] The signal-to-noise ratio is also a key parameter for acquiring image data. The signal-to-noise ratio indicates the ratio between the effective signal (i.e. the real information of the image) and the noise. The noise is caused by the working state of the sensor, the interference of the external environment, and the fluctuation of the circuit system, which will cause random light and dark changes or granular noise in some areas of the image, affecting the image quality. Images with a high signal-to-noise ratio can more truly reflect the actual situation of the PCB surface without being disturbed by noise.
[0024] In addition, in the actual image data acquisition process, attention should also be paid to image consistency and standardization. Consistency means that each acquired image has the same brightness, contrast and other characteristics, so that PCB images from different batches or different locations maintain the same quality level. Especially in automated production lines, standardized settings for image acquisition (such as fixed exposure time, light intensity and acquisition angle) help subsequent detection models process similar image data, reduce variables caused by environmental factors, and thus ensure the stability of detection.
[0025] After completing the image data acquisition, data storage and management are also links that need attention. High-resolution image data is large in volume, especially in industrial environments. The detection system needs to process a large number of circuit board images, which places high demands on storage and transmission. The use of high-speed data transmission interfaces (such as USB 3.0 or Gigabit Ethernet) can effectively reduce delays and ensure smooth data transmission. At the same time, the storage system should have sufficient capacity to support multiple inspections and backups for subsequent retrieval and analysis. In addition, with reasonable data compression and encoding technology, storage space can be reduced without losing image quality, providing a guarantee for the stable operation of the system.
[0026] In step S12, the PCB circuit board image data is input into the pre-trained multi-light source synchronous imaging model to obtain the multi-light source fusion image process, which aims to use the image optimization function of the model to reduce the effects of shadows, reflections, etc. under single light source imaging conditions. This model does not directly adjust the actual settings of the light source, but achieves a more uniform and clear visual effect by deeply optimizing the collected image data, so as to more accurately detect defects in the PCB circuit board. The multi-light source synchronous imaging model mainly relies on the pre-trained illumination balance convolutional neural network, and uses the model to learn and optimize image features to improve the adaptability and stability of the image.
[0027] During the training phase of the multi-light source synchronous imaging model, the model is learned through a large amount of multi-light source data to master the brightness distribution, reflection intensity and edge detail features of the PCB circuit board at different lighting angles. The core of the training is to enable the model to identify and effectively compensate for the shadow areas and reflective areas in the image, so that the image taken under a single light source is 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 under different acquisition environments.
[0028] In actual applications, the model extracts and fuses the multi-dimensional features of PCB image data through convolution and pooling operations to construct a multi-light source rendering. First, the light source calibration and intensity calibration operations identify shadows and reflective areas based on the illumination distribution characteristics in the image. In this way, the model does not rely on the actual light source configuration, but automatically detects the brightness distribution of different areas based on the image content. Subsequently, the model combines the multi-light source intensity adjustment parameters to perform corresponding brightness enhancement or attenuation operations in areas with uneven illumination, making the light intensity distribution in the image more uniform.
[0029] After completing the illumination balancing operation, the model performs an image fusion operation. Through simulated weighting under various illumination conditions, the features of shadows and reflective areas are reasonably compensated, thereby generating a unified multi-light source rendering. In this process, the model balances the brightness and contrast of different areas of the image. Specifically, when the model is fusion, it analyzes the light intensity distribution of each pixel position in the image, obtains the multi-light source intensity adjustment parameters of each pixel point, and adjusts the shadow and highlight areas to improve the overall clarity of the image.
[0030] It should be noted that the advantage of the multi-light source synchronous imaging model is that it can improve the imaging quality through optimization processing at the data level, making the circuit board image more suitable for subsequent defect detection steps.
[0031] In a preferred implementation, the training process of the multi-light source synchronous imaging model includes: Building a light-balanced 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-balanced 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.
[0032] It should be noted that the training process of the illumination balance convolutional neural network model is to conduct in-depth analysis of the circuit board surface image under multi-angle illumination conditions to reduce the interference of shadows, reflections, etc. caused by single light source imaging. The model training first collects the brightness distribution data of each pixel on the circuit board surface under different illumination conditions, including the intensity, angle, reflection characteristics and detailed edge features of the illumination. Through the convolution operation, the model gradually learns the distribution law of the brightness of the circuit board surface under multi-light source conditions, and extracts the main features in the circuit board image through the pooling layer. The model adjusts the weights layer by layer according to these features, thereby establishing the brightness and contrast standards of the circuit board surface under ideal illumination conditions, so as to reproduce the multi-light source effect in the imaging data.
[0033] 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 in each iteration. The initial model may have deviations in the processing of different brightness distribution areas, and the loss value is large. As the number of training times increases, the convolutional neural network will gradually adjust its internal weight distribution to better handle the brightness, contrast and details of different areas on the surface of the circuit board. Specifically, during the training process, the model will continue to reduce the brightness differences in shadows and reflective areas, enhance the response to low-brightness details, and balance the reflection intensity of high-brightness areas, so that the final output image is closer to the ideal image under multi-light source conditions.
[0034] There are two stopping conditions during the training process: one is that the training reaches the preset maximum number of training times, and the other is that when the loss function value drops below the set loss threshold, the model is considered to have been fully learned and optimized. If the number of training times has not reached the maximum value, 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 well under the existing data conditions, and can avoid overfitting. Finally, when the loss function reaches the threshold or the number of training times reaches the preset value, the model is considered to have completed training. At this point, the optimized illumination balance convolutional neural network model is used as a multi-light source synchronous imaging model for subsequent PCB circuit board image optimization processing to improve the shadow and reflection problems that may be caused by single light source imaging, and improve the image quality and accuracy during defect detection.
[0035] In a preferred implementation, 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 multiple light source intensity adjustment parameters; According to the multi-light source intensity adjustment parameter, a light source adjustment operation is performed on the PCB circuit board image data to obtain imaging data under multiple light sources; An image fusion operation is performed according to the imaging data under the multiple light sources to obtain a multi-light source fused image.
[0036] It should be noted that the light source calibration and intensity calibration operations are to analyze the brightness changes of different areas on the circuit board surface under lighting conditions, and then calculate and generate multi-light source intensity adjustment parameters. This process reads the light intensity value of each pixel in the PCB image data to identify the brightness characteristics of different areas, so as to calibrate the lighting effect in subsequent processing and make the light intensity of each part of the image more uniform. Specifically, the calibration operation analyzes the brightness value of each pixel based on the image content, identifies the shadows or reflective areas in the image that may be caused by a single light source, and generates adjustment parameters accordingly to make the light intensity of these areas tend to be balanced.
[0037] In the light source adjustment stage, the multi-light source intensity adjustment parameters will be applied to the image data, and the brightness of each pixel will be enhanced or weakened in a targeted manner through the model optimization algorithm to generate imaging data under multiple light sources. In this process, the system will not actually add or change the light source, but will optimize the lighting conditions of the collected image through the image-based brightness adjustment compensation mechanism, and simulate the multi-light source lighting effect as much as possible, so that the shadows in the image are faded and the areas with excessive brightness are lowered, thereby forming an image with a more moderate light-dark contrast.
[0038] Finally, image fusion is performed based on the imaging data under multiple light sources after light source calibration. Image fusion further optimizes the multi-light source effect by balancing the brightness of different areas and eliminating the contrast problem caused by a single light source. The result of the fusion operation is a multi-light source fusion image, which can significantly reduce the impact of surface shadows, reflections and other factors on image quality, making the image more uniform and smooth in visual effect, providing high-quality image data input for subsequent defect identification.
[0039] In a preferred implementation, the light source calibration and intensity calibration operations are performed according to the PCB circuit board image data to obtain multiple 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 The 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 of each pixel is obtained by the following formula: in Indicates 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 .
[0040] 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 of each pixel position is calculated, and the distribution of light intensity values is obtained by combining the initial intensity of each light source, the light intensity attenuation coefficient, and the distance from the light source to the pixel point. Specifically, the light intensity attenuation coefficient describes the characteristic that the light intensity gradually decreases with increasing distance; the distance factor reflects the relative position of each pixel position relative to multiple light sources, which helps the system establish a more accurate light intensity distribution model, thereby better simulating the lighting effect under multi-light source imaging.
[0041] After obtaining the light intensity value of each pixel, through further analysis of these data, The formula obtains the multi-light source intensity adjustment parameters. The formula combines the preset uniform light intensity value as a reference standard, and compares the brightness value of each pixel with it, and again considers the light source intensity, attenuation coefficient, and the distance between each light source and the pixel. In this way, the light intensity distribution of each pixel position can be dynamically adjusted to make the different brightness areas in the image more uniform, and there will be no overbrightness or overdarkness caused by a single light source. The ultimate goal of this process is to reasonably distribute the light intensity in different areas of the image data, so that the brightness of the image is more balanced in space, thereby effectively reducing the impact of shadows, reflections and other problems.
[0042] After obtaining the multi-light source intensity adjustment parameters, the system can optimize the brightness and contrast in the image based on these parameters, so that the light intensity of each pixel is closer to the preset uniform lighting effect, forming a unified lighting performance. Ultimately, the multi-light source intensity adjustment parameters ensure that the image data can more accurately reflect the actual condition of the circuit board surface, providing a clear and stable image foundation for subsequent defect detection.
[0043] In step S13, the multi-light source fusion image is optimized to generate a denoised grayscale image, which aims to improve the clarity and quality of the image through data preprocessing, and provide a high-precision basis for subsequent defect detection. In this step, when the multi-light source fusion image is optimized, the noise that may exist in the image is first removed by a noise reduction algorithm. The noise sources include electromagnetic interference during the shooting process, sensor instability factors, and image distortion caused by changes in lighting conditions. The noise reduction operation commonly uses 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 retaining the texture and structural features of the circuit board surface.
[0044] After the noise reduction process is completed, the image will be converted into a grayscale image. The purpose of this step is to simplify the image data structure so that the brightness information of the image can be presented in a centralized manner, which facilitates the subsequent feature extraction and detection. By converting the color image into a grayscale image, the interference of color information on defect detection can be removed, and the detection process can be focused on the brightness difference of the image, which helps to highlight the tiny defects on the surface of the circuit board, such as cracks, corrosion spots, etc., because these defects will appear as brightness discontinuities or tiny texture changes in the image. Grayscale processing can also reduce data redundancy and speed up the subsequent analysis process.
[0045] It should be noted that denoising and grayscale operations are not only about removing interference and simplifying data, but also about providing a unified and stable image input for defect detection. After the multi-light source fusion image is processed by denoising and grayscale, the generated denoised grayscale image can maintain the structural details and brightness contrast information on the circuit board surface to the greatest extent, providing a better foundation for the detection algorithm to identify subtle defects. By reducing unnecessary color information and noise interference, the denoised grayscale image can more efficiently highlight surface defects in the subsequent feature extraction and detection process, laying a solid foundation for the accuracy and stability of the detection model.
[0046] In step S14, region division and feature extraction operations are performed based on the denoised grayscale image, aiming to clearly separate different regions in the image so that the feature information of each region can be effectively identified in the subsequent detection process. First, region division is performed based on the structural characteristics of the circuit board image. Usually, each region on the circuit board has different textures or geometric features, so an edge detection algorithm can be used to separate different structures, components or solder joints in the image. Through this segmentation method, the circuit board, solder joints, wires and other parts in the image can be formed into independent regions, ensuring that the outline of each region is clear, thereby facilitating subsequent feature extraction operations.
[0047] After the 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, edge, brightness contrast, etc. For example, the brightness change and edge features of the solder joint area can be used to identify solder joint defects, and 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 grayscale image in spatial distribution are further analyzed to accurately reflect the unique information of each region.
[0048] It should be noted that region division and feature extraction are the basic links of image analysis. This operation can not only clearly divide different regions of the denoised grayscale image, but also extract key features in the region, providing efficient data support for subsequent defect detection and classification. The feature data of each region obtained through this step will be used as a basis for judgment in the subsequent detection and analysis to improve the detection accuracy and classification accuracy.
[0049] In step S15, the core is to judge the existence 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 of any defect type in the database, the system determines that the corresponding type of defect exists in the region. This method based on vector comparison can effectively improve the accuracy of defect identification and avoid misjudgment due to subtle differences in features.
[0050] In addition, the model further analyzes the potential risks and impacts of PCB defects in the time dimension through the defect dynamic development trend evaluation formula. The evaluation value represents the severity and possible impact of the defect at different times. By integrating the defect development trend and impact value at the time point, and calculating the dynamic development trend evaluation value based on the time interval. The weight coefficients in the formula are used to reflect the proportion of different indicators in the evaluation, so that the system can comprehensively consider the characteristics of each dimension of the defect. For example, by comparing the defect development trend at the current time point and the defect development trend in the past several times, it can be inferred whether the defect has a deterioration trend, which provides a reference for subsequent defect repair and maintenance.
[0051] In a preferred implementation, the training process of the multi-scale dynamic defect detection model includes: A multi-scale temporal convolutional network model is constructed based on texture changes, edge curvature, area ratio of circuit board defects and morphological characteristics of defects at different scales, and the multi-scale temporal convolutional network model is trained; 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.
[0052] It should be noted that the training process of the multi-scale dynamic defect detection model adopts a multi-scale temporal convolutional network (MSTCN). The construction of this model mainly revolves around the texture changes, edge curvature, area ratio and morphological characteristics of circuit board defects at different scales. This multi-scale analysis model training can effectively adapt to the significant differences in the detailed features of PCB defects. For example, some defects may appear as obvious edge fractures at a large scale, but only as slight texture changes at a small scale. Therefore, by introducing a multi-scale convolutional structure, the model can be equipped with the ability to capture features at different scales, thereby ensuring the adaptability of the model when facing different types of defects.
[0053] During the training process, the multi-scale temporal convolutional network model extracts and learns defect feature information layer by layer, and captures the dynamic changes of defects through convolution operations in the time dimension. This training method based on temporal convolution can simulate the gradual changes in the morphological features of defects during detection or use, so that the model can not only identify static defects, but also adapt to the evolution trend of defects in multi-frame image sequences, thereby more comprehensively understanding the potential development direction of defects. The training process continues until the model's training times reach or exceed the preset maximum training times, or the model's loss function value drops below the set loss threshold, indicating that the model has reached convergence in learning defect features.
[0054] The loss function in the training process is mainly used to measure the gap between the model prediction results and the actual labels, and its optimization goal is to minimize the gap through iterative training. The multi-scale temporal convolutional network model after optimization training can be used as a multi-scale dynamic defect detection model in practical applications. In this way, the model can not only accurately detect the presence of circuit board defects, but also has the ability to adapt to dynamic defects in complex environments, thus providing an efficient and reliable technical means for PCB quality monitoring and defect management.
[0055] In a preferred implementation, the inputting of the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection conditions 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 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 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 by the following formula: in, is the defect dynamic development trend evaluation value, Indicates at a point in time When the potential risks and impacts of defects are 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 a weight coefficient of each indicator for the evaluation value of the dynamic development trend of defects; and the PCB defect detection situation is obtained according to the evaluation value of the dynamic development trend of defects.
[0056] It should be noted that in order to better identify the defects of PCB circuit boards, we judge and predict the development status of defects by calculating the similarity between regional features and defect features in the database, as well as the dynamic development trend evaluation value of defects. The basis for the design of these formulas is to start from the actual law of defect feature changes, and use mathematical means to quantify and capture the changing trends of defects at different time points, so as to facilitate real-time defect monitoring and risk assessment.
[0057] First, the similarity calculation formula The design of takes into account the difference between the regional characteristics and the 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 features of the defects 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 impact of the numerical values of different dimensions of the feature vector and ensuring the comparability of the results. Through the 1-operation, the similarity value finally makes it more intuitive to represent the degree of matching. The closer the similarity is to 1, the closer the regional features are to the defect features. This formula not only retains the difference, 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 of time. If the defect severity changes significantly over time, it means that the defect has a tendency to expand or worsen rapidly; if the change is small, it means that the defect develops more slowly. This term further introduces the rate of defect growth, that is, the change in defect level per unit time. ,The "speed" of defect expansion can be quantified. This is the key to evaluating the potential for 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 periodic 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, which can be adjusted according to different application requirements. For example, when focusing on the immediate changes of defects, and 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.
[0058] In a preferred implementation, obtaining the PCB defect detection status 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 severely defective; in, , They are respectively the preset defect assessment low threshold and the defect assessment middle threshold.
[0059] 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.
[0060] In order to facilitate the understanding of the present invention, some preferred embodiments of the present invention are further described below.
[0061] In one implementation, light source calibration and intensity calibration operations are performed based on PCB circuit board image data to generate multi-light source intensity adjustment parameters. This process uses a mathematical model to calculate the theoretical light intensity value of each pixel in a multi-light source environment, and adjusts the light source intensity based on the actual collected image data, thereby simulating the effect of multi-light source synchronous imaging. This method significantly reduces shadows and reflections by optimizing the lighting conditions of the image, improves image quality, and provides a good image foundation for subsequent feature extraction and defect detection.
[0062] In another implementation, the reinforcement learning technology in the deep learning framework can also be used to dynamically adjust the lighting conditions of the multi-light source system. Specifically, a model is built that autonomously determines the position and intensity adjustment strategy of the light source based on the quality feedback of the current image, such as contrast, clarity and other indicators, to achieve the best imaging effect. The model continuously learns through interaction with the environment and gradually masters the strategy of generating the best lighting mode under different conditions. This implementation method can not only achieve adaptive optimization of lighting conditions, but also continuously improve over time to cope with more complex production environments.
[0063] 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.
[0064] In the inspection process of the PCB production line, when a PCB circuit board enters the inspection station, the industrial camera captures multi-angle images of its surface. These images are then input into the pre-trained multi-light source synchronous imaging model. The model automatically calculates the required light source intensity adjustment parameters by analyzing the brightness distribution characteristics of each area, thereby optimizing the light intensity distribution in the image to make it more uniform, and generating a multi-light source fusion image to reduce the impact of shadows and reflections.
[0065] Next, the system performs optimization processing such as noise reduction on the generated multi-light source fusion image. Specifically, a series of filtering operations are performed to remove clutter and noise in the image, making the subtle solder joints, connections and other structures on the circuit board clearer, providing high-quality visual data for subsequent analysis.
[0066] Then, the feature extraction step is performed. The system automatically segments different areas using the processed image and extracts features related to the defect, such as texture, edge shape, etc. These features will be input into the multi-scale dynamic defect detection model, and the model determines the defect type by comparing the current features with the data in the known defect feature library. If the similarity exceeds the set threshold, it is determined that the corresponding defect exists in the area.
[0067] In addition, the system also analyzes the expansion trend of defects in the time dimension. If the detected defect evaluation value is greater than the preset maximum threshold, it means that the defect will cause a greater impact, and the system will determine the PCB board as a severe defect and scrap it; if the defect evaluation value is less than the preset minimum threshold, it means that the defect is minor and will not affect the function of the circuit board, and simple repair or observation can be performed; if the evaluation value is between the minimum and maximum thresholds, it means that the defect has developed to a certain extent, which will affect some functions of the PCB and require comprehensive repair or replacement.
[0068] In summary, the present invention realizes efficient and accurate detection of PCB circuit board defects through the collaborative work of a multi-light source synchronous imaging model and a multi-scale dynamic defect detection model.
[0069] Reference Figure 2 The second embodiment of the present invention provides a PCB circuit board defect detection device, comprising: A data acquisition module is used to acquire PCB circuit board image data; A multi-light source imaging module, used for 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; An image optimization module, used for performing image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image; A feature extraction module, used to perform region division and feature extraction operations according to 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.
[0070] It should be noted that a PCB circuit board defect detection device provided in an embodiment of the present invention is used to execute all process steps of a PCB circuit board defect detection method in the above embodiment. The working principles and beneficial effects of the two correspond one to one, and thus will not be described in detail.
[0071] 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 each module / unit in the above-mentioned device embodiments are implemented, such as the feature extraction module.
[0072] 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, which are used to describe the execution process of the computer program in the device.
[0073] The device may be a computing device such as a desktop computer, a notebook, a PDA, and a smart tablet. The device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the above components are merely examples of the device and do not constitute a limitation on the device. The device may include more or fewer components than the above, or a combination of certain components, or different components. For example, the device may also include input and output devices, network access devices, buses, etc.
[0074] 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) or 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, etc. The processor is the control center of the device, and various interfaces and lines are used to connect various parts of the entire device.
[0075] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0076] Wherein, if the module / unit integrated in the device is implemented in the form of 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 implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0077] It should be noted that the device embodiments described above are merely schematic, 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 on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying 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 may understand and implement it without paying any creative effort.
[0078] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. A PCB circuit board defect detection method, characterized in that: include: Get 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; According to the denoised grayscale image, performing region division and feature extraction operations to obtain features of each region; The features of each region are input into a pre-trained multi-scale dynamic defect detection model to obtain the PCB defect detection situation.
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-balanced 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-balanced 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: A multi-scale temporal convolutional network model is constructed based on texture changes, edge curvature, area ratio of circuit board defects and morphological characteristics of defects at different scales, and the multi-scale temporal convolutional network model is trained; 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: 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 multiple light source intensity adjustment parameters; According to the multi-light source intensity adjustment parameter, a light source adjustment operation is performed on the PCB circuit board image data to obtain imaging data under multiple light sources; An image fusion operation is performed according to the imaging data under the multiple light sources to obtain a multi-light source fused image.
5. The PCB circuit board defect detection method according to claim 4, characterized in that: The light source calibration and intensity calibration operations are performed according to the PCB circuit board image data to obtain multiple 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 The 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 of each pixel is obtained by the following formula: in Indicates 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 .
6. The PCB circuit board defect detection method according to claim 1, characterized in that: The inputting of the features of each region into a pre-trained multi-scale dynamic defect detection model to obtain PCB defect detection conditions 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 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 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 by the following formula: in, is the defect dynamic development trend assessment value, Indicates at a point in time When the potential risks and impacts of defects are 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 a weight coefficient of each indicator for the evaluation value of the dynamic development trend of defects; and the PCB defect detection situation is obtained according to the evaluation value of the dynamic development trend of defects.
7. The PCB circuit board defect detection method according to claim 6, characterized in that: The PCB defect detection situation 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 severely defective; in, , They are respectively the preset defect assessment low threshold and the defect assessment middle threshold.
8. A PCB circuit board defect detection device, characterized in that: include: A data acquisition module is used to acquire PCB circuit board image data; A multi-light source imaging module, used for 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; An image optimization module, used for performing image optimization processing on the multi-light source fusion image to obtain a noise-reduced grayscale image; A feature extraction module, used to perform region division and feature extraction operations according to 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.
9. An electronic device, characterized in that: It comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the PCB circuit board defect detection method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the PCB circuit board defect detection method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
PCB laser repairing method and device based on image detection
CN112557417A
Data processing method for integrated circuit manufacturing
CN113409251A
PCB (Printed Circuit Board) defect detection method based on improved Officient Det
CN116993660A
Exposure optimization method for circuit board printing
CN117876367A
Lens defect detection method and system, processor and storage medium
CN117929393A
Cited By
Shared massage chair operation state monitoring method, system, equipment and medium
CN119719933A
Printed circuit board defect detection system based on virtual reality technology
CN119722664A
Stitch quality detection method for automatic sewing of cover
CN120510132A
Defect detection method and system for automotive trim injection molded part based on visual inspection
CN120747000A
A visual detection-based defect detection method and system for an automobile interior injection molding part
CN120747000B