Defect detection method and device, computer device and medium

By acquiring regional illumination and synthesizing images of the workpiece under test, combined with edge detection and global threshold segmentation algorithms, the problem of low defect detection accuracy in existing technologies is solved, and accurate extraction and efficient detection of defects are achieved.

CN116402781BActive Publication Date: 2026-03-17GUANGDONG LYRIC ROBOT INTELLIGENT AUTOMATION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing technologies have low defect detection accuracy in device appearance inspection, are greatly affected by lighting conditions, and are difficult to accurately extract minute defects, resulting in low detection efficiency and poor accuracy.

Method used

By acquiring images of a portion of the workpiece under test under illumination, performing feature segmentation and image synthesis, and combining edge detection algorithms and global threshold segmentation algorithms, defect information is extracted.

Benefits of technology

It enables precise extraction of defect edges, improves the accuracy and precision of defect detection, and enhances the uniformity and efficiency of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116402781B_ABST
    Figure CN116402781B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a defect detection method and device, computer equipment and medium, and belong to the technical field of image detection. The method comprises: illuminating at least a part of a workpiece to be measured each time and collecting images of the workpiece to be measured to obtain multiple workpiece images, wherein the workpiece images comprise an overall image obtained by illuminating the workpiece to be measured as a whole and collecting images; dividing features of the overall image to obtain a feature area; synthesizing the overall image and the multiple workpiece images to obtain a target synthesis image; detecting features of the target synthesis image based on a preset edge detection algorithm and a global threshold segmentation algorithm to determine target defect information corresponding to the feature area. The embodiments of the present application can realize accurate extraction of defect edges and improve the accuracy of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image detection technology, and in particular to a defect detection method, apparatus, computer equipment, and medium. Background Technology

[0002] In the process of visual inspection of components, manual inspection of product appearance quality is inefficient, labor-intensive, and has poor inspection accuracy. It is also greatly affected by objective factors such as the skill level of personnel, which can easily cause fluctuations in the appearance quality of the carrier tape product, affecting the accuracy of the inspection. Related technologies often require photographic acquisition of the components. Users analyze these photographs to determine whether the components have defects or damage. In the process of visual inspection, commonly used defect detection methods often utilize edge extraction algorithms to analyze the smoothness and unevenness of contours and edges. However, with changes in lighting conditions, existing technologies cannot detect subtle defects, and edge extraction algorithms cannot accurately extract edges. This leads to difficulty in distinguishing defect features and a decrease in defect detection accuracy. Summary of the Invention

[0003] The main objective of this application is to provide a defect detection method, apparatus, computer equipment, and medium that can accurately extract defect edges and improve the accuracy of defect detection.

[0004] To achieve the above objectives, a first aspect of this application provides a defect detection method, the method comprising:

[0005] Each time, at least a portion of the workpiece to be tested is illuminated and an image of the workpiece is acquired, resulting in multiple workpiece images. The workpiece images include an overall image acquired by illuminating the entire workpiece.

[0006] The overall image is segmented into feature regions;

[0007] The overall image and multiple workpiece images are combined to obtain a target composite image;

[0008] Based on a preset edge detection algorithm and a global threshold segmentation algorithm, feature detection is performed on the target composite image to determine the target defect information corresponding to the feature region.

[0009] In some embodiments, the step of performing feature detection on the target composite image based on a preset edge detection algorithm and a global threshold segmentation algorithm to determine the target defect information corresponding to the feature region includes:

[0010] The edge information of the target composite image is extracted according to the edge detection algorithm to obtain the edge image corresponding to the feature region;

[0011] The target threshold is obtained by setting a threshold for the edge image based on the global threshold segmentation algorithm.

[0012] Gray values ​​are extracted from all elements in the edge image to obtain multiple gray value information;

[0013] The target defect information is determined by binarizing all the grayscale values ​​according to the target threshold.

[0014] In some embodiments, the step of extracting edge information from the target composite image according to the edge detection algorithm to obtain an edge image corresponding to the feature region includes:

