Defect Detection Method, Device and Electronic Equipment

By obtaining the contour interception method of the detection path curve and normal vector direction, defect detection is automated, which solves the high cost problems caused by manual customization and improves detection efficiency.

CN120013941BActive Publication Date: 2025-07-11HANGZHOU HIKROBOT TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510490974.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-07-11
Estimated Expiration
2045-04-16

AI Technical Summary

Technical Problem

In the prior art, defect detection requires manual customization of solutions, resulting in high time and labor costs and low efficiency.

Method used

By obtaining the detection path curve matching the image area to be measured, the pixel points are obtained and the contour intercepts are performed based on the normal vector direction, the contour area is obtained for defect detection.

Benefits of technology

Automatic defect detection is realized, avoiding the high cost of manual customized solutions and improving detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120013941B_ABST
    Figure CN120013941B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a defect detection method, apparatus, and electronic device. In the embodiments of the present application, first, at least two pixel points on a detection path curve are obtained by using the obtained detection path curve that matches the detection path of the image area to be measured. Then, based on the direction of the normal vector of each obtained pixel point, each pixel point corresponding contour area, that is, the region of interest to be detected, is obtained from the image area to be measured through contour intercepting, and defect detection is performed using the contour areas corresponding to the pixel points, so as to realize automatic defect detection of the image area to be measured. This can avoid high time and labor costs caused by manually customizing defect detection schemes, and effectively improve the efficiency 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 machine vision technology, and in particular, to a defect detection method, apparatus, and electronic device. Background Art

[0002] Defect detection is widely applied in many fields such as machine vision; the objects of defect detection are also various, such as flexible and shapeless detection objects like weld seams and rubber strips.

[0003] Currently, in practical applications, usually, a corresponding defect detection scheme is customized manually for each defect detection object. However, the above-mentioned manual method will result in high time and labor costs, thus reducing the efficiency of defect detection. Summary of the Invention

[0004] In view of this, this application provides a defect detection method, apparatus, and electronic device to improve the efficiency of defect detection.

[0005] An embodiment of this application provides a defect detection method, which includes:

[0006] Obtain a detection path curve that matches the detection path of the image area to be measured;

[0007] Use the detection path curve to obtain at least two pixel points on the detection path curve;

[0008] For each pixel point, based on the direction of the normal vector of this pixel point in the image area to be measured, perform contour intercepting processing on the image area to be measured to obtain the contour area corresponding to this pixel point;

[0009] Perform defect detection based on the contour areas corresponding to each pixel point.

[0010] An embodiment of this application also provides a defect detection apparatus, which includes:

[0011] A first obtaining module, configured to obtain a detection path curve that matches the detection path of the image area to be measured;

[0012] A second obtaining module, configured to use the detection path curve to obtain at least two pixel points on the detection path curve;

[0013] An intercepting module, configured to, for each pixel point, based on the direction of the normal vector of this pixel point in the image area to be measured, perform contour intercepting processing on the image area to be measured to obtain the contour area corresponding to this pixel point;

[0014] A detection module, configured to perform defect detection based on the contour areas corresponding to each pixel point.

[0015] An embodiment of the present application also provides an electronic device, which includes:

[0016] a processor; and

[0017] a computer-readable storage medium storing computer program instructions, which, when run by the processor, cause the processor to execute the steps of the above method.

[0018] An embodiment of the present application also provides a computer-readable storage medium storing computer program instructions, which, when run by the processor, cause the processor to execute the steps in the above method.

[0019] It can be seen from the above technical solutions that in the embodiment of the present application, first, at least two pixel points on the detection path curve are obtained by using the detected path curve matching the detection path of the image region to be detected. Then, based on the direction of the normal vector of each obtained pixel point, each pixel point corresponding contour region, that is, the region of interest to be detected, is obtained from the image region to be detected by contour intercepting, and the contour regions corresponding to the pixel points are used for defect detection to realize automatic defect detection of the image region to be detected. This can avoid the high time and labor costs caused by manually customizing the defect detection scheme and effectively improve the efficiency of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings herein are incorporated into the specification and form a part of this application, showing embodiments consistent with the present application and, together with the specification, are used to explain the principles of the present application.

[0021] Figure 1 It is a schematic flowchart of the method provided by the embodiment of the present application.

[0022] Figure 2 It is a schematic diagram of the defect detection image provided by the embodiment of the present application.

[0023] Figure 3 It is a schematic diagram of the detection path curve provided by the embodiment of the present application.

[0024] Figure 4 It is a schematic diagram of the implementation of contour intercepting provided by the embodiment of the present application.

[0025] Figure 5 It is a schematic diagram of the stitched image provided by the embodiment of the present application.

[0026] Figure 6 It is a schematic diagram of the device structure provided by the embodiment of the present application.

