Geometric figure burr detection method and system for optimizing fitting logic and medium
By performing edge point detection and geometrical fitting in the straight line glitch detection algorithm, combining least squares anti-noise fitting and simplifying caliper logic, the problems of glitch point influence and low edge point positioning efficiency in the existing technology are solved, and efficient and accurate glitch detection is achieved.
Patent Information
- Application Number
- CN202411759277.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-04-15
AI Technical Summary
The existing burr detection algorithm on the straight line cannot effectively eliminate the influence of burr points, resulting in the detected straight line deviating from the actual straight line profile in the case of multiple burr points, affecting the accurate judgment of burr points. At the same time, the calculation efficiency of the edge point positioning algorithm is low.
By acquiring the original image and setting the ROI of the region of interest, edge point detection and geometric fitting are performed, and the anti-noise fitting algorithm based on the least squares method and the simplified caliper method to find edge point logic are used to optimize the algorithm efficiency of edge point search and reduce the operation time.
In the presence of interference points and glitch points, the geometric figures are accurately fitted, the correct glitch points are found, and the algorithm efficiency of edge point search is optimized, which significantly reduces the computing time.
Smart Images

Figure CN119831932A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image detection technology, and in particular to a method, system and medium for detecting burrs on geometric figures with optimized fitting logic. Background Art
[0002] Burr detection on a straight line is a basic algorithm for industrial machine vision. By comparing the gap between the detected edge and the standard fitted straight line, points with excessive errors are detected as burr points.
[0003] The main problem with the existing algorithm is that the straight line fitting algorithm cannot eliminate the influence of burrs. If the burrs deviate too much or there are too many burrs, the straight line detected based on the edge points will deviate from the actual straight line contour of the detection area, thus affecting the judgment of the burrs. In addition, the time-consuming part of the current algorithm is mainly the edge point positioning algorithm, and its computational efficiency needs to be improved. In response to the above problems, effective technical solutions are urgently needed. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, system and medium for burr detection on geometric figures with optimized fitting logic, which can accurately fit geometric figures and find the correct burr points, while optimizing the algorithm efficiency of edge point search and reducing calculation time.
[0005] The embodiment of the present application also provides a method for detecting burrs on geometric figures with optimized fitting logic, including:
[0006] Get the original image and set the region of interest ROI;
[0007] Perform edge point detection on ROI to obtain edge points;
[0008] Using the edge points to perform geometric figure fitting to obtain a fitting figure;
[0009] The burr point is calculated based on the error between the edge point and the fitting graph, and the burr information is output.
[0010] In this solution, the ROI shape is a rectangle, a rotated rectangle, a ring, a circle or an arc.
[0011] In this solution, the step of detecting edge points of ROI to obtain edge points includes:
[0012] When the ROI shape is a rectangle or a rotated rectangle, the ROI is divided into different detection segments, and the average pixel gradient in the vertical direction y of each detection segment is calculated. For each detection segment, the average pixel gradient is traversed from top to bottom or from bottom to top, and the first position where the average gradient is greater than the threshold is output as the detected edge point;
[0013] When the ROI shape is a ring, circle or arc, the edge points in the ROI are detected, different detection segments are divided on the ROI, the average pixel gradient along the radius r is calculated, the detection segments of the polar coordinate image are traversed, and a detection segment is traversed from small to large or from large to small r, and the first position where the average gradient is greater than the threshold is output as the detected edge point.
[0014] In this solution, when the ROI shape is a rectangle or a rotated rectangle, the detection segment expression is:
[0015] (x1, x2, y1, y1)={pt(x, y)|x1<x<x2, y1<y<y2}
[0016] Among them, x1, x2, y1, y1 represent the four vertices of the rectangular box respectively;
[0017] When the ROI shape is a ring, a circle or an arc, the detection segment expression is:
[0018] (θ1, θ2)={pt(θ,r)|θ1<θ<θ2,r inner <r<r outer}
[0019] θ1 and θ2 represent the angle range of the arc. If the ROI range is a circle or annulus, the range is 0-360 degrees; r inner is the inner radius of the ring, circle or arc, r outer The outer radius of the annulus, circle or arc. If the ROI range is a circle or annulus, the inner radius is 0.
[0020] In this scheme, the calculation formula for the average pixel gradient in the vertical direction y is:
[0021] P(pt) is the pixel value of point pt
[0022] P′ avg (y) = P avg (y)-P avg (y-1)
[0023] Among them, P′ avg (y) represents the gradient at a certain detection segment y, P avg (y) represents the average pixel value at y, P avg (y-1) represents the average pixel value at y-1;
[0024] The average pixel gradient along the radius r:
[0025] P(pt) is the pixel value of point pt
[0026] P′avg (r) = P avg (r)-P avg (r-1)
[0027] Among them, P′ avg (r) represents the gradient of a detection segment at a distance r from the ROI center, P avg (r) represents the average pixel value of a detection segment at a distance r from the ROI center, P avg (r-1) represents the average pixel value of a detection segment at a distance r-1 from the center of the ROI.
[0028] In this solution, when the edge points are used to fit the geometric figures, a least squares anti-noise fitting algorithm is used, and the steps include:
[0029] After each fitting, 20% of the points with the largest errors are deleted until the number of remaining edge points is 1 / 2 of the original number, and then the fitting is stopped.
[0030] In this scheme, the burr points are calculated based on the errors between the edge points and the fitted geometric figures, including: for each section of the burr, the area enclosed by the projection of each point on the burr to the reference figure is calculated as the burr area, the length of the burr point column projected onto the reference figure is used as the burr length, and at the same time, the minimum circumscribed rectangle of the burr can be calculated based on each section of the burr point column.
[0031] In this solution, if the ROI shape is a ring, a circle or an arc, the ROI angle, the part within the outer radius is first converted to a polar coordinate space of 360x the outer radius size through polar coordinate transformation.
[0032] The second aspect of the present application further provides a burr detection system on a straight line with optimized fitting logic, the system comprising: a memory and a processor, the memory comprising a program of a burr detection method on a geometric figure with optimized fitting logic, and the program of the burr detection method on a geometric figure with optimized fitting logic is executed by the processor to implement the following steps:
[0033] Get the original image and set the region of interest ROI;
[0034] Perform edge point detection on ROI to obtain edge points;
[0035] Using the edge points to perform geometric figure fitting to obtain a fitting figure;
[0036] The burr point is calculated based on the error between the edge point and the fitting graph, and the burr information is output.
[0037] In a third aspect, the present application also provides a computer-readable storage medium, which includes a program for a method for detecting burrs on geometric figures with optimized fitting logic. When the program for the method for detecting burrs on geometric figures with optimized fitting logic is executed by a processor, the steps of the method for detecting burrs on geometric figures with optimized fitting logic are implemented.
[0038] As can be seen from the above, the embodiment of the present application provides a method, system and medium for detecting burrs on geometric figures with optimized fitting logic, which obtains an original image and sets a region of interest ROI; performs edge point detection on the ROI to obtain edge points; and uses the edge points to fit a geometric figure to obtain a fitting figure;
[0039] The burr point is calculated based on the error between the edge point and the fitting figure, and the burr information is output. The present invention can still accurately fit the geometric figure in the presence of interference points and burr points, find the correct burr point, and at the same time, optimize the algorithm efficiency of edge point search, reduce the repeated calculation of some relatively redundant data, and reduce the operation time. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 A flow chart of a method for detecting burrs on geometric figures with optimized fitting logic provided in an embodiment of the present application;
[0042] Figure 2 The linear original image provided by the embodiment of the present application;
[0043] Figure 3 A rectangular ROI image provided in an embodiment of the present application.
[0044] Figure 4 The fitting graph provided in the embodiment of the present application is a detection segment image of a straight line;
[0045] Figure 5 The edge detection result diagram of the fitting graph provided in the embodiment of the present application is a straight line;
[0046] Figure 6 The fitting result diagram of the fitting graph provided in the embodiment of the present application is a straight line;
[0047] Figure 7 The fitting graph provided in the embodiment of the present application is a burr detection result graph in which a straight line is provided.
[0048] Figure 8 The circular original image provided in the embodiment of the present application.
[0049] Fig. 9 A circular ROI image provided in an embodiment of the present application.
[0050] Fig.10 This is an image after polar coordinate transformation provided in an embodiment of the present application.
[0051] Fig.11 The fitting figure provided in the embodiment of the present application is a detection segment image of a circle.
[0052] Fig.12 The fitting figure provided in the embodiment of the present application is an edge detection result diagram of a circle.
[0053] Fig.13 The fitting graph provided in the embodiment of the present application is a fitting result graph of a circle.
[0054] Fig.14 A burr detection result diagram in which the fitting graph provided in the embodiment of the present application is a circle. DETAILED DESCRIPTION
[0055] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0056] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0057] Please refer to Figure 1 , Figure 1 The flowchart of a method for detecting burrs on a geometric figure by optimizing fitting logic in some embodiments of the present application. The method for detecting burrs on a geometric figure by optimizing fitting logic is used in a terminal device, and the method for detecting burrs on a geometric figure by optimizing fitting logic comprises the following steps:
[0058] S101, acquiring an original image and setting a region of interest ROI;
[0059] S102, performing edge point detection on the ROI to obtain edge points;
[0060] S103, performing geometric figure fitting using the edge points to obtain a fitting figure;
[0061] S104, calculating the burr point according to the error between the edge point and the fitting graph, and outputting the burr information.
[0062] It should be noted that the present application obtains the original image and sets the region of interest (ROI); then performs edge point detection on the ROI to obtain edge points; then uses the edge points to perform geometric figure fitting to obtain a fitting figure, calculates the burr points based on the error between the edge points and the fitting figure, and outputs the burr information.
[0063] like Figure 2 and Figure 8 The original image is shown. Figure 3 and Fig. 9 The ROI image is shown. According to an embodiment of the present invention, the ROI shape is a rectangle, a rotated rectangle, a ring, a circle or an arc.
[0064] It should be noted that setting the ROI to a rectangle, a rotated rectangle, a ring, a circle or an arc can facilitate the comparison of the detected burrs.
[0065] According to an embodiment of the present invention, the step of performing edge point detection on the ROI to obtain edge points includes:
[0066] When the ROI shape is a rectangle or a rotated rectangle, the ROI is divided into different detection segments, and the average pixel gradient in the vertical direction y of each detection segment is calculated. For each detection segment, the average pixel gradient is traversed from top to bottom or from bottom to top, and the first position where the average gradient is greater than the threshold is output as the detected edge point;
[0067] When the ROI shape is a ring, circle or arc, the edge points in the ROI are detected, different detection segments are divided on the ROI, the average pixel gradient along the radius r is calculated, the detection segments of the polar coordinate image are traversed, and a detection segment is traversed from small to large or from large to small r, and the first position where the average gradient is greater than the threshold is output as the detected edge point.
[0068] like Figure 4 and Fig.11 Shown is the detection segment image.
[0069] It should be noted that when the ROI shape is a rectangle or a rotated rectangle, a number of detection segments as shown below can be distributed on an ROI, and each detection segment can detect at most one edge point; a detection segment can be defined as follows: The detection segment expression is:
[0070] (x1, x2, y1, y1)={pt(x, y)|x1<x<x2, y1<y<y2}
[0071] Among them, x1, x2, y1, y1 represent the four vertices of the rectangular box respectively.
[0072] Optionally, the average pixel gradient calculation formula in the vertical direction y is:
[0073] P(pt) is the pixel value of point pt
[0074] P′ avg (y) = P avg (y)-P avg (y-1)
[0075] Among them, P′ avg (y) represents the gradient at a certain detection segment y, P avg (y) represents the average pixel value at y, P avg (y-1) represents the average pixel value at y-1.
[0076] When the ROI shape is a ring, circle or arc, first convert the RO angle, the part within the outer radius, to the polar coordinate space of 360x the outer radius size through polar coordinate transformation. Fig.10 The image shown is after polar coordinate transformation;
[0077] The detection segment expression is:
[0078] (θ1, θ2)={pt(θ,r)|θ1<θ<θ2,r inner <r<r outer}
[0079] θ1 and θ2 represent the angle range of the arc. If the ROI range is a circle or annulus, the range is 0-360 degrees; r inner is the inner radius of the ring, circle or arc, r outer The outer radius of the annulus, circle or arc. If the ROI range is a circle or annulus, the inner radius is 0;
[0080] The average pixel gradient along the radius r:
[0081] P(pt) is the pixel value of point pt
[0082] P′ avg(r) = P avg (r)-P avg (r-1)
[0083] Among them, P′ avg (r) represents the gradient of a detection segment at a distance r from the ROI center, P avg (r) represents the average pixel value of a detection segment at a distance r from the ROI center, P avg (r-1) represents the average pixel value of a detection segment at a distance r-1 from the center of the ROI.
[0084] It should be noted that the present application solution can set a shielding area, so some edge points in the lower right corner are not detected.
[0085] like Figure 5 and Fig.12 Shown are the edge detection results.
[0086] It should be noted that the present invention adopts a simplified caliper method to find edge point logic, eliminating the calculation of the maximum gradient point of the detection segment required by the existing algorithm, reducing one layer of traversal and reducing the complexity of the algorithm. As a result, the time required to process a 9000×9000 image is reduced from more than 300ms to less than 100ms.
[0087] According to an embodiment of the present invention, when the edge points are used for straight line fitting, an anti-noise fitting algorithm based on the least squares method is adopted, and 20% of the points with the largest errors are deleted each time fitting is performed until the number of remaining edge points is 1 / 2 of the original number, and fitting is stopped.
[0088] It should be noted that, based on the least squares fitting, this application adds the logic of iterative fitting after deleting edge points with large errors, so that the fitted graph will eventually converge to the correct edge position. As a result, the algorithm has a good fitting effect based on a sufficient number of valid edge points. Figure 6 and Fig.13 The straight line fitting results are shown.
[0089] According to an embodiment of the present invention, the burr point is calculated based on the error between the edge point and the fitting pattern, including: for each burr segment, the area enclosed by the projection of each point on the burr to the reference pattern is calculated as the burr area, the length of the burr point sequence projected onto the reference pattern is used as the burr length, and the minimum circumscribed rectangle of the burr can be calculated based on each burr point sequence. Figure 7 and Fig.14 Shown are the glitch detection results.
[0090] In a second aspect, the present application provides a burr detection system on a straight line with optimized fitting logic, the system comprising: a memory and a processor, the memory comprising a program of a burr detection method on a geometric figure with optimized fitting logic, and the program of the burr detection method on a geometric figure with optimized fitting logic is executed by the processor to implement the following steps:
[0091] S101, acquiring an original image and setting a region of interest ROI;
[0092] S102, performing edge point detection on the ROI to obtain edge points;
[0093] S103, performing geometric figure fitting using the edge points to obtain a fitting figure;
[0094] S104, calculating the burr point according to the error between the edge point and the fitting graph, and outputting the burr information.
[0095] It should be noted that the present application obtains the original image and sets the region of interest (ROI); then performs edge point detection on the ROI to obtain edge points; then uses the edge points to perform geometric figure fitting to obtain a fitting figure, calculates the burr points based on the error between the edge points and the fitting figure, and outputs the burr information.
[0096] like Figure 2 and Figure 8 The original image is shown. Figure 3 and Fig. 9 The ROI image is shown. According to an embodiment of the present invention, the ROI shape is a rectangle, a rotated rectangle, a ring, a circle or an arc.
[0097] It should be noted that setting the ROI to a rectangle, a rotated rectangle, a ring, a circle or an arc can facilitate the comparison of the detected burrs.
[0098] According to an embodiment of the present invention, the step of performing edge point detection on the ROI to obtain edge points includes:
[0099] When the ROI shape is a rectangle or a rotated rectangle, the ROI is divided into different detection segments, and the average pixel gradient in the vertical direction y of each detection segment is calculated. For each detection segment, the average pixel gradient is traversed from top to bottom or from bottom to top, and the first position where the average gradient is greater than the threshold is output as the detected edge point;
[0100] When the ROI shape is a ring, circle or arc, the edge points in the ROI are detected, different detection segments are divided on the ROI, the average pixel gradient along the radius r is calculated, the detection segments of the polar coordinate image are traversed, and a detection segment is traversed from small to large or from large to small r, and the first position where the average gradient is greater than the threshold is output as the detected edge point.
[0101] like Figure 4 and Fig.11 Shown is the detection segment image.
[0102] It should be noted that when the ROI shape is a rectangle or a rotated rectangle, a number of detection segments as shown below can be distributed on an ROI, and each detection segment can detect at most one edge point; a detection segment can be defined as follows: The detection segment expression is:
[0103] (x1, x2, y1, y1)={pt(x, y)|x1<x<x2, y1<y<y2}
[0104] Among them, x1, x2, y1, y1 represent the four vertices of the rectangular box respectively.
[0105] Optionally, the average pixel gradient calculation formula in the vertical direction y is:
[0106] P(pt) is the pixel value of point pt
[0107] P′ avg (y) = P avg (y)-P avg (y-1)
[0108] Among them, P′ avg (y) represents the gradient at a certain detection segment y, P avg (y) represents the average pixel value at y, P avg (y-1) represents the average pixel value at y-1.
[0109] When the ROI shape is a ring, circle or arc, first convert the RO angle, the part within the outer radius, to the polar coordinate space of 360x the outer radius size through polar coordinate transformation. Fig.10 The image shown is after polar coordinate transformation;
[0110] The detection segment expression is:
[0111] (θ1, θ2)={pt(θ,r)|θ1<θ<θ2,r inner <r<r outer}
[0112] θ1 and θ2 represent the angle range of the arc. If the ROI range is a circle or annulus, the range is 0-360 degrees; r inner is the inner radius of the ring, circle or arc, r outer The outer radius of the annulus, circle or arc. If the ROI range is a circle or annulus, the inner radius is 0;
[0113] The average pixel gradient along the radius r:
[0114] P(pt) is the pixel value of point pt
[0115] P a ' vg (r) = P avg (r)-P avg (r-1)
[0116] Among them, P′ avg (r) represents the gradient of a detection segment at a distance r from the ROI center, P avg (r) represents the average pixel value of a detection segment at a distance r from the ROI center, P avg (r-1) represents the average pixel value of a detection segment at a distance r-1 from the center of the ROI.
[0117] It should be noted that the present application solution can set a shielding area, so some edge points in the lower right corner are not detected.
[0118] like Figure 5 and Fig.12 Shown are the edge detection results.
[0119] It should be noted that the present invention adopts a simplified caliper method to find edge point logic, eliminating the calculation of the maximum gradient point of the detection segment required by the existing algorithm, reducing one layer of traversal and reducing the complexity of the algorithm. As a result, the time required to process a 9000×9000 image is reduced from more than 300ms to less than 100ms.
[0120] According to an embodiment of the present invention, when the edge points are used for straight line fitting, an anti-noise fitting algorithm based on the least squares method is adopted, and 20% of the points with the largest errors are deleted each time fitting is performed until the number of remaining edge points is 1 / 2 of the original number, and fitting is stopped.
[0121] It should be noted that, based on the least squares fitting, this application adds the logic of iterative fitting after deleting edge points with large errors, so that the fitted graph will eventually converge to the correct edge position. As a result, the algorithm has a good fitting effect based on a sufficient number of valid edge points. Figure 6 and Fig.13 The straight line fitting results are shown.
[0122] According to an embodiment of the present invention, the burr point is calculated based on the error between the edge point and the fitting pattern, including: for each burr segment, the area enclosed by the projection of each point on the burr to the reference pattern is calculated as the burr area, the length of the burr point sequence projected onto the reference pattern is used as the burr length, and the minimum circumscribed rectangle of the burr can be calculated based on each burr point sequence. Figure 7 and Fig.14 Shown are the glitch detection results.
[0123] In a third aspect, the present application also provides a computer-readable storage medium, which includes a program for a method for detecting burrs on geometric figures with optimized fitting logic. When the program for the method for detecting burrs on geometric figures with optimized fitting logic is executed by a processor, the steps of the method for detecting burrs on geometric figures with optimized fitting logic are implemented.
[0124] The present invention discloses a method, system and medium for detecting burrs on geometric figures with optimized fitting logic, which obtains the original image and sets a region of interest (ROI); performs edge point detection on the ROI to obtain edge points; uses the edge points to fit the geometric figure to obtain a fitted figure; calculates the burr points based on the error between the edge points and the fitted figure, and outputs the burr information. The present invention can still accurately fit a straight line and find the correct burr points in the presence of interference points and burr points. At the same time, it optimizes the algorithm efficiency of edge point search, reduces the repeated calculation of some relatively redundant data, and reduces the operation time.
[0125] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0126] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0127] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0128] Those skilled in the art can understand that: all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, and other media that can store program codes.
[0129] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
Claims
1. A method for detecting burrs on geometric figures by optimizing fitting logic, characterized in that: include: Get the original image and set the region of interest ROI; Perform edge point detection on ROI to obtain edge points; Using the edge points to perform geometric figure fitting to obtain a fitting figure; The burr point is calculated based on the error between the edge point and the fitting graph, and the burr information is output.
2. The burr detection method on geometric figures of the optimized fitting logic according to claim 1 is characterized in that: The ROI shape is a rectangle, a rotated rectangle, a ring, a circle or an arc.
3. The burr detection method on geometric figures of the optimized fitting logic according to claim 2 is characterized in that: The step of detecting edge points of the ROI to obtain edge points comprises: When the ROI shape is a rectangle or a rotated rectangle, the ROI is divided into different detection segments, and the average pixel gradient in the vertical direction y of each detection segment is calculated. For each detection segment, the average pixel gradient is traversed from top to bottom or from bottom to top, and the first position where the average gradient is greater than the threshold is output as the detected edge point; When the ROI shape is a ring, circle or arc, the edge points in the ROI are detected, different detection segments are divided on the ROI, the average pixel gradient along the radius r is calculated, the detection segments of the polar coordinate image are traversed, and a detection segment is traversed from small to large or from large to small r, and the first position where the average gradient is greater than the threshold is output as the detected edge point.
4. The method for detecting burrs on geometric figures by optimizing fitting logic according to claim 3, characterized in that: When the ROI shape is a rectangle or a rotated rectangle, the detection segment expression is: (x1, x2, y1, y1)={pt(x, y)|x1<x<x2, y1<y<y2} Among them, x1, x2, y1, y1 represent the four vertices of the rectangular box respectively; When the ROI shape is a ring, a circle or an arc, the detection segment expression is: (θ1,θ2)={pt(θ,r)|θ1<θ<θ2,r inner <r<r outer } θ1 and θ2 represent the angle range of the arc. If the ROI range is a circle or annulus, the range is 0-360 degrees; r inner is the inner radius of the ring, circle or arc, r outer The outer radius of the annulus, circle or arc. If the ROI range is a circle or annulus, the inner radius is 0.
5. The method for detecting burrs on geometric figures by optimizing fitting logic according to claim 3, characterized in that: The calculation formula for the average pixel gradient in the vertical direction y is: P(pt) is the pixel value of point pt P a ' vg (y)=P avg (y)-P avg (y-1) Among them, P′ avg (y) represents the gradient at a certain detection segment y, P avg (y) represents the average pixel value at y, P avg (y-1) represents the average pixel value at y-1; The average pixel gradient along the radius r: P(pt) is the pixel value of point pt P a ' vg (r)=P avg (r)-P avg (r-1) Among them, P′ avg (r) represents the gradient of a detection segment at a distance r from the ROI center, P avg (r) represents the average pixel value of a detection segment at a distance r from the ROI center, P avg (r-1) represents the average pixel value of a detection segment at a distance r-1 from the center of the ROI.
6. The method for detecting burrs on geometric figures by optimizing fitting logic according to claim 1, characterized in that: When the edge points are used to fit the geometric figures, an anti-interference fitting algorithm based on the least squares method is adopted, and the steps include: After each fitting, 20% of the points with the largest errors are deleted until the number of remaining edge points is 1 / 2 of the original number, and then the fitting is stopped.
7. The method for detecting burrs on geometric figures by optimizing fitting logic according to claim 1, characterized in that: The burr points are calculated based on the errors between the edge points and the fitted geometric figures, including: for each section of the burr, the area enclosed by the projection of each point on the burr to the reference figure is calculated as the burr area, the length of the burr point column projected onto the reference figure is used as the burr length, and at the same time, the minimum circumscribed rectangle of the burr can be calculated based on each section of the burr point column.
8. The method for detecting burrs on geometric figures by optimizing fitting logic according to claim 2, characterized in that: If the ROI shape is a ring, circle or arc, the RO angle and the part within the outer radius are first converted to the polar coordinate space of 360x the outer radius size through polar coordinate transformation.
9. A straight line burr detection system with optimized fitting logic, characterized in that: The system includes: a memory and a processor, wherein the memory includes a program of a burr detection method on a geometric figure with optimized fitting logic, and when the program of the burr detection method on a geometric figure with optimized fitting logic is executed by the processor, the following steps are implemented: Get the original image and set the region of interest ROI; Perform edge point detection on ROI to obtain edge points; Using the edge points to perform geometric figure fitting to obtain a fitting figure; The burr point is calculated based on the error between the edge point and the fitting graph, and the burr information is output.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a program of a method for detecting burrs on geometric figures using optimized fitting logic. When the program of the method for detecting burrs on geometric figures using optimized fitting logic is executed by a processor, the steps of the method for detecting burrs on geometric figures using optimized fitting logic as described in any one of claims 1 to 8 are implemented.