Automatic optical detection device and method for circuit board defects

By using edge detection and feature pixel matching, circuit board defects are identified, solving the problem of missed and false detections caused by tiny defects being submerged in the background texture, thus achieving more accurate circuit board defect detection.

CN121347526AInactive Publication Date: 2026-01-16DONGGUAN CITY SHUYUE ELECTRNIC CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511705588.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-20
Publication Date
2026-01-16
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Circuit board defects are often small and easily obscured by the background texture, leading to missed or false detections and affecting the accuracy of the test results.

Method used

Feature pixels of circuit board edge images and standard circuit board edge images are obtained by edge detection. The relative differences and motion vectors of matching feature pixels are calculated to identify abnormal moving pixels. Combined with the smoothness of changes in connected components, the probability of defects is calculated to obtain the optical detection results of circuit board defects.

Benefits of technology

It improves the accuracy of circuit board defect detection, reduces missed and false detections, and enhances the reliability of test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121347526A_ABST
    Figure CN121347526A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image matching, in particular to an automatic optical detection device and method for circuit board defects, and the method comprises the steps: collecting a standard circuit board image and a circuit board image of a to-be-detected circuit board, and extracting feature pixel points; determining a relative difference of the corresponding feature pixel points and a matched motion vector of the edge pixel points, and identifying all abnormal motion pixel points; and acquiring a connected domain formed by the abnormal motion pixel points, calculating the change smoothness of the connected domain and the defect possibility of the circuit board to be detected, and acquiring an optical detection result of the circuit board defect according to the defect possibility. The accuracy of circuit board defects can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image matching technology, specifically to an automatic optical inspection device and method for circuit board defects. Background Technology

[0002] In the manufacturing process of PCB printed circuit boards, even the slightest process deviation can lead to defects, such as component misalignment, solder bridging, cold solder joints, missing components, or reversed polarity. Automated optical inspection can be used to compare the actual image of the circuit board with a standard image, automatically identifying differences exceeding tolerance limits. This enables visual inspection of the circuit board, preventing defects that could lead to product malfunctions and decreased reliability.

[0003] However, the defects on the circuit board are relatively small and easily get lost in the background texture, leading to missed or false detections of these minor defects and affecting the accuracy of the circuit board defect detection results. Summary of the Invention

[0004] To address the aforementioned technical problems, this application provides an automatic optical inspection device and method for circuit board defects, the specific technical solution of which is as follows: In a first aspect, one embodiment of this application provides an automated optical inspection method for circuit board defects, the method comprising the following steps: Acquire a standard circuit board image and a circuit board image of the circuit board to be inspected. Obtain a circuit board edge image composed of edge pixels and a standard circuit board edge image composed of standard edge pixels through edge detection. Extract all feature pixels from the circuit board edge image and the standard circuit board edge image. The corresponding feature pixels in the circuit board edge image and the standard circuit board edge image are denoted as matching feature pixels. Based on the differences in different pixel values ​​in the local neighborhood of the feature pixels and the positional relationship between the corresponding feature pixels and the edge pixels in the circuit board edge image and the standard circuit board edge image, the relative differences of the matching feature pixels are determined. Based on the relative differences of all matching feature pixels, the matching motion vector of each edge pixel in the circuit board edge image is determined. Based on the differences between the matching motion vectors of all edge pixels, all abnormal motion pixels in the circuit board edge image are identified. The connected components formed by abnormally moving pixels in the circuit board edge image are obtained. The smoothness of the change of the connected components is calculated based on the difference between the matching motion vectors of all abnormally moving pixels in the same connected component and other edge pixels in the local neighborhood. The probability of defects of the circuit board to be detected corresponding to the circuit board edge image is calculated by combining the matching differences of all abnormally moving pixels in all connected components in the circuit board edge image. Based on the probability of defects, the optical detection results of the circuit board defects are obtained.

[0005] Furthermore, the method for obtaining the relative differences of the matching feature pixels is as follows: The grayscale difference of matching feature pixels is determined based on the difference in different pixel values ​​within the local neighborhood of the feature pixel. The relative positional difference of the matching feature pixels is determined based on the positional relationship between the corresponding feature pixels and the edge pixels in the circuit board edge image and the standard circuit board edge image. The positive correlation between the grayscale difference and the relative position difference of the matched feature pixels is denoted as the relative difference of the matched feature pixels.