[0027] Figure 7 It is a schematic diagram of the electronic device structure provided by the embodiment of the present application. Detailed implementation manners

[0028] To enable those skilled in the art to better understand the technical solutions provided in the embodiments of the present application and make the above-mentioned objects, features, and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0029] See Figure 1 , Figure 1 which is a schematic flowchart of a defect detection method provided in an embodiment of the present application. This method is applied to an electronic device. As an example, the electronic device may be a device such as a laptop computer or a server, and is not specifically limited here. As Figure 1 shown, the process may include the following steps:

[0030] Step 101, obtain a detection path curve that matches the detection path of the image area to be measured.

[0031] In this embodiment, the image area to be measured may refer to the image area corresponding to an externally input image containing a defect detection object. Optionally, the externally input image in this embodiment is not specifically limited and can be flexibly set according to actual application requirements. For example, the externally input image may be a two-dimensional (2D) luminance map or a three-dimensional (3D) depth map, etc.

[0032] In this embodiment, the detection path of the image area to be measured can be determined according to actual application requirements. For example, as an embodiment, the detection path of the image area to be measured can be any shape, specifically, it can be a regular shape such as an arc, a rectangle, and a straight line segment, or an irregular shape. Among them, a regular shape may refer to a shape with a clear shape and size that can be divided according to a certain fixed rule or pattern; on the contrary, an irregular shape may refer to a shape that cannot be divided according to a certain fixed rule or pattern.

[0033] Based on this, the detection path curve that matches the detection path of the image area to be measured can be understood as a curve that matches the shape of the detection path of the image area to be measured. Among them, when the shape of the detection path of the image area to be measured is a regular shape, the curve that matches the detection path of the image area to be measured can be a regular curve, such as a circle, an arc, a rectangle, and a straight line segment, etc., which are not listed one by one here. When the shape of the detection path of the image area to be measured is an irregular shape, the curve that matches the detection path of the image area to be measured can be an irregular curve, that is, a free curve.

[0034] As an example, in this step, a detection path curve that matches the detection path of the image area to be measured is obtained. When specifically implemented, for example, it can be: a detection path curve that matches the detection path of the image area to be measured can be drawn through curve drawing parameters input externally. In this embodiment, for different types of defect detection objects, corresponding curve drawing parameters can be determined based on actual application requirements, and a detection path curve suitable for the defect detection object can be generated based on the curve drawing parameters, so that the defect detection method in this embodiment can be adapted to different types of defect detection objects, thereby effectively improving the versatility and flexibility of defect detection.

[0035] Optionally, based on the above description, for regular curves, the curve drawing parameters input externally can include parameters characterizing the geometric features of the curve. For example, if the curve is a circle, the corresponding curve drawing parameters can include the center coordinates, radius, and parameters such as the mathematical equation characterizing the circle; if the curve is an arc, the corresponding curve drawing parameters can include the center coordinates, radius, start and end angles of the arc, and parameters such as the mathematical equation characterizing the arc; if the curve is a rectangle, the corresponding curve drawing parameters can include the length, width, coordinates of a vertex of the rectangle, and parameters such as the mathematical equation characterizing the rectangle. Here, taking the mathematical equation characterizing the circle as an example, the mathematical equation characterizing the circle can be , where represents the center coordinates, represents the radius; as for other mathematical equations, they will not be exemplified one by one here.

[0036] For irregular curves, spline curves such as Cutmull-Rom spline curves can be used to represent them. Among them, a spline curve can refer to a curve obtained by a given set of control points, and the curve must pass through the control points. Based on this, the curve drawing parameters input externally can include parameters characterizing the spline curve, such as a set of control points and parameters such as the mathematical equation characterizing the spline curve.

[0037] In this embodiment, it should be noted that the coordinates, vertex coordinates, control points, etc. included in the above curve drawing parameters are all coordinate points in the same pixel coordinate system. Among them, the pixel coordinate system refers to the pixel coordinate system corresponding to the image area to be measured.

[0038] Step 102: Use the detection path curve to obtain at least two pixel points on the detection path curve.

[0039] In this embodiment, in this step, at least two pixel points on the detection path curve are obtained by using the detection path curve. There are many implementation manners in specific implementation. For example, as an embodiment, the detection path curve is sampled according to a set sampling interval to obtain the pixel coordinates and normal vectors of at least two pixel points on the detection path curve. Among them, for each pixel point, if the pixel point meets the requirement for the existence of the normal vector, the normal vector of the detection path curve at this pixel point is determined as the normal vector of this pixel point; otherwise, the normal vector of this pixel point is determined according to the normal vectors of at least one adjacent pixel point of this pixel point among the sampled pixel points.

