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 PDFInfo
- 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
- image
- sample training
- defect detection
- printed circuit
- circuit board
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
- G06T7/0004—Industrial image inspection
- G06T7/0008—Industrial image inspection checking presence/absence
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N20/00—Machine learning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/44—Local 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
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/50—Extraction 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
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/77—Processing 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/774—Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30108—Industrial image inspection
- G06T2207/30141—Printed circuit board [PCB]
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing 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
Description
技术领域technical field
本发明涉及检测技术领域,尤其涉及一种印刷电路板的缺陷检测方法、装置、设备及存储介质。The present invention relates to the technical field of detection, and in particular, to a method, device, equipment and storage medium for defect detection of printed circuit boards.
背景技术Background technique
在车载屏幕自动化生产过程中,PCB(Printed Circuit Board,印刷电路板)是其重要组成部分,但在PCB生产过程中,往往会出现PCB元器件缺失,偏移以及错位等缺陷。传统的人工检测无法满足在线检测的要求,因此机器视觉检测PCB缺陷成为目前主要的检测手段,但现有技术中检测精度较低。In the automatic production process of vehicle screen, PCB (Printed Circuit Board, printed circuit board) is an important part, but in the process of PCB production, defects such as missing, offset and dislocation of PCB components often occur. Traditional manual inspection cannot meet the requirements of online inspection, so machine vision inspection of PCB defects has become the main inspection method at present, but the inspection accuracy in the existing technology is low.
发明内容SUMMARY OF THE INVENTION
本发明的主要目的在于提供一种印刷电路板的缺陷检测方法、装置、设备及存储介质,旨在解决现有技术中PCB的缺陷检测精度较低的技术问题。The main purpose of the present invention is to provide a method, device, equipment and storage medium for defect detection of a printed circuit board, aiming to solve the technical problem of low detection accuracy of PCB defects in the prior art.
为实现上述目的,本发明提供了一种印刷电路板的缺陷检测方法,所述印刷电路板的缺陷检测方法包括:In order to achieve the above object, the present invention provides a method for detecting defects of printed circuit boards, the method for detecting defects of printed circuit boards includes:
获取样本印刷电路板的样本训练图像和待检测印刷电路板的待检测图像;Obtain the sample training image of the sample printed circuit board and the to-be-tested image of the to-be-tested printed circuit board;
根据所述样本训练图像进行特征计算,得到所述样本训练图像对应的样本训练特征;Perform feature calculation according to the sample training image to obtain sample training features corresponding to the sample training image;
根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型;Perform model training according to the sample training features and the sample training images to obtain a preset defect detection model;
根据所述预设缺陷检测模型对所述待检测图像进行缺陷检测,得到所述印刷电路板的缺陷检测结果。Perform defect detection on the to-be-detected image according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
可选地,所述样本训练特征包括目标尺寸轮廓特征、图像方差特征、方向梯度直方图特征、边缘密度特征、平均梯度强度特征、累加梯度值特征、傅里叶频谱特征以及相关面特征中的至少一项;Optionally, the sample training features include target size profile features, image variance features, directional gradient histogram features, edge density features, average gradient strength features, accumulated gradient value features, Fourier spectrum features, and correlation surface features. at least one;
所述根据所述样本训练图像进行特征计算,得到所述样本训练图像对应的样本训练特征,包括:The feature calculation is performed according to the sample training image to obtain the sample training feature corresponding to the sample training image, including:
根据所述样本训练图像进行目标尺寸轮廓特征计算,得到目标尺寸轮廓特征;Perform target size contour feature calculation according to the sample training image to obtain target size contour features;
根据所述样本训练图像进行图像方差特征计算,得到图像方差特征;Perform image variance feature calculation according to the sample training image to obtain image variance feature;
根据所述样本训练图像进行单元格划分,得到划分单元;Cell division is performed according to the sample training image to obtain division cells;
根据所述划分单元进行方向直方图特征计算,得到方向直方图特征;Perform direction histogram feature calculation according to the dividing unit to obtain the direction histogram feature;
根据所述样本训练图像确定边缘像素值、行像元素以及列像元素;Determine edge pixel values, row image elements and column image elements according to the sample training image;
根据所述边缘像素值、行像元素以及列像元素进行边缘密度特征计算,得到边缘密度特征;Perform edge density feature calculation according to the edge pixel value, row image element and column image element to obtain edge density feature;
根据所述样本训练图像进行平均梯度强度计算,得到平均梯度强度特征;Calculate the average gradient intensity according to the sample training image to obtain the average gradient intensity feature;
根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;Determine the gradient of each pixel coordinate direction in the sample training image according to the sample training image;
根据所述各像素点坐标方向的梯度进行累加梯度值计算,得到累加梯度值特征;Calculate the cumulative gradient value according to the gradient in the coordinate direction of each pixel point to obtain the cumulative gradient value feature;
根据所述样本训练图像确定图像尺寸;Determine the image size according to the sample training image;
根据所述图像尺寸进行傅里叶频谱特征计算,得到傅里叶频谱特征;Perform Fourier spectral feature calculation according to the image size to obtain Fourier spectral features;
根据所述样本训练图像进行相关面特征计算,得到相关面特征。The relevant surface feature is calculated according to the sample training image to obtain the relevant surface feature.
可选地,所述根据所述样本训练图像进行目标尺寸轮廓特征计算,得到目标尺寸轮廓特征,包括:Optionally, performing target size contour feature calculation according to the sample training image to obtain target size contour features, including:
根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;Determine the gradient of each pixel coordinate direction in the sample training image according to the sample training image;
根据所述各像素点坐标方向的梯度确定所述各像素点的梯度角度;Determine the gradient angle of each pixel point according to the gradient of the coordinate direction of each pixel point;
根据所述梯度角度和预设角度区间确定梯度方向熵;Determine the gradient direction entropy according to the gradient angle and the preset angle interval;
根据所述梯度方向熵和所述预设角度区间对应数量确定目标尺寸轮廓特征。The target size contour feature is determined according to the gradient direction entropy and the corresponding quantity of the preset angle interval.
可选地,所述根据所述样本训练图像进行图像方差特征计算,得到图像方差特征,包括:Optionally, the image variance feature calculation is performed according to the sample training image to obtain the image variance feature, including:
根据所述样本训练图像确定各像素点对应的灰度值、行像元素以及列像元素;Determine the gray value, row image element and column image element corresponding to each pixel point according to the sample training image;
根据所述各像素点对应的灰度值确定图像灰度平均值;Determine the average grayscale value of the image according to the grayscale value corresponding to each pixel point;
根据所述各像素点对应的灰度值、行像元素、列像元素以及图像灰度平均值确定图像方差特征。The image variance feature is determined according to the gray value corresponding to each pixel point, the line image element, the column image element and the average value of the image gray level.
可选地,所述根据所述样本训练图像进行平均梯度强度计算,得到平均梯度强度特征,包括:Optionally, the average gradient intensity calculation is performed according to the sample training image to obtain the average gradient intensity feature, including:
根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;Determine the gradient of each pixel coordinate direction in the sample training image according to the sample training image;
根据所述各像素点坐标方向的梯度确定各像素点的梯度强度值;Determine the gradient intensity value of each pixel point according to the gradient in the coordinate direction of each pixel point;
根据所述梯度强度值确定所述样本训练图像的梯度强度图;Determine the gradient intensity map of the sample training image according to the gradient intensity value;
根据所述梯度强度图进行均值滤波操作,得到平均梯度强度图;Perform an average filtering operation according to the gradient intensity map to obtain an average gradient intensity map;
根据所述平均梯度强度图确定平均梯度强度特征。An average gradient intensity feature is determined from the average gradient intensity map.
可选地,所述根据所述样本训练图像进行相关面特征计算,得到相关面特征,包括:Optionally, calculating the relevant surface features according to the sample training image to obtain the relevant surface features, including:
根据所述样本训练图像进行单元格划分,得到划分单元;Cell division is performed according to the sample training image to obtain division cells;
根据所述划分单元对应的划分单元图像和所述样本训练图像进行梯度强度计算,得到所述样本训练图像对应的第一梯度强度和所述划分单元图像对应的第二梯度强度;Perform 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;
根据所述第一梯度强度、第二梯度强度、样本训练图像以及划分单元图像进行相关系数计算,得到相关面特征。The correlation coefficient is calculated according to the first gradient strength, the second gradient strength, the sample training image and the divided unit image, so as to obtain the correlation surface feature.
可选地,所述根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型,包括:Optionally, performing model training according to the sample training features and the sample training images to obtain a preset defect detection model, including:
获取预设评价指标;Obtain preset evaluation indicators;
根据所述样本训练特征和所述样本训练图像进行模型训练,得到初始训练模型和所述初始训练模型的混淆矩阵指标;Perform model training according to the sample training features and the sample training images, to obtain the initial training model and the confusion matrix index of the initial training model;
根据所述预设评价指标和所述混淆矩阵指标进行模型评估,得到评估结果;Perform model evaluation according to the preset evaluation index and the confusion matrix index to obtain an evaluation result;
当所述评估结果为预设结果时,根据所述初始训练模型得到预设缺陷检测模型。When the evaluation result is a preset result, a preset defect detection model is obtained according to the initial training model.
此外,为实现上述目的,本发明还提出一种印刷电路板的缺陷检测装置,所述印刷电路板的缺陷检测装置包括:In addition, in order to achieve the above object, the present invention also provides a defect detection device for a printed circuit board, and the defect detection device for a printed circuit board includes:
获取模块,用于获取样本印刷电路板的样本训练图像和待检测印刷电路板的待检测图像;an acquisition module for acquiring the sample training image of the sample printed circuit board and the to-be-detected image of the to-be-detected printed circuit board;
计算模块,用于根据所述样本训练图像进行特征计算,得到所述样本训练图像对应的样本训练特征;a computing module, configured to perform feature calculation according to the sample training image to obtain sample training features corresponding to the sample training image;
训练模块,用于根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型;a training module, configured to perform model training according to the sample training features and the sample training images to obtain a preset defect detection model;
检测模块,用于根据所述预设缺陷检测模型对所述待检测图像进行缺陷检测,得到所述印刷电路板的缺陷检测结果。The detection module is configured to perform defect detection on the to-be-detected image according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
此外,为实现上述目的,本发明还提出一种印刷电路板的缺陷检测设备,所述印刷电路板的缺陷检测设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的印刷电路板的缺陷检测程序,所述印刷电路板的缺陷检测程序配置为实现如上文所述的印刷电路板的缺陷检测方法。In addition, in order to achieve the above object, the present invention also provides a defect detection device for a printed circuit board. The defect detection device for a printed circuit board includes: a memory, a processor, and a device stored in the memory and available in the processor. A printed circuit board defect detection program running on the printed circuit board defect detection program configured to implement the printed circuit board defect detection method as described above.
此外,为实现上述目的,本发明还提出一种存储介质,所述存储介质上存储有印刷电路板的缺陷检测程序,所述印刷电路板的缺陷检测程序被处理器执行时实现如上文所述的印刷电路板的缺陷检测方法。In addition, in order to achieve the above object, the present invention also provides a storage medium, on which a defect detection program of a printed circuit board is stored, and the defect detection program of the printed circuit board is executed by a processor to achieve the above-mentioned A method for defect detection of printed circuit boards.
本发明通过获取样本印刷电路板的样本训练图像和待检测印刷电路板的待检测图像;根据所述样本训练图像进行特征计算,得到所述样本训练图像对应的样本训练特征;根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型;根据所述预设缺陷检测模型对所述待检测图像进行缺陷检测,得到所述印刷电路板的缺陷检测结果。通过上述方式,基于样本印刷电路板的样本训练图像对应的样本训练特征进行模型训练,得到可以准确识别印刷电路板对应图像中是否存在缺陷的预设缺陷检测模型,从而基于预设缺陷检测模型对待检测图像进行缺陷检测,提高了PCB在线检测时的缺陷检测精度和准确率,满足PCB在线缺陷检测的需求。The present invention obtains the sample training image of the sample printed circuit board and the to-be-detected image of the printed circuit board to be detected; performs feature calculation according to the sample training image to obtain the sample training feature corresponding to the sample training image; Perform model training on the features and the sample training image to obtain a preset defect detection model; perform defect detection on the to-be-detected image according to the preset defect detection model to obtain a defect detection result of the printed circuit board. Through the above method, model training is performed based on the sample training features corresponding to the sample training images of the sample printed circuit board, and a preset defect detection model that can accurately identify whether there is a defect in the corresponding image of the printed circuit board is obtained. Detecting images for defect detection improves the accuracy and accuracy of defect detection during PCB online inspection, and meets the needs of PCB online defect detection.
附图说明Description of drawings
图1是本发明实施例方案涉及的硬件运行环境的印刷电路板的缺陷检测设备的结构示意图;1 is a schematic structural diagram of a defect detection device for a printed circuit board in a hardware operating environment according to an embodiment of the present invention;
图2为本发明印刷电路板的缺陷检测方法第一实施例的流程示意图;FIG. 2 is a schematic flowchart of a first embodiment of a method for detecting defects in a printed circuit board according to the present invention;
图3为本发明印刷电路板的缺陷检测方法第二实施例的流程示意图;3 is a schematic flowchart of a second embodiment of a method for detecting defects in a printed circuit board according to the present invention;
图4为本发明印刷电路板的缺陷检测装置第一实施例的结构框图。FIG. 4 is a structural block diagram of a first embodiment of a defect detection device for a printed circuit board according to the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.
参照图1,图1为本发明实施例方案涉及的硬件运行环境的印刷电路板的缺陷检测设备结构示意图。Referring to FIG. 1 , FIG. 1 is a schematic structural diagram of a defect detection device for a printed circuit board in a hardware operating environment according to an embodiment of the present invention.
如图1所示,该印刷电路板的缺陷检测设备可以包括:处理器1001,例如中央处理器(Central Processing Unit,CPU),通信总线1002、用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如无线保真(Wireless-Fidelity,Wi-Fi)接口)。存储器1005可以是高速的随机存取存储器(RandomAccess Memory,RAM)存储器,也可以是稳定的非易失性存储器(Non-Volatile Memory,NVM),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 1 , the defect detection device of the printed circuit board may include: a
本领域技术人员可以理解,图1中示出的结构并不构成对印刷电路板的缺陷检测设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 1 does not constitute a limitation on the defect detection equipment of the printed circuit board, and may include more or less components than the one shown, or combine some components, or different Component placement.
如图1所示,作为一种存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及印刷电路板的缺陷检测程序。As shown in FIG. 1 , the
在图1所示的印刷电路板的缺陷检测设备中,网络接口1004主要用于与网络服务器进行数据通信;用户接口1003主要用于与用户进行数据交互;本发明印刷电路板的缺陷检测设备中的处理器1001、存储器1005可以设置在印刷电路板的缺陷检测设备中,所述印刷电路板的缺陷检测设备通过处理器1001调用存储器1005中存储的印刷电路板的缺陷检测程序,并执行本发明实施例提供的印刷电路板的缺陷检测方法。In the printed circuit board defect detection device shown in FIG. 1, the
本发明实施例提供了一种印刷电路板的缺陷检测方法,参照图2,图2为本发明一种印刷电路板的缺陷检测方法第一实施例的流程示意图。An embodiment of the present invention provides a method for detecting defects in a printed circuit board. Referring to FIG. 2 , FIG. 2 is a schematic flowchart of a first embodiment of a method for detecting defects in a printed circuit board according to the present invention.
印刷电路板的缺陷检测方法包括以下步骤:The defect detection method of printed circuit board includes the following steps:
步骤S10:获取样本印刷电路板的样本训练图像和待检测印刷电路板的待检测图像。Step S10: Obtain a sample training image of a sample printed circuit board and an image to be detected of the printed circuit board to be detected.
需要说明的是,本实施例的执行主体为终端设备,终端设备上安装有印刷电路板的缺陷检测系统,在终端设备接收到检测指令时,将检测指令转发到印刷电路板的缺陷检测系统,印刷电路板的缺陷检测系统根据检测指令获取样本训练图像和待检测图像。根据样本训练图像进行特征计算,得到各样本训练图像对应的样本训练特征,根据样本训练特征和样本训练图像进行模型训练,得到预设缺陷检测模型。基于得到的预设缺陷检测模型对待检测图像进行缺陷检测,得到印刷电路板的缺陷检测结果。It should be noted that the execution body of this embodiment is a terminal device, and a printed circuit board defect detection system is installed on the terminal device. When the terminal device receives a detection instruction, it forwards the detection instruction to the printed circuit board defect detection system. The defect detection system of the printed circuit board obtains the sample training image and the image to be inspected according to the inspection instruction. Perform feature calculation according to the sample training images to obtain sample training features corresponding to each sample training image, and perform model training according to the sample training features and the sample training images to obtain a preset defect detection model. Based on the obtained preset defect detection model, the image to be inspected is inspected for defects, and the defect inspection result of the printed circuit board is obtained.
可以理解的是,从预设数据库中获取大量样本印刷电路板的样本训练图像,样本训练图像可以是有缺陷的样本训练图像,也可以是无缺陷的样本训练图像。样本印刷电路板对应的样本训练图像是经过人工判别的,对于有缺陷的样本训练图像对应的标签设置为1,无缺陷的样本训练图像对应的标签设置为0,最终将所有的样本印刷电板的样本训练图像及对应标签进行存储,得到样本训练图像数据集。It can be understood that the sample training images of a large number of sample printed circuit boards are obtained from the preset database, and the sample training images may be defective sample training images or non-defective sample training images. The sample training images corresponding to the sample printed circuit boards are manually discriminated. The label corresponding to the defective sample training image is set to 1, and the label corresponding to the non-defective sample training image is set to 0. Finally, all the sample printed circuit boards are set to The sample training images and corresponding labels are stored to obtain the sample training image dataset.
在具体实现中,待检测图像即为待检测印刷电路板对应的图像。In a specific implementation, the to-be-detected image is an image corresponding to the to-be-detected printed circuit board.
步骤S20:根据所述样本训练图像进行特征计算,得到所述样本训练图像对应的样本训练特征。Step S20: Perform feature calculation according to the sample training images to obtain sample training features corresponding to the sample training images.
需要说明的是,样本训练特征指的是基于样本训练图像进行特征计算后得到的图像特征值,样本训练特征包括目标尺寸轮廓特征、图像方差特征、方向梯度直方图特征、边缘密度特征、平均梯度强度特征、累加梯度值特征、傅里叶频谱特征以及相关面特征中的至少一项。It should be noted that the sample training feature refers to the image feature value obtained after feature calculation based on the sample training image, and the sample training feature includes the target size contour feature, image variance feature, directional gradient histogram feature, edge density feature, and average gradient. At least one of an intensity feature, an accumulated gradient value feature, a Fourier spectrum feature, and a correlation surface feature.
步骤S30:根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型。Step S30: Perform model training according to the sample training features and the sample training images to obtain a preset defect detection model.
需要说明的是,将样本训练特征和对应的样本训练图像按照预设比例进行拆分,得到测试集和训练集。采用GBDT(Gradient Boosting Decision Tree,梯度下降决策树)根据训练集进行模型训练拟合,根据测试集对模型训练后的初始训练模型进行检测实验,最终得到可以准确识别印刷电路板对应图像中是否存在缺陷的预设缺陷检测模型。It should be noted that the sample training features and corresponding sample training images are split according to a preset ratio to obtain a test set and a training set. GBDT (Gradient Boosting Decision Tree, gradient descent decision tree) is used to train and fit the model according to the training set, and the initial training model after model training is tested according to the test set. Preset defect detection models for defects.
可以理解的是,为了保证模型训练的准确性,使后续缺陷检测时的精度提高,进一步地,所述根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型,包括:获取预设评价指标;根据所述样本训练特征和所述样本训练图像进行模型训练,得到初始训练模型和所述初始训练模型的混淆矩阵指标;根据所述预设评价指标和所述混淆矩阵指标进行模型评估,得到评估结果;当所述评估结果为预设结果时,根据所述初始训练模型得到预设缺陷检测模型。It can be understood that, in order to ensure the accuracy of model training and improve the accuracy 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: obtaining a preset evaluation index; performing model training according to the sample training feature and the sample training image to obtain an initial training model and a confusion matrix index of the initial training model; according to the preset evaluation index and the confusion The matrix index is used for model evaluation to obtain an evaluation result; when the evaluation result is a preset result, a preset defect detection model is obtained according to the initial training model.
在具体实现中,预设评价指标指的是预先设定的模型可以停止训练的指标。根据样本训练特征和样本训练图像采用GBDT分类算法进行模型训练,得到初始训练模型和初始训练模型的混淆矩阵指标。将预设评价指标和混淆矩阵指标进行模型评估,得到混淆矩阵指标是否满足要求的评估结果。当评估结果为混淆矩阵指标满足要求的预设结果时,则可将初始训练模型作为预设缺陷检测模型。当评估结果为混淆矩阵指标不满足要求时,需要根据预设评价指标来调整模型训练时的训练参数,例如步长、学习率、迭代次数以及模型分类的节点数,然后重新进行模型训练。In a specific implementation, the preset evaluation index refers to a preset index by which the model can stop training. According to the sample training features and sample training images, the GBDT classification algorithm is used for model training, and the initial training model and the confusion matrix indicators of the initial training model are obtained. Perform model evaluation on the preset evaluation index and the confusion matrix index, and obtain the evaluation result of whether the confusion matrix index meets the requirements. When the evaluation result is the preset result that the confusion matrix index meets the requirements, the initial training model can be used as the preset defect detection model. When the evaluation result is that the confusion matrix index does not meet the requirements, it is necessary to adjust the training parameters during model training according to the preset evaluation index, such as step size, learning rate, number of iterations, and the number of nodes for model classification, and then re-train the model.
步骤S40:根据所述预设缺陷检测模型对所述待检测图像进行缺陷检测,得到所述印刷电路板的缺陷检测结果。Step S40: Perform defect detection on the to-be-detected image according to the preset defect detection model to obtain a defect detection result of the printed circuit board.
需要说明的是,在得到预设缺陷检测模型后,输入待检测图像至预设缺陷检测模型对待检测图像进行缺陷检测,得到印刷电路板是否存在元器件缺失、偏移以及错位等缺失的缺陷检测结果。It should be noted that, after obtaining the preset defect detection model, input the image to be detected into the preset defect detection model to perform defect detection on the image to be detected, and obtain whether the printed circuit board has defects such as missing components, offsets and dislocations. result.
本实施例通过获取样本印刷电路板的样本训练图像和待检测印刷电路板的待检测图像;根据所述样本训练图像进行特征计算,得到所述样本训练图像对应的样本训练特征;根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型;根据所述预设缺陷检测模型对所述待检测图像进行缺陷检测,得到所述印刷电路板的缺陷检测结果。通过上述方式,基于样本印刷电路板的样本训练图像对应的样本训练特征进行模型训练,得到可以准确识别印刷电路板对应图像中是否存在缺陷的预设缺陷检测模型,从而基于预设缺陷检测模型对待检测图像进行缺陷检测,提高了PCB在线检测时的缺陷检测精度和准确率,满足PCB在线缺陷检测的需求。In this embodiment, a sample training image of a sample printed circuit board and a to-be-detected image of a printed circuit board to be detected are obtained; feature calculation is performed according to the sample training image to obtain sample training features corresponding to the sample training image; Perform model training on the training feature and the sample training image to obtain a preset defect detection model; perform defect detection on the to-be-detected image according to the preset defect detection model to obtain a defect detection result of the printed circuit board. Through the above method, model training is performed based on the sample training features corresponding to the sample training images of the sample printed circuit board, and a preset defect detection model that can accurately identify whether there is a defect in the corresponding image of the printed circuit board is obtained. Detecting images for defect detection improves the accuracy and accuracy of defect detection during PCB online inspection, and meets the needs of PCB online defect detection.
参考图3,图3为本发明一种印刷电路板的缺陷检测方法第二实施例的流程示意图。Referring to FIG. 3 , FIG. 3 is a schematic flowchart of a second embodiment of a method for detecting defects of a printed circuit board according to the present invention.
基于上述第一实施例,所述样本训练特征包括目标尺寸轮廓特征、图像方差特征、方向梯度直方图特征、边缘密度特征、平均梯度强度特征、累加梯度值特征、傅里叶频谱特征以及相关面特征中的至少一项,本实施例印刷电路板的缺陷检测方法中所述步骤S20,包括:Based on the above-mentioned first embodiment, the sample training features include target size profile features, image variance features, directional gradient histogram features, edge density features, average gradient strength features, accumulated gradient value features, Fourier spectral features, and correlation surfaces At least one of the features, the step S20 in the method for detecting defects of a printed circuit board of this embodiment, includes:
步骤S21:根据所述样本训练图像进行目标尺寸轮廓特征计算,得到目标尺寸轮廓特征。Step S21: Perform target size contour feature calculation according to the sample training image to obtain target size contour features.
需要说明的是,目标尺寸轮廓特征即为各样本训练图像对应的大尺度轮廓特征Hnor。It should be noted that the target size contour feature is the large-scale contour feature H nor corresponding to each sample training image.
可以理解的是,为了得到准确的目标尺寸轮廓特征Hnor,进一步地,所述根据所述样本训练图像进行目标尺寸轮廓特征计算,得到目标尺寸轮廓特征,包括:根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;根据所述各像素点坐标方向的梯度确定所述各像素点的梯度角度;根据所述梯度角度和预设角度区间确定梯度方向熵;根据所述梯度方向熵和所述预设角度区间对应数量确定目标尺寸轮廓特征。It can be understood that, in order to obtain the accurate target size contour feature H nor , further, performing the target size contour feature calculation according to the sample training image to obtain the target size contour feature includes: determining the target size contour feature according to the sample training image. the gradient of each pixel coordinate direction in the sample training image; the gradient angle of each pixel point is determined according to the gradient of the coordinate direction of each pixel point; the gradient direction entropy is determined according to the gradient angle and the preset angle interval; The gradient direction entropy and the corresponding quantity of the preset angle interval determine the contour feature of the target size.
在具体实现中,各像素点坐标方向的梯度指的是样本训练图像中各像素点x方向的梯度Gx(x,y)和y方向的梯度Gy(x,y)。各像素点的梯度角度指的是各像素点的梯度角度 In a specific implementation, the gradient in the coordinate direction of each pixel point refers to the gradient G x (x, y) in the x direction of each pixel point in the sample training image and the gradient G y (x, y) in the y direction. The gradient angle of each pixel refers to the gradient angle of each pixel
需要说明的是,预设角度区间指的是将0到360度的梯度方向平均划分为n个区间后得到的n个角度区间。n即为预设角度区间对应数量,对样本像素图像进行单元格划分,得到多个划分单元,大小约为w*h=10*10,计算每个样本像素图像中每个划分单元在的梯度角度在各个预设角度区间内的像素概率pi。分别统计划分单元梯度方向直方图中每个方向的概率,从而得到每个划分单元的梯度方向熵在得到梯度方向熵后,根据熵的定义可知,当每个方向的梯度出现概率都相等的情况下,熵取最大值,得到归一化梯度方向熵其中,对归一化后的熵值进行统计,对H中像素点进行由大到小排序,将排序结果中占像素数的前30%的点进行加权,即行程最终目标区域的值w和h分别是目标区域的宽和高,Hnor即为目标尺寸轮廓特征It should be noted that the preset angle interval refers to n angle intervals obtained by dividing the gradient direction of 0 to 360 degrees into n intervals on average. n is the corresponding number of preset angle intervals, divide the sample pixel image into cells to obtain a plurality of division units, the size is about w*h=10*10, calculate the gradient of each division unit in each sample pixel image The pixel probability p i of the angle within each preset angle interval. Calculate the probability of each direction in the gradient direction histogram of the division unit separately, so as to obtain the gradient direction entropy of each division unit In getting the gradient direction entropy Then, according to the definition of entropy, when the probability of the gradient in each direction is equal, the entropy takes the maximum value, and the normalized gradient direction entropy is obtained. in, Count the normalized entropy values, sort the pixels in H from large to small, and weight the top 30% of the pixels in the sorting result, that is, the value of the final destination area of the trip w and h are the width and height of the target area, respectively, and H nor is the target size contour feature
步骤S22:根据所述样本训练图像进行图像方差特征计算,得到图像方差特征。Step S22: Perform image variance feature calculation according to the sample training image to obtain image variance feature.
需要说明的是,图像方差特征指的是图像的灰度方差特征,反映了图像灰度整体的起伏变化程度。根据样本训练图像进行图像方差特征计算,得到图像方差特征Var。It should be noted that the image variance feature refers to the grayscale variance feature of the image, which reflects the fluctuation degree of the overall grayscale of the image. The image variance feature is calculated according to the sample training image, and the image variance feature V ar is obtained.
可以理解的是,为了得到准确的图像方差特征,进一步地,所述根据所述样本训练图像进行图像方差特征计算,得到图像方差特征,包括:根据所述样本训练图像确定各像素点对应的灰度值、行像元素以及列像元素;根据所述各像素点对应的灰度值确定图像灰度平均值;根据所述各像素点对应的灰度值、行像元素、列像元素以及图像灰度平均值确定图像方差特征。It can be understood that, in order to obtain the accurate image variance feature, further, performing the image variance feature calculation according to the sample training image to obtain the image variance feature includes: determining the grayscale corresponding to each pixel point according to the sample training image. degree value, line image element and column image element; determine the average gray level of the image according to the gray value corresponding to each pixel point; according to the gray value, line image element, column image element and image corresponding to each pixel point The gray mean value determines the image variance characteristics.
在具体实现中,根据样本训练图像确定各像素点对应的灰度值X(i,j),(i,j)指的是像素点的坐标,样本训练图像的行像元素m以及列像元素n。根据各像素点对应的灰度可确定样本训练图像灰度的平均值E(X(i,j)),根据各像素点对应的灰度值、行像元素、列像元素以及图像灰度平均值可确定图像方差特征 In the specific implementation, the gray value X(i,j) corresponding to each pixel is determined according to the sample training image, where (i,j) refers to the coordinates of the pixel, the row image element m and the column image element of the sample training image n. According to the gray level corresponding to each pixel point, the average value E(X(i,j)) of the sample training image gray level can be determined. value to determine image variance characteristics
步骤S23:根据所述样本训练图像进行单元格划分,得到划分单元。Step S23: Perform cell division according to the sample training image to obtain division cells.
需要说明的是,对样本训练图像进行单元格划分,得到各大小相同的划分单元。It should be noted that the sample training images are divided into cells to obtain divided cells of the same size.
步骤S24:根据所述划分单元进行方向直方图特征计算,得到方向直方图特征。Step S24: Perform direction histogram feature calculation according to the dividing unit to obtain the direction histogram feature.
需要说明的是,计算所有划分单元熵值的总和,得到方向直方图特征Hog熵。It should be noted that the sum of the entropy values of all division units is calculated to obtain the Hog entropy of the direction histogram feature.
步骤S25:根据所述样本训练图像确定边缘像素值、行像元素以及列像元素。Step S25: Determine edge pixel values, line image elements and column image elements according to the sample training image.
需要说明的是,根据样本训练图像通过边缘算子求得边缘像素值,并确定样本训练图像的行像元素m以及列像元素n。It should be noted that the edge pixel value is obtained through the edge operator according to the sample training image, and the row image element m and the column image element n of the sample training image are determined.
步骤S26:根据所述边缘像素值、行像元素以及列像元素进行边缘密度特征计算,得到边缘密度特征。Step S26: Perform edge density feature calculation according to the edge pixel values, line image elements and column image elements to obtain edge density features.
需要说明的是,边缘密度特征用于判定样本训练图像中边缘特征分布是否密集,是反映影像信息量的一种指标。根据边缘像素值、行像元素以及列像元素进行边缘密度特征计算可得到边缘密度特征其中,edge是边缘像素值的绝对值。It should be noted that 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 amount of image information. The edge density feature can be obtained by calculating the edge density feature according to the edge pixel value, line image element and column image element. where edge is the absolute value of the edge pixel value.
步骤S27:根据所述样本训练图像进行平均梯度强度计算,得到平均梯度强度特征。Step S27: Calculate the average gradient intensity according to the sample training image to obtain the average gradient intensity feature.
需要说明的是,根据样本训练图像可进行平均梯度强度计算,得到平均梯度强度特征。It should be noted that the average gradient intensity can be calculated according to the sample training image to obtain the average gradient intensity feature.
可以理解的是,为了得到准确的平均梯度强度,进一步地,所述根据所述样本训练图像进行平均梯度强度计算,得到平均梯度强度特征,包括:根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;根据所述各像素点坐标方向的梯度确定各像素点的梯度强度值;根据所述梯度强度值确定所述样本训练图像的梯度强度图;根据所述梯度强度图进行均值滤波操作,得到平均梯度强度图;根据所述平均梯度强度图确定平均梯度强度特征。It can be understood that, in order to obtain an accurate average gradient strength, further, performing the average gradient strength calculation according to the sample training image to obtain the average gradient strength feature includes: determining the sample training image according to the sample training image. According to the gradient of the coordinate direction of each pixel point, the gradient intensity value of each pixel point is determined; the gradient intensity map of the sample training image is determined according to the gradient intensity value; according to the gradient intensity A mean value filtering operation is performed on the graph to obtain an average gradient intensity map; the average gradient intensity feature is determined according to the average gradient intensity map.
在具体实现中,各像素点坐标方向的梯度指的是样本训练图像中各像素点x方向的梯度Gx(x,y)和y方向的梯度Gy(x,y),然后得到各像素点的梯度强度值从而得到样本训练图像的梯度强度图。并对样本训练图像进行单元格划分,得到划分单元,以划分单元的大小为模板进行均值滤波操作,得到划分单元的平均梯度强度图。根据平均梯度强度图排名,取前30%的梯度强度值的平均值为样本训练图像的平均梯度强度值。In the specific implementation, the gradient in the coordinate direction of each pixel point refers to the gradient G x (x, y) in the x direction of each pixel point in the sample training image and the gradient G y (x, y) in the y direction, and then each pixel is obtained. Gradient strength value of point Thereby, the gradient intensity map of the sample training image is obtained. The sample training image is divided into cells to obtain the divided cells, and the mean value filtering operation is performed with the size of the divided cells as a template to obtain the average gradient intensity map of the divided cells. According to the average gradient intensity map ranking, the average gradient intensity value of the top 30% is taken as the average gradient intensity value of the sample training images.
步骤S28:根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度。Step S28: Determine the gradient of each pixel coordinate direction in the sample training image according to the sample training image.
需要说明的是,各像素点坐标方向的梯度指的是样本训练图像中各像素点x方向的梯度Gx(x,y)和y方向的梯度Gy(x,y)。It should be noted that the gradient in the coordinate direction of each pixel point refers to the gradient G x (x, y) in the x direction of each pixel point in the sample training image and the gradient G y (x, y) in the y direction.
步骤S29:根据所述各像素点坐标方向的梯度进行累加梯度值计算,得到累加梯度值特征。Step S29: Calculate the cumulative gradient value according to the gradient in the coordinate direction of each pixel point to obtain the cumulative gradient value feature.
需要说明的是,累加梯度值特征描述一个区域中梯度强度的和,一个区域中累加的边缘数越强,则有越明显的梯度特征。根据各像素点坐标方向的梯度进行累加梯度值计算,累加梯度值特征最终 It should be noted that the cumulative gradient value feature describes the sum of the gradient strengths in a region, and the stronger the cumulative number of edges in a region, the more obvious the gradient feature is. Calculate the cumulative gradient value according to the gradient in the coordinate direction of each pixel point, and accumulate the gradient value characteristics finally
步骤S210:根据所述样本训练图像确定图像尺寸。Step S210: Determine the image size according to the sample training image.
需要说明的是,根据样本训练图像确定样本训练图像原图尺寸I。It should be noted that the original image size I of the sample training image is determined according to the sample training image.
步骤S211:根据所述图像尺寸进行傅里叶频谱特征计算,得到傅里叶频谱特征。Step S211: Perform Fourier spectral feature calculation according to the image size to obtain Fourier spectral features.
需要说明的是,傅里叶频谱特征描述了样本训练图像的纹理特征,在得到图像尺寸后,得到样本训练图像的傅里叶变换能量图FI,FI=|F(I)|,F(I)为I的二维傅里叶变换,FI的大小也为m×n,E=sum(FI)=sum[|F(I)|],E为傅里叶能量和,则It should be noted that the Fourier spectral feature describes the texture feature of the sample training image. After the image size is obtained, the Fourier transform energy map FI of the sample training image is obtained, FI=|F(I)|, F(I ) is the two-dimensional Fourier transform of I, the size of FI is also m×n, E=sum(FI)=sum[|F(I)|], E is the Fourier energy sum, then
其中,BW2、BW4、BW8、BW16分别被称为1/2半径能量和、1/4半径能量和、1/8半径能量和、1/16半径能量和。Among them, BW2, BW4, BW8, and BW16 are respectively referred to as 1/2 radius energy sum, 1/4 radius energy sum, 1/8 radius energy sum, and 1/16 radius energy sum.
步骤S212:根据所述样本训练图像进行相关面特征计算,得到相关面特征。Step S212: Calculate the relevant surface features according to the sample training image to obtain the relevant surface features.
需要说明的是,相关面特征指的是样本训练图像和划分单元图像的相关系数。It should be noted that the correlation surface feature refers to the correlation coefficient between the sample training image and the divided unit image.
可以理解的是,为了得到准确的相关面特征,进一步地,所述根据所述样本训练图像进行相关面特征计算,得到相关面特征,包括:根据所述样本训练图像进行单元格划分,得到划分单元;根据所述划分单元对应的划分单元图像和所述样本训练图像进行梯度强度计算,得到所述样本训练图像对应的第一梯度强度和所述划分单元图像对应的第二梯度强度;根据所述第一梯度强度、第二梯度强度、样本训练图像以及划分单元图像进行相关系数计算,得到相关面特征。It can be understood that, in order to obtain accurate relevant surface features, further, performing the relevant surface feature calculation according to the sample training image to obtain the relevant surface features includes: performing cell division according to the sample training image to obtain a division. unit; carry out gradient intensity calculation according to the division unit image corresponding to the division unit and the sample training image, and obtain the first gradient intensity corresponding to the sample training image and the second gradient intensity corresponding to the division unit image; The first gradient strength, the second gradient strength, the sample training image and the division unit image are used to calculate the correlation coefficient to obtain the correlation surface feature.
在具体实现中,根据样本训练图像进行单元格划分,得到各大小相同的划分单元,并得到划分单元对应的划分单元图像。第一梯度强度指的是样本训练图像在各像素点的梯度强度第二梯度强度指的是划分单元图像在各像素点的梯度强度 In a specific implementation, the cells are divided according to the sample training images to obtain division units of the same size, and the 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 The second gradient strength refers to the gradient strength of the divided unit image at each pixel point
需要说明的是,在得到第一梯度强度、第二梯度强度、样本训练图像以及划分单元图像,可进行相关系数计算得到相关面特征。划分单元图像在样本训练图像上以像素为布长进行遍历,相关面系数S的大小为(W-w+1)×(H-h+1),每个像素值是划分单元图像和样本训练图像对应区域的相关系数值。相关面中的局部极大值为峰值,局部范围大小由外界设定,最终相关面特征其中,E(ai)是划分单元图像梯度强度的均值,E(AI)是样本训练图像对应区域梯度强度的均值。(x,y)是划分单元图像图左上角坐标在样本训练图像中。It should be noted that, after obtaining the first gradient strength, the second gradient strength, the sample training image and the divided unit image, the correlation coefficient can be calculated to obtain the correlation surface feature. The divided unit image is traversed on the sample training image with pixels as the cloth length. The size of the correlation surface coefficient S is (W-w+1)×(H-h+1), and each pixel value is the dividing unit image and sample training. The correlation coefficient value of the corresponding area of the image. The local maximum value in the correlation surface is the peak value, the size of the local range is set by the outside world, and the final correlation surface features Among them, E(ai) is the mean value of the gradient strength of the divided unit image, and E(AI) is the mean value of the gradient strength of the corresponding region of the sample training image. (x,y) is the coordinate of the upper left corner of the divided unit image graph in the sample training image.
本实施例通过根据所述样本训练图像进行目标尺寸轮廓特征计算,得到目标尺寸轮廓特征;根据所述样本训练图像进行图像方差特征计算,得到图像方差特征;根据所述样本训练图像进行单元格划分,得到划分单元;根据所述划分单元进行方向直方图特征计算,得到方向直方图特征;根据所述样本训练图像确定边缘像素值、行像元素以及列像元素;根据所述边缘像素值、行像元素以及列像元素进行边缘密度特征计算,得到边缘密度特征;根据所述样本训练图像进行平均梯度强度计算,得到平均梯度强度特征;根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;根据所述各像素点坐标方向的梯度进行累加梯度值计算,得到累加梯度值特征;根据所述样本训练图像确定图像尺寸;根据所述图像尺寸进行傅里叶频谱特征计算,得到傅里叶频谱特征;根据所述样本训练图像进行相关面特征计算,得到相关面特征。从而可以得到准确的样本训练特征,为后续模型训练提供了准确的训练数据。In this embodiment, the target size contour feature is obtained by calculating the target size contour feature according to the sample training image; the image variance feature is obtained by calculating the image variance feature according to the sample training image; and the cell division is performed according to the sample training image. , obtain a division unit; perform direction histogram feature calculation according to the division unit, obtain the direction histogram feature; determine edge pixel values, line image elements and column image elements according to the sample training image; Perform edge density feature calculation on image elements and column image elements to obtain edge density features; perform average gradient intensity calculation according to the sample training image to obtain average gradient intensity features; determine each pixel in the sample training image according to the sample training image The gradient of the point coordinate direction; calculate the accumulated gradient value according to the gradient of the coordinate direction of each pixel point, and obtain the accumulated gradient value feature; determine the image size according to the sample training image; calculate the Fourier spectrum feature according to the image size , to obtain the Fourier spectral feature; and to calculate the correlation surface feature according to the sample training image to obtain the correlation surface feature. Thus, accurate sample training features can be obtained, and accurate training data can be provided for subsequent model training.
此外,参照图4,本发明实施例还提出一种印刷电路板的缺陷检测装置,所述印刷电路板的缺陷检测装置包括:In addition, referring to FIG. 4 , an embodiment of the present invention further provides a defect detection device for a printed circuit board, and the defect detection device for a printed circuit board includes:
获取模块10,用于获取样本印刷电路板的样本训练图像和待检测印刷电路板的待检测图像。The acquiring
计算模块20,用于根据所述样本训练图像进行特征计算,得到所述样本训练图像对应的样本训练特征。The
训练模块30,用于根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型。The
检测模块40,用于根据所述预设缺陷检测模型对所述待检测图像进行缺陷检测,得到所述印刷电路板的缺陷检测结果。The
本实施例通过获取样本印刷电路板的样本训练图像和待检测印刷电路板的待检测图像;根据所述样本训练图像进行特征计算,得到所述样本训练图像对应的样本训练特征;根据所述样本训练特征和所述样本训练图像进行模型训练,得到预设缺陷检测模型;根据所述预设缺陷检测模型对所述待检测图像进行缺陷检测,得到所述印刷电路板的缺陷检测结果。通过上述方式,基于样本印刷电路板的样本训练图像对应的样本训练特征进行模型训练,得到可以准确识别印刷电路板对应图像中是否存在缺陷的预设缺陷检测模型,从而基于预设缺陷检测模型对待检测图像进行缺陷检测,提高了PCB在线检测时的缺陷检测精度和准确率,满足PCB在线缺陷检测的需求。In this embodiment, a sample training image of a sample printed circuit board and a to-be-detected image of a printed circuit board to be detected are obtained; feature calculation is performed according to the sample training image to obtain sample training features corresponding to the sample training image; Perform model training on the training feature and the sample training image to obtain a preset defect detection model; perform defect detection on the to-be-detected image according to the preset defect detection model to obtain a defect detection result of the printed circuit board. Through the above method, model training is performed based on the sample training features corresponding to the sample training images of the sample printed circuit board, and a preset defect detection model that can accurately identify whether there is a defect in the corresponding image of the printed circuit board is obtained. Detecting images for defect detection improves the accuracy and accuracy of defect detection during PCB online inspection, and meets the needs of PCB online defect detection.
在一实施例中,所述计算模块20,还用于根据所述样本训练图像进行目标尺寸轮廓特征计算,得到目标尺寸轮廓特征;In one embodiment, the
根据所述样本训练图像进行图像方差特征计算,得到图像方差特征;Perform image variance feature calculation according to the sample training image to obtain image variance feature;
根据所述样本训练图像进行单元格划分,得到划分单元;Cell division is performed according to the sample training image to obtain division cells;
根据所述划分单元进行方向直方图特征计算,得到方向直方图特征;Perform direction histogram feature calculation according to the dividing unit to obtain the direction histogram feature;
根据所述样本训练图像确定边缘像素值、行像元素以及列像元素;Determine edge pixel values, row image elements and column image elements according to the sample training image;
根据所述边缘像素值、行像元素以及列像元素进行边缘密度特征计算,得到边缘密度特征;Perform edge density feature calculation according to the edge pixel value, row image element and column image element to obtain edge density feature;
根据所述样本训练图像进行平均梯度强度计算,得到平均梯度强度特征;Calculate the average gradient intensity according to the sample training image to obtain the average gradient intensity feature;
根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;Determine the gradient of each pixel coordinate direction in the sample training image according to the sample training image;
根据所述各像素点坐标方向的梯度进行累加梯度值计算,得到累加梯度值特征;Calculate the cumulative gradient value according to the gradient in the coordinate direction of each pixel point to obtain the cumulative gradient value feature;
根据所述样本训练图像确定图像尺寸;Determine the image size according to the sample training image;
根据所述图像尺寸进行傅里叶频谱特征计算,得到傅里叶频谱特征;Perform Fourier spectral feature calculation according to the image size to obtain Fourier spectral features;
根据所述样本训练图像进行相关面特征计算,得到相关面特征。The relevant surface feature is calculated according to the sample training image to obtain the relevant surface feature.
在一实施例中,所述计算模块20,还用于根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;In one embodiment, the
根据所述各像素点坐标方向的梯度确定所述各像素点的梯度角度;Determine the gradient angle of each pixel point according to the gradient of the coordinate direction of each pixel point;
根据所述梯度角度和预设角度区间确定梯度方向熵;Determine the gradient direction entropy according to the gradient angle and the preset angle interval;
根据所述梯度方向熵和所述预设角度区间对应数量确定目标尺寸轮廓特征。The target size contour feature is determined according to the gradient direction entropy and the corresponding quantity of the preset angle interval.
在一实施例中,所述计算模块20,还用于根据所述样本训练图像确定各像素点对应的灰度值、行像元素以及列像元素;In one embodiment, the
根据所述各像素点对应的灰度值确定图像灰度平均值;Determine the average grayscale value of the image according to the grayscale value corresponding to each pixel point;
根据所述各像素点对应的灰度值、行像元素、列像元素以及图像灰度平均值确定图像方差特征。The image variance feature is determined according to the gray value corresponding to each pixel point, the line image element, the column image element and the average value of the image gray level.
在一实施例中,所述计算模块20,还用于根据所述样本训练图像确定所述样本训练图像中各像素点坐标方向的梯度;In one embodiment, the
根据所述各像素点坐标方向的梯度确定各像素点的梯度强度值;Determine the gradient intensity value of each pixel point according to the gradient in the coordinate direction of each pixel point;
根据所述梯度强度值确定所述样本训练图像的梯度强度图;Determine the gradient intensity map of the sample training image according to the gradient intensity value;
根据所述梯度强度图进行均值滤波操作,得到平均梯度强度图;Perform an average filtering operation according to the gradient intensity map to obtain an average gradient intensity map;
根据所述平均梯度强度图确定平均梯度强度特征。An average gradient intensity feature is determined from the average gradient intensity map.
在一实施例中,所述计算模块20,还用于根据所述样本训练图像进行单元格划分,得到划分单元;In one embodiment, the
根据所述划分单元对应的划分单元图像和所述样本训练图像进行梯度强度计算,得到所述样本训练图像对应的第一梯度强度和所述划分单元图像对应的第二梯度强度;Perform 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;
根据所述第一梯度强度、第二梯度强度、样本训练图像以及划分单元图像进行相关系数计算,得到相关面特征。The correlation coefficient is calculated according to the first gradient strength, the second gradient strength, the sample training image and the divided unit image, so as to obtain the correlation surface feature.
在一实施例中,所述训练模块30,还用于获取预设评价指标;In one embodiment, the
根据所述样本训练特征和所述样本训练图像进行模型训练,得到初始训练模型和所述初始训练模型的混淆矩阵指标;Perform model training according to the sample training features and the sample training images, to obtain the initial training model and the confusion matrix index of the initial training model;
根据所述预设评价指标和所述混淆矩阵指标进行模型评估,得到评估结果;Perform model evaluation according to the preset evaluation index and the confusion matrix index to obtain an evaluation result;
当所述评估结果为预设结果时,根据所述初始训练模型得到预设缺陷检测模型。When the evaluation result is a preset result, a preset defect detection model is obtained according to the initial training model.
由于本装置采用了上述所有实施例的全部技术方案,因此至少具有上述实施例的技术方案所带来的所有有益效果,在此不再一一赘述。Since the device adopts all the technical solutions of all the above-mentioned embodiments, it has at least all the beneficial effects brought by the technical solutions of the above-mentioned embodiments, which will not be repeated here.
此外,本发明实施例还提出一种存储介质,所述存储介质上存储有印刷电路板的缺陷检测程序,所述印刷电路板的缺陷检测程序被处理器执行时实现如上文所述的印刷电路板的缺陷检测方法的步骤。In addition, an embodiment of the present invention also provides a storage medium, where a defect detection program of a printed circuit board is stored on the storage medium, and the printed circuit board as described above is implemented when the defect detection program of the printed circuit board is executed by a processor. Steps of a method for defect detection of a board.
由于本存储介质采用了上述所有实施例的全部技术方案,因此至少具有上述实施例的技术方案所带来的所有有益效果,在此不再一一赘述。Since the storage medium adopts all the technical solutions of all the above-mentioned embodiments, it has at least all the beneficial effects brought by the technical solutions of the above-mentioned embodiments, which will not be repeated here.
需要说明的是,以上所描述的工作流程仅仅是示意性的,并不对本发明的保护范围构成限定,在实际应用中,本领域的技术人员可以根据实际的需要选择其中的部分或者全部来实现本实施例方案的目的,此处不做限制。It should be noted that the above-described workflow is only illustrative, and does not limit the protection scope of the present invention. In practical applications, those skilled in the art can select some or all of them to implement according to actual needs. The purpose of the solution in this embodiment is not limited here.
另外,未在本实施例中详尽描述的技术细节,可参见本发明任意实施例所提供的印刷电路板的缺陷检测方法,此处不再赘述。In addition, for technical details that are not described in detail in this embodiment, reference may be made to the defect detection method for a printed circuit board provided by any embodiment of the present invention, and details are not repeated here.
此外,需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。Furthermore, it should be noted that, herein, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article or system comprising a series of elements includes not only those elements, but also other elements not expressly listed or inherent to such a process, method, article or system. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article or system that includes the element.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages or disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如只读存储器(Read Only Memory,ROM)/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本发明各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the method of the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on such understanding, the technical solutions of the present invention can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products are stored in a storage medium (such as a read-only memory). , ROM)/RAM, magnetic disk, optical disk), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) execute the methods described in the various embodiments of the present invention.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied in other related technical fields , are similarly included in the scope of patent protection of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210434417.3A CN114897797B (en) | 2022-04-24 | 2022-04-24 | Printed circuit board defect detection method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210434417.3A CN114897797B (en) | 2022-04-24 | 2022-04-24 | Printed circuit board defect detection method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114897797A true CN114897797A (en) | 2022-08-12 |
CN114897797B CN114897797B (en) | 2025-04-04 |
Family
ID=82716780
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210434417.3A Active CN114897797B (en) | 2022-04-24 | 2022-04-24 | Printed circuit board defect detection method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114897797B (en) |
Cited By (2)
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 |
CN119648648A (en) * | 2024-11-25 | 2025-03-18 | 西安科航煤矿机械有限公司 | A method, device and system for detecting processing quality of mining parts |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2011087A (en) * | 1977-12-26 | 1979-07-04 | Siderurgie Fse Inst Rech | Electromagnetic detection of flaws in metal products |
CN1695166A (en) * | 2002-09-12 | 2005-11-09 | 恩莱因公司 | System and method for acquiring and processing complex images |
JP2012073684A (en) * | 2010-09-27 | 2012-04-12 | Fujitsu Ltd | Image recognition method, apparatus and program |
CN108090897A (en) * | 2017-12-18 | 2018-05-29 | 川亿电脑(深圳)有限公司 | Detection method, detection device and the storage medium of printed wire board defect |
CN108717069A (en) * | 2018-05-29 | 2018-10-30 | 电子科技大学 | A kind of high-pressure bottle thermal imaging imperfection detection method based on the segmentation of row variable step |
CN109632808A (en) * | 2018-12-05 | 2019-04-16 | 深圳大学 | Seamed edge defect inspection method, device, electronic equipment and storage medium |
CN110348499A (en) * | 2019-06-28 | 2019-10-18 | 西安理工大学 | A kind of sewing thread trace defect inspection method |
WO2019233166A1 (en) * | 2018-06-04 | 2019-12-12 | 杭州海康威视数字技术股份有限公司 | Surface defect detection method and apparatus, and electronic device |
CN113139932A (en) * | 2021-03-23 | 2021-07-20 | 广东省科学院智能制造研究所 | Deep learning defect image identification method and system based on ensemble learning |
US20210272256A1 (en) * | 2020-02-28 | 2021-09-02 | Kabushiki Kaisha Toshiba | Inspection apparatus, inspection method, and storage medium |
CN114240942A (en) * | 2022-02-25 | 2022-03-25 | 武汉市雷成龙液压机械有限公司 | A method and system for surface quality control of metal parts based on image processing |
CN114299066A (en) * | 2022-03-03 | 2022-04-08 | 清华大学 | Defect detection method and device based on saliency feature pre-extraction and image segmentation |
-
2022
- 2022-04-24 CN CN202210434417.3A patent/CN114897797B/en active Active
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2011087A (en) * | 1977-12-26 | 1979-07-04 | Siderurgie Fse Inst Rech | Electromagnetic detection of flaws in metal products |
CN1695166A (en) * | 2002-09-12 | 2005-11-09 | 恩莱因公司 | System and method for acquiring and processing complex images |
JP2012073684A (en) * | 2010-09-27 | 2012-04-12 | Fujitsu Ltd | Image recognition method, apparatus and program |
CN108090897A (en) * | 2017-12-18 | 2018-05-29 | 川亿电脑(深圳)有限公司 | Detection method, detection device and the storage medium of printed wire board defect |
CN108717069A (en) * | 2018-05-29 | 2018-10-30 | 电子科技大学 | A kind of high-pressure bottle thermal imaging imperfection detection method based on the segmentation of row variable step |
WO2019233166A1 (en) * | 2018-06-04 | 2019-12-12 | 杭州海康威视数字技术股份有限公司 | Surface defect detection method and apparatus, and electronic device |
CN109632808A (en) * | 2018-12-05 | 2019-04-16 | 深圳大学 | Seamed edge defect inspection method, device, electronic equipment and storage medium |
CN110348499A (en) * | 2019-06-28 | 2019-10-18 | 西安理工大学 | A kind of sewing thread trace defect inspection method |
US20210272256A1 (en) * | 2020-02-28 | 2021-09-02 | Kabushiki Kaisha Toshiba | Inspection apparatus, inspection method, and storage medium |
CN113139932A (en) * | 2021-03-23 | 2021-07-20 | 广东省科学院智能制造研究所 | Deep learning defect image identification method and system based on ensemble learning |
CN114240942A (en) * | 2022-02-25 | 2022-03-25 | 武汉市雷成龙液压机械有限公司 | A method and system for surface quality control of metal parts based on image processing |
CN114299066A (en) * | 2022-03-03 | 2022-04-08 | 清华大学 | Defect detection method and device based on saliency feature pre-extraction and image segmentation |
Non-Patent Citations (2)
Title |
---|
崔子冠;干宗良;唐贵进;刘峰;朱秀昌;: "联合梯度强度与方向信息的图像质量评价", 仪器仪表学报, no. 12, 15 December 2015 (2015-12-15) * |
张偌雅;李珍珍;: "数字图像质量评价综述", 现代计算机(专业版), no. 29, 15 October 2017 (2017-10-15) * |
Cited By (3)
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 |
CN119648648A (en) * | 2024-11-25 | 2025-03-18 | 西安科航煤矿机械有限公司 | A method, device and system for detecting processing quality of mining parts |
Also Published As
Publication number | Publication date |
---|---|
CN114897797B (en) | 2025-04-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111160469B (en) | An Active Learning Method for Object Detection System | |
CN111414934A (en) | Pointer type meter reading automatic identification method based on fast R-CNN and U-Net | |
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 | |
CN109410192B (en) | A fabric defect detection method and device for multi-texture grading fusion | |
CN111242899B (en) | Image-based flaw detection method and computer-readable storage medium | |
CN114266773B (en) | Display panel defect positioning method, device, equipment and storage medium | |
CN114155244B (en) | Defect detection method, device, equipment and storage medium | |
CN114897797A (en) | Method, device and equipment for detecting defects of printed circuit board and storage medium | |
CN116071405A (en) | Method and device for screen printing image registration on lithium battery surface | |
CN105354816B (en) | Electronic component positioning method and device | |
CN116152208A (en) | Defect detection method, device, equipment and storage medium | |
CN118898600B (en) | Full-automatic analyzer sample state evaluation method based on AI visual detection | |
CN112668365A (en) | Material warehousing identification method, device, equipment and storage medium | |
CN112419244B (en) | Concrete crack segmentation method and device | |
CN113744252A (en) | Method, apparatus, storage medium and program product for marking and detecting defects | |
CN118822940A (en) | Defect detection methods, devices, media, products and equipment | |
CN118247252A (en) | Data quality noise detection method based on multi-method joint variation | |
CN114359300B (en) | Optimization method, device and system of image segmentation model and storage medium | |
CN110874837A (en) | Automatic defect detection method based on local feature distribution | |
CN116433661A (en) | Method, device, equipment and medium for detecting semiconductor wafer by multitasking | |
KR20240089449A (en) | Teacher data creation support device, teacher data creation support method | |
CN119338835B (en) | Industrial part defect detection method and system based on X-rays | |
CN119068505B (en) | A PCB classification method, system and storage medium based on visual recognition | |
CN115830043B (en) | Boundary detection method, device, equipment and storage medium for wireless charging magnet |
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 | ||
CB02 | Change of applicant information |
Country or region after: China Address after: Room 572, 18th Floor, Building B4, Phase I, Longshan Innovation Park, Wuhan Future Science and Technology City, No. 999 Gaoxin Avenue, Donghu New Technology Development Zone, Wuhan City, Hubei Province, 430000 Applicant after: Wuhan Haiwei Technology Co.,Ltd. Address before: 430000 room 1588-2, 15 / F, B3 building, zone II, National Geospatial Information Industry base, No. 3, wudayuan 4th Road, East Lake New Technology Development Zone, Wuhan, Hubei Applicant before: WUHAN HAIWEI TECHNOLOGY Co.,Ltd. Country or region before: China |
|
CB02 | Change of applicant information | ||
GR01 | Patent grant | ||
GR01 | Patent grant |