CN112669267B - Circuit board defect detection method and device, electronic equipment and storage medium - Google Patents
Circuit board defect detection method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN112669267B CN112669267B CN202011511881.5A CN202011511881A CN112669267B CN 112669267 B CN112669267 B CN 112669267B CN 202011511881 A CN202011511881 A CN 202011511881A CN 112669267 B CN112669267 B CN 112669267B
- Authority
- CN
- China
- Prior art keywords
- image
- sub
- circuit board
- trained
- sample set
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)
- Image Analysis (AREA)
- Image Processing (AREA)
Abstract
The application relates to a detection model and discloses a circuit board defect detection method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a first image, wherein a circuit board in the first image is defective; inputting the first image into a trained generation network to obtain a second image, wherein the circuit board in the second image is free of defects; determining defect information of a circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image; wherein the defect information includes at least one of: defect location, defect area, and defect type. By implementing the embodiment of the application, the accurate detection of the defects of the circuit board is realized.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for detecting a defect of a circuit board, an electronic device, and a storage medium.
Background
In electronic products, circuit boards are an important part of the composition electronic products, and are widely applied to various electronic devices, and the normal operation of the electronic products depends on the quality of the circuit boards to a great extent, so the defect detection for the circuit boards is an important direction for researching the industrial manufacturing field.
Since the human eye has a weak resolving power for a tiny target, high instability, and cannot efficiently complete a detection task in the face of a large amount of data, the manual detection in the past has gradually been replaced by machine detection. The machine and the detection scheme applying artificial intelligence, such as applying optical equipment scanning, adding deep learning to detect and identify, can realize the gray level and observe the micrometer level target, have the characteristics of consistent stability and comprehensive traceability of information, and can achieve better detection efficiency and accuracy even in the face of larger data volume. However, due to the variety of defects of the circuit board, the defects need to be manually marked in the existing detection scheme, so that the defect detection of the circuit board is realized based on the manually marked defects. However, the manual labeling has errors, which results in the fact that the existing detection scheme may not realize accurate detection of the defects of the circuit board. Therefore, a technical means is needed to realize accurate detection of the defects of the circuit board.
Disclosure of Invention
The embodiment of the application provides a method, a device, electronic equipment and a storage medium for detecting defects of a circuit board, which realize accurate detection of the defects of the circuit board.
The first aspect of the present application provides a method for detecting a defect of a circuit board, comprising:
Acquiring a first image, wherein a circuit board in the first image is defective;
inputting the first image into a trained generation network to obtain a second image, wherein the circuit board in the second image is free of defects;
determining defect information of a circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image;
Wherein the defect information includes at least one of: defect location, defect area, and defect type.
The second aspect of the application provides a circuit board defect detection device, which comprises an acquisition module, an input module and a determination module,
The acquisition module is used for acquiring a first image, wherein the circuit board in the first image is defective;
the input module is used for inputting the first image into a trained generation network to obtain a second image, and the circuit board in the second image is free of defects;
The determining module is used for determining defect information of the circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image;
Wherein the defect information includes at least one of: defect location, defect area, and defect type.
A third aspect of the present application provides an electronic device for circuit board defect detection, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and are generated for execution by the processor to perform instructions of steps in any one of the methods for circuit board defect detection.
A fourth aspect of the present application provides a computer readable storage medium storing a computer program for execution by the processor to implement the method of any one of the methods of circuit board defect detection.
According to the technical scheme, the defect information of the circuit board in the defective image can be determined according to the texture characteristic value corresponding to each pixel in the defective image and the texture characteristic value corresponding to each pixel in the non-defective image by inputting the defective image into the trained generating network, so that the defect detection of the circuit board based on the manually marked defect in the existing scheme is avoided, and the problem that the accurate detection of the defect of the circuit board cannot be realized under the condition that the manual mark has errors is solved.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Wherein:
FIG. 1 is a schematic diagram of a system for detecting defects of a circuit board according to an embodiment of the present application;
FIG. 2 is a schematic diagram of yet another system for detecting defects of a circuit board according to an embodiment of the present application;
Fig. 3 is a schematic flow chart of a method for detecting defects of a circuit board according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a gray value pair according to an embodiment of the present application;
Fig. 5 is a schematic diagram of a circuit board defect detecting device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device in a hardware running environment according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The following will describe in detail.
The terms first and second in the description and claims of the application and in the above-mentioned figures are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
Referring first to fig. 1, fig. 1 is a schematic diagram of a circuit board defect detection system according to an embodiment of the present application, where the circuit board defect detection system 100 includes a circuit board defect detection device 110. The circuit board defect detection device 110 is used for processing, storing images, and the like. The circuit board defect detection system 100 may include an integrated single device or multiple devices, and for convenience of description, the circuit board defect detection system 100 will be referred to as an electronic device. It will be appreciated that the electronic device may include various handheld devices, vehicle mounted devices, wearable devices, computing devices or other processing devices connected to a wireless modem, as well as various forms of User Equipment (UE), mobile Station (MS), terminal devices (TERMINAL DEVICE), and the like.
Referring to fig. 2, fig. 2 is a schematic diagram of yet another system for detecting defects of a circuit board according to an embodiment of the present application, where the system includes a server 20 and a database 21. The server 20 is used to implement the scheme according to the embodiment of the present application. The database 21 is used for storing a first image, a sample set, etc. For example, the server 20 may obtain the first image from the database 21. The function of the particular server 20 is not limited herein.
In addition, human eyes have poor resolving power to tiny targets, high instability and the inability to efficiently complete detection tasks in the face of large amounts of data, so that manual detection in the past has gradually been replaced by machine detection. The machine and the detection scheme applying artificial intelligence, such as applying optical equipment scanning, adding deep learning to detect and identify, can realize the gray level and observe the micrometer level target, have the characteristics of consistent stability and comprehensive traceability of information, and can achieve better detection efficiency and accuracy even in the face of larger data volume. However, due to the variety of defects of the circuit board, the defects need to be manually marked in the existing detection scheme, so that the defect detection of the circuit board is realized based on the manually marked defects. However, the manual labeling has errors, which results in the fact that the existing detection scheme may not realize accurate detection of the defects of the circuit board. Therefore, a technical means is needed to realize accurate detection of the defects of the circuit board.
Based on this, the embodiment of the present application proposes a method for detecting defects of a circuit board to solve the above-mentioned problems, and the following detailed description of the embodiment of the present application is provided.
Referring to fig. 3, fig. 3 is a schematic flow chart of a circuit board defect detection method according to an embodiment of the present application. The method for detecting the defects of the circuit board can be applied to electronic equipment or a server, and as shown in fig. 3, the method comprises the following steps:
301. A first image is acquired, wherein the circuit board in the first image is defective.
Illustratively, step 301 may include: the server invokes an interface to obtain the first image from the database.
The first image is an image subjected to noise removal and color image enhancement.
It should be noted that no other device than the circuit board is present in the first image.
302. Inputting the first image into a trained generation network to obtain a second image, wherein the circuit board in the second image is free of defects.
303. Determining defect information of a circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image; wherein the defect information includes at least one of: defect location, defect area, and defect type.
Wherein the defect types include one or more of: solder joint short circuit, more copper, less copper, solder joint open circuit, breach, burr and mar.
Optionally, the determining defect information of the circuit board in the first image according to the texture feature value corresponding to each pixel in the first image and the texture feature value corresponding to each pixel in the second image includes: determining a first feature map corresponding to the first image according to the first image, wherein the first feature map comprises texture feature values corresponding to each pixel; determining a second feature map corresponding to the second image according to the second image, wherein the second feature map comprises texture feature values corresponding to each pixel; comparing the texture characteristic value corresponding to each pixel in the first characteristic diagram with the texture characteristic value corresponding to each pixel in the second characteristic diagram; and when the absolute value between the first texture characteristic value in the first characteristic diagram and the texture characteristic value in the second characteristic diagram is larger than a third threshold value, determining the defect information of the circuit board in the first image according to the first texture characteristic value.
The determining, according to the first image, a first feature map corresponding to the first image includes: graying the first image to obtain a first gray image; and determining a texture characteristic value corresponding to each pixel point according to a gray value pair formed by the gray value of each pixel in the first gray image and the gray value corresponding to any one pixel in the adjacent pixels so as to obtain a first characteristic image.
Referring to fig. 4, fig. 4 is a schematic diagram of a gray value pair according to an embodiment of the present application. Specifically, referring to fig. 4, it can be seen that the gray value of the pixel 1 and the gray value of the pixel 2 form a gray value pair; alternatively, the gray value of pixel 1 may form a gray value pair with the gray value of pixel 3; alternatively, the gray value of pixel 1 may form a gray value pair with the gray value of pixel 4; alternatively, the gray value of pixel 1 may form a gray value pair with the gray value of pixel 5.
Wherein, the determining, according to the second image, a second feature map corresponding to the second image includes: graying the second image to obtain a second gray image; and determining a texture characteristic value corresponding to each pixel point according to a gray value pair formed by the gray value of each pixel in the second gray image and the gray value corresponding to any one pixel in the adjacent pixels so as to obtain a second characteristic image.
The third threshold may be set by an administrator, or may be configured in a configuration file, which is not limited herein.
The first texture feature value may be one or more texture feature values corresponding to one or more pixels in the first feature map, which is not limited herein.
Wherein, the determining the defect information of the circuit board in the first image according to the first texture feature value can be understood as: determining the position of the pixel corresponding to the first texture characteristic value to obtain a defect position included in defect information; determining the size of a pixel corresponding to the first texture feature value; determining a defect area included in the defect information according to the size of the pixel corresponding to the first texture characteristic value; restoring the region corresponding to the first texture feature value from the first feature map to the region corresponding to the first image; displaying an area corresponding to the first image on a display interface; and when the defect type input instruction is detected on the display interface, acquiring the defect type included in the defect information.
It will be appreciated that the display interface may include a defect type input box in which a user may enter a defect type. Further, when the defect type input instruction is detected on the display interface, obtaining the defect type included in the defect information includes: and when the defect type input instruction is detected on the display interface, acquiring the defect type included in the defect information from the defect type input box.
According to the technical scheme, the defect information of the circuit board in the defective image can be determined according to the texture characteristic value corresponding to each pixel in the defective image and the texture characteristic value corresponding to each pixel in the non-defective image by inputting the defective image into the trained generating network, so that the defect detection of the circuit board based on the manually marked defect in the existing scheme is avoided, and the problem that the accurate detection of the defect of the circuit board cannot be realized under the condition that the manual mark has errors is solved.
In a possible implementation manner, before the first image is input into the trained generating network to obtain the second image, the method further includes:
Obtaining a sample set, wherein the sample set comprises a positive sample set and a negative sample set, the circuit board of each positive sample in the positive sample set is not defective, and the circuit board of each negative sample in the negative sample set is defective;
Alternately inputting the positive sample set and the negative sample set into a generating network to be trained, inputting the output result of the generating network to be trained into a discriminating network to be trained whenever the output result of the generating network to be trained is available, and stopping inputting samples which are not alternately input into the generating network to be trained in the positive sample set and the negative sample set into the generating network to be trained until the ratio of the number of first labels to the number of second labels in the output result of the discriminating network to be trained is higher than a first threshold value, so as to obtain the trained generating network; wherein the first label is a non-defective label and the second label is a defective label.
The first threshold may be set by an administrator, or may be configured in a configuration file, which is not limited herein.
Alternatively, each negative sample in the negative sample set may be determined from each positive sample in the positive sample set. Specifically, defects such as solder joint short circuit, more copper, less copper, solder joint open circuit, notch, burr and scratch and the like can be artificially added on the circuit board of each positive sample in the positive sample set, so as to obtain a negative sample set comprising different defect types.
Optionally, obtaining the sample set includes: the calling interface obtains a sample set from the database.
Wherein each sample in the sample set is determined from the image after noise removal and color image enhancement.
The generating network to be trained and the judging network to be trained are deep neural networks.
According to the technical scheme, samples which are not alternately input into the generating network to be trained in the positive sample set and the negative sample set are stopped from being input into the generating network to be trained until the ratio of the number of the first labels to the number of the second labels in the output result of the judging network to be trained is higher than the first threshold value, so that the reliability of the generating network to be trained is improved, and the image output by the generating network to be trained is more similar to a defect-free image.
In one possible embodiment, the loss function in the generation network to be trained satisfies the following formula:
The method comprises the steps of generating a negative sample set, wherein L is a loss function in the generating network to be trained, M is the number of the negative sample set, omega n is a weight, V n is a first vector, a first element in the first vector is a mean value of at least one element, a first row element and a first column element and a diagonal element of the first row element, which are acquired by taking a step length as a preset step length in a first direction and a second direction respectively by taking a first row element and a first column element as a reference in a second vector, the second vector is determined according to each element in the vector corresponding to the first negative sample and a vector corresponding to a first positive sample, the first negative sample is any negative sample in the negative sample set, the first positive sample is a positive sample associated with the first negative sample in the positive sample set, and the first direction and the second direction are different.
The preset step size may be set by an administrator, or may be configured in a configuration file, which is not limited herein.
If the first direction is downward, the second direction is rightward; if the first direction is to the right, the second direction is downward.
It should be noted that, other elements in the first vector except the first element may refer to the first element, which is not described herein.
The vector corresponding to the first negative sample isThe vector corresponding to the first positive sample isThe second vector isThat is, the second vector isIf the preset step length is 1, the first vector may be
According to the technical scheme, the updating of the loss function is realized by utilizing the vector determined by each element in the vector corresponding to the negative sample and the vector corresponding to the positive sample, so that the reliability of the trained generation network is improved, and the image output by the trained generation network is more similar to a defect-free image.
In one possible implementation, the ω n is a ratio of a minimum element in the first vector to a sum of each element in the first vector.
In one possible implementation manner, the determining defect information of the circuit board in the first image according to the texture feature value corresponding to each pixel in the first image and the texture feature value corresponding to each pixel in the second image includes:
splitting the first image into a plurality of first sub-images of equal size;
splitting the second image into a plurality of second sub-images with the same size, wherein the plurality of first sub-images are in one-to-one correspondence with the plurality of second sub-images;
And comparing the texture characteristic value corresponding to each first sub-image in the plurality of first sub-images with the texture characteristic value corresponding to each second sub-image in the plurality of second sub-images to determine the defect information of the circuit board in the first image.
Optionally, before comparing the texture feature value corresponding to each of the first sub-images with the texture feature value corresponding to each of the second sub-images to determine defect information of the circuit board in the first image, the method further includes: determining a first sub-feature map corresponding to each first sub-image according to each first sub-image in the plurality of first sub-images, wherein the first sub-feature map comprises texture feature values corresponding to each pixel; and determining a second sub-feature map corresponding to each second sub-image according to each second sub-image in the plurality of second sub-images, wherein the second sub-feature map comprises texture feature values corresponding to each pixel.
Wherein the determining, according to each first sub-image in the plurality of first sub-images, a first sub-feature map corresponding to each first sub-image includes: graying each first sub-image in the plurality of first sub-images to obtain a gray sub-image corresponding to each first sub-image; and determining a texture characteristic value corresponding to each pixel point according to a gray value pair formed by the gray value of each pixel in the gray sub-image corresponding to each first sub-image and the gray value corresponding to any one pixel in the adjacent pixels so as to obtain a characteristic image corresponding to each first sub-image.
Wherein the determining, according to each second sub-image in the plurality of second sub-images, a second sub-feature map corresponding to each second sub-image includes: graying each second sub-image in the plurality of second sub-images to obtain a gray sub-image corresponding to each second sub-image; and determining a texture characteristic value corresponding to each pixel point according to a gray value pair formed by the gray value of each pixel in the gray sub-image corresponding to each second sub-image and the gray value corresponding to any one pixel in the adjacent pixels so as to obtain a characteristic image corresponding to each second sub-image.
According to the technical scheme, the images are segmented, so that a plurality of sub-images can be compared at the same time, and the efficiency of determining the defect information of the circuit board in the images is improved.
In one possible implementation manner, the third sub-image is any one of the first sub-images, the fourth sub-image is a sub-image corresponding to the third sub-image in the second sub-images, and comparing the texture feature value corresponding to each of the first sub-images with the texture feature value corresponding to each of the second sub-images to determine defect information of the circuit board in the first image includes:
Constructing a coordinate system by taking the geometric center of a third sub-image as an origin, wherein the third sub-image is any one of the plurality of first sub-images, the positive direction of the abscissa of the coordinate system is horizontal to the right, and the positive direction of the ordinate of the coordinate system is upward;
Comparing the texture characteristic value of the image in the circle with the initial radius being the preset radius in the third sub-image with the texture characteristic value of the corresponding image in the fourth sub-image by taking the origin of the coordinate system as a round point, and increasing the preset radius by a second threshold value after each comparison until the comparison of the third sub-image and the fourth sub-image is finished, so as to obtain a comparison result of each time;
and determining defect information corresponding to the third sub-image according to the comparison result.
The second threshold may be set by an administrator or may be configured in a configuration file, which is not limited herein.
And determining defect information corresponding to the third sub-image according to the comparison result, wherein the determining defect information comprises the following steps: and if the comparison result is inconsistent, determining defect information corresponding to the current comparison to obtain defect information corresponding to the third sub-image.
According to the technical scheme, the sub-images are compared by taking the circle as a reference, so that the image area of each comparison is reduced, the single comparison efficiency is improved, and the efficiency of determining the defect information of the circuit board in the image is improved.
Referring to fig. 5, fig. 5 is a schematic diagram of a circuit board defect detecting device according to an embodiment of the present application. As shown in fig. 5, a circuit board defect detecting device 500 according to an embodiment of the present application includes an obtaining module 501, an input module 502 and a determining module 503,
The acquiring module 501 is configured to acquire a first image, where a circuit board in the first image has a defect;
The input module 502 is configured to input the first image into a trained generating network to obtain a second image, where the second image has no defect on a circuit board;
The determining module 503 is configured to determine defect information of the circuit board in the first image according to the texture feature value corresponding to each pixel in the first image and the texture feature value corresponding to each pixel in the second image;
Wherein the defect information includes at least one of: defect location, defect area, and defect type.
According to the technical scheme, the defect information of the circuit board in the defective image can be determined according to the texture characteristic value corresponding to each pixel in the defective image and the texture characteristic value corresponding to each pixel in the non-defective image by inputting the defective image into the trained generating network, so that the defect detection of the circuit board based on the manually marked defect in the existing scheme is avoided, and the problem that the accurate detection of the defect of the circuit board cannot be realized under the condition that the manual mark has errors is solved.
In a possible implementation manner, before inputting the first image into the trained generating network to obtain the second image, the obtaining module 501 is further configured to obtain a sample set, where the sample set includes a positive sample set and a negative sample set, and each positive sample in the positive sample set has no defect on a circuit board, and each negative sample in the negative sample set has a defect on a circuit board; the input module 502 is further configured to alternately input the positive sample set and the negative sample set into a generating network to be trained, and input the output result of the generating network to be trained into a discriminating network to be trained whenever the generating network to be trained has an output result, until a ratio of a number of first labels to a number of second labels in the output result of the discriminating network to be trained is higher than a first threshold, stop inputting samples in the generating network to be trained, which are not alternately input into the generating network to be trained in the positive sample set and the negative sample set, into the generating network to be trained, so as to obtain the trained generating network;
wherein the first label is a non-defective label and the second label is a defective label.
According to the technical scheme, samples which are not alternately input into the generating network to be trained in the positive sample set and the negative sample set are stopped from being input into the generating network to be trained until the ratio of the number of the first labels to the number of the second labels in the output result of the judging network to be trained is higher than the first threshold value, so that the reliability of the generating network to be trained is improved, and the image output by the generating network to be trained is more similar to a defect-free image.
In one possible embodiment, the loss function in the generation network to be trained satisfies the following formula:
The method comprises the steps of generating a negative sample set, wherein L is a loss function in the generating network to be trained, M is the number of the negative sample set, omega n is a weight, V n is a first vector, a first element in the first vector is a mean value of at least one element, a first row element and a first column element and a diagonal element of the first row element, which are acquired by taking a step length as a preset step length in a first direction and a second direction respectively by taking a first row element and a first column element as a reference in a second vector, the second vector is determined according to each element in the vector corresponding to the first negative sample and a vector corresponding to a first positive sample, the first negative sample is any negative sample in the negative sample set, the first positive sample is a positive sample associated with the first negative sample in the positive sample set, and the first direction and the second direction are different.
According to the technical scheme, the updating of the loss function is realized by utilizing the vector determined by each element in the vector corresponding to the negative sample and the vector corresponding to the positive sample, so that the reliability of the trained generation network is improved, and the image output by the trained generation network is more similar to a defect-free image.
In one possible implementation, the ω n is a ratio of a minimum element in the first vector to a sum of each element in the first vector.
In one possible implementation, the apparatus 500 further includes a segmentation module 504 that, when determining the defect information of the circuit board in the first image based on the texture feature value corresponding to each pixel in the first image and the texture feature value corresponding to each pixel in the second image,
The segmentation module 504 is configured to segment the first image into a plurality of first sub-images with the same size;
the segmentation module 504 is configured to segment the second image into a plurality of second sub-images with equal sizes, where the plurality of first sub-images are in one-to-one correspondence with the plurality of second sub-images;
The determining module 503 is configured to compare a texture feature value corresponding to each of the first sub-images with a texture feature value corresponding to each of the second sub-images to determine defect information of the circuit board in the first image.
According to the technical scheme, the images are segmented, so that a plurality of sub-images can be compared at the same time, and the efficiency of determining the defect information of the circuit board in the images is improved.
In one possible implementation manner, the third sub-image is any one of the first sub-images, the fourth sub-image is a sub-image corresponding to the third sub-image in the second sub-images, the apparatus 500 further includes a construction module 505 and a comparison module 506, when comparing the texture feature value corresponding to each of the first sub-images with the texture feature value corresponding to each of the second sub-images to determine the defect information of the circuit board in the first image,
The building module 505 is configured to build a coordinate system with a geometric center of a third sub-image as an origin, where the third sub-image is any one of the first sub-images, a positive direction of an abscissa of the coordinate system is horizontal to the right, and a positive direction of an ordinate of the coordinate system is upward;
The comparing module 506 is configured to compare, with an origin of the coordinate system as a circle point, a texture feature value of an image in a circle with an initial radius being a preset radius in the third sub-image with a texture feature value of a corresponding image in the fourth sub-image, and after each comparison, increase the preset radius by a second threshold value until the comparison between the third sub-image and the fourth sub-image is completed, so as to obtain a comparison result of each time;
The determining module 503 is configured to determine defect information corresponding to the third sub-image according to the comparison result.
According to the technical scheme, the sub-images are compared by taking the circle as a reference, so that the image area of each comparison is reduced, the single comparison efficiency is improved, and the efficiency of determining the defect information of the circuit board in the image is improved.
Referring to fig. 6, fig. 6 is a schematic diagram of an electronic device structure of a hardware running environment according to an embodiment of the present application.
An embodiment of the present application provides an electronic device for detecting a circuit board defect, including a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor to perform instructions including steps in any of the circuit board defect detection methods. As shown in fig. 6, an electronic device of a hardware running environment according to an embodiment of the present application may include:
A processor 601, such as a CPU.
The memory 602 may alternatively be a high-speed RAM memory or a stable memory, such as a disk memory.
A communication interface 603 for enabling a connection communication between the processor 601 and the memory 602.
It will be appreciated by those skilled in the art that the configuration of the electronic device shown in fig. 6 is not limiting and may include more or fewer components than shown, or certain components may be combined, or a different arrangement of components.
As shown in fig. 6, memory 602 may include an operating system, a network communication module, and one or more programs. An operating system is a program that manages and controls server hardware and software resources, supporting the execution of one or more programs. The network communication module is used to enable communication between components within the memory 602 and with other hardware and software within the electronic device.
In the electronic device shown in fig. 6, the processor 601 is configured to execute one or more programs in the memory 602, and implement the following steps:
Acquiring a first image, wherein a circuit board in the first image is defective;
inputting the first image into a trained generation network to obtain a second image, wherein the circuit board in the second image is free of defects;
determining defect information of a circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image;
Wherein the defect information includes at least one of: defect location, defect area, and defect type.
The specific implementation of the electronic device according to the present application may refer to each embodiment of the above-mentioned method for detecting a defect of a circuit board, which is not described herein.
The present application also provides a computer readable storage medium for storing a computer program, the stored computer program being executed by the processor to implement the steps of:
Acquiring a first image, wherein a circuit board in the first image is defective;
inputting the first image into a trained generation network to obtain a second image, wherein the circuit board in the second image is free of defects;
determining defect information of a circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image;
Wherein the defect information includes at least one of: defect location, defect area, and defect type.
The specific implementation of the computer readable storage medium according to the present application can be found in the embodiments of the above-mentioned circuit board defect detection method, and will not be described herein.
It should be noted that, for simplicity of description, the foregoing method embodiments are all expressed as a series of action combinations, but it should be understood by those skilled in the art that the present application is not limited by the order of action described, as some steps may be performed in other order or simultaneously in accordance with the present application. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required for the present application.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application.
Claims (5)
1. A method for detecting defects in a circuit board, comprising:
Acquiring a first image, wherein a circuit board in the first image is defective;
inputting the first image into a trained generation network to obtain a second image, wherein the circuit board in the second image is free of defects;
determining defect information of a circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image;
wherein the defect information includes at least one of: defect location, defect area, and defect type;
before the first image is input into the trained generation network to obtain the second image, the method further comprises:
Obtaining a sample set, wherein the sample set comprises a positive sample set and a negative sample set, the circuit board of each positive sample in the positive sample set is not defective, and the circuit board of each negative sample in the negative sample set is defective;
Alternately inputting the positive sample set and the negative sample set into a generating network to be trained, inputting the output result of the generating network to be trained into a discriminating network to be trained whenever the output result of the generating network to be trained is available, and stopping inputting samples which are not alternately input into the generating network to be trained in the positive sample set and the negative sample set into the generating network to be trained until the ratio of the number of first labels to the number of second labels in the output result of the discriminating network to be trained is higher than a first threshold value, so as to obtain the trained generating network;
Wherein the first label is a non-defective label and the second label is a defective label;
the loss function in the generation network to be trained satisfies the following formula: ;
Wherein L is a loss function in the generating network to be trained, the method comprises the following steps of For the number of negative sample sets, theAs a weight, theThe method comprises the steps that a first element in a first vector is a mean value of at least one element, a first row and a first column element and a diagonal element of the first row and the first column element, which are obtained by taking a step length as a preset step length, in a first direction and a second direction respectively by taking the first row and the first column element as a reference, wherein the first element in the first vector is a second vector, the second vector is determined according to each element in a vector corresponding to a first negative sample and a vector corresponding to a first positive sample, the first negative sample is any negative sample in the negative sample set, the first positive sample is a positive sample associated with the first negative sample in the positive sample set, and the first direction and the second direction are different;
The said A ratio of a minimum element in the first vector to a sum of each element in the first vector;
The determining the defect information of the circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image comprises the following steps:
splitting the first image into a plurality of first sub-images of equal size;
splitting the second image into a plurality of second sub-images with the same size, wherein the plurality of first sub-images are in one-to-one correspondence with the plurality of second sub-images;
And comparing the texture characteristic value corresponding to each first sub-image in the plurality of first sub-images with the texture characteristic value corresponding to each second sub-image in the plurality of second sub-images to determine the defect information of the circuit board in the first image.
2. The method of claim 1, wherein the third sub-image is any one of the first sub-images, the fourth sub-image is a sub-image corresponding to the third sub-image among the second sub-images, and the comparing the texture feature value corresponding to each of the first sub-images with the texture feature value corresponding to each of the second sub-images to determine the defect information of the circuit board in the first image includes:
Constructing a coordinate system by taking the geometric center of a third sub-image as an origin, wherein the third sub-image is any one of the plurality of first sub-images, the positive direction of the abscissa of the coordinate system is horizontal to the right, and the positive direction of the ordinate of the coordinate system is upward;
Comparing the texture characteristic value of the image in the circle with the initial radius being the preset radius in the third sub-image with the texture characteristic value of the corresponding image in the fourth sub-image by taking the origin of the coordinate system as a round point, and increasing the preset radius by a second threshold value after each comparison until the comparison of the third sub-image and the fourth sub-image is finished, so as to obtain a comparison result of each time;
and determining defect information corresponding to the third sub-image according to the comparison result.
3. A circuit board defect detection device is characterized by comprising an acquisition module, an input module and a determination module,
The acquisition module is used for acquiring a first image, wherein the circuit board in the first image is defective;
the input module is used for inputting the first image into a trained generation network to obtain a second image, and the circuit board in the second image is free of defects;
The determining module is used for determining defect information of the circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image;
wherein the defect information includes at least one of: defect location, defect area, and defect type;
before inputting the first image into a trained generation network to obtain a second image,
The acquisition module is further used for acquiring a sample set, wherein the sample set comprises a positive sample set and a negative sample set, the circuit board of each positive sample in the positive sample set is free of defects, and the circuit board of each negative sample in the negative sample set is free of defects;
The input module is further configured to alternately input the positive sample set and the negative sample set into a generating network to be trained, and input the output result of the generating network to be trained into a discriminating network to be trained whenever the generating network to be trained has an output result, until a ratio of the number of first labels to the number of second labels in the output result of the discriminating network to be trained is higher than a first threshold value, stop inputting samples in the generating network to be trained, in which the samples in the generating network to be trained are not alternately input in the positive sample set and the negative sample set, into the generating network to be trained, so as to obtain the trained generating network;
Wherein the first label is a non-defective label and the second label is a defective label;
the loss function in the generation network to be trained satisfies the following formula: ;
Wherein L is a loss function in the generating network to be trained, the method comprises the following steps of For the number of negative sample sets, theAs a weight, theThe method comprises the steps that a first element in a first vector is a mean value of at least one element, a first row and a first column element and a diagonal element of the first row and the first column element, which are obtained by taking a step length as a preset step length, in a first direction and a second direction respectively by taking the first row and the first column element as a reference, wherein the first element in the first vector is a second vector, the second vector is determined according to each element in a vector corresponding to a first negative sample and a vector corresponding to a first positive sample, the first negative sample is any negative sample in the negative sample set, the first positive sample is a positive sample associated with the first negative sample in the positive sample set, and the first direction and the second direction are different;
The said A ratio of a minimum element in the first vector to a sum of each element in the first vector;
The device also comprises a segmentation module which is used for determining the defect information of the circuit board in the first image according to the texture characteristic value corresponding to each pixel in the first image and the texture characteristic value corresponding to each pixel in the second image,
The segmentation module is used for segmenting the first image into a plurality of first sub-images with the same size;
the segmentation module is used for segmenting the second image into a plurality of second sub-images with the same size, and the plurality of first sub-images are in one-to-one correspondence with the plurality of second sub-images;
The determining module is configured to compare a texture feature value corresponding to each of the plurality of first sub-images with a texture feature value corresponding to each of the plurality of second sub-images, so as to determine defect information of the circuit board in the first image.
4. An electronic device for circuit board defect detection, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and are generated for execution by the processor to perform the instructions of the steps of the method of any of claims 1-2.
5. A computer readable storage medium for storing a computer program for execution by a processor to implement the method of any one of claims 1-2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011511881.5A CN112669267B (en) | 2020-12-18 | 2020-12-18 | Circuit board defect detection method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011511881.5A CN112669267B (en) | 2020-12-18 | 2020-12-18 | Circuit board defect detection method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112669267A CN112669267A (en) | 2021-04-16 |
CN112669267B true CN112669267B (en) | 2024-07-09 |
Family
ID=75407324
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011511881.5A Active CN112669267B (en) | 2020-12-18 | 2020-12-18 | Circuit board defect detection method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112669267B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115034171A (en) * | 2022-05-07 | 2022-09-09 | 奥蒂玛光学科技(深圳)有限公司 | Defect labeling method, defect labeling equipment and storage medium |
CN116642908A (en) * | 2023-05-23 | 2023-08-25 | 赣州市超跃科技有限公司 | Circuit board copper deposition monitoring system and method |
CN118890784A (en) * | 2024-08-08 | 2024-11-01 | 中江立江电子有限公司 | A method and device for improving flexible PCB preparation efficiency |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109829895A (en) * | 2019-01-09 | 2019-05-31 | 武汉精立电子技术有限公司 | A kind of AOI defect inspection method based on GAN |
CN111784670A (en) * | 2020-06-30 | 2020-10-16 | 平安国际智慧城市科技股份有限公司 | Hot rolled steel plate surface defect identification method and device based on computer vision |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3532781B2 (en) * | 1999-02-12 | 2004-05-31 | 株式会社メガチップス | Image processing circuit of image input device |
-
2020
- 2020-12-18 CN CN202011511881.5A patent/CN112669267B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109829895A (en) * | 2019-01-09 | 2019-05-31 | 武汉精立电子技术有限公司 | A kind of AOI defect inspection method based on GAN |
CN111784670A (en) * | 2020-06-30 | 2020-10-16 | 平安国际智慧城市科技股份有限公司 | Hot rolled steel plate surface defect identification method and device based on computer vision |
Also Published As
Publication number | Publication date |
---|---|
CN112669267A (en) | 2021-04-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111179251B (en) | Defect detection system and method using template comparison based on Siamese neural network | |
CN112669267B (en) | Circuit board defect detection method and device, electronic equipment and storage medium | |
CN109753953B (en) | Method and device for positioning text in image, electronic equipment and storage medium | |
CN113436100B (en) | Method, apparatus, device, medium, and article for repairing video | |
CN114266773B (en) | Display panel defect positioning method, device, equipment and storage medium | |
CN114240939A (en) | Method, system, equipment and medium for detecting appearance defects of mainboard components | |
CN114627089B (en) | Defect identification method, defect identification device, computer equipment and computer readable storage medium | |
CN113191977B (en) | Image enhancement system for target detection and identification under severe environmental conditions | |
CN117197110A (en) | Image recognition method and device, storage medium and electronic equipment | |
CN117011216A (en) | Defect detection method and device, electronic equipment and storage medium | |
CN113989592A (en) | Expansion method and device for semantically segmenting image sample and electronic equipment | |
CN116542926B (en) | Method, device, equipment and storage medium for identifying defects of two-dimension codes of battery | |
CN117809115A (en) | SMT (surface mounted technology) patch wrong part detection method, SMT patch wrong part detection device and SMT patch wrong part detection visual detection system | |
CN116993654B (en) | Camera module defect detection method, device, equipment, storage medium and product | |
CN117557777A (en) | Sample image determining method and device, electronic equipment and storage medium | |
CN113886745B (en) | Page picture testing method and device and electronic equipment | |
CN105354833A (en) | Shadow detection method and apparatus | |
CN115311237A (en) | Image detection method and device and electronic equipment | |
CN115063614A (en) | Image matching method and device and electronic equipment | |
CN117078708A (en) | Training method, device, equipment, medium and product for image detection and model | |
CN114255339A (en) | A method, device and storage medium for identifying breakpoints of power transmission wires | |
CN117036227B (en) | Data processing method, device, electronic device, medium and program product | |
CN116740385B (en) | Equipment quality inspection method, device and system | |
CN119048506B (en) | Defect identification method, device, equipment and medium for photovoltaic string | |
CN117152065A (en) | PCB bare board defect detection method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |