Edge detection method, defect detection method, and detection apparatus

CN115861351BActive Publication Date: 2026-09-04SUZHOU MEGAROBO TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211565821.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-07
Publication Date
2026-09-04
Estimated Expiration
2042-12-07

AI Technical Summary

Technical Problem

然而,由于产品种类、形态并不统一,使用机器视觉进行产品缺陷检测时,遍历搜索边缘点很难快速检测产品的边缘,同时检测的产品边缘很难避免产品本身形态变化和随机性背景干扰的影响,容易造成检测的产品边缘与实际的产品边缘存在难以接受的偏差,并导致产品缺陷检测失败,需要重新检测或人工处理

Benefits of technology

[0019] This invention calculates the offset based on a template image and the image under test. The calculated offset determines the relative position of the Region of Interest (ROI) with a specified direction (a designated direction identifier vector) in the image under test. This avoids the need to search and determine the ROI generation location due to variations in product shape against the background. In this invention, the segmented regions are all directional transformations relative to the adjusted direction identifier vector. These segmented regions discretize and directionally arrange the ROIs, avoiding edge point searches within the entire ROI. This enables edge detection for products with irregular edges and production line applications with acceptable inspection times in actual production. It improves the use of computing resources and the inspection time per device, allowing for rapid edge fitting and detection. Therefore, this invention avoids the difficulty in determining device edges caused by variations in device shape and random background interference, thereby improving edge detection efficiency and defect detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115861351B_ABST
    Figure CN115861351B_ABST
Patent Text Reader

Abstract

The application provides an edge detection method, a defect detection method and a detection device, and belongs to the technical field of image processing. The method comprises the following steps: acquiring a to-be-detected image; generating a current region of interest corresponding to a template region of interest in the to-be-detected image according to the offset of the to-be-detected image and a template image and the template region of interest configured in the template image, wherein the template region of interest of the template image is configured with a theoretical contour line of a target edge, and the template region of interest has a specified direction identification vector; segmenting the current region of interest in a direction perpendicular to the direction identification vector of the current region of interest to obtain a plurality of segmented regions; determining edge points in each segmented region; and fitting the edge points into an edge line. The application can avoid the influence of the morphology change of a to-be-detected device and random background interference on the determination of the edge of the device, thereby improving the edge detection efficiency and the defect detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically to an edge detection method, a defect detection method, a detection device, an electronic device, and a machine-readable storage medium. Background Technology

[0002] With continuous economic and social development and rising living standards, the demand for various products is rapidly shifting from focusing on quantity to pursuing quality improvement. For manufacturers, striving to achieve high-end equipment manufacturing in the new era, promoting the industry towards the high end of the value chain, improving product quality, and meeting users' high demands for product quality have become urgent needs. However, the diverse forms and complex structures of products make product quality testing challenging, placing higher demands on product testing equipment in this new era.

[0003] Studies show that machine vision offers advantages in production efficiency for inspecting products for quality issues. However, due to the lack of uniformity in product types and forms, when using machine vision for product defect detection, it is difficult to quickly detect product edges by traversing and searching for edge points. At the same time, it is difficult to avoid the influence of changes in the product's shape and random background interference, which can easily lead to unacceptable deviations between the detected product edges and the actual product edges, resulting in product defect detection failures and requiring re-inspection or manual processing. Summary of the Invention

[0004] The purpose of this invention is to provide an edge detection method, a defect detection method, and a detection device to avoid the difficulty in determining the edge of the device due to the influence of changes in the shape of the device under test and random background interference, thereby improving the edge detection efficiency and the defect detection accuracy.

[0005] To achieve the above objectives, embodiments of the present invention provide an edge detection method, the edge detection method comprising: Acquire the image to be tested; Based on the offset between the image to be tested and the template image and the template region of interest configured in the template image, a current region of interest corresponding to the template region of interest is generated in the image to be tested, wherein the template region of interest of the template image is configured with the theoretical contour line of the target edge, and the template region of interest has a specified direction identifier vector; The region of interest is divided into multiple segments along the direction of the direction identifier vector perpendicular to the region of interest. Identify the edge points in each segmented region and fit the edge points as edge lines.

[0006] Specifically, after acquiring the image to be tested, and before generating a current region of interest in the image to be tested corresponding to the template region of interest based on the offset between the image to be tested and the template image and the template region of interest configured in the template image, the process includes: Calculate the offset between the template image and the image to be tested.

[0007] Specifically, the offset between the template image and the image to be tested is calculated, including any one of the following: Based on the reference point and reference line segment in the template image, and the corresponding point and corresponding line segment in the image to be tested, the coordinate offset of the reference point and the corresponding point and the angular offset of the reference line segment and the corresponding line segment are calculated, and the coordinate offset and the angular offset are used as the offset. Based on the outline of the device under test in the template image and the image under test, as well as the center position of the device under test, the angular offset of the outline of the device under test in the template image and the image under test and the coordinate offset of the center position are determined, and the coordinate offset and the angular offset are used as the offset. And the offset is calculated by extracting the outline of the device under test from the image under test.

[0008] Specifically, after determining the edge points in each segmented region and before fitting the edge points as edge lines, the edge detection method further includes: Filter out edge points with abnormal coordinate values ​​to obtain the remaining edge points.

[0009] Specifically, the step of filtering edge points with abnormal coordinate values ​​to obtain the remaining edge points includes: Perform affine transformations on the edge points of each segmented region; Statistically obtain the metric values ​​of the coordinates of the transformed edge points; Remove abnormal edge points where the difference between the coordinate value and the measurement value of the abnormal edge point is higher than the measurement threshold; Perform an inverse affine transformation on the edge points obtained after removal.

[0010] Specifically, performing an affine transformation on the edge points of each segmented region includes: Determine the center point corresponding to the coordinate values ​​of the edge points in each segmented region; Initialize the transformation matrix of the current region of interest, which rotates around the center point; Determine the direction of the specified direction identifier vector and the first rotation angle of the specified direction; The direction of the orientation identifier vector of the current region of interest and the second rotation angle of the specified direction are determined by the offset angle in the offset and the first rotation angle. Using the transformation matrix and the second rotation angle, the edge points in each segmented region are rotated to edge points along the specified direction.

[0011] Specifically, the step of filtering edge points with abnormal coordinate values ​​to obtain the remaining edge points includes: Connect adjacent edge points in pairs to determine the edge segments; Determine the angle between each edge segment and the direction of the direction identifier vector of the current region of interest; Exclude edge points that are at intersections, which are edge points between edge segments with an angle higher than the angle threshold.

[0012] Specifically, the region of interest in the template includes both the local image region and the local background region of the device under test in the template image, as well as the edge line between the two.

[0013] This invention provides a defect detection method, which includes: Based on the aforementioned edge detection method, the edge lines are determined; Based on the edge line, the defect area is determined; Calculate the parameters of the defect region, and use the parameters to determine whether the device under test has a defect.

[0014] Specifically, the target region is the area outside the device under test, defined by the edge line. This region is located in the region of interest for defect detection, which includes the current region of interest. The determination of the defect region based on the edge line includes any one of the following: The target object within the target area is extracted using an image segmentation algorithm, and the defect area is determined based on the target object. The image segmentation algorithm determines the suspected defect region in the region of interest for defect detection, and the defect region is determined based on the intersection of the suspected defect region and the target region.

[0015] This invention provides a detection device, which includes: The acquisition module is used to acquire the image to be tested; The generation module is used to generate a current region of interest in the image to be tested that corresponds to the template region of interest, based on the offset between the image to be tested and the template image and the template region of interest configured in the template image. The template region of interest in the template image is configured with the theoretical contour line of the target edge, and the template region of interest has a specified direction identifier vector. The segmentation module is used to segment the current region of interest into multiple segmented regions by following the direction of the direction identifier vector perpendicular to the current region of interest. The fitting module is used to determine the edge points in each segmented region and fit these edge points as edge lines.

[0016] Specifically, the detection device also includes: A defect detection module is used to determine the defect area based on the edge line; The defect detection module is used to calculate the parameters of the defect area and determine whether the device under test has a defect based on the parameters.

[0017] In another aspect, embodiments of the present invention provide an electronic device, the electronic device comprising: At least one processor; A memory connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the aforementioned method by executing the instructions stored in the memory.

[0018] In another aspect, embodiments of the present invention provide a machine-readable storage medium storing machine instructions that, when executed on a machine, cause the machine to perform the aforementioned method.

[0019] This invention calculates the offset based on a template image and the image under test. The calculated offset determines the relative position of the Region of Interest (ROI) with a specified direction (a designated direction identifier vector) in the image under test. This avoids the need to search and determine the ROI generation location due to variations in product shape against the background. In this invention, the segmented regions are all directional transformations relative to the adjusted direction identifier vector. These segmented regions discretize and directionally arrange the ROIs, avoiding edge point searches within the entire ROI. This enables edge detection for products with irregular edges and production line applications with acceptable inspection times in actual production. It improves the use of computing resources and the inspection time per device, allowing for rapid edge fitting and detection. Therefore, this invention avoids the difficulty in determining device edges caused by variations in device shape and random background interference, thereby improving edge detection efficiency and defect detection accuracy.

[0020] This invention specifically determines the offset between images through reference points, lines, and contours, featuring rapid implementation and simple calculation. This invention can perform a rotational affine transformation on candidate edge points along any direction to a specified direction (such as the horizontal direction), and the affine transformation avoids the influence of the offset between the ROI in the template image and the image under test. This allows for the calculation of the median of its vertical coordinates, filtering out points with large differences between their vertical coordinates and the median, calculating the angle between adjacent points of the filtered points and the angle with the detection area, and further filtering out points with large differences as the final fitting points to fit the edge, thus achieving robustness and accuracy in device edge detection.

[0021] Other features and advantages of the embodiments of the present invention will be described in detail in the following detailed description section. Attached Figure Description

[0022] The accompanying drawings are provided to further illustrate embodiments of the present invention and form part of the specification. They are used together with the following detailed description to explain the embodiments of the present invention, but do not constitute a limitation thereof. In the drawings: Figure 1 This is a schematic diagram of the main method steps in an embodiment of the present invention; Figure 2 This is a schematic diagram of an exemplary template image according to an embodiment of the present invention; Figure 3 This is a schematic diagram of an exemplary workpiece template image according to an embodiment of the present invention; Figure 4 This is a schematic diagram of an exemplary workpiece image to be tested that is offset from a template image, according to an embodiment of the present invention. Figure 5 This is a schematic diagram of an exemplary segmented region according to an embodiment of the present invention; Figure 6 This is a schematic diagram of another exemplary segmented region according to an embodiment of the present invention; Figure 7 This is a schematic diagram illustrating the location of edge points within a segmented region, as exemplified in an embodiment of the present invention. Figure 8 This is a schematic diagram illustrating the coordinate positions of an exemplary set of edge points according to an embodiment of the present invention; Figure 9 This is a schematic diagram illustrating the coordinate positions of an exemplary edge point according to an embodiment of the present invention; Figure 10 This is a schematic diagram of a line segment connecting an exemplary edge point according to an embodiment of the present invention; Figure 11 This is a schematic diagram of the ROI region in an exemplary defect detection according to an embodiment of the present invention; Figure 12This is a schematic diagram of an exemplary defect area according to an embodiment of the present invention; Figure 13 This is a schematic diagram of a workpiece in the first exemplary application scenario of this invention. Figure 14 This is a schematic diagram of a workpiece in the first exemplary application scenario of this invention. Figure 15 This is a schematic diagram of a workpiece in a second exemplary application scenario according to an embodiment of the present invention; Figure 16 This is a schematic diagram of a workpiece in a third exemplary application scenario of the present invention. Detailed Implementation

[0023] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the scope of the present invention.

[0024] As described above, current defect detection generally uses machine vision for product defect detection. Specifically, it involves traversing and searching for edge points to obtain the product edge, and then detecting defects on the product edge. This can be achieved by defining a region of interest, then using threshold segmentation to search for edge points, and finally fitting an edge line based on these edge points using the least squares method. However, because this method involves blindly searching within a region of interest, it is inefficient. Furthermore, if the threshold is not set appropriately, the fitted line may not be a true edge line, thus affecting the defect detection effect. This invention will provide a solution for product edge detection and defect detection.

[0025] Example 1 This invention provides an edge detection method that can be used to detect defects in devices. For example... Figure 1 The edge detection method may include: S1) Obtain the image to be tested; S2) Based on the offset between the image to be tested and the template image and the template region of interest configured in the template image, generate a current region of interest in the image to be tested corresponding to the template region of interest, wherein the template region of interest of the template image is configured with the theoretical contour line of the target edge, and the template region of interest has a specified direction identifier vector; S3) Divide the current region of interest into multiple segmented regions along the direction of the direction identifier vector perpendicular to the current region of interest; S4) Determine the edge points in each segmented region and fit the edge points as edge lines.

[0026] In this embodiment of the invention, the instructions corresponding to the aforementioned edge detection method can be executed by a visual inspection device. This visual inspection device may include a camera and a controller. Specifically, the controller can execute the corresponding instructions; the controller can use the camera to photograph the device under test and acquire images (data) from the camera, i.e., the image under test can be acquired in step S1). In some advantageous application scenarios, the camera can be equipped with a lens, and the inspection station on the production line where the device under test is located can be equipped with a light source, thereby improving the device's focus, brightness, and contrast in the image under test.

