Circuit board wiring detection method based on deep learning
Through the improved YOLOV8-seg model and attention mechanism module, combined with image segmentation and matching algorithm, the problem of insufficient wiring detection accuracy in the existing technology is solved, and high accuracy detection is achieved in complex environments to meet intelligent manufacturing intelligent detection requirements.
Patent Information
- Application Number
- CN202411021379.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-22
AI Technical Summary
The existing circuit board wiring detection methods cannot meet the needs of intelligent inspection, especially in complex environments, it is difficult to accurately detect slender wiring conditions.
The improved YOLOV8-seg model is used, combined with the attention mechanism module, and image segmentation and matching algorithm analysis are performed, the Euro-type distance between the interface and the line is calculated, the occlusion situation is identified through vector fitting and angle calculation, and compared with the wiring standards to determine Wiring correctness.
It improves the accuracy and accuracy of line detection, and can effectively identify the docking situation of interfaces and lines in complex environments, meeting the intelligent detection needs of intelligent manufacturing.
Smart Images

Figure CN119006379A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence and target detection technology, and in particular to a circuit board wiring detection method based on deep learning. Background Art
[0002] With the rapid improvement of hardware computing power and the gradual implementation of the new infrastructure development strategy, artificial intelligence has been applied to many fields, including smart medical care, intelligent manufacturing, and autonomous driving. Among them, image segmentation is one of the most widely used methods in smart medical care, intelligent manufacturing, and autonomous driving. The principle of image segmentation technology is to classify all pixels in the picture. Its principle determines that image segmentation is used to detect complex scenes containing rich information. In smart medical care, image segmentation can complete the analysis of medical images and feedback information such as tumors and lesions to doctors in advance. In autonomous driving, image segmentation can extract lane information in complex scenes and improve the perception of autonomous driving. In intelligent manufacturing, image segmentation can complete the detection of component defects and improve the automation and intelligence of product lines.
[0003] Circuit board wiring detection is an important part of intelligent manufacturing. When conducting circuit board wiring detection, it is necessary to first detect whether the components in the circuit board have been installed in place and then detect whether the circuits are connected correctly. With the vigorous development of intelligent manufacturing today, the demand for production intelligent detection is increasing, and the existing circuit board wiring detection method can no longer meet the needs of intelligent detection. Summary of the invention
[0004] The purpose of the present invention is to solve the problem that the existing circuit board wiring detection method cannot meet the needs of intelligent detection. A circuit board wiring detection method based on deep learning is provided, which uses an improved YOLOV8-seg model to complete the instance segmentation of the circuit board image to be detected, and uses a matching algorithm to perform line detection analysis, which can solve the line detection problem in complex environment scenarios.
[0005] The purpose of the present invention is mainly achieved through the following technical solutions:
[0006] The circuit board wiring detection method based on deep learning includes the following steps:
[0007] Step S1, obtaining a circuit board image to be detected and processing it to a set resolution, and then inputting it into an improved YOLOV8-seg model, the improved YOLOV8-seg model performs image segmentation and processes to obtain detection information of interfaces and circuits; wherein, the improved YOLOV8-seg model adds an attention mechanism module after the SPPF structure of the YOLOV8-seg model backbone network, and the attention mechanism module is used to improve the image segmentation accuracy from the improved YOLOV8-seg model backbone network to the neck layer network, so that all slender features in the circuit board image to be detected are extracted;
[0008] Step S2, calculate the Euclidean distance between each interface and the starting point and the end point of the line. When the Euclidean distance between the interface and the line is less than the set pixel point threshold, it is determined that the interface has been connected to the line. If a line has been connected to two interfaces, it is determined that the line connection is not blocked, and the process goes to step S5; if a line is only connected to one interface or no interface is connected, it is determined that the line is blocked, and the process goes to step S3;
[0009] Step S3, intercept all pixel points within the set length of the start and end points of the blocked line and set the vectors of the start and end points of the blocked line, take the midpoint of the image width of the segmented circuit board image to be detected for vector fitting, calculate the angles and intersections between all vectors, find the same vectors whose angles are within the set angle deviation threshold of 180° and whose intersections do not exceed the image range, identify the lines corresponding to the two same vectors as the same line and synchronize the start and end point information;
[0010] Step S4, detecting whether there is an interface at the start and end positions of the line after the synchronization of the start and end information within the set pixel threshold range, if there is an interface, determining that the interface is successfully connected to the line connection, otherwise determining that the line connection is unsuccessful;
[0011] Step S5: compare the interface and the circuit with the wiring standard in the circuit board production data. If the comparison is consistent, it is determined that the connection is correct; otherwise, it is determined that the connection is incorrect.
[0012] Furthermore, in the step S1, the image of the circuit board to be detected is processed to a set resolution of 640*640, and the resolution of the image after processing by the improved YOLOV8-seg model is 20*20, 40*40 and 80*80.
[0013] Furthermore, the input of the attention mechanism module in step S1 is the output of the SPPF structure. The three matrices Q, K, and V are generated by linearly transforming the input. The formula for attention calculation by the attention mechanism module is as follows:
[0014]
[0015] Among them, Q represents the query vector, K represents the key vector, V represents the value vector, and d k represents the dimension of the key vector, V T represents matrix transpose, and softmax represents the softmax function.
[0016] Furthermore, in step S2, the pixel threshold is set to 30 pixels.
[0017] Furthermore, the calculation formula for calculating the Euclidean distance between each interface and the starting point and the end point of the line in step S2 is:
[0018]
[0019] Among them, x i Represents the i-th dimension coordinate of the first point, y i represents the i-th dimension coordinate of the second point, n is the number of spatial dimensions, i=1, 2, ..., n, x represents the horizontal coordinate position of the pixel point, and y represents the vertical coordinate position of the pixel point.
[0020] Furthermore, in step S3, the fitting formula for vector fitting of the midpoint of the image width of the segmented circuit board image to be detected is:
[0021] y=kx+b
[0022] Among them, k represents the slope, b represents the ordinate of the intersection of the function graph and the Y-axis, x represents the abscissa position of the pixel point, and y represents the ordinate position of the pixel point.
[0023] The objects detected by the present invention are the interfaces and wiring in the circuit board. The volume of the interface is small compared to the entire original image. The wiring is slender, and it is also small compared to the original image and easily overlaps with other wiring. Therefore, the present invention improves the detection accuracy through the attention mechanism. The attention mechanism is a mechanism by which the model deepens the features of a piece of pixel points that may be the detection target. This is similar to when looking at a picture, a certain small object in the picture is a little unclear. You can zoom in on the area of this small object to see more feature information of the small object and its surroundings. The present invention uses the attention mechanism to deepen the features of the pixels around the suspected target to improve the receptive field.
[0024] In summary, compared with the prior art, the present invention has the following beneficial effects: the present invention processes the image of the circuit board to be detected and then passes it into the improved YOLOV8-seg model. The improved YOLOV8-seg model first generates the result of target detection, then performs image segmentation on the detected interface and line, and finally generates the detection information of the interface and line. The present invention pairs the detection results of the interface and the line, that is, one interface is connected to one line, and directly generates a matching result for the line that has been connected to the two interfaces, and then pairs the blocked lines through the matching algorithm and generates a matching result, and then compares the generated matching result with the known matching information, which can solve the line detection problem in complex environment scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:
[0026] Figure 1 A flowchart of a specific embodiment of the present invention;
[0027] Figure 2 This is the structure diagram of the improved YOLOV8-seg model;
[0028] Figure 3 for Figure 2 Figure 2. C2f structure diagram.
[0029] Figure 4 for Figure 2 The structure diagram of SPPF;
[0030] Figure 5 for Figure 2 Module structure diagram of the attention mechanism. DETAILED DESCRIPTION
[0031] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0032] Example:
[0033] like Figure 1As shown, the circuit board wiring detection method based on deep learning includes the following steps: step S1, obtaining the circuit board image to be detected and processing it to a set resolution and then inputting it into the improved YOLOV8-seg model, the improved YOLOV8-seg model performs image segmentation and processes to obtain the detection information of the interface and the line; wherein, the improved YOLOV8-seg model adds an attention mechanism module after the SPPF structure of the YOLOV8-seg model backbone network, and the attention mechanism module is used to improve the image segmentation accuracy of the improved YOLOV8-seg model backbone network to the neck layer network, so that all the slender features in the circuit board image to be detected are extracted; step S2, calculating the Euclidean distance between each interface and the starting point and end point of the line, when the Euclidean distance between the interface and the line is less than the set pixel threshold, it is determined that the interface has been connected to the line, if a line has been connected to two interfaces, it is determined that the line wiring is unobstructed, and the process goes to step S5; if a line is only If one interface is connected or no interface is connected, it is determined that the line is blocked and the process goes to step S3; step S3, intercept all the pixel points within the set length of the starting point and end point of the blocked line and set the vectors of the starting point and end point of the blocked line, take the midpoint of the image width of the segmented circuit board image to be detected for vector fitting, calculate the angles and intersections between all vectors, find the same vectors whose angles of each vector are within the set angle deviation threshold range of 180° and whose intersections do not exceed the image range, identify the lines corresponding to the two same vectors as the same line and synchronize the start and end point information; step S4, detect whether there is an interface within the set pixel threshold range at the starting and end points of the line after the synchronization of the start and end point information, if there is an interface, determine that the interface and the line wiring are successfully connected, otherwise determine that the line wiring is unsuccessful; step S5, compare the interface and the line with the wiring standard in the circuit board production data, if the comparison is consistent, determine that the connection is correct, otherwise determine that the connection is incorrect. Among them, in this embodiment, the detection information of the interface and the line obtained by the improved YOLOV8-seg model is the image segmentation mask of the circuit board interface and the line. In step S2 of this embodiment, the pixel threshold value is set to 30 pixels.
[0034] In step S1 of this embodiment, the process of performing image segmentation and processing to obtain the detection information of interfaces and lines by the improved YOLOV8-seg model is an instance segmentation process, and its implementation process includes the following two steps: The first step is target detection, which first detects all interfaces and connections. This process only generates the size of the target box and the type of the target. The second step is target segmentation, in which the original image is screenshotted with the target box, the target is segmented in the screenshot, and a mask is generated. The mask plays a partitioning role to distinguish a certain interface or connection from other interfaces or connections.
[0035] In this embodiment, the image of the circuit board to be inspected comes from an industrial camera. In step S1, the image of the circuit board to be inspected is processed to a set resolution of 640*640. After the image is processed by the improved YOLOV8-seg model, the resolution of the image is 20*20, 40*40 and 80*80.
[0036] The input of the attention mechanism module in step S1 of this embodiment is the output of the SPPF structure. The three matrices Q, K, and V are generated by linearly transforming the input. The formula for attention calculation by the attention mechanism module is as follows:
[0037]
[0038] Among them, Q represents the query vector, K represents the key vector, V represents the value vector, and d k represents the dimension of the key vector, V T represents matrix transpose, and softmax represents the softmax function.
[0039] The calculation formula for calculating the Euclidean distance between each interface and the starting point and the end point of the line in step S2 of this embodiment is:
[0040]
[0041] Among them, x i Represents the i-th dimension coordinate of the first point, y i represents the i-th dimension coordinate of the second point, n is the number of spatial dimensions, i=1, 2, ..., n, x represents the horizontal coordinate position of the pixel point, and y represents the vertical coordinate position of the pixel point.
[0042] In step S3 of this embodiment, the fitting formula for vector fitting of the midpoint of the image width of the segmented circuit board image to be detected is:
[0043] y=kx+b
[0044] Among them, k represents the slope, b represents the ordinate of the intersection of the function graph and the Y-axis, x represents the abscissa position of the pixel point, and y represents the ordinate position of the pixel point.
[0045] In this embodiment, the instance segmentation of the circuit board image to be detected is implemented based on the improved YOLOV8-seg model. YOLOV8-seg is a one-shot instance segmentation model. The structure of the improved YOLOV8-seg model in this embodiment is as follows: Figure 2 As shown in Figure 2, the backbone network is an improved CSPNET structure, which improves the original C3 structure to a C2F structure. The C2F structure enriches the fluidity of the gradient and greatly improves the performance by splitting the input into vectors with fewer channels and then performing convolution calculations and splicing. Figure 3The end of the backbone network is the SPPF structure, which can improve the perception domain of feature collection. Figure 4 As shown in the figure, the SPPF structure extracts features of targets of different sizes by pooling different receptive fields without increasing the amount of additional calculation. The purpose of the input to the SPPF structure is to downsample the data through the CONV module. The CONV module is a convolution operation with a step size of 2. At the same time, the C2F module is used to fuse the data, extract features while reducing the feature size, reduce the amount of calculation, and input features of sizes 20×20, 40×40, and 80×80 to the neck part. The neck part uses the structure of the ELAN network. The difference between the ELAN structure and the traditional residual structure is that the concatenation of convolution calculation structures at different steps can reduce the amount of calculation and further increase the feature fusion degree, improve the calculation efficiency of the model, and upsample the features through the Upsample module and pass them to the head end. The head end adopts a decoupled structure, first extracting features through the CONV module and then generating target box prediction, classification prediction, and target segmentation masks through the CONV2D module. The classification results and other results do not share parameters. The decoupled results can improve the robustness of different sample types after training. The loss function of this embodiment adopts DFL (Distributed Focal Loss), which can narrow the gap between training and testing, so that the classification and positioning quality can be expressed more efficiently, providing richer and more accurate location information without adding additional calculations. YOLOV8 has sufficient accuracy and speed for target detection tasks, but it lacks the receptive field for long-shaped targets for target segmentation, so the model needs to be improved. Since the wiring in the circuit accounts for a small area relative to the entire circuit board and some wiring is blocked, this embodiment adds an attention mechanism module after the SPPF structure. The structure of the attention mechanism module is as follows: Figure 5 As shown in the figure, the accuracy of image segmentation is improved. The input of the attention mechanism module is the output of the SPPF structure. The three matrices Q, K, and V are generated by linear transformation of the input. The parameters of the linear transformation can be adjusted through model training. By performing attention calculation, the receptive field is improved to overcome the problem that convolution calculation can only calculate the pixels within the receptive field of view, and all features cannot be effectively extracted for slender targets such as wires.
[0046] This embodiment outputs the box position information and segmentation information of the target through the improved YOLOV8-seg model. There are two types of targets, interface and line. Since the line needs to be matched, the position information of the starting point and end point of the line is added. The starting point and end point information of the line are separate target categories generated when the sample is annotated. After obtaining the detection information of the interface and line through the improved YOLOV8-seg model, this embodiment matches the line according to the wiring standard in the circuit board production data.
[0047] Before using the improved YOLOV8-seg model, this embodiment first trains the improved YOLOV8-seg model. The pixels of the training input circuit board image are 640*640, and there are 10,000 training samples in total. After 500 rounds of training, the scene segmentation accuracy AP is 42.3.
[0048] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A circuit board wiring detection method based on deep learning, characterized in that: The following steps are involved: Step S1, obtaining a circuit board image to be detected and processing it to a set resolution, and then inputting it into an improved YOLOV8-seg model, the improved YOLOV8-seg model performs image segmentation and processes to obtain detection information of interfaces and circuits; wherein, the improved YOLOV8-seg model adds an attention mechanism module after the SPPF structure of the YOLOV8-seg model backbone network, and the attention mechanism module is used to improve the image segmentation accuracy from the improved YOLOV8-seg model backbone network to the neck layer network, so that all slender features in the circuit board image to be detected are extracted; Step S2, calculate the Euclidean distance between each interface and the starting point and the end point of the line. When the Euclidean distance between the interface and the line is less than the set pixel point threshold, it is determined that the interface has been connected to the line. If a line has been connected to two interfaces, it is determined that the line connection is not blocked, and the process goes to step S5; if a line is only connected to one interface or no interface is connected, it is determined that the line is blocked, and the process goes to step S3; Step S3, intercept all pixel points within the set length of the start and end points of the blocked line and set the vectors of the start and end points of the blocked line, take the midpoint of the image width of the segmented circuit board image to be detected for vector fitting, calculate the angles and intersections between all vectors, find the same vectors whose angles are within the set angle deviation threshold of 180° and whose intersections do not exceed the image range, identify the lines corresponding to the two same vectors as the same line and synchronize the start and end point information; Step S4, detecting whether there is an interface at the start and end positions of the line after the synchronization of the start and end information within the set pixel threshold range, if there is an interface, determining that the interface is successfully connected to the line connection, otherwise determining that the line connection is unsuccessful; Step S5: compare the interface and the circuit with the wiring standard in the circuit board production data. If the comparison is consistent, it is determined that the connection is correct; otherwise, it is determined that the connection is incorrect.
2. The circuit board wiring detection method based on deep learning according to claim 1, characterized in that: In the step S1, the image of the circuit board to be detected is processed to a set resolution of 640*640, and the resolution of the image after processing by the improved YOLOV8-seg model is 20*20, 40*40 and 80*80.
3. The circuit board wiring detection method based on deep learning according to claim 1, characterized in that: The input of the attention mechanism module in step S1 is the output of the SPPF structure. The three matrices Q, K, and V are generated by linearly transforming the input. The formula for attention calculation by the attention mechanism module is as follows: Among them, Q represents the query vector, K represents the key vector, V represents the value vector, and d k represents the dimension of the key vector, V T represents matrix transpose, and softmax represents the softmax function.
4. The circuit board wiring detection method based on deep learning according to claim 1, characterized in that: In step S2, the pixel threshold is set to 30 pixels.
5. The circuit board wiring detection method based on deep learning according to claim 1, characterized in that: The calculation formula for calculating the Euclidean distance between each interface and the starting point and the end point of the line in step S2 is: Among them, x i Represents the i-th dimension coordinate of the first point, y i represents the i-th dimension coordinate of the second point, n is the number of spatial dimensions, i=1, 2, ..., n, x represents the horizontal coordinate position of the pixel point, and y represents the vertical coordinate position of the pixel point.
6. The circuit board wiring detection method based on deep learning according to any one of claims 1 to 5, characterized in that: The fitting formula for vector fitting of the midpoint of the image width of the segmented circuit board image to be detected in step S3 is: y=kx+b Among them, k represents the slope, b represents the ordinate of the intersection of the function graph and the Y-axis, x represents the abscissa position of the pixel point, and y represents the ordinate position of the pixel point.
Citation Information
Cited By
CT flaw detection auxiliary method and equipment based on instance segmentation model and storage medium
CN119417833A