[0015] Based on a preset sampling direction, feature sampling is performed on the target composite image to obtain a grayscale curve;

[0016] The grayscale curve is differentiated according to the edge detection algorithm to obtain multiple grayscale abrupt change locations.

[0017] A region of interest is generated based on multiple grayscale abrupt change points;

[0018] The target composite image is cropped according to the region of interest to obtain the edge image corresponding to the feature region.

[0019] In some embodiments, the step of binarizing all the grayscale value information according to the target threshold to determine the target defect information includes:

[0020] The target threshold is compared with each of the grayscale values ​​to obtain a first set of elements and a second set of elements, wherein the elements in the first set of elements are those whose grayscale values ​​are greater than or equal to the target threshold, and the elements in the second set of elements are those whose grayscale values ​​are less than the target threshold.

[0021] The elements in the first element set are marked according to the preset first state value to determine the feature region;

[0022] The elements in the second element set are marked according to the preset second state value to determine the normal region;

[0023] The target defect information is obtained by performing feature representation on the feature region and the normal region.

[0024] In some embodiments, the step of image synthesis of the overall image and multiple workpiece images to obtain a target composite image includes:

[0025] Weighted bias processing is performed on multiple workpiece images to obtain multiple biased images;

[0026] Multiple bias channels are determined based on the bias image, and the bias image and the bias channels are combined to obtain a composite image.

[0027] The cross-union ratio (CUNR) of the composite image and the feature regions is calculated based on a preset blob tool to obtain the CUNR value.

[0028] The target composite image is determined based on the cross-union ratio, the composite image, and the preset cross-union ratio conditions.

[0029] In some embodiments, the calculation of the intersection-union ratio (IU) of the composite image and the feature regions based on a preset blob tool to obtain the IU value includes:

[0030] The feature width, feature height, and center point coordinates are determined based on the feature region.

[0031] The composite image is binarized to obtain the first feature region of the composite image;

[0032] The first feature region is segmented using the blob tool to obtain the second feature region;

[0033] The width, height, and coordinates of the synthesized feature center point are determined based on the second feature region.

[0034] The intersection-union ratio (IUGR) is calculated for the feature width, feature height, center point coordinates, composite feature width, composite feature height, and composite center point coordinates to obtain the IUGR value.

[0035] In some embodiments, determining the target composite image based on the intersection-union ratio, the composite image, and a preset intersection-union ratio condition includes:

[0036] The intersection-union ratio is compared with the preset intersection-union ratio condition;

[0037] If the cross-union ratio satisfies the cross-union ratio condition, the target composite graph is determined based on the composite graph;

[0038] or,

[0039] If the crossover-union ratio does not meet the crossover-union ratio condition, the weighted bias processing is continued on multiple workpiece images to obtain an iterative crossover-union ratio until the iterative crossover-union ratio meets the crossover-union ratio condition.

[0040] A second aspect of this application provides a defect detection device, the device comprising:

[0041] The image acquisition module is used to illuminate at least a portion of the workpiece to be tested each time and acquire images of the workpiece to be tested, thereby obtaining multiple workpiece images, wherein the workpiece images include an overall image obtained by illuminating the entire workpiece to be tested.

[0042] The feature segmentation module is used to segment the overall image into feature regions.

[0043] An image synthesis module is used to synthesize the overall image and multiple workpiece images to obtain a target composite image;

[0044] The defect determination module is used to perform feature detection on the target composite image based on a preset edge detection algorithm and a global threshold segmentation algorithm, and determine the target defect information corresponding to the feature region.

[0045] A third aspect of this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor is used to perform a defect detection method as described in any one of the embodiments of the first aspect of this application.

[0046] A fourth aspect of this application provides a storage medium, which is a computer-readable storage medium storing a computer program. When the computer program is executed by a computer, the computer is used to perform the defect detection method as described in any one of the embodiments of the first aspect of this application.

