PCB defect feature extraction method based on machine vision

CN122550503APending Publication Date: 2026-08-11SHENZHEN HAIYUDA ELECTRONIC TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-15
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0003]现有的缺陷检测主要针对PCB电路板轻微划痕、细小毛刺等缺陷,除了这些生产工艺的缺陷,PCB板线路的缺陷也会影响PCB板正常使用,比如公开号为CN121527479A的专利申请中,公开了基于特征提取的PCB电路板缺陷视觉检测方法及系统,该方案主要针对PCB电路板轻微划痕、细小毛刺等缺陷,未能对PCB板线路的缺陷进行检测,同时线路缺陷种类多样,需要一种简单的方法能够同时识别出线路缺陷,现有技术未能针对线路缺陷检测设定简单并且合适的检测方法,导致PCB板线路缺陷检测复杂或者准确度低

Benefits of technology

[0058]本发明的有益效果:本发明通过构建目标数据筛选方法;基于正常的PCB板图像获取历史PCB板灰度;基于历史PCB板灰度和目标数据筛选方法获取第一灰度阈值和第二灰度阈值;获取待检测的PCB板图像,标记为实时PCB板图像;基于实时PCB板图像、第一灰度阈值以及第二灰度阈值获取实时线路轮廓;基于实时线路轮廓获取实时构建值;基于正常的PCB板图像和目标数据筛选方法获取构建偏移阈值;基于实时构建值和构建偏移阈值判断线路是否出现缺陷,优势在于,针对线路缺陷检测设定简单并且合适的检测方法,提升线路缺陷检测效率和准确度;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122550503A_ABST
    Figure CN122550503A_ABST
Patent Text Reader

Abstract

The application discloses a PCB defect feature extraction method based on machine vision and relates to the technical field of defect detection, and comprises the following steps: constructing a target data screening method; obtaining historical PCB grayscale based on normal PCB images; obtaining a first grayscale threshold and a second grayscale threshold based on the historical PCB grayscale and the target data screening method; obtaining a PCB image to be detected, which is marked as a real-time PCB image; obtaining a real-time line contour based on the real-time PCB image, the first grayscale threshold and the second grayscale threshold; obtaining a real-time construction value based on the real-time line contour; obtaining a construction offset threshold based on the normal PCB image and the target data screening method; and judging whether a line has defects based on the real-time construction value and the construction offset threshold; the application is used to solve the problem that the prior art fails to set a simple and suitable detection method for line defect detection, leading to complex PCB line defect detection or low accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, specifically a method for extracting defect features from PCB boards based on machine vision. Background Technology

[0002] As the mechanical support and electrical interconnection carrier of electronic components, the manufacturing quality of printed circuit boards directly determines the reliability and lifespan of the final electronic products; therefore, defect detection of printed circuit boards is necessary.

[0003] Existing defect detection methods mainly target minor scratches and small burrs on PCB circuit boards. In addition to these manufacturing process defects, defects in PCB circuitry can also affect the normal use of PCB boards. For example, patent application CN121527479A discloses a visual inspection method and system for PCB circuit board defects based on feature extraction. This solution mainly targets minor scratches and small burrs on PCB circuit boards, but fails to detect defects in PCB circuitry. At the same time, there are various types of circuit defects, requiring a simple method to identify them simultaneously. Existing technologies have not set up a simple and appropriate detection method for circuit defects, resulting in complex or low-accuracy PCB circuit defect detection. Summary of the Invention

[0004] This invention aims to at least partially solve one of the technical problems in the prior art by constructing a target data filtering method; obtaining historical PCB board grayscale values ​​based on normal PCB board images; obtaining a first grayscale threshold and a second grayscale threshold based on the historical PCB board grayscale values ​​and the target data filtering method; obtaining a PCB board image to be detected and marking it as a real-time PCB board image; obtaining real-time circuit contours based on the real-time PCB board image, the first grayscale threshold, and the second grayscale threshold; obtaining real-time construction values ​​based on the real-time circuit contours; obtaining a construction offset threshold based on normal PCB board images and the target data filtering method; and determining whether defects have occurred in the circuit based on the real-time construction values ​​and the construction offset threshold, thereby solving problem 1.