[0006] Furthermore, the method for obtaining the grayscale difference of the matching feature pixels is as follows: The sum of the absolute values ​​of the differences in grayscale values ​​of all corresponding pixels within the local neighborhood of the matching feature pixel is denoted as the first difference sum of the matching feature pixel; the absolute value of the difference in grayscale values ​​of the matching feature pixel is denoted as the first difference value of the matching feature pixel; the positive correlation result between the first difference sum of the matching feature pixel and the first difference value is denoted as the grayscale difference degree of the matching feature pixel.

[0007] Furthermore, the method for obtaining the relative positional difference of the matching feature pixels is as follows: The minimum Euclidean distance between a feature pixel and all edge pixels in the edge image is denoted as the first relative distance of the feature pixel. The absolute value of the difference between the first relative distances of the corresponding matching feature pixels is denoted as the relative position difference of the corresponding matching feature pixels.

[0008] Furthermore, the method for obtaining the matching motion vector of each edge pixel in the circuit board edge image is as follows: The relative difference between matching feature pixels is used as the matching cost between matching feature pixels. The Hungarian algorithm is used to match all corresponding feature pixels in the circuit board edge image and the standard circuit board edge image. Combined with the homography matrix, the matching results of edge pixels in the circuit board edge image and the standard circuit board edge image are obtained. The vector pointing from the standard edge pixel in the standard circuit board edge image to the matching edge pixel in the circuit board edge image is denoted as the matching motion vector of the matching edge pixel in the circuit board edge image.

[0009] Furthermore, the method for obtaining the abnormal motion pixels is as follows: Let any edge pixel in the circuit board edge image be the target edge pixel. Let the mean of the absolute values ​​of the differences between the directions of the matching motion vectors of the target edge pixel and all other edge pixels in the circuit board edge image be the matching direction difference of the target edge pixel. Let the mean of the absolute values ​​of the differences between the lengths of the matching motion vectors of the target edge pixel and all other edge pixels in the circuit board edge image be the matching length difference of the target edge pixel. Let the positive correlation between the matching direction difference and the matching length difference of the target edge pixel be the matching difference of the target edge pixel. Based on the matching differences of all edge pixels in the circuit board edge image, a matching difference threshold is determined, and all pixels with matching differences greater than the matching difference threshold are recorded as abnormal motion pixels.

[0010] Furthermore, the method for calculating the smoothness of change of the connected components is as follows: Other edge pixels contained in the local neighborhood of the abnormal motion pixel are denoted as adjacent edge pixels. The sum of the magnitudes of the vector differences between the abnormal motion pixel and all its adjacent edge pixels in the local neighborhood is denoted as the local similarity difference of the abnormal motion pixel. The normalized value of the sum of the local similarity differences of all abnormal moving pixels in the same connected region is denoted as the first normalized value of the connected region. The difference between the number 1 and the first normalized value of the connected region is denoted as the smoothness of the change of the connected region.

[0011] Furthermore, the method for obtaining the probability of defects in the circuit board to be detected corresponding to the circuit board edge image is as follows: The product of the average matching difference of all abnormally moving pixels in the connected region and the smoothness of the change in the connected region is denoted as the defect probability of the connected region. The maximum value of the defect probability of all connected components identified in the circuit board edge image is denoted as the defect probability of the circuit board to be detected corresponding to the circuit board edge image.

[0012] Furthermore, the specific method for obtaining the optical inspection results of circuit board defects based on the probability of defects includes: Circuit boards to be inspected that have a defect probability greater than or equal to a preset defect judgment threshold are judged as defective circuit boards; otherwise, they are judged as normal circuit boards.

[0013] Secondly, another embodiment of this application provides an automatic optical inspection device for circuit board defects, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the automatic optical inspection method for circuit board defects described above.