[0047] The defect detection method, apparatus, computer equipment, and medium proposed in this application have the following beneficial effects: First, at least a portion of the workpiece to be tested is illuminated and images of the workpiece are acquired to obtain multiple workpiece images. The overall image in the workpiece images is then divided into specific feature regions, facilitating accurate identification of defects in the feature regions. Next, the overall image and multiple workpiece images are synthesized to obtain a target composite image, achieving uniform imaging of the composite image and improving the accuracy of defect detection. Finally, based on a preset edge detection algorithm and a global threshold segmentation algorithm, feature detection is performed on the target composite image, which can accurately determine the edge contours of the feature regions, thereby determining the target defect information corresponding to the feature regions, achieving accurate detection of defect information, and improving the accuracy of defect location in the workpiece to be tested. Attached Figure Description

[0048] Figure 1 This is a flowchart of a defect detection method provided in one embodiment of this application;

[0049] Figure 2 yes Figure 1 The detailed flowchart of step S104;

[0050] Figure 3 yes Figure 2 The detailed flowchart of step S201;

[0051] Figure 4 yes Figure 2 The detailed flowchart of step S204;

[0052] Figure 5 yes Figure 1 The detailed flowchart of step S103;

[0053] Figure 6 yes Figure 5 The detailed flowchart of step S503;

[0054] Figure 7 yes Figure 5 The detailed flowchart of step S504;

[0055] Figure 8 This is a schematic diagram of the defect detection device provided in the embodiments of this application;

[0056] Figure 9 This is a schematic diagram of the hardware structure of the computer device provided in the embodiments of this application. Detailed Implementation

[0057] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0058] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0060] The defect detection method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, or smartwatch, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms; the software can be an application implementing the above method, but is not limited to the above forms.

[0061] The embodiments of this application can be used in numerous general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer computer devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0062] Please refer to Figure 1 , Figure 1 This is a flowchart of a specific method of the defect detection method provided in the embodiments of this application. In some embodiments, the defect detection method includes, but is not limited to, steps S101 to S104.

[0063] Step S101: Illuminate at least a portion of the workpiece to be tested each time and acquire images of the workpiece to be tested to obtain multiple workpiece images.

[0064] It should be noted that the workpiece image includes the overall image obtained by illuminating the entire workpiece under test.

[0065] In some embodiments, a light source emitter is provided above the workpiece to be tested. The light source emitter is turned on or off by a light source controller. During each illumination of the workpiece to be tested, the rear area, left area, front area, right area, and overall illumination of the light source emitter are controlled sequentially so that at least a part of the workpiece to be tested is illuminated. Images of the workpiece to be tested in different illuminated areas are acquired to obtain multiple workpiece images, which are convenient for subsequent image synthesis.

[0066] Understandably, during the image acquisition process of the workpiece under test, the rear quarter light source emitter can be turned on first to trigger the camera to take a picture and obtain the first image. Then, the left quarter light source emitter, the front quarter light source emitter, the right quarter light source emitter, and the overall light source emitter can be turned on in sequence to obtain the second image, the third image, the fourth image, and the overall image. The first image, the second image, the third image, the fourth image, and the overall image can be integrated to obtain multiple workpiece images.

[0067] It is worth noting that the activation sequence of the light source emitter and the illumination area can be adjusted according to the user's needs in this embodiment, and this embodiment does not impose any specific restrictions.

[0068] Step S102: Perform feature segmentation on the overall image to obtain feature regions;

[0069] In some embodiments, the overall image is segmented into features, and a distinct feature is defined in the overall image to obtain a feature region, which facilitates the subsequent calculation of defect features.

[0070] Step S103: Combine the overall image and multiple workpiece images to obtain the target composite image;

[0071] In some embodiments, image synthesis is performed on the overall image and multiple workpiece images. In this embodiment, the image synthesis is based on multi-channel image synthesis to obtain a target composite image, which facilitates subsequent location operations for target defect information.

[0072] Step S104: Based on the preset edge detection algorithm and global threshold segmentation algorithm, feature detection is performed on the target composite image to determine the target defect information corresponding to the feature region.

