WO2022088663A1 - 缺陷检测方法及装置、电子设备和存储介质 - Google Patents

缺陷检测方法及装置、电子设备和存储介质 Download PDF

Info

Publication number
WO2022088663A1
WO2022088663A1 PCT/CN2021/096064 CN2021096064W WO2022088663A1 WO 2022088663 A1 WO2022088663 A1 WO 2022088663A1 CN 2021096064 W CN2021096064 W CN 2021096064W WO 2022088663 A1 WO2022088663 A1 WO 2022088663A1
Authority
WO
WIPO (PCT)
Prior art keywords
feature
feature point
map
point
target
Prior art date
Application number
PCT/CN2021/096064
Other languages
English (en)
French (fr)
Inventor
牛临潇
李�诚
Original Assignee
北京市商汤科技开发有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 北京市商汤科技开发有限公司 filed Critical 北京市商汤科技开发有限公司
Priority to JP2022538297A priority Critical patent/JP2023507024A/ja
Publication of WO2022088663A1 publication Critical patent/WO2022088663A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • G06T7/001Industrial image inspection using an image reference approach
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30141Printed circuit board [PCB]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Definitions

  • the present disclosure relates to the technical field of image processing, and in particular, to a defect detection method and device, an electronic device, and a storage medium.
  • PCBs printed circuit boards
  • the performance of electronic equipment is not only affected by the quality and performance of the electronic components themselves, but also largely depends on the quality of the PCB.
  • PCB defect detection technology is an important link related to the quality and production cycle of electronic systems, and has received much attention since the invention of PCB.
  • manufacturers of various equipment have higher and higher requirements for circuit boards, not only pursuing higher performance and production efficiency, but also having stricter requirements on quality factors such as the yield rate of circuit boards.
  • AOI optical inspection
  • Embodiments of the present disclosure provide at least a defect detection method and apparatus, an electronic device, and a storage medium.
  • an embodiment of the present disclosure provides a defect detection method, including: acquiring a first feature map of a template image and a second feature map of an image to be detected; for each first feature map in the first feature map Feature points, from a plurality of first feature points in the first feature map, determine a plurality of associated feature points whose distances from the first feature point satisfy a preset condition; for each of the first features point, based on the determined similarity between each associated feature point of the first feature point and the target second feature point in the second feature map, perform feature enhancement processing on the first feature point; wherein, the The target second feature point is the second feature point whose position in the second feature map matches the first feature point; based on the second feature map and the first feature map after feature enhancement processing, determine The defect detection result corresponding to the image to be detected.
  • the difference between the image to be detected and the template image caused by the acquisition noise, matching error, and production error existing in the image to be detected is reduced, and the improvement is improved.
  • the defect detection accuracy of the image to be inspected is improved.
  • the similarity between each associated feature point and the target second feature point is determined in the following manner: based on each associated feature point in the first feature map and the preset distance threshold to obtain the first feature submap corresponding to each associated feature point; and based on the position of the target second feature point in the second feature map, and the distance threshold, to obtain the second feature submap corresponding to the second feature point of the target; based on the first feature submap and the second feature submap, determine that each associated feature point and the target second similarity between feature points.
  • the first feature corresponding to each associated feature point is obtained based on the position of each associated feature point in the first feature map and a preset distance threshold.
  • map including: on the first feature map, determining a first circular area with each associated feature point as the center and the distance threshold as the radius, based on the first feature map on the The first feature point in a circular area is to obtain the first feature sub-map; the position of the second feature point of the target in the second feature map and the distance threshold are used to obtain the
  • the second feature sub-map corresponding to the second feature point of the target includes: on the second feature map, determining a second circular area with the second feature point of the target as the center and the distance threshold as the radius, Based on the second feature points located in the second circular area on the second feature map, the second feature submap is obtained.
  • the first feature corresponding to each associated feature point is obtained based on the position of each associated feature point in the first feature map and a preset distance threshold.
  • the graph includes: determining a target side length based on the distance threshold; on the first feature graph, determining a first target side length with the determined target side length centered on each associated feature point as the side length on the first feature graph
  • the first feature sub-map is obtained based on the first feature point located in the first square area on the first feature map
  • the second feature point based on the target is located in the second feature map and the distance threshold, to obtain the second feature submap corresponding to the second feature point of the target, including: on the second feature map, determining the second feature point of the target as the center, with
  • the determined target side length is the second square area of the side length
  • the second feature sub-map is obtained based on the second feature points located in the second square area on the second feature map.
  • the similarity of the first feature point based on the relationship between each associated feature point of the first feature point and the target second feature point in the second feature map the similarity of the first feature point, and the feature enhancement process is performed on the first feature point, including: based on the similarity between each associated feature point of the first feature point and the target second feature point, and the first feature feature values corresponding to a plurality of the associated feature points of the point respectively, and feature enhancement processing is performed on the first feature point.
  • based on the similarity between each associated feature point of the first feature point and the target second feature point, and a plurality of the associated feature points of the first feature point respectively corresponding feature values, and performing feature enhancement processing on the first feature point including: based on the similarity between each associated feature point and the target second feature point, performing a feature enhancement process on the plurality of associated feature points respectively
  • the corresponding feature values are weighted and summed to obtain a first sum value; and, the similarity corresponding to a plurality of the associated feature points is summed to obtain a second sum value; the first sum value and the described
  • the ratio of the second sum value is used as the feature value of the first feature point after feature enhancement processing is performed on the first feature point.
  • determining the defect detection result corresponding to the to-be-detected image based on the second feature map and the first feature map after feature enhancement processing includes:
  • an attention mask image of the second feature map is generated; wherein, any pixel in the attention mask image
  • the pixel value represents the abnormality value of the defect in the second feature point whose position in the second feature map matches with the any pixel point;
  • a defect detection result corresponding to the image to be detected is determined.
  • determining the defect detection result corresponding to the to-be-detected image based on the attention mask image and the enhanced first feature map includes:
  • a defect detection result corresponding to the to-be-detected image is determined.
  • embodiments of the present disclosure further provide a defect detection apparatus, including: an acquisition part configured to acquire a first feature map of a template image and a second feature map of an image to be detected; a determination part configured to For each first feature point in the first feature map, from a plurality of first feature points in the first feature map, determine a plurality of first feature points whose distances from the first feature point satisfy a preset condition.
  • the feature enhancement processing part is configured to, for each of the first feature points, based on each associated feature point of the determined first feature point and the target second feature point in the second feature map The similarity between the first feature points is carried out feature enhancement processing; wherein, the target second feature point is the second feature point whose position matches the first feature point in the second feature map; the detection part , which is configured to determine a defect detection result corresponding to the image to be detected based on the second feature map and the first feature map after feature enhancement processing.
  • it further includes: a similarity determination part, configured to obtain each of the associated feature points based on the position of each associated feature point in the first feature map and a preset distance threshold. the first feature sub-map corresponding to the associated feature point; and based on the position of the target second feature point in the second feature map and the distance threshold, obtaining the second feature corresponding to the target second feature point subgraph; determining the similarity between each associated feature point and the target second feature point based on the first feature submap and the second feature submap.
  • a similarity determination part configured to obtain each of the associated feature points based on the position of each associated feature point in the first feature map and a preset distance threshold. the first feature sub-map corresponding to the associated feature point; and based on the position of the target second feature point in the second feature map and the distance threshold, obtaining the second feature corresponding to the target second feature point subgraph; determining the similarity between each associated feature point and the target second feature point based on the first feature submap and the second feature submap.
  • the similarity determination part is further configured to: on the first feature map, determine the first feature point with each associated feature point as the center of the circle and the distance threshold as the radius.
  • the first feature sub-map is obtained based on the first feature points located in the first circular area on the first feature map; on the second feature map, it is determined that the target The second feature point is a second circular area with the center of the circle and the distance threshold is the radius, and the second feature is obtained based on the second feature point located in the second circular area on the second feature map. picture.
  • the similarity determination part is further configured to: determine the target side length based on the distance threshold; on the first feature map, determine that each associated feature point is the center, the determined target side length is the first square area with the side length, and based on the first feature point located in the first square area on the first feature map, the first feature sub-map is obtained; On the second feature map, determine a second square area with the target second feature point as the center and the determined target side length as the side length, based on the second feature map located in the second square The second feature point in the area is obtained to obtain the second feature submap.
  • the feature enhancement processing part is further configured to: based on the similarity between each associated feature point of the first feature point and the target second feature point, and the The feature values corresponding to the plurality of associated feature points of the first feature point, respectively, are subjected to feature enhancement processing for the first feature point.
  • the feature enhancement processing part is further configured to: based on the similarity between each associated feature point and the target second feature The corresponding feature values are weighted and summed to obtain a first sum value; and, the similarity corresponding to a plurality of the associated feature points is summed to obtain a second sum value; the first sum value and all The ratio of the second sum value is used as the feature value of the first feature point after feature enhancement processing is performed on the first feature point.
  • the detection part is further configured to: generate the attention of the second feature map based on the second feature map and the enhanced first feature map mask image; wherein, the pixel value of any pixel in the attention mask image represents the abnormality value of the defect that the second feature point whose position matches with the any pixel in the second feature map; based on The attention mask image and the enhanced first feature map determine a defect detection result corresponding to the to-be-detected image.
  • the detection part is further configured to: combine the attention mask image and the enhanced first feature map to obtain a combined feature map;
  • the attention mask image and the merged feature map are subjected to feature fusion processing to obtain a feature fusion image; based on the feature fusion image, a defect detection result corresponding to the to-be-detected image is determined.
  • an embodiment of the present disclosure further provides an electronic device, including: a processor and a memory connected to each other, the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, The machine-readable instructions are executed by the processor to implement the first aspect, or the defect detection method in any possible implementation manner of the first aspect.
  • embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to execute the first aspect, or any one of the first aspect.
  • an embodiment of the present disclosure further provides a computer program, including computer-readable code, and when the computer-readable code is executed in an electronic device, the processor in the electronic device implements the above-mentioned first step when executed.
  • the processor in the electronic device implements the above-mentioned first step when executed.
  • FIG. 1 shows a system architecture diagram of a defect detection system provided by an embodiment of the present disclosure
  • FIG. 2 shows a flowchart of a defect detection method provided by an embodiment of the present disclosure
  • FIG. 3 shows a flowchart of a specific method for determining the similarity between each associated feature point and the target second feature point provided by an embodiment of the present disclosure
  • FIG. 4 shows a schematic diagram of a defect detection apparatus provided by an embodiment of the present disclosure
  • FIG. 5 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure.
  • the embodiments of the present disclosure provide a defect detection method and device, electronic equipment, and storage medium, by performing feature enhancement on the first feature map of the template image, so as to reduce the acquisition noise and matching noise due to the image to be detected.
  • the devices include, for example, terminal devices or servers or other processing devices.
  • the terminal devices may be dedicated to PCB quality inspection, or may be other terminal devices, such as computers and mobile devices.
  • the defect detection method may be implemented by the processor calling computer-readable instructions stored in the memory.
  • defect detection method provided by the embodiments of the present disclosure can be used for defect detection of other items, such as workpieces, machine parts, and the like, in addition to defect detection of PCBs.
  • FIG. 1 is a system architecture diagram of a defect detection system provided by an embodiment of the present disclosure; as shown in FIG. 1 , the defect detection system 100 includes a server 10 and a terminal device 20 , and the server 10 and the terminal device 20 are connected through a network.
  • the terminal device 20 is used to obtain the first feature map of the template image and the second feature map of the image to be detected; for each first feature point in the first feature map, from a plurality of first features in the first feature map Among the points, determine a plurality of associated feature points whose distance from the first feature point satisfies a preset condition; for each first feature point, based on each associated feature point of the determined first feature point and the second The similarity between the target second feature points in the feature map, and feature enhancement processing is performed on the first feature point; wherein, the target second feature point is the position in the second feature map that matches the first feature point.
  • the second feature point; the defect detection result corresponding to the image to be detected is determined based on the second feature map and the first feature map after feature enhancement processing.
  • the server 10 is configured to store the template image and the first feature map of the template image, or send the required template image and the first feature map of the template image to the terminal device 20 according to an acquisition request of the terminal device 20 .
  • the terminal device 20 may send both the template image and the first feature map of the template image to the server 10 for backup storage, so that other terminal devices can
  • the template image and the first feature map of the template image can be directly obtained from the server 10 to perform defect detection, so as to improve the detection efficiency when other terminal devices perform defect detection.
  • the terminal device 20 can directly obtain the required template image from the server 10 and the first feature point of the template image, so as to improve the detection efficiency when the terminal device 20 performs defect detection.
  • defect detection method provided by the embodiment of the present disclosure will be described in detail below by taking defect detection on a PCB as an example.
  • Fig. 2 is a flowchart of a defect detection method provided by an embodiment of the present disclosure, the method includes steps S101 to S104, wherein:
  • S101 Obtain a first feature map of a template image and a second feature map of an image to be detected;
  • S102 For each first feature point in the first feature map, from a plurality of first feature points in the first feature map, determine that the distance from the first feature point satisfies a preset condition Multiple associated feature points of ;
  • S103 For each of the first feature points, based on the determined similarity between each associated feature point of the first feature point and the target second feature point in the second feature The feature point is subjected to feature enhancement processing; wherein, the target second feature point is the second feature point whose position matches the first feature point in the second feature map;
  • S104 Determine a defect detection result corresponding to the image to be detected based on the second feature map and the first feature map after feature enhancement processing.
  • the template image refers to an image captured on a qualified PCB used in the case of performing defect detection on the PCB.
  • the image to be inspected refers to the image obtained from the PCB to be inspected.
  • a feature extraction neural network can be used to extract features from the template image and the image to be detected, respectively, to obtain the first feature map of the template image and the image to be detected.
  • the second feature map of the image can be used to extract features from the template image and the image to be detected, respectively, to obtain the first feature map of the template image and the image to be detected.
  • the first feature map when performing defect detection processing on the same PCB image to be inspected, since the template images used are all the same, the first feature map can be extracted only once for the template image, and the Its first feature map is stored; in the process of performing defect detection processing on each of the multiple images to be detected, in the case that the first feature map of the template image already exists, it is only necessary to store the first feature map.
  • the first feature map can be read from the storage location of the map; and a feature extraction network is used to perform feature extraction processing on the image to be processed to obtain the second feature map of each image to be processed.
  • the associated feature point whose distance from the first feature point satisfies the preset condition is, for example, in the first feature map, the distance from the first feature point is less than the preset distance.
  • the first feature point of a certain distance threshold L is, for example, in the first feature map, the distance from the first feature point is less than the preset distance.
  • the distance L is, for example, any one of the L1 distance, the L2 distance, the Euclidean distance, or the Manhattan distance.
  • all the first feature points that meet the preset conditions in the first feature map may be determined as the associated feature points; All the first feature points that satisfy the preset conditions are taken as candidate feature points, and then a plurality of associated feature points are determined from the plurality of candidate feature points in the manner of random sampling or uniform interval sampling.
  • the target second feature point of the first feature point is the second feature point whose position matches the first feature point in the second feature map.
  • the first feature map is represented as:
  • the second feature map is represented as:
  • the target second feature point matching the position thereof is: b ij .
  • the similarity between each associated feature point of the first feature point and the target second feature point is to be determined.
  • an embodiment of the present disclosure further provides a specific method for determining the similarity between each associated feature point and the target second feature point, including:
  • S203 Determine the similarity between each associated feature point and the target second feature point based on the first feature submap and the second feature submap.
  • the preset distance threshold is a first circular area with a radius
  • the first feature sub-map is obtained based on a first feature point located in the first circular area on the first feature map.
  • the first feature points in the first feature submap may include all the first feature points located in the first circular area, or may only include part of the first feature points located in the first circular area.
  • the second feature submap corresponding to the second feature point of the target for example, on the second feature map, it can be determined that the second feature point of the target is the center of the circle, and the preset distance threshold is For the second circular area of the radius, the second feature sub-map is obtained based on the second feature points located in the second circular area on the second feature map.
  • the second feature points in the second feature submap may include all the second feature points located in the second circular area, or may only include a part of the second feature points located in the second circular area.
  • the second feature point in the second feature submap also only includes the first feature point in the first circular area. Part of the second feature points in the circular area; and the positions of the first feature points in the first feature sub-map and the second feature points in the second sub-map match one by one.
  • the target side length may also be determined based on the distance threshold; on the first feature map , determine a first square area with each associated feature point as the center and the determined target side length as the side length, based on the first feature point located in the first square area on the first feature map , to obtain the first feature submap.
  • the target side length for example, satisfies: 2R+1; wherein, R represents the above-mentioned distance threshold.
  • the first feature point included in the first feature submap includes, for example, all the first feature points located in the first square area, or only the first feature points located in the first square area. Part of the first feature points in the square area.
  • the second feature sub-map corresponding to the second feature point of the target for example, on the second feature map
  • the target side length is a second square area with a side length
  • the second feature sub-map is obtained based on the second feature points located in the second square area on the second feature map.
  • the second feature points included in the second feature submap include, for example, all the second feature points located in the second square area, or only include the second feature points located in the second square area. Part of the second feature points in the second square area.
  • the similarity between the associated feature point and the target second feature point is determined based on the first feature submap.
  • the normalized correlation coefficient NCC n of the similarity between the n-th associated feature point and the target second feature point satisfies the following: Formula 1):
  • patch A represents the first feature submap
  • Patch B represents the second feature submap
  • patch A *Patch B represents the matrix multiplication of the first feature submap and the second feature submap
  • sum( ) represents the matrix Sum the element values of all elements.
  • the normalized correlation coefficient range is [-1, 1]. The higher the value of this coefficient, the more similar the correlation feature point and the target second feature point are.
  • S103 for example, it can be based on the similarity between each associated feature point of the first feature point and the target second feature point, and a plurality of the associated feature points of the first feature point, respectively. For the corresponding feature value, feature enhancement processing is performed on the first feature point.
  • weighted summation is performed on the feature values corresponding to the plurality of associated feature points respectively, to obtain a first sum value; and, for a plurality of associated feature points
  • the similarity corresponding to the feature points is summed to obtain a second sum value; the ratio of the first sum value and the second sum value is taken as the first feature point after feature enhancement processing is performed.
  • the eigenvalue of a feature point is a feature point.
  • the feature value ft(A) 2 of the any first feature point after feature enhancement processing satisfies the following formula (2):
  • ft(A)' n represents the eigenvalue corresponding to the nth associated feature point.
  • the pixel values of the pixels are relatively close; in the process of feature enhancement for any feature point, the associated features of any feature point
  • the similarity between the point and the target second feature point in the second feature map is high, it is more likely that the associated feature point and the target second feature point represent the same object; In this case, the possibility that the associated feature point and the target second feature point represent the same object is low; therefore, using the similarity between the associated feature point and the target second feature point to perform feature enhancement processing on the first feature point can Reduce the difference between the first feature point and the second feature point of the target caused by the acquisition noise, matching error, and production error of the image to be detected, and reduce the matching of the image to be detected and the template image caused by the above errors. An error situation that occurs when you are missed on time.
  • the defect detection result corresponding to the image to be detected is determined based on the second feature map and the first feature map after feature enhancement processing, for example, the A feature map is divided into a plurality of small first sub-graphs, and the second feature map is divided into a plurality of small second sub-graphs;
  • each first subgraph from a plurality of second subgraphs, determine the target second subgraph corresponding to the position of the first subgraph, and calculate the difference between the first subgraph and the corresponding target second subgraph Similarity; when the similarity between the two is greater than the preset similarity threshold, it means that in the image to be detected, there is no defect in the area corresponding to the second sub-image of the target; between the two In the case that the similarity of the target second sub-image is less than or equal to the preset similarity threshold, it means that there is a defect in the area corresponding to the target second sub-image in the image to be detected.
  • other methods may also be used to perform defect detection on the image to be detected, for example, using a pre-trained defect detection neural network, and using the enhanced first feature map and the second feature map as the defect detection
  • the input of the neural network obtains the defect detection result of the image to be detected.
  • an embodiment of the present disclosure provides a specific example of determining the defect detection result corresponding to the image to be detected based on the second feature map and the first feature map after feature enhancement processing, including:
  • an attention mask image of the second feature map is generated; wherein, any pixel in the attention mask image
  • the pixel value of the second feature map represents the abnormality value of the defect in the second feature point whose position matches the any pixel point in the second feature map; based on the attention mask image and the enhanced A feature map to determine the defect detection result corresponding to the image to be detected.
  • an attention mask image corresponding to the second feature map can be obtained in the following manner: for each second feature point in the second feature map, from a plurality of first feature points in the first feature map , determine a plurality of associated feature points corresponding to the second feature point; wherein, for each associated feature point corresponding to the second feature point, the distance between the target first feature points that match the position of the second feature point satisfies Preset conditions; based on the similarity between the second feature point and each associated feature point, determine the abnormality value of the second feature point; based on the abnormality value of each second feature point in the second feature map, obtain The attention mask image corresponding to the second feature map.
  • the specific method of determining the associated feature point corresponding to the second feature point and the method of determining the similarity between the second feature point and the associated feature point are similar to the methods of determining the associated feature point in S102 and S103 above.
  • the similarity between the second feature point and each associated feature point is determined, for example, the maximum similarity between the multiple associated feature points and the second feature point can be determined; based on the maximum similarity, determine The abnormality value of the second feature point.
  • the abnormality value S of any second feature point for example, satisfies the following formula (3):
  • H represents the maximum similarity.
  • is a preset coefficient, such as 1, 0.5, etc. Specifically, it can be set according to actual needs.
  • the average similarity may be determined according to the similarity between the plurality of associated feature points and the second feature point, and the abnormality value of the second feature point may be determined based on the average similarity.
  • the attention mask image is obtained based on the abnormality value corresponding to each second feature point in the second feature map; this When , for example, an image composed of abnormality values corresponding to all the second feature points can be used as an attention mask image.
  • the defect detection result corresponding to the to-be-detected image can be determined based on the attention mask image and the enhanced first feature map in the following manner:
  • the feature-enhanced image and the second feature map may be superimposed to obtain a combined feature map.
  • the feature fusion image can be input into a pre-trained detection network, and defect detection processing is performed on the feature fusion image to obtain a defect detection result corresponding to the image to be detected.
  • the detection network provided by the embodiment of the present disclosure adopts a fully convolutional one-stage object detection (Fully Convolutional One-Stage Object Detection, FCOS) network.
  • FCOS Fully Convolutional One-Stage Object Detection
  • the FCOS network can detect the defect category, the defect centrality, and the position of the defect frame in the first feature map.
  • the defect centrality is used to represent the probability that a certain feature point in the first feature map is the center of the defect frame.
  • the position of the defect frame in the first feature map indicates the position where the defect exists in the first feature map.
  • the first feature map of the template image and the second feature map of the image to be detected by acquiring the first feature map of the template image and the second feature map of the image to be detected, and for each first feature point in the first feature map, determine the relationship with the first feature from the first feature map A plurality of associated feature points whose distances between points meet preset conditions; for each first feature point, the determined associated feature point of the first feature point matches the position of the first feature point in the second feature map
  • the similarity between the second feature points of the target perform feature enhancement processing on the first feature point;
  • the feature map and the second feature map are used to determine the defect detection result corresponding to the image to be detected.
  • feature enhancement processing is performed on each first feature point in each first feature map, so as to reduce the image to be detected and the template image caused by acquisition noise, matching error, and production error existing in the image to be detected The difference between them can improve the defect detection accuracy of the image to be inspected.
  • the defect detection method provided by the embodiments of the present disclosure can be applied to technical fields such as industrial image correlation or artificial intelligence (artificial intelligence, AI) education, for example, can be specifically applied to industrial image processing and embedded image detection.
  • industrial image correlation or artificial intelligence (artificial intelligence, AI) education for example, can be specifically applied to industrial image processing and embedded image detection.
  • AI artificial intelligence
  • the writing order of each step does not mean a strict execution order but constitutes any limitation on the implementation process, and the specific execution order of each step should be based on its function and possible Internal logic is determined.
  • the embodiments of the present disclosure also provide a defect detection device corresponding to the defect detection method. implementation of the method.
  • the apparatus includes: an acquisition part 31 , a determination part 32 , a feature enhancement processing part 33 , and a detection part 34 ; wherein,
  • the acquisition part 31 is configured to acquire the first feature map of the template image and the second feature map of the image to be detected;
  • the determining part 32 is configured to, for each first feature point in the first feature map, determine the distance between the first feature point and the first feature point from the plurality of first feature points in the first feature map Multiple associated feature points whose distances meet preset conditions;
  • the feature enhancement processing section 33 is configured to, for each of the first feature points, determine the correlation between each associated feature point of the first feature point and the target second feature point in the second feature map. similarity, and perform feature enhancement processing on the first feature point; wherein, the target second feature point is the second feature point whose position matches the first feature point in the second feature map;
  • the detection part 34 is configured to determine a defect detection result corresponding to the image to be detected based on the first feature map and the second feature map after feature enhancement processing.
  • a similarity determination part 35 configured to obtain the each associated feature point based on the position of each associated feature point in the first feature map and a preset distance threshold. a first feature sub-map corresponding to each associated feature point; and based on the position of the target second feature point in the second feature map and the distance threshold, obtain a second feature point corresponding to the target second feature point feature sub-map; determining the similarity between each associated feature point and the target second feature point based on the first feature sub-map and the second feature sub-map.
  • the similarity determination part 35 is further configured to: on the first feature map, determine a circle whose center is each associated feature point and the distance threshold is a radius. In the first circular area, based on the first feature point located in the first circular area on the first feature map, the first feature sub-map is obtained; on the second feature map, it is determined that the The second feature point of the target is a second circular area with the center of the circle and the distance threshold as the radius, and the second feature is obtained based on the second feature point located in the second circular area on the second feature map subgraph.
  • the similarity determination part 35 is further configured to: determine the target side length based on the distance threshold; is a first square area with the target side length as the center and the determined target side length is the side length, and based on the first feature point located in the first square area on the first feature map, the first feature sub-map is obtained; On the second feature map, determine a second square area with the target second feature point as the center and the determined target side length as the side length, based on the second feature map located in the second square area The second feature point in the square area is obtained to obtain the second feature submap.
  • the feature enhancement processing part 33 is further configured to: based on the similarity between each associated feature point of the first feature point and the target second feature point, and Feature enhancement processing is performed on the first feature point for the feature values corresponding to the plurality of associated feature points of the first feature point respectively.
  • the feature enhancement processing part 33 is further configured to: based on the similarity between each associated feature point and the target second feature point The feature values corresponding to the points are respectively weighted and summed to obtain a first sum value; and, the similarity corresponding to a plurality of the associated feature points is summed to obtain a second sum value; the first sum value is summed The ratio of the second sum value is used as the feature value of the first feature point after feature enhancement processing is performed on the first feature point.
  • the detection part 34 is further configured to: generate the attention of the second feature map based on the second feature map and the enhanced first feature map Force mask image; wherein, the pixel value of any pixel in the attention mask image represents the abnormality value of the defect that the second feature point in the second feature map whose position matches with this any pixel point; Based on the attention mask image and the enhanced first feature map, a defect detection result corresponding to the image to be detected is determined.
  • the detection part 34 is further configured to: combine the attention mask image and the enhanced first feature map to obtain a combined feature map; A feature fusion process is performed on the attention mask image and the merged feature map to obtain a feature fusion image; based on the feature fusion image, a defect detection result corresponding to the to-be-detected image is determined.
  • a "part" may be a part of a circuit, a part of a processor, a part of a program or software, etc., of course, a unit, a module or a non-modularity.
  • An embodiment of the present disclosure further provides an electronic device 30 (that is, the above-mentioned terminal device 20 ).
  • an electronic device 30 that is, the above-mentioned terminal device 20 .
  • a schematic structural diagram of the electronic device 30 provided by the embodiment of the present disclosure includes:
  • first feature point in the first feature map For each first feature point in the first feature map, from a plurality of first feature points in the first feature map, determine a number of first feature points whose distances from the first feature point satisfy a preset condition. associated feature points;
  • the target second feature point is the second feature point whose position matches the first feature point in the second feature map
  • a defect detection result corresponding to the image to be detected is determined.
  • Embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the steps of the defect detection method described in the above method embodiments are executed.
  • the storage medium may be a volatile or non-volatile computer-readable storage medium.
  • the computer program product of the defect detection method provided by the embodiments of the present disclosure includes a computer-readable storage medium storing program codes, and the instructions included in the program codes can be used to execute the steps of the defect detection methods described in the above method embodiments. , for details, refer to the above method embodiments.
  • Embodiments of the present disclosure further provide a computer program, which implements any one of the methods in the foregoing embodiments when the computer program is executed by a processor.
  • the computer program product can be specifically implemented by hardware, software or a combination thereof.
  • the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), etc. Wait.
  • the units described as separate components may or may not be physically separated, and components shown as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the functions, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a processor-executable non-volatile computer-readable storage medium.
  • the technical solutions of the present disclosure can be embodied in the form of software products in essence, or the parts that contribute to the prior art or the parts of the technical solutions.
  • the computer software products are stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure.
  • a computer-readable storage medium can also be a tangible device that holds and stores instructions for use by the instruction execution device, and can be a volatile storage medium or a non-volatile storage medium.
  • the computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
  • a more specific list (non-exhaustive list) of computer-readable storage media includes: USB sticks, magnetic disks, optical disks, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable Programmable Read Only Memory (EPROM or Flash), Static Random Access Memory Reader (ROM), Portable Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD), Memory Stick, Floppy Disk, Memory Encoding Device, Such as punch cards or recessed structures with instructions stored thereon, and any suitable combination of the above.
  • Computer-readable storage media are not to be interpreted as transient signals per se, such as radio waves or other freely propagating battery waves, battery waves propagating through waveguides or other media media (eg, light pulses through fiber optic cables), or Electrical signals transmitted through wires.
  • Embodiments of the present disclosure provide a defect detection method and device, an electronic device, and a storage medium, wherein the method includes: acquiring a first feature map of a template image and a second feature map of an image to be detected; for the first feature map For each first feature point in the first feature map, from a plurality of first feature points in the first feature map, determine a plurality of associated feature points whose distance from the first feature point satisfies the preset condition; for each first feature point a feature point, based on the determined similarity between each associated feature point of the first feature point and the target second feature point in the second feature map, perform feature enhancement processing on the first feature point; wherein the target The second feature point is a second feature point whose position in the second feature map matches the first feature point; based on the second feature map and the first feature map after feature enhancement processing, determine the to-be-detected feature The defect detection result corresponding to the image. This process can improve the defect detection accuracy of the image to be inspected.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Multimedia (AREA)
  • Image Analysis (AREA)
  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)