[0027] In this embodiment of the invention, the aforementioned image to be tested is the region of interest (current ROI) of the image to be tested, generated relative to the template image.

[0028] The template image can include the target edge of a device on the production line. The device presented in the template image can be a portion of the device. The template image can be marked with a template region of interest (ROI), which can be configured with the theoretical contour line of the aforementioned target edge. That is, the local image of the marked template ROI includes the theoretical contour line of the aforementioned target edge, which can include one or more theoretical edge segments. The template ROI can include both a local (image) region (a local image) of the device under test in the template image and a local background region (also a local image), as well as the edge line or narrow edge band region between the two. Based on device characteristics, regions with an aspect ratio (long side to short side) greater than a specified value can be considered narrow band regions. If an edge line exists within this narrow band region, it can be called an edge narrow band region. The edge line or edge narrow band region can be the target edge. In some application scenarios, the template image can include the device (partial image) and the background (partial image) of the detection station where the device is located. The template ROI can be configured with a portion of the device locality and the background. For example, if the device is a winding workpiece, the device locality is one end of the winding workpiece, and the area near this end (within any specified distance range) is a portion of the background. To facilitate computation, the ROI can be a rectangular region, referring to the image area within the rectangular frame.

[0029] In an exemplary template image disclosed in this invention, such as Figure 2The device under test 100 can be a wire-wound workpiece (to better demonstrate the actual application scenario, a physical workpiece and a real background 101 are used as examples). The edge of any end of the wire-wound workpiece can be selected as the target edge. In the template image, the template ROI 102 can include the local area of ​​the device under test 100 and the local area of ​​the background area 101, as well as the target edge between them. The direction of the direction identifier vector of the template ROI 102 is presented and represented by the arrow 103. The direction of the direction identifier vector of the template ROI 102 (the direction of the arrow 103) can be parallel to the extension direction of the target edge, that is, it describes the direction of the target edge. Figure 2 The "+" symbol can represent the center point of the template ROI102, and the coordinates of this center point can be used to establish a coordinate system during the calculation process.

[0030] In the template image described above, the template ROI can have a specified direction identifier vector. This direction identifier vector can be a numerical vector used to describe the characteristics of the straight line direction of the target edge of the device under test within the ROI. This characteristic refers to the local distribution characteristics of the device and the background, where the target edge (region or line) divides the ROI into a partial area of ​​the device and a partial area of ​​the background. The direction of the line containing the direction identifier vector is not necessarily (based on the actual detection results) the direction of the straight line containing the target edge in the current ROI of the image under test, but the direction of the line containing the direction identifier vector can be specified as (or parallel to) the direction of the straight line containing the target edge in the template ROI of the template image, which simplifies calculations. This direction identifier vector can be used as a configuration parameter for the template ROI. The angle between any tangent line of the aforementioned theoretical contour line and the straight line passing through the specified direction identifier vector can be greater than or equal to 0° and less than 90°. The direction identifier described by this direction identifier vector can be displayed in the template image. In some application scenarios, the directional marker can be an arrow. This arrow can be perpendicular to the straight line containing one edge of the template ROI, or it can point outside the template ROI. The angle between the straight line containing this edge and the theoretical contour line is greater than the angle between the straight line containing the other edge (which is perpendicular to this edge in the template ROI) and the theoretical contour line. The arrow can also be collinear with the straight line containing the other edge of the template ROI, that is, the arrow mark in the template image can overlap with the other edge.

[0031] Based on the above, the current ROI can be generated in the test image using the relative relationship between the test image and the template image. Before generating the current ROI, the aforementioned edge detection method may include: A) Calculate the offset between the template image and the image to be tested.

[0032] Calculating this offset can include any of the following: A01) Based on the reference point and reference line segment in the template image, and the corresponding point and corresponding line segment in the image to be tested, calculate the coordinate offset of the reference point and the corresponding point, and the angular offset of the reference line segment and the corresponding line segment, and use the coordinate offset and the angular offset as the offset. A02) Based on the template image and the outline of the device under test in the image under test, as well as the center position of the device under test, determine the angular offset of the outline of the device under test in the template image and the image under test, and the coordinate offset of the center position, and use the coordinate offset and the angular offset as the offset. A03) Extract the outline of the device under test from the image under test and calculate the offset.

[0033] In step A01 above, the theoretical contour lines and specified points of the template image can be used as reference line segments and reference points, respectively. For example, two intersecting theoretical edge line segments can be used as reference line segments, and the intersection point of the lines perpendicular to these two theoretical edge line segments can be used as reference points. The image to be tested can be binarized to determine the two contour lines corresponding to the device under test in the image to be tested, as well as the intersection point of the corresponding lines perpendicular to these two contour lines. Through the reference line segments and reference points, and the corresponding two contour lines and intersection points, the displacement coordinates and rotation angles are determined, which are used as coordinate offsets and angular offsets, respectively, thereby obtaining the offset between the image to be tested and the template image. Even if there are slight design adjustments between the device in the template image and the device in the image to be tested, the template image will not become unusable in the detection process of the adjusted device, demonstrating good versatility.

[0034] In step A02 above, the relative positions of devices in a batch on the production line or devices passing through a designated inspection station are fixed. For example, the relative positions of the center point of the winding part and the edge segments at both ends of a winding workpiece are fixed. The center position (which can be the center point) and contour line (which can be a designated edge segment) of the device under test are determined in the template image. Based on the template image, the angular offset and coordinate offset corresponding to the image under test are determined by rotation and displacement. This helps to quickly calculate the offset of devices in the same batch on the production line or those passing through the same designated inspection station.

[0035] In step A03 above, the contour line of the device under test (DUT) can be extracted from the image under test. The offset between this contour line and the contour line of the DUT in the template image can be calculated. For example, if both contour lines are straight lines, the angular offset and coordinate offset between the straight lines can be calculated. Alternatively, multiple points on the contour line of the DUT in the image under test can be selected, and a straight line between any two points and a point not on that straight line can be determined. Relative to the specified straight line and specified point in the template image, the angular offset and coordinate offset can be determined. This can help to quickly calculate the offset of the DUT projected as a simple polygon or ellipse.

[0036] In an exemplary offset calculation example disclosed in this invention, such as Figure 3 The template image 200 includes a background image 201 and a device under test (DUT) image 202. The DUT can be a plate-like workpiece with distributed arrayed through holes 203. In this case, a reference point can be specified as the center point (i.e., the aforementioned center position) 204 or intersection point 205 of the DUT image 202, and reference line segments can be specified as line segments 206 and 207 (for simplified calculation, straight edges of the workpiece can be specified). Figure 4 The dashed line and the dashed boundary circle represent the same coordinate system. Figure 3 The image to be tested 200t may include a background image 201t and an image of the device under test 202t. The device under test may be a plate-like workpiece with arrayed through holes 203t distributed thereon. The arrayed through holes 203t and the arrayed through holes 203 may have the same size or different size, and may have the same opening method or different opening method. At this time, the corresponding point to the center point 204 is the center point 204t determined (based on the geometric relationship of the binarized line segments), the corresponding point to the intersection point 205 is the intersection point 205t determined (based on the geometric relationship of the binarized line segments), the corresponding line segment to the line segment 206 is the line segment 206t obtained by binarization, and the corresponding line segment to the line segment 207 is the line segment 207t obtained by binarization. The offset can be calculated based on the reference point and corresponding point, and the aforementioned line segments. In this case, center point 204 and center point 204t can overlap, the coordinate offset can be 0, and the angle offset can be the angle between line segment 206 and line segment 206t. β Understandably, the calculation method using the workpiece's outline or outline and center point can be implemented by referring to the method here for calculating the offset between reference points and corresponding points and line segments, which will not be elaborated further.

[0037] In this embodiment of the invention, regarding step S2), the current ROI with a direction identifier vector can be directly generated in the image to be tested based on the aforementioned offset and the template ROI in the template image. Alternatively, an initialized ROI (set as the specified ROI) can be generated in the image to be tested, where the direction identifier vector can be initialized together and its relative relationship with the ROI remains unchanged. Then, the initialized ROI is adjusted using the aforementioned offset, thereby ultimately generating the current ROI with a direction identifier vector in the image to be tested. It is understood that the above generation implementation method is not the only limitation; different generation implementation methods can be determined based on product requirements and configuration parameter characteristics, adapting to the program logic and integration design.

[0038] In step S3 of this embodiment of the invention, after generating the current ROI, the current ROI can be segmented (processed) along the direction of the direction identifier vector perpendicular to the current ROI.

[0039] In an exemplary segmentation processing example disclosed in this invention, segmentation processing can generate a specified number of segmented regions along the direction of the directional identifier vector perpendicular to the current ROI. The segmented regions can be simple polygons, ellipses, or circles. Simple polygons include parallelograms, rectangles, etc. There are equal intervals between the segmented regions, such as the interval between the center points of the segmented regions or the interval between specified sides of the segmented regions. The segmented regions can be arranged at equal intervals along the direction of the directional identifier vector of the current ROI. The area of ​​each segmented region is smaller than the area of ​​the current ROI. For example, at least two segmented regions are generated in the current ROI. In some advantageous applications, the size of the segmented regions can be adjusted to specify the generation of 8, 10, 12, etc., segmented regions. To provide acceptable tolerances or deviations, the aforementioned perpendicularity can refer to basic perpendicularity and a 90° allowance. Basic perpendicularity means a deviation of 5%, 10%, etc., based on the 90° allowance. Perpendicularity in this embodiment of the invention can be understood in this way.

[0040] like Figure 5 The image to be tested may include a background image 300 and a local image 301 of the device under test (the area with diagonal lines). The current ROI 302 can be generated from this image to be tested. The current ROI 302 may also include images from... Figure 5The target edge 304 of the device under test is observed (before edge points are fitted). The extension direction of the target edge 304 is the direction 303 of the current ROI 302's direction identifier vector. For illustrative purposes, the line containing direction 303 can be taken as the horizontal axis of the coordinate system, and the line perpendicular to direction 303 can be taken as the vertical axis. In the current ROI 302, along the direction 303 perpendicular to the current ROI 302's direction identifier vector, eight segmented regions 305 can be generated. These segmented regions 305 can be rectangular. The side parallel to the vertical axis of the segmented region 305 is the length (perpendicular to direction 303), and the side parallel to the horizontal axis is the width. The aspect ratio (length to width) of the segmented region 305 is greater than a threshold value, meaning the segmented region 305 can be a long and narrow region. This allows for the segmentation of edges of products with varying shapes, improving the size of the search area and the speed of edge point detection.

[0041] In another exemplary segmentation processing example disclosed in this invention, the segmentation processing can also utilize a set of equally spaced parallel straight lines along the direction of the direction identifier vector perpendicular to the current ROI to cut the current ROI. The cut regions can be numbered, and odd- or even-numbered cut regions are taken as segmentation regions. For example... Figure 6 The image to be tested may include a background image 400 and a local image 401 of the device under test (the area with diagonal lines). The current ROI 402 can be generated from this image to be tested. The current ROI 402 may also include images from... Figure 6 The target edge 404 of the device under test is observed. The extension direction of the target edge 404 is the direction 403 of the direction identifier vector of the current ROI 402. A set of equally spaced parallel straight lines can be used to cut the current ROI 402. For example, line 405 has two intersection points with the two edges of the current ROI 402. These two intersection points, together with the two vertices of the current ROI 402, form the cutting region a1 (numbered). The two vertices are located to the left of line 405. Line 406 has two intersection points with the two edges of the current ROI 402. These two intersection points, together with the two intersection points determined by line 405, form the cutting region a2. In this way, cutting regions a1~a17 can be obtained. Odd-numbered or even-numbered cutting regions can be selected as segmented regions.

[0042] In step S4) of this embodiment of the invention, the obtained segmented regions can be searched to determine the edge points in each segmented region. In some application scenarios, the search can be performed using the change points of gray-level gradients between edges and non-edges, or a threshold segmentation method can be used to search for edge points. For example, a threshold for the gray-level change amplitude can be set, and points that meet the threshold can be used as target points. If there are multiple target points, one can be selected, for example, the first or last searched point can be determined as the target point, and this target point can be used as the edge point.

[0043] In some advantageous applications, coordinate points within segmented regions can be searched along the direction perpendicular to the current ROI's direction identifier vector. That is, within each segmented region, coordinate points can be searched without following the direction of the current ROI's direction identifier vector. This is because the direction of the current ROI's direction identifier vector describes the direction of the straight line containing the device's edge within the current ROI; therefore, edge points exist in the direction perpendicular to the current ROI's direction identifier vector. In this way, a set of edge points corresponding to the segmented regions can be obtained. Based on this set of edge points, edge lines can be fitted to achieve edge detection of devices in the image under test. For example... Figure 7 , can Figure 5 Based on this, a search is performed along direction 306 in each segmented region, and edge points P are determined in each of the eight segmented regions.

[0044] In other application scenarios, edge points can be grouped based on different locations of the device under test (DUT). For example, for a wire-wound workpiece, the current ROI includes images of both ends and the middle of the workpiece. 24 segmented regions (the number can be specified) and 24 edge points can be generated. Along the direction of the direction identifier vector, the first 8 (the number can be specified) and the last 8 (the number can be specified) edge points are fitted to the end target edge line of the DUT, and the middle 8 edge points are fitted to the middle target edge line of the DUT. Furthermore, before fitting the edge line, 8 (the number can be specified) edge points can be grouped as a group of edge points, which can serve as an exemplary grouping method in the outlier filtering operation mentioned later. After the outlier filtering operation is completed, the obtained edge points are fitted to the edge line of the DUT.