[0014] The embodiments of this application have at least the following beneficial effects: This application acquires images of the circuit board to be inspected and a defect-free, quality-compliant circuit board. Since directly matching the circuit board edge image with a standard circuit board edge image requires excessive computational resources, to achieve real-time detection, feature points are extracted from the circuit board edge image and the standard circuit board edge image for matching. Corresponding matching feature pixels are identified from the images. The similarity of the local grayscale features and local relative position features of the matching feature pixels is evaluated to obtain the relative differences between the matching feature pixels. Based on the relative differences of all matching feature pixels, the circuit board edge image and the standard circuit board edge image are matched to obtain the matching motion vectors of the corresponding edge pixels. Based on the differences between the matching motion vectors of all edge pixels, all abnormal motion pixels in the circuit board edge image are identified. The connected components formed by the abnormal motion pixels in the circuit board edge image correspond to abnormal edges that may be circuit board defects. Furthermore, based on the feature ratios of the abnormal motion pixels corresponding to the location of the circuit board defect... By analyzing the spatial distribution of abnormal moving pixels and the similarity of matching motion vectors within the local area of ​​abnormal moving pixels, and by considering features located in the same local region, the smoothness of connected component changes is obtained. The greater the smoothness of connected component changes, the greater the difference between the matching motion vectors of all abnormal moving pixels contained in the edge of the connected component and the adjacent edge pixels. Moreover, the difference is more likely to be caused by inconsistency with the standard template, and less likely to be caused by noise or other influences. The edge corresponding to the connected component is more likely to correspond to a circuit board defect. Then, by combining the matching differences of all abnormal moving pixels in all connected components in the circuit board edge image, the probability of the circuit board to be detected having a defect corresponding to the circuit board edge image is evaluated. Based on the evaluation results, the optical detection results of the circuit board defect are obtained, which solves the problem that the circuit board defect is small and easily submerged in the background texture, leading to missed detection and false detection of small circuit board defects, and improves the accuracy of circuit board defect detection results. Attached Figure Description

[0015] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 A flowchart illustrating the steps of an automated optical inspection method for circuit board defects, provided as an embodiment of this application; Figure 2This is a flowchart illustrating the feature pixel acquisition process provided in one embodiment of this application. Detailed Implementation

[0017] To further illustrate the technical means and effects adopted by this application to achieve the intended purpose of the invention, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of an automatic optical inspection device and method for circuit board defects proposed in this application. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.

[0019] The following description, in conjunction with the accompanying drawings, details the specific scheme of the automatic optical inspection device and method for circuit board defects provided in this application.

[0020] Please see Figure 1 The diagram illustrates a flowchart of an automated optical inspection method for circuit board defects according to an embodiment of this application. The method includes the following steps: Step S001: Acquire a standard circuit board image and a circuit board image of the circuit board to be inspected. Obtain a circuit board edge image composed of edge pixels and a standard circuit board edge image composed of standard edge pixels through edge detection. Extract all feature pixels from the circuit board edge image and the standard circuit board edge image.

[0021] A conveyor belt transports the circuit board to be inspected. A camera is positioned above the conveyor belt and fixed in place by a bracket. The camera captures images of the circuit board within its viewfinder, thus obtaining the circuit board image. The U-net semantic segmentation model is used to process the denoised circuit board image, removing the background and obtaining the foreground image. Edge detection is then performed on the foreground image to obtain the circuit board edge image and all edge pixels within it.

[0022] Images of defect-free, quality-compliant circuit boards are acquired and designated as standard circuit board images. The U-net semantic segmentation model is used to process the denoised standard circuit board images, removing the background and obtaining standard foreground images. Edge detection is then performed on the standard foreground images to obtain standard circuit board edge images and all standard edge pixels within those images.

[0023] Among them, image denoising, using the U-net semantic segmentation model to remove the background from the image, and image edge detection are all well-known techniques and will not be described in detail. In this embodiment, Gaussian filtering denoising algorithm is used to denoise the circuit board image, and Canny edge detection algorithm is used to perform edge detection.

[0024] It should be noted that the circuit board defects identified in this embodiment are mainly processing defects, specifically including cold solder joints, incomplete solder joints, solder balls, inadequate cleaning, and flux residue.

[0025] Directly matching the circuit board edge image with the standard circuit board edge image requires too much computational resources. In order to achieve real-time detection, feature points are extracted from the circuit board edge image and the standard circuit board edge image for matching.

[0026] Preferably, as an embodiment of this application, the SUSAN algorithm is used to extract feature pixels from the circuit board edge image and the standard circuit board edge image.

[0027] The flowchart for obtaining feature pixels is as follows: Figure 2 As shown. The use of the SUSAN algorithm to extract feature points from different images is a well-known technique and will not be elaborated further.