[0040] In this embodiment, as an embodiment, the above-mentioned sampling of the detection path curve according to the set sampling interval to obtain the pixel coordinates and normal vectors of at least two pixel points on the detection path curve can be specifically implemented as follows: First, a pixel point is selected from the detection path curve as the sampling starting point, that is, the first pixel point obtained by sampling. For example, taking an arc as an example, the pixel point corresponding to the starting angle of the arc can be selected as the sampling starting point, and the normal vector of the sampled pixel point is determined. Then, according to the mathematical equation corresponding to the detection path curve and the set sampling interval, the pixel coordinates of the next sampled pixel point are determined, and the normal vector of the sampled pixel point is determined, and so on until the end point of the detection path curve, such as the pixel point corresponding to the termination angle of the arc.

[0041] As for how to specifically determine the pixel coordinates of the next sampled pixel point according to the mathematical equation corresponding to the detection path curve and the set sampling interval in this step, and how to specifically determine the normal vector of the pixel point, examples will be described below and will not be elaborated here for the time being.

[0042] Step 103: For each pixel point, based on the direction of the normal vector of this pixel point in the image area to be measured, perform contour intercepting processing on the image area to be measured to obtain the contour area corresponding to this pixel point.

[0043] In this embodiment, in this step, based on the direction of the normal vector of this pixel point in the image area to be measured, performing contour intercepting processing on the image area to be measured to obtain the contour area corresponding to this pixel point has many implementation manners in specific implementation. For example, as an embodiment, in the image area to be measured, a first area is intercepted along the direction of the normal vector of this pixel point in the image area to be measured starting from this pixel point; then, the contour area corresponding to this pixel point is obtained according to this first area. Specifically, the first area can be used as the contour area corresponding to this pixel point.

[0044] For another example, as an embodiment, in the image area to be measured, a second area is intercepted starting from the pixel point in a direction opposite to the normal vector direction of the pixel point in the image area to be measured; then, the contour area corresponding to the pixel point is obtained based on the second area. Specifically, the second area can be used as the contour area corresponding to the pixel point.

[0045] For yet another example, as an embodiment, in the image area to be measured, a first area is intercepted starting from the pixel point in the normal vector direction of the pixel point in the image area to be measured; and, in the image area to be measured, a second area is intercepted starting from the pixel point in a direction opposite to the normal vector direction of the pixel point in the image area to be measured; then, the contour area corresponding to the pixel point is obtained based on the first area and the first area. Specifically, the first area and the second area can be used as the contour area corresponding to the pixel point.

[0046] In this embodiment, as an embodiment, the above-mentioned intercepting the first area starting from the pixel point can be specifically implemented as follows: in the image area to be measured, extend a first intercepting length in the normal vector direction of the pixel point in the image area to be measured to obtain a first extended line segment; then, on the first extended line segment, starting from the pixel point, sample at a set first sampling interval to obtain at least two first sampling points, and use the image area formed by each first sampling point as the first area.

[0047] As for the above-mentioned intercepting the second area starting from the pixel point, it is similar to the specific implementation manner of intercepting the first area starting from the pixel point. For example, as an embodiment, in the image area to be measured, extend a second intercepting length in a direction opposite to the normal vector direction of the pixel point in the image area to be measured to obtain a second extended line segment; then, on the second extended line segment, starting from the pixel point, sample at a set second sampling interval to obtain at least two second sampling points, and use the image area formed by each second sampling point as the second area.

[0048] Optionally, the above-mentioned first intercepting length, second intercepting length, first sampling interval, and second sampling interval can be flexibly set based on actual application requirements, and this embodiment does not specifically limit them. For example, the above-mentioned first intercepting length and second intercepting length can be the same or different. The above-mentioned first sampling interval and second sampling interval can be the same or different.

[0049] Step 104, perform defect detection based on the contour areas corresponding to each pixel point.

[0050] As described above, the contour region corresponding to any pixel point may include multiple sampling points (i.e., pixel points). Optionally, in this embodiment, each sampling point included in the contour region corresponding to any pixel point includes at least the pixel coordinates of the sampling point and the pixel value. Among them, if the image corresponding to the measured image region is a luminance map, the pixel value of the pixel point is the luminance value; if the image corresponding to the measured image region is a depth map, the pixel value of the pixel point is the depth value.

[0051] In this embodiment, the pixel coordinates of the pixel points in the measured image region are all integers, that is, the pixel values of the pixel points with integer pixel coordinates are known, while the pixel values of the pixel points with non-integer pixel coordinates are unknown. Based on this, as an embodiment, for any pixel point, in the process of obtaining the contour region corresponding to the pixel point by sampling, if the pixel coordinates of a sampling point are non-integer, the pixel value of the sampling point is unknown. In this case, the pixel value of the sampling point can be calculated by an interpolation processing method such as bilinear interpolation processing method. Specifically, for example, based on the pixel coordinates of the sampling point, at least one pixel point with integer pixel coordinates within the set range of the sampling point can be found from the measured image region, so as to perform a set calculation (such as weighted average, etc.) using the pixel values of the found pixel points to obtain the pixel value of the sampling point.

