A PCB board component defect detection method, system, device and medium
By combining deep learning models with classic image processing methods, the problems of poor consistency and misjudgment in PCB component inspection are solved, efficient and intelligent defect detection of multiple types of components is achieved, and detection accuracy and speed are improved.
Patent Information
- Application Number
- CN202411228537.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-09-03
AI Technical Summary
Existing PCB component inspection methods have the following problems: poor consistency in inspection results, low reliability, high cost, difficult equipment maintenance, and easy misjudgment of areas with unclear light and shadow. Therefore, they cannot be widely used for the inspection of multiple types of components.
Deep learning models and classic image processing methods are used to process image data in stages. Combined with convolutional neural networks and visual Transformer, local and global information learning is achieved through sparse attention mechanism and deep separable convolution, and defect detection is performed in combination with classic image processing methods.
It improves the accuracy and consistency of detection, reduces the amount of calculation and time cost, and realizes efficient and intelligent defect detection of multiple types of components.
Smart Images

Figure CN119048837B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of defect detection technology, and in particular to a PCB component defect detection method, system, equipment and medium based on machine vision. Background Art
[0002] In recent years, with the rapid development of my country's 3C manufacturing industry, the application of microelectronics technology has also developed towards high density, high integration, and smaller devices. Almost all electronic devices realize various functions and complex control through the electrical interconnection of various components on the PCB board. Therefore, the placement quality of various components on the PCB board has a direct impact on the quality of the final 3C product.
[0003] Traditional methods for inspecting the quality of PCB component placement rely primarily on manual inspection and flying probe testing. These traditional methods significantly damage workers' eyesight and suffer from inconsistent and low-reliability test results. Flying probe testing offers the advantage of high speed, but the associated equipment is expensive and presents numerous maintenance and usage challenges. With the continuous advancement of deep learning and computer vision technologies, many companies are utilizing automated optical inspection (AOI) technology to inspect the quality of PCB component placement, achieving promising results. AOI equipment typically uses a charge-coupled device (CCD) to capture image data of mounted PCB components. The device's built-in intelligent algorithm then identifies the CCD image and generates a recognition result.
[0004] Compared with traditional methods, AOI methods have fast detection speed, good reusability, and low cost, and therefore have good application prospects. For example, the invention with patent application number CN201510570537.6 discloses an image stitching method for AOI inspection of printed circuit boards. The AOI device has at least two cameras located at the same height and arranged at intervals. Each camera captures the part of the circuit board that needs to be inspected in its corresponding area, and the images captured by each camera are stored in the internal storage of the AOI device. The internal processing unit of the AOI device runs an image processing unit. The image processing unit extracts the images in the internal storage and uses an image stitching method to stitch the images captured by all the cameras individually into a complete image according to the positional relationship of the areas they captured. The AOI inspection problem of large PCBs is solved by scanning the area with multiple cameras and then stitching them together. It is suitable for AOI inspection of large workpieces and can capture multiple images at a time and process each image in parallel, thereby improving the efficiency of AOI inspection image acquisition. However, this AOI inspection method is prone to misjudgment for components with gray or unclear light and shadow areas in the image. In addition, since optical inspection is affected by light intensity, angle, resolution and other factors, some defects can only be detected under specific conditions. Therefore, the existing method can only detect one or several types of components at a time, limiting the widespread application of AOI inspection technology. Summary of the Invention
[0005] In order to overcome the defects of the above-mentioned prior art, the purpose of the present invention is to provide a PCB board component defect detection method, system, device and medium based on machine vision, which uses a deep learning model and a classic image processing method based on OpenCV to process image data in stages to achieve PCB board component defect detection. The present invention also includes the system, device and medium under this method.
[0006] In order to achieve the above object, the technical solution of the present invention is:
[0007] A method for detecting defects in components on a PCB, comprising the following steps:
[0008] Step S1: Original image acquisition
[0009] Use a CCD camera to capture PCB component image data using a non-overlapping shooting method to obtain a data set sample. Take the mode value of the image resolution in the data set sample as the preset resolution, and uniformly convert all samples in the data set to the preset resolution size.
[0010] Step S2: Image preprocessing
[0011] The dataset samples are divided into training and test sets in proportion, and the sample distribution in the training and test sets is guaranteed to be consistent. All types of components are included. Based on the PyTorch Transforms module, random center cropping, flipping, and rotation of the sample images in the training set are performed as data augmentation operations.
[0012] Step S3: Establish deep learning model CVM
[0013] The deep learning model CVM is divided into three parts: a shallow network, a deep network, and a classifier. The shallow network includes three downsampling modules, each of which is composed of a 1x1 convolutional layer, a BN layer, a ReLU activation function, a 3x3 convolutional layer, and a maximum pooling layer. The deep network is divided into two branches, one is the convolutional branch, and the other is the Transformer branch. The convolutional branch is composed of three 3x3 convolutional layers connected in sequence. The Transformer branch is composed of three sparse visual encoders connected in sequence. Each sparse visual encoder includes a local feature extraction module, a global feature extraction module, and a feature mixing module. The classifier consists of a fully connected layer and a softmax function. The number of output channels of the fully connected layer is equal to the number of target categories.
[0014] By performing downsampling operations in the shallow network, the deep network uses two different branches, convolution and visual encoder, to complete local information learning and global information learning respectively. A connection is established between the two branches to strengthen information interaction and achieve joint learning of low-level and high-level features. The three sparse visual encoders divide the image into different groups of patch blocks and only calculate self-attention between the patch blocks.
[0015] Step S4: Model training
[0016] First, batch size, epoch, optimizer, and loss function hyperparameters are set. The Adam optimizer and cosine annealing strategy are used to guide the network parameters to the theoretical optimal value. Then, the training set sample data is input into the deep learning model CVM in step S3 to learn the characteristics of the sample. The cross entropy loss function is selected as the loss function, and the goal is to minimize the loss function value. The evaluation metric is the test set accuracy. Finally, the deep learning model CVM is continuously iteratively trained and the network parameters are continuously updated until the model converges or the number of iterations reaches the set termination value, resulting in the final network model Ours.
[0017] Step S5: Component image classification
[0018] The image to be detected is input into the network model Ours. The network model Ours gives the recognition result and the credibility α. If α≥α0, the model recognition result is considered credible and the detection result is directly output. Among them, α0 is an manually set empirical value. On the contrary, if α<α0, it is considered that the network recognition is wrong and it is necessary to enter the next stage to complete the detection based on the classic image processing method for re-detection;
[0019] Step S6: Classical image processing
[0020] The median filter is used to smooth the image; the histogram equalization method is then used to adjust the distribution of the original image pixels so that they are more evenly distributed within the range of (0, 255), thereby enhancing the contrast of the image;
[0021] Step S7: Image binarization
[0022] The image processed in step S6 is converted into a grayscale image, and then the grayscale image is binarized using an adaptive threshold method. The image is divided into foreground and background parts according to the grayscale characteristics of the image, and the areas of no interest in the image are masked;
[0023] Step S8: Edge extraction
[0024] Perform morphological opening and closing operations on the binary image in step S7 to segment independent image elements. Then, adopt an edge detection method based on the Canny operator to preliminarily obtain the edge of the target according to the pixel gradient. Then, adopt the non-maximum pixel gradient suppression method to eliminate the stray response caused by edge detection and remove most non-edge points. By setting high and low thresholds, pixels with gradient intensity higher than the high threshold are defined as strong edges, and pixels with gradient intensity lower than the low threshold are not considered as edge points. Pixels between the two are then judged by the isolated weak edge suppression method. If there is a strong edge image point in the pixel's area, the point is determined to be a strong pixel until the edge of the object is obtained.
[0025] Step S9: Mark point recognition
[0026] First, the object contour is extracted based on the edge of the object obtained in step S8, all contours are retrieved and the entire level of nested contours is reconstructed, and then the circumscribed rectangle of the object is obtained based on the coordinates of the object contour. The aspect ratio of the circumscribed rectangle of the contour is used to determine whether the contour is a circle. After all circles are obtained, they are filtered according to the area of the circle to obtain the final Mark point. If the Mark point is detected, the center coordinates of the circle are directly output and matched with the normal component Mark point information to output the detection result; if the Mark point is not recognized, it is necessary to proceed to the next step of text area extraction.
[0027] Step S10: Text area extraction
[0028] First, the outline of the text line is extracted, the minimum circumscribed rectangle of the text line outline is obtained, and a detection rectangular frame is marked in the original image. The rectangular frame area is the ROI part, and the ROI part is divided into the foreground and background; then the pixel inversion operation is performed on the ROI part to convert it into a black text on a white background; the processed feature image is then subjected to morphological transformation and maximum connected area operation to enhance the contrast of the character foreground relative to the noise background and highlight the edge contour of the character; the rotation angle of the minimum border of the non-horizontal character after the operation is calculated, and then the image is rotated and cropped to ensure that the text part is horizontal and located in the image; finally, the Image_to_String module in Tesseract-OCR is used to recognize the character information of the PCB image components and give the recognition result.
[0029] Step S11: character matching
[0030] After steps S9 and S10, character information and coordinate information on the component to be identified are obtained, and by comparing the classification, character and coordinate information of the component to be identified with that of the standard component, it is determined whether the component has defects.
[0031] The present invention also includes a defect detection system, equipment, and medium for a PCB component defect detection method based on the above-mentioned machine vision, specifically:
[0032] A PCB component defect detection system is used in PCB component quality inspection to implement the above-mentioned PCB component defect detection method based on machine vision, and includes a processing instruction module for executing each step in the method.
[0033] A PCB component defect detection device, comprising:
[0034] Memory: a computer-readable device storing a computer program for the machine vision-based PCB component defect detection method;
[0035] Processor: used to implement the machine vision-based PCB component defect detection method when executing the computer program.
[0036] A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, can implement the machine vision-based PCB component defect detection method.
[0037] Compared with the prior art, the technical advantages of the present invention are:
[0038] 1. The deep learning model of step S3 of the present invention is an efficient combination of convolutional neural networks and visual transformers, which realizes the learning of global and local information. A convolution module is designed to extract local features such as texture, edge, and shape, and a visual autoencoder module is designed to extract the global features of the image, allowing the model to focus on the key areas in the image. The information interaction between the two branches is completed through the sequence and image conversion method, thereby realizing multi-feature fusion and improving the expressive ability of the model.
[0039] 2. The deep learning model proposed in this invention uses a large number of depthwise separable convolutions to replace standard convolutions. Compared with standard convolutions, depthwise separable convolutions do not have point multiplication operations in the channel direction, which reduces the number of model parameters. It adopts a sparse attention mechanism to divide the image into different groups and complete self-attention calculations between each group, which greatly reduces the amount of calculation and improves the model inference speed. It has the characteristics of fewer model parameters and faster model inference speed.
[0040] 3. This method combines deep learning methods with classic image processing methods to detect component defects in PCB images in stages, achieving more intelligent and flexible defect detection and achieving higher detection accuracy. Compared with traditional discrimination methods and other detection algorithms, this method obtains detection results the fastest and takes the least time.
[0041] 4. In steps S5-S10 of the present invention, a mechanism analysis is performed on the soldering process of PCB components, and the image characteristics of different types of components and different types of defects are obtained. Different discrimination indicators are set based on these characteristics. By establishing a strict indicator range, accurate discrimination is achieved, and the inspection results are consistent and reliable.
[0042] In summary, the present invention uses a deep learning model and a classic image processing method based on OpenCV to process image data in stages, realizes defect detection of PCB board components, solves the problems of low detection efficiency and poor detection accuracy caused by manual detection, and can complete high-efficiency and high-speed real-time detection under non-contact detection conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a flow chart of a PCB component defect detection method proposed by the present invention.
[0044] Figure 2 This is a model diagram of the PCB component image classification algorithm based on convolutional-visual Transformer joint feature learning.
[0045] Figure 3 This is the result of obtaining the coordinates of the rectangular Mark points using the classic image processing method in this invention.
[0046] Figure 4 This is the result of obtaining the circular Mark point position using the classic image processing method in the present invention.
[0047] Figure 5 This is a result diagram of component character information obtained by the text area extraction and recognition method of the present invention. DETAILED DESCRIPTION
[0048] An embodiment of the present invention will be described in detail below with reference to the accompanying drawings.
[0049] Reference Figure 1 A method for detecting defects in PCB components, comprising the following steps:
[0050] Step S1: Original image acquisition
[0051] Use a CCD camera to capture PCB component image data using a non-overlapping shooting method to obtain a data set sample. Take the mode value of the image resolution in the data set sample as the preset resolution, and uniformly convert all samples in the data set to the preset resolution size.
[0052] Step S2: Image preprocessing
[0053] The dataset samples are divided into training set and test set in a ratio of 8:2, and the sample distribution in the training set and test set is kept consistent. All types of components are included. Based on the PyTorch Transforms module, random center cropping, flipping, and rotation of the sample images in the training set are performed as data augmentation operations.
[0054] The initial dataset is split into training and test sets in an 8:2 ratio. First, the original image resolution is uniformly resized to 224. Then, the original input of size (H, W, C) is converted into a tensor of shape (224, 224, 3) through random center cropping, random horizontal flipping, and tensor conversion.
[0055] Step S3: Establish deep learning model CVM
[0056] like Figure 2As shown, the deep learning model CVM is divided into three parts: a shallow network, a deep network and a classifier. The shallow network includes three downsampling modules, each of which is composed of a 1x1 convolutional layer, a BN layer, a ReLU activation function, a 3x3 convolutional layer and a maximum pooling layer; the deep network is divided into two branches, one is a convolutional branch, and the other is a Transformer branch. The convolutional branch is composed of three 3x3 convolutional layers connected in sequence, and the Transformer branch is composed of three sparse visual encoders connected in sequence. Each sparse visual encoder includes a local feature extraction module (two convolutional layers), a global feature extraction module (Transformer Encoder) and a feature mixing module (splicing operation + convolutional layer); the classifier consists of a fully connected layer and a softmax function, and the number of output channels of the fully connected layer is equal to the number of target categories.
[0057] To address the problems of convolutional neural networks lacking global information learning and visual transformers lacking local feature extraction, downsampling operations are performed in shallow networks, and two different branches, convolution and visual encoders, are used in deep networks to complete local information learning and global information learning respectively. A connection is established between the two branches to strengthen information interaction, realize low-level and high-level feature joint learning, and improve model performance. To address the problems of large computational complexity and large number of parameters in the visual transformer attention mechanism, a sparse attention mechanism is proposed. That is, the three sparse visual encoders divide the image into different groups of patch blocks and only calculate self-attention between patch blocks, avoiding too many redundant pixels from participating in self-attention calculations. In addition, depthwise separable convolution is used instead of ordinary convolution to reduce the number of model parameters and improve the model inference speed.
[0058] Step S4: Model training
[0059] First, set the batchsize, epoch, optimizer, and loss function hyperparameters. Set the batchsize to 30 and the number of epoch iterations to 100. Use the Adam optimizer and cosine annealing strategy to guide the network parameters to the theoretical optimal values. Then, input the training set sample data into the deep learning model CVM in step S3 to learn the characteristics of the samples. The cross-entropy loss function is selected as the loss function, the goal is to minimize the loss function value, and the test set accuracy is selected as the evaluation indicator. Finally, the deep learning model CVM continuously iterates and trains, continuously updating the network parameters until the model converges or the number of iterations reaches the set termination value, obtaining the final network model Ours.
[0060] Step S5: Component image classification
[0061] Specifically, the process of component image classification is as follows: the image to be detected is input into the network model Ours, and the network model Ours gives the recognition result and credibility α. If α≥α0, the model recognition result is considered to be credible, and the detection result is directly output, where α0 is an manually set empirical value. On the contrary, if α<α0, it is considered that the network recognition is wrong, and it is necessary to enter the next stage based on the classic image processing method to complete the detection and re-detection.
[0062] Step S6: Classical image processing
[0063] Classic image processing includes image smoothing and image enhancement. Because images collected at industrial sites usually contain salt and pepper noise, median filtering is used to smooth the image and reduce the impact of noise. Histogram equalization is used to adjust the distribution of original image pixels so that they are more evenly distributed within the (0, 255) range, thereby enhancing the image contrast.
[0064] Step S7: Image binarization
[0065] The image processed in step S6 is converted into a grayscale image, and then the grayscale image is binarized using an adaptive threshold method. The image is divided into foreground and background parts according to the grayscale characteristics of the image, and the areas of no interest in the image are masked to facilitate better analysis of the shape and contour of the object.
[0066] Step S8: Edge extraction
[0067] Perform morphological opening and closing operations on the binary image in step S7 to segment independent image elements. Then, adopt an edge detection method based on the Canny operator to preliminarily obtain the edge of the target according to the pixel gradient. Then, adopt the non-maximum pixel gradient suppression method to eliminate the stray response caused by edge detection and remove most non-edge points. By setting high and low thresholds, pixels with gradient intensity higher than the high threshold are defined as strong edges, and pixels with gradient intensity lower than the low threshold are not considered as edge points. Pixels between the two are then judged by the isolated weak edge suppression method. If there is a strong edge image point in the pixel's area, the point is determined to be a strong pixel until the edge of the object is obtained.
[0068] Step S9: Mark point recognition
[0069] Mark points are reference points on the image used to judge defects, usually in the form of circles. For polar opposite defects, the Mark point information can be used to judge the polarity of the component. Circle detection is performed using the contour search method. First, the object contour is extracted based on the edge of the object obtained in step S8. All contours are retrieved and the entire level of nested contours is reconstructed. Then, the circumscribed rectangle of the object is obtained based on the coordinates of the object contour. The aspect ratio of the circumscribed rectangle of the contour is used to determine whether the contour is a circle. Normally, the circumscribed rectangle of a circle is approximately equal to a square, so its aspect ratio is close to 1.0. After all the circles are obtained, they are screened based on the area of the circle to obtain the final Mark point. If the Mark point is detected, the coordinates of the center of the circle are directly output and matched with the Mark point information of the normal component to output the detection result, such as Figure 3 、 Figure 4 As shown; if the Mark point is not recognized, you need to proceed to the next step of text area extraction.
[0070] Step S10: Text area extraction
[0071] First, the outline of the text line is extracted, the minimum circumscribed rectangle of the text line outline is obtained, and a detection rectangular box is marked in the original image. The rectangular box area is the ROI part, and the ROI part is divided as the foreground and background; then the pixel inversion operation is performed on the ROI part to convert it into a black text on a white background; the processed feature image is then subjected to morphological transformation and maximum connected area operation to enhance the contrast of the character foreground relative to the noise background and highlight the edge contour of the character; the rotation angle of the minimum border of the non-horizontal character after the operation is calculated, and then the image is rotated and cropped to ensure that the text part is horizontal and located in the image; finally, the Image_to_String module in Tesseract-OCR is used to recognize the character information of the PCB image components and give the recognition results, such as Figure 5 shown.
[0072] Step S11: character matching
[0073] After steps S9 and S10, character information and coordinate information on the component to be identified are obtained, and by comparing the classification, character and coordinate information of the component to be identified with that of the standard component, it is determined whether the component has defects.
[0074] Specifically, the type of component can be determined based on the first few letters of the character, for example, R represents resistance, L represents inductance, and C represents capacitance; the position of the character can be used to determine whether defects such as polarity reversal and wrong parts have occurred. If the recognized character does not match the standard component character, it means that the component has a wrong pasting defect. If the rotation angle of the character is 180°, it means that the component has a polarity reversal defect. Finally, the test result is directly output.
[0075] Implementation effect:
[0076] like Figure 3 、 Figure 4 、 Figure 5 As shown in the figure, the classification accuracy of the method of the present invention reaches 99.5%, and both mark point recognition and text recognition have achieved good results, which proves the effectiveness and advancement of the method.
[0077] Table 1 shows the accuracy results of the component classification task completed by the convolution-visual Transformer joint feature learning network in the present invention.
[0078] Table 1
[0079]
[0080]
[0081]
[0082] The present invention provides a defect detection system, device, and medium for a machine vision-based PCB component defect detection method, specifically:
[0083] A PCB component defect detection system is used in PCB component quality inspection to implement the above-mentioned PCB component defect detection method based on machine vision, and includes a processing instruction module for executing each step in the method.
[0084] A PCB component defect detection device, comprising:
[0085] Memory: a computer-readable device storing a computer program for the machine vision-based PCB component defect detection method;
[0086] Processor: used to implement the machine vision-based PCB component defect detection method when executing the computer program.
[0087] A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, can implement the machine vision-based PCB component defect detection method.
[0088] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A PCB board component defect detection method, characterized in that the steps include: Step S1: Original image acquisition Use a CCD camera to capture PCB component image data using a non-overlapping shooting method to obtain a data set sample. Take the mode value of the image resolution in the data set sample as the preset resolution, and uniformly convert all samples in the data set to the preset resolution size. Step S2: Image preprocessing The dataset samples are divided into training and test sets in proportion, and the sample distribution in the training and test sets is guaranteed to be consistent. All types of components are included. Based on the PyTorch Transforms module, random center cropping, flipping, and rotation of the sample images in the training set are performed as data augmentation operations. Step S3: Establish deep learning model CVM The deep learning model CVM is divided into three parts: a shallow network, a deep network, and a classifier. The shallow network includes three downsampling modules, each of which is composed of a 1x1 convolutional layer, a BN layer, a ReLU activation function, a 3x3 convolutional layer, and a maximum pooling layer. The deep network is divided into two branches, one is the convolutional branch, and the other is the Transformer branch. The convolutional branch is composed of three 3x3 convolutional layers connected in sequence. The Transformer branch is composed of three sparse visual encoders connected in sequence. Each sparse visual encoder includes a local feature extraction module, a global feature extraction module, and a feature mixing module. The classifier consists of a fully connected layer and a softmax function. The number of output channels of the fully connected layer is equal to the number of target categories. By performing downsampling operations in the shallow network, the deep network uses two different branches, convolution and visual encoder, to complete local information learning and global information learning respectively. A connection is established between the two branches to strengthen information interaction and achieve joint learning of low-level and high-level features. The three sparse visual encoders divide the image into different groups of patch blocks and only calculate self-attention between the patch blocks. Step S4: Model training First, batch size, epoch, optimizer, and loss function hyperparameters are set. The Adam optimizer and cosine annealing strategy are used to guide the network parameters to the theoretical optimal value. Then, the training set sample data is input into the deep learning model CVM in step S3 to learn the characteristics of the sample. The cross entropy loss function is selected as the loss function, and the goal is to minimize the loss function value. The evaluation metric is the test set accuracy. Finally, the deep learning model CVM is continuously iteratively trained and the network parameters are continuously updated until the model converges or the number of iterations reaches the set termination value, resulting in the final network model Ours. Step S5: Component image classification The component image classification process is as follows: the image to be tested is input into the network model Ours. The network model gives the recognition result and the credibility α. If α≥α0, the model recognition result is considered credible and the detection result is directly output. Among them, α0 is a manually set empirical value. On the contrary, if α<α0, the network recognition is considered to be wrong and it is necessary to enter the next stage to complete the detection based on the classic image processing method for re-detection. Step S6: Classical image processing The median filter is used to smooth the image; the histogram equalization method is then used to adjust the distribution of the original image pixels so that they are more evenly distributed within the range of (0, 255), thereby enhancing the contrast of the image; Step S7: Image binarization The image processed in step S6 is converted into a grayscale image, and then the grayscale image is binarized using an adaptive threshold method. The image is divided into foreground and background parts according to the grayscale characteristics of the image, and the areas of no interest in the image are masked; Step S8: Edge extraction Perform morphological opening and closing operations on the binary image in step S7 to segment independent image elements. Then, adopt an edge detection method based on the Canny operator to preliminarily obtain the edge of the target according to the pixel gradient. Then, adopt a non-maximum pixel gradient suppression method to eliminate the stray response caused by edge detection and remove most non-edge points. By setting high and low thresholds, pixels with gradient strength higher than the high threshold are defined as strong edges, and pixels with gradient strength lower than the low threshold are not considered edge points. Pixels between the two are then judged by the isolated weak edge suppression method. If there is a strong edge image point in the pixel's area, the pixel is determined to be a strong pixel until the edge of the object is obtained. Step S9: Mark point recognition First, the object contour is extracted based on the edge of the object obtained in step S8, all contours are retrieved and the entire level of nested contours is reconstructed, and then the circumscribed rectangle of the object is obtained based on the coordinates of the object contour. The aspect ratio of the circumscribed rectangle of the contour is used to determine whether the contour is a circle. After all circles are obtained, they are filtered according to the area of the circle to obtain the final Mark point. If the Mark point is detected, the center coordinates of the circle are directly output and matched with the normal component Mark point information to output the detection result; if the Mark point is not recognized, it is necessary to proceed to the next step of text area extraction.
2. A PCB component defect detection method according to claim 1, characterized in that the steps include: If no Mark point is recognized, it is necessary to proceed to the next step, i.e., step S10: text area extraction: first, the outline of the text line is extracted, the minimum circumscribed rectangle of the text line outline is obtained, and a detection rectangle is marked in the original image. The rectangular frame area is the ROI part, and the ROI part is divided into the foreground and background; then the pixel inversion operation is performed on the ROI part to convert it into black text on a white background; The processed feature image is then subjected to morphological transformation and maximum connected area operations to enhance the contrast of the character foreground relative to the noisy background and highlight the edge contours of the characters. The rotation angle of the minimum bounding box of the non-horizontal characters after the operation is calculated, and the image is then rotated and cropped to ensure that the text part is horizontal and located in the image. Finally, the Image_to_String module in Tesseract-OCR is used to recognize the character information of the PCB image components and present the recognition results. Step S11: character matching After steps S9 and S10, character information and coordinate information on the component to be identified are obtained, and by comparing the classification, character and coordinate information of the component to be identified with that of the standard component, it is determined whether the component has defects.
3. A PCB component defect detection system, characterized in that: The invention is applied in the quality inspection of PCB components to realize the PCB component defect detection method according to claim 1 or 2, and includes a processing instruction module for executing each step in the method.
4. A PCB component defect detection device, characterized in that: include: Memory: a computer-readable device storing the computer program of the PCB component defect detection method according to claim 1 or 2; Processor: used to implement the PCB board component defect detection method according to claim 1 or 2 when executing the computer program.
5. A computer-readable storage medium storing a computer program, wherein: When the computer program is executed by a processor, it can implement the PCB board component defect detection method described in claim 1 or 2.
Citation Information
Patent Citations
Printed circuit board AOI detection image stitching method
CN105184739A
Full-automatic dairy cow cervical lesion physical examination method
CN114240863A
Improved chip multi-defect detection method and system based on fusion of SwinIR and RT-DETR
CN117934420A