Defect detection method and device, electronic equipment and storage medium
By performing defect detection on the surface of industrial products using color and grayscale images, and combining color masking and pseudo-defect similarity judgment, the problem of high error rate in traditional detection technology is solved, and more reliable defect detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JABIL CIRCUIT GUANGZHOU LTD
- Filing Date
- 2026-01-28
- Publication Date
- 2026-05-05
AI Technical Summary
Traditional defect detection technologies are easily affected by changes in lighting, product color differences, and background interference, resulting in high defect detection error rates and unreliable results.
By performing defect detection on color and grayscale images of the area to be detected, the authenticity of the target defect is determined by color mask and pseudo-defect similarity. Deep learning models and pseudo-defect filtering algorithms are used to improve the robustness of defect detection.
This effectively avoids excessive recall, improves the accuracy and reliability of defect detection, and reduces the false positive rate.
Smart Images

Figure CN121982010A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of product defect detection technology, specifically relating to a defect detection method, device, electronic equipment, and storage medium. Background Technology
[0002] Traditional defect detection techniques are easily affected by interference when detecting surface defects in industrial products. Although industrial images have a fixed background, they are easily affected by factors such as changes in lighting, product color differences, product background, and subtle differences in product surface components. This can lead to over-recall in defect detection (that is, normal, defect-free areas are also judged as defects), resulting in an excessively high error rate in product defect detection and unreliable defect detection results. Summary of the Invention
[0003] This application provides a defect detection method, device, electronic device, and storage medium that can solve the problems of excessively high error rate and unreliable defect detection results in product defect detection.
[0004] In a first aspect, embodiments of this application provide a defect detection method, which includes: performing defect detection on a color image and / or grayscale image corresponding to a region to be detected to determine a target defect; and determining that the target defect exists in the region to be detected if the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect.
[0005] Secondly, embodiments of this application provide a defect detection device, which includes: a detection module, used to perform defect detection on a color image and / or grayscale image corresponding to a region to be detected, and to determine a target defect; and a determination module, used to determine that the region to be detected contains the target defect if the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect.
[0006] Thirdly, embodiments of this application provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.
[0007] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0008] In this embodiment, a target defect is identified by performing defect detection on the color image and / or grayscale image corresponding to the area to be detected. If the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect, the presence of the target defect in the area to be detected is determined. This method can determine the authenticity and validity of the target defect by using the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect, thereby improving the robustness of defect detection and avoiding excessive recall. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 This is a schematic flowchart of a defect detection method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the framework of a defect detection method provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a defect detection device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0011] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0012] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0013] The defect detection method, apparatus, electronic device, and storage medium provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0014] Figure 1 This diagram illustrates a defect detection method according to an embodiment of this application. This method can be executed by an electronic device. In other words, the method can be executed by software or hardware installed in an electronic device, and includes the following steps: Step S101: Perform defect detection on the color image and / or grayscale image corresponding to the area to be detected to determine the target defect.
[0015] The defect detection method provided in this application is mainly applicable to industrial surface defect detection scenarios where sufficient defect samples are lacking. Figure 2 This paper presents a schematic diagram of the framework of a defect detection method provided in an embodiment of this application. The following is a detailed explanation in conjunction with... Figure 2 The defect detection method provided in the embodiments of this application will be described.
[0016] like Figure 2 As shown, the image of the product captured by the industrial camera is first obtained from the image input module. Then, the image to be detected is appropriately cropped and scaled by the image cropping and scaling module to adapt to the detection of subsequent algorithms. For example, the background area is removed, only the product area in the image is cropped, and it is scaled to a suitable resolution to facilitate algorithm detection. The subsequent processing steps are mainly divided into two branches for defect detection: color image and grayscale image.
[0017] In this embodiment, defect detection can be performed using a color image of the area to be detected. The image output by the image cropping and scaling module of the area to be detected is input into the defect detection module 1 to detect the target defect on the color image.
[0018] In another embodiment, defect detection can also be performed on the grayscale image of the area to be detected. Specifically, the image output by the image cropping and scaling module 1 can be input to the image grayscale conversion module. The image grayscale conversion module can convert the RGB color image into a grayscale image (black and white image). The grayscale image is then input to the defect detection module 2 to obtain the target defect on the grayscale image.
[0019] In this embodiment, defect detection module 1 and defect detection module 2 perform defect detection based on deep learning-based industrial defect detection models, such as Padim and Patchcore. An image is input to the industrial defect detection model, and the output is an image heatmap and defect region information.
[0020] Step S102: If the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect, the target defect is determined to exist in the area to be detected.
[0021] In this embodiment, regarding the color of the area to be detected, if the defect detection module 1 outputs an empty defect detection result, the pseudo-defect filtering module 1 and the semantic assignment module do not perform any processing and directly output the detection result to the result judgment module, determining that the area to be detected in the color image does not contain a target defect. If the defect detection module 1 detects a target defect, the target defect can be input to the pseudo-defect filtering module 1. The pseudo-defect filtering module 1 judges the similarity between the target defect and a preset pseudo defect. If the similarity between the target defect and the preset pseudo defect determines that the target defect is not a pseudo defect, the target defect can be input to the semantic assignment module. The semantic assignment module performs semantic judgment on the pseudo defect using the color mask of the target defect to determine whether the target defect is a real defect, and inputs the judgment result to the result judgment module. In this embodiment, the detected target defects can be processed in batches to filter out pseudo defects and defects that do not meet specific semantic conditions.
[0022] In this embodiment, for the grayscale image of the area to be detected, if the defect detection module 2 outputs an empty defect detection result, the pseudo-defect filtering module 2 does not perform any processing and directly outputs the detection result to the result judgment module. If the defect detection module 2 detects a target defect on the grayscale image, the target defect can be input to the pseudo-defect filtering module 2. The pseudo-defect filtering module 2 judges the similarity between the target defect and a preset pseudo defect. If the similarity between the target defect and the preset pseudo defect determines that the target defect is not a pseudo defect, the target defect can be input to the result judgment module. In this embodiment, the detected target defects can be processed in batches to filter out pseudo defects.
[0023] In this embodiment, the result judgment module can determine whether a target defect exists in the area to be detected based on the defect detection results of the color image and / or the defect detection results of the grayscale image. Specifically, if the target defect in the color image and / or the target defect in the grayscale image are determined to be real defects, it can be determined that a target defect (real defect) exists in the area to be detected.
[0024] In this embodiment, a target defect is identified by performing defect detection on the color image and / or grayscale image corresponding to the area to be detected. If the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect, the presence of the target defect in the area to be detected is determined. This method can determine the authenticity and validity of the target defect by using the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect, thereby improving the robustness of defect detection and avoiding excessive recall.
[0025] In one embodiment, after performing defect detection on the color image and / or grayscale image corresponding to the area to be detected and determining the target defect, the method further includes: when the area to be detected corresponds to the color image, determining the similarity between the target defect and a false defect; when the similarity is dissimilar, determining the number of non-zero value pixels of the target defect based on the color mask of the target defect; when the number of targets is greater than a pixel threshold and the abnormal score of the target defect is greater than a first score threshold, determining the target defect as a real defect, wherein the pixel threshold is greater than or equal to zero; and when the number of targets is equal to zero and the abnormal score of the target defect is greater than a second score threshold, determining the target defect as a real defect.
[0026] For target defects in color images, assuming the target defect and pseudo-defects are dissimilar, the colors contained in the target defect can be defined based on prior conditions. The HSV color detection function is defined as follows: Set a first score threshold for anomaly detection. (Low score threshold) and second lowest score threshold (High score threshold), the target defect is defined as The anomaly score of the target defect area is The pixel function of the color mask for the target defect is The pixel threshold is .
[0027] In this embodiment of the application, the anomaly score S(R) of the target defect is calculated using pixel anomaly scores, and the calculation method is as follows: First, the coordinates of each pixel in the image to be detected are defined as (x, y). The abnormality score of each pixel in the image is obtained by the defect detection model, which is P(x, y). The minimum value of P(x, y) is 0 and the maximum value is 1. The larger the value, the greater the abnormality of the pixel.
[0028] Then, an anomaly threshold is set to conf, and a mask image with the same size as the image to be detected is set to Mask. The coordinates (x, y) of each pixel in the mask image correspond one-to-one with the coordinates of each pixel in the image to be detected. The value of each pixel in the mask image Mask is set to Mask(x, y). When P(x, y) > conf, the value of the pixel Mask(x, y) = 1; otherwise, the value of the pixel Mask(x, y) = 0.
[0029] Finally, let R be the region formed by pixels with Mask(x,y)=1, and let N be the number of pixels with Mask(x,y)=1. Then, the anomaly score S(R) of the target defect is obtained by calculating the average anomaly score of the pixels with Mask(x,y)=1, as shown in the following formula:
[0030] In this embodiment, the HSV color mask is calculated using the HSV color detection function. Then, calculate the target number of non-zero value pixels in the HSV color mask. .
[0031] In the implementation of this application, if the number of non-zero pixel points is... The number of target pixels with values greater than zero and non-zero is greater than the pixel threshold, which satisfies the condition. Then, it is further determined whether the abnormal score of the defect area is greater than the first score threshold. ,like If the defect is determined to be a real defect, then the defect is determined to be a real defect; otherwise, the defect is determined to be a non-real defect.
[0032] If the number of non-zero pixel points is The number of target pixels with zero and non-zero values is less than or equal to the pixel threshold, which satisfies the condition. Then, it is further determined whether the abnormal score of the defect area is greater than the second score threshold. ,like If the defect is determined to be a real defect, then the defect is determined to be a real defect; otherwise, the defect is determined to be a non-real defect.
[0033] In one embodiment, after performing defect detection on the color image and / or grayscale image corresponding to the area to be detected and determining the target defect, the method further includes: if the area to be detected corresponds to the grayscale image, determining the similarity between the target defect and a false defect; if the similarity is not similar, determining the target defect as a real defect.
[0034] When the area to be detected corresponds to a grayscale image, for the target defect in the grayscale image, the similarity between the target defect and the pseudo-defect is first determined; if the similarity is not similar, the target defect is determined to be a real defect.
[0035] In one embodiment, determining the similarity between the target defect and the pseudo defect includes: determining that the similarity between the target defect and the pseudo defect is dissimilar when it is determined that the target defect and the pseudo defect are of different categories, the Euclidean distance between the target defect and the pseudo defect is greater than a distance threshold, and the area difference between the target defect and the pseudo defect is greater than an area threshold.
[0036] In this embodiment, since the background of most industrial inspection images is fixed, pseudo-defects usually originate from the background area and are very similar to common real defects in terms of geometry or color space. Therefore, this embodiment pre-defines pseudo-defects, defining their categories, center coordinates, and areas. In this embodiment, the similarity between the target defect and the pseudo-defect can be determined based on the category, center coordinates, and area of the pseudo-defect and the category, center coordinates, and area of the target defect.
[0037] For example, define a pseudo-defect. False defects pseudo center coordinates The area is Information such as... In this embodiment of the application, multiple pseudo-defects can be defined on an image. In this embodiment of the application, the target defect detected on the color image is... Target defects center coordinates The area is The output of defect detection module 1 can contain one or more random target defects. .
[0038] In this embodiment of the application, the pseudo-defect filtering module 1 and the pseudo-defect filtering module 2 receive the target defect B output from the defect detection module and determine the similarity between the target defect B and the pseudo-defect A.
[0039] In this embodiment of the application, the process of determining the similarity between the target defect B and the pseudo-defect A includes: 1. Determine whether the target defect B and the pseudo defect A are of the same category. If the target defect B and the pseudo defect A are of the same category, the similarity between the target defect B and the pseudo defect A is determined to be similar, and the target defect B can be considered as a pseudo defect.
[0040] 2. If the target defect B and the pseudo defect A are determined to be of different categories, it can be further determined whether the Euclidean distance between the center coordinates of the pseudo defect A and the center coordinates of the target defect B is greater than a distance threshold. If the Euclidean distance between the center coordinates of pseudo-defect A and the center coordinates of target defect B is less than or equal to the distance threshold ( By using this method, we can determine that the similarity between the target defect B and the pseudo defect A is similar, and therefore we can consider the target defect B to be a pseudo defect.
[0041] 3. If the Euclidean distance between the center coordinates of pseudo-defect A and the center coordinates of target defect B is greater than the distance threshold. ( Furthermore, it can be determined whether the area difference between the target defect B and the pseudo-defect A is greater than an area threshold. If the area difference between the target defect B and the pseudo-defect A is determined to be greater than the area threshold, the similarity between the target defect B and the pseudo-defect A is determined to be dissimilar. If the area difference between the target defect B and the pseudo-defect A is determined to be less than or equal to the area threshold, the similarity between the target defect B and the pseudo-defect A is determined to be similar. For example, if the area difference is 10%, the area difference between the target defect B and the pseudo-defect A is... ,like If so, the similarity between the target defect B and the pseudo defect A is determined to be dissimilar.
[0042] In this embodiment, methods such as image grayscale conversion, pseudo-defect filtering, and semantic assignment are introduced to improve the robustness of defect detection, reduce over-recall, and enhance the controllability, effectiveness, and accuracy of defect detection results. Image grayscale conversion reduces the impact of factors such as color difference on the algorithm; the pseudo-defect filtering algorithm addresses the impact of normal areas with large morphological changes on the algorithm (e.g., the color and shape changes of component pads on PCBA boards are greater than other areas); and semantic assignment allows for targeted attention to defects of key concern.
[0043] It should be noted that the defect detection method provided in this application can be executed by a defect detection device or a control module within that defect detection device for executing the defect detection method. This application uses the example of a defect detection device executing a defect detection method to illustrate the defect detection device provided in this application.
[0044] Figure 3 This is a schematic diagram of the defect detection device according to an embodiment of this application. Figure 3 As shown, the defect detection device 300 includes: a detection module 310 and a determination module 320.
[0045] The detection module 310 is used to perform defect detection on the color image and / or grayscale image corresponding to the area to be detected, and to determine the target defect; the determination module 320 is used to determine that the target defect exists in the area to be detected when the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect.
[0046] In one embodiment, the determining module 320 is further configured to: determine the similarity between the target defect and the pseudo-defect when the area to be detected corresponds to the color image; when the similarity is dissimilar, determine the number of non-zero value pixels of the target defect based on the color mask of the target defect; determine the target defect as a real defect when the number of targets is greater than a pixel threshold and the abnormal score of the target defect is greater than a first score threshold, wherein the pixel threshold is greater than or equal to zero; and determine the target defect as a real defect when the number of targets is equal to zero and the abnormal score of the target defect is greater than a second score threshold.
[0047] In one embodiment, the determining module 320 is further configured to: determine the similarity between the target defect and the pseudo defect when the area to be detected corresponds to the grayscale image; and determine the target defect as a real defect when the similarity is dissimilar.
[0048] In one embodiment, the determining module 320 is configured to: determine that the similarity between the target defect and the pseudo defect is dissimilar when it is determined that the target defect and the pseudo defect are of different categories, the Euclidean distance between the target defect and the pseudo defect is greater than a distance threshold, and the area difference between the target defect and the pseudo defect is greater than an area threshold.
[0049] The defect detection device in this application embodiment can be a device, or it can be a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.
[0050] The defect detection device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit it.
[0051] The defect detection device provided in this application embodiment can achieve... Figures 1 to 2 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0052] Optionally, such as Figure 4 As shown, this application embodiment also provides an electronic device 400, including a processor 401 and a memory 402. The memory 402 stores a program or instructions that can run on the processor 401. When the program or instructions are executed by the processor 401, they perform the following: perform defect detection on the color image and / or grayscale image corresponding to the area to be detected to determine the target defect; and determine that the target defect exists in the area to be detected if the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset false defect.
[0053] In one embodiment, after performing defect detection on the color image and / or grayscale image corresponding to the area to be detected and identifying the target defect, if the area to be detected corresponds to the color image, the similarity between the target defect and the false defect is determined; if the similarity is dissimilar, the number of non-zero pixel values of the target defect is determined according to the color mask of the target defect; if the number of targets is greater than a pixel threshold and the abnormal score of the target defect is greater than a first score threshold, the target defect is determined to be a real defect, where the pixel threshold is greater than or equal to zero; if the number of targets is equal to zero and the abnormal score of the target defect is greater than a second score threshold, the target defect is determined to be a real defect.
[0054] In one embodiment, after performing defect detection on the color image and / or grayscale image corresponding to the area to be detected and determining the target defect, if the area to be detected corresponds to the grayscale image, the similarity between the target defect and the false defect is determined; if the similarity is not similar, the target defect is determined to be a real defect.
[0055] In one embodiment, if it is determined that the target defect and the pseudo defect are of different categories, the Euclidean distance between the target defect and the pseudo defect is greater than a distance threshold, and the area difference between the target defect and the pseudo defect is greater than an area threshold, then the similarity between the target defect and the pseudo defect is determined to be dissimilar.
[0056] The specific execution steps can be found in the various steps of the above defect detection method embodiments, and can achieve the same technical effect. To avoid repetition, they will not be repeated here.
[0057] It should be noted that the electronic devices in the embodiments of this application include: servers, terminals, or other devices besides terminals.
[0058] The above electronic device structure does not constitute a limitation on the electronic device. An electronic device may include more or fewer components than illustrated, or combine certain components, or arrange them differently. For example, an input unit may include a Graphics Processing Unit (GPU) and a microphone, and a display unit may use a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar display panels. User input units include at least one of a touch panel and other input devices. A touch panel is also called a touchscreen. Other input devices may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be elaborated further here.
[0059] Memory can be used to store software programs and various data. Memory can primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area can store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, memory can include volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (Synchlink DRAM, SLDRAM), and direct memory bus RAM (DRRAM).
[0060] The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly handles operations related to the operating system, user interface, and applications, while the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into the processor.
[0061] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described defect detection method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0062] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as ROM, RAM, magnetic disk, or optical disk.
[0063] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0064] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0065] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A defect detection method, characterized in that, include: Defect detection is performed on the color and / or grayscale images corresponding to the area to be detected to identify the target defect; If the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect, then the target defect is determined to exist in the area to be detected.
2. The method according to claim 1, characterized in that, After performing defect detection on the color image and / or grayscale image corresponding to the area to be detected, and identifying the target defect, the process also includes: When the area to be detected corresponds to the color image, the similarity between the target defect and the pseudo-defect is determined; When the similarity is dissimilar, the number of non-zero value pixels of the target defect is determined based on the color mask of the target defect; If the number of targets is greater than the pixel threshold and the abnormal score of the target defect is greater than the first score threshold, the target defect is determined to be a real defect, and the pixel threshold is greater than or equal to zero. If the number of targets is zero and the abnormal score of the target defect is greater than the second score threshold, the target defect is determined to be a real defect.
3. The method according to claim 1, characterized in that, After performing defect detection on the color image and / or grayscale image corresponding to the area to be detected, and identifying the target defect, the process also includes: When the area to be detected corresponds to the grayscale image, the similarity between the target defect and the pseudo-defect is determined; If the similarity is not found, the target defect is determined to be a real defect.
4. The method according to claim 2 or 3, characterized in that, Determining the similarity between the target defect and the pseudo-defect includes: If it is determined that the target defect and the pseudo defect are of different categories, the Euclidean distance between the target defect and the pseudo defect is greater than a distance threshold, and the area difference between the target defect and the pseudo defect is greater than an area threshold, then the similarity between the target defect and the pseudo defect is determined to be dissimilar.
5. A defect detection device, characterized in that, include: The detection module is used to perform defect detection on the color image and / or grayscale image corresponding to the area to be detected, and to determine the target defect; The determination module is used to determine that the target defect exists in the area to be detected when the target defect is determined to be a real defect based on the color mask of the target defect and / or the similarity between the target defect and a preset pseudo defect.
6. The apparatus according to claim 5, characterized in that, The determining module is further configured to: When the area to be detected corresponds to the color image, the similarity between the target defect and the pseudo-defect is determined; When the similarity is dissimilar, the number of non-zero value pixels of the target defect is determined based on the color mask of the target defect; If the number of targets is greater than the pixel threshold and the abnormal score of the target defect is greater than the first score threshold, the target defect is determined to be a real defect, and the pixel threshold is greater than or equal to zero. If the number of targets is zero and the abnormal score of the target defect is greater than the second score threshold, the target defect is determined to be a real defect.
7. The apparatus according to claim 5, characterized in that, The determining module is further configured to: When the area to be detected corresponds to the grayscale image, the similarity between the target defect and the pseudo-defect is determined; If the similarity is not found, the target defect is determined to be a real defect.
8. The apparatus according to claim 6 or 7, characterized in that, The determining module is used for: If it is determined that the target defect and the pseudo defect are of different categories, the Euclidean distance between the target defect and the pseudo defect is greater than a distance threshold, and the area difference between the target defect and the pseudo defect is greater than an area threshold, then the similarity between the target defect and the pseudo defect is determined to be dissimilar.
9. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the defect detection method as described in any one of claims 1-4.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the defect detection method as described in any one of claims 1-4.