[0073] It should be noted that the preset edge detection algorithm can be the Sobel operator algorithm, the differential edge detection method, the Laplacian edge detection operator algorithm, etc., and the Sobel operator algorithm is used in this embodiment.

[0074] In some embodiments, steps S101 to S104 involve: first, illuminating at least a portion of the workpiece to be tested and acquiring images of the workpiece to obtain multiple workpiece images; then, dividing the overall image of the workpiece into specific feature regions to facilitate accurate identification of defects in these feature regions; next, synthesizing the overall image and multiple workpiece images to obtain a target composite image, achieving uniform imaging of the composite image and improving the accuracy of defect detection; finally, performing feature detection on the target composite image based on a preset edge detection algorithm and a global threshold segmentation algorithm, accurately determining the edge contours of the feature regions, thereby determining the target defect information corresponding to the feature regions, achieving accurate detection of defect information, and improving the accuracy of defect localization in the workpiece to be tested.

[0075] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating step S104 as provided in an embodiment of this application. In some embodiments, step S104 may include, but is not limited to, steps S201 and S204.

[0076] Step S201: Extract edge information from the target composite image using an edge detection algorithm to obtain an edge image corresponding to the feature region;

[0077] Step S202: Set a threshold for the edge image based on the global threshold segmentation algorithm to obtain the target threshold;

[0078] Step S203: Extract grayscale values ​​from all elements in the edge image to obtain multiple grayscale value information;

[0079] Step S204: Binarize all grayscale information according to the target threshold to determine the target defect information.

[0080] In steps S201 to S204 of some embodiments, edge information is extracted from the target composite image according to the edge detection algorithm, the location of the feature region is located, and the edge image corresponding to the feature region is obtained. Then, a threshold is set on the edge image based on the global threshold segmentation algorithm to obtain the target threshold, wherein the target threshold is a set specified gray value threshold. Then, gray values ​​are extracted from all elements in the edge image to obtain gray value information corresponding to each element. Finally, all gray value information is binarized according to the target threshold, and the image that meets the set threshold is extracted to determine the target defect information, thereby realizing the accurate extraction of target defect information, which facilitates the subsequent positioning of target defect information and improves the processing accuracy of the workpiece.

[0081] Please refer to Figure 3 , Figure 3This is a flowchart illustrating step S201 provided in an embodiment of this application. In some embodiments, step S201 includes, but is not limited to, steps S301 and S304.

[0082] Step S301: Perform feature sampling on the target composite image based on a preset sampling direction to obtain a grayscale curve;

[0083] Step S302: Perform a derivative operation on the grayscale curve according to the edge detection algorithm to obtain multiple grayscale abrupt change location points;

[0084] Step S303: Generate the region of interest based on multiple gray-scale abrupt change locations;

[0085] Step S304: Based on the region of interest, the target composite image is cropped to obtain the edge image corresponding to the region of interest.

[0086] In steps S301 to S304 of some embodiments, during the process of extracting edge information from the target composite image, the target composite image is first sampled based on a preset sampling direction to obtain the gray value curve in the sampling direction. Then, the gray value curve is differentiated according to the edge detection algorithm to obtain multiple gray value abrupt change points, and gray value abrupt change positioning points are obtained. Then, the edges are determined based on the multiple gray value abrupt change positioning points to generate a region of interest (ROI). Finally, the ROI is extracted from the target composite image to obtain the edge image corresponding to the ROI.

[0087] Please refer to Figure 4 , Figure 4 This is a flowchart illustrating step S204 as provided in an embodiment of this application. In some embodiments, step S204 may include, but is not limited to, steps S401 and S404.

[0088] Step S401: Compare the target threshold with each grayscale value to obtain the first element set and the second element set;

[0089] It should be noted that the elements in the first element set are those with grayscale values ​​greater than or equal to the target threshold, while the elements in the second element set are those with grayscale values ​​less than the target threshold.

[0090] Step S402: Mark the elements in the first element set according to the preset first state value to determine the feature region;