[0005] To achieve the above objectives, this application provides a machine vision-based method for extracting defect features from PCB boards, comprising the following steps:

[0006] Construct a method for filtering target data;

[0007] Obtain historical PCB board grayscale values ​​based on normal PCB board images;

[0008] The first grayscale threshold and the second grayscale threshold are obtained based on the historical PCB board grayscale and target data filtering method;

[0009] Acquire the PCB board image to be inspected and mark it as a real-time PCB board image;

[0010] Real-time line contours are obtained based on real-time PCB board images, a first grayscale threshold, and a second grayscale threshold.

[0011] Real-time construction values ​​are obtained based on real-time line contours;

[0012] The construction offset threshold is obtained based on normal PCB board images and target data filtering methods;

[0013] Determine if a line has a defect based on real-time build values ​​and build offset thresholds.

[0014] Furthermore, constructing a target data filtering method includes the following sub-steps:

[0015] Set the target data value;

[0016] Obtain the first number of target data values;

[0017] Establish a Cartesian coordinate system with the target data value as the horizontal axis and the number of target data values ​​as the vertical axis, and label it as the target data coordinate system;

[0018] Obtain the target data value and the number of target data values ​​as the coordinates of the x-axis and y-axis, respectively, and mark them as the target data coordinate points;

[0019] Plot all target data coordinate points in the target data coordinate system;

[0020] The function is obtained by fitting all the target data coordinate points to a function, and then labeled as the target data function.

[0021] Furthermore, constructing a target data filtering method also includes the following sub-steps:

[0022] Within the range of the target data value, the area enclosed by the target data function and the horizontal axis of the target data coordinate system is obtained and marked as the first overall area;

[0023] Obtain the area of ​​the first overall region and mark it as the first overall area;

[0024] Obtain the maximum value of the ordinate among all target data coordinate points and mark it as the target data height;

[0025] Define a length, and mark it as the length of the first rectangle;

[0026] Create a rectangle on the horizontal axis of the target data coordinate system with a height equal to the target data height and a width equal to the length of the first rectangle, and be able to move left and right. Mark this rectangle as the first construction rectangle.

[0027] The average area of ​​the rectangle is obtained as follows: K2 = K1 × (D1 ÷ D2); where K2 is the average area of ​​the rectangle, K1 is the first overall area, D1 is the length of the first rectangle, and D2 is the range length of the target data value.

[0028] Set a ratio value, which is marked as the first ratio value; obtain the product of the average area of ​​the rectangle and the first ratio value, and mark it as the abnormal area threshold.

[0029] Furthermore, constructing a target data filtering method also includes the following sub-steps:

[0030] Obtain the area of ​​the intersection region between the first constructed rectangle and the first overall region, and mark it as the rectangle detection area;

[0031] The first constructed rectangle is moved to the right from the leftmost side of the target data coordinate system. When the detected area of ​​the rectangle is greater than or equal to the abnormal area threshold, the movement of the first constructed rectangle is stopped. The target data value corresponding to the minimum x-coordinate of the first constructed rectangle at this time is obtained and marked as the first range threshold.

[0032] The first constructed rectangle is moved to the left from the rightmost side of the target data coordinate system. When the detected area of ​​the rectangle is greater than or equal to the abnormal area threshold, the movement of the first constructed rectangle is stopped. The target data value corresponding to the largest x-coordinate of the first constructed rectangle at this time is obtained and marked as the second range threshold.

[0033] Furthermore, obtaining historical PCB grayscale values ​​based on normal PCB images includes the following sub-steps:

[0034] Convert normal PCB board images into grayscale images and mark them as historical PCB board grayscale images;

[0035] Obtain the grayscale values ​​of the circuit areas on the PCB board from the historical PCB board grayscale image and mark them as historical PCB board grayscale.