[0028] This completes the acquisition of all feature pixels in the circuit board edge image and the standard circuit board edge image.

[0029] Step S002: Record the corresponding feature pixels in the circuit board edge image and the standard circuit board edge image as matching feature pixels. Determine the relative difference of the matching feature pixels based on the difference of different pixel values ​​in the local neighborhood of the feature pixels and the positional relationship between the corresponding feature pixels and the edge pixels in the circuit board edge image and the standard circuit board edge image. Determine the matching motion vector of each edge pixel in the circuit board edge image based on the relative difference of all matching feature pixels. Identify all abnormal motion pixels in the circuit board edge image based on the difference between the matching motion vectors of all edge pixels.

[0030] The corresponding feature pixels in the circuit board edge image and the standard circuit board edge image are recorded as matching feature pixels. The grayscale difference of the matching feature pixels is determined based on the difference of different pixel values ​​in the local neighborhood of the corresponding feature pixels in the circuit board edge image and the standard circuit board edge image.

[0031] Preferably, as an embodiment of this application, the sum of the absolute values ​​of the differences in grayscale values ​​of all corresponding pixels contained in the local neighborhood of the matching feature pixel is denoted as the first difference sum of the matching feature pixel; the absolute value of the difference in grayscale values ​​of the matching feature pixel is denoted as the first difference value of the matching feature pixel; and the positive correlation result between the first difference sum of the matching feature pixel and the first difference value is denoted as the grayscale difference degree of the matching feature pixel.

[0032] It is understood that a positive correlation is applied to the first sum of differences and the first difference value of the matching feature pixels, ensuring that the first sum of differences and the first difference value of the matching feature pixels are positively correlated with the grayscale difference of the matching feature pixels. It is also understood that the positive correlation in this application refers to the relationship between the independent variable and the dependent variable, where the independent variable is the first sum of differences and the first difference value of the matching feature pixels, and the dependent variable is the grayscale difference of the matching feature pixels. A positive correlation means that the dependent variable increases (decreases) as the independent variable increases (decreases), and can be an additive relationship, a multiplicative relationship, etc.

[0033] Preferably, as an embodiment of this application, the product of the first difference summation of the matching feature pixels and the first difference value is denoted as the grayscale difference of the matching feature pixels.

[0034] In this embodiment, a local area with a side length of 3 centered on the matching feature pixel is used as the local neighborhood of the matching feature pixel.

[0035] To more accurately match feature pixels, it's necessary to consider the differences in the relative positions of the circuit board within the camera's viewfinder in the circuit board image and the standard circuit board image. When the placement and relative positions of the circuit board to be inspected differ from those of a defect-free, quality-compliant circuit board on the conventional tape and within the camera's viewfinder, matching the corresponding feature pixels solely based on grayscale differences may lead to unreliable matching results. Therefore, evaluating the relative positions of the matching feature pixels is essential.

[0036] The relative positional difference of the matching feature pixels is determined based on the positional relationship between the corresponding feature pixels and the edge pixels in the circuit board edge image and the standard circuit board edge image.

[0037] The minimum Euclidean distance between a feature pixel and all edge pixels in the edge image is denoted as the first relative distance of the feature pixel. The absolute value of the difference between the first relative distances of the corresponding matching feature pixels is denoted as the relative position difference of the corresponding matching feature pixels.

[0038] It is understandable that when a feature pixel is also an edge pixel, the first relative distance of the feature pixel is 0; the value of the relative position difference of the corresponding matching feature pixel is denoted as the value of the relative position difference of each matching feature pixel in the corresponding matching feature pixel.

[0039] The positive correlation between the grayscale difference and the relative position difference of the matched feature pixels is denoted as the relative difference of the matched feature pixels.

[0040] Preferably, as an embodiment of this application, the normalized value of the product of the grayscale difference and the relative position difference of the matching feature pixels is denoted as the relative difference of the matching feature pixels.

[0041] It should be noted that this embodiment uses the Z-Score standard normalization method to calculate the normalized value. In practical applications, implementers may use other methods of existing technology, such as the maximum-minimum normalization method or the sigmoid function, to calculate the normalized value, and no limitation is made here.