[0091] Step S403: Mark the elements in the second element set according to the preset second state value to determine the normal region;

[0092] Step S404: Perform feature representation on the feature region and the normal region to obtain target defect information.

[0093] In steps S401 to S404 of some embodiments, the target threshold is compared with the grayscale value information of each element. Elements greater than or equal to the target threshold are divided into a first element set, and elements less than the target threshold are divided into a second element set. Then, the elements in the first element set are marked according to a preset first state value so that the elements in the first element set can be displayed, and the feature area of ​​the display state is determined. Then, the elements in the second element set are marked according to a preset second state value so that the elements in the second element set are in a transparent state, i.e., a hidden state, and the normal area of ​​the transparent state is determined. Finally, the feature area and the normal area are feature-expressed to maximize the highlighting of the defect feature area and obtain the target defect information, thereby realizing the location of the target defect information and improving the accuracy of defect detection.

[0094] It should be noted that in this embodiment, the first element set and the second element set are binarized to 0 / 255. The preset first state value is set to 255 and the second state value is set to 0. Therefore, the elements in the first element set are set to 255 and the elements in the second element set are set to 0, thereby achieving clear marking of defect information, which facilitates the subsequent positioning and inspection of the workpiece.

[0095] Please refer to Figure 5 , Figure 5 This is a flowchart illustrating step S103 provided in an embodiment of this application. In some embodiments, step S103 includes, but is not limited to, steps S501 and S504.

[0096] Step S501: Perform weighted bias processing on multiple workpiece images to obtain multiple biased images;

[0097] In some embodiments, each workpiece image is subjected to weighted bias processing to obtain multiple bias images, thereby making the image brightness of the bias images uniform and avoiding the situation where the image brightness is too bright or too dark.

[0098] It should be noted that in the process of weighted bias processing of workpiece images, the original grayscale value of each workpiece image needs to be obtained first. Then, the grayscale value of each workpiece image is weighted and biased based on the preset offset value and weight value to obtain multiple biased images. This allows the grayscale value of brighter areas of the workpiece image to be reduced, while the grayscale value of darker areas to be increased, thereby improving the overall uniformity of image brightness.

[0099] It is worth noting that in the process of weighted bias processing, the image weight value corresponding to the workpiece image is first determined in the randomly generated weight matrix of the workpiece image, and the image offset value corresponding to the workpiece image is determined in the preset offset value. Then, the image grayscale value is weighted and biased according to the image weight value and the image offset value to obtain the target grayscale value. Finally, the brightness of the workpiece image is adjusted according to the target grayscale value, so that the grayscale value of the brighter parts of the workpiece image is reduced and the grayscale value of the darker parts is increased. This process is repeated for each workpiece image, and weighted bias processing is performed to obtain multiple biased images with uniform brightness.

[0100] It should be noted that the specific weighted bias calculation process is shown in the following formula (1):

[0101] y = a1*x + b1 (1)

[0102] Where a1 represents the image weight value, b1 represents the image offset value, x represents the image gray value, and y is the target gray value after weighted bias.

[0103] Step S502: Determine multiple bias channels based on the bias image, and perform image synthesis on the bias image and the bias channels to obtain a composite image;

[0104] In some embodiments, a bias channel corresponding to each bias image is determined based on the bias image, and the bias image and the bias channel are image-synthesized to obtain a new and complete composite image, thereby realizing the image synthesis.

[0105] It should be noted that during the image synthesis process, it is first necessary to obtain each pixel of the bias image, then sort the bias image to obtain the bias sequence, so as to avoid the image order being disordered during the synthesis process, which would lead to the disorder of the synthesized image area. Finally, the pixels and the bias channels corresponding to each bias image are added according to the bias sequence to obtain the synthesized image.

[0106] It should be noted that the coefficients multiplied by each pixel in the bias image will not exceed 1, and the overall pixel grayscale value will not exceed 255, thereby avoiding data overflow.

[0107] Step S503: Calculate the cross-union ratio (CUI) of the composite image and feature regions based on a preset blob tool to obtain the CUI value;