[0045] In this embodiment of the invention, since outliers may exist among the aforementioned edge points, these edge points can be filtered. Before fitting the edge point as an edge line, the aforementioned edge detection method may further include: F) Filter the edge points with abnormal coordinate values ​​to obtain the remaining edge points.

[0046] In the first example, filtering can be performed using affine transformation and statistics. Step F) may include: F01) Perform an affine transformation on the edge points of each segmented region; F02) Statistically obtain the coordinate values ​​of the transformed edge points; F03) Remove abnormal edge points, where the difference between the coordinate value and the measurement value of the abnormal edge point is higher than the measurement threshold; F04) Perform an inverse affine transformation on the edge points obtained after removal.

[0047] Step F01) serves to correct the horizontal coordinate points, requiring only the calculation of the ordinate, thus simplifying the calculation process. Step F01) may include: F11) Determine the center point corresponding to the coordinate values ​​of the edge points in each segmented region; F12) Initialize the transformation matrix of the current region of interest, which rotates along the center point; F13) Determines the direction of the specified direction identifier vector (of the template ROI) and the first rotation angle of the specified direction; F14) Determine the direction of the current region of interest's direction identifier vector and the second rotation angle of the specified direction using the offset angle in the offset and the first rotation angle; F15) Rotates the edge points in each segmented region to edge points along the specified direction using the transformation matrix and the second rotation angle.

[0048] The affine transformation can include coordinate point rotation. Edge points in each segmented region can be grouped into a set P of edge points, and this set P can be rotated to a horizontal direction (which can be the horizontal axis of the coordinate system, i.e., the previously specified direction). In step F11), the mean coordinates of these edge points can be calculated as the center point of the edge point set, or any point in the edge point set P can be specified as the center point. The angle between the direction of any point in the edge point set P and the direction of the line determined by the center point and the direction of the current ROI's direction identifier vector (which can be specified as positive) can be determined. These angles describe the relative relationships between the edge points in the edge point set P. Step F13) can determine the deflection of the direction of the template ROI's direction identifier vector in the coordinate system. Step F14) can determine the angle between the direction of the current ROI's direction identifier vector in the image to be tested and the horizontal axis of the coordinate system. This angle is the angle of rotation of the edge point set P as a whole in the coordinate system (i.e., the second rotation angle). In step F12), the transformation matrix can be a rotation transformation matrix. The angle describing the relative relationship is constructed during initialization to obtain the transformation matrix that rotates relative to the center point. In step F15), the second rotation angle can be written into the rotation transformation matrix as an angle parameter. The transformation matrix can rotate the edge point set P to the horizontal direction while maintaining the relative relationship between the edge points in accordance with the aforementioned relative relationship, thus obtaining the transformed edge points after performing the affine transformation.

[0049] In an exemplary filtering operation example disclosed in this invention, in order to illustrate and observe the relationship between coordinate points and the current ROI, such as... Figure 8 A coordinate system can exist. xoy And the current ROI500, the direction of the direction identifier vector of the current ROI500 is direction 501, after segmentation processing, each segmented region within the current ROI500 ( Figure 8A set of edge points P (not shown) can be searched and determined. This set P includes 8 edge points P1 to P8. The mean point 502 can be determined by the mean of the x-coordinate (point) values ​​and the mean of the y-coordinate values ​​in this set P. A line 503 passing through this center point can be observed. The direction of line 503 can be direction 501. After performing an affine transformation 504, the transformed set of edge points P can be obtained. The current ROI 505, direction 506, and line 508 are the transformed ROI of the current ROI 500, the transformed direction of direction 501, and the transformed line of line 503, respectively. In actual processing, the current ROI, the direction of the line passing through the center point, and the direction identifier vector can be left unchanged. Only the center point and the set of edge points P can be transformed. The transformation example here is for illustration. Since line 508 is already parallel to the x-axis... x Then, the difference (absolute value) between the ordinate values ​​of the edge points and the center point in the transformed edge point set P can be compared with a specified ordinate threshold to determine whether each edge point is an outlier. For example, the difference Δ between the ordinate value of the transformed edge point P2 and the center point 507 (i.e., the ordinate value of the projected point 509) can be used to determine whether each edge point is an outlier. y P2 If the ordinate value is greater than the specified ordinate threshold, the difference Δ between the ordinate value of the transformed edge point P8 and the center point 507 (i.e., the ordinate value of the projected point 510) is... y P8 If the values ​​are greater than the specified ordinate threshold, edge points P2 and P8 can be identified as outliers. These outliers are removed from the edge point set P after performing the inverse affine transformation 511. The resulting edge point set includes edge points P1, P3~P7. Depending on the data processing implementation, step F04 may be omitted. The removal operation can be performed directly on the cached original edge point set P, and the resulting edge point set can be directly used for the edge line fitting step.

[0050] In an exemplary numerical example of an affine transformation operation disclosed in this invention, in step F01), the angle between the direction of the orientation identifier vector of the template ROI and the horizontal direction is 45°, and the offset angle between the image to be tested and the template image is 30°. At this time, the direction of the orientation identifier vector of the current ROI in the image to be tested is 15° with the horizontal direction. Any point in the aforementioned edge point set P and the aforementioned center point form a straight line direction that is 5° with the direction of the orientation identifier vector of the current ROI (the clockwise direction of each angle is the same). Therefore, the rotation angle of the edge point set P is 15°, and the rotation transformation angle required for the affine transformation of this arbitrary point is 15°. The straight line direction of the transformed edge point corresponding to this arbitrary point and the transformed point of the aforementioned center point is still 5° with the horizontal direction (parallel to the direction identifier vector of the current ROI). Before the transformation, the vector decomposition of the outlier edge points and their projected points in the edge point set P exists in the horizontal direction. The projected point of the edge point is the projection point on the straight line passing through the center point, and the direction of this straight line is parallel to the direction identifier vector of the current ROI. After the transformation, this decomposition does not exist, thus simplifying the complexity of outlier handling. Figure 9 The current ROI direction identifier vector is 600. It can be observed that the vector between edge point P0 and its projection point 603 on the straight line 602 passing through center point 601 lies on the horizontal axis. x There are decompositions along the direction (which can be horizontal). After performing affine transformation 604, we obtain the direction 605, the center point 606, the transformed P0, the projection point 607, and the line 608. At this point, the vector between the edge point P0 and the projection point 607 lies on the horizontal axis. x Since there is no longer a factor to be decomposed in the direction, we can simply compare the relative magnitudes of the ordinate values, which improves both computational complexity and processing speed.