[0052] Based on the above description, as an embodiment, in this step, defect detection is performed based on the contour regions corresponding to each pixel point. In specific implementation, for example, it can be: for each pixel point, first perform a specified contour fitting process on the contour region corresponding to the pixel point based on the pixel coordinates and pixel values of the pixel points included in the contour region corresponding to the pixel point to obtain a contour fitting result; then, perform a specified difference process on the contour region corresponding to the pixel point and the contour fitting result to obtain a difference process result; finally, determine whether there is a defect in the contour region corresponding to the pixel point based on the difference process result.

[0053] In this embodiment, the above contour fitting result can be understood as an ideal contour region (i.e., a contour region without any defects) fitted based on the contour region corresponding to the pixel point. Based on this, as an embodiment, the above determination of whether there is a defect in the contour region corresponding to the pixel point based on the difference process result can be, for example: if the difference process result is greater than or equal to the set difference threshold, it means that the gap between the contour region corresponding to the pixel point and the contour fitting result is relatively large. In this case, it can be determined that there is a defect in the contour region corresponding to the pixel point; if the difference process result is less than the set difference threshold, it means that the gap between the contour region corresponding to the pixel point and the contour fitting result is relatively small and can be ignored. In this case, it can be determined that there is no defect in the contour region corresponding to the pixel point.

[0054] It should be noted that the above embodiments of how to perform defect detection based on the contour regions corresponding to each pixel are only examples and are not used for limitation. In this embodiment, filtering difference methods, model difference methods, etc. can also be used to perform defect detection on the contour regions corresponding to each pixel; as for how to specifically use the filtering difference method and the model difference method for defect detection, this embodiment does not specifically limit. Moreover, in this embodiment, in addition to performing defect detection on the contour regions corresponding to each pixel one by one as described above, the contour regions corresponding to each pixel can also be combined into an overall contour region to perform overall defect detection on this overall contour region using the above defect detection method; or, each pixel can also be divided into multiple groups, and each group of pixels can include at least two pixels. Then, for each group of pixels, the contour regions corresponding to this group of pixels are combined into a contour region to perform defect detection on the combined contour region using the above defect detection method, and so on. This embodiment does not specifically limit this.

[0055] So far, the Figure 1 shown process is completed.

[0056] Through Figure 1 As can be seen from the shown process, in the embodiment of the present application, first, at least two pixels on the detection path curve are obtained by using the obtained detection path curve that matches the detection path of the image region to be measured. Then, based on the direction of the normal vector of each obtained pixel, each pixel's corresponding contour region, that is, the region of interest to be detected, is obtained from the image region to be measured through contour interception, and defect detection is performed using the contour regions corresponding to each pixel to achieve automatic defect detection of the image region to be measured. This can avoid the high time and labor costs caused by manually customizing the defect detection scheme and effectively improve the efficiency of defect detection.

[0057] Next, a description will be given of how to specifically determine the pixel coordinates of the next sampled pixel based on the mathematical equation corresponding to the detection path curve and the set sampling interval in step 102 above.

[0058] In this embodiment, as an example, the determination of the pixel coordinates of the next sampled pixel based on the mathematical equation corresponding to the detection path curve and the set sampling interval can be, for example, in specific implementation: if the detection path curve is a regular curve, then based on the mathematical equation corresponding to the detection path curve, the pixel coordinates of the next sampled pixel that is on the detection path curve and has a distance length of the set sampling interval from the currently sampled pixel can be directly calculated.

[0059] If the detection path curve is an irregular curve, the interval length between two pixel points on the detection path curve can be obtained by integrating the mathematical equation corresponding to the detection path curve. Based on this, in a way of gradually approaching the set sampling interval through an approximation method such as the bisection method, etc., the pixel coordinates of the next sampled pixel point on the detection path curve and with an interval length approximately equal to the set sampling interval from the currently sampled pixel point can be obtained.

[0060] The following describes how to specifically determine the normal vector of the pixel point in step 102 above.

[0061] In this embodiment, as an example, for each pixel point, if it is determined based on the mathematical equation corresponding to the detection path curve that the detection path curve is differentiable at this pixel point, then it is determined that this pixel point meets the set requirement for the existence of the normal vector. In this case, the normal vector of the detection path curve at this pixel point can be determined as the normal vector of this pixel point; among them, the normal vector of the detection path curve at this pixel point can be a vector that is perpendicular to the tangent of the detection path curve at this pixel point and whose direction points to the bending direction of the detection path curve.