[0108] In some embodiments, the cross-union ratio (CUI) of the synthesized image and defect feature information is calculated based on a preset blob tool to obtain the CUI value, thereby improving the image accuracy of the synthesized image and solving the problem of uneven defect imaging.

[0109] Step S504: Determine the target composite image based on the crossover-union ratio, the composite image, and the preset crossover-union ratio conditions.

[0110] In some embodiments, the cross-union ratio (CUP) is compared with a preset CUP condition to determine whether the current composite image meets the CUP condition requirements, and the target composite image is determined based on the determination result, thereby achieving uniform imaging.

[0111] Please refer to Figure 6 , Figure 6 This is a flowchart illustrating step S503 provided in an embodiment of this application. In some embodiments, step S503 includes, but is not limited to, steps S601 and S605.

[0112] Step S601: Determine the feature width, feature height, and center point coordinates based on the feature region;

[0113] In some embodiments, the feature width, feature height, and center point coordinates of the feature are first determined based on the feature region of the overall image, denoted as w0, h0, and (x0, y0).

[0114] Step S602: Perform grayscale binarization on the composite image to obtain the first feature region of the composite image;

[0115] In some embodiments, the composite image is binarized to highlight the defect features in the composite image, thereby obtaining the first feature region and improving the efficiency of defect feature finding.

[0116] Step S603: The first feature region is segmented by a threshold based on a preset blob tool to obtain the second feature region;

[0117] In some embodiments, a second feature region is obtained by threshold segmentation of the first feature region based on a preset blob tool. In the process of threshold segmentation, the area of ​​the composite image needs to be combined for segmentation, and the segmented results are filtered to obtain the second feature region.

[0118] Step S604: Determine the width of the synthesized feature, the height of the synthesized feature, and the coordinates of the synthesized center point based on the second feature region;

[0119] In some embodiments, the composite feature width w1, composite feature height h1, and composite center point coordinates (x1, y1) are determined based on the second feature region to facilitate subsequent cross-union ratio calculation.

[0120] Step S605: Calculate the intersection-union ratio (IUGR) of the feature width, feature height, center point coordinates, composite feature width, composite feature height, and composite center point coordinates to obtain the IUGR value.

[0121] In some embodiments, the intersection-union ratio of the second feature region and the feature region is calculated based on the width, height and coordinate points, thereby determining whether the synthesized image meets the standard and achieving uniform imaging of defect features.

[0122] Please refer to Figure 7 , Figure 7 This is a flowchart illustrating step S504 as provided in an embodiment of this application. In some embodiments, step S504 includes, but is not limited to, steps S701 and S703.

[0123] Step S701: Compare the crossover-union ratio with the preset crossover-union ratio conditions;

[0124] Step S702: If the crossover-union ratio satisfies the crossover-union ratio condition, determine the target composite map based on the composite map.

[0125] In steps S701 to S702 of some embodiments, the cross-union ratio is compared with the preset cross-union ratio conditions. If the cross-union ratio meets the cross-union ratio conditions, it indicates that the composite image has reached the specified specifications and can be directly used as the target composite image.

[0126] It should be noted that the intersection-union ratio conditions can be set by the user according to their needs, and this embodiment does not impose specific restrictions.

[0127] Step S703: If the crossover-union ratio does not meet the crossover-union ratio condition, continue to perform weighted bias processing on multiple workpiece images to obtain an iterative crossover-union ratio until the iterative crossover-union ratio meets the crossover-union ratio condition.

[0128] In some embodiments, during the comparison of the cross-union ratio with the preset cross-union ratio conditions, if the cross-union ratio does not meet the cross-union ratio conditions, it indicates that the composite image at this time does not meet the specified specifications. In this case, steps S501-S503 need to be repeated, that is, the weighted bias processing of multiple workpiece images is continued, and the weights are iteratively optimized until the iterative cross-union ratio meets the cross-union ratio conditions. The iterative composite image corresponding to the iterative cross-union ratio is then used as the target composite image.