[0036] Furthermore, obtaining the first grayscale threshold and the second grayscale threshold based on the historical PCB board grayscale and target data filtering method includes the following sub-steps:

[0037] The historical PCB board grayscale values ​​are taken as target data values, and then the first range threshold and the second range threshold are obtained and marked as the first grayscale threshold and the second grayscale threshold, respectively.

[0038] Furthermore, obtaining the real-time circuit outline based on the real-time PCB board image, the first grayscale threshold, and the second grayscale threshold includes the following sub-steps:

[0039] Convert the real-time PCB board image into a grayscale image and label it as a real-time PCB board grayscale image.

[0040] Obtain the grayscale values ​​of pixels in the real-time PCB board grayscale image and mark them as real-time PCB board grayscale values;

[0041] Obtain the real-time grayscale values ​​of pixels between the first grayscale threshold and the second grayscale threshold, and mark them as real-time line grayscale values;

[0042] Obtain the region composed of real-time line grayscale values ​​and mark it as the real-time line region;

[0043] Obtain the outline of the real-time line area and mark it as the real-time line outline.

[0044] Furthermore, obtaining real-time construction values ​​based on real-time line contours includes the following sub-steps:

[0045] A point on the real-time line profile that is first detected is marked as the first starting point;

[0046] Draw a perpendicular line from the first starting point to the real-time line outline, and mark it as the first vertical line;

[0047] Obtain the intersection point of the first vertical line and the real-time line outline on the opposite side, and mark it as the second starting point;

[0048] Starting from a first starting point, move along one direction of the real-time line profile, while simultaneously moving a second starting point along the same direction of the real-time line profile, with the first and second starting points moving the same distance.

[0049] While moving simultaneously, the slope of the real-time line profile at the first starting point is obtained and marked as the first search slope;

[0050] Obtain the slope of the real-time line profile at the second starting point and mark it as the second search slope;

[0051] Obtain the absolute value of the difference between the first search slope and the second search slope, and mark it as the real-time construction value.

[0052] Furthermore, obtaining the construction offset threshold based on normal PCB board images and target data filtering methods includes the following sub-steps:

[0053] Obtain real-time construction values ​​for straight lines and corners on a normal route, and mark them as historical construction values;

[0054] The historical build values ​​are treated as target data values, and then a second range threshold is obtained and marked as the build offset threshold.

[0055] Furthermore, determining whether a line has a defect based on real-time build values ​​and build offset thresholds includes the following sub-steps:

[0056] Determine if the real-time construction value exceeds the construction offset threshold, obtain the positions of the first and second starting points at this time, and mark them as the first abnormal point.

[0057] Determine whether the first abnormal point reaches the connection between the line and the via. If so, treat the first abnormal point as a normal via connection. If not, treat the first abnormal point as a defective point.

[0058] The beneficial effects of this invention are as follows: This invention constructs a target data filtering method; obtains historical PCB board grayscale values ​​based on normal PCB board images; obtains a first grayscale threshold and a second grayscale threshold based on the historical PCB board grayscale values ​​and the target data filtering method; obtains the PCB board image to be detected and marks it as a real-time PCB board image; obtains real-time circuit contours based on the real-time PCB board image, the first grayscale threshold, and the second grayscale threshold; obtains real-time construction values ​​based on the real-time circuit contours; obtains a construction offset threshold based on normal PCB board images and the target data filtering method; and determines whether a defect has occurred in the circuit based on the real-time construction value and the construction offset threshold. The advantage lies in setting a simple and appropriate detection method for circuit defect detection, thereby improving the efficiency and accuracy of circuit defect detection.

[0059] This invention obtains real-time construction values ​​based on real-time line contours. Its advantage lies in improving the efficiency and accuracy of line defect detection by performing defect detection based on real-time construction values. Attached Figure Description

[0060] Figure 1 This is a flowchart of the steps of the method of the present invention;

[0061] Figure 2 This is a schematic diagram of the target data function of the present invention;

