AOI (Automatic Optic Inspection) method for PCB (Printed Circuit Board)
By compensating brightness and chromaticity in the Lab color space, and combining color, contour and texture feature screening, convolutional neural network is used for classification recognition, which solves the problem of image quality degradation under the influence of lighting and the large amount of training data of deep learning models, and achieves more efficient PCB circuit board defect detection.
Patent Information
- Application Number
- CN202411710999.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-11
AI Technical Summary
The existing machine vision detection technology has a great impact on image color intensity when the lighting conditions change, resulting in a decline in image quality, making it difficult to identify fine defects on the surface of PCB circuit boards, and the training data of deep learning models is large, which takes time to classify and identify.
The image is separated from brightness and chromaticity by using Lab color space, and the difference between the standard image and the reference image is brightness compensation and chromaticity compensation to reduce the influence of light. Combining color features, convolutional features and texture feature screening, convolutional neural networks are used for classification recognition to reduce the amount of training data of deep learning models.
It improves the accuracy of PCB circuit board image detection, can more effectively identify surface defects, especially fine defects, and reduces the training time and data volume of deep learning models.
Smart Images

Figure CN119600358A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of AOI detection, and in particular to an AOI detection method for a PCB circuit board. Background Art
[0002] In the modern electronic manufacturing industry, PCB circuit boards serve as the support and connection carrier of electronic components, and their quality is directly related to the performance and reliability of the entire electronic product. With the rapid development of intelligent manufacturing technology, machine vision inspection technology has been widely used in the field of PCB defect detection due to its advantages such as high efficiency, accuracy, and non-contact. As the core component of electronic products, the production process of PCB boards is complex and delicate, and omissions in any link may lead to product quality problems.
[0003] At present, visual inspection technology for PCB circuit boards is widely used, but lighting conditions have a great impact on the color intensity of the image, which in turn affects the image quality and thus the results of machine vision inspection. Traditional machine vision algorithms are difficult to identify relatively fine defects on the surface of PCB circuit boards. As the demand for inspection continues to increase, the complexity of the algorithm is also increasing. At the same time, the amount of training data for deep learning models is too large, so classification and recognition takes too long.
[0004] In view of this, we propose an AOI inspection method for PCB circuit boards to solve the existing problems. Summary of the invention
[0005] The object of the present invention is to provide an AOI inspection method for a PCB circuit board to solve the problems raised in the above background technology.
[0006] To achieve the above object, the present invention provides the following technical solution: an AOI detection method for PCB circuit boards, the working steps comprising:
[0007] S1: Image acquisition and preprocessing: The staff obtains a standard image through the actual structural distribution of a PCB circuit board with no surface defects, acquires an image of the PCB circuit board to be inspected, obtains an inspection image, and corrects the brightness and chromaticity of the inspection image through the Lab color space to obtain a corrected image;
[0008] S2: Color feature screening: Perform brightness and chromaticity segmentation on the standard image to obtain a standard segmented image, perform brightness and chromaticity segmentation on the corrected image to obtain a corrected segmented image, subtract the pixel color intensity of the corrected segmented image from the standard segmented image to obtain a difference segmentation matrix, and judge whether there are defects on the surface of the PCB circuit board based on the color feature difference;
[0009] S3: Contour feature screening: perform contour extraction on the standard image to obtain a standard contour image, perform contour extraction on the corrected image corresponding to the PCB circuit board that has not been detected with surface defects in S2 to obtain a corrected contour image, subtract the pixel color intensity of the corrected contour image from the standard contour image to obtain a difference contour matrix, and judge whether there are defects on the surface of the PCB circuit board based on the difference in contour features;
[0010] S4: Texture feature screening: Extract texture features from the standard image to obtain a standard texture image, extract texture features from the corrected image corresponding to the PCB circuit board that has not been detected with surface defects in S2 and S3 to obtain a corrected texture image, subtract pixel intensity from the corrected texture image and the standard texture image to obtain a difference texture matrix, and judge whether there are defects on the surface of the PCB circuit board based on the difference in texture features;
[0011] S5: Classification and recognition: A convolutional neural network is used to classify and recognize the corrected images corresponding to the PCB circuit boards that have not been detected with surface defects by S2, S3 and S4, and to determine whether there are defects on the surface of the PCB circuit boards based on color features, contour features and texture features.
[0012] Furthermore, the specific working steps of S1 include:
[0013] A1: Capture an image of a PCB circuit board without surface defects to obtain a reference image, convert the reference image from RGB space to Lab space to obtain a reference Lab image, and divide the reference Lab image into a reference L image, a reference a image, and a reference b image;
[0014] A2: The staff adjusts the pixel color intensity of the reference L image, the reference a image, and the reference b image according to the actual structural distribution of the PCB circuit board without surface defects to obtain the standard image, which includes the standard L image, the standard a image, and the standard b image;
[0015] A3: Subtract the pixel color intensity of the standard image obtained by A2 from the reference Lab image obtained by A1 to obtain a difference matrix. The difference image includes a difference L matrix, a difference a matrix, and a difference b matrix.
[0016] A4: Capture an image of the PCB circuit board to be inspected to obtain an inspection image, convert the inspection image from RGB space to Lab space to obtain an inspection Lab image, and divide the inspection Lab image into an inspection L image, an inspection a image, and an inspection b image;
[0017] A5: Add the pixel color intensities of the test Lab image obtained in A4 and the difference matrix obtained in A3 to obtain a corrected image, which includes a corrected L image, a corrected a image, and a corrected b image.
[0018] Furthermore, the specific working steps of S2 include:
[0019] B1: Segment the standard L image, the standard a image and the standard b image according to the color intensity distribution to obtain a standard segmented image, which includes the standard segmented L image, the standard segmented a image and the standard segmented b image;
[0020] B2: segmenting the corrected L image, the corrected a image, and the corrected b image according to the color intensity distribution to obtain a corrected segmented image, where the corrected segmented image includes the corrected segmented L image, the corrected segmented a image, and the corrected segmented b image;
[0021] B3: Subtract the pixel color intensity of the corrected segmented image obtained in B2 from the standard segmented image obtained in B1 to obtain a difference segmentation matrix, which includes a difference segmentation L matrix, a difference segmentation a matrix, and a difference segmentation b matrix;
[0022] B4: If the difference segmentation L matrix, the difference segmentation a matrix, or the difference segmentation b matrix corresponding to the PCB circuit board to be inspected has a value exceeding the set color difference range, it is determined that there is a defect on the surface of the PCB circuit board.
[0023] Furthermore, the specific working steps of S3 include:
[0024] C1: extracting the contours of the standard L image, the standard a image and the standard b image to obtain a standard contour image, which includes the standard contour L image, the standard contour a image and the standard contour b image;
[0025] C2: extracting contours of the corrected L image, the corrected a image, and the corrected b image corresponding to the PCB circuit board in S2 that has not been detected to have surface defects, to obtain a corrected contour image, which includes the corrected contour L image, the corrected contour a image, and the corrected contour b image;
[0026] C3: Subtract the pixel color intensity of the corrected contour image obtained by C2 from the standard contour image obtained by C1 to obtain a difference contour matrix, which includes a difference contour L matrix, a difference contour a matrix, and a difference contour b matrix;
[0027] C4: If the difference profile L matrix, the difference profile a matrix, or the difference profile b matrix corresponding to the PCB circuit board to be inspected has a value that exceeds the set profile difference range, it is determined that there is a defect on the surface of the PCB circuit board.
[0028] Furthermore, the specific working steps of S4 include:
[0029] D1: extracting texture features from the standard L image, the standard a image and the standard b image to obtain a standard texture image, which includes the standard texture L image, the standard texture a image and the standard texture b image;
[0030] D2: extracting texture features from the corrected L image, the corrected a image, and the corrected b image corresponding to the PCB circuit boards that have not been detected with surface defects in S2 and S3 to obtain a corrected texture image, which includes the corrected texture L image, the corrected texture a image, and the corrected texture b image;
[0031] D3: Subtract the pixel color intensity of the corrected texture image obtained by D2 from the standard texture image obtained by D1 to obtain a difference texture matrix, which includes a difference texture L matrix, a difference texture a matrix, and a difference texture b matrix;
[0032] D4: If the difference texture L matrix, the difference texture a matrix, or the difference texture b matrix corresponding to the PCB circuit board to be inspected has a value that exceeds the set texture difference range, it is determined that there is a defect on the surface of the PCB circuit board.
[0033] Furthermore, in S5, there is a link of model training and optimization, in which the classification model is trained through training samples and label data, and the model training is continuously optimized and adjusted by adjusting the network structure, optimizing hyperparameters, and introducing regularization.
[0034] Furthermore, after image acquisition of a PCB circuit board with no surface defects or a PCB circuit board to be inspected, the edge of the circuit board is extracted through the Canny function, and then the contour of the circuit board is found and drawn through the findContours function and the minAreaRect function, and then the perspective transformation and area extraction of the circuit board are performed through the findHomography function and the warpPerspective function, and then the image is denoised and enhanced.
[0035] Furthermore, the kmeans function is used to segment the image.
[0036] Furthermore, the edge of the image is extracted by using the Canny function and used as the contour.
[0037] Furthermore, the gray level co-occurrence matrix is used to extract features from the image.
[0038] Compared with the prior art, the present invention has the following beneficial effects:
[0039] The present invention separates brightness and chromaticity through Lab color space, and performs brightness compensation and chromaticity compensation on the inspection image according to the difference between the standard image and the reference image, thereby reducing the influence of external light on the brightness and chromaticity of the PCB circuit board image, and improving the accuracy of subsequent surface defect detection of the PCB circuit board; performs brightness segmentation and chromaticity segmentation on the PCB circuit board image through the kmeans function, and judges whether the PCB circuit board surface has defects according to the color feature difference; performs brightness contour extraction and chromaticity contour extraction on the PCB circuit board image through the Canny function, and judges whether the PCB circuit board surface has defects according to the contour feature difference; performs brightness texture extraction and chromaticity texture extraction on the PCB circuit board image through the grayscale co-occurrence matrix, and judges whether the PCB circuit board surface has defects according to the texture feature difference; and performs classification and recognition on relatively fine defects on the PCB circuit board surface through a convolutional neural network model, thereby reducing the amount of training data of the deep learning model and effectively reducing the time of classification and recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 The present invention is a workflow diagram of an AOI detection method for a PCB circuit board;
[0041] Figure 2 It is the workflow diagram of image acquisition and preprocessing of the present invention;
[0042] Figure 3 A workflow diagram for color feature screening of the present invention;
[0043] Figure 4 A workflow diagram for the profile feature screening of the present invention;
[0044] Figure 5 The flowchart of the texture feature screening of the present invention. DETAILED DESCRIPTION
[0045] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and specific embodiments.
[0046] Embodiment 1
[0047] like Figure 1 As shown, an AOI inspection method for PCB circuit boards includes the following steps:
[0048] S1: Image acquisition and preprocessing: The staff obtains a standard image through the actual structural distribution of a PCB circuit board with no surface defects, acquires an image of the PCB circuit board to be inspected, obtains an inspection image, and corrects the brightness and chromaticity of the inspection image through the Lab color space to obtain a corrected image;
[0049] S2: Color feature screening: Perform brightness and chromaticity segmentation on the standard image to obtain a standard segmented image, perform brightness and chromaticity segmentation on the corrected image to obtain a corrected segmented image, subtract the pixel color intensity of the corrected segmented image from the standard segmented image to obtain a difference segmentation matrix, and judge whether there are defects on the surface of the PCB circuit board based on the color feature difference;
[0050] S3: Contour feature screening: perform contour extraction on the standard image to obtain a standard contour image, perform contour extraction on the corrected image corresponding to the PCB circuit board that has not been detected with surface defects in S2 to obtain a corrected contour image, subtract the pixel color intensity of the corrected contour image from the standard contour image to obtain a difference contour matrix, and judge whether there are defects on the surface of the PCB circuit board based on the difference in contour features;
[0051] S4: Texture feature screening: Extract texture features from the standard image to obtain a standard texture image, extract texture features from the corrected image corresponding to the PCB circuit board that has not been detected with surface defects in S2 and S3 to obtain a corrected texture image, subtract pixel intensity from the corrected texture image and the standard texture image to obtain a difference texture matrix, and judge whether there are defects on the surface of the PCB circuit board based on the difference in texture features;
[0052] S5: Classification and recognition: A convolutional neural network is used to classify and recognize the corrected images corresponding to the PCB circuit boards that have not been detected with surface defects by S2, S3 and S4, and to determine whether there are defects on the surface of the PCB circuit boards based on color features, contour features and texture features.
[0053] like Figure 2 As shown, the specific working steps of S1 include:
[0054] A1: Capture an image of a PCB circuit board without surface defects to obtain a reference image, convert the reference image from RGB space to Lab space to obtain a reference Lab image, and divide the reference Lab image into a reference L image, a reference a image, and a reference b image;
[0055] A2: The staff adjusts the pixel color intensity of the reference L image, the reference a image, and the reference b image according to the actual structural distribution of the PCB circuit board without surface defects to obtain the standard image, which includes the standard L image, the standard a image, and the standard b image;
[0056] A3: Subtract the pixel color intensity of the standard image obtained by A2 from the reference Lab image obtained by A1 to obtain a difference matrix. The difference image includes a difference L matrix, a difference a matrix, and a difference b matrix.
[0057] A4: Capture an image of the PCB circuit board to be inspected to obtain an inspection image, convert the inspection image from RGB space to Lab space to obtain an inspection Lab image, and divide the inspection Lab image into an inspection L image, an inspection a image, and an inspection b image;
[0058] A5: Add the pixel color intensity of the test Lab image obtained in A4 and the difference matrix obtained in A3 to obtain a corrected image, which includes a corrected L image, a corrected a image, and a corrected b image.
[0059] like Figure 3 As shown, the specific working steps of S2 include:
[0060] B1: Segment the standard L image, the standard a image and the standard b image according to the color intensity distribution to obtain a standard segmented image, which includes the standard segmented L image, the standard segmented a image and the standard segmented b image;
[0061] B2: segmenting the corrected L image, the corrected a image, and the corrected b image according to the color intensity distribution to obtain a corrected segmented image, where the corrected segmented image includes the corrected segmented L image, the corrected segmented a image, and the corrected segmented b image;
[0062] B3: Subtract the pixel color intensity of the corrected segmented image obtained in B2 from the standard segmented image obtained in B1 to obtain a difference segmentation matrix, which includes a difference segmentation L matrix, a difference segmentation a matrix, and a difference segmentation b matrix;
[0063] B4: If the difference segmentation L matrix, the difference segmentation a matrix, or the difference segmentation b matrix corresponding to the PCB circuit board to be inspected has a value exceeding the set color difference range, it is determined that there is a defect on the surface of the PCB circuit board.
[0064] like Figure 4 As shown, the specific working steps of S3 include:
[0065] C1: extracting the contours of the standard L image, the standard a image and the standard b image to obtain a standard contour image, which includes the standard contour L image, the standard contour a image and the standard contour b image;
[0066] C2: extracting contours of the corrected L image, the corrected a image, and the corrected b image corresponding to the PCB circuit board in S2 that has not been detected to have surface defects, to obtain a corrected contour image, which includes the corrected contour L image, the corrected contour a image, and the corrected contour b image;
[0067] C3: Subtract the pixel color intensity of the corrected contour image obtained by C2 from the standard contour image obtained by C1 to obtain a difference contour matrix, which includes a difference contour L matrix, a difference contour a matrix, and a difference contour b matrix;
[0068] C4: If the difference profile L matrix, the difference profile a matrix, or the difference profile b matrix corresponding to the PCB circuit board to be inspected has a value that exceeds the set profile difference range, it is determined that there is a defect on the surface of the PCB circuit board.
[0069] like Figure 5 As shown, the specific working steps of S4 include:
[0070] D1: extracting texture features from the standard L image, the standard a image and the standard b image to obtain a standard texture image, which includes the standard texture L image, the standard texture a image and the standard texture b image;
[0071] D2: extracting texture features from the corrected L image, the corrected a image, and the corrected b image corresponding to the PCB circuit boards that have not been detected with surface defects in S2 and S3 to obtain a corrected texture image, which includes the corrected texture L image, the corrected texture a image, and the corrected texture b image;
[0072] D3: Subtract the pixel color intensity of the corrected texture image obtained by D2 from the standard texture image obtained by D1 to obtain a difference texture matrix, which includes a difference texture L matrix, a difference texture a matrix, and a difference texture b matrix;
[0073] D4: If the difference texture L matrix, the difference texture a matrix, or the difference texture b matrix corresponding to the PCB circuit board to be inspected has a value that exceeds the set texture difference range, it is determined that there is a defect on the surface of the PCB circuit board.
[0074] The working principle of an AOI inspection method for a PCB circuit board based on the first embodiment is:
[0075] The conversion relationship from RGB color space to XYZ color space is:
[0076]
[0077] Where: [T] is a 3×3 matrix:
[0078]
[0079] The conversion relationship from XYZ color space to Lab color space is:
[0080]
[0081] Where: X n , Y n , Z n They are 0.950456, 1.0, and 1.088754 respectively; function f is a correction function similar to the Gamma function. When t>0.008856, When t≤0.008856,
[0082] In A1, an image of a PCB circuit board without surface defects is collected to obtain a reference image. The pixel set of the reference image is I R , will I R Convert from RGB space to Lab space to obtain the reference Lab image. The pixel set of the reference L image is I RL , the pixel set of the reference image a is I Ra , the pixel set of the reference b image is I Rb , where I RL ,I Ra and I Rb All of them are grayscale image sets. In the Lab color space, L is the brightness component, with a value range of 0 to 100, representing from pure black to pure white. Therefore, the higher the L value, the brighter the color; the lower the value, the darker the color; a is the red-green component, with a value range of -128 to 127, representing the range from green to red. Therefore, a positive value of a indicates that the color is biased towards red, and a negative value indicates that the color is biased towards green; b is the yellow-blue component, with a value range of -128 to 127, representing the range from blue to yellow. Therefore, a positive value of b indicates that the color is biased towards yellow, and a negative value indicates that the color is biased towards blue. However, in grayscale image display, the grayscale value ranges from 0 to 255. Therefore, when the L, a, and b parameters of an image are represented by a grayscale image, the color intensity value needs to be converted. When converted from the RGB color space to the Lab color space, the L component value is divided by 100 and then multiplied by 255 for grayscale representation, and the a and b component values are added by 128 for grayscale representation.
[0083] In A2, the staff conducted a survey on the I based on the actual structural distribution of the PCB circuit board without surface defects. RL ,I Ra and I Rb Adjust the pixel color intensity to obtain a standard image. The pixel set of the standard L image is I SL , the pixel set of the standard a image is I Sa , the pixel set of the standard b image is I Sb .
[0084] In A3, the data set of the difference L matrix is I DL , the data set of the difference a matrix is I Da, the data set of the difference b matrix is I Db , I DL =I SL -I RL , I Da =I Sa -I Ra , I Db =I Sb -I Rb , for the subtraction of pixel color intensity between the standard image and the reference image, the horizontal and vertical coordinates correspond one to one.
[0085] In A4, the PCB circuit board to be inspected is imaged to obtain an inspection image, and the pixel set of the inspection image is I T , convert the test image from RGB space to Lab space, obtain the test Lab image, and the pixel set of the test L image is I TL , check that the pixel set of image a is I Ta , check that the pixel set of image b is I Tb , where I TL ,I Ta and I Tb All of them are grayscale image sets. The conversion of color intensity values is the same as A1.
[0086] In A5, the pixel set of the corrected L image is I CL , the pixel set of the corrected image a is I Ca , the pixel set of the corrected b image is I Cb , I CL =I TL +I DL , I Ca =I Ta +I Da , I Cb =I Tb +I Db , the pixel color intensity of the test image and the difference matrix are added, and the horizontal and vertical coordinates correspond one to one.
[0087] Lighting conditions have a significant impact on image brightness and chromaticity, which in turn affects image quality, thus affecting the results of machine vision inspection. The RGB color space is converted to the Lab color space, and then the effects of external lighting on brightness and chromaticity are offset.
[0088] In image acquisition and preprocessing, after acquiring images of PCB circuit boards with no surface defects or PCB circuit boards to be inspected, the edges of the circuit boards are extracted through the Canny function, and then the contours of the circuit boards are found and drawn through the findContours function and the minAreaRect function. Then, the perspective transformation and area extraction of the circuit boards are performed through the findHomography function and the warpPerspective function, and then the image is denoised and enhanced.
[0089] The mathematical model of perspective transformation is:
[0090]
[0091] Where: is the coordinate matrix before transformation; is the transformed coordinate matrix; is the transformation matrix; usually a 33 and w and z are set to constant 1.
[0092] The outline of the circuit board drawn by the minAreaRect function is a rectangle. The four vertices of the outline rectangle are set to P1, P2, P3, and P4, where the ordinates of P1 and P2 are smaller than the ordinates of P3 and P4, and the abscissas of P1 and P3 are smaller than the abscissas of P2 and P4. The coordinates of the four vertices of the outline rectangle are set as the input values of the perspective transformation, and the four vertices of the image are set as the output values of the perspective transformation. The width of the image is W, and the height of the image is H. Therefore, the coordinates of the output values are (0,0), (W,0), (0,H), and (W,H). P1 matches (0,0), P2 matches (W,0), P3 matches (0,H), and P4 matches (W,H). The transformation matrix is obtained by the findHomography function, and the circuit board is extracted by the warpPerspective function.
[0093] In B1, the standard image is segmented according to the color intensity distribution to obtain a standard segmented image. The pixel set of the standard segmented L image is I SKL , the pixel set of the standard segmentation image a is I SKa , the pixel set of the standard segmentation b image is I SKb .
[0094] In B2, the corrected image is segmented according to the color intensity distribution to obtain a corrected segmented image. The pixel set of the corrected segmented image is I CKL , the pixel set of the corrected segmented image a is I CKa , the pixel set of the corrected segmented image b is I CKb .
[0095] In B3, the data set of the difference partition L matrix is I DKL , the data set of the difference partition a matrix is I DKa , the data set of the difference partition b matrix is I DKb , I DKL =I CKL -I SKL , I DKa =I CKa -I SKa , I DKb =I CKb -I SKb , for the subtraction of the pixel color intensity between the corrected segmented image and the standard segmented image, the horizontal and vertical coordinates correspond one to one.
[0096] In B4, set the color difference range to include the brightness difference range [-T KL ,T KL ] and the chromaticity difference range [-T Ka ,T Ka ] and [-T Kb ,T Kb ], the data set of the difference segmentation matrix is I DK , there exists an array P DK ∈I DK , P DK The corresponding L value, a value, and b value are P DKL , P DKa , P DKb ,like or or It is determined that there are defects on the surface of the PCB circuit board.
[0097] In color feature screening, kmeans function is used to segment the image. Color is one of the important features of PCB boards and their defects. Through the color segmentation algorithm, different color areas in the image can be distinguished, and then the color information of key parts such as solder joints and components can be identified. Color features are of great significance for detecting solder joint defects (such as excessive tin, insufficient tin, and solder leaks).
[0098] In C1, the standard image is contour extracted to obtain a standard contour image. The pixel set of the standard contour L image is I SCL , the pixel set of the standard contour a image is I SCa , the pixel set of the standard contour b image is I SCb .
[0099] In C2, contour extraction is performed on the correction image corresponding to the PCB circuit board that has not been detected with surface defects in S2 to obtain a correction contour image. The pixel set of the correction contour image is I CCL, the pixel set of the corrected contour a image is I CCa , the pixel set of the corrected contour b image is I CCb .
[0100] In C3, the data set of the difference profile L matrix is I DCL , the data set of the difference profile a matrix is I DCa , the data set of the difference profile b matrix is I DCb , I DCL =I CCL -I SCL , I DCa =I CCa -I SCa , I DCb =I CCb -I SCb , for the subtraction of the pixel color intensity between the corrected contour image and the standard contour image, the horizontal and vertical coordinates correspond one to one.
[0101] In C4, the contour difference range is set to include the brightness contour difference range [-T CL ,T CL ] and the chromaticity profile difference range [-T Ca ,T Ca ] and [-T Cb ,T Cb ], the data set of the difference profile matrix is I DC , there exists an array P DC ∈I DC , P DC The corresponding L value, a value, and b value are P DCL , P DCa , P DCb ,like or or It is determined that there are defects on the surface of the PCB circuit board.
[0102] In contour feature screening, the Canny function is used to extract the edge of the image and use it as the contour. Shape and size are another important feature dimension. Through edge detection, contour extraction and other algorithms, the shape and size information of targets such as solder joints and components can be obtained. This information is crucial for determining whether the target has defects (such as irregular shape, inconsistent size, etc.).
[0103] In D1, texture features are extracted from the standard image to obtain a standard texture image. The pixel set of the standard texture L image is I SGL , the pixel set of the standard texture a image is I SGa , the pixel set of the standard texture b image is I SGb .
[0104] In D2, texture features are extracted from the corrected images corresponding to the PCB circuit boards that have not been detected with surface defects in S2 and S3 to obtain a corrected texture image. The pixel set of the corrected texture image is I CGL , the pixel set of the corrected texture a image is I CGa , the pixel set of the corrected texture b image is I CGb .
[0105] In D3, the data set of the difference texture L matrix is I DGL , the data set of the difference texture a matrix is I DGa , the data set of the difference texture b matrix is I DGb , I DGL =I CGL -I SGL , I DGa =I CGa -I SGa , I DGb =I CGb -I SGb , for the subtraction of pixel color intensity between the corrected texture image and the standard texture image, the horizontal and vertical coordinates correspond one to one.
[0106] In D4, setting the texture difference range includes the brightness texture difference range [-T GL ,T GL ] and the range of chromaticity texture difference [-T Ga ,T Ga ] and [-T Gb ,T Gb ], the data set of the difference texture matrix is I DG , there exists an array P DG ∈I DG , P DG The corresponding L value, a value, and b value are P DGL , P DGa , P DGb ,like or or It is determined that there are defects on the surface of the PCB circuit board.
[0107] In texture feature screening, the gray level co-occurrence matrix is used to extract features from the image. Texture features reflect the fineness and arrangement of the image surface. For certain types of PCB board defects (such as scratches, stains, etc.), texture features are an effective basis for identification. Through the texture analysis algorithm, the texture features in the image can be extracted for defect identification.
[0108] The above-mentioned image acquisition and preprocessing steps separate brightness and chromaticity through the Lab color space, and perform brightness compensation and chromaticity compensation on the inspection image according to the difference between the standard image and the reference image, thereby reducing the influence of external light on the brightness and chromaticity of the PCB circuit board image and improving the accuracy of subsequent PCB circuit board surface defect detection.
[0109] The above steps of color feature screening, contour feature screening and texture feature screening can identify more obvious defects on the surface of PCB circuit boards, but it is difficult to identify more subtle defects. Therefore, a convolutional neural network is used to classify and identify the corrected images corresponding to PCB circuit boards that have not yet detected surface defects in S2, S3 and S4, and to determine whether there are defects on the surface of the PCB circuit board based on color features, contour features and texture features. Among them, there is a link of model training and optimization, in which the classification model is trained through training samples and label data, and the model training is continuously optimized and adjusted by adjusting the network structure, optimizing hyperparameters and introducing regularization.
[0110] The detection requirements for finer defects on the surface of PCB circuit boards are relatively high. Therefore, the algorithm is more complex, the amount of training data for deep learning models is large, and classification and recognition takes too long. In order to reduce the amount of training data for deep learning models and reduce the time for classification and recognition, traditional feature screening is used to screen the more obvious defects on the surface of PCB circuit boards to reduce the recognition time. For finer defects, the deep learning model is used for classification and recognition. Therefore, the deep learning model only needs to train the data corresponding to finer defects, and does not need to train the data corresponding to more obvious defects, thereby reducing the amount of training data for the deep learning model.
[0111] The above-mentioned specific embodiments are only several preferred embodiments of the present invention. Based on the technical solutions of the present invention and the relevant inspirations of the above-mentioned embodiments, those skilled in the art can make various alternative improvements and combinations to the above-mentioned specific embodiments.
Claims
1. An AOI inspection method for PCB circuit boards, characterized in that: The working steps include: S1: Image acquisition and preprocessing: The staff obtains a standard image through the actual structural distribution of a PCB circuit board with no surface defects, acquires an image of the PCB circuit board to be inspected, obtains an inspection image, and corrects the brightness and chromaticity of the inspection image through the Lab color space to obtain a corrected image; S2: Color feature screening: Perform brightness and chromaticity segmentation on the standard image to obtain a standard segmented image, perform brightness and chromaticity segmentation on the corrected image to obtain a corrected segmented image, subtract the pixel color intensity of the corrected segmented image from the standard segmented image to obtain a difference segmentation matrix, and judge whether there are defects on the surface of the PCB circuit board based on the color feature difference; S3: Contour feature screening: perform contour extraction on the standard image to obtain a standard contour image, perform contour extraction on the corrected image corresponding to the PCB circuit board that has not been detected with surface defects in S2 to obtain a corrected contour image, subtract the pixel color intensity of the corrected contour image from the standard contour image to obtain a difference contour matrix, and judge whether there are defects on the surface of the PCB circuit board based on the difference in contour features; S4: Texture feature screening: Extract texture features from the standard image to obtain a standard texture image, extract texture features from the corrected image corresponding to the PCB circuit board that has not been detected with surface defects in S2 and S3 to obtain a corrected texture image, subtract pixel intensity from the corrected texture image and the standard texture image to obtain a difference texture matrix, and judge whether there are defects on the surface of the PCB circuit board based on the difference in texture features; S5: Classification and recognition: A convolutional neural network is used to classify and recognize the corrected images corresponding to the PCB circuit boards that have not been detected with surface defects by S2, S3 and S4, and to determine whether there are defects on the surface of the PCB circuit boards based on color features, contour features and texture features.
2. The AOI detection method for PCB circuit board according to claim 1, characterized in that: The specific working steps of S1 include: A1: Capture an image of a PCB circuit board without surface defects to obtain a reference image, convert the reference image from RGB space to Lab space to obtain a reference Lab image, and divide the reference Lab image into a reference L image, a reference a image, and a reference b image; A2: The staff adjusts the pixel color intensity of the reference L image, the reference a image, and the reference b image according to the actual structural distribution of the PCB circuit board without surface defects to obtain the standard image, which includes the standard L image, the standard a image, and the standard b image; A3: Subtract the pixel color intensity of the standard image obtained by A2 from the reference Lab image obtained by A1 to obtain a difference matrix. The difference image includes a difference L matrix, a difference a matrix, and a difference b matrix. A4: Capture an image of the PCB circuit board to be inspected to obtain an inspection image, convert the inspection image from RGB space to Lab space to obtain an inspection Lab image, and divide the inspection Lab image into an inspection L image, an inspection a image, and an inspection b image; A5: Add the pixel color intensity of the test Lab image obtained in A4 and the difference matrix obtained in A3 to obtain a corrected image, which includes a corrected L image, a corrected a image, and a corrected b image.
3. The AOI detection method for PCB circuit board according to claim 1, characterized in that: The specific working steps of S2 include: B1: Segment the standard L image, the standard a image and the standard b image according to the color intensity distribution to obtain a standard segmented image, which includes the standard segmented L image, the standard segmented a image and the standard segmented b image; B2: segmenting the corrected L image, the corrected a image, and the corrected b image according to the color intensity distribution to obtain a corrected segmented image, where the corrected segmented image includes the corrected segmented L image, the corrected segmented a image, and the corrected segmented b image; B3: Subtract the pixel color intensity of the corrected segmented image obtained in B2 from the standard segmented image obtained in B1 to obtain a difference segmentation matrix, which includes a difference segmentation L matrix, a difference segmentation a matrix, and a difference segmentation b matrix; B4: If the difference segmentation L matrix, the difference segmentation a matrix, or the difference segmentation b matrix corresponding to the PCB circuit board to be inspected has a value exceeding the set color difference range, it is determined that there is a defect on the surface of the PCB circuit board.
4. The AOI detection method for PCB circuit board according to claim 1, characterized in that: The specific working steps of S3 include: C1: extracting the contours of the standard L image, the standard a image and the standard b image to obtain a standard contour image, which includes the standard contour L image, the standard contour a image and the standard contour b image; C2: extracting contours of the corrected L image, the corrected a image, and the corrected b image corresponding to the PCB circuit board in S2 that has not been detected to have surface defects, to obtain a corrected contour image, which includes the corrected contour L image, the corrected contour a image, and the corrected contour b image; C3: Subtract the pixel color intensity of the corrected contour image obtained by C2 from the standard contour image obtained by C1 to obtain a difference contour matrix, which includes a difference contour L matrix, a difference contour a matrix, and a difference contour b matrix; C4: If the difference profile L matrix, the difference profile a matrix, or the difference profile b matrix corresponding to the PCB circuit board to be inspected has a value that exceeds the set profile difference range, it is determined that there is a defect on the surface of the PCB circuit board.
5. The AOI detection method for PCB circuit board according to claim 1, characterized in that: The specific working steps of S4 include: D1: extracting texture features from the standard L image, the standard a image and the standard b image to obtain a standard texture image, which includes the standard texture L image, the standard texture a image and the standard texture b image; D2: extracting texture features from the corrected L image, the corrected a image, and the corrected b image corresponding to the PCB circuit boards that have not been detected with surface defects in S2 and S3, to obtain a corrected texture image, which includes the corrected texture L image, the corrected texture a image, and the corrected texture b image; D3: Subtract the pixel color intensity of the corrected texture image obtained by D2 from the standard texture image obtained by D1 to obtain a difference texture matrix, which includes a difference texture L matrix, a difference texture a matrix, and a difference texture b matrix; D4: If the difference texture L matrix, the difference texture a matrix, or the difference texture b matrix corresponding to the PCB circuit board to be inspected has a value that exceeds the set texture difference range, it is determined that there is a defect on the surface of the PCB circuit board.
6. The AOI detection method for PCB circuit board according to claim 1, characterized in that: In S5, there is a link of model training and optimization. The classification model is trained through training samples and label data, and the model training is continuously optimized and adjusted by adjusting the network structure, optimizing hyperparameters, and introducing regularization.
7. The AOI detection method for a PCB circuit board according to claim 2, characterized in that: After capturing images of PCB circuit boards with no surface defects or PCB circuit boards to be inspected, the edges of the circuit boards are extracted using the Canny function, and then the contours of the circuit boards are discovered and drawn using the findContours function and the minAreaRect function. The perspective transformation and area extraction of the circuit boards are then performed using the findHomography function and the warpPerspective function, and then the images are denoised and enhanced.
8. The AOI detection method for a PCB circuit board according to claim 3, characterized in that: The kmeans function is used to segment the image.
9. The AOI detection method for PCB circuit board according to claim 4, characterized in that: The edge of the image is extracted using the Canny function and used as the contour.
10. The AOI inspection method for PCB circuit board according to claim 5, characterized in that: Gray-level co-occurrence matrix is used to extract features from images.