[0042] The greater the relative difference between the matching feature pixels, the greater the difference between the local grayscale value features and the local relative position features of the matching feature pixels.

[0043] The relative difference between matching feature pixels is used as the matching cost between matching feature pixels. A cost matrix is ​​constructed, and the Hungarian algorithm is used to match all corresponding feature pixels in the circuit board edge image and the standard circuit board edge image to obtain the matching results of all matching feature pixels. Using the homography matrix, the matching results of corresponding edge pixels in the circuit board edge image and the standard circuit board edge image are obtained based on the matching results of corresponding feature pixels in the circuit board edge image and the standard circuit board edge image.

[0044] The vector pointing from the standard edge pixel in the standard circuit board edge image to the matching edge pixel in the circuit board edge image is denoted as the matching motion vector of the matching edge pixel in the circuit board edge image.

[0045] Among them, the use of cost matrix and Hungarian algorithm for pixel matching is a well-known technique and will not be elaborated further; using homography matrix and matching results of matching feature pixels can achieve dense matching based on global transformation, obtain the matching results of all pixels in two images, and achieve more efficient matching.

[0046] When the circuit board edge image and the standard circuit board edge image are perfectly matched, the matching motion vectors of all edge pixels in the circuit board edge image should be exactly the same. Therefore, the degree of abnormality of the edge where the edge pixel is located can be judged based on the difference in the matching motion vectors of all edge pixels in the circuit board edge image, and thus the presence of defects in the circuit board to be inspected can be determined.

[0047] Let any edge pixel in the circuit board edge image be the target edge pixel. Let the mean of the absolute values ​​of the differences between the directions of the matching motion vectors of the target edge pixel and all other edge pixels in the circuit board edge image be the matching direction difference of the target edge pixel. Let the mean of the absolute values ​​of the differences between the lengths of the matching motion vectors of the target edge pixel and all other edge pixels in the circuit board edge image be the matching length difference of the target edge pixel. Let the positive correlation between the matching direction difference and the matching length difference of the target edge pixel be the matching difference of the target edge pixel.

[0048] Preferably, as an embodiment of this application, the normalized value of the product of the matching direction difference and the matching length difference of the target edge pixels is denoted as the matching difference of the target edge pixels.

[0049] The greater the matching difference of the target edge pixels, the more likely the target edge pixels are to correspond to the defect location on the surface of the circuit board to be inspected.

[0050] The same method can be used to obtain the matching difference of any edge pixel in the circuit board edge image.

[0051] The matching differences of all edge pixels in the circuit board edge image are processed using the Otsu's method to obtain the matching difference threshold. All pixels with matching differences greater than the matching difference threshold are recorded as abnormal motion pixels.

[0052] At this point, all abnormally moving pixels in the circuit board edge image have been identified.

[0053] Step S003: Obtain the connected components composed of abnormally moving pixels in the circuit board edge image. Calculate the smoothness of the changes in the connected components based on the differences in the matching motion vectors between all abnormally moving pixels in the same connected component and other edge pixels in the local neighborhood. Combine the matching differences of all abnormally moving pixels in all connected components in the circuit board edge image to calculate the probability of defects in the circuit board to be detected corresponding to the circuit board edge image. Based on the probability of defects, obtain the optical detection results of the circuit board defects.

[0054] Furthermore, in order to further improve the reliability of circuit board defect detection results and avoid the influence of image noise on matching and detection results, based on the similarity of the features of abnormal moving pixels corresponding to the circuit board defect location and the feature that they are located in the same local area, the spatial distribution of abnormal moving pixels and the similarity of matching motion vectors within the local range of abnormal moving pixels are analyzed.

[0055] Connectivity analysis is performed on all abnormal motion pixels in the circuit board edge image to obtain the connected regions composed of abnormal motion pixels. The smoothness of the changes in the connected regions is calculated based on the difference between the matching motion vectors of all abnormal motion pixels in the same connected region and other edge pixels in the local neighborhood.

[0056] Preferably, as an embodiment of this application, other edge pixels contained in the local neighborhood of the abnormal motion pixel are denoted as adjacent edge pixels; the sum of the magnitudes of the vector differences between the abnormal motion pixel and all adjacent edge pixels in the local neighborhood is denoted as the local similarity difference of the abnormal motion pixel; the normalized value of the sum of the local similarity differences of all abnormal motion pixels in the same connected component is denoted as the first normalized value of the connected component; and the difference between the number 1 and the first normalized value of the connected component is denoted as the smoothness of change of the connected component.