[0051] In step F02), after the transformation, the metric value of the ordinate of the edge point set P can be calculated. For example, the metric value can be the median or mean of the ordinates of the edge points in the edge point set. In step F03), abnormal edge points can be removed using a metric threshold and the metric value. For example, the metric threshold can be a specified median threshold or mean threshold. An abnormal edge point's ordinate value is higher than the median threshold, or the difference between the abnormal edge point's ordinate value and the mean is higher than the mean threshold. In step F04), the inverse affine transformation can be performed on the transformed edge point set P using an inverse transformation matrix. The inverse transformation matrix can be obtained based on the transformation matrix and the aforementioned rotation angle, such as by performing angle restoration and matrix transpose calculations.

[0052] In the second example, abnormal edge points can be filtered out by the angle between the lines connecting adjacent edge points. Step F) may include: f01) Connect adjacent edge points in pairs to determine the edge segments; f02) Determine the angle between each edge segment and the direction of the direction identifier vector of the current region of interest; f03) Remove edge points that are at intersections, which are edge points between edge segments with an angle higher than the angle threshold.

[0053] Steps f01) to f03) can filter edge points independently, or they can be further filtered based on the edge points obtained in step f04). For example, if the edge point set includes edge points P1, P2, P3, and P4, connect each pair of adjacent points. These connections can be considered edge segments. Calculate the angles of these edge segments. Then, calculate the difference between the calculated angle and the angle of the current ROI's direction identifier vector. If the difference is higher than the angle threshold (which can be 5° to 10°), the intersection points need to be removed. The intersection points are the edge points between edge segments with angles higher than the angle threshold. The direction of the current ROI direction identifier vector can be parallel to the direction of the target edge in the image under test or can describe the direction of the target edge. The angle of the current ROI direction identifier vector can be used to represent the angle of the actual edge of the device in the image under test. This embodiment of the invention avoids the difficulty in calculating and determining the product edge line due to the different product edges with different shapes, realizes the edge direction description of the product, and improves the calculation implementation difficulty and detection universality.

[0054] In an exemplary example of filtering edge points by connecting lines disclosed in this invention, such as Figure 10 In the current ROI700, eight edge points P1~P8 are identified. Since the direction 701 of the current ROI700's orientation identifier vector describes the target edge (extension direction) of the device under test in the image under test, the angle of the line segment connecting the two points and the angle of direction 701 (coordinate system) can be used as the basis for this determination. xoy(In the same clockwise direction), determine whether each edge point is an outlier. For example, connect each pair of edge points with line 702 to obtain line segments P1P2, P2P3, P3P4, P4P5, P5P6, P6P7, and P7P8. The angle of line segment P1P2 corresponding to edge point P2 within circle 703, and the angle of direction 701, have an absolute difference greater than a specified angle threshold; and the angle of line segment P2P3, and the angle of direction 701, have an absolute difference greater than a specified angle threshold. Therefore, edge point P2 is determined to be an outlier and needs to be removed. Thus, after filtering, edge points P1, P3~P8 are obtained.

[0055] In this embodiment of the invention, step S4) above determines the edge line of the target edge based on the edge points obtained in the above steps. For example, the least squares method can be used to fit these points to obtain a straight line segment, i.e., the edge line or the target edge of the device under test.

[0056] This invention also provides a defect detection method based on the same inventive concept as the aforementioned detection method. The instructions corresponding to this defect detection method can be executed by a visual inspection device. This defect detection method may include: D1) Determine the edge lines based on the aforementioned edge detection method; D2) Based on the edge line, determine the defect area; D3) Calculate the parameters of the defect region and determine whether the device under test is defective based on the parameters.

[0057] Step D2) can be implemented in various ways. In the first example of determining the defect region in this embodiment of the invention, step D2) may include: D201) Based on template defect detection ROI, determine the effective region in the image to be tested; D202) The effective area is divided into two parts by the edge line. These two parts are the product area and the target area. Understandably, the target area may contain some areas with edge defects. D203) Using image segmentation methods such as threshold segmentation or histogram method, object extraction is performed on the target area to extract the defect area in the target area.

[0058] This allows for the configuration of a template image, which can contain two Regions of Interest (ROIs): a template defect detection ROI and a template edge detection ROI (i.e., the aforementioned template ROI). The template defect detection ROI can include the template edge detection ROI. The aforementioned offset angle can be used to simultaneously generate both the defect detection ROI and the edge detection ROI (i.e., the aforementioned current ROI) of the image under test. The two ROIs of the image under test encompass the local device region and the background region within the image, such as... Figure 11 In the image under test 800, a defect detection ROI 801 and an edge detection ROI 802 can be generated (the direction of the direction identifier vector is not shown, and the portion overlapping the bounding box of the winding workpiece is represented by a white line). The image under test 800 can include a background image 803 of the inspection station and an image 804 of the actual winding workpiece. It is worth noting that the edge between a local area on one side of the winding workpiece and the background area within the edge detection ROI 802 can be a target edge. This target edge does not need to be regular and can still be determined by the aforementioned edge detection method. The defect detection ROI can be used as an effective region. The effective region is larger than the edge detection ROI and contains more image information about the device and the background, which helps to improve the accuracy of the image segmentation algorithm, such as threshold segmentation or histogram method.

[0059] In a second example of determining the defect region according to an embodiment of the present invention, step D2) may include: D201) Based on template defect detection ROI, determine the effective region in the image to be tested; D202) Uses image segmentation methods such as threshold segmentation or histogram method to extract objects from the effective area, and extracts suspected defect areas from the effective area. Suspected defect areas may contain part of the device itself. D203) divides the effective area into two parts by using edge lines: the product area and the target area. D204) Identify the intersection area between the suspected target area and the target area, and use the intersection area as the defect area.

[0060] Among them, steps D201) and D203) are implemented in the same way as the aforementioned steps D201) and D202).

[0061] The parameters in step D3) may include parameters such as the length, width, and / or area of ​​the defect region. Based on these parameters and the configured numerical indicators, it is determined whether the defect region is a real device defect. For example, if the area of ​​the defect region is greater than the numerical indicator of the area, then the defect region is determined to be a real device defect. Figure 12 The target edge 805 divides the effective region 801 into the product region 806 and the target region 807. The effective region 801 can also be used to extract suspected defect regions through image segmentation algorithms. The intersection between the target region 807 and the suspected defect region can be the defect region 808. Alternatively, the target region 807 can be thresholded to determine the defect region 808. The length, width, area, and other index values ​​of the defect region 808 can be calculated. In some application scenarios, if the calculated index value is greater than the parameter threshold corresponding to the index value, it can be determined that the product has a defect.

[0062] The embodiments of the present invention can obtain ideal edge lines in cases of device edge damage, irregular edges, and edges with other abnormal features. Compared with the method of directly searching for edge points and fitting, it has better robustness and accuracy, wide adaptability, and a wide range of applications. It can detect device edge performance, and defects such as edge protrusion and indentation can be detected quickly. The embodiments of the present invention can be applied to edge detection and defect detection applications, and have the characteristics of algorithm universality and easy computation implementation.