[0062] Figure 3 This is a schematic diagram of the first range threshold and the second range threshold of the present invention;

[0063] Figure 4 This is a schematic diagram of the first abnormal point of the present invention. Detailed Implementation

[0064] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0065] Example 1, please refer to Figure 1 As shown, this application provides a machine vision-based method for extracting defect features from PCB boards, including the following steps:

[0066] Step S1, construct the target data filtering method; Step S1 includes the following sub-steps:

[0067] Step S101: Set the target data value; for example, the target data value is the historical PCB board grayscale; in order to obtain the accurate range of the target data value;

[0068] Step S102: Obtain a first number of target data values; the target data values ​​are a range, for example, the first number is 1000.

[0069] Step S103: Establish a Cartesian coordinate system with the target data value as the horizontal axis and the number of target data values ​​as the vertical axis, and mark it as the target data coordinate system;

[0070] Step S104: Obtain the coordinates of the target data value and the number of target data values ​​as the x-coordinate and y-coordinate respectively, and mark them as the target data coordinate points;

[0071] Step S105: Plot all target data coordinate points in the target data coordinate system;

[0072] Step S106: Perform function fitting on all target data coordinate points to obtain a function, and mark it as the target data function;

[0073] In practical applications, for example, if the target data value is the historical grayscale value of a PCB board, please refer to [link / reference needed]. Figure 2 The diagram shows a schematic of the target data function obtained.

[0074] Step S107: Within the range of the target data value, obtain the area enclosed by the target data function and the horizontal axis of the target data coordinate system, and mark it as the first overall area;

[0075] Step S108: Obtain the area of ​​the first overall region and mark it as the first overall area;

[0076] Step S109: Obtain the maximum value of the ordinate among all target data coordinate points and mark it as the target data height;

[0077] Step S110: Set a length, marked as the first rectangle length; the first rectangle length is set to define the first construction rectangle and to observe the distribution of target data values ​​based on the first construction rectangle. Therefore, the first rectangle length should not be set too large, for example, the first rectangle length is 1cm.

[0078] Step S111: Create a rectangle on the horizontal axis of the target data coordinate system with a height equal to the target data height and a width equal to the length of the first rectangle, and mark it as the first construction rectangle;