[0057] It is understandable that each connected component corresponds to an abnormal edge that may be a circuit board defect.

[0058] The greater the smoothness of the change in the connected region, the greater the difference between the matching motion vectors of all abnormal motion pixels contained in the edge of the connected region and the adjacent edge pixels. Moreover, the difference is more likely to be caused by inconsistency with the standard template, and the less likely the difference is caused by noise or other influences. The edge of the connected region is more likely to correspond to a circuit board defect.

[0059] The product of the average matching difference of all abnormally moving pixels in a connected region and the smoothness of the change in the connected region is denoted as the defect probability of the connected region. The maximum value of the defect probabilities of all connected regions identified in the circuit board edge image is denoted as the defect probability of the circuit board to be detected corresponding to the circuit board edge image.

[0060] A person skilled in the art selects 100 defective circuit boards from the attack targets, obtains the probability of defects in the defective circuit boards, and uses the minimum probability of defects in all defective circuit boards as the defect judgment threshold. Circuit boards to be tested with a defect probability greater than or equal to the defect judgment threshold are judged as defective circuit boards; circuit boards to be tested with a defect probability less than the defect judgment threshold are judged as normal circuit boards.

[0061] At this point, the optical inspection results of the circuit board defects are obtained.

[0062] This application also proposes an automated optical inspection device for circuit board defects, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the steps described above. Since a method for automated optical inspection of circuit board defects has been described in detail above, it will not be repeated here.

[0063] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments of this specification have been described above. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are possible or may be advantageous.

[0064] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0065] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them; modifications to the technical solutions described in the foregoing embodiments, or equivalent substitutions of some of the technical features, do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method of automatic optical inspection of a circuit board defect, characterized by, The method includes the following steps: Acquire a standard circuit board image and a circuit board image of the circuit board to be inspected. Obtain a circuit board edge image composed of edge pixels and a standard circuit board edge image composed of standard edge pixels through edge detection. Extract all feature pixels from the circuit board edge image and the standard circuit board edge image. The corresponding feature pixels in the circuit board edge image and the standard circuit board edge image are denoted as matching feature pixels. Based on the differences in different pixel values ​​in the local neighborhood of the feature pixels and the positional relationship between the corresponding feature pixels and the edge pixels in the circuit board edge image and the standard circuit board edge image, the relative differences of the matching feature pixels are determined. Based on the relative differences of all matching feature pixels, the matching motion vector of each edge pixel in the circuit board edge image is determined. Based on the differences between the matching motion vectors of all edge pixels, all abnormal motion pixels in the circuit board edge image are identified. The connected components formed by abnormally moving pixels in the circuit board edge image are obtained. The smoothness of the change of the connected components is calculated based on the difference between the matching motion vectors of all abnormally moving pixels in the same connected component and other edge pixels in the local neighborhood. The probability of defects of the circuit board to be detected corresponding to the circuit board edge image is calculated by combining the matching differences of all abnormally moving pixels in all connected components in the circuit board edge image. Based on the probability of defects, the optical detection results of the circuit board defects are obtained.

2. The method of claim 1, wherein the step of detecting the defects on the circuit board is performed by using a light source and a camera. The method for obtaining the relative differences of the matching feature pixels is as follows: The grayscale difference of matching feature pixels is determined based on the difference in different pixel values ​​within the local neighborhood of the feature pixel. The relative positional difference of the matching feature pixels is determined based on the positional relationship between the corresponding feature pixels and the edge pixels in the circuit board edge image and the standard circuit board edge image. The positive correlation between the grayscale difference and the relative position difference of the matched feature pixels is denoted as the relative difference of the matched feature pixels.

3. The method of claim 2, wherein the step of detecting the defects comprises the steps of: detecting the defects on the circuit board by using a light source and a camera; and determining the positions of the defects on the circuit board by using the camera. The method for obtaining the grayscale difference of the matching feature pixels is as follows: The sum of the absolute values ​​of the differences in grayscale values ​​of all corresponding pixels within the local neighborhood of the matching feature pixel is denoted as the first difference sum of the matching feature pixel; the absolute value of the difference in grayscale values ​​of the matching feature pixel is denoted as the first difference value of the matching feature pixel; the positive correlation result between the first difference sum of the matching feature pixel and the first difference value is denoted as the grayscale difference degree of the matching feature pixel.