[0062] If it is determined based on the mathematical equation corresponding to the detection path curve that the detection path curve is not differentiable at this pixel point, such as at the vertex of a rectangle where it is not differentiable, etc., then it is determined that this pixel point does not meet the set requirement for the existence of the normal vector. In this case, the normal vector of this pixel point can be determined based on the normal vectors of at least one adjacent pixel point of this pixel point among the sampled pixel points.

[0063] As an example, the above-mentioned determining the normal vector of this pixel point based on the normal vectors of at least one adjacent pixel point of this pixel point among the sampled pixel points can be specifically implemented as follows: A vector that passes through this pixel point, is parallel to and has the same direction as the reference vector can be determined as the normal vector of this pixel point.

[0064] Optionally, the above-mentioned reference vector can be, for example, the normal vector of the previous pixel point of this pixel point among the sampled pixel points, the normal vector of the next pixel point of this pixel point among the sampled pixel points, or the sum of the normal vectors of the previous pixel point and the next pixel point of this pixel point, etc. This embodiment does not specifically limit it.

[0065] So far, the further description of step 102 above is completed.

[0066] The following further describes step 103 above.

[0067] In this embodiment, compared with a regular curve, for the case where the detection path curve is an irregular curve, the detection path curve drawn by the input drawing parameters is relatively rough. Based on this, this embodiment can iteratively optimize the detection path curve to more accurately intercept the region of interest to be detected, that is, the contour region, and improve the accuracy of defect detection. Moreover, since this embodiment will iteratively optimize the detection path curve, the initially drawn detection path curve can be relatively rough, so that the defect detection method of this embodiment has good usability.

[0068] Specifically, as an embodiment, after performing contour intercepting processing on the measured image region to obtain the contour region corresponding to the pixel point, and before performing defect detection based on the contour regions corresponding to the pixel points, this embodiment can first determine whether the detection path curve meets the requirements of a set irregular curve (that is, an irregular curve). If so, feature points are respectively selected from the contour regions corresponding to the pixel points.

[0069] Afterwards, when the set error requirement is not met between each pixel point and each feature point, it means that the current detection path curve still needs to be iteratively optimized. In this case, a detection path curve can be generated based on each feature point, and the step of obtaining at least two pixel points on the detection path curve by using the detection path curve is returned; when the set error requirement is met between each pixel point and each feature point, it means that the current detection path curve has met the requirements of iterative optimization and does not need to be optimized further. In this case, the step of performing defect detection based on the contour regions corresponding to the pixel points can be continued.

[0070] In this embodiment, optionally, the situation where the set error requirement is not met between each pixel point and each feature point may refer to that the average value of the differences between the pixel coordinates of each pixel point and the pixel coordinates of each feature point is greater than the set error threshold; correspondingly, the situation where the set error requirement is met between each pixel point and each feature point may refer to that the average value of the differences between the pixel coordinates of each pixel point and the pixel coordinates of each feature point is less than or equal to the set error threshold.

[0071] As another embodiment, after performing contour intercepting processing on the measured image region to obtain the contour region corresponding to the pixel point, and before performing defect detection based on the contour regions corresponding to the pixel points, this embodiment can first determine whether the detection path curve meets the requirements of a set irregular curve (that is, an irregular curve). If so, then:

[0072] When the number of acquired detection path curves is not the set number, it means that the detection path curves still need to be iteratively optimized. In this case, feature points can be separately selected from the contour regions corresponding to each pixel point, so as to generate detection path curves based on the feature points, and return the above step of using the detection path curves to obtain at least two pixel points on the detection path curves.

[0073] When the number of acquired detection path curves is the set number, it means that the detection path curves have met the requirements of iterative optimization and do not need to be optimized further. In this case, the step of defect detection can be continued based on the contour regions corresponding to each pixel point.

[0074] In this embodiment, the curve drawing parameters input externally may further include indication information for indicating whether the curve to be drawn is an irregular curve. Based on this, as an embodiment, the determination of whether the detection path curve meets the set requirements for an irregular curve can be, for example, in specific implementation: if it is determined based on the indication information in the externally input curve drawing parameters that the curve to be drawn is an irregular curve, then it is determined that the detection path curve meets the set requirements for an irregular curve; otherwise, it is determined that the detection path curve does not meet the set requirements for an irregular curve.

[0075] In this embodiment, as an embodiment, the selection of feature points from the contour regions corresponding to each pixel point can be, for example, in specific implementation: for each pixel point, based on the pixel values of the pixel points included in the contour region corresponding to the pixel point, feature points are selected from the contour region corresponding to the pixel point. Optionally, the selected feature points can be, for example, the pixel point with the highest pixel value in the contour region corresponding to the pixel point, or the pixel point with the lowest pixel value in the contour region corresponding to the pixel point. This embodiment does not specifically limit.

[0076] To facilitate understanding of the specific implementation process of the above defect detection method, the following will be described by way of specific examples.

[0077] In this embodiment, the user first inputs an image containing the defect detection object (such as Figure 2 the shown defect detection image) and curve drawing parameters into the electronic device.

