A method, device, equipment and medium for defect detection of industrial products
The corner detection threshold is dynamically adjusted through the Harris corner detection algorithm and the region growth algorithm, which solves the defect missed or mis-checked problems caused by the corner detection algorithm when the threshold is not set at the time, and improves the accuracy and reliability of industrial product defect detection.
Patent Information
- Application Number
- CN202510128268.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-05
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2045-02-05
AI Technical Summary
When using corner detection algorithm to detect industrial products defects, if the threshold is set improperly, it may lead to missed inspection or mis-checking of defect areas, affecting the accuracy of the detection results.
The Harris corner point detection algorithm determines the corner point response values of each pixel point in the image to be detected, and the initial threshold is determined based on these response values. The image is divided into different regions using the region growth algorithm, and the region complexity of each region is calculated to adjust the threshold value to obtain an adaptive threshold value.
The corner detection threshold is dynamically adjusted according to the complexity of different regions, which improves the accuracy and reliability of defect detection and reduces the risk of false alarms.
Smart Images

Figure CN119559180B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a defect detection method, device, equipment and medium for industrial products. Background Art
[0002] With the advancement of science and technology and the acceleration of globalization, the development of industrial products has undergone tremendous changes. As product technology advances, the potential risk of defects also increases. Therefore, it has become particularly important to perform defect detection on industrial products.
[0003] Corner detection is a practical and efficient method for defect detection of industrial products. It accurately captures the geometric shape and structural changes of objects by identifying corner features in images, and is suitable for detecting specific defects such as cracks and gaps. In addition, corner detection is highly robust to changes in illumination and noise, and can maintain stable performance in complex environments such as industrial production environments. However, the selection of the threshold for the corner response value in the corner detection algorithm will affect the number of corners finally detected, and the threshold is pre-set. When the threshold of corner detection is not set properly, important corner features may be ignored, resulting in missed defect detection. In addition, when the threshold of corner detection is not set properly, it may also lead to a significant increase in noise points, which greatly reduces the accuracy of the detection results, leading to misjudgment and waste of resources.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of this application is to provide a defect detection method, device, equipment and medium for industrial products, aiming to solve the technical problem of missed detection and wrong detection of defect areas when the threshold is set improperly when using a corner detection algorithm for defect detection.
[0006] To achieve the above-mentioned purpose, the present application provides a defect detection method for industrial products, comprising: collecting an image to be detected of an industrial product and obtaining a standard image of the industrial product; using a Harris corner detection algorithm to determine a corner point response value of each pixel in the image to be detected, and determining an initial threshold based on the corner point response value of each pixel, wherein the initial threshold of each pixel is the same; based on the corner point response value of each pixel in the image to be detected and using a region growing algorithm, the image to be detected is divided into a plurality of regions; calculating the region complexity of each region, and adjusting the initial threshold of the corresponding region based on the region complexity of each region to obtain an adaptive threshold of each region; using the Harris corner detection algorithm and the adaptive threshold of each region to determine a plurality of corner points of the image to be detected and a plurality of corner points of the standard image, and performing defect detection on the industrial product based on the plurality of corner points of the image to be detected and the plurality of corner points of the standard image.
[0007] Optionally, determining an initial threshold based on the corner point response value of each pixel point includes: constructing a corner point response value histogram using the corner point response values of all pixels in the image to be detected; and determining an initial threshold based on the corner point response value histogram.
[0008] Optionally, the calculating the regional complexity of each region includes: calculating the significance of corner points of each region; calculating the degree of distribution of corner points of each region; and determining the regional complexity of each region based on the significance of corner points and the degree of distribution of corner points of each region.
[0009] Optionally, calculating the saliency of the corner points of each region includes: using the following formula (1) to calculate the saliency of the corner points of each region:
[0010]
[0011] in, Indicates The corner point significance of the region, Indicates The area contained in The corner point response value, Indicates The area contained in The number of pixels corresponding to the corner point response value. Indicates The type of corner point response value contained in the region.
[0012] Optionally, adjusting the initial threshold of the corresponding area based on the regional complexity of each area to obtain the adaptive threshold of each area includes: adjusting the initial threshold based on the regional complexity of each area using the following formula (2) to obtain the adaptive threshold corresponding to each area:
[0013]
[0014] in, Indicates Adaptive thresholding of regions, Indicates The regional complexity of the region, Indicates The maximum value of the corner point response value in the region is Represents the initial threshold.
[0015] Optionally, there is a one-to-one correspondence between each pixel point in the image to be detected and each pixel point in the standard image; before using the Harris corner point detection algorithm and the adaptive threshold of each area to determine a number of corner points of the image to be detected and a number of corner points of the standard image, the method also includes: based on the correspondence, dividing the standard image into a number of areas, wherein each area of the standard image corresponds one-to-one to each area divided by the image to be detected.
[0016] Optionally, the defect detection of industrial products based on several corner points of the image to be detected and several corner points of the standard image includes: generating a feature descriptor of the image to be detected based on several corner points of the image to be detected, and generating a feature descriptor of the standard image based on several corner points of the standard image; comparing the feature descriptor of the image to be detected with the feature descriptor of the standard image to obtain a target area of the image to be detected; performing defect detection on the target area to determine whether the target area is a defective area.
[0017] In addition, to achieve the above-mentioned purpose, the present application also provides a defect detection device for industrial products, including: an image acquisition module, used to acquire the image to be detected of the industrial product and obtain the standard image of the industrial product; an initial threshold determination module, used to determine the corner point response value of each pixel in the image to be detected by using the Harris corner point detection algorithm, and determine an initial threshold based on the corner point response value of each pixel, wherein the initial threshold of each pixel is the same; a region segmentation module, used to divide the image to be detected into a plurality of regions based on the corner point response value of each pixel in the image to be detected and using a region growing algorithm; a threshold improvement module, used to calculate the regional complexity of each region, and adjust the initial threshold of the corresponding region based on the regional complexity of each region to obtain an adaptive threshold of each region; a defect detection module, used to determine a plurality of corner points of the image to be detected and a plurality of corner points of the standard image by using the Harris corner point detection algorithm and the adaptive threshold of each region, and perform defect detection on the industrial product based on the plurality of corner points of the image to be detected and the plurality of corner points of the standard image.
[0018] The present application also provides a defect detection device for industrial products, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned defect detection method for industrial products.
[0019] The present application also provides a computer-readable storage medium, comprising: a computer program stored therein, wherein when the computer program is executed by a processor, the above-mentioned defect detection method for industrial products is implemented.
[0020] The present application proposes a defect detection method, device, equipment and medium for industrial products. First, it is considered that since industrial products have different shapes, if the same corner point response threshold is set for different industrial products, too few corner points will be detected for industrial products with more complex shapes, resulting in the problem of missed defect detection, while too many corner points will be detected for industrial products with simpler shapes, that is, the corner points obtained contain some noise points, resulting in the problem of false defect detection. Therefore, the embodiment of the present application first uses the Harris corner point detection algorithm to determine the corner point response value of each pixel in the image to be detected, and determines the initial threshold based on the corner point response value of each pixel, that is, the initial corner point detection threshold corresponding to the image to be detected of the industrial product is set for different industrial products based on the characteristics of the image to be detected corresponding to the industrial product.
[0021] In addition, the present application also takes into account that different areas on the surface of industrial products have different shapes. If the same corner detection threshold is set for different areas, more corners will appear in areas with complex backgrounds. More corners may contain a large number of irrelevant features, while areas with simple backgrounds have fewer corners, resulting in a lack of sufficient information to describe the shape and structure of the product, all of which affect the accuracy of defect detection. Therefore, the embodiment of the present application divides the image to be detected into several areas, calculates the regional complexity of each area, and adjusts the initial threshold based on the regional complexity of each area to obtain an adaptive threshold corresponding to each area, thereby achieving different corner response thresholds based on the complexity differences of different areas in the industrial product image, so as to set a lower threshold in simple areas to accurately capture details, and set a higher threshold in complex areas to retain features and reduce noise, thereby improving the accuracy and reliability of overall defect detection and reducing the risk of false alarms. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A flowchart of a defect detection method for industrial products according to an embodiment of the present application;
[0023] Figure 2 It is a structural block diagram of a defect detection device for industrial products according to one embodiment of the present application;
[0024] Figure 3 It is a schematic structural diagram of a defect detection device for industrial products according to one embodiment of the present application.
[0025] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0026] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0027] In the prior art, the steps of using the Harris corner detection algorithm to extract corners are generally to first calculate the corner response value of each pixel based on the image gradient information, then select a threshold and extract pixels with higher corner response values based on the threshold, which are considered as corners. Finally, non-maximum suppression is applied to refine the corner detection results to obtain more accurate corner positions.
[0028] Among them, the choice of the corner point response threshold in the Harris algorithm will affect the number of corner points finally detected. However, since the threshold is set artificially in advance and when the surface of the industrial product has complex textures or patterns, if the threshold is set low, more corner points may be retained, resulting in more concentrated corner points, thereby increasing the computational burden of subsequent defect detection based on corner points, and more concentrated corner points will cause some normal areas to be misjudged as defective areas. If the threshold is set high, many corner points with corner point response values lower than the threshold will be screened out, and the number of corner points detected will be significantly reduced, thereby affecting the accuracy of subsequent defect detection based on corner points, that is, some defects may not be detected.
[0029] To solve the above problems, the present application provides a defect detection method, device, equipment and medium for industrial products. The present application scheme is introduced in detail below.
[0030] Figure 1 is a flow chart of a defect detection method for industrial products according to an embodiment of the present application. The defect detection method for industrial products can be performed by a defect detection device with data processing capability. Figure 1 , the defect detection method for industrial products may include the following steps:
[0031] S1, collecting the image of the industrial product to be inspected and obtaining the standard image of the industrial product.
[0032] It should be noted that in this embodiment, when performing defect detection on industrial products, it is necessary to first collect images of the industrial products to be detected. The images of the industrial products to be detected can be images of the industrial products after any component is processed, and the standard images of the industrial products are images of the industrial products without defects. It is understandable that defect detection is required after any component of the industrial products is processed.
[0033] In the specific implementation process, first, a standard image of the industrial product is obtained in the industrial Internet of Things system, then the camera is correctly installed and connected to the defect detection equipment, the position and angle of the camera are adjusted to be consistent with the acquisition angle of the standard image, and finally, the image of the industrial product is acquired to obtain the image to be inspected of the industrial product. The camera can be a high-resolution camera and needs to be kept stable during the acquisition process to ensure the integrity of the details in the image to be inspected.
[0034] In one embodiment, after collecting the image to be inspected of the industrial product and obtaining the standard image of the industrial product, the image to be inspected may be subjected to denoising, enhancement and other processing.
[0035] Among them, the industrial environment is relatively complex and the lighting conditions in the industrial environment are relatively unstable. Strong light, shadows or reflections will affect the uniformity and contrast of the image. Therefore, it is necessary to perform pre-processing such as denoising and enhancement, i.e., lighting balance, on the image to be detected to improve the image quality of the image to be detected. For example, a Gaussian filtering algorithm can be used to perform denoising on the image to be detected, and at the same time, a Gamma correction algorithm can be used to enhance the image to be detected, i.e., perform lighting balance.
[0036] S2, using the Harris corner detection algorithm to determine the corner point response value of each pixel in the image to be detected, and determining an initial threshold based on the corner point response value of each pixel, wherein the initial threshold of each pixel is the same.
[0037] It should be noted that the specific steps of the Harris corner detection algorithm are usually to grayscale the image, calculate the gradients in the x and y directions and construct the Harris matrix, determine the Harris response function, that is, the corner response value, according to the Harris matrix, select a threshold and evaluate the corner strength of each pixel by the size of the corner response value, and finally, perform non-maximum suppression to extract significant corners.
[0038] In the specific implementation process, the Harris corner detection algorithm is used to calculate the corner point response value of each pixel in the image to be detected, where the corner point response value of each pixel reflects the change in the local neighborhood of the pixel, that is, it characterizes the significance of the point as a corner point in the image.
[0039] It should be further explained that if the same corner point response threshold is uniformly set for different industrial products, too few corner points will be detected for industrial products with more complex shapes, resulting in the problem of missed defects; while for industrial products with simpler shapes, too many corner points will be detected, that is, the corner points obtained contain some noise points, resulting in the problem of false defect detection. Therefore, for the defect detection method for industrial products provided in the present application, for different industrial products, the initial corner point response threshold of the image to be detected, that is, the initial threshold, needs to be determined according to the corner point response value of the pixel point in the image to be detected of the corresponding product.
[0040] In one embodiment, in step S2, determining an initial threshold based on the corner point response value of each pixel point may specifically include:
[0041] S21, constructing a corner point response value histogram using the corner point response values of all pixels in the image to be detected;
[0042] S22. Determine an initial threshold value according to the corner point response value histogram.
[0043] In a specific implementation process, a corner point response value histogram is constructed based on the corner point response value of each pixel in the image to be detected, with the corner point response value as the horizontal coordinate and the number of the same corner point response value as the vertical coordinate.
[0044] Furthermore, all the maximum values in the corner point response value histogram are obtained, and the minimum value of the corner point response values among all the maximum values is used as the initial threshold.
[0045] S3, dividing the image to be detected into a plurality of regions based on the corner point response value of each pixel point in the image to be detected and using a region growing algorithm.
[0046] It should be noted that the region growing algorithm is an image segmentation technology based on pixel similarity. Its basic process is to start from one or more seed points, and then check whether its neighboring pixels meet the similarity conditions. If they do, they are added to the current region, and this process is recursively repeated until no more neighboring pixels meet the conditions. Region growing can effectively process images with obvious texture changes and segment the image into several regions.
[0047] In the specific implementation process, the image to be detected is divided into several regions using a region growing algorithm, wherein the seed points of the region growing algorithm can be selected in descending order according to the corner point response values of the pixel points in the image to be detected until the image to be detected is completely divided.
[0048] S4, calculating the regional complexity of each region, and adjusting the initial threshold of the corresponding region based on the regional complexity of each region to obtain an adaptive threshold of each region.
[0049] Among them, regional complexity can characterize the texture complexity of each area in the image to be detected. For example, if a certain area is a complex texture area such as a thread, a gear tooth surface, a weld, etc., the regional complexity of this area is relatively large; and if a certain area is a simple texture area such as a metal shell, a plastic shell, etc., the regional complexity of this area is relatively small.
[0050] It should be noted that, due to the different forms of industrial products, when the surface of an industrial product contains complex texture areas such as gear tooth surfaces, threads, etc., if the corner point response threshold is set low, more corner points will be detected, thereby increasing the computational burden of subsequent defect detection based on corner points. At the same time, the more concentrated corner points may contain a lot of noise and irrelevant features, increasing the complexity of subsequent analysis. When the surface of an industrial product contains a simple texture area, such as a metal shell or a plastic shell of an industrial product, if the corner point response threshold is set high, too few corner points will be detected, and too few corner points may lead to the lack of sufficient information to describe the shape and structure of the product, so that some small defects may not be detected. Therefore, the embodiment of the present application sets different corner point response thresholds based on the complexity differences of different areas in the industrial product image, so that a lower threshold is set in a simple area to accurately capture details, and a higher threshold is set in a complex area to retain features and reduce noise, thereby improving the accuracy and reliability of overall defect detection and reducing the risk of false alarms.
[0051] In a specific implementation process, the corner point response values of all pixels in the image to be detected are first normalized, wherein the normalization process is to map the corner point response value of each pixel to a range from 0 to 1.
[0052] In one embodiment, in step S4, calculating the regional complexity of each region may specifically include:
[0053] S41, calculating the saliency of the corner points of each region;
[0054] S42, calculating the distribution degree of corner points in each area;
[0055] S43. Determine the regional complexity of each region based on the corner point significance and corner point distribution degree of each region.
[0056] In the specific implementation process, for any area, the number of pixel points corresponding to each corner point response value in the area is calculated, and the product of each corner point response value contained in the area and its corresponding number is accumulated to obtain the corner point significance of the area.
[0057] Specifically, the For example, the following formula (1) can be used to calculate the Corner saliency of regions :
[0058]
[0059] in, Indicates The corner point significance of the region, Indicates The area contained in The corner point response value, Indicates The area contained in The number of pixels corresponding to the corner point response value. Indicates The type of corner point response value contained in the region.
[0060] It should be noted that when the background in a certain area is complex, the area contains more pixels with larger corner response values, and then the product obtained by multiplying the larger corner response value in the area with the larger number of pixels corresponding to the corner response value is also larger, so the product of accumulating the product of all corner response values in the area and the number of pixels corresponding to them is also larger, that is, the corner significance of the area is also larger. When the background in a certain area is simple, the number of pixels with larger corner response values in the area is small, and the number of pixels with smaller corner response values is large, so the product of accumulating the product of all corner response values in the area and the number of pixels corresponding to them is also smaller, that is, the corner significance of the area is also smaller.
[0061] Furthermore, for any corner point response value contained in any region, the minimum distance between each pixel and other pixels corresponding to the corner point response value is calculated, and the minimum distances of all pixels are accumulated to obtain the distance distribution value of the corner point response value. The corner point response value is multiplied by the distance distribution value of the corner point response value to obtain the distribution degree of the corner point response value. The distribution degrees of all the corner point response values in the region are accumulated to obtain the corner point distribution degree of the region.
[0062] It should be noted that, when a certain area is relatively complex, that is, when the detected corner points are relatively concentrated, it is reflected in the corner point response value that the pixel points with larger corner point response values in the area are distributed more concentratedly, and then the distance distribution value of each corner point response value in this embodiment can represent the distribution of the pixel points corresponding to the corner point response value, and each corner point response value is multiplied by the distance distribution value of the corner point response value. At this time, each corner point response value can be represented as an enhancement factor, which is used to enhance the degree of the distance distribution value, and then the corner point distribution degree of the area is relatively large. When a certain area is relatively simple, that is, there are fewer corner points detected, the pixel points with smaller corner point response values in the area are distributed more concentratedly, and then the result obtained by multiplying the smaller corner point response value by the distance distribution value of the corner point response value is also smaller, and then the corner point distribution degree of the area is relatively small.
[0063] Furthermore, the product of the corner point significance and the corner point distribution degree of each region is taken as the regional complexity of the region, and the regional complexity of all regions is linearly normalized. It should be noted that the regional complexity can represent the complexity of the pattern or background in each region.
[0064] Further, the For example, based on the The regional complexity of each region can be obtained by adjusting the initial threshold using the following formula (2): The adaptive threshold corresponding to the area :
[0065]
[0066] in, Indicates Adaptive thresholding of regions, Indicates The regional complexity of the region, Indicates The maximum value of the corner point response value in the region is Represents the initial threshold.
[0067] It should be noted that for a simple background area, the corresponding regional complexity is small, and the adaptive threshold of the area obtained based on the regional complexity of the area is close to the initial threshold, and the initial threshold set in this embodiment is small, so the adaptive threshold of the area is also small, so as to accurately capture more details. For a complex background area, the corresponding regional complexity is large, and the adaptive threshold of the area obtained based on the regional complexity of the area is also large, so as to retain the features while reducing the interference of noise.
[0068] S5, using the Harris corner detection algorithm and the adaptive threshold of each area to determine several corner points of the image to be detected and several corner points of the standard image, and performing defect detection on the industrial product based on the several corner points of the image to be detected and several corner points of the standard image.
[0069] It should be noted that when defects occur in industrial products, there will be slight differences between the image to be detected and the standard image, that is, additional corner points will appear at the defects. Therefore, the Harris corner detection algorithm and the adaptive thresholds of each area can be used to first determine several corner points of the image to be detected and several corner points of the standard image, and then defect detection of industrial products can be performed based on several corner points of the image to be detected and several corner points of the standard image.
[0070] In one embodiment, in step S5, there is a one-to-one correspondence between each pixel point in the image to be detected and each pixel point in the standard image. Before determining a number of corner points of the image to be detected and a number of corner points of the standard image using the Harris corner detection algorithm and the adaptive threshold of each region, this embodiment may further include:
[0071] Based on the one-to-one correspondence between each pixel in the image to be detected and each pixel in the standard image, the standard image is divided into a plurality of regions, wherein each region of the standard image corresponds one-to-one to each region divided by the image to be detected.
[0072] In the specific implementation process, the Harris corner detection algorithm and the adaptive threshold of each area in the image to be detected can be used to first determine several corner points of the image to be detected, and then the Harris corner detection algorithm and the adaptive threshold of each area in the standard image can be used to determine several corner points of the standard image.
[0073] In one embodiment, in step S5, defect detection of industrial products based on a plurality of corner points of the image to be detected and a plurality of corner points of the standard image may specifically include:
[0074] S51, generating a feature descriptor of the image to be detected based on a number of corner points of the image to be detected, and generating a feature descriptor of the standard image based on a number of corner points of the standard image;
[0075] S52, comparing the feature descriptor of the image to be detected with the feature descriptor of the standard image to obtain a target area of the image to be detected;
[0076] S53: Perform defect detection on the target area to determine whether the target area is a defective area.
[0077] In the specific implementation process, taking the image to be detected as an example, any local feature descriptor algorithm is used to generate a feature descriptor for each corner point, wherein each feature descriptor can represent the local information of the neighborhood where the corner point is located, and a feature vector of the image to be detected is formed based on the feature descriptors of all corner points.
[0078] Furthermore, any matching algorithm is used to calculate the similarity between the feature vector of the image to be detected and the feature vector of the standard image, and a number of matching pairs are screened out according to the similarity value, and the target area in the image to be detected is determined through the several matching pairs.
[0079] Furthermore, the target area of the image to be inspected is marked, and defect detection is performed on the target area to determine whether the target area is a defect area.
[0080] The defect detection method for industrial products provided in the embodiment of the present application first considers that since industrial products have different shapes, if the same corner point response value threshold is set for different industrial products, too few corner points will be detected for industrial products with more complex shapes, resulting in the problem of missed defect detection, while too many corner points will be detected for industrial products with simpler shapes, that is, the corner points obtained contain some noise points, resulting in the problem of false defect detection. Therefore, the embodiment of the present application first uses the Harris corner point detection algorithm to determine the corner point response value of each pixel in the image to be detected, and determines the initial threshold based on the corner point response value of each pixel, that is, the initial corner point detection threshold corresponding to the image to be detected of the industrial product is set for different industrial products based on the characteristics of the image to be detected corresponding to the industrial product.
[0081] In addition, the embodiments of the present application also take into account that different areas on the surface of industrial products have different shapes. If the same corner detection threshold is set for different areas, more corners will appear in areas with complex backgrounds. More corners may contain a large number of irrelevant features, while areas with simple backgrounds have fewer corners, resulting in a lack of sufficient information to describe the shape and structure of the product, all of which affect the accuracy of defect detection. Therefore, the embodiments of the present application divide the image to be detected into several areas, calculate the regional complexity of each area, and adjust the initial threshold based on the regional complexity of each area to obtain the adaptive threshold corresponding to each area, thereby achieving different corner response value thresholds based on the complexity differences of different areas in the industrial product image, so as to set a lower threshold in simple areas to accurately capture details, and set a higher threshold in complex areas to retain features and reduce noise, thereby improving the accuracy and reliability of overall defect detection and reducing the risk of false alarms.
[0082] Based on the above embodiments, Figure 2 FIG. 1 is a structural block diagram of a defect detection device for industrial products according to an embodiment of the present application, such as Figure 2As shown, the defect detection device for industrial products may include: an image acquisition module 210, an initial threshold determination module 220, a region segmentation module 230, a threshold improvement module 240, and a defect detection module 250, wherein:
[0083] The image acquisition module 210 is used to acquire the image to be inspected of the industrial product and obtain the standard image of the industrial product;
[0084] The initial threshold determination module 220 is used to determine the corner point response value of each pixel in the image to be detected by using the Harris corner point detection algorithm, and determine an initial threshold value based on the corner point response value of each pixel, wherein the initial threshold value of each pixel is the same;
[0085] The region segmentation module 230 is used to divide the image to be detected into a plurality of regions based on the corner point response value of each pixel point in the image to be detected and using a region growing algorithm;
[0086] The threshold improvement module 240 is used to calculate the regional complexity of each region, and adjust the initial threshold of the corresponding region based on the regional complexity of each region to obtain an adaptive threshold of each region;
[0087] The defect detection module 250 is used to determine several corner points of the image to be detected and several corner points of the standard image using the Harris corner detection algorithm and the adaptive threshold of each area, and perform defect detection on industrial products based on the several corner points of the image to be detected and several corner points of the standard image.
[0088] In an exemplary embodiment, the initial threshold determination module 220 may also be used to construct a corner point response value histogram using the corner point response values of all pixels in the image to be detected; and determine an initial threshold value according to the corner point response value histogram.
[0089] In an exemplary embodiment, the threshold improvement module 240 may also be used to calculate the corner significance of each region; calculate the degree of corner distribution of each region; and determine the region complexity of each region based on the corner significance and the degree of corner distribution of each region.
[0090] In an exemplary embodiment, the threshold improvement module 240 may also use the following formula (1) to calculate the corner significance of each region:
[0091]
[0092] in, Indicates The corner point significance of the region, Indicates The area contained in The corner point response value, Indicates The area contained in The number of pixels corresponding to the corner point response value. Indicates The type of corner point response value contained in the region.
[0093] In an exemplary embodiment, the threshold improvement module 240 may also use the following formula (2) to adjust the initial threshold to obtain an adaptive threshold corresponding to each region:
[0094]
[0095] in, Indicates Adaptive thresholding of regions, Indicates The regional complexity of the region, Indicates The maximum value of the corner point response value in the region is Represents the initial threshold.
[0096] In an exemplary embodiment, there is a one-to-one correspondence between each pixel point in the image to be detected in the defect detection module 250 and each pixel point in the standard image. The defect detection module 250 can also be used to divide the standard image into several areas based on the correspondence, wherein each area of the standard image corresponds one-to-one to each area divided by the image to be detected.
[0097] In an exemplary embodiment, the defect detection module 250 can also be used to generate a feature descriptor of the image to be detected based on several corner points of the image to be detected, and to generate a feature descriptor of the standard image based on several corner points of the standard image; compare the feature descriptor of the image to be detected with the feature descriptor of the standard image to obtain a target area of the image to be detected; perform defect detection on the target area to determine whether the target area is a defect area.
[0098] Those skilled in the art should understand that the division of the various modules in the embodiment is merely a division of logical functions, and in actual application, all or part of them can be integrated into one or more actual carriers, and these modules can be implemented entirely in the form of software called by a processing unit, or entirely in the form of hardware, or in the form of a combination of software and hardware. It should be noted that each module in a defect detection device for industrial products in this embodiment corresponds one-to-one to each step in a defect detection method for industrial products in the aforementioned embodiment. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned defect detection method for industrial products, which will not be repeated here.
[0099] Based on the above embodiments, Figure 3 FIG. 1 is a schematic diagram of a defect detection device for industrial products according to an embodiment of the present application. Figure 3 As shown, the electronic device may include: a processor (processor) 310, a communication interface (Communications Interface) 320, a memory (memory) 330 and a communication bus 340, wherein the processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 can call the logic instructions in the memory 330 to execute a defect detection method for industrial products, which method includes: collecting an image to be detected of the industrial product and obtaining a standard image of the industrial product; using the Harris corner point detection algorithm to determine the corner point response value of each pixel point in the image to be detected, and determining an initial threshold based on the corner point response value of each pixel point, wherein the initial threshold of each pixel point is the same; based on the corner point response value of each pixel point in the image to be detected and using a region growing algorithm, the image to be detected is divided into a plurality of regions; calculating the regional complexity of each region, and adjusting the initial threshold of the corresponding region based on the regional complexity of each region to obtain an adaptive threshold of each region; using the Harris corner point detection algorithm and the adaptive threshold of each region to determine a plurality of corner points of the image to be detected and a plurality of corner points of the standard image, and performing defect detection on the industrial product based on the plurality of corner points of the image to be detected and a plurality of corner points of the standard image.
[0100] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0101] On the basis of the above embodiments, on the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the defect detection method for industrial products provided by the above methods, the method including: collecting an image to be detected of an industrial product and obtaining a standard image of the industrial product; using the Harris corner point detection algorithm to determine the corner point response value of each pixel in the image to be detected, and determining an initial threshold based on the corner point response value of each pixel, wherein the initial threshold of each pixel is the same; based on the corner point response value of each pixel in the image to be detected and using a region growing algorithm, the image to be detected is divided into a plurality of regions; calculating the regional complexity of each region, and adjusting the initial threshold of the corresponding region based on the regional complexity of each region to obtain an adaptive threshold of each region; using the Harris corner point detection algorithm and the adaptive threshold of each region to determine a plurality of corner points of the image to be detected and a plurality of corner points of the standard image, and performing defect detection on the industrial product based on the plurality of corner points of the image to be detected and the plurality of corner points of the standard image.
[0102] On the basis of the above embodiments, on another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the processor executes the defect detection method for industrial products provided by the above methods, the method comprising: collecting an image to be detected of the industrial product and obtaining a standard image of the industrial product; determining a corner point response value of each pixel in the image to be detected by using the Harris corner point detection algorithm, and determining an initial threshold based on the corner point response value of each pixel, wherein the initial threshold of each pixel is the same; dividing the image to be detected into a plurality of regions based on the corner point response value of each pixel in the image to be detected and using a region growing algorithm; calculating the regional complexity of each region, and adjusting the initial threshold of the corresponding region based on the regional complexity of each region to obtain an adaptive threshold of each region; determining a plurality of corner points of the image to be detected and a plurality of corner points of the standard image by using the Harris corner point detection algorithm and the adaptive threshold of each region, and performing defect detection on the industrial product based on the plurality of corner points of the image to be detected and the plurality of corner points of the standard image.
[0103] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A defect detection method for industrial products, characterized in that: include: Collect images of industrial products to be inspected and obtain standard images of industrial products; The Harris corner detection algorithm is used to determine the corner point response value of each pixel in the image to be detected, and an initial threshold is determined based on the corner point response value of each pixel, wherein the initial threshold of each pixel is the same; Based on the corner point response value of each pixel point in the image to be detected and using a region growing algorithm, the image to be detected is divided into a plurality of regions; Calculate the regional complexity of each area, and adjust the initial threshold of the corresponding area based on the regional complexity of each area to obtain the adaptive threshold of each area; The Harris corner detection algorithm and the adaptive threshold of each area are used to determine several corner points of the image to be detected and several corner points of the standard image, and defect detection of industrial products is performed based on the several corner points of the image to be detected and several corner points of the standard image; The step of calculating the regional complexity of each region includes: Calculate the corner significance of each region; Calculate the distribution degree of corner points in each area; Determine the regional complexity of each region based on the significance and distribution of corner points in each region; The initial threshold of the corresponding area is adjusted based on the area complexity of each area to obtain the adaptive threshold of each area, including: Based on the regional complexity of each region, the initial threshold is adjusted using the following formula (2) to obtain the adaptive threshold corresponding to each region: in, Indicates Adaptive thresholding of regions, Indicates The regional complexity of the region, Indicates The maximum value of the corner point response value in the region is Represents the initial threshold.
2. The defect detection method for industrial products according to claim 1, characterized in that: The determining an initial threshold value based on the corner point response value of each pixel point includes: Constructing a corner point response value histogram using the corner point response values of all pixels in the image to be detected; An initial threshold is determined according to the corner point response value histogram.
3. The defect detection method for industrial products according to claim 1, characterized in that: The calculating the saliency of the corner points of each region includes: The following formula (1) is used to calculate the corner significance of each region: in, Indicates The corner point significance of the region, Indicates The area contained in The corner point response value, Indicates The area contained in The number of pixels corresponding to the corner point response value. Indicates The type of corner point response value contained in the region.
4. The defect detection method for industrial products according to claim 1, characterized in that: There is a one-to-one correspondence between each pixel point in the image to be detected and each pixel point in the standard image; before using the Harris corner point detection algorithm and the adaptive threshold of each area to determine a number of corner points of the image to be detected and a number of corner points of the standard image, the method also includes: Based on the corresponding relationship, the standard image is divided into a plurality of regions, wherein each region of the standard image corresponds one-to-one to each region divided into the image to be detected.
5. The defect detection method for industrial products according to claim 1, characterized in that: The defect detection of industrial products based on a plurality of corner points of the image to be detected and a plurality of corner points of the standard image comprises: Generate a feature descriptor of the image to be detected based on several corner points of the image to be detected, and generate a feature descriptor of the standard image based on several corner points of the standard image; Comparing the feature descriptor of the image to be detected with the feature descriptor of the standard image to obtain a target area of the image to be detected; Perform defect detection on the target area to determine whether the target area is a defect area.
6. A defect detection device for industrial products, characterized in that: include: An image acquisition module, used to acquire images of industrial products to be inspected and obtain standard images of industrial products; An initial threshold determination module is used to determine the corner point response value of each pixel in the image to be detected by using the Harris corner point detection algorithm, and determine an initial threshold based on the corner point response value of each pixel, wherein the initial threshold of each pixel is the same; A region segmentation module, used for dividing the image to be detected into a plurality of regions based on the corner point response value of each pixel point in the image to be detected and using a region growing algorithm; The threshold improvement module is used to calculate the regional complexity of each area, and adjust the initial threshold of the corresponding area based on the regional complexity of each area to obtain the adaptive threshold of each area; A defect detection module is used to determine several corner points of the image to be detected and several corner points of the standard image by using the Harris corner detection algorithm and the adaptive threshold of each area, and to perform defect detection on the industrial product based on the several corner points of the image to be detected and the several corner points of the standard image; The threshold improvement module is also used for: Calculate the corner significance of each region; Calculate the distribution degree of corner points in each area; Determine the regional complexity of each region based on the significance and distribution of corner points in each region; Based on the regional complexity of each region, the initial threshold is adjusted using the following formula (2) to obtain the adaptive threshold corresponding to each region: in, Indicates Adaptive thresholding of regions, Indicates The regional complexity of the region, Indicates The maximum value of the corner point response value in the region is Represents the initial threshold.
7. A defect detection device for industrial products, characterized in that: include: at least one processor; And, a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the defect detection method for industrial products as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the defect detection method for industrial products according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Corner point detecting and matching-based medicine recognition system and recognition method thereof
CN106980852A
SD card pose detection method based on dynamic angular point positioning
CN112923852A