[0063] In some exemplary application scenarios of this invention, by executing the aforementioned detection method, images can be analyzed and processed to determine whether a product has defects, thereby achieving product quality inspection.

[0064] In the first exemplary application scenario, such as Figure 13 The device under test can be an inductor. To facilitate observation of the inductor's structure, the assembly structure is presented by photographing a side view of one end of the inductor. The inductor is placed in the background 900 of the testing station. The inductor includes a winding component 901 and a cover plate 902. Figure 14 If it is necessary to detect whether there is a defect in the tail wire length of the winding component 901, the tail wire length of the inductor edge is detected by a visual inspection device. An image of the winding component 901 viewed from above is taken by a camera and used as the test image. The controller executes the above detection method to find the edge line. The determined defect area is the part that exceeds the edge line. If the exceeding part does not meet the numerical requirements, it is considered a defect. Figure 14 In this process, the aforementioned edge detection method can be performed on the four edges of the winding component 901 to obtain four edge lines 903-906. Based on edge lines 903, 904, and 906, a first target region can be segmented, and defective regions 907-909 (the white areas within the dashed circles) in the first target region can be determined using a threshold segmentation method. Based on edge lines 903, 904, and 905, a second target region can be segmented, and defective region 910 in the second target region can be determined using a threshold segmentation method. Similarly, a third target region is obtained based on edge lines 904, 905, and 906, and defective region 911 in the third target region can be determined. A fourth target region is obtained based on edge lines 905, 906, and 903, and defective region 912 in the fourth target region can be determined. Finally, based on the index values ​​of each defective region, it is determined whether it is a product defect, thus completing the defect detection of the winding component of the inductor.

[0065] In the second exemplary application scenario, such as Figure 15The misalignment of the inductor element's cover (plate) assembly is detected using a visual inspection device. An image of the cover plate 902 is captured by a camera and used as the test image. A controller executes the corresponding instructions for the four edges of the cover plate to detect the edge lines of the target. Figure 15 The image shows three edge lines 913-915. Based on these edge lines, defect areas are determined. At this point, the target area and product area obtained by segmenting the image using edge line 914 can be used. Based on image segmentation of the target area, defect area 916 (the white area within the elliptical dashed line) can be determined, confirming the presence of a defect. Similarly, the target areas and defect areas corresponding to the remaining edge lines can be determined. Finally, based on the index values ​​of each defect area, it is determined whether it is a product defect, thus completing the defect detection of the inductor component's cover plate.

[0066] In the third exemplary application scenario, such as Figure 16 , can be with Figure 13 Similarly, a visual inspection device is used to detect misalignment on the side of the inductor's cover assembly. Images of the winding component 901 and one end of the cover 902 of the inductor are captured by a camera and used as test images. The controller performs the above detection method on both sides, generating an edge detection ROI 917 and a direction identification vector (arrow 918 indicates the direction of the vector) in the test image. The edge detection ROI 917 is used to fit the edge line on one side of the winding component 901. An edge detection ROI 919 and a direction identification vector (arrow 920 indicates the direction of the vector) can also be generated in the test image. The edge detection ROI 917 is used to fit the edge line on one side of the cover 902. Based on the two edge lines obtained, the distance or angle between the two edge lines is calculated. If the distance or angle exceeds the threshold range corresponding to the index value, the assembly structure of the inductor has a defect.

[0067] Example 2 This embodiment of the invention belongs to the same inventive concept as Embodiment 1. This embodiment of the invention provides a detection device, which may include: The acquisition module is used to acquire the image to be tested; The generation module is used to generate a current region of interest in the image to be tested that corresponds to the template region of interest, based on the offset between the image to be tested and the template image and the template region of interest configured in the template image. The template region of interest in the template image is configured with the theoretical contour line of the target edge, and the template region of interest has a specified direction identifier vector. The segmentation module is used to segment the current region of interest into multiple segmented regions by following the direction of the direction identifier vector perpendicular to the current region of interest. The fitting module is used to determine the edge points in each segmented region and fit these edge points as edge lines.

[0068] Specifically, the detection device also includes: A defect detection module is used to determine the defect area based on the edge line; The defect detection module is used to calculate the parameters of the defect area and determine whether the device under test has a defect based on the parameters.

[0069] Specifically, the detection device also includes: The offset calculation module is used to calculate the offset between the template image and the image to be tested.

[0070] Specifically, the offset between the template image and the image to be tested is calculated, including any one of the following: Based on the reference point and reference line segment in the template image, and the corresponding point and corresponding line segment in the image to be tested, the coordinate offset of the reference point and the corresponding point and the angular offset of the reference line segment and the corresponding line segment are calculated, and the coordinate offset and the angular offset are used as the offset. Based on the outline of the device under test in the template image and the image under test, as well as the center position of the device under test, the angular offset of the outline of the device under test in the template image and the image under test and the coordinate offset of the center position are determined, and the coordinate offset and the angular offset are used as the offset. And the offset is calculated by extracting the outline of the device under test from the image under test.

[0071] Specifically, the detection device also includes: The filtering module is used to filter edge points with abnormal coordinate values ​​to obtain the remaining edge points.

[0072] Specifically, edge points with abnormal coordinate values ​​are filtered to obtain the remaining edge points, including: Perform affine transformations on the edge points of each segmented region; Statistically obtain the metric values ​​of the coordinates of the transformed edge points; Remove abnormal edge points where the difference between the coordinate value and the measurement value of the abnormal edge point is higher than the measurement threshold; Perform an inverse affine transformation on the edge points obtained after removal.

[0073] Specifically, affine transformations are performed on the edge points of each segmented region, including: Determine the center point corresponding to the coordinate values ​​of the edge points in each segmented region; Initialize the transformation matrix of the current region of interest, which rotates around the center point; Determine the direction of the specified direction identifier vector and the first rotation angle of the specified direction; The direction of the orientation identifier vector of the current region of interest and the second rotation angle of the specified direction are determined by the offset angle in the offset and the first rotation angle. Using the transformation matrix and the second rotation angle, the edge points in each segmented region are rotated to edge points along the specified direction.

[0074] Specifically, edge points with abnormal coordinate values ​​are filtered to obtain the remaining edge points, including: Connect adjacent edge points in pairs to determine the edge segments; Determine the angle between each edge segment and the direction of the direction identifier vector of the current region of interest; Exclude edge points that are at intersections, which are edge points between edge segments with an angle higher than the angle threshold.

[0075] Specifically, the region of interest in the template includes both the local image region and the local background region of the device under test in the template image, as well as the edge line between the two.