[0078] The electronic device draws a detection path curve that matches the detection path of the image region corresponding to the externally input image (i.e., the measured image region) through the externally input curve drawing parameters, such as the Figure 3 shown detection path curve.

[0079] After obtaining the detection path curve, the electronic device samples the detection path curve according to the set sampling interval to obtain the pixel coordinates and normal vectors of at least two pixel points on the detection path curve. As for how to specifically obtain the pixel coordinates and normal vectors of at least two pixel points on the detection path curve, reference can be made to the above relevant description, which will not be elaborated here.

[0080] For each pixel point obtained by the above sampling, the electronic device performs a contour truncation process on the measured image area based on the direction of the normal vector of the pixel point in the measured image area to obtain the contour area corresponding to the pixel point. And the contour areas corresponding to each pixel point are aligned and arranged to obtain a stitched image for subsequent defect detection processing.

[0081] Specifically, as an embodiment, refer to Figure 4 the schematic diagram of the implementation of the contour truncation shown. For each pixel point obtained by the above sampling, the electronic device extends a first truncation length along the direction of the normal vector of the pixel point in the measured image area in the measured image area to obtain a first extended line segment, and extends a second truncation length along the direction opposite to the direction of the normal vector of the pixel point in the measured image area to obtain a second extended line segment. Then, on the extended line segment formed by the first extended line segment and the second extended line segment, a pixel point is selected as the starting point from the extended line segment. For example, one of the endpoints of the extended line segment can be selected, and the extended line segment is sampled at a set truncation sampling interval to obtain at least two sampling points, and the image area formed based on each sampling point is used as the contour area corresponding to the pixel point. Based on this, the contour areas corresponding to each pixel point can be aligned to obtain a stitched image. For example, refer to Figure 5 the schematic diagram of the stitched image shown, which is Figure 3 the stitched image obtained after performing the above corresponding processing on the detection path curve shown.

[0082] After the electronic device performs a contour truncation process on the measured image area to obtain the contour area corresponding to the pixel point, and before performing defect detection based on the contour areas corresponding to each pixel point, it will also determine whether the detection path curve meets the set non-regular curve requirements. If so, feature points will be selected from the contour areas corresponding to each pixel point respectively; and when the error requirements are not met between each pixel point and each feature point, a detection path curve is generated based on each feature point, and the step of the electronic device sampling the detection path curve according to the set sampling interval after obtaining the detection path curve is returned; when the error requirements are met between each pixel point and each feature point, the subsequent step of performing defect detection based on the contour areas corresponding to each pixel point is continued.

[0083] After obtaining the contour regions corresponding to each pixel point, the electronic device performs defect detection based on the contour regions corresponding to each pixel point, thereby realizing defect detection for the image region to be measured. As for how to perform defect detection based on the contour regions corresponding to each pixel point, reference can be made to the above relevant description and will not be elaborated here.

[0084] So far, the description of the method provided by the embodiment of the present application is completed. Next, the device provided by the embodiment of the present application will be described:

[0085] See Figure 6 , Figure 6 is a schematic structural diagram of a defect detection device provided by an embodiment of the present application. This device is applied to an electronic device. As Figure 6 shown, the defect detection device 600 includes:

[0086] A first acquisition module 601, configured to acquire a detection path curve that matches the detection path of the image region to be measured;

[0087] A second acquisition module 602, configured to use the detection path curve to acquire at least two pixel points on the detection path curve;

[0088] A truncation module 603, configured to perform contour truncation processing on the image region to be measured based on the direction of the normal vector of each pixel point in the image region to be measured to obtain the contour region corresponding to each pixel point;

[0089] A detection module 604, configured to perform defect detection based on the contour regions corresponding to each pixel point.

[0090] As an embodiment, the first acquisition module 601 is specifically configured to: draw a detection path curve that matches the detection path of the image region to be measured through curve drawing parameters input externally.

[0091] As an embodiment, the above device further includes: a generation module, configured to, after performing contour truncation processing on the image region to be measured to obtain the contour region corresponding to each pixel point and before performing defect detection based on the contour regions corresponding to each pixel point, if the detection path curve meets the set non-regular curve requirements, select feature points from the contour regions corresponding to each pixel point respectively; and when the error requirements between each pixel point and each feature point are not met, generate a detection path curve based on each feature point, and return to the step of using the detection path curve to acquire at least two pixel points on the detection path curve;

[0092] When the error requirements between each pixel point and each feature point are met, continue to execute the step of performing defect detection based on the contour regions corresponding to each pixel point.

[0093] As an embodiment, when the generation module executes the operation of respectively selecting feature points from the contour regions corresponding to each pixel point, it is specifically configured to: for each pixel point, based on the pixel values of the pixel points included in the contour region corresponding to this pixel point, select feature points from the contour region corresponding to this pixel point.

