Defect detection method, device, equipment and computer readable storage medium
By performing area division and feature analysis on the target image, the problems of diverse morphology and random locations in defect detection are solved, and more accurate defect detection results are achieved.
Patent Information
- Application Number
- CN202010740667.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-28
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2040-07-28
AI Technical Summary
The existing defect detection technology has inaccurate detection results due to different defect shapes, different sizes and random locations, and errors.
By acquiring the target image and dividing the area, acquiring the area feature identification and defect characteristics, filtering, segmentation and feature screening are performed based on these features, defect images are output, and the connecting domains are analyzed one by one to determine the defect judgment result.
Improves the flexibility and accuracy of defect detection and improves the user experience.
Smart Images

Figure CN111882541B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of product defect detection, and in particular to a defect detection method, device, equipment and computer-readable storage medium. Background Art
[0002] The defect imaging system mainly includes: camera, lens and light source. The system selects appropriate camera, lens and light source to image the defect according to the specific needs of the customer. The automatic defect detection part is the brain of the entire visual inspection system. The automatic detection of defects using image processing technology is the core of the entire system. Although various detection algorithms continue to emerge, there is still a certain gap in actual application to meet the needs of actual applications. Usually, due to the different shapes and sizes of defects, the detection results are inaccurate and there are consequences of errors.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a defect detection method, device, equipment and computer-readable storage medium, aiming to solve the current technical problem of inaccurate detection results caused by various defect shapes, sizes, random locations, etc.
[0005] To achieve the above object, the present invention provides a defect detection method, which comprises the following steps:
[0006] Acquire a target image, and divide the target image into regions to obtain a plurality of region images;
[0007] Respectively obtaining a region feature identifier of each region image in a plurality of region images, and respectively determining a defect feature corresponding to the region feature identifier of each region image;
[0008] Based on the defect features, a defect image corresponding to each regional image is outputted respectively.
[0009] Preferably, when the product to be inspected is placed on the defect detection platform, a target image of the product to be inspected is captured based on a camera device of the defect detection platform.
[0010] Preferably, product feature information of the product to be inspected is obtained, and / or pixel screening is performed on the target image to obtain a pixel defect area corresponding to the target image;
[0011] Based on the product feature information and / or the pixel defect area corresponding to the target image, the target image is divided into regions to obtain a plurality of regional images, and regional feature identification is performed on the plurality of regional images.
[0012] Preferably, based on the defect features corresponding to each regional image, the algorithm parameters corresponding to the regional image are determined;
[0013] Based on the algorithm parameters corresponding to the area image, the area image is detected using a preset algorithm to output a defect image corresponding to the area image.
[0014] Preferably, based on the filtering parameters corresponding to the regional image, the regional image is pre-filtered to obtain a filtered image;
[0015] Based on the segmentation parameters corresponding to the regional image, defect segmentation is performed on the filtered image to obtain a binary image;
[0016] Based on the characteristic parameters, feature screening is performed on the binary image to determine a defect image corresponding to the binary image, and the defect image is output.
[0017] Preferably, a connected domain analysis is performed on the binary image to obtain a connected domain set of the binary image;
[0018] Based on the feature parameters, feature screening is performed on each connected domain of the connected domain set of the binary image one by one to determine a defect image corresponding to the binary image, and the defect image is output.
[0019] Preferably, feature extraction is performed on each connected domain of the connected domain set of the binary image one by one to obtain a feature set corresponding to each connected domain;
[0020] Obtaining a feature value corresponding to each feature in the feature set corresponding to the connected domain, and comparing the feature value with a standard feature value to obtain a defect determination result corresponding to the connected domain;
[0021] Based on the defect determination result corresponding to each connected domain of the connected domain set, a defect image corresponding to the binary image is determined.
[0022] In addition, to achieve the above object, the present invention also provides a defect detection device, the defect detection device comprising:
[0023] A first acquisition module is used to acquire a target image and divide the target image into regions to acquire a plurality of region images;
[0024] A second acquisition module is used to respectively acquire a regional feature identifier of each of the plurality of regional images, and respectively determine a defect feature corresponding to the regional feature identifier of each regional image;
[0025] The output module is used to output the defect image corresponding to each regional image based on the defect feature.
[0026] Preferably, the first acquisition module is further used to:
[0027] When the product to be inspected is placed on the defect inspection platform, a target image of the product to be inspected is collected based on the camera device of the defect inspection platform.
[0028] Preferably, the first acquisition module is further used to:
[0029] Acquire product feature information of the product to be inspected, and / or perform pixel screening on the target image to obtain a pixel defect area corresponding to the target image;
[0030] Based on the product feature information and / or the pixel defect area corresponding to the target image, the target image is divided into regions to obtain a plurality of regional images, and regional feature identification is performed on the plurality of regional images.
[0031] Preferably, the output module is further used to:
[0032] Determining algorithm parameters corresponding to each regional image based on defect features corresponding to the regional image;
[0033] Based on the algorithm parameters corresponding to the area image, the area image is detected using a preset algorithm to output a defect image corresponding to the area image.
[0034] Preferably, the output module is further used to:
[0035] Based on the filtering parameters corresponding to the regional image, pre-filtering the regional image to obtain a filtered image;
[0036] Based on the segmentation parameters corresponding to the regional image, defect segmentation is performed on the filtered image to obtain a binary image;
[0037] Based on the characteristic parameters, feature screening is performed on the binary image to determine a defect image corresponding to the binary image, and the defect image is output.
[0038] Preferably, the output module is further used to:
[0039] Performing a connected domain analysis on the binary image to obtain a connected domain set of the binary image;
[0040] Based on the feature parameters, feature screening is performed on each connected domain of the connected domain set of the binary image one by one to determine a defect image corresponding to the binary image, and the defect image is output.
[0041] Preferably, the output module is further used to:
[0042] Extracting features from each connected domain of the connected domain set of the binary image one by one to obtain a feature set corresponding to each connected domain;
[0043] Obtaining a feature value corresponding to each feature in the feature set corresponding to the connected domain, and comparing the feature value with a standard feature value to obtain a defect determination result corresponding to the connected domain;
[0044] Based on the defect determination result corresponding to each connected domain of the connected domain set, a defect image corresponding to the binary image is determined.
[0045] In addition, to achieve the above-mentioned purpose, the present invention also provides a defect detection device, which includes: a memory, a processor, and a defect detection program stored in the memory and executable on the processor, and the defect detection program implements the steps of the above-mentioned defect detection method when executed by the processor.
[0046] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a defect detection program is stored, and when the defect detection program is executed by a processor, the steps of the defect detection method described above are implemented.
[0047] The defect detection method proposed in the present invention obtains a target image and divides the target image into regions to obtain a plurality of regional images, then obtains the regional feature identifiers of each of the plurality of regional images, and determines the defect features corresponding to the regional feature identifiers of each regional image, and outputs the defect images corresponding to each regional image based on the defect features. Various defects of different sizes that may appear at various positions on the image can be detected, thereby improving the flexibility of defect detection and the accuracy of defect detection results, thereby improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a schematic diagram of the structure of a defect detection device in a hardware operating environment involved in an embodiment of the present invention;
[0049] Figure 2 It is a flow chart of the first embodiment of the defect detection method of the present invention;
[0050] Figure 3 A schematic diagram of a scene of a first embodiment of a defect detection method of the present invention;
[0051] Figure 4 Schematic diagram of the N-ary tree algorithm involved in the defect detection method of the present invention.
[0052] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0053] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0054] like Figure 1 As shown, Figure 1 It is a schematic diagram of the structure of a defect detection device in a hardware operating environment involved in an embodiment of the present invention.
[0055] like Figure 1 As shown, the defect detection device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0056] Optionally, the defect detection equipment may also include a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, and the like. Among them, sensors include light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display screen according to the brightness of the ambient light, and the proximity sensor may turn off the display screen and / or backlight when the mobile terminal is moved to the ear. As a type of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile terminal (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; of course, the mobile terminal can also be equipped with other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., which will not be repeated here.
[0057] Those skilled in the art will understand that Figure 1The defect detection device structure shown in the figure does not constitute a limitation of the defect detection device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0058] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a defect detection program.
[0059] exist Figure 1 In the terminal shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the defect detection program stored in the memory 1005.
[0060] In this embodiment, the defect detection device includes: a memory 1005, a processor 1001, and a defect detection program stored in the memory 1005 and executable on the processor 1001, wherein the processor 1001 calls the defect detection program stored in the memory 1005 and performs the following operations:
[0061] Acquire a target image, and divide the target image into regions to obtain a plurality of region images;
[0062] Respectively obtaining a region feature identifier of each region image in a plurality of region images, and respectively determining a defect feature corresponding to the region feature identifier of each region image;
[0063] Based on the defect features, a defect image corresponding to each regional image is outputted respectively.
[0064] Further, the processor 1001 may call the defect detection program stored in the memory 1005, and further perform the following operations:
[0065] When the product to be inspected is placed on the defect inspection platform, a target image of the product to be inspected is collected based on the camera device of the defect inspection platform.
[0066] Further, the processor 1001 may call the defect detection program stored in the memory 1005, and further perform the following operations:
[0067] Acquire product feature information of the product to be inspected, and / or perform pixel screening on the target image to obtain a pixel defect area corresponding to the target image;
[0068] Based on the product feature information and / or the pixel defect area corresponding to the target image, the target image is divided into regions to obtain a plurality of regional images, and regional feature identification is performed on the plurality of regional images.
[0069] Further, the processor 1001 may call the defect detection program stored in the memory 1005, and further perform the following operations:
[0070] Determining algorithm parameters corresponding to each regional image based on defect features corresponding to the regional image;
[0071] Based on the algorithm parameters corresponding to the area image, the area image is detected using a preset algorithm to output a defect image corresponding to the area image.
[0072] Further, the processor 1001 may call the defect detection program stored in the memory 1005, and further perform the following operations:
[0073] Based on the filtering parameters corresponding to the regional image, pre-filtering the regional image to obtain a filtered image;
[0074] Based on the segmentation parameters corresponding to the regional image, defect segmentation is performed on the filtered image to obtain a binary image;
[0075] Based on the characteristic parameters, feature screening is performed on the binary image to determine a defect image corresponding to the binary image, and the defect image is output.
[0076] Further, the processor 1001 may call the defect detection program stored in the memory 1005, and further perform the following operations:
[0077] Performing a connected domain analysis on the binary image to obtain a connected domain set of the binary image;
[0078] Based on the feature parameters, feature screening is performed on each connected domain of the connected domain set of the binary image one by one to determine a defect image corresponding to the binary image, and the defect image is output.
[0079] Further, the processor 1001 may call the defect detection program stored in the memory 1005, and further perform the following operations:
[0080] Extracting features from each connected domain of the connected domain set of the binary image one by one to obtain a feature set corresponding to each connected domain;
[0081] Obtaining a feature value corresponding to each feature in the feature set corresponding to the connected domain, and comparing the feature value with a standard feature value to obtain a defect determination result corresponding to the connected domain;
[0082] Based on the defect determination result corresponding to each connected domain of the connected domain set, a defect image corresponding to the binary image is determined.
[0083] The present invention also provides a defect detection method, referring to Figure 2 , Figure 2 FIG. 1 is a flow chart of a first embodiment of a defect detection method according to the present invention.
[0084] Step S10, acquiring a target image, and dividing the target image into regions to acquire a plurality of region images;
[0085] In this embodiment, when performing product defect detection, a target image of the product is obtained, and then the obtained product target image is divided into regions to obtain several regional images. It can be understood that as users' requirements for product quality continue to increase, the appearance of the product is also increasingly valued. Due to production processes and other reasons, appearance defects will inevitably appear in the product production process, including spots, scratches, cracks, dirt, depressions, bulges and other appearance defects. At present, a machine defect detection algorithm is used to perform regional detection on the product. However, due to the wide variety of product defects and the random locations of various defects in the product, it is necessary to divide the product into multiple different regions for the same product and adopt targeted defect algorithm detection for multiple different regions. Specifically, the target image corresponding to the product to be detected is collected, and the target image is input, and then the target image is divided into regions according to the preset division rules to obtain several regional images, wherein the preset division rules can be based on the characteristics of the product to be tested. For example, if the product to be tested is a ceramic bowl, the ceramic bowl can be divided into a bowl holder, a concave area, and a convex area, and the bowl holder image, the concave image and the convex image are respectively detected.
[0086] Furthermore, before step S10, the following steps are included:
[0087] Step S11, when the product to be inspected is placed on a defect inspection platform, a target image of the product to be inspected is captured based on a camera device of the defect inspection platform.
[0088] In this step, when performing product defect detection, the product to be detected must first be placed on the defect detection platform, such as Figure 3 , Figure 3 FIG. 1 is a schematic diagram of a scene according to an embodiment of the present invention. Figure 3 As shown, Figure 3As shown on the left, the rectangle on the lower left represents the defect detection platform, the cylinder above the rectangle represents the product to be detected, and the upper left side of the rectangle represents the light source, wherein the light source serves as fill light to avoid the presence of shadow areas in the target image corresponding to the product to be detected captured by the camera device due to insufficient light, thereby affecting the defect detection result of the product. Specifically, for example, when detecting concave-convex products, the light source is used to fill light in the concave area of the concave-convex product to obtain a target image without defects. Figure 3 On the upper left side is the camera device, which is used to capture the target image corresponding to the product to be inspected. Figure 3 The defect detection system is shown on the right. Specifically, the defect detection system includes a computer and defect detection algorithm software installed on the computer, such as Figure 3 As shown, the camera device establishes a communication connection with the computer. After the camera device captures the target image of the device to be inspected, it transmits the target image to the computer based on the communication line between the camera device and the computer, and finally performs defect detection on the platform to be inspected based on the defect detection algorithm software installed on the computer.
[0089] Specifically, step S10 includes:
[0090] Step S12, obtaining product feature information of the product to be inspected, and / or performing pixel screening on the target image to obtain a pixel defect area corresponding to the target image;
[0091] Step S13, based on the product feature information and / or the pixel defect area corresponding to the target image, the target image is divided into regions to obtain a plurality of regional images, and regional feature identification is performed on the plurality of regional images.
[0092] Specifically, a product to be inspected is placed on a defect detection platform, and product feature information of the product to be inspected is obtained, such as structural information of the product to be inspected, material properties of the product to be inspected, etc. Then, based on the camera device of the defect detection platform, a target image of the product to be inspected is collected, and then the target image is pixel-screened to obtain a pixel defect area corresponding to the target image. Specifically, the target image is grayscale preprocessed, and then a grayscale value set corresponding to the target image is obtained, and the average grayscale value of the grayscale value set is calculated. Then, a target grayscale value in the grayscale value set whose grayscale value is less than the average grayscale value is obtained, and the position information of the target grayscale value is obtained. Based on the position information of the target grayscale value, the pixel defect area corresponding to the target image is obtained, and the pixel defect area is pixel-marked.
[0093] In this step, it can be understood that the target image is input and the target image is divided into regions to obtain a number of regional images. Specifically, the target image is input, and then the product feature information of the product to be inspected corresponding to the target image and / or the pixel defect area corresponding to the target image is obtained, and the target image is divided into regions. Specifically, for example, if the product to be inspected is paper, the paper may have defects such as uneven paper edges or rough paper edges. In this case, the edges of the product to be inspected can be divided according to the post information of the product to be inspected, and the edge feature identifiers after division are marked, such as feature identifiers of uneven edges and / or rough edges.
[0094] Step S20, respectively obtaining a region feature identifier of each region image in a plurality of region images, and respectively determining a defect feature corresponding to the region feature identifier of each region image;
[0095] In this embodiment, it can be understood that the purpose of dividing the target image into several regional images is to perform different detections on different regions. Therefore, before defect detection, it is necessary to confirm the corresponding regional defect characteristics. Specifically, the regional feature identifier of each regional image in the several regional images is obtained respectively, wherein the regional feature identifier includes the pixel identifier of the region and / or the defect identifier of the region.
[0096] Step S30: outputting defect images corresponding to each regional image based on the defect features.
[0097] In this embodiment, after determining the defect features corresponding to the regional feature identifiers of each regional image respectively, the algorithm parameters are set based on the defect features to obtain the custom algorithms corresponding to the respective regional images, and defect detection is performed on each regional image based on the custom algorithms corresponding to the respective regional images to output the corresponding defect images.
[0098] Specifically, step S30 includes:
[0099] Step S301, determining the algorithm parameters corresponding to each regional image based on the defect features corresponding to the regional image,
[0100] Step S302: Based on the algorithm parameters corresponding to the regional image, a preset algorithm detection is performed on the regional image to output a defect image corresponding to the regional image.
[0101] In this step, the preset algorithm process involved in this embodiment is specifically to perform defect filtering on the input regional image, and then perform defect segmentation and feature screening on the filtered regional image to output the corresponding defect image in each regional image. Therefore, in order to solve the technical problem of inaccurate defect detection results caused by different shapes, sizes and random positions of product defects when performing defect detection on products, in this implementation, after obtaining the defect features corresponding to each regional image, the algorithm parameters corresponding to the regional image are determined based on each defect feature, that is, the corresponding filtering parameters, defect segmentation parameters and feature extraction parameters are set respectively, so as to perform preset algorithm detection on the regional image based on the preset algorithm.
[0102] Specifically, refer to Figure 4 When detecting a regional image, a corresponding filter is used to perform defect filtering based on the defect features corresponding to the regional image. For example, if the defect features of the regional image are divided based on the defect shape, when it is detected that the regional image has point defects, linear defects and surface defects, the filter 1 corresponding to the point defect, the filter 2 corresponding to the linear defect and the filter 3 corresponding to the surface defect are used to perform defect filtering on the regional image respectively. Further, point defects are used for illustration. Due to the differences in point defects, for example, point defects 1 with an image clarity within a first preset range and point defects 2 with an image clarity within a second preset range are used. After the filter 1 performs defect filtering on the regional image, the corresponding segmentation parameters are set according to the defect characteristics of the point defects to perform defect segmentation on the filtered regional image, such as performing image binarization processing on the filtered regional image to obtain a corresponding binary image, and then performing feature screening on the binary image based on preset feature screening parameters to output a corresponding defect image, and further, before outputting the defect image, the coordinate information and defect feature information (defect type, defect size, etc.) of the defect image are obtained, and the coordinate information and defect feature information of the defect image are used as identification information of the defect image, and the identification information of the defect image is output together with the defect image.
[0103] The defect detection method proposed in this embodiment obtains a target image and divides the target image into regions to obtain a plurality of regional images, then obtains the regional feature identifiers of each of the plurality of regional images, and determines the defect features corresponding to the regional feature identifiers of each regional image, and finally outputs the defect images corresponding to each regional image based on the defect features. Various defects of different sizes that may appear at various positions on the image can be detected and output, thereby improving the flexibility of defect detection and the accuracy of defect detection results, thereby improving user experience.
[0104] Based on the first embodiment, a second embodiment of the method of the present invention is proposed. In this embodiment, step S302 further includes:
[0105] Step S3021, performing pre-filtering processing on the regional image based on the filtering parameters corresponding to the regional image to obtain a filtered image;
[0106] Step S3022, performing defect segmentation on the filtered image based on the segmentation parameters corresponding to the regional image to obtain a binary image;
[0107] Step S3023: Based on the feature parameters, feature screening is performed on the binary image to determine a defect image corresponding to the binary image, and the defect image is output.
[0108] In this step, after setting the algorithm parameters corresponding to the defect features of each regional image respectively, the regional image is detected by a preset algorithm based on the algorithm parameters corresponding to the regional image, wherein the detection parameters include filtering parameters, segmentation parameters and feature parameters. Specifically, refer to Figure 4 , based on the N-ary tree traversal principle, the regional image is detected in turn with the preset algorithm under the corresponding filtering parameters, segmentation parameters and feature parameters. Specifically, if the input target image is I(x,y), the brightness distribution information corresponding to the target image I(x,y) is obtained to obtain the regional image with abnormal brightness in the target image I(x,y), and then the regional image with abnormal brightness in the target image I(x,y) is filtered based on the filtering parameters corresponding to the regional image. Optionally, a morphological filtering method is used to enhance the abnormal brightness area and suppress the background. Specifically, the filtering parameters of the regional image with abnormal brightness in the target image I(x,y) are obtained, and then the corresponding filter F(n) is selected according to the filtering parameters. Finally, after setting the corresponding filtering parameters for the filter F(n), the target image I(x,y) is filtered to obtain the filtering result image R(x,y), where R(x,y)=F(I(x,y)).
[0109] Then, the defect segmentation of the filtered image R(x, y) is performed according to the corresponding segmentation parameters. The specific method can adopt the image binarization OTSU method, or the adaptive binarization method, that is, the filtered image R(x, y) is binarized based on the corresponding binarization function to obtain the binary image B(x, y), and then the segmented binary image B(x, y) is subjected to feature screening to determine the defect image corresponding to the binary image, and the defect image is output.
[0110] Specifically, step S3023 includes:
[0111] Performing a connected domain analysis on the binary image to obtain a connected domain set of the binary image;
[0112] Based on the feature parameters, feature screening is performed on each connected domain of the connected domain set of the binary image one by one to determine a defect image corresponding to the binary image, and the defect image is output.
[0113] In this step, each connected domain {C1, C2, C3, ..., Cn} of the binary image B(x, y) is extracted, and features are extracted for each connected domain, wherein the features include multiple features such as region size, length, width, contrast, rectangularity, circularity, aspect ratio, etc., that is, based on the above multiple features, feature screening is performed on each connected domain of the connected domain set of the binary image one by one to determine the defect image corresponding to the binary image, and the defect image is output.
[0114] Specifically, feature extraction is performed on each connected domain of the connected domain set of the binary image one by one to obtain a feature set corresponding to each connected domain;
[0115] Obtaining a feature value corresponding to each feature in the feature set corresponding to the connected domain, and comparing the feature value with a standard feature value to obtain a defect determination result corresponding to the connected domain;
[0116] Based on the defect determination result corresponding to each connected domain of the connected domain set, a defect image corresponding to the binary image is determined.
[0117] In this step, after extracting features from each connected domain, the feature set of the connected domain Cn is obtained as {F1, F2, F3, ..., Fk}. Finally, according to the known defect features, feature screening is performed on each connected domain to finally obtain the defect area. Furthermore, feature screening is performed according to the following principles: when Fk is within the standard threshold range, let Sk=1; when Fk is not within the standard threshold range, let Sk=0, and finally let Dn=Sk*Sk*Sk*,...,Sk*R(x,y)=F(I(x,y)). When Dn is equal to 1, it means that area Cm is a defective area, otherwise it is a normal area. Based on the above feature screening principles, the defective image corresponding to the binary image B(x,y) is obtained, that is, the defective area Cm where Dn is equal to 1 in the connected domain {C1,C2,C3,…,Cn} corresponding to the binary image B(x,y), and then the coordinate information and defect feature information of the defective area Cm are used as the identification information of the defective image, and the identification information of the defective image is output together with the defective image.
[0118] The defect detection method proposed in this embodiment performs pre-filtering processing on the regional image based on the filtering parameters corresponding to the regional image to obtain a filtered image, performs defect segmentation on the filtered image based on the segmentation parameters corresponding to the regional image to obtain a binary image, performs feature screening on the binary image based on the feature parameters to determine the defect image corresponding to the binary image, and outputs the defect image. Various defects of different sizes that may appear at various positions on the image can be detected, thereby improving the flexibility of defect detection and the accuracy of defect detection results, thereby improving user experience.
[0119] In addition, an embodiment of the present invention further provides a defect detection device, the defect detection device comprising:
[0120] A first acquisition module is used to acquire a target image and divide the target image into regions to acquire a plurality of region images;
[0121] A second acquisition module is used to respectively acquire a regional feature identifier of each of the plurality of regional images, and respectively determine a defect feature corresponding to the regional feature identifier of each regional image;
[0122] The output module is used to output the defect image corresponding to each regional image based on the defect feature.
[0123] Wherein, when the defect detection device is executed by a processor, the steps of each embodiment of the defect detection method described above are implemented.
[0124] In addition, an embodiment of the present invention further proposes a computer-readable storage medium, on which a defect detection program is stored. When the defect detection program is executed by a processor, the steps of each embodiment of the defect detection method described above are implemented.
[0125] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0126] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0127] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0128] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A defect detection method, It is characterized in that The defect detection method comprises the following steps: Acquire a target image, and divide the target image into regions to obtain a plurality of region images; Respectively obtaining a region feature identifier of each region image in a plurality of region images, and respectively determining a defect feature corresponding to the region feature identifier of each region image, wherein the region feature identifier includes a pixel identifier of the region and / or a defect identifier of the region; Based on the defect features, outputting defect images corresponding to each regional image respectively; The step of outputting the defect image corresponding to each regional image based on the defect feature comprises: Determine algorithm parameters corresponding to each regional image based on defect features corresponding to the regional image, wherein the algorithm parameters include filtering parameters, segmentation parameters and feature parameters; Based on the algorithm parameters corresponding to the regional image, the regional image is tested using a preset algorithm to output a defect image corresponding to the regional image; The step of performing a preset algorithm detection on the regional image based on the algorithm parameters corresponding to the regional image to output a defect image corresponding to the regional image includes: Based on the N-ary tree traversal principle, the region image is sequentially tested with a preset algorithm corresponding to the filtering parameters, the segmentation parameters and the feature parameters to output a defect image corresponding to the region image.
2. The defect detection method according to claim 1, It is characterized in that The step of acquiring the target image comprises: When the product to be inspected is placed on the defect inspection platform, a target image of the product to be inspected is collected based on the camera device of the defect inspection platform.
3. The defect detection method according to claim 1, It is characterized in that The step of dividing the target image into regions to obtain a plurality of regional images comprises: Acquire product feature information of the product to be inspected, and / or perform pixel screening on the target image to obtain a pixel defect area corresponding to the target image; Based on the product feature information and / or the pixel defect area corresponding to the target image, the target image is divided into regions to obtain a plurality of regional images, and regional feature identification is performed on the plurality of regional images.
4. The defect detection method according to claim 1, It is characterized in that The step of performing a preset algorithm detection on the regional image based on the algorithm parameters corresponding to the regional image to output a defect image corresponding to the regional image includes: Based on the filtering parameters corresponding to the regional image, pre-filtering the regional image to obtain a filtered image; Based on the segmentation parameters corresponding to the regional image, defect segmentation is performed on the filtered image to obtain a binary image; Based on the characteristic parameters, feature screening is performed on the binary image to determine a defect image corresponding to the binary image, and the defect image is output.
5. The defect detection method according to claim 4, It is characterized in that The step of performing feature screening on the binary image based on the feature parameters to determine the defect image corresponding to the binary image comprises: Performing a connected domain analysis on the binary image to obtain a connected domain set of the binary image; Based on the feature parameters, feature screening is performed on each connected domain of the connected domain set of the binary image one by one to determine a defect image corresponding to the binary image, and the defect image is output.
6. The defect detection method according to claim 5, It is characterized in that The step of performing feature screening on each connected domain of the connected domain set of the binary image one by one to determine the defect image corresponding to the binary image comprises: Extracting features from each connected domain of the connected domain set of the binary image one by one to obtain a feature set corresponding to each connected domain; Obtaining a feature value corresponding to each feature in the feature set corresponding to the connected domain, and comparing the feature value with a standard feature value to obtain a defect determination result corresponding to the connected domain; Based on the defect determination result corresponding to each connected domain of the connected domain set, a defect image corresponding to the binary image is determined.
7. A defect detection device, It is characterized in that The defect detection device comprises: A first acquisition module is used to acquire a target image and divide the target image into regions to acquire a plurality of region images; A second acquisition module is used to respectively acquire a regional feature identifier of each regional image in a plurality of regional images, and respectively determine a defect feature corresponding to the regional feature identifier of each regional image, wherein the regional feature identifier includes a regional pixel identifier and / or a regional defect identifier; An output module, used for outputting defect images corresponding to each regional image based on the defect features; The output module is further used to determine the algorithm parameters corresponding to each regional image based on the defect features corresponding to the regional image, wherein the algorithm parameters include filtering parameters, segmentation parameters and feature parameters; based on the algorithm parameters corresponding to the regional image, perform a preset algorithm detection on the regional image to output the defect image corresponding to the regional image; The output module is also used to perform preset algorithm detection on the regional image in sequence according to the filtering parameters, the segmentation parameters and the feature parameters based on the N-ary tree traversal principle, so as to output a defect image corresponding to the regional image.
8. A defect detection device, It is characterized in that The defect detection device comprises: a memory, a processor, and a defect detection program stored in the memory and executable on the processor, wherein the defect detection program implements the steps of the defect detection method according to any one of claims 1 to 6 when executed by the processor.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a defect detection program, and when the defect detection program is executed by a processor, the steps of the defect detection method according to any one of claims 1 to 6 are implemented.