[0079] Step S112, obtain the average area of ​​the rectangle as: K2=K1×(D1÷D2;where K2 is the average area of ​​the rectangle, K1 is the first overall area, D1 is the length of the first rectangle, and D2 is the range length of the target data value;

[0080] In practical applications, a distance of 1cm is defined as the distance corresponding to a target data value length of 1; for example, the first overall area obtained is 120cm². 2 The length of the first rectangle is 1cm, and the length of the second rectangle is 16cm. The average area of ​​the rectangles is: K2 = 120 × (1 ÷ 16) = 7.5cm². 2 .

[0081] Step S113: Set a ratio value and mark it as the first ratio value; obtain the product of the average area of ​​the rectangle and the first ratio value and mark it as the abnormal area threshold; the abnormal area threshold is set in order to obtain the area with less distribution of target data values, so the abnormal area threshold should not be set too large, so the first ratio value should not be too large, for example, the first ratio value is 0.2;

[0082] In practical applications, the threshold for abnormal area is: 0.2 × 7.5 = 1.5 cm. 2 .

[0083] Step S114: Obtain the area of ​​the intersection region between the first constructed rectangle and the first overall region, and mark it as the rectangle detection area;

[0084] Step S115: Move the first constructing rectangle from the leftmost side of the target data coordinate system to the right. When the detected area of ​​the rectangle is greater than or equal to the abnormal area threshold, stop moving the first constructing rectangle. Obtain the target data value corresponding to the smallest x-coordinate of the first constructing rectangle at this time and mark it as the first range threshold. Filter out the target data values ​​that are too small to obtain a more accurate minimum target data value.

[0085] Step S116: Move the first constructed rectangle from the rightmost side of the target data coordinate system to the left. When the detected area of ​​the rectangle is greater than or equal to the abnormal area threshold, stop moving the first constructed rectangle. Obtain the target data value corresponding to the largest x-coordinate of the first constructed rectangle at this time and mark it as the second range threshold. Filter out excessively large target data values ​​to obtain a more accurate maximum target data value.

[0086] In practical applications, the first constructed rectangle is translated to the right from the leftmost side of the target data coordinate system. This is done when the rectangle's detection area is greater than or equal to 1.5 cm. 2 Stop moving the first construction rectangle; see [link / reference] Figure 4As shown, at the stopping position of the first constructed rectangle, the target data value corresponding to the smallest x-coordinate of the first constructed rectangle at this time is obtained, which is 181. Therefore, the first range threshold is 181. The first constructed rectangle is then shifted to the left from the rightmost side of the target data coordinate system. When the detected area of ​​the rectangle is greater than or equal to 1.5cm... 2 Stop moving the first construction rectangle; see [link / reference] Figure 4 As shown, the first constructed rectangle stops at its designated position; the target data value corresponding to the largest x-coordinate of the first constructed rectangle at this point is 195, so the second range threshold is 195.

[0087] Step S2: Obtain historical PCB grayscale values ​​based on normal PCB board images; Step S2 includes the following sub-steps:

[0088] Step S201: Convert the normal PCB board image into a grayscale image and mark it as a historical PCB board grayscale image; the normal PCB board image and the real-time PCB board image should have the same illumination intensity to facilitate the acquisition of the circuit area;

[0089] Step S202: Obtain the grayscale values ​​of the line areas on the PCB board in the historical PCB board grayscale image and mark them as historical PCB board grayscale.

[0090] Step S3 involves obtaining a first grayscale threshold and a second grayscale threshold based on historical PCB board grayscale and target data filtering methods. Step S3 includes the following sub-steps:

[0091] Step S301: Treat the historical PCB board grayscale as the target data value, and then obtain the first range threshold and the second range threshold, which are respectively marked as the first grayscale threshold and the second grayscale threshold.

[0092] In practical applications, the historical PCB board grayscale is regarded as the target data value. Then, the first range threshold and the second range threshold are obtained as 181 and 195 respectively. Thus, the first grayscale threshold and the second grayscale threshold are 181 and 195 respectively.

[0093] Step S4: Obtain the image of the PCB board to be inspected and mark it as a real-time PCB board image.

[0094] Step S5: Obtain the real-time circuit outline based on the real-time PCB board image, the first grayscale threshold, and the second grayscale threshold; Step S5 includes the following sub-steps:

[0095] Step S501: Convert the real-time PCB board image into a grayscale image and mark it as a real-time PCB board grayscale image.

[0096] Step S502: Obtain the grayscale value of the pixel in the real-time PCB board grayscale image and mark it as the real-time PCB board grayscale value;

[0097] Step S503: Obtain the real-time PCB board grayscale value of the pixel points between the first grayscale threshold and the second grayscale threshold, and mark it as the real-time line grayscale value.

[0098] Step S504: Obtain the region composed of real-time line grayscale values ​​and mark it as the real-time line region;

[0099] Step S505: Obtain the outline of the real-time circuit area and mark it as the real-time circuit outline; the real-time circuit outline is the outline of the PCB board circuit.

[0100] In practical applications, the real-time grayscale values ​​of PCB board pixels between 181 and 195 are obtained and marked as real-time line grayscale values.

[0101] Step S6: Obtain real-time construction values ​​based on real-time line contours; Step S6 includes the following sub-steps:

[0102] Step S601: Mark a point on the real-time line profile that is being detected as the first starting point;

[0103] Step S602: Draw a perpendicular line from the first starting point to the real-time line profile and mark it as the first vertical line;

[0104] Step S603: Obtain the intersection point of the first vertical line and the real-time line outline on the opposite side, and mark it as the second starting point;

[0105] Step S604: Starting from the first starting point, move along one direction of the real-time line profile, while the second starting point moves along the same direction of the real-time line profile, and the first and second starting points move the same distance.

[0106] Step S605: While moving simultaneously, obtain the slope of the real-time line profile of the first starting point and mark it as the first search slope;

[0107] Step S606: Obtain the slope of the real-time line profile of the second starting point and mark it as the second search slope;

[0108] Step S607: Obtain the absolute value of the difference between the first search slope and the second search slope, and mark it as the real-time construction value. Since the line width is consistent, the first search slope and the second search slope are consistent, and the real-time construction value will be close to 0. If the line has defects or breaks, the first search slope and the second search slope will be different, and the real-time construction value will increase. Therefore, the real-time construction value can be used to determine whether there are defects in the line.

[0109] Step S7: Obtain the construction offset threshold based on normal PCB board image and target data filtering methods; Step S7 includes the following sub-steps:

[0110] Step S701: Obtain the real-time construction values ​​of straight lines and corners of normal routes, and mark them as historical construction values;

[0111] Step S702: Treat the historical construction value as the target data value, and then obtain the second range threshold, which is marked as the construction offset threshold. The construction offset threshold is the maximum value of the real-time construction value of the normal PCB board circuit. If it exceeds the construction offset threshold, it can be preliminarily considered that a defect has occurred. The maximum value of the real-time construction value of the normal PCB board circuit obtained by the target data filtering method is more accurate.

[0112] In practical applications, historical construction values ​​are treated as target data values, and then the second range threshold is set to 0.2, so the construction offset threshold is 0.2.

[0113] Step S8: Determine whether a defect has occurred in the line based on the real-time construction value and the construction offset threshold; Step S8 includes the following sub-steps:

[0114] Step S801: Determine whether the real-time construction value is greater than the construction offset threshold, obtain the positions of the first starting point and the second starting point at this time, and mark them as the first abnormal point. The first abnormal point may be that the line reaches the via. The via on the PCB board is a small hole drilled between layers. The hole wall is made conductive by electroplating copper. Its core function is to connect the wires of different layers in the multilayer board. When the line reaches the via, the construction value will also be greater than the construction offset threshold, so further judgment is required.

[0115] Step S802: Determine whether the first abnormal point reaches the connection between the line and the via. If yes, the first abnormal point is regarded as a normal via connection. If not, the first abnormal point is regarded as a defective point. Therefore, if the first abnormal point reaches the connection between the line and the via, it means that the line is normal. If not, it means that the line has a defect.

[0116] For practical applications, please refer to Figure 4 As shown, if the first abnormal point does not reach the connection between the line and the via, it indicates that there is a defect in the line at this point.

[0117] Example 2: This application also provides an electronic device, which may include: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus. The memory stores computer-readable instructions, and the processor can call the instructions in the memory. When the computer-readable instructions are executed by the processor, steps such as those in the PCB board defect feature extraction method based on machine vision are performed to achieve the following functions: constructing a target data filtering method; obtaining historical PCB board grayscale based on normal PCB board images; obtaining a first grayscale threshold and a second grayscale threshold based on historical PCB board grayscale and the target data filtering method; acquiring a PCB board image to be detected and marking it as a real-time PCB board image; obtaining real-time circuit contours based on the real-time PCB board image, the first grayscale threshold, and the second grayscale threshold; obtaining real-time construction values ​​based on the real-time circuit contours; obtaining a construction offset threshold based on normal PCB board images and the target data filtering method; and determining whether a defect has occurred in the circuit based on the real-time construction value and the construction offset threshold.

[0118] Furthermore, when the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0119] Example 3: This application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the PCB board defect feature extraction method based on machine vision provided by the above methods. The method includes: constructing a target data filtering method; obtaining historical PCB board grayscale based on normal PCB board images; obtaining a first grayscale threshold and a second grayscale threshold based on historical PCB board grayscale and the target data filtering method; obtaining a PCB board image to be detected and marking it as a real-time PCB board image; obtaining real-time circuit contours based on the real-time PCB board image, the first grayscale threshold, and the second grayscale threshold; obtaining real-time construction values ​​based on the real-time circuit contours; obtaining a construction offset threshold based on normal PCB board images and the target data filtering method; and determining whether a defect has occurred in the circuit based on the real-time construction value and the construction offset threshold.