4. The method of claim 2, wherein the step of detecting the defects on the circuit board is performed by using a light source having a wavelength of 405 nm. The method for obtaining the relative positional difference of the matching feature pixels is as follows: The minimum Euclidean distance between a feature pixel and all edge pixels in the edge image is denoted as the first relative distance of the feature pixel. The absolute value of the difference between the first relative distances of the corresponding matching feature pixels is denoted as the relative position difference of the corresponding matching feature pixels.

5. The method of claim 1, wherein the step of detecting the defects on the circuit board is performed by using a light source having a wavelength of 405 nm. The method for obtaining the matching motion vector of each edge pixel in the circuit board edge image is as follows: The relative difference of the matched feature pixel points is taken as the matching cost between the matched feature pixel points, and the Hungarian algorithm is used to realize the matching of all corresponding feature pixel points in the circuit board edge image and the standard circuit board edge image, and the matching results of the edge pixel points in the circuit board edge image and the standard circuit board edge image are obtained in combination with the homography matrix. A vector from a standard edge pixel point in the standard circuit board edge image to a matched edge pixel point in the circuit board edge image is taken as the matching motion vector of the matched edge pixel point in the circuit board edge image.

6. The method of claim 1, wherein the step of detecting the defects comprises the steps of: detecting the defects by using a light source and a camera; and determining the defects by using a computer. The method for obtaining the abnormal motion pixel point is as follows: The absolute value of the difference between the matching motion vector of the target edge pixel point and the matching motion vector of any other edge pixel point in the circuit board edge image is taken as the matching direction difference of the target edge pixel point, and the average value of the absolute values of the differences between the length of the matching motion vector of the target edge pixel point and the length of the matching motion vector of any other edge pixel point in the circuit board edge image is taken as the matching length difference of the target edge pixel point; the positive correlation processing result of the matching direction difference and the matching length difference of the target edge pixel point is taken as the matching difference of the target edge pixel point. The matching difference threshold is determined according to the matching differences of all edge pixel points in the circuit board edge image, and all pixel points with a matching difference greater than the matching difference threshold are taken as abnormal motion pixel points.

7. The method of claim 1, wherein the step of detecting the defects comprises the steps of: detecting the defects by using a light source and a camera; and determining the defects by using a computer. The method for calculating the change smoothness of the connected domain is as follows: The other edge pixel points contained in the local neighborhood of the abnormal motion pixel point are taken as adjacent edge pixel points, and the accumulation sum of the modulus of the vector difference between the matching motion vector of the abnormal motion pixel point and the matching motion vector of any adjacent edge pixel point in the local neighborhood is taken as the local similarity difference of the abnormal motion pixel point. The normalization value of the accumulation sum of the local similarity differences of all abnormal motion pixel points in the same connected domain is taken as the first normalization value of the connected domain, and the difference between the number 1 and the first normalization value of the connected domain is taken as the change smoothness of the connected domain.

8. The method of claim 1, wherein the step of detecting the defects comprises the steps of: detecting the defects on the circuit board by using a light source and a camera; and determining the positions of the defects on the circuit board by using a computer. The method for obtaining the defect possibility of the circuit board corresponding to the circuit board edge image is as follows: The product of the average value of the matching differences of all abnormal motion pixel points on the connected domain and the change smoothness of the connected domain is taken as the defect possibility of the connected domain. The maximum value of the defect possibilities of all connected domains recognized in the circuit board edge image is taken as the defect possibility of the circuit board corresponding to the circuit board edge image.

9. The automatic optical inspection method for circuit board defects according to claim 1, characterized in that, The method for obtaining the optical detection result of the circuit board defect according to the defect possibility includes the following specific method: If the defect possibility is greater than or equal to a preset defect judgment threshold, the circuit board to be detected is determined as a defective circuit board; otherwise, the circuit board to be detected is determined as a normal circuit board.

10. An apparatus for automatic optical inspection of defects on a circuit board, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program to realize the steps of the automatic optical detection method of the circuit board defect according to any one of claims 1-9.