Defect detection method and device and electronic equipment
By obtaining the detection path curve and normal vector direction of pixel points for contour intercepting, the high cost and low efficiency problems caused by the existing defect detection methods relying on manual customization solutions are solved, and automated defect detection is realized and detection efficiency is improved.
Patent Information
- Application Number
- CN202510490974.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2045-04-16
AI Technical Summary
The existing defect detection methods rely on manual customized solutions, resulting in high time and labor costs and low efficiency.
By obtaining the detection path curve matching the image area to be measured, multiple pixel points are obtained, and contour intercepting is performed based on the normal vector direction of each pixel point, the contour area corresponding to each pixel point is obtained, and defect detection is performed.
Automatic defect detection is realized, reducing labor costs and time, and improving the efficiency of defect detection.
Smart Images

Figure CN120013941A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine vision technology, and in particular to defect detection methods, devices and electronic equipment. Background Art
[0002] Defect detection is widely used in many fields such as machine vision. The objects of defect detection are also varied, such as welds, rubber strips and other flexible objects with no fixed shape.
[0003] Currently, in practical applications, a corresponding defect detection solution is usually manually customized for each defect detection object. However, this manual method will lead to high time and labor costs, thereby reducing the efficiency of defect detection. Summary of the invention
[0004] In view of this, the present application provides a defect detection method, device and electronic equipment to improve the efficiency of defect detection.
[0005] The present invention provides a defect detection method, which includes: Acquire a detection path curve that matches the detection path of the image area being detected; Using the detection path curve, acquiring 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 image area under test, performing contour interception processing on the image area under test to obtain a contour area corresponding to the pixel point; Defect detection is performed based on the contour area corresponding to each pixel point.
[0006] The present application also provides a defect detection device, which includes: A first acquisition module, used to acquire a detection path curve that matches the detection path of the detected image area; A second acquisition module, used to acquire at least two pixel points on the detection path curve using the detection path curve; A capture module, for performing contour capture processing on the image area under test based on the direction of the normal vector of the pixel point in the image area under test for each pixel point, so as to obtain a contour area corresponding to the pixel point; The detection module is used to perform defect detection based on the contour area corresponding to each pixel point.
[0007] The present application also provides an electronic device, the electronic device comprising: Processor; and A computer-readable storage medium stores computer program instructions, which, when executed by a processor, cause the processor to execute the steps of the above method.
[0008] An embodiment of the present application further provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes the steps in the above method.
[0009] It can be seen from the above technical scheme that in the embodiment of the present application, the detection path curve obtained that matches the detection path of the image area to be measured is first used to obtain at least two pixel points on the detection path curve. Then, based on the direction of the normal vector of each pixel point obtained, the contour area corresponding to each pixel point, that is, the area of interest to be detected, is obtained from the image area to be measured by contour interception, and defect detection is performed using the contour area corresponding to each pixel point to realize automatic defect detection in the image area to be measured. This can avoid high time and labor costs caused by manually customized defect detection schemes, and effectively improve the efficiency of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The accompanying drawings, which are incorporated in the specification and constitute a part of this application, illustrate embodiments consistent with the application and, together with the description, serve to explain the principles of the application.
[0011] Figure 1 A schematic diagram of the method flow provided in an embodiment of the present application.
[0012] Figure 2 A schematic diagram of a defect detection image provided in an embodiment of the present application.
[0013] Figure 3 A schematic diagram of a detection path curve provided in an embodiment of the present application.
[0014] Figure 4 A schematic diagram of the implementation of contour interception provided in an embodiment of the present application.
[0015] Figure 5 A schematic diagram of a stitched image provided in an embodiment of the present application.
[0016] Figure 6 A schematic diagram of the device structure provided in an embodiment of the present application.
[0017] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.
[0019] See also Figure 1 , Figure 1 The present invention provides a flowchart of a defect detection method. The method is applied to electronic devices. As an embodiment, the electronic device can be a notebook computer, a server, etc., which is not specifically limited here. Figure 1 As shown, the process may include the following steps: Step 101: Acquire a detection path curve that matches the detection path of the detected image area.
[0020] In this embodiment, the image area to be tested may refer to an image area corresponding to an externally input image containing a defect detection object. Optionally, in this embodiment, the externally input image is not specifically limited and can be flexibly set based on actual application requirements. For example, the externally input image can be a two-dimensional (2D) brightness image, a three-dimensional (3D) depth image, and so on.
[0021] In this embodiment, the detection path of the image area to be detected can be determined according to actual application requirements. For example, as an embodiment, the detection path of the image area to be detected can be of any shape, specifically, it can be a regular shape such as an arc, a rectangle, and a straight line segment, or it can be an irregular shape. Among them, a regular shape can refer to a shape with a clear shape and size, which can be divided according to a certain fixed rule or pattern; and in contrast to a regular shape, an irregular shape can refer to a shape that cannot be divided according to a certain fixed rule or pattern.
[0022] Based on this, the detection path curve that matches the detection path of the image area under test can be understood as a curve that matches the shape of the detection path of the image area under test. Among them, when the shape of the detection path of the image area under test is a regular shape, the curve that matches the detection path of the image area under test can be a regular curve, such as a circle, an arc, a rectangle, and a straight line segment, etc., which are not listed here one by one. When the shape of the detection path of the image area under test is an irregular shape, the curve that matches the detection path of the image area under test can be an irregular curve, that is, a free curve.
[0023] As an embodiment, in this step, a detection path curve matching the detection path of the detected image area is obtained. In a specific implementation, for example, a detection path curve matching the detection path of the detected image area can be drawn by using 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.
[0024] Optionally, based on the above description, for a regular curve, the externally input curve drawing parameters may include parameters that characterize the geometric features of the curve. For example, if the curve is a circle, the corresponding curve drawing parameters may include parameters such as the coordinates of the center of the circle, the radius, and a mathematical equation that characterizes the circle; if the curve is an arc, the corresponding curve drawing parameters may include parameters such as the coordinates of the center of the circle, the radius, the start and end angles of the arc, and a mathematical equation that characterizes the arc; if the curve is a rectangle, the corresponding curve drawing parameters may include parameters such as the length, width, the coordinates of a vertex of the rectangle, and a mathematical equation that characterizes the rectangle. Here, taking the mathematical equation that characterizes a circle as an example, the mathematical equation that characterizes a circle may be ,in, represents the coordinates of the center of the circle, represents the radius; as for other mathematical equations, they are not given here one by one.
[0025] For irregular curves, spline curves such as Cutmull-Rom spline curves can be used to represent them, wherein a spline curve can refer to a curve obtained by giving a set of control points, and the curve must pass through the control points. Based on this, the external input curve drawing parameters may include parameters representing the spline curve, such as a set of control points, and parameters such as a mathematical equation representing the spline curve.
[0026] In this embodiment, it should be noted that the coordinates, vertex coordinates, and control points included in the curve drawing parameters are all coordinate points in the same pixel coordinate system, where the pixel coordinate system refers to the pixel coordinate system corresponding to the image area under test.
[0027] Step 102: using the detection path curve, obtaining at least two pixel points on the detection path curve.
[0028] In this embodiment, the detection path curve is used in this step to obtain at least two pixel points on the detection path curve. There are many ways to implement it in practice. For example, as an embodiment, the detection path curve is sampled according to a set sampling interval to obtain 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 normal vector existence requirement, the normal vector of the detection path curve at the pixel point is determined as the normal vector of the pixel point; otherwise, the normal vector of the pixel point is determined based on the normal vector of at least one adjacent pixel point of the pixel point among the sampled pixels.
[0029] In this embodiment, as an embodiment, the detection path curve is sampled 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. In the specific implementation, for example, it can be: first select a pixel point from the detection path curve as the sampling starting point, that is, the first pixel point obtained by sampling. For example, taking the 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 can be determined. After that, the pixel coordinates of the next sampled pixel point can be determined according to the mathematical equation corresponding to the detection path curve and the set sampling interval, and the normal vector of the sampled pixel point can be determined, and so on, until the end point of the detection path curve is reached, such as the pixel point corresponding to the end angle of the arc.
[0030] As for how to determine the pixel coordinates of the next sampled pixel point based on the mathematical equation corresponding to the detection path curve and set the sampling interval in this step, as well as how to determine the normal vector of the pixel point, the following will give an example description and will not be repeated here.
[0031] Step 103 : for each pixel point, based on the direction of the normal vector of the pixel point in the image area under test, perform contour interception processing on the image area under test to obtain a contour area corresponding to the pixel point.
[0032] In this embodiment, in this step, based on the direction of the normal vector of the pixel point in the measured image area, the contour interception processing is performed on the measured image area to obtain the contour area corresponding to the pixel point. There are many ways to implement it in specific implementation. For example, as an embodiment, in the measured image area, along the direction of the normal vector of the pixel point in the measured image area, a first area is intercepted starting from the pixel point; then, the contour area corresponding to the pixel point is obtained based on the first area. Specifically, the first area can be used as the contour area corresponding to the pixel point.
[0033] For example, as an embodiment, in the measured image area, a second area is intercepted starting from the pixel point along a direction opposite to the direction of the normal vector of the pixel point in the measured image area; then, a 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.
[0034] For another example, as an embodiment, in the measured image area, a first area is intercepted starting from the pixel point along the direction of the normal vector of the pixel point in the measured image area; and, in the measured image area, a second area is intercepted starting from the pixel point along the direction opposite to the direction of the normal vector of the pixel point in the measured image area; thereafter, based on the first area and the second area, a contour area corresponding to the pixel point is obtained, specifically, the first area and the second area can be used as the contour area corresponding to the pixel point.
[0035] In this embodiment, as an embodiment, the above-mentioned interception of the first area starting from the pixel point can be, for example, implemented as follows: in the measured image area, the first interception length is extended along the direction of the normal vector of the pixel point in the measured image area to obtain a first extended line segment; then, on the first extended line segment, with the pixel point as the starting point, sampling is performed according to a set first sampling interval to obtain at least two first sampling points, and the image area composed of the first sampling points is used as the first area.
[0036] As for the above-mentioned interception of the second area from the pixel point, the specific implementation method is similar to the specific implementation method of intercepting the first area from the pixel point. For example, as an embodiment, in the image area to be measured, the second interception length is extended in a direction opposite to the direction of the normal vector of the pixel point in the image area to obtain a second extended line segment; then, on the second extended line segment, with the pixel point as the starting point, sampling is performed according to a set second sampling interval to obtain at least two second sampling points, and the image area formed by each second sampling point is used as the second area.
[0037] Optionally, the first interception length, the second interception length, the first sampling interval, and the second sampling interval can be flexibly set based on actual application requirements, and this embodiment does not specifically limit this. For example, the first interception length and the second interception length can be the same or different. The first sampling interval and the second sampling interval can be the same or different.
[0038] Step 104: perform defect detection based on the contour area corresponding to each pixel point.
[0039] As described above, the contour area 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 area corresponding to any pixel point includes at least the pixel coordinates and pixel value of the sampling point. If the image corresponding to the image area under test is a brightness image, the pixel value of the pixel point is the brightness value; if the image corresponding to the image area under test is a depth image, the pixel value of the pixel point is the depth value.
[0040] In this embodiment, the pixel coordinates of the pixel points in the measured image area are all integers, that is, the pixel values of the pixel points whose pixel coordinates are integers are known, while the pixel values of the pixel points whose pixel coordinates are non-integers are unknown. Based on this, as an embodiment, for any pixel point, in the process of obtaining the contour area 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 a bilinear interpolation processing method. Specifically, based on the pixel coordinates of the sampling point, at least one pixel point within the set range of the sampling point and with an integer pixel coordinate can be found from the measured image area, so as to use the pixel values of each pixel point found to perform a set calculation (such as weighted average, etc.) to obtain the pixel value of the sampling point.
[0041] Based on the above description, as an embodiment, in this step, defect detection is performed based on the contour area corresponding to each pixel point. In a specific implementation, for example, it can be as follows: for each pixel point, first, based on the pixel coordinates and pixel values of the pixels contained in the contour area corresponding to the pixel point, a specified contour fitting process is performed on the contour area corresponding to the pixel point to obtain a contour fitting result; then, a specified differential process is performed on the contour area corresponding to the pixel point and the contour fitting result to obtain a differential processing result; finally, based on the differential processing result, it is determined whether there is a defect in the contour area corresponding to the pixel point.
[0042] In this embodiment, the above-mentioned contour fitting result can be understood as an ideal contour area (that is, a contour area without any defects) fitted based on the contour area corresponding to the pixel point. Based on this, as an embodiment, the above-mentioned determination of whether the contour area corresponding to the pixel point has defects based on the difference processing result can be implemented as follows: if the difference processing result is greater than or equal to the set difference threshold, it means that the difference between the contour area corresponding to the pixel point and the contour fitting result is large, in which case it can be determined that the contour area corresponding to the pixel point has defects; if the difference processing result is less than the set difference threshold, it means that the difference between the contour area corresponding to the pixel point and the contour fitting result is small and can be ignored, in which case it can be determined that the contour area corresponding to the pixel point has no defects.
[0043] It should be noted that the above-mentioned embodiments of how to perform defect detection based on the contour area corresponding to each pixel point are only examples and are not intended to be limiting. This embodiment may also use a filter difference method, a model difference method, etc. to perform defect detection on the contour area corresponding to each pixel point; as for how to use the filter difference method and the model difference method to perform defect detection, this embodiment does not specifically limit it. Moreover, in addition to the above-mentioned defect detection on the contour area corresponding to each pixel point one by one, the contour areas corresponding to each pixel point may be pieced together into an overall contour area, so as to perform overall defect detection on the overall contour area using the above-mentioned defect detection method; or, each pixel point may be divided into multiple groups, each group of pixel points may include at least two pixel points, and then, for each group of pixel points, the contour areas corresponding to the group of pixel points are pieced together into one contour area, so as to perform defect detection on the pieced-together contour area using the above-mentioned defect detection method, and so on, and this embodiment does not specifically limit this.
[0044] So far, completed Figure 1 The process shown.
[0045] pass Figure 1 It can be seen from the shown process that in the embodiment of the present application, the acquired detection path curve that matches the detection path of the image area to be measured is first used to obtain at least two pixel points on the detection path curve. Then, based on the direction of the normal vector of each pixel point obtained, the contour area corresponding to each pixel point, that is, the area of interest to be detected, is obtained from the image area to be measured by contour interception, and defect detection is performed using the contour area corresponding to each pixel point to realize automatic defect detection in the image area to be measured. This can avoid high time and labor costs caused by manually customized defect detection schemes, and effectively improve the efficiency of defect detection.
[0046] The following describes how to 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 the above step 102.
[0047] In this embodiment, as an embodiment, the above-mentioned pixel coordinates of the next sampled pixel point are determined based on the mathematical equation corresponding to the detection path curve and the set sampling interval. In the specific implementation, for example, it can be: 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 point on the detection path curve and with an interval length of the set sampling interval between the currently sampled pixel point can be directly calculated.
[0048] 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, the set sampling interval can be gradually approached by an approximation method such as bisection to obtain the pixel coordinates of the next sampled pixel point on the detection path curve whose interval length with the currently sampled pixel point is approximately the set sampling interval.
[0049] The following describes how to determine the normal vector of the pixel point in the above step 102.
[0050] In this embodiment, as an embodiment, 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 the pixel point, then it is determined that the pixel point meets the set normal vector existence requirement. In this case, the normal vector of the detection path curve at the pixel point can be determined as the normal vector of the pixel point; wherein, the normal vector of the detection path curve at the pixel point can be a vector that is perpendicular to the tangent of the detection path curve at the pixel point and whose direction points to the bending direction of the detection path curve.
[0051] If it is determined based on the mathematical equation corresponding to the detection path curve that the detection path curve is not differentiable at the pixel point, such as not being differentiable at the vertex of a rectangle, then it is determined that the pixel point does not meet the set normal vector existence requirement. In this case, the normal vector of the pixel point can be determined based on the normal vector of at least one adjacent pixel point of the pixel point among the sampled pixel points.
[0052] As an embodiment, the normal vector of the pixel point is determined based on the normal vector of at least one adjacent pixel point of the pixel point among the sampled pixel points. In a specific implementation, for example, a vector passing through the pixel point and being parallel to and in the same direction as the reference vector can be determined as the normal vector of the pixel point.
[0053] Optionally, the above-mentioned reference vector can be, for example, the normal vector of the previous pixel point among the sampled pixel points, the normal vector of the next pixel point among the sampled pixel points, or the sum of the normal vector of the previous pixel point and the normal vector of the next pixel point, etc., which is not specifically limited in this embodiment.
[0054] This completes the further description of the above step 102.
[0055] The above step 103 is further described below.
[0056] In this embodiment, compared with a regular curve, when the detection path curve is an irregular curve, the detection path curve drawn by the externally 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. In addition, since this embodiment iteratively optimizes the detection path curve, the detection path curve initially drawn can be relatively rough, so that the defect detection method of this embodiment has better usability.
[0057] Specifically, as an embodiment, this embodiment can determine whether the detection path curve meets the set non-regular curve (i.e., irregular curve) requirements after performing contour interception processing on the image area to be tested to obtain the contour area corresponding to the pixel point, and before performing defect detection based on the contour area corresponding to each pixel point. If so, feature points are selected respectively from the contour area corresponding to each pixel point.
[0058] Afterwards, when the set error requirements are not met between each pixel point and each feature point, it means that the current detection path curve still needs to continue to be iteratively optimized. In this case, a detection path curve can be generated based on each feature point, and the step of using the detection path curve to obtain at least two pixel points on the detection path curve is returned; when the set error requirements are 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 no further optimization is needed. In this case, the step of performing defect detection based on the contour area corresponding to each pixel point can be continued.
[0059] In this embodiment, optionally, the above-mentioned pixel points and the feature points do not meet the set error requirements, which may mean that the average value of the difference 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 above-mentioned pixel points and the feature points meet the set error requirements, which may mean that the average value of the difference 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.
[0060] As another embodiment, this embodiment may first determine whether the detection path curve meets the set non-regular curve (i.e., irregular curve) requirement after performing contour interception processing on the detected image area to obtain the contour area corresponding to the pixel point and before performing defect detection based on the contour area corresponding to each pixel point. If so, then: When the number of acquired detection path curves is not the set number, it means that the detection path curve needs to continue to be iteratively optimized. In this case, feature points can be selected from the contour area corresponding to each pixel point respectively to generate a detection path curve based on each feature point, and return to the above step of using the detection path curve to obtain at least two pixel points on the detection path curve.
[0061] When the number of acquired detection path curves reaches the set number, it means that the detection path curve has met the requirements of iterative optimization and no further optimization is required. In this case, the step of performing defect detection based on the contour area corresponding to each pixel point can be continued.
[0062] In this embodiment, the above-mentioned externally input curve drawing parameters may also include indication information for indicating whether the curve to be drawn is an irregular curve. Based on this, as an embodiment, the above-mentioned determination of whether the detection path curve meets the set irregular curve requirements may be implemented as follows: if the curve to be drawn is determined to be an irregular curve based on the indication information in the externally input curve drawing parameters, then it is determined that the detection path curve meets the set irregular curve requirements; otherwise, it is determined that the detection path curve does not meet the set irregular curve requirements.
[0063] In this embodiment, as an embodiment, the feature points are selected from the contour area corresponding to each pixel point. In a specific implementation, for example, for each pixel point, based on the pixel values of the pixels included in the contour area corresponding to the pixel point, a feature point is selected from the contour area corresponding to the pixel point. Optionally, the selected feature point may be, for example, a pixel point with the highest pixel value in the contour area corresponding to the pixel point, or a pixel point with the lowest pixel value in the contour area corresponding to the pixel point, which is not specifically limited in this embodiment.
[0064] In order to facilitate understanding of the specific implementation process of the above defect detection method, a specific embodiment is described below by way of example.
[0065] In this embodiment, the user firstly uploads an image containing a defect detection object (such as Figure 2 The defect detection image shown), and curve drawing parameters are input into the electronic device.
[0066] The electronic device draws a detection path curve matching the detection path of the image area to be tested in the image area corresponding to the external input image (that is, the image area to be tested) through the curve drawing parameters input externally, for example Figure 3 The detection path curve is shown.
[0067] After obtaining the detection path curve, the electronic device will sample 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 obtain the pixel coordinates and normal vectors of at least two pixel points on the detection path curve, please refer to the above related description, which will not be repeated here.
[0068] For each pixel point obtained by the above sampling, the electronic device will perform contour interception processing on the tested image area based on the direction of the normal vector of the pixel point in the tested image area to obtain the contour area corresponding to the pixel point. The contour areas corresponding to each pixel point are aligned and arranged to obtain a spliced image for subsequent defect detection processing.
[0069] Specifically, as an example, see Figure 4 The implementation diagram of contour interception shown in the figure shows that for each pixel point obtained by the above sampling, the electronic device will extend a first interception length in the measured image area along the direction of the normal vector of the pixel point in the measured image area to obtain a first extended line segment, and extend a second interception length in 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. Afterwards, on the extended line segment formed by the first extended line segment and the second extended line segment, a pixel point is selected from the extended line segment as the starting point, for example, one of the end points of the extended line segment can be selected, and the extended line segment is sampled according to the set interception sampling interval to obtain at least two sampling points, so that the image area formed by 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, see Figure 5 The schematic diagram of the stitched image shown is Figure 3 The detection path curve shown is subjected to the above corresponding processing to obtain a stitched image.
[0070] After the electronic device performs contour interception processing on the image area under test to obtain the contour area corresponding to the pixel point, and before performing defect detection based on the contour area corresponding to each pixel point, it will also determine whether the detection path curve meets the set irregular curve requirements. If so, it will select feature points from the contour area corresponding to each pixel point respectively; and when the set 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 electronic device returns to the step of sampling the detection path curve according to the set sampling interval after obtaining the detection path curve; when the set error requirements are met between each pixel point and each feature point, continue to execute the subsequent step of performing defect detection based on the contour area corresponding to each pixel point.
[0071] After obtaining the contour area corresponding to each pixel point, the electronic device will perform defect detection based on the contour area corresponding to each pixel point, thereby realizing defect detection of the image area under test. As for how to perform defect detection based on the contour area corresponding to each pixel point, please refer to the above related description, which will not be repeated here.
[0072] At this point, the description of the method provided in the embodiment of the present application is completed. The following is a description of the device provided in the embodiment of the present application: See also Figure 6 , Figure 6 This is a schematic diagram of the structure of a defect detection device provided in an embodiment of the present application. The device is applied to electronic equipment. Figure 6 As shown, the defect detection device 600 includes: A first acquisition module 601 is used to acquire a detection path curve that matches the detection path of the detected image area; A second acquisition module 602 is used to acquire at least two pixel points on the detection path curve using the detection path curve; An interception module 603 is used for performing contour interception processing on the image area under test based on the direction of the normal vector of the pixel point in the image area under test for each pixel point to obtain a contour area corresponding to the pixel point; The detection module 604 is used to perform defect detection based on the contour area corresponding to each pixel point.
[0073] As an embodiment, the first acquisition module 601 is specifically used to draw a detection path curve matching the detection path of the detected image area through externally input curve drawing parameters.
[0074] As an embodiment, the above-mentioned device further includes: a generating module, which is used to select feature points from the contour area corresponding to each pixel point respectively after performing contour interception processing on the image area to be tested to obtain the contour area corresponding to the pixel point, and before performing defect detection based on the contour area corresponding to each pixel point, if the detection path curve meets the set irregular curve requirements; 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 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, the step of performing defect detection based on the contour area corresponding to each pixel point is continued.
[0075] As an embodiment, the generation module, when executing the selection of feature points from the contour area corresponding to each pixel point, is specifically used to: for each pixel point, based on the pixel value of the pixel point contained in the contour area corresponding to the pixel point, select the feature point from the contour area corresponding to the pixel point.
[0076] As an embodiment, the interception module 603 is specifically used for: In the measured image area, along the direction of the normal vector of the pixel point in the measured image area, a first area is intercepted starting from the pixel point; and / or, In the measured image area, intercepting a second area starting from the pixel point along a direction opposite to the direction of the normal vector of the pixel point in the measured image area; According to the first region and / or the first area, a contour region corresponding to the pixel point is obtained.
[0077] As an embodiment, the second acquisition module 602 is specifically configured to: Sampling the detection path curve according to a set sampling interval to obtain 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 set normal vector existence requirement, the normal vector of the detection path curve at the pixel point is determined as the normal vector of the pixel point; otherwise, the normal vector of the pixel point is determined based on the normal vector of at least one adjacent pixel point of the pixel point among the sampled pixel points.
[0078] As an embodiment, the detection module 604 is specifically configured to: For each pixel point, based on the pixel coordinates and pixel values of the pixel points contained in the contour area corresponding to the pixel point, the contour area corresponding to the pixel point is subjected to a designated contour fitting process to obtain a contour fitting result; Performing a specified difference processing on the contour area corresponding to the pixel point and the contour fitting result to obtain a difference processing result; Based on the difference processing result, it is determined whether there is a defect in the contour area corresponding to the pixel point.
[0079] So far, completed Figure 6 Structural description of the device shown.
[0080] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0081] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0082] See also Figure 7, is a schematic diagram of the hardware structure of an electronic device provided by an exemplary embodiment of the present 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 communicate 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. The electronic device may also include other hardware according to the actual function of the electronic device, which will not be described in detail.
[0083] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented.
[0084] Exemplarily, the computer-readable storage medium may be any electronic, magnetic, optical or other physical storage device that may contain or store information, such as executable instructions, data, etc. For example, the computer-readable storage medium may be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof. The processor and memory may be supplemented by or incorporated into a dedicated logic circuit.
[0085] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A defect detection method, characterized in that: The method comprises: Acquire a detection path curve that matches the detection path of the image area being detected; Using the detection path curve, acquiring 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 image area under test, performing contour interception processing on the image area under test to obtain a contour area corresponding to the pixel point; Defect detection is performed based on the contour area corresponding to each pixel point.
2. The method according to claim 1, characterized in that The step of acquiring a detection path curve that matches the detection path of the detected image area includes: A detection path curve matching the detection path of the detected image area is drawn using curve drawing parameters input externally.
3. The method according to claim 1, characterized in that After performing contour interception processing on the image area to be tested to obtain the contour area corresponding to the pixel point, and before performing defect detection based on the contour area corresponding to each pixel point, the method further includes: If the detection path curve meets the set irregular curve requirements, feature points are selected from the contour area corresponding to each pixel point; and when the error between each pixel point and each feature point does not meet the set error requirements, a detection path curve is generated based on each feature point, and the process returns 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, the step of performing defect detection based on the contour area corresponding to each pixel point is continued.
4. The method according to claim 3, characterized in that The selecting of feature points from the contour areas corresponding to the pixels comprises: For each pixel point, a feature point is selected from the contour area corresponding to the pixel point based on the pixel values of the pixels included in the contour area corresponding to the pixel point.
5. The method according to claim 1, characterized in that The performing contour interception processing 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 includes: In the measured image area, along the direction of the normal vector of the pixel point in the measured image area, a first area is intercepted starting from the pixel point; and / or, In the measured image area, intercepting a second area starting from the pixel point along a direction opposite to the direction of the normal vector of the pixel point in the measured image area; According to the first region and / or the first area, a contour region corresponding to the pixel point is obtained.
6. The method according to claim 1, characterized in that The using the detection path curve to obtain at least two pixel points on the detection path curve comprises: Sampling the detection path curve according to a set sampling interval to obtain 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 set normal vector existence requirement, the normal vector of the detection path curve at the pixel point is determined as the normal vector of the pixel point; otherwise, the normal vector of the pixel point is determined based on the normal vector of at least one adjacent pixel point of the pixel point among the sampled pixel points.
7. The method according to claim 1, characterized in that The defect detection based on the contour area corresponding to each pixel point includes: For each pixel point, based on the pixel coordinates and pixel values of the pixel points contained in the contour area corresponding to the pixel point, the contour area corresponding to the pixel point is subjected to a designated contour fitting process to obtain a contour fitting result; Performing a specified difference processing on the contour area corresponding to the pixel point and the contour fitting result to obtain a difference processing result; Based on the difference processing result, it is determined whether there is a defect in the contour area corresponding to the pixel point.
8. A defect detection device, characterized in that: The device comprises: A first acquisition module, used to acquire a detection path curve that matches the detection path of the detected image area; A second acquisition module, used to acquire at least two pixel points on the detection path curve using the detection path curve; A capture module, for performing contour capture processing on the image area under test based on the direction of the normal vector of the pixel point in the image area under test for each pixel point, so as to obtain a contour area corresponding to the pixel point; The detection module is used to perform defect detection based on the contour area corresponding to each pixel point.
9. The device according to claim 8, characterized in that The first acquisition module is specifically used to: draw a detection path curve matching the detection path of the detected image area through externally input curve drawing parameters; and / or, The device further includes: a generating module, which is used to select feature points from the contour area corresponding to each pixel point respectively after performing contour interception processing on the measured image area to obtain the contour area corresponding to the pixel point and before performing defect detection based on the contour area corresponding to each pixel point if the detection path curve meets the set irregular curve requirement; and when the error requirements set 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 obtain at least two pixel points on the detection path curve; when the error requirements set between each pixel point and each feature point are met, continue to perform the step of performing defect detection based on the contour area corresponding to each pixel point; and / or, The generating module, when executing the selection of feature points from the contour area corresponding to each pixel point, is specifically used to: for each pixel point, based on the pixel value of the pixel point included in the contour area corresponding to the pixel point, select the feature point from the contour area corresponding to the pixel point; and / or, The interception module is specifically used to: intercept a first area from the pixel point in the measured image area along the direction of the normal vector of the pixel point in the measured image area; and / or, in the measured image area, intercept a second area from the pixel point in the direction opposite to the direction of the normal vector of the pixel point in the measured image area; obtain a contour area corresponding to the pixel point based on the first area and / or the first area; and / or, The second acquisition module is specifically used to: sample the detection path curve according to a set sampling interval to obtain 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 normal vector existence requirement, the normal vector of the detection path curve at the pixel point is determined as the normal vector of the pixel point, otherwise, the normal vector of the pixel point is determined based on the normal vector of at least one adjacent pixel point of the pixel point among the sampled pixel points; and / or, The detection module is specifically used to: for each pixel point, based on the pixel coordinates and pixel values of the pixel points contained in the contour area corresponding to the pixel point, perform a specified contour fitting process on the contour area corresponding to the pixel point to obtain a contour fitting result; perform a specified differential process on the contour area corresponding to the pixel point and the contour fitting result to obtain a differential process result; and determine whether there is a defect in the contour area corresponding to the pixel point based on the differential process result.
10. An electronic device, characterized in that: The electronic device includes: Processor; and A computer-readable storage medium, wherein computer program instructions are stored in the computer-readable storage medium, and when the computer program instructions are executed by the processor, the processor executes the steps in any one of the methods of claims 1 to 7.
Citation Information
Patent Citations
Detection method and device of bead body position defect
CN106447649A
River suspension pollutant prediction method and prediction system
CN112988945A
Defect detection method and device based on machine vision and electronic equipment
CN115546145A
Edge defect detection method and device, electronic equipment and storage medium
CN116188379A
Defect detection method and device, electronic equipment and storage medium
CN117011218A