[0120] Example 4: This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it performs the steps of the above-described PCB board defect feature extraction method based on machine vision to achieve the following functions: constructing a target data filtering method; obtaining historical PCB board grayscale values ​​based on normal PCB board images; obtaining a first grayscale threshold and a second grayscale threshold based on historical PCB board grayscale values ​​and the target data filtering method; obtaining an image of the PCB board to be detected and marking it as a real-time PCB board image; obtaining real-time circuit contours based on the real-time PCB board image, the first grayscale threshold, and the second grayscale threshold; obtaining real-time construction values ​​based on the real-time circuit contours; obtaining a construction offset threshold based on normal PCB board images and the target data filtering method; and determining whether a defect has occurred in the circuit based on the real-time construction value and the construction offset threshold.

[0121] Based on the above description of the embodiments, the embodiments of the present invention can be provided as methods, systems, or computer program products. Based on this understanding, the above technical solutions, in essence or in terms of their contribution to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or certain parts of the embodiments.

[0122] In the embodiments provided in this application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of modules or units is only a logical functional division, and there may be other division methods in actual implementation. Furthermore, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces. The indirect coupling or communication connection between systems, modules, and units may be electrical, mechanical, or other forms.

[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for extracting a defect feature of a PCB based on machine vision, characterized in that, Includes the following steps: Construct a method for filtering target data; Obtain historical PCB board grayscale values ​​based on normal PCB board images; The first grayscale threshold and the second grayscale threshold are obtained based on the historical PCB board grayscale and target data filtering method; Acquire the PCB board image to be inspected and mark it as a real-time PCB board image; Real-time line contours are obtained based on real-time PCB board images, a first grayscale threshold, and a second grayscale threshold. Real-time construction values ​​are obtained based on real-time line contours; The construction offset threshold is obtained based on normal PCB board images and target data filtering methods; Determine if a line has a defect based on real-time build values ​​and build offset thresholds. 2.The method of claim 1, wherein, Constructing a target data filtering method includes the following sub-steps: Set the target data value; Obtain the first number of target data values; Establish a Cartesian coordinate system with the target data value as the horizontal axis and the number of target data values ​​as the vertical axis, and label it as the target data coordinate system; Obtain the target data value and the number of target data values ​​as the coordinates of the x-axis and y-axis, respectively, and mark them as the target data coordinate points; Plot all target data coordinate points in the target data coordinate system; The function is obtained by fitting all the target data coordinate points to a function, and then labeled as the target data function. 3.The method of claim 2, wherein, The construction of a target data filtering method also includes the following sub-steps: Within the range of the target data value, the area enclosed by the target data function and the horizontal axis of the target data coordinate system is obtained and marked as the first overall area; Obtain the area of ​​the first overall region and mark it as the first overall area; Obtain the maximum value of the ordinate among all target data coordinate points and mark it as the target data height; Define a length, and mark it as the length of the first rectangle; Create a rectangle on the horizontal axis of the target data coordinate system with a height equal to the target data height and a width equal to the length of the first rectangle, and be able to move left and right. Mark this rectangle as the first construction rectangle. The average area of ​​the rectangle is obtained as follows: K2 = K1 × (D1 ÷ D2); where K2 is the average area of ​​the rectangle, K1 is the first overall area, D1 is the length of the first rectangle, and D2 is the range length of the target data value. Set a ratio value, which is marked as the first ratio value; obtain the product of the average area of ​​the rectangle and the first ratio value, and mark it as the abnormal area threshold.

4. The method of claim 3, wherein the method further comprises: The construction of a target data filtering method also includes the following sub-steps: Obtain the area of ​​the intersection region between the first constructed rectangle and the first overall region, and mark it as the rectangle detection area; The first constructed rectangle is moved to the right from the leftmost side of the target data coordinate system. When the detected area of ​​the rectangle is greater than or equal to the abnormal area threshold, the movement of the first constructed rectangle is stopped. The target data value corresponding to the minimum x-coordinate of the first constructed rectangle at this time is obtained and marked as the first range threshold. The first constructed rectangle is moved to the left from the rightmost side of the target data coordinate system. When the detected area of ​​the rectangle is greater than or equal to the abnormal area threshold, the movement of the first constructed rectangle is stopped. The target data value corresponding to the largest x-coordinate of the first constructed rectangle at this time is obtained and marked as the second range threshold.

5. The PCB board defect feature extraction method based on machine vision according to claim 4, characterized in that, Obtaining historical PCB board grayscale values ​​from normal PCB board images includes the following sub-steps: Convert normal PCB board images into grayscale images and mark them as historical PCB board grayscale images; Obtain the grayscale values ​​of the circuit areas on the PCB board from the historical PCB board grayscale image and mark them as historical PCB board grayscale. 6.The method of claim 5, wherein, Obtaining the first grayscale threshold and the second grayscale threshold based on the historical PCB board grayscale and target data filtering method includes the following sub-steps: The historical PCB board grayscale values ​​are taken as target data values, and then the first range threshold and the second range threshold are obtained and marked as the first grayscale threshold and the second grayscale threshold, respectively.

7. The machine vision-based PCB defect feature extraction method of claim 6, wherein, Obtaining the real-time circuit outline based on the real-time PCB board image, the first grayscale threshold, and the second grayscale threshold includes the following sub-steps: Convert the real-time PCB board image into a grayscale image and label it as a real-time PCB board grayscale image. Obtain the grayscale values ​​of pixels in the real-time PCB board grayscale image and mark them as real-time PCB board grayscale values; Obtain the real-time grayscale values ​​of pixels between the first grayscale threshold and the second grayscale threshold, and mark them as real-time line grayscale values; Obtain the region composed of real-time line grayscale values ​​and mark it as the real-time line region; Obtain the outline of the real-time line area and mark it as the real-time line outline.

8. The PCB board defect feature extraction method based on machine vision according to claim 7, characterized in that, Obtaining real-time constructed values ​​based on real-time line contours includes the following sub-steps: A point on the real-time line profile that is first detected is marked as the first starting point; Draw a perpendicular line from the first starting point to the real-time line outline, and mark it as the first vertical line; Obtain the intersection point of the first vertical line and the real-time line outline on the opposite side, and mark it as the second starting point; Starting from a first starting point, move along one direction of the real-time line profile, while simultaneously moving a second starting point along the same direction of the real-time line profile, with the first and second starting points moving the same distance. While moving simultaneously, the slope of the real-time line profile at the first starting point is obtained and marked as the first search slope; Obtain the slope of the real-time line profile at the second starting point and mark it as the second search slope; Obtain the absolute value of the difference between the first search slope and the second search slope, and mark it as the real-time construction value. 9.The method of claim 8, wherein, Obtaining the construction offset threshold based on normal PCB board images and target data filtering methods includes the following sub-steps: Obtain real-time construction values ​​for straight lines and corners on a normal route, and mark them as historical construction values; The historical build values ​​are treated as target data values, and then a second range threshold is obtained and marked as the build offset threshold.

10. The machine vision-based PCB defect feature extraction method of claim 9, wherein, Determining whether a line has a defect based on real-time build values ​​and build offset thresholds includes the following sub-steps: Determine if the real-time construction value exceeds the construction offset threshold, obtain the positions of the first and second starting points at this time, and mark them as the first abnormal point. Determine whether the first abnormal point reaches the connection between the line and the via. If so, treat the first abnormal point as a normal via connection. If not, treat the first abnormal point as a defective point.

Citation Information

Patent Citations

  • PCB (Printed Circuit Board) defect visual detection method and system based on feature extraction

    CN121527479A