[0129] Please see Figure 8 This application also provides a defect detection device that can implement the above-described defect detection method. The device includes:

[0130] The image acquisition module 801 is used to illuminate at least a portion of the workpiece to be tested each time and to acquire images of the workpiece to be tested, thereby obtaining multiple workpiece images. The workpiece images include an overall image of the workpiece to be tested that is illuminated and acquired.

[0131] The feature segmentation module 802 is used to segment the overall image into feature regions;

[0132] The image synthesis module 803 is used to synthesize the overall image and multiple workpiece images to obtain a target composite image.

[0133] The defect determination module 804 is used to perform feature detection on the target composite image based on a preset edge detection algorithm and a global threshold segmentation algorithm, and determine the target defect information corresponding to the feature region.

[0134] The defect detection device in this application embodiment is used to execute the defect detection method in the above embodiment. Its specific processing procedure is the same as the defect detection method in the above embodiment, and will not be described in detail here.

[0135] This application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the defect detection method in the above embodiments of this application.

[0136] Reference Figure 9 , Figure 9 This is a schematic diagram of the hardware structure of the computer device provided in the embodiments of this application.

[0137] The following is combined Figure 9 The hardware structure of the computer device is described in detail. The computer device includes: a processor 910, a memory 920, an input / output interface 930, a communication interface 940, and a bus 950.

[0138] The processor 910 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.

[0139] The memory 920 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 920 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 920 and is called and executed by the processor 910 using the defect detection method of the embodiments of this application.

[0140] The input / output interface 930 is used to implement information input and output;

[0141] The communication interface 940 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.); and the bus 950 is used to transmit information between the various components of the device (such as processor 910, memory 920, input / output interface 930 and communication interface 940).

[0142] The processor 910, memory 920, input / output interface 930 and communication interface 940 are connected to each other within the device via bus 950.

[0143] This application also provides a storage medium, which is a computer-readable storage medium storing a computer program. When the computer program is executed by a computer, the computer is used to perform the defect detection method as described in the above embodiments of this application.

[0144] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0145] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0146] It will be understood by those skilled in the art that Figures 1 to 7 The technical solutions shown do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0147] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0148] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0149] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0150] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0151] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0152] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0153] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0154] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0155] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A defect detection method characterized by, The method comprises: Each time the at least one part of the workpiece is irradiated and the image of the workpiece is collected, a plurality of workpiece images are obtained, wherein the workpiece image comprises an overall image obtained by irradiating the workpiece as a whole and collecting the image; The overall image is divided into features to obtain a feature area; The original image gray value of the plurality of workpiece images is obtained, and the image gray value of each workpiece image is weighted and offset based on a preset offset value and a preset weight value to obtain a plurality of offset images; According to the offset image, a plurality of offset channels are determined, and the offset image and the offset channel are synthesized to obtain a synthesis image; The intersection-over-union ratio of the synthesis image and the feature area is calculated based on a preset spot tool to obtain an intersection-over-union ratio value; The target synthesis image is determined according to the intersection-over-union ratio value, the synthesis image and a preset intersection-over-union ratio condition; The target defect information corresponding to the feature area is determined by performing feature detection on the target synthesis image based on a preset edge detection algorithm and a global threshold segmentation algorithm. The target synthesis image is determined according to the intersection-over-union ratio value, the synthesis image and a preset intersection-over-union ratio condition, comprising: Comparing the intersection-over-union ratio value with the preset intersection-over-union ratio condition; In the case that the intersection-over-union ratio value meets the intersection-over-union ratio condition, the target synthesis image is determined according to the synthesis image; Or, In the case that the intersection-over-union ratio value does not meet the intersection-over-union ratio condition, the weighted offset processing of the plurality of workpiece images is continued to obtain an iterative intersection-over-union ratio value until the iterative intersection-over-union ratio value meets the intersection-over-union ratio condition.