[0076] In some application scenarios disclosed in this invention, the aforementioned modules can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), systems-with-controllers (MCUs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof.

[0077] This invention also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements the aforementioned method by executing the instructions stored in the memory. In some application scenarios, the electronic device may be an industrial control computer on a production line, a server, or a testing device with a controller chip or a system-on-a-chip, etc.

[0078] This invention also provides a machine-readable storage medium storing machine instructions that, when executed on a machine, cause the machine to perform the aforementioned method.

[0079] The optional embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the embodiments of the present invention are not limited to the specific details in the above embodiments. Within the scope of the technical concept of the embodiments of the present invention, various simple modifications can be made to the technical solutions of the embodiments of the present invention, and these simple modifications all fall within the protection scope of the embodiments of the present invention.

[0080] It should also be noted that the various specific technical features described in the above embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, the embodiments of the present invention will not describe the various possible combinations separately.

[0081] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a microcontroller, chip, or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium may be non-transient and may include various media capable of storing program code, such as a USB flash drive, hard disk, read-only memory (ROM), random access memory (RAM), flash memory, magnetic disk, or optical disk.

[0082] Furthermore, various different implementations of the present invention can be combined arbitrarily, as long as they do not violate the spirit of the present invention, they should also be regarded as the content disclosed in the present invention.

Claims

1. An edge detection method, characterized in that, The edge detection method includes: Acquire the image to be tested; Based on the offset between the image under test and the template image and the template region of interest configured in the template image, a current region of interest with a direction identifier vector is generated in the image under test, which corresponds to the template region of interest. The template region of interest of the template image is configured with the theoretical contour line of the target edge, and the template region of interest has a specified direction identifier vector. The direction identifier vector is used to describe the characteristics of the straight line direction of the target edge of the device under test in the region of interest. In the image to be tested, the current region of interest is segmented along the direction of the direction identifier vector perpendicular to the current region of interest to obtain multiple segmented regions; Identify the edge points in each segmented region and fit the edge points as edge lines.

2. The edge detection method according to claim 1, characterized in that, After acquiring the image to be tested, and before generating a current region of interest in the image to be tested corresponding to the template region of interest based on the offset between the image to be tested and the template image and the template region of interest configured in the template image, the process includes: Calculate the offset between the template image and the image to be tested.

3. The edge detection method according to claim 2, characterized in that, The offset between the template image and the image to be tested is calculated, including any one of the following: Based on the reference point and reference line segment in the template image, and the corresponding point and corresponding line segment in the image to be tested, the coordinate offset of the reference point and the corresponding point and the angular offset of the reference line segment and the corresponding line segment are calculated, and the coordinate offset and the angular offset are used as the offset. Based on the outline of the device under test in the template image and the image under test, as well as the center position of the device under test, the angular offset of the outline of the device under test in the template image and the image under test and the coordinate offset of the center position are determined, and the coordinate offset and the angular offset are used as the offset. And the offset is calculated by extracting the outline of the device under test from the image under test.

4. The edge detection method according to claim 1, characterized in that, After determining the edge points in each segmented region and before fitting the edge points as edge lines, the edge detection method further includes: Filter out edge points with abnormal coordinate values ​​to obtain the remaining edge points.

5. The edge detection method according to claim 4, characterized in that, The step of filtering edge points with abnormal coordinate values ​​to obtain the remaining edge points includes: Perform affine transformations on the edge points of each segmented region; Statistically obtain the metric values ​​of the coordinates of the transformed edge points; Remove abnormal edge points where the difference between the coordinate value and the measurement value of the abnormal edge point is higher than the measurement threshold; Perform an inverse affine transformation on the edge points obtained after removal.

6. The edge detection method according to claim 5, characterized in that, The affine transformation performed on the edge points of each segmented region includes: Determine the center point corresponding to the coordinate values ​​of the edge points in each segmented region; Initialize the transformation matrix of the current region of interest, which rotates around the center point; Determine the direction of the specified direction identifier vector and the first rotation angle of the specified direction; The direction of the orientation identifier vector of the current region of interest and the second rotation angle of the specified direction are determined by the offset angle in the offset and the first rotation angle. Using the transformation matrix and the second rotation angle, the edge points in each segmented region are rotated to edge points along the specified direction.

7. The edge detection method according to claim 4 or 6, characterized in that, The step of filtering edge points with abnormal coordinate values ​​to obtain the remaining edge points includes: Connect adjacent edge points in pairs to determine the edge segments; Determine the angle between each edge segment and the direction of the direction identifier vector of the current region of interest; Exclude edge points that are at intersections, which are edge points between edge segments with an angle higher than the angle threshold.

8. The edge detection method according to claim 1, characterized in that, The region of interest in the template includes both the local image region and the local background region of the device under test in the template image, as well as the edge line between the two.

9. A defect detection method, characterized in that, The defect detection method includes: Based on the edge detection method according to any one of claims 1 to 8, determine the edge line; Based on the edge line, the defect area is determined; Calculate the parameters of the defect region, and use the parameters to determine whether the device under test has a defect.

10. The defect detection method according to claim 9, characterized in that, The target region is a region outside the device under test, defined by the edge line. This region is located in the region of interest for defect detection, which includes the current region of interest. The determination of the defect region based on the edge line includes any one of the following: The target object within the target area is extracted using an image segmentation algorithm, and the defect area is determined based on the target object. The image segmentation algorithm determines the suspected defect region in the region of interest for defect detection, and the defect region is determined based on the intersection of the suspected defect region and the target region.

11. A detection device, characterized in that, The detection device includes: The acquisition module is used to acquire the image to be tested; The generation module is used to generate a current region of interest (ROI) with a direction identifier vector in the image under test based on the offset between the image under test and the template image and the template ROI configured in the template image. The template ROI of the template image is configured with the theoretical contour line of the target edge, and the template ROI has a specified direction identifier vector. The direction identifier vector is used to describe the characteristics of the straight line direction of the target edge of the device under test in the ROI. The segmentation module is used to segment the current region of interest in the image under test along the direction of the direction identifier vector perpendicular to the current region of interest, thereby obtaining multiple segmented regions. The fitting module is used to determine the edge points in each segmented region and fit these edge points as edge lines.

12. The detection device according to claim 11, characterized in that, The detection device also includes: A defect detection module is used to determine the defect area based on the edge line; The defect detection module is used to calculate the parameters of the defect area and determine whether the device under test has a defect based on the parameters.

13. An electronic device, characterized in that, The electronic device includes: At least one processor; A memory connected to the at least one processor; The memory stores instructions executable by the at least one processor, which implements the method described in any one of claims 1 to 10 by executing the instructions stored in the memory.

14. A machine-readable storage medium storing machine instructions that, when executed on a machine, cause the machine to perform the method of any one of claims 1 to 10.

Citation Information

Patent Citations

  • Bolt gusset plate corrosion detection method, device and equipment and storage medium

    CN112419298A

  • Device edge detection method and device, storage medium and electronic equipment

    CN114494116A