Abstract

一种缺陷检测方法及装置、电子设备和存储介质,其中,该方法包括:获取模板图像的第一特征图、以及待检测图像的第二特征图(S101);针对所述第一特征图中的每个第一特征点,从所述第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点(S102);针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,所述目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点(S103);基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果(S104)。

Description

缺陷检测方法及装置、电子设备和存储介质
相关申请的交叉引用
本公开基于申请号为202011191756.0、申请日为2020年10月30日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本公开作为参考。
技术领域
本公开涉及图像处理技术领域,具体而言,涉及一种缺陷检测方法及装置、电子设备和存储介质。
背景技术
随着科技的发展,现代制造业对于印刷电路板(Printed circuit board,PCB)的需求也日益增长。电子设备性能的优劣不但受电子元器件本身质量和性能的影响,而且在很大程度上取决于PCB质量的好坏。PCB缺陷检测技术是关系到电子系统质量和生产周期的重要环节,自从PCB发明以来就备受重视。当前各种设备的生产厂商对于电路板的要求越来越高,不只是追求更高性能和生产效率,对电路板的良品率等质量因素还有更加严格的要求。
当前通常利用自动光学检测(Automated Optical Inspection,AOI)设备来进行PCB缺陷检测;AOI设备在自动检测时,通过摄像头对PCB进行自动扫描得到PCB图像,然后将PCB图像中的焊点与数据库中合格PCB的模板图像进行比较,以检查出PCB上存在的缺陷。
发明内容
本公开实施例至少提供一种缺陷检测方法及装置、电子设备和存储介质。
第一方面,本公开实施例提供了一种缺陷检测方法,包括:获取模板图像的第一特征图、以及待检测图像的第二特征图;针对所述第一特征图中的每个第一特征点,从所述第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,所述目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点;基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
这样,通过对模板图像的第一特征图进行特征增强,以减小由于待检测图像存在的采集噪声、匹配误差、以及生产误差,所带来的待检测图像和模板图像之间的差异,提升对待检测图像的缺陷检测精度。
一种可能的实施方式中,采用下述方式确定所述每个关联特征点与所述 目标第二特征点之间的相似度:基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图;以及基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图;基于所述第一特征子图、以及所述第二特征子图,确定所述每个关联特征点与所述目标第二特征点之间的相似度。
一种可能的实施方式中,所述基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图,包括:在所述第一特征图上,确定以所述每个关联特征点为圆心、以所述距离阈值为半径的第一圆形区域,基于所述第一特征图上位于该第一圆形区域内的第一特征点,得到所述第一特征子图;所述基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图,包括:在所述第二特征图上,确定以所述目标第二特征点为圆心、以所述距离阈值为半径的第二圆形区域,基于所述第二特征图上位于该第二圆形区域内的第二特征点,得到所述第二特征子图。
一种可能的实施方式中,所述基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图,包括:基于所述距离阈值,确定目标边长;在所述第一特征图上,确定以所述每个关联特征点为中心、以确定的所述目标边长为边长的第一正方形区域,基于所述第一特征图上位于该第一正方形区域内的第一特征点,得到所述第一特征子图;所述基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图,包括:在所述第二特征图上,确定以所述目标第二特征点为中心、以确定的所述目标边长为边长的第二正方形区域,基于所述第二特征图上位于该第二正方形区域内的第二特征点,得到所述第二特征子图。
一种可能的实施方式中,所述针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理,包括:基于该第一特征点的所述每个关联特征点与所述目标第二特征点之间的相似度,以及该第一特征点的多个所述关联特征点分别对应的特征值,对该第一特征点进行特征增强处理。
一种可能的实施方式中,基于该第一特征点的所述每个关联特征点与所述目标第二特征点之间的相似度,以及该第一特征点的多个所述关联特征点分别对应的特征值,对该第一特征点进行特征增强处理,包括:基于所述每个关联特征点与所述目标第二特征点之间的相似度,对多个所述关联特征点分别对应的特征值进行加权求和,得到第一和值;以及,对多个所述关联特征点分别对应的相似度进行求和,得到第二和值;将所述第一和值和所述第二和值的比值,作为对该第一特征点进行特征增强处理后的所述第一特征点的特征值。
一种可能的实施方式中,所述基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果,包括:
基于所述第二特征图、以及所述增强处理后的所述第一特征图,生成所述第二特征图的注意力掩码图像;其中,所述注意力掩码图像中任一像素点的像素值,表征该第二特征图中位置与该任一像素点匹配的第二特征点存在缺陷的异常度值;
基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
一种可能的实施方式中,所述基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果,包括:
对所述注意力掩码图像、以及所述增强处理后的所述第一特征图进行合并处理,得到合并特征图;
对所述注意力掩码图像、以及所述合并特征图进行特征融合处理,得到特征融合图像;
基于所述特征融合图像,确定所述待检测图像对应的缺陷检测结果。
第二方面,本公开实施例还提供一种缺陷检测装置,包括:获取部分,被配置为获取模板图像的第一特征图、以及待检测图像的第二特征图;确定部分,被配置为针对所述第一特征图中的每个第一特征点,从所述第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;特征增强处理部分,被配置为针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,所述目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点;检测部分,被配置为基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
一种可能的实施方式中,还包括:相似度确定部分,被配置为基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图;以及基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图;基于所述第一特征子图、以及所述第二特征子图,确定所述每个关联特征点与所述目标第二特征点之间的相似度。
一种可能的实施方式中,所述相似度确定部分,还被配置为:在所述第一特征图上,确定以所述每个关联特征点为圆心、以所述距离阈值为半径的第一圆形区域,基于所述第一特征图上位于该第一圆形区域内的第一特征点,得到所述第一特征子图;在所述第二特征图上,确定以所述目标第二特征点为圆心、以所述距离阈值为半径的第二圆形区域,基于所述第二特征图上位于该第二圆形区域内的第二特征点,得到所述第二特征子图。
一种可能的实施方式中,所述相似度确定部分,还被配置为:基于所述距离阈值,确定目标边长;在所述第一特征图上,确定以所述每个关联特征 点为中心、以确定的所述目标边长为边长的第一正方形区域,基于所述第一特征图上位于该第一正方形区域内的第一特征点,得到所述第一特征子图;在所述第二特征图上,确定以所述目标第二特征点为中心、以确定的所述目标边长为边长的第二正方形区域,基于所述第二特征图上位于该第二正方形区域内的第二特征点,得到所述第二特征子图。
一种可能的实施方式中,所述特征增强处理部分,还被配置为:基于该第一特征点的所述每个关联特征点与所述目标第二特征点之间的相似度,以及该第一特征点的多个所述关联特征点分别对应的特征值,对该第一特征点进行特征增强处理。
一种可能的实施方式中,所述特征增强处理部分,还被配置为:基于所述每个关联特征点与所述目标第二特征点之间的相似度,对多个所述关联特征点分别对应的特征值进行加权求和,得到第一和值;以及,对多个所述关联特征点分别对应的相似度进行求和,得到第二和值;将所述第一和值和所述第二和值的比值,作为对该第一特征点进行特征增强处理后的所述第一特征点的特征值。
一种可能的实施方式中,所述检测部分,还被配置为:基于所述第二特征图、以及所述增强处理后的所述第一特征图,生成所述第二特征图的注意力掩码图像;其中,所述注意力掩码图像中任一像素点的像素值,表征该第二特征图中位置与该任一像素点匹配的第二特征点存在缺陷的异常度值;基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
一种可能的实施方式中,所述检测部分,还被配置为:对所述注意力掩码图像、以及所述增强处理后的所述第一特征图进行合并处理,得到合并特征图;对所述注意力掩码图像、以及所述合并特征图进行特征融合处理,得到特征融合图像;基于所述特征融合图像,确定所述待检测图像对应的缺陷检测结果。
第三方面,本公开实施例还提供一种电子设备,包括:相互连接的处理器和存储器,所述存储器存储有所述处理器可执行的机器可读指令,在电子设备运行的情况下,所述机器可读指令被所述处理器执行以实现上述第一方面,或第一方面中任一种可能的实施方式中的缺陷检测方法。
第四方面,本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述第一方面,或第一方面中任一种可能的实施方式中的缺陷检测方法。
第五方面,本公开实施例还提供一种计算机程序,包括计算机可读代码,在所述计算机可读代码在电子设备中运行的情况下,所述电子设备中的处理器执行时实现上述第一方面,或第一方面中任一种可能的实施方式中的缺陷检测方法。
为使本公开的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。
附图说明
为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,此处的附图被并入说明书中并构成本说明书中的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。
图1示出了本公开实施例所提供的缺陷检测系统的一个系统架构图;
图2示出了本公开实施例所提供的一种缺陷检测方法的流程图;
图3示出了本公开实施例所提供的确定每个关联特征点与目标第二特征点之间相似度的具体方法的流程图;
图4示出了本公开实施例所提供的一种缺陷检测装置的示意图;
图5示出了本公开实施例所提供的一种电子设备的示意图。
具体实施方式
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。
经研究发现,在使用AOI设备对PCB进行缺陷检测的情况下,首先需要专业的工程师根据PCB上焊点的位置,针对PCB进行编程;在编程后,通过AOI设备上的摄像头自动扫描PCB得到PCB图像,然后将PCB图像中的焊点与数据库中合格图像的金属焊点进行比较;在PCB图像中任一金属焊点与合格图像中对应金属焊点的形状不一致的情况下,则确定该焊点可能存在缺陷,然后将该焊点位置标注出来,并通过AOI设备上的显示设备展示给工程师,以使工程师能够基于缺陷检测结果来进行后续处理。
但是实际上,PCB在生产过程中,常常造成PCB上存在生产误差;另外在将PCB的待检测图像和模板图像进行比对的情况下,也会存在图像之间的匹配误差;此外,待检测图像在采集过程也可能存在采集噪声;这些误差导致了当前对PCB的缺陷检测结果存在大量误检区域,造成缺陷检测精度的下降。
基于上述研究,本公开实施例提供了一种缺陷检测方法及装置、电子设备和存储介质,通过对模板图像的第一特征图进行特征增强,以减小由于待检测图像存在的采集噪声、匹配误差、以及生产误差,所带来的待检测图像和模板图像之间的差异,提升对待检测图像的缺陷检测精度。
针对以上方案所存在的缺陷,均是发明人在经过实践并仔细研究后得出 的结果,因此,上述问题的发现过程以及下文中本公开实施例针对上述问题所提出的解决方案,都应该是发明人在本公开实施例过程中对本公开做出的贡献。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。
为便于对本实施例进行理解,首先对本公开实施例所公开的一种缺陷检测方法进行详细介绍,本公开实施例所提供的缺陷检测方法的执行主体一般为具有一定计算能力的计算机设备,该计算机设备例如包括:终端设备或服务器或其它处理设备,终端设备可以为专用于进行PCB质量检测的设备,也可以为其他终端设备,例如电脑、移动设备等。在一些可能的实现方式中,该缺陷检测方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。
另外,本公开实施例提供的缺陷检测方法除了能够用于对PCB进行缺陷检测外,还可以对其他物品进行缺陷检测,例如工件、机器部件等。
图1为本公开实施例所提供的缺陷检测系统的一个系统架构图;如图1所示,缺陷检测系统100包括服务器10和终端设备20,且服务器10和终端设备20通过网络连接。终端设备20用于获取模板图像的第一特征图、以及待检测图像的第二特征图;针对第一特征图中的每个第一特征点,从第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;针对每个第一特征点,基于确定的该第一特征点的每个关联特征点与第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点;基于第二特征图、以及特征增强处理后的第一特征图,确定待检测图像对应的缺陷检测结果。服务器10用于存储模板图像和模板图像的第一特征图,或者,根据终端设备20的获取请求,向终端设备20发送所需的模板图像和模板图像的第一特征图。
在一些实施例中,终端设备20可以在获取到模板图像和模板图像的第一特征图后,将模板图像和模板图像的第一特征图均发送至服务器10进行备份存储,以使其他终端设备可以从服务器10处直接获取该模板图像和该模板图像的第一特征图,进行缺陷检测,以提高其他终端设备进行缺陷检测时的检测效率。
在另一些实施例中,在服务器10中已存储有终端设备20所需的模板图像和模板图像的第一特征图的情况下,终端设备20则可以直接从服务器10处获取所需的模板图像和该模板图像的第一特征点,以提高终端设备20进行缺陷检测时的检测效率。
下面以对PCB进行缺陷检测为例对本公开实施例提供的缺陷检测方法加以详细说明。
参见图2所示,为本公开实施例提供的缺陷检测方法的流程图,所述方 法包括步骤S101~S104,其中:
S101:获取模板图像的第一特征图、以及待检测图像的第二特征图;
S102:针对所述第一特征图中的每个第一特征点,从所述第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;
S103:针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,所述目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点;
S104:基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
下面分别对上述S101~S104加以详细说明。
在上述S101中,模板图像,是指在对PCB进行缺陷检测的情况下所用的对合格的PCB拍摄的图像。待检测图像,是指对待检测的PCB获取的图像。
在获取模板图像的第一特征图和待检测图像的第二特征图时,例如可以采用特征提取神经网络分别对模板图像和待检测图像进行特征提取,得到模板图像的第一特征图和待检测图像的第二特征图。
在一种可能的实施方式中,在对相同的PCB的待检测图像进行缺陷检测处理时,由于所采用的模板图像都是同一张,因此可以只针对模板图像提取一次第一特征图,并将其第一特征图存储起来;在对多张待检测图像中的每张待检测图像进行缺陷检测处理过程中,在已经存在模板图像的第一特征图的情况下,只需要从存储第一特征图的存储位置中读取第一特征图即可;并利用特征提取网络对待处理图像进行特征提取处理,得到每张待处理图像的第二特征图。
在上述S102中,在具体实施中,与第一特征点之间的距离满足预设条件的关联特征点,例如是在第一特征图中,与第一特征点之间的距离小于预设的某一距离阈值L的第一特征点。
示例性的,该距离L例如L1距离、L2距离、欧式距离、或者曼哈顿距离中任一种。
在为每个第一特征点确定多个关联特征点的情况下,可以将第一特征图中所有满足预设条件的第一特征点均确定为该关联特征点;也可以将第一特征图中所有满足预设条件的第一特征点作为备选特征点,然后按照随机采样、或者均匀间隔采样的方式,从多个备选特征点中确定多个关联特征点。
在上述S103中,针对每个第一特征点,该第一特征点的目标第二特征点,为在第二特征图中位置与该第一特征点匹配的第二特征点。
示例性的,若第一特征图和第二特征图的尺寸为m×n,第一特征图表示 为:
Figure PCTCN2021096064-appb-000001
第二特征图表示为:
Figure PCTCN2021096064-appb-000002
对于第一特征图中的任一第一特征点a ij,与之位置匹配的目标第二特征点为:b ij
在确定了与第一特征点位置匹配的目标第二特征点后,要确定该第一特征点的各个关联特征点与该目标第二特征点之间的相似度。
参见图3所示,本公开实施例还提供一种确定每个关联特征点与目标第二特征点之间的相似度的具体方法,包括:
S201:基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图;
S202:基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图;
S203:基于所述第一特征子图、以及所述第二特征子图,确定所述每个关联特征点与所述目标第二特征点之间的相似度。
此处,上述S201和S202之间无先后逻辑关系。
在一种可能的实施方式中,在确定任一关联特征点对应的第一特征子图的情况下,例如可以在所述第一特征图上,确定以该任一关联特征点为圆心、以该预设的距离阈值为半径的第一圆形区域,并基于所述第一特征图上位于该第一圆形区域内的第一特征点,得到所述第一特征子图。
此处,第一特征子图中的第一特征点,可以包括位于第一圆形区域内的所有第一特征点,也可以仅仅包括位于第一圆形区域内的部分第一特征点。
类似的,在确定目标第二特征点对应的第二特征子图的情况下,例如可以在第二特征图上,确定以所述目标第二特征点为圆心、以该预设的距离阈值为半径的第二圆形区域,基于所述第二特征图上位于该第二圆形区域内的第二特征点,得到所述第二特征子图。
相同的,第二特征子图中的第二特征点,可以包括位于第二圆形区域内的所有第二特征点,也可以仅仅包括位于第二圆形区域内的部分第二特征点。
示例性的,在第一特征子图中的第一特征点仅仅包括位于第一圆形区域内的部分第一特征点的情况下,第二特征子图中的第二特征点也仅仅包括第二圆形区域内的部分第二特征点;且第一特征子图中的第一特征点和第二子图中的第二特征点位置一一匹配。
在另一种可能的实施方式中,在确定任一关联特征点对应的第一特征子图的情况下,例如还可以基于所述距离阈值,确定目标边长;在所述第一特征图上,确定以所述每个关联特征点为中心、以确定的所述目标边长为边长的第一正方形区域,基于所述第一特征图上位于该第一正方形区域内的第一特征点,得到所述第一特征子图。
此处,目标边长例如满足:2R+1;其中,R表示上述距离阈值。
在确定关联特征点对应的第一特征子图的情况下,第一特征子图包括的第一特征点,例如包括位于第一正方形区域内的所有第一特征点,也可以仅仅包括位于第一正方形区域内的部分第一特征点。
类似的,在确定目标第二特征点对应的第二特征子图的情况下,例如可以在所述第二特征图上,确定以所述每个目标第二特征点为中心、以确定的所述目标边长为边长的第二正方形区域,基于所述第二特征图上位于该第二正方形区域内的第二特征点,得到所述第二特征子图。
在确定目标第二特征点对应的第二特征子图的情况下,第二特征子图包括的第二特征点,例如包括位于第二正方形区域内的所有第二特征点,也可以仅仅包括位于第二正方形区域内的部分第二特征点。
在得到第一特征子图和第二特征子图后,基于第一特征子图确定关联特征点和目标第二特征点之间的相似度。
示例性的,若与任一第一特征点对应的关联特征点有N个,则第n个关联特征点和目标第二特征点之间的相似度的归一化相关系数NCC n满足下述公式(1):
Figure PCTCN2021096064-appb-000003
其中,patch A表示第一特征子图;Patch B表示第二特征子图;patch A*Patch B表示将第一特征子图和第二特征子图进行矩阵乘法;sum(·)表示将矩阵中所有元素的元素值求和。归一化相关系数范围为[-1,1],此系数值越高,代表关联特征点和目标第二特征点之间越相似。
在上述S103中,例如可以基于该第一特征点的所述每个关联特征点与所述目标第二特征点之间的相似度,以及该第一特征点的多个所述关联特征点分别对应的特征值,对该第一特征点进行特征增强处理。
在具体实施中,示例性的,在对第一特征点进行特征增强处理的情况下,例如可以采用下述方式:
基于所述每个关联特征点与目标第二特征点之间的相似度,对多个所述关联特征点分别对应的特征值进行加权求和,得到第一和值;以及,对多个关联特征点分别对应的相似度进行求和,得到第二和值;将所述第一和值和所述第二和值的比值,作为对该第一特征点进行特征增强处理后的所述第一特征点的特征值。
示例性的,对于任一第一特征点,该任一第一特征点被特征增强处理后的特征值ft(A) 2满足下述公式(2):
Figure PCTCN2021096064-appb-000004
其中,ft(A)′ n表征第n个关联特征点对应的特征值。
在对第一特征图中的所有第一特征点进行特征增强处理后,得到进行特征增强处理后的第一特征图。
在图像中位置接近的像素点所表征的对象为同一对象的情况下,像素点的像素值是较为接近的;在对任一特征点进行特征增强处理过程中,该任一特征点的关联特征点与第二特征图中的目标第二特征点之间的相似度较高的情况下,表征该关联特征点与目标第二特征点表征相同对象的可能性较高;在像素低较低的情况下,表征该关联特征点与目标第二特征点表征相同对象的可能性较低;因此利用关联特征点和目标第二特征点之间的相似度对第一特征点进行特征增强处理,能够减少待检测图像存在的采集噪声、匹配误差、以及生产误差等带来的第一特征点和目标第二特征点之间的差异,降低由于上述误差所导致的将待检测图像和模板图像进行配准时所差生的错误的情况。
在基于第二特征图、以及进行了特征增强处理后的第一特征图、确定待检测图像对应的缺陷检测结果的情况下,例如可以按照预设的分割尺寸和预设移动步长,将第一特征图分割为多个小的第一子图,并将第二特征图分割为多个小的第二子图;
针对每个第一子图,从多个第二子图中,确定与该第一子图位置对应的目标第二子图,并计算第一子图与对应的目标第二子图之间的相似度;在该两者之间的相似度大于预设的相似度阈值的情况下,表征在待检测图像中,与该目标第二子图对应的区域未存在缺陷;在该两者之间的相似度小于或者等于该预设相似度阈值的情况下,表征在待检测图像中,与该目标第二子图像对应的区域存在缺陷。
在本公开另一种实施例中,还可以采用其他方法来对待检测图像进行缺陷检测,例如利用预先训练的缺陷检测神经网络,将增强后的第一特征图和第二特征图作为该缺陷检测神经网络的输入,得到待检测图像的缺陷检测结果。
示例性的,本公开实施例提供一种基于第二特征图、和特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果的具体示例,包括:
基于所述第二特征图、以及所述增强处理后的所述第一特征图,生成所述第二特征图的注意力掩码图像;其中,所述注意力掩码图像中任一像素点的像素值,表征该第二特征图中位置与该任一像素点匹配的第二特征点存在缺陷的异常度值;基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
在具体实施中,例如可以采用下述方式得到第二特征图对应的注意力掩码图像:针对第二特征图中的每个第二特征点,从第一特征图的多个第一特征点中,确定与该第二特征点对应的多个关联特征点;其中,该第二特征点对应的各个关联特征点,与该第二特征点位置匹配的目标第一特征点之间的 距离满足预设条件;基于该第二特征点与每个关联特征点之间的相似度,确定该第二特征点的异常度值;基于第二特征图中各个第二特征点的异常度值,得到第二特征图对应的注意力掩码图像。
此处,第二特征点对应的关联特征点的具体确定方式、以及确定第二特征点与关联特征点之间的相似度的方式,与上述S102和S103中确定关联特征点的方式类似。
在确定了第二特征点与每个关联特征点之间的相似度后,例如可以确定多个关联特征点分别与该第二特征点之间的最大相似度;基于所述最大相似度,确定该第二特征点的异常度值。
任一第二特征点的异常度值S例如满足下述公式(3):
S=1-λ×H        (3)
其中,H表示最大相似度。λ为预设系数,例如为1、0.5等。具体可以根据实际的需要进行设定。
又例如,可以根据多个关联特征点分别与该第二特征点之间的相似度,确定相似度均值,并基于该相似度均值,确定该第二特征点的异常度值。
在确定了第二特征图中每个第二特征点对应的异常度值后,基于所述第二特征图中各个第二特征点对应的异常度值,得到所述注意力掩码图像;此时,例如可以将所有第二特征点分别对应的异常度值构成的图像,作为注意力掩码图像。
在得到注意力掩码图像后,例如可以采用下述方式基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果:
对所述注意力掩码图像、以及所述增强处理后的所述第一特征图进行合并处理,得到合并特征图;对所述注意力掩码图像、以及所述合并特征图进行特征融合处理,得到特征融合图像;基于所述特征融合图像,确定所述待检测图像对应的缺陷检测结果。
在具体实施中,例如可以将特征增强图像和第二特征图进行叠加,得到合并特征图。
在基于注意力掩码图像、以及合并特征图得到特征融合图像的情况下,例如可以对将注意力掩码图像和合并特征图进行矩阵相乘,得到特征融合图像。
在得到特征融合图像后,例如可以将特征融合图像输入至预先训练的检测网络,对特征融合图像进行缺陷检测处理,得到与待检测图像对应的缺陷检测结果。本公开实施例提供的检测网络例如,采用全卷积逐像素目标检测(Fully Convolutional One-Stage Object Detection,FCOS)网络。其中,FCOS网络能够检测出缺陷类别、缺陷中心度、缺陷框在第一特征图中的位置。
其中,缺陷中心度用于表征第一特征图中的某个特征点为缺陷框中心的概率。
缺陷框在第一特征图中的位置,指示了第一特征图中存在缺陷的位置。
本公开实施例通过获取模板图像的第一特征图和待检测图像的第二特征图,并针对第一特征图中的每个第一特征点,从第一特征图中确定与该第一特征点之间的距离满足预设条件的多个关联特征点;针对每个第一特征点,基于确定的该第一特征点的关联特征点与第二特征图中与该第一特征点位置匹配的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;在将第一特征图中所有第一特征点都进行特征增强处理后,基于特征增强处理后的第一特征图和第二特征图,确定待检测图像对应的缺陷检测结果。该过程通过对各第一特征图中的各个第一特征点进行特征增强处理,以减小由于待检测图像存在的采集噪声、匹配误差、以及生产误差,所带来的待检测图像和模板图像之间的差异,提升对待检测图像的缺陷检测精度。
本公开实施例提供的缺陷检测方法,可以应用于与工业图像相关或人工智能(artificial intelligence,AI)教育等技术领域中,例如,具体可以应用于工业图像处理方面和嵌入式图像检测方面。
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。
基于同一发明构思,本公开实施例中还提供了与缺陷检测方法对应的缺陷检测装置,由于本公开实施例中的装置的原理与本公开实施例上述缺陷检测方法相似,因此装置的实施可以参见方法的实施。
参照图4所示,为本公开实施例提供的一种缺陷检测装置的示意图,所述装置包括:获取部分31、确定部分32、特征增强处理部分33、以及检测部分34;其中,
获取部分31,被配置为获取模板图像的第一特征图、以及待检测图像的第二特征图;
确定部分32,被配置为针对所述第一特征图中的每个第一特征点,从所述第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;
特征增强处理部分33,被配置为针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,所述目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点;
检测部分34,被配置为基于特征增强处理后的所述第一特征图、以及所述第二特征图,确定所述待检测图像对应的缺陷检测结果。
一种可能的实施方式中,还包括:相似度确定部分35,被配置为基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图;以及基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图;基于所述第一特征子图、以及所述第二特征子图,确定所述每个关联特征点与所述目标第二特征点之间的相似度。
一种可能的实施方式中,所述相似度确定部分35,还被配置为:在所述第一特征图上,确定以所述每个关联特征点为圆心、以所述距离阈值为半径的第一圆形区域,基于所述第一特征图上位于该第一圆形区域内的第一特征点,得到所述第一特征子图;在所述第二特征图上,确定以所述目标第二特征点为圆心、以所述距离阈值为半径的第二圆形区域,基于所述第二特征图上位于该第二圆形区域内的第二特征点,得到所述第二特征子图。
一种可能的实施方式中,所述相似度确定部分35,还被配置为:基于所述距离阈值,确定目标边长;在所述第一特征图上,确定以所述每个关联特征点为中心、以确定的所述目标边长为边长的第一正方形区域,基于所述第一特征图上位于该第一正方形区域内的第一特征点,得到所述第一特征子图;在所述第二特征图上,确定以所述目标第二特征点为中心、以确定的所述目标边长为边长的第二正方形区域,基于所述第二特征图上位于该第二正方形区域内的第二特征点,得到所述第二特征子图。
一种可能的实施方式中,所述特征增强处理部分33,还被配置为:基于该第一特征点的所述每个关联特征点与所述目标第二特征点之间的相似度,以及该第一特征点的多个所述关联特征点分别对应的特征值,对该第一特征点进行特征增强处理。
一种可能的实施方式中,所述特征增强处理部分33,还被配置为:基于所述每个关联特征点与所述目标第二特征点之间的相似度,对多个所述关联特征点分别对应的特征值进行加权求和,得到第一和值;以及,对多个所述关联特征点分别对应的相似度进行求和,得到第二和值;将所述第一和值和所述第二和值的比值,作为对该第一特征点进行特征增强处理后的所述第一特征点的特征值。
一种可能的实施方式中,所述检测部分34,还被配置为:基于所述第二特征图、以及所述增强处理后的所述第一特征图,生成所述第二特征图的注意力掩码图像;其中,所述注意力掩码图像中任一像素点的像素值,表征该第二特征图中位置与该任一像素点匹配的第二特征点存在缺陷的异常度值;基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
一种可能的实施方式中,所述检测部分34,还被配置为:对所述注意力掩码图像、以及所述增强处理后的所述第一特征图进行合并处理,得到合并特征图;对所述注意力掩码图像、以及所述合并特征图进行特征融合处理,得到特征融合图像;基于所述特征融合图像,确定所述待检测图像对应的缺陷检测结果。
关于装置中的各部分的处理流程、以及各部分之间的交互流程的描述可以参照上述方法实施例中的相关说明,这里不再详述。
在本公开实施例以及其他的实施例中,“部分”可以是部分电路、部分处理器、部分程序或软件等等,当然也可以是单元,还可以是模块也可以是非模块化的。
本公开实施例还提供了一种电子设备30(即上述的终端设备20),如图5所示,为本公开实施例提供的电子设备30结构示意图,包括:
处理器11和存储器12;所述存储器12存储有所述处理器11可执行的机器可读指令,在电子设备运行的情况下,所述机器可读指令被所述处理器执行以实现下述步骤:
获取模板图像的第一特征图、以及待检测图像的第二特征图;
针对所述第一特征图中的每个第一特征点,从所述第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;
针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,所述目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点;
基于特征增强处理后的所述第一特征图、以及所述第二特征图,确定所述待检测图像对应的缺陷检测结果。
上述指令的具体执行过程可以参考本公开实施例中所述的缺陷检测方法的步骤。
本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述方法实施例中所述的缺陷检测方法的步骤。其中,该存储介质可以是易失性或非易失的计算机可读取存储介质。
本公开实施例所提供的缺陷检测方法的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行上述方法实施例中所述的缺陷检测方法的步骤,具体可参见上述方法实施例。
本公开实施例还提供一种计算机程序,该计算机程序被处理器执行时实现前述实施例的任意一种方法。该计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考前述方法实施例中的对应过程。在本公开所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作 为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。
计算机可读取存储介质还可以是保持和存储由指令执行设备使用的指令的有形设备,可为易失性存储介质或非易失性存储介质。计算机可读存储介质例如可以是——但不限于——电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的列子(非穷举的列表)包括:U盘、磁碟、光盘、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦拭可编程只读存储器(EPROM或闪存)、静态随机存储读取器(ROM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、记性编码设备、例如其上存储有指令的打孔卡或凹槽内凹起结构、以及上述的任意合适的组合。这里所使用的计算机可读存储介质不被解释为瞬时信号本身,诸如无线电波或者其他自由传播的电池波、通过波导或其他传媒介质传播的电池波(例如,通过光纤电缆的光脉冲)、或者通过电线传输的电信号。
最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。
工业实用性
本公开实施例提供了一种缺陷检测方法及装置、电子设备和存储介质,其中,该方法包括:获取模板图像的第一特征图、以及待检测图像的第二特征图;针对第一特征图中的每个第一特征点,从第一特征图中的多个第一特 征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;针对每个第一特征点,基于确定的该第一特征点的每个关联特征点与第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,目标第二特征点为第二特征图中位置与该第一特征点匹配的第二特征点;基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。该过程能够提升对待检测图像的缺陷检测精度。

Claims (19)

  1. 一种缺陷检测方法,包括:
    获取模板图像的第一特征图、以及待检测图像的第二特征图;
    针对所述第一特征图中的每个第一特征点,从所述第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;
    针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,所述目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点;
    基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
  2. 根据权利要求1所述的方法,其中,采用下述方式确定所述每个关联特征点与所述目标第二特征点之间的相似度:
    基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图;以及
    基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图;
    基于所述第一特征子图、以及所述第二特征子图,确定所述每个关联特征点与所述目标第二特征点之间的相似度。
  3. 根据权利要求2所述的方法,其中,所述基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图,包括:
    在所述第一特征图上,确定以所述每个关联特征点为圆心、以所述距离阈值为半径的第一圆形区域,基于所述第一特征图上位于该第一圆形区域内 的第一特征点,得到所述第一特征子图;
    所述基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图,包括:
    在所述第二特征图上,确定以所述目标第二特征点为圆心、以所述距离阈值为半径的第二圆形区域,基于所述第二特征图上位于该第二圆形区域内的第二特征点,得到所述第二特征子图。
  4. 根据权利要求2所述的方法,其中,所述基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图,包括:
    基于所述距离阈值,确定目标边长;
    在所述第一特征图上,确定以所述每个关联特征点为中心、以确定的所述目标边长为边长的第一正方形区域,基于所述第一特征图上位于该第一正方形区域内的第一特征点,得到所述第一特征子图;
    所述基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图,包括:
    在所述第二特征图上,确定以所述目标第二特征点为中心、以确定的所述目标边长为边长的第二正方形区域,基于所述第二特征图上位于该第二正方形区域内的第二特征点,得到所述第二特征子图。
  5. 根据权利要求1-4任一项所述的方法,其中,所述针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理,包括:
    基于该第一特征点的所述每个关联特征点与所述目标第二特征点之间的相似度,以及该第一特征点的多个所述关联特征点分别对应的特征值,对该第一特征点进行特征增强处理。
  6. 根据权利要求5所述的方法,其中,所述基于该第一特征点的所述每个关联特征点与所述目标第二特征点之间的相似度,以及该第一特征点的多 个所述关联特征点分别对应的特征值,对该第一特征点进行特征增强处理,包括:
    基于所述每个关联特征点与所述目标第二特征点之间的相似度,对多个所述关联特征点分别对应的特征值进行加权求和,得到第一和值;
    以及,对多个所述关联特征点分别对应的相似度进行求和,得到第二和值;
    将所述第一和值和所述第二和值的比值,作为对该第一特征点进行特征增强处理后的所述第一特征点的特征值。
  7. 根据权利要求1-6任一项所述的方法,其中,所述基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果,包括:
    基于所述第二特征图、以及所述增强处理后的所述第一特征图,生成所述第二特征图的注意力掩码图像;其中,所述注意力掩码图像中任一像素点的像素值,表征该第二特征图中位置与该任一像素点匹配的第二特征点存在缺陷的异常度值;
    基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
  8. 根据权利要求7所述的方法,其中,所述基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果,包括:
    对所述注意力掩码图像、以及所述增强处理后的所述第一特征图进行合并处理,得到合并特征图;
    对所述注意力掩码图像、以及所述合并特征图进行特征融合处理,得到特征融合图像;
    基于所述特征融合图像,确定所述待检测图像对应的缺陷检测结果。
  9. 一种缺陷检测装置,包括:
    获取部分,被配置为获取模板图像的第一特征图、以及待检测图像的第二特征图;
    确定部分,被配置为针对所述第一特征图中的每个第一特征点,从所述第一特征图中的多个第一特征点中,确定与该第一特征点之间的距离满足预设条件的多个关联特征点;
    特征增强处理部分,被配置为针对每个所述第一特征点,基于确定的该第一特征点的每个关联特征点与所述第二特征图中的目标第二特征点之间的相似度,对该第一特征点进行特征增强处理;其中,所述目标第二特征点为所述第二特征图中位置与该第一特征点匹配的第二特征点;
    检测部分,被配置为基于所述第二特征图、以及特征增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
  10. 根据权利要求9所述的装置,其中,所述装置还包括:
    相似度确定部分,被配置为基于所述每个关联特征点在所述第一特征图中的位置,以及预设的距离阈值,得到所述每个关联特征点对应的第一特征子图;以及基于所述目标第二特征点在所述第二特征图中的位置、以及所述距离阈值,得到所述目标第二特征点对应的第二特征子图;基于所述第一特征子图、以及所述第二特征子图,确定所述每个关联特征点与所述目标第二特征点之间的相似度。
  11. 根据权利要求10所述的装置,其中,所述相似度确定部分,还被配置为在所述第一特征图上,确定以所述每个关联特征点为圆心、以所述距离阈值为半径的第一圆形区域,基于所述第一特征图上位于该第一圆形区域内的第一特征点,得到所述第一特征子图;在所述第二特征图上,确定以所述目标第二特征点为圆心、以所述距离阈值为半径的第二圆形区域,基于所述第二特征图上位于该第二圆形区域内的第二特征点,得到所述第二特征子图。
  12. 根据权利要求10所述的装置,其中,所述相似度确定部分,还被配置为基于所述距离阈值,确定目标边长;在所述第一特征图上,确定以所述 每个关联特征点为中心、以确定的所述目标边长为边长的第一正方形区域,基于所述第一特征图上位于该第一正方形区域内的第一特征点,得到所述第一特征子图;在所述第二特征图上,确定以所述目标第二特征点为中心、以确定的所述目标边长为边长的第二正方形区域,基于所述第二特征图上位于该第二正方形区域内的第二特征点,得到所述第二特征子图。
  13. 根据权利要求9-12任一项所述的装置,其中,所述特征增强处理部分,还被配置为基于该第一特征点的所述每个关联特征点与所述目标第二特征点之间的相似度,以及该第一特征点的多个所述关联特征点分别对应的特征值,对该第一特征点进行特征增强处理。
  14. 根据权利要求13所述的装置,其中,所述特征增强处理部分,还被配置为基于所述每个关联特征点与所述目标第二特征点之间的相似度,对多个所述关联特征点分别对应的特征值进行加权求和,得到第一和值;以及,对多个所述关联特征点分别对应的相似度进行求和,得到第二和值;将所述第一和值和所述第二和值的比值,作为对该第一特征点进行特征增强处理后的所述第一特征点的特征值。
  15. 根据权利要求9-14任一项所述的装置,其中,所述检测部分,还被配置为基于所述第二特征图、以及所述增强处理后的所述第一特征图,生成所述第二特征图的注意力掩码图像;其中,所述注意力掩码图像中任一像素点的像素值,表征该第二特征图中位置与该任一像素点匹配的第二特征点存在缺陷的异常度值;基于所述注意力掩码图像、以及所述增强处理后的所述第一特征图,确定所述待检测图像对应的缺陷检测结果。
  16. 根据权利要求15所述的装置,其中,所述检测部分,还被配置为对所述注意力掩码图像、以及所述增强处理后的所述第一特征图进行合并处理,得到合并特征图;对所述注意力掩码图像、以及所述合并特征图进行特征融合处理,得到特征融合图像;基于所述特征融合图像,确定所述待检测图像对应的缺陷检测结果。
  17. 一种电子设备,包括:相互连接的处理器和存储器,所述存储器存储有所述处理器可执行的机器可读指令,在电子设备运行的情况下,所述机器可读指令被所述处理器执行以实现如权利要求1至8任一所述的缺陷检测方法。
  18. 一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行如权利要求1至8任意一项所述的缺陷检测方法。
  19. 一种计算机程序,包括计算机可读代码,在所述计算机可读代码在电子设备中运行的情况下,所述电子设备中的处理器执行时实现权利要求1至8任意一项所述的缺陷检测方法。
PCT/CN2021/096064 2020-10-30 2021-05-26 缺陷检测方法及装置、电子设备和存储介质 WO2022088663A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2022538297A JP2023507024A (ja) 2020-10-30 2021-05-26 欠陥検出方法及びその装置、電子機器並びに記憶媒体

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011191756.0A CN112508846B (zh) 2020-10-30 2020-10-30 缺陷检测方法及装置、电子设备和存储介质
CN202011191756.0 2020-10-30

Publications (1)

Publication Number Publication Date
WO2022088663A1 true WO2022088663A1 (zh) 2022-05-05

Family

ID=74954615

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/096064 WO2022088663A1 (zh) 2020-10-30 2021-05-26 缺陷检测方法及装置、电子设备和存储介质

Country Status (3)

Country Link
JP (1) JP2023507024A (zh)
CN (1) CN112508846B (zh)
WO (1) WO2022088663A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115631199A (zh) * 2022-12-21 2023-01-20 深圳新视智科技术有限公司 pin针缺陷检测方法、装置、设备及存储介质
CN115965856A (zh) * 2023-02-23 2023-04-14 深圳思谋信息科技有限公司 图像检测模型构建方法、装置、计算机设备及存储介质
CN116721101A (zh) * 2023-08-09 2023-09-08 山东华航高分子材料有限公司 一种塑件表面波流痕的缺陷检测方法
CN116883417A (zh) * 2023-09-08 2023-10-13 武汉东方骏驰精密制造有限公司 基于机器视觉的工件质检方法及装置
WO2024098727A1 (zh) * 2022-11-10 2024-05-16 广东博智林机器人有限公司 螺杆洞检测方法、装置、设备及存储介质

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112508846B (zh) * 2020-10-30 2023-04-18 北京市商汤科技开发有限公司 缺陷检测方法及装置、电子设备和存储介质
CN112967264A (zh) * 2021-03-19 2021-06-15 深圳市商汤科技有限公司 缺陷检测方法及装置、电子设备和存储介质
CN113506243A (zh) * 2021-06-04 2021-10-15 联合汽车电子有限公司 Pcb焊接缺陷检测方法、装置及存储介质
CN113406092B (zh) * 2021-08-18 2022-01-11 阿里巴巴(中国)有限公司 数字化生产检测系统、方法、装置、设备及存储介质
CN114742791A (zh) * 2022-04-02 2022-07-12 深圳市国电科技通信有限公司 印刷电路板组装的辅助缺陷检测方法、装置及计算机设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130322737A1 (en) * 2012-05-30 2013-12-05 Hitachi High-Technologies Corporation Defect inspection method and defect inspection apparatus
CN107492091A (zh) * 2017-07-06 2017-12-19 东莞理工学院 基于机器视觉的标签外观检测方法及终端设备
CN110967851A (zh) * 2019-12-26 2020-04-07 成都数之联科技有限公司 一种液晶面板array图像的线路提取方法及系统
CN111160477A (zh) * 2019-12-31 2020-05-15 哈工汇智(深圳)科技有限公司 一种基于特征点检测的图像模板匹配方法
CN112508846A (zh) * 2020-10-30 2021-03-16 北京市商汤科技开发有限公司 缺陷检测方法及装置、电子设备和存储介质

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103456009B (zh) * 2013-08-28 2016-04-20 深圳市中瀛鑫科技股份有限公司 目标检测方法与装置、监控系统
US9846929B2 (en) * 2016-03-24 2017-12-19 Hong Kong Applied Science and Technology Research Institute Company Limited Fast density estimation method for defect inspection application
CN106600600A (zh) * 2016-12-26 2017-04-26 华南理工大学 基于特征匹配的晶圆缺陷检测方法
CN106952257B (zh) * 2017-03-21 2019-12-03 南京大学 一种基于模板匹配与相似度计算的曲面标签破损缺陷检测方法
CN110136160B (zh) * 2019-05-13 2023-03-24 南京大学 一种基于圆投影的快速图像匹配方法
CN111179253B (zh) * 2019-12-30 2023-11-24 歌尔股份有限公司 一种产品缺陷检测方法、装置与系统
CN111445467A (zh) * 2020-04-08 2020-07-24 珠海格力电器股份有限公司 亮灯缺陷检测方法、装置、电子设备及存储介质
CN111666974A (zh) * 2020-04-29 2020-09-15 平安科技(深圳)有限公司 图像匹配方法、装置、计算机设备及存储介质
CN111696092B (zh) * 2020-06-11 2023-08-25 深圳市华汉伟业科技有限公司 一种基于特征对比的缺陷检测方法及系统、存储介质
CN111814905A (zh) * 2020-07-23 2020-10-23 上海眼控科技股份有限公司 目标检测方法、装置、计算机设备和存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130322737A1 (en) * 2012-05-30 2013-12-05 Hitachi High-Technologies Corporation Defect inspection method and defect inspection apparatus
CN107492091A (zh) * 2017-07-06 2017-12-19 东莞理工学院 基于机器视觉的标签外观检测方法及终端设备
CN110967851A (zh) * 2019-12-26 2020-04-07 成都数之联科技有限公司 一种液晶面板array图像的线路提取方法及系统
CN111160477A (zh) * 2019-12-31 2020-05-15 哈工汇智(深圳)科技有限公司 一种基于特征点检测的图像模板匹配方法
CN112508846A (zh) * 2020-10-30 2021-03-16 北京市商汤科技开发有限公司 缺陷检测方法及装置、电子设备和存储介质

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024098727A1 (zh) * 2022-11-10 2024-05-16 广东博智林机器人有限公司 螺杆洞检测方法、装置、设备及存储介质
CN115631199A (zh) * 2022-12-21 2023-01-20 深圳新视智科技术有限公司 pin针缺陷检测方法、装置、设备及存储介质
CN115965856A (zh) * 2023-02-23 2023-04-14 深圳思谋信息科技有限公司 图像检测模型构建方法、装置、计算机设备及存储介质
CN115965856B (zh) * 2023-02-23 2023-05-30 深圳思谋信息科技有限公司 图像检测模型构建方法、装置、计算机设备及存储介质
CN116721101A (zh) * 2023-08-09 2023-09-08 山东华航高分子材料有限公司 一种塑件表面波流痕的缺陷检测方法
CN116721101B (zh) * 2023-08-09 2023-10-20 山东华航高分子材料有限公司 一种塑件表面波流痕的缺陷检测方法
CN116883417A (zh) * 2023-09-08 2023-10-13 武汉东方骏驰精密制造有限公司 基于机器视觉的工件质检方法及装置
CN116883417B (zh) * 2023-09-08 2023-12-05 武汉东方骏驰精密制造有限公司 基于机器视觉的工件质检方法及装置

Also Published As

Publication number Publication date
CN112508846B (zh) 2023-04-18
JP2023507024A (ja) 2023-02-20
CN112508846A (zh) 2021-03-16

Similar Documents

Publication Publication Date Title
WO2022088663A1 (zh) 缺陷检测方法及装置、电子设备和存储介质
WO2022151658A1 (zh) 一种缺陷检测方法、装置、计算机设备及计算机可读存储介质
US11854173B2 (en) System and method for finding lines in an image with a vision system
CN108875731B (zh) 目标识别方法、装置、系统及存储介质
CN106650662B (zh) 目标对象遮挡检测方法及装置
CN112288723B (zh) 缺陷检测方法、装置、计算机设备及存储介质
US8321358B2 (en) Interpersonal relationships analysis system and method which computes distances between people in an image
US11699283B2 (en) System and method for finding and classifying lines in an image with a vision system
CN107038443B (zh) 一种在电路板上定位感兴趣区域的方法和装置
JP2023120281A (ja) ビジョンシステムでラインを検出するためのシステム及び方法
US10679094B2 (en) Automatic ruler detection
CN112926531A (zh) 特征信息提取方法、模型训练方法、装置及电子设备
CN112700440B (zh) 物体缺陷检测方法、装置、计算机设备及存储介质
CN114494751A (zh) 证照信息识别方法、装置、设备及介质
US20240078801A1 (en) System and method for finding and classifying lines in an image with a vision system
CN112579810B (zh) 印刷电路板分类方法、装置、计算机设备和存储介质
CN110148133B (zh) 基于特征点及其结构关系的电路板残片图像识别方法
CN109033797B (zh) 一种权限设置方法及装置
CN115187769A (zh) 一种定位方法及装置
CN111951211B (zh) 一种目标检测方法、装置及计算机可读存储介质
CN112949526A (zh) 人脸检测方法和装置
CN112559342A (zh) 一种画面测试图像的获取方法、装置、设备及存储介质
CN114581890B (zh) 确定车道线的方法、装置、电子设备和存储介质
CN116182807B (zh) 一种姿态信息确定方法、装置、电子设备、系统和介质
CN116051559B (zh) 一种产品检测方法、装置、设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21884406

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2022538297

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21884406

Country of ref document: EP

Kind code of ref document: A1