2. The defect detection method of claim 1, wherein The target defect information corresponding to the feature area is determined by performing feature detection on the target synthesis image based on a preset edge detection algorithm and a global threshold segmentation algorithm, comprising: Edge information of the target synthesis image is extracted according to the edge detection algorithm to obtain an edge image corresponding to the feature area; A target threshold is obtained by setting a threshold for the edge image based on the global threshold segmentation algorithm; A plurality of gray value information is obtained by extracting the gray value of all elements in the edge image; The target defect information is determined by binarizing all the gray value information according to the target threshold.

3. The defect detection method according to claim 2, wherein The edge information of the target synthesis image is extracted according to the edge detection algorithm to obtain an edge image corresponding to the feature area, comprising: Feature sampling is performed on the target synthesis image based on a preset sampling direction to obtain a gray value curve; A plurality of gray mutation positioning points are obtained by performing derivation operation on the gray value curve according to the edge detection algorithm; A region of interest is generated according to a plurality of gray mutation positioning points; The target synthesis image is cut according to the region of interest to obtain the edge image corresponding to the region of interest.

4. The defect detection method according to claim 2, characterized by, The target defect information is determined by binarizing all the gray value information according to the target threshold. Comparing the target threshold value with each of the gray value information, a first element set and a second element set are obtained, wherein elements in the first element set are elements whose gray value information is greater than or equal to the target threshold value, and elements in the second element set are elements whose gray value information is less than the target threshold value; According to a preset first state value, elements in the first element set are marked to determine a feature region; According to a preset second state value, elements in the second element set are marked to determine a normal region; The feature region and the normal region are expressed to obtain the target defect information.

5. The defect detection method of claim 1, wherein The Jaccard index of the composite image and the feature region is calculated based on a preset spot tool to obtain a Jaccard index value, including: According to the feature region, a feature width, a feature height, and a center point coordinate are determined; The composite image is subjected to gray value binarization processing to obtain a first feature region of the composite image; The first feature region is subjected to threshold segmentation based on the spot tool to obtain a second feature region; According to the second feature region, a composite feature width, a composite feature height, and a composite center point coordinate are determined; The Jaccard index of the feature width, the feature height, the center point coordinate, the composite feature width, the composite feature height, and the composite center point coordinate is calculated to obtain the Jaccard index value.

6. A defect detection apparatus characterized by comprising: The device comprises: An image acquisition module for illuminating at least a part of a workpiece to be tested each time and acquiring an image of the workpiece to be tested to obtain a plurality of workpiece images, wherein the workpiece images include an overall image obtained by illuminating the workpiece to be tested as a whole and acquiring an image; A feature division module for dividing features of the overall image to obtain a feature region; An image synthesis module for obtaining original image gray values of a plurality of the workpiece images, performing weighted bias processing on the image gray values of each of the workpiece images based on a preset offset value and a preset weight value to obtain a plurality of biased images, determining a plurality of bias channels according to the biased images, and synthesizing the biased images and the bias channels to obtain a composite image; calculating a Jaccard index value based on a preset spot tool for the composite image and the feature region; and determining a target composite image according to the Jaccard index value, the composite image, and a preset Jaccard index condition. The determination of the target composite image according to the Jaccard index value, the composite image, and the preset Jaccard index condition includes comparing the Jaccard index value with the preset Jaccard index condition; in the case where the Jaccard index value meets the Jaccard index condition, determining the target composite image according to the composite image; or in the case where the Jaccard index value does not meet the Jaccard index condition, continuing to perform weighted bias processing on a plurality of the workpiece images to obtain an iterative Jaccard index value until the iterative Jaccard index value meets the Jaccard index condition. The defect determination module is configured to perform feature detection on the target composite image based on a preset edge detection algorithm and a global threshold segmentation algorithm, and determine target defect information corresponding to the feature region.

7. A computer device, comprising: The computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the defect detection method according to any one of claims 1 to 5.

8. A storage medium, characterized by The storage medium is a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer executes the computer program to perform the defect detection method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Glass bottle opening defect detection method, system and device and storage medium

    CN112561896A

  • Defect detection method and device, electronic equipment and storage medium

    CN114841946A