[0094] As an embodiment, the interception module 603 is specifically configured to:

[0095] In the region of the image to be measured, starting from this pixel point, intercept a first region along the direction of the normal vector of this pixel point in the region of the image to be measured; and / or,

[0096] In the region of the image to be measured, starting from this pixel point, intercept a second region along the direction opposite to the direction of the normal vector of this pixel point in the region of the image to be measured;

[0097] Based on the first region and / or the second region, obtain the contour region corresponding to this pixel point.

[0098] As an embodiment, the second acquisition module 602 is specifically configured to:

[0099] Sample the detection path curve according to a set sampling interval to obtain the pixel coordinates and normal vectors of at least two pixel points on the detection path curve;

[0100] Among them, for each pixel point, if this pixel point meets the set requirement for the existence of a normal vector, then determine the normal vector of the detection path curve at this pixel point as the normal vector of this pixel point; otherwise, determine the normal vector of this pixel point based on the normal vectors of at least one adjacent pixel point of this pixel point among the sampled pixel points.

[0101] As an embodiment, the detection module 604 is specifically configured to:

[0102] For each pixel point, based on the pixel coordinates and pixel values of the pixel points included in the contour region corresponding to this pixel point, perform specified contour fitting processing on the contour region corresponding to this pixel point to obtain a contour fitting result;

[0103] Perform specified difference processing on the contour region corresponding to this pixel point and the contour fitting result to obtain a difference processing result;

[0104] Based on the difference processing result, determine whether there are defects in the contour region corresponding to this pixel point.

[0105] Thus far, the Figure 6 structural description of the shown device is completed.

[0106] For the implementation processes of the functions and roles of each module in the above device, please refer to the implementation processes of the corresponding steps in the above method for details, which will not be elaborated here.

[0107] For the device embodiments, since they basically correspond to the method embodiments, relevant parts can refer to the descriptions in the method embodiments. The device embodiments described above are only illustrative. The modules described as separate components may or may not be physically separated. The components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed to multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this application. Those of ordinary skill in the art can understand and implement it without creative efforts.

[0108] Please refer to Figure 7 , which is a schematic diagram of the hardware structure of an electronic device provided in an exemplary embodiment of this application. The electronic device may include a processor 701, a communication interface 702, a computer-readable storage medium 703, and a communication bus 704. The processor 701, the communication interface 702, and the computer-readable storage medium 703 complete communication with each other through the communication bus 704. Among them, a computer program is stored on the computer-readable storage medium 703; the processor 701 can execute the steps of the method described in the above embodiment by executing the program stored on the computer-readable storage medium 703. According to the actual functions of the electronic device, the electronic device may further include other hardware, which will not be elaborated here.

[0109] Correspondingly, an embodiment of this application also provides a computer-readable storage medium, on which several computer instructions are stored. When the computer instructions are executed by a processor, the methods disclosed in the above examples of this application can be implemented.

[0110] Exemplarily, the above computer-readable storage medium can be any electronic, magnetic, optical or other physical storage device that can contain or store information, such as executable instructions, data, etc. For example, the computer-readable storage medium can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or a combination thereof. The processor and the memory can be supplemented by or incorporated into dedicated logic circuits.

[0111] The above are only the preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application shall be included within the scope of protection of this application.

Claims

1. A defect detection method, characterized in that, The method includes: drawing a detection path curve that matches the detection path of the area of the image to be measured through externally input curve drawing parameters; using the detection path curve to obtain at least two pixel points on the detection path curve; for each pixel point, based on the direction of the normal vector of the pixel point in the area of the image to be measured, performing contour intercepting processing on the area of the image to be measured to obtain a contour area corresponding to the pixel point; performing defect detection based on the contour areas corresponding to the respective pixel points.

2. The method according to claim 1, wherein After performing contour intercepting processing on the area of the image to be measured to obtain a contour area corresponding to the pixel point, and before performing defect detection based on the contour areas corresponding to the respective pixel points, the method further includes: if the detection path curve meets the set requirements for an irregular curve, respectively selecting feature points from the contour areas corresponding to the respective pixel points; and when the set error requirement is not met between each pixel point and each feature point, generating a detection path curve based on the respective feature points, and returning to the step of using the detection path curve to obtain at least two pixel points on the detection path curve; when the set error requirement is met between each pixel point and each feature point, continuing to execute the step of performing defect detection based on the contour areas corresponding to the respective pixel points.

3. The method according to claim 2, wherein The respectively selecting feature points from the contour areas corresponding to the respective pixel points includes: for each pixel point, based on the pixel values of the pixel points included in the contour area corresponding to the pixel point, selecting feature points from the contour area corresponding to the pixel point.

4. The method according to claim 1, wherein The performing contour intercepting processing on the area of the image to be measured based on the direction of the normal vector of the pixel point in the area of the image to be measured to obtain a contour area corresponding to the pixel point includes: in the area of the image to be measured, intercepting a first area starting from the pixel point along the direction of the normal vector of the pixel point in the area of the image to be measured; and / or, in the area of the image to be measured, intercepting a second area starting from the pixel point along the direction opposite to the direction of the normal vector of the pixel point in the area of the image to be measured; obtaining a contour area corresponding to the pixel point according to the first area and / or the second area.

5. The method according to claim 1, wherein The using the detection path curve to obtain at least two pixel points on the detection path curve includes: sampling the detection path curve according to a set sampling interval to obtain the pixel coordinates and normal vectors of at least two pixel points on the detection path curve; wherein, for each pixel point, if the pixel point meets the set requirement for the existence of a normal vector, determining the normal vector of the detection path curve at the pixel point as the normal vector of the pixel point, otherwise, determining the normal vector of the pixel point according to the normal vectors of at least one adjacent pixel point of the pixel point among the sampled pixel points.

6. The method according to claim 1, wherein The performing defect detection based on the contour areas corresponding to the respective pixel points includes: for each pixel point, based on the pixel coordinates and pixel values of the pixel points included in the contour area corresponding to the pixel point, performing specified contour fitting processing on the contour area corresponding to the pixel point to obtain a contour fitting result; Perform a specified difference processing on the contour region corresponding to the pixel point and the contour fitting result to obtain a difference processing result; Determine whether there is a defect in the contour region corresponding to the pixel point based on the difference processing result.

7. A defect detection device, characterized in that, The device includes: A first acquisition module, configured to draw a detection path curve that matches the detection path of the image region to be measured through externally input curve drawing parameters; A second acquisition module, configured to use the detection path curve to acquire at least two pixel points on the detection path curve; An intercepting module, configured to, for each pixel point, perform a contour intercepting process on the image region to be measured based on the direction of the normal vector of the pixel point in the image region to be measured to obtain a contour region corresponding to the pixel point; A detection module, configured to perform defect detection based on the contour regions corresponding to the pixel points.

8. The device according to claim 7, wherein the device further includes: a generation module, configured to, after performing a contour intercepting process on the image region to be measured to obtain a contour region corresponding to the pixel point, and before performing defect detection based on the contour regions corresponding to the pixel points, if the detection path curve meets the requirements of a set irregular curve, select feature points from the contour regions corresponding to the pixel points respectively; and when the error requirements between the pixel points and the feature points are not met, generate a detection path curve based on the feature points, and return to the step of using the detection path curve to acquire at least two pixel points on the detection path curve; when the error requirements between the pixel points and the feature points are met, continue to execute the step of performing defect detection based on the contour regions corresponding to the pixel points; and / or, when performing the operation of respectively selecting feature points from the contour regions corresponding to the pixel points, the generation module is specifically configured to: for each pixel point, select a feature point from the contour region corresponding to the pixel point based on the pixel values of the pixel points included in the contour region corresponding to the pixel point; and / or, the intercepting module is specifically configured to: in the image region to be measured, intercept a first region starting from the pixel point along the direction of the normal vector of the pixel point in the image region to be measured; and / or, in the image region to be measured, intercept a second region starting from the pixel point along the direction opposite to the direction of the normal vector of the pixel point in the image region to be measured; and obtain the contour region corresponding to the pixel point according to the first region and / or the second region; and / or, the second acquisition module is specifically configured to: sample the detection path curve according to a set sampling interval to obtain the pixel coordinates and normal vectors of at least two pixel points on the detection path curve; wherein, for each pixel point, if the pixel point meets the requirements for the existence of a normal vector, determine the normal vector of the detection path curve at the pixel point as the normal vector of the pixel point, otherwise, determine the normal vector of the pixel point according to the normal vectors of at least one adjacent pixel point of the pixel point among the sampled pixel points; and / or, The detection module is specifically configured to: for each pixel point, perform specified contour fitting processing on the contour region corresponding to the pixel point based on the pixel coordinates and pixel values of the pixel points included in the contour region corresponding to the pixel point, so as to obtain a contour fitting result; perform specified difference processing on the contour region corresponding to the pixel point and the contour fitting result, so as to obtain a difference processing result; and determine whether there is a defect in the contour region corresponding to the pixel point based on the difference processing result.

9. An electronic device, characterized in that, The electronic device includes: a processor; and a computer-readable storage medium storing computer program instructions, and when the computer program instructions are run by the processor, the processor is caused to execute the steps in any one of the methods recited in claims 1 to 6.

Citation Information

Patent Citations

  • Detection method and device of bead body position defect

    CN106447649A

  • Edge defect detection method and device, electronic equipment and storage medium

    CN116188379A

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

    CN117218062A