CN114897797A - Method, device and equipment for detecting defects of printed circuit board and storage medium - Google Patents

Method, device and equipment for detecting defects of printed circuit board and storage medium Download PDF

Info

Publication number
CN114897797A
CN114897797A CN202210434417.3A CN202210434417A CN114897797A CN 114897797 A CN114897797 A CN 114897797A CN 202210434417 A CN202210434417 A CN 202210434417A CN 114897797 A CN114897797 A CN 114897797A
Authority
CN
China
Prior art keywords
sample training
image
gradient
defect detection
printed circuit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210434417.3A
Other languages
Chinese (zh)
Inventor
李林峰
汪杨刚
高强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Haiwei Technology Co ltd
Original Assignee
Wuhan Haiwei Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Haiwei Technology Co ltd filed Critical Wuhan Haiwei Technology Co ltd
Priority to CN202210434417.3A priority Critical patent/CN114897797A/en
Publication of CN114897797A publication Critical patent/CN114897797A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • G06T7/0008Industrial image inspection checking presence/absence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/50Extraction of image or video features by performing operations within image blocks; by using histograms, e.g. histogram of oriented gradients [HoG]; by summing image-intensity values; Projection analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/774Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30141Printed circuit board [PCB]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Software Systems (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Image Analysis (AREA)

Abstract

The invention belongs to the technical field of detection, and discloses a method, a device, equipment and a storage medium for detecting defects of a printed circuit board. The method comprises the following steps: acquiring a sample training image of a sample printed circuit board and an image to be detected of a printed circuit board to be detected; performing feature calculation according to the sample training image to obtain sample training features corresponding to the sample training image; performing model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model; and carrying out defect detection on the image to be detected according to a preset defect detection model to obtain a defect detection result of the printed circuit board. By the method, the preset defect detection model capable of accurately identifying whether the printed circuit board has defects in the corresponding image is obtained, so that the image to be detected is subjected to defect detection based on the preset defect detection model, the defect detection precision and accuracy during PCB online detection are improved, and the requirement of PCB online defect detection is met.

Description

Method, device and equipment for detecting defects of printed circuit board and storage medium
Technical Field
The present invention relates to the field of inspection technologies, and in particular, to a method, an apparatus, a device, and a storage medium for inspecting defects of a printed circuit board.
Background
In the automatic production process of the vehicle-mounted screen, a Printed Circuit Board (PCB) is an important component of the vehicle-mounted screen, but in the production process of the PCB, defects such as missing, shifting and dislocation of PCB components often occur. The traditional manual detection can not meet the requirement of on-line detection, so that the machine vision detection of the PCB defects becomes the main detection means at present, but the detection precision in the prior art is lower.
Disclosure of Invention
The invention mainly aims to provide a method, a device, equipment and a storage medium for detecting the defects of a printed circuit board, and aims to solve the technical problem of low precision of the defect detection of the PCB in the prior art.
In order to achieve the above object, the present invention provides a method for detecting defects of a printed circuit board, the method comprising:
acquiring a sample training image of a sample printed circuit board and an image to be detected of a printed circuit board to be detected;
performing feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image;
performing model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model;
and carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
Optionally, the sample training features comprise at least one of a target size profile feature, an image variance feature, an orientation gradient histogram feature, an edge density feature, an average gradient strength feature, an accumulated gradient value feature, a fourier spectrum feature, and a correlation surface feature;
the performing feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image includes:
calculating the target size contour feature according to the sample training image to obtain the target size contour feature;
performing image variance feature calculation according to the sample training image to obtain an image variance feature;
carrying out cell division according to the sample training image to obtain a division unit;
calculating the direction histogram characteristics according to the dividing unit to obtain the direction histogram characteristics;
determining edge pixel values, row pixel elements and column pixel elements according to the sample training image;
performing edge density feature calculation according to the edge pixel values, the row pixel elements and the column pixel elements to obtain edge density features;
calculating average gradient strength according to the sample training image to obtain an average gradient strength characteristic;
determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image;
performing accumulated gradient value calculation according to the gradient of each pixel point in the coordinate direction to obtain an accumulated gradient value characteristic;
determining the size of an image according to the sample training image;
performing Fourier spectrum feature calculation according to the image size to obtain Fourier spectrum features;
and performing relevant surface feature calculation according to the sample training image to obtain relevant surface features.
Optionally, the calculating the target size contour feature according to the sample training image to obtain the target size contour feature includes:
determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image;
determining the gradient angle of each pixel point according to the gradient of the coordinate direction of each pixel point;
determining gradient direction entropy according to the gradient angle and a preset angle interval;
and determining the profile characteristics of the target size according to the gradient direction entropy and the corresponding number of the preset angle intervals.
Optionally, the performing, according to the sample training image, image variance feature calculation to obtain an image variance feature includes:
determining a gray value, a row pixel element and a column pixel element corresponding to each pixel point according to the sample training image;
determining an image gray average value according to the gray value corresponding to each pixel point;
and determining the image variance characteristics according to the gray value, the row pixel elements, the column pixel elements and the image gray average value corresponding to each pixel point.
Optionally, the calculating an average gradient strength according to the sample training image to obtain an average gradient strength characteristic includes:
determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image;
determining the gradient intensity value of each pixel point according to the gradient of the coordinate direction of each pixel point;
determining a gradient intensity map of the sample training image according to the gradient intensity values;
carrying out mean value filtering operation according to the gradient intensity graph to obtain an average gradient intensity graph;
determining an average gradient intensity characteristic from the average gradient intensity map.
Optionally, the performing, according to the sample training image, correlation surface feature calculation to obtain a correlation surface feature includes:
carrying out cell division according to the sample training image to obtain a division unit;
performing gradient intensity calculation according to the partition unit image corresponding to the partition unit and the sample training image to obtain a first gradient intensity corresponding to the sample training image and a second gradient intensity corresponding to the partition unit image;
and calculating a correlation coefficient according to the first gradient strength, the second gradient strength, the sample training image and the division unit image to obtain the characteristics of the correlation surface.
Optionally, the performing model training according to the sample training features and the sample training images to obtain a preset defect detection model includes:
acquiring a preset evaluation index;
performing model training according to the sample training characteristics and the sample training images to obtain an initial training model and a confusion matrix index of the initial training model;
performing model evaluation according to the preset evaluation index and the confusion matrix index to obtain an evaluation result;
and when the evaluation result is a preset result, obtaining a preset defect detection model according to the initial training model.
In addition, in order to achieve the above object, the present invention also provides a defect detecting apparatus for a printed circuit board, including:
the acquisition module is used for acquiring a sample training image of a sample printed circuit board and an image to be detected of a printed circuit board to be detected;
the calculation module is used for carrying out feature calculation according to the sample training images to obtain sample training features corresponding to the sample training images;
the training module is used for carrying out model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model;
and the detection module is used for carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
Further, to achieve the above object, the present invention also provides a defect detecting apparatus of a printed circuit board, including: the defect detection program of the printed circuit board is configured to realize the defect detection method of the printed circuit board.
In addition, in order to achieve the above object, the present invention further provides a storage medium, on which a defect detection program of a printed circuit board is stored, the defect detection program of the printed circuit board, when being executed by a processor, implementing the defect detection method of the printed circuit board as described above.
The method comprises the steps of obtaining a sample training image of a sample printed circuit board and an image to be detected of the printed circuit board to be detected; performing feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image; performing model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model; and carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board. By the mode, model training is carried out on the sample training characteristics corresponding to the sample training images of the sample printed circuit board, and the preset defect detection model which can accurately identify whether defects exist in the corresponding images of the printed circuit board is obtained, so that defect detection is carried out on the images to be detected based on the preset defect detection model, the defect detection precision and accuracy during PCB online detection are improved, and the requirement of PCB online defect detection is met.
Drawings
FIG. 1 is a schematic structural diagram of a defect detection apparatus for a printed circuit board in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart illustrating a method for detecting defects of a printed circuit board according to a first embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for detecting defects of a printed circuit board according to a second embodiment of the present invention;
FIG. 4 is a block diagram of a defect detecting apparatus for a printed circuit board according to a first embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a defect detection device of a printed circuit board in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the defect detecting apparatus of the printed circuit board may include: a processor 1001, such as a Central Processing Unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a Wireless interface (e.g., a Wireless-Fidelity (Wi-Fi) interface). The Memory 1005 may be a Random Access Memory (RAM) Memory, or may be a Non-Volatile Memory (NVM), such as a disk Memory. The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration shown in fig. 1 does not constitute a limitation of the defect detection apparatus of a printed circuit board, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a storage medium, may include therein a defect detection program of an operating system, a network communication module, a user interface module, and a printed circuit board.
In the defect inspection apparatus of a printed circuit board shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 of the defect inspection apparatus of the printed circuit board according to the present invention may be provided in the defect inspection apparatus of the printed circuit board, which calls the defect inspection program of the printed circuit board stored in the memory 1005 through the processor 1001 and executes the defect inspection method of the printed circuit board according to the embodiment of the present invention.
An embodiment of the present invention provides a method for detecting defects of a printed circuit board, and referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of the method for detecting defects of a printed circuit board according to the present invention.
The defect detection method of the printed circuit board comprises the following steps:
step S10: and acquiring a sample training image of the sample printed circuit board and an image to be detected of the printed circuit board to be detected.
It should be noted that the main execution body of this embodiment is a terminal device, a defect detection system of the printed circuit board is installed on the terminal device, when the terminal device receives a detection instruction, the detection instruction is forwarded to the defect detection system of the printed circuit board, and the defect detection system of the printed circuit board obtains the sample training image and the image to be detected according to the detection instruction. And performing feature calculation according to the sample training images to obtain sample training features corresponding to each sample training image, and performing model training according to the sample training features and the sample training images to obtain a preset defect detection model. And carrying out defect detection on the image to be detected based on the obtained preset defect detection model to obtain a defect detection result of the printed circuit board.
It is understood that a plurality of sample training images of the sample printed circuit board are obtained from the predetermined database, and the sample training images may be defective sample training images or non-defective sample training images. And finally, storing the sample training images and the corresponding labels of all the sample printed circuit boards to obtain a sample training image data set.
In a specific implementation, the image to be detected is an image corresponding to the printed circuit board to be detected.
Step S20: and performing feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image.
It should be noted that the sample training feature refers to an image feature value obtained by performing feature calculation based on a sample training image, and the sample training feature includes at least one of a target size profile feature, an image variance feature, a directional gradient histogram feature, an edge density feature, an average gradient intensity feature, an accumulated gradient value feature, a fourier spectrum feature, and a correlation plane feature.
Step S30: and carrying out model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model.
It should be noted that the sample training features and the corresponding sample training images are split according to a preset ratio to obtain a test set and a training set. And performing model training fitting according to the training set by adopting a GBDT (Gradient Boosting Decision Tree), and performing a detection experiment on the initial training model after the model training according to the test set to finally obtain a preset defect detection model capable of accurately identifying whether the defects exist in the corresponding image of the printed circuit board.
It can be understood that, in order to ensure the accuracy of model training and improve the precision of subsequent defect detection, further, the model training is performed according to the sample training features and the sample training images to obtain a preset defect detection model, including: acquiring a preset evaluation index; performing model training according to the sample training characteristics and the sample training images to obtain an initial training model and a confusion matrix index of the initial training model; performing model evaluation according to the preset evaluation index and the confusion matrix index to obtain an evaluation result; and when the evaluation result is a preset result, obtaining a preset defect detection model according to the initial training model.
In a specific implementation, the preset evaluation index refers to an index at which a preset model can stop training. And performing model training by adopting a GBDT classification algorithm according to the sample training characteristics and the sample training images to obtain an initial training model and a confusion matrix index of the initial training model. And performing model evaluation on the preset evaluation index and the confusion matrix index to obtain an evaluation result whether the confusion matrix index meets the requirement. And when the evaluation result is a preset result that the confusion matrix index meets the requirement, taking the initial training model as a preset defect detection model. When the evaluation result is that the confusion matrix index does not meet the requirement, training parameters during model training, such as step length, learning rate, iteration times and the number of nodes of model classification, need to be adjusted according to preset evaluation indexes, and then model training is performed again.
Step S40: and carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
After the preset defect detection model is obtained, the image to be detected is input to the preset defect detection model to perform defect detection on the image to be detected, so that a defect detection result of whether components are missing, offset, misplaced and the like exists in the printed circuit board is obtained.
The embodiment obtains a sample training image of a sample printed circuit board and an image to be detected of the printed circuit board to be detected; performing feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image; performing model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model; and carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board. By the mode, model training is carried out on the basis of the sample training features corresponding to the sample training images of the sample printed circuit board, and the preset defect detection model capable of accurately identifying whether defects exist in the corresponding images of the printed circuit board is obtained, so that defect detection is carried out on the image to be detected on the basis of the preset defect detection model, the defect detection precision and accuracy during PCB online detection are improved, and the requirement for PCB online defect detection is met.
Referring to fig. 3, fig. 3 is a flowchart illustrating a method for detecting defects of a printed circuit board according to a second embodiment of the present invention.
Based on the first embodiment, the sample training features include at least one of a target size profile feature, an image variance feature, an orientation gradient histogram feature, an edge density feature, an average gradient intensity feature, an accumulated gradient value feature, a fourier spectrum feature, and a correlation plane feature, in the method for detecting defects of a printed circuit board of this embodiment, the step S20 includes:
step S21: and calculating the target size contour feature according to the sample training image to obtain the target size contour feature.
It should be noted that the target-size contour feature is a large-scale contour feature H corresponding to each sample training image nor
It will be appreciated that in order to obtain an accurate target dimension profile feature H nor Further, the calculating the target size contour feature according to the sample training image to obtain the target size contour feature includes: determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image; determining the gradient angle of each pixel point according to the gradient of the coordinate direction of each pixel point; determining gradient direction entropy according to the gradient angle and a preset angle interval; and determining the profile characteristics of the target size according to the gradient direction entropy and the corresponding number of the preset angle intervals.
In a specific implementation, the gradient of each pixel in the coordinate direction refers to the gradient G of each pixel in the x direction in the sample training image x Gradient G in (x, y) and y directions y (x, y). The gradient angle of each pixel point refers to the gradient angle of each pixel point
Figure BDA0003612421090000081
It should be noted that the preset angle interval refers to n angle intervals obtained by equally dividing the gradient direction of 0 to 360 degrees into n intervals. n is the corresponding number of the preset angle intervals, and the sample pixel image is subjected to cell division to obtain a plurality of division units with the size being aboutw h 10, calculating the pixel probability p of each division unit in each sample pixel image in each preset angle interval i . Respectively counting the probability of each direction in the histogram of the gradient direction of the partition unit, thereby obtaining the entropy of the gradient direction of each partition unit
Figure BDA0003612421090000082
In obtaining the gradient direction entropy
Figure BDA0003612421090000083
Then, according to the definition of the entropy, under the condition that the gradient occurrence probability of each direction is equal, the entropy takes the maximum value to obtain the entropy of the normalized gradient direction
Figure BDA0003612421090000091
Wherein,
Figure BDA0003612421090000092
counting the normalized entropy values, sorting the pixel points in the H from large to small, and weighting the points accounting for the first 30% of the pixel number in the sorting result, namely the value of the final target area of the stroke
Figure BDA0003612421090000093
w and H are the width and height, respectively, of the target region, H nor Is the target dimension profile characteristic
Step S22: and performing image variance characteristic calculation according to the sample training image to obtain an image variance characteristic.
The image variance characteristic refers to a gray-scale variance characteristic of an image, and reflects the fluctuation degree of the entire image gray scale. Performing image variance feature calculation according to the sample training image to obtain an image variance feature V ar
It can be understood that, in order to obtain an accurate image variance feature, further, the performing an image variance feature calculation according to the sample training image to obtain an image variance feature includes: determining a gray value, a row pixel element and a column pixel element corresponding to each pixel point according to the sample training image; determining an image gray average value according to the gray value corresponding to each pixel point; and determining the image variance characteristics according to the gray value, the row pixel elements, the column pixel elements and the image gray average value corresponding to each pixel point.
In the specific implementation, the gray value X (i, j), (i, j) refers to the coordinate of the pixel point, and the row pixel m and the column pixel n of the sample training image, which correspond to each pixel point, are determined according to the sample training image. Determining the average value E (X (i, j)) of the gray level of the sample training image according to the gray level corresponding to each pixel point, and determining the variance characteristic of the image according to the gray level corresponding to each pixel point, the row pixel element, the column pixel element and the average value of the gray level of the image
Figure BDA0003612421090000094
Step S23: and carrying out cell division according to the sample training image to obtain a division unit.
The sample training image is divided into cells to obtain divided cells having the same size.
Step S24: and calculating the directional histogram characteristics according to the dividing unit to obtain the directional histogram characteristics.
It should be noted that, the sum of entropy values of all the division units is calculated to obtain the Hog entropy of the histogram feature.
Step S25: and determining edge pixel values, row pixel elements and column pixel elements according to the sample training image.
It should be noted that, an edge pixel value is obtained through an edge operator according to the sample training image, and a row pixel m and a column pixel n of the sample training image are determined.
Step S26: and calculating the edge density characteristic according to the edge pixel value, the row pixel pixels and the column pixel pixels to obtain the edge density characteristic.
The edge density feature is used to determine whether the edge feature distribution in the sample training image is dense, and is an index reflecting the image information amount. Based on edge pixel values, row pixels, andthe edge density feature can be obtained by calculating the edge density feature of the column pixel
Figure BDA0003612421090000101
Where edge is the absolute value of the edge pixel value.
Step S27: and calculating the average gradient strength according to the sample training image to obtain the average gradient strength characteristic.
It should be noted that, the average gradient intensity may be calculated according to the sample training image to obtain the average gradient intensity characteristic.
It is to be understood that, in order to obtain an accurate average gradient strength, further, the calculating an average gradient strength according to the sample training image to obtain an average gradient strength characteristic includes: determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image; determining the gradient intensity value of each pixel point according to the gradient of the coordinate direction of each pixel point; determining a gradient intensity map of the sample training image according to the gradient intensity values; carrying out mean value filtering operation according to the gradient intensity graph to obtain an average gradient intensity graph; determining an average gradient intensity characteristic from the average gradient intensity map.
In a specific implementation, the gradient of each pixel in the coordinate direction refers to the gradient G of each pixel in the x direction in the sample training image x Gradient G in (x, y) and y directions y (x, y), then obtaining the gradient intensity value of each pixel point
Figure BDA0003612421090000102
Thereby obtaining a gradient intensity map of the sample training image. And carrying out cell division on the sample training image to obtain a division unit, and carrying out mean value filtering operation by taking the size of the division unit as a template to obtain an average gradient intensity graph of the division unit. And according to the average gradient intensity map ranking, taking the average value of the top 30% of the gradient intensity values as the average gradient intensity value of the sample training image.
Step S28: and determining the gradient of each pixel point in the sample training image in the coordinate direction according to the sample training image.
It should be noted that the gradient of each pixel in the coordinate direction refers to the gradient G of each pixel in the x direction in the sample training image x Gradient G in (x, y) and y directions y (x,y)。
Step S29: and calculating an accumulated gradient value according to the gradient of each pixel point in the coordinate direction to obtain an accumulated gradient value characteristic.
It should be noted that the cumulative gradient value feature describes the sum of gradient strengths in a region, and the stronger the number of edges accumulated in a region, the more obvious the gradient feature. Calculating the accumulated gradient value according to the gradient of each pixel point in the coordinate direction, and accumulating the gradient value characteristics
Figure BDA0003612421090000111
Finally, the product is processed
Figure BDA0003612421090000112
Step S210: and determining the image size according to the sample training image.
The original size I of the sample training image is determined from the sample training image.
Step S211: and performing Fourier spectrum feature calculation according to the image size to obtain Fourier spectrum features.
The fourier spectrum feature describes texture features of a sample training image, and after obtaining an image size, a fourier transform energy map FI of the sample training image is obtained, where FI ═ f (I) |, f (I) is a two-dimensional fourier transform of I, FI is also m × n, E ═ sum (FI) > sum [ | f (I) | ], and E is a fourier energy sum, and then
Figure BDA0003612421090000113
Figure BDA0003612421090000114
Figure BDA0003612421090000115
Figure BDA0003612421090000116
Among them, BW2, BW4, BW8, BW16 are referred to as 1/2 radius energy sum, 1/4 radius energy sum, 1/8 radius energy sum, 1/16 radius energy sum, respectively.
Step S212: and performing relevant surface feature calculation according to the sample training image to obtain relevant surface features.
It should be noted that the correlation surface feature refers to a correlation coefficient between the sample training image and the partition unit image.
It can be understood that, in order to obtain an accurate correlation surface feature, further, the performing correlation surface feature calculation according to the sample training image to obtain a correlation surface feature includes: carrying out cell division according to the sample training image to obtain a division unit; performing gradient intensity calculation according to the division unit image corresponding to the division unit and the sample training image to obtain a first gradient intensity corresponding to the sample training image and a second gradient intensity corresponding to the division unit image; and calculating a correlation coefficient according to the first gradient strength, the second gradient strength, the sample training image and the division unit image to obtain the characteristics of the correlation surface.
In the specific implementation, cell division is performed according to a sample training image to obtain division units with the same size, and division unit images corresponding to the division units are obtained. The first gradient strength refers to the gradient strength of the sample training image at each pixel point
Figure BDA0003612421090000121
The second gradient strength refers to the gradient strength of the divided unit image at each pixel point
Figure BDA0003612421090000122
It should be noted that, correlation coefficient calculation may be performed to obtain the correlation surface feature after obtaining the first gradient strength, the second gradient strength, the sample training image, and the partition unit image. The dividing unit image traverses on the sample training image by taking pixels as the layout length, the size of the correlation surface coefficient S is (W-W +1) × (H-H +1), and each pixel value is the correlation coefficient value of the corresponding area of the dividing unit image and the sample training image. The local maximum value in the correlation surface is a peak value, the size of the local range is set by the outside, and finally the characteristics of the correlation surface
Figure BDA0003612421090000123
Wherein, e (ai) is the mean of the gradient intensities of the image of the partition unit, and e (ai) is the mean of the gradient intensities of the corresponding regions of the sample training image. (x, y) is the coordinates of the upper left corner of the divided unit image map in the sample training image.
In the embodiment, target size contour features are calculated according to the sample training images to obtain the target size contour features; performing image variance feature calculation according to the sample training image to obtain an image variance feature; carrying out cell division according to the sample training image to obtain a division unit; calculating the direction histogram feature according to the dividing unit to obtain the direction histogram feature; determining edge pixel values, row pixel elements and column pixel elements according to the sample training image; performing edge density feature calculation according to the edge pixel values, the row pixel elements and the column pixel elements to obtain edge density features; calculating average gradient strength according to the sample training image to obtain average gradient strength characteristics; determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image; calculating an accumulated gradient value according to the gradient of each pixel point in the coordinate direction to obtain an accumulated gradient value characteristic; determining an image size according to the sample training image; performing Fourier spectrum feature calculation according to the image size to obtain Fourier spectrum features; and performing correlation surface feature calculation according to the sample training image to obtain correlation surface features. Therefore, accurate sample training characteristics can be obtained, and accurate training data is provided for subsequent model training.
In addition, referring to fig. 4, an embodiment of the present invention further provides a defect detecting apparatus for a printed circuit board, where the defect detecting apparatus for a printed circuit board includes:
the acquisition module 10 is used for acquiring a sample training image of a sample printed circuit board and an image to be detected of a printed circuit board to be detected.
And the calculating module 20 is configured to perform feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image.
And the training module 30 is configured to perform model training according to the sample training features and the sample training images to obtain a preset defect detection model.
And the detection module 40 is used for carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
The embodiment comprises the steps of obtaining a sample training image of a sample printed circuit board and an image to be detected of a printed circuit board to be detected; performing feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image; performing model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model; and carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board. By the mode, model training is carried out on the sample training characteristics corresponding to the sample training images of the sample printed circuit board, and the preset defect detection model which can accurately identify whether defects exist in the corresponding images of the printed circuit board is obtained, so that defect detection is carried out on the images to be detected based on the preset defect detection model, the defect detection precision and accuracy during PCB online detection are improved, and the requirement of PCB online defect detection is met.
In an embodiment, the calculating module 20 is further configured to perform target size contour feature calculation according to the sample training image to obtain a target size contour feature;
performing image variance feature calculation according to the sample training image to obtain an image variance feature;
carrying out cell division according to the sample training image to obtain a division unit;
calculating the direction histogram characteristics according to the dividing unit to obtain the direction histogram characteristics;
determining edge pixel values, row pixel elements and column pixel elements according to the sample training image;
performing edge density feature calculation according to the edge pixel values, the row pixel elements and the column pixel elements to obtain edge density features;
calculating average gradient strength according to the sample training image to obtain average gradient strength characteristics;
determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image;
performing accumulated gradient value calculation according to the gradient of each pixel point in the coordinate direction to obtain an accumulated gradient value characteristic;
determining the size of an image according to the sample training image;
performing Fourier spectrum feature calculation according to the image size to obtain Fourier spectrum features;
and performing relevant surface feature calculation according to the sample training image to obtain relevant surface features.
In an embodiment, the calculating module 20 is further configured to determine, according to the sample training image, a gradient of a coordinate direction of each pixel point in the sample training image;
determining the gradient angle of each pixel point according to the gradient of the coordinate direction of each pixel point;
determining gradient direction entropy according to the gradient angle and a preset angle interval;
and determining the profile characteristics of the target size according to the gradient direction entropy and the corresponding number of the preset angle intervals.
In an embodiment, the calculating module 20 is further configured to determine, according to the sample training image, a gray value, row pixel elements, and column pixel elements corresponding to each pixel point;
determining an image gray average value according to the gray value corresponding to each pixel point;
and determining the image variance characteristics according to the gray value, the row pixel elements, the column pixel elements and the image gray average value corresponding to each pixel point.
In an embodiment, the calculating module 20 is further configured to determine, according to the sample training image, a gradient of a coordinate direction of each pixel point in the sample training image;
determining the gradient intensity value of each pixel point according to the gradient of the coordinate direction of each pixel point;
determining a gradient intensity map of the sample training image according to the gradient intensity values;
carrying out mean value filtering operation according to the gradient intensity graph to obtain an average gradient intensity graph;
determining an average gradient intensity characteristic from the average gradient intensity map.
In an embodiment, the calculating module 20 is further configured to perform cell division according to the sample training image to obtain a division unit;
performing gradient intensity calculation according to the partition unit image corresponding to the partition unit and the sample training image to obtain a first gradient intensity corresponding to the sample training image and a second gradient intensity corresponding to the partition unit image;
and calculating a correlation coefficient according to the first gradient strength, the second gradient strength, the sample training image and the division unit image to obtain the characteristics of the correlation surface.
In an embodiment, the training module 30 is further configured to obtain a preset evaluation index;
performing model training according to the sample training characteristics and the sample training images to obtain an initial training model and a confusion matrix index of the initial training model;
performing model evaluation according to the preset evaluation index and the confusion matrix index to obtain an evaluation result;
and when the evaluation result is a preset result, obtaining a preset defect detection model according to the initial training model.
Since the present apparatus employs all technical solutions of all the above embodiments, at least all the beneficial effects brought by the technical solutions of the above embodiments are achieved, and are not described in detail herein.
In addition, an embodiment of the present invention further provides a storage medium, where a defect detection program of a printed circuit board is stored, and the defect detection program of the printed circuit board, when executed by a processor, implements the steps of the defect detection method of the printed circuit board as described above.
Since the storage medium adopts all technical solutions of all the embodiments, at least all the beneficial effects brought by the technical solutions of the embodiments are achieved, and no further description is given here.
It should be noted that the above-mentioned work flows are only illustrative and do not limit the scope of the present invention, and in practical applications, those skilled in the art may select some or all of them according to actual needs to implement the purpose of the solution of the present embodiment, and the present invention is not limited herein.
In addition, the technical details that are not described in detail in this embodiment may be referred to a defect detection method of a printed circuit board provided in any embodiment of the present invention, and are not described herein again.
Further, it is to be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages and disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention or portions thereof that contribute to the prior art may be embodied in the form of a software product, where the computer software product is stored in a storage medium (e.g. Read Only Memory (ROM)/RAM, magnetic disk, optical disk), and includes several instructions for enabling a terminal device (e.g. a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A defect detection method of a printed circuit board is characterized by comprising the following steps:
acquiring a sample training image of a sample printed circuit board and an image to be detected of a printed circuit board to be detected;
performing feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image;
performing model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model;
and carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
2. The method of claim 1, wherein the sample training features include at least one of target size profile features, image variance features, histogram of oriented gradient features, edge density features, mean gradient intensity features, cumulative gradient value features, fourier spectrum features, and correlation plane features;
the performing feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image includes:
calculating the target size contour feature according to the sample training image to obtain the target size contour feature;
performing image variance feature calculation according to the sample training image to obtain an image variance feature;
carrying out cell division according to the sample training image to obtain a division unit;
calculating the direction histogram characteristics according to the dividing unit to obtain the direction histogram characteristics;
determining edge pixel values, row pixel elements and column pixel elements according to the sample training image;
performing edge density feature calculation according to the edge pixel values, the row pixel elements and the column pixel elements to obtain edge density features;
calculating average gradient strength according to the sample training image to obtain average gradient strength characteristics;
determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image;
performing accumulated gradient value calculation according to the gradient of each pixel point in the coordinate direction to obtain an accumulated gradient value characteristic;
determining an image size according to the sample training image;
performing Fourier spectrum feature calculation according to the image size to obtain Fourier spectrum features;
and performing relevant surface feature calculation according to the sample training image to obtain relevant surface features.
3. The method of claim 2, wherein the calculating the target size profile features according to the sample training image to obtain the target size profile features comprises:
determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image;
determining the gradient angle of each pixel point according to the gradient of the coordinate direction of each pixel point;
determining gradient direction entropy according to the gradient angle and a preset angle interval;
and determining the profile characteristics of the target size according to the gradient direction entropy and the corresponding number of the preset angle intervals.
4. The method of claim 2, wherein the performing image variance feature calculation based on the sample training image to obtain an image variance feature comprises:
determining a gray value, a row pixel element and a column pixel element corresponding to each pixel point according to the sample training image;
determining an image gray average value according to the gray value corresponding to each pixel point;
and determining the image variance characteristics according to the gray value, the row pixel elements, the column pixel elements and the image gray average value corresponding to each pixel point.
5. The method of claim 2, wherein the calculating an average gradient strength from the sample training image to obtain an average gradient strength characteristic comprises:
determining the gradient of each pixel point coordinate direction in the sample training image according to the sample training image;
determining the gradient intensity value of each pixel point according to the gradient of the coordinate direction of each pixel point;
determining a gradient intensity map of the sample training image according to the gradient intensity values;
carrying out mean value filtering operation according to the gradient intensity graph to obtain an average gradient intensity graph;
determining an average gradient intensity characteristic from the average gradient intensity map.
6. The method of claim 2, wherein the calculating the correlation surface features according to the sample training image to obtain the correlation surface features comprises:
carrying out cell division according to the sample training image to obtain a division unit;
performing gradient intensity calculation according to the partition unit image corresponding to the partition unit and the sample training image to obtain a first gradient intensity corresponding to the sample training image and a second gradient intensity corresponding to the partition unit image;
and calculating a correlation coefficient according to the first gradient strength, the second gradient strength, the sample training image and the division unit image to obtain the characteristics of the correlation surface.
7. The method of claim 1, wherein the performing model training based on the sample training features and the sample training images to obtain a predetermined defect detection model comprises:
acquiring a preset evaluation index;
performing model training according to the sample training characteristics and the sample training images to obtain an initial training model and a confusion matrix index of the initial training model;
performing model evaluation according to the preset evaluation index and the confusion matrix index to obtain an evaluation result;
and when the evaluation result is a preset result, obtaining a preset defect detection model according to the initial training model.
8. A defect detecting apparatus of a printed circuit board, comprising:
the acquisition module is used for acquiring a sample training image of a sample printed circuit board and an image to be detected of a printed circuit board to be detected;
the calculation module is used for carrying out feature calculation according to the sample training image to obtain a sample training feature corresponding to the sample training image;
the training module is used for carrying out model training according to the sample training characteristics and the sample training images to obtain a preset defect detection model;
and the detection module is used for carrying out defect detection on the image to be detected according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
9. A defect inspection apparatus of a printed circuit board, the apparatus comprising: a memory, a processor and a defect detection program of a printed circuit board stored on the memory and executable on the processor, the defect detection program of the printed circuit board being configured to implement the defect detection method of the printed circuit board according to any one of claims 1 to 7.
10. A storage medium having stored thereon a defect detection program of a printed circuit board, the defect detection program of the printed circuit board realizing the defect detection method of the printed circuit board according to any one of claims 1 to 7 when executed by a processor.
CN202210434417.3A 2022-04-24 2022-04-24 Method, device and equipment for detecting defects of printed circuit board and storage medium Pending CN114897797A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210434417.3A CN114897797A (en) 2022-04-24 2022-04-24 Method, device and equipment for detecting defects of printed circuit board and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210434417.3A CN114897797A (en) 2022-04-24 2022-04-24 Method, device and equipment for detecting defects of printed circuit board and storage medium

Publications (1)

Publication Number Publication Date
CN114897797A true CN114897797A (en) 2022-08-12

Family

ID=82716780

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210434417.3A Pending CN114897797A (en) 2022-04-24 2022-04-24 Method, device and equipment for detecting defects of printed circuit board and storage medium

Country Status (1)

Country Link
CN (1) CN114897797A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117132599A (en) * 2023-10-26 2023-11-28 深圳市利器精工科技有限公司 Circuit board defect detection method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117132599A (en) * 2023-10-26 2023-11-28 深圳市利器精工科技有限公司 Circuit board defect detection method and device, electronic equipment and storage medium
CN117132599B (en) * 2023-10-26 2024-04-09 深圳市利器精工科技有限公司 Circuit board defect detection method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN114266773B (en) Display panel defect positioning method, device, equipment and storage medium
CN113421263B (en) Part defect detection method, device, medium and computer program product
CN109977997B (en) Image target detection and segmentation method based on convolutional neural network rapid robustness
CN114612469B (en) Product defect detection method, device and equipment and readable storage medium
CN109726746B (en) Template matching method and device
CN111160469A (en) Active learning method of target detection system
CN110766095B (en) Defect detection method based on image gray level features
CN112070079B (en) X-ray contraband package detection method and device based on feature map weighting
CN114155244B (en) Defect detection method, device, equipment and storage medium
CN111242899B (en) Image-based flaw detection method and computer-readable storage medium
CN113205511B (en) Electronic component batch information detection method and system based on deep neural network
CN117392042A (en) Defect detection method, defect detection apparatus, and storage medium
TW201606854A (en) Automatic calibration sample selection for die-to-database photomask inspection
CN116740652B (en) Method and system for monitoring rust area expansion based on neural network model
CN117994250B (en) Wafer defect detection method, device, equipment and storage medium
CN116542975A (en) Defect classification method, device, equipment and medium for glass panel
CN115578377A (en) Panel defect detection method, training method, device, equipment and medium
CN114897797A (en) Method, device and equipment for detecting defects of printed circuit board and storage medium
CN113469302A (en) Multi-circular target identification method and system for video image
CN117523557A (en) Method, device, equipment and medium for detecting space transcriptome chip
CN116523871A (en) Method and device for detecting defects of machined part, electronic equipment and storage medium
CN114359300B (en) Optimization method, device and system of image segmentation model and storage medium
CN114170229B (en) Method, device and equipment for registering defect images of printed circuit board and storage medium
CN115330705A (en) Skin paint surface defect detection method based on adaptive weighting template NCC
CN111127485B (en) Method, device and equipment for extracting target area in CT image

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination