Circular fitting method, device, and storage medium

By using edge detection and iterative weighted fitting methods, target detection points are selected and optimized according to the fitting weights. This solves the problem of insufficient accuracy caused by noise and outliers in circular fitting, and realizes high-precision circular parameter acquisition in complex environments.

CN122335941APending Publication Date: 2026-07-03ZHEJIANG HUARAY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG HUARAY TECH CO LTD
Filing Date
2026-03-17
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing technologies for identifying and locating circular workpieces are subject to interference from factors such as uneven lighting, occlusion, and imaging noise, resulting in insufficient accuracy of circular fitting results. In particular, under strong noise and outlier interference, the assumptions of the RANSAC algorithm do not hold, leading to unreliable fitting results.

Method used

Edge detection is performed on the target image, target detection points are selected and iteratively fitted. The fitting weight is determined based on the degree of fitting match, and weighted iterative fitting is performed to optimize the fitting accuracy of the point set, eliminate outlier interference, and optimize inlier error.

Benefits of technology

It improves the accuracy and robustness of circular fitting, and can obtain high-precision circular parameters under strong noise and outlier interference, ensuring the accuracy and robustness of the fitting results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122335941A_ABST
    Figure CN122335941A_ABST
Patent Text Reader

Abstract

The application discloses a circle fitting method and device and a storage medium. The circle fitting method comprises the following steps: performing edge detection processing on a to-be-fitted circular target in a target image to obtain edge detection points; selecting target detection points in the edge detection points to perform iterative fitting processing to obtain an iterative fitting circle; determining fitting weights corresponding to the target detection points according to the fitting matching degrees of the iterative fitting circle and the target detection points; and performing weighted iterative fitting processing according to the fitting weights and the target detection points to obtain target circular parameters of the to-be-fitted circular target. The above scheme can improve the circle fitting precision when the circular target is recognized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine vision technology, and in particular to a method, device, and storage medium for circular fitting. Background Technology

[0002] In the field of machine vision technology, accurate identification and positioning of circular workpieces (such as bearings, wafers, silicon wafers, etc.) is a key step in realizing robot grasping, assembly, and dimensional measurement.

[0003] However, in real-world applications, edge point data in images is often affected by factors such as uneven lighting, occlusion, and imaging noise, resulting in a large number of outliers and inliers with errors, which can cause significant deviations in the circular fitting results.

[0004] Currently, although algorithms such as RANSAC (Random Sample Consensus) can be used for circle fitting, which can eliminate some outliers through random sampling and consensus mechanisms, their implementation principle assumes that the interior points are completely error-free. This does not hold true in real industrial environments (such as uneven lighting, image blurring, etc.), resulting in insufficient accuracy of circle fitting in some highly disturbed scenarios. Summary of the Invention

[0005] This application provides at least one method, apparatus, device, and computer-readable storage medium for circular fitting.

[0006] The first aspect of this application provides a circular fitting method, comprising: performing edge detection processing on a circular target to be fitted in an acquired target image to obtain edge detection points; selecting target detection points among the edge detection points for iterative fitting processing to obtain an iteratively fitted circle; determining the fitting weight corresponding to each target detection point based on the fitting matching degree between the iteratively fitted circle and each target detection point; and performing weighted iterative fitting processing based on the fitting weight and each target detection point to obtain the target circle parameters of the circular target to be fitted.

[0007] In one embodiment, the step of selecting target detection points among the edge detection points for iterative fitting processing to obtain an iterative fitting circle includes: performing circular fitting processing on the edge detection points to obtain a first fitting circle; determining target detection points among the edge detection points based on the fitting matching degree between each edge detection point and the first fitting circle and a preset inlier rate; performing circular fitting processing on the target detection points to obtain a second fitting circle; and determining the second fitting circle as the iterative fitting circle in response to the second fitting circle meeting the obtained current iteration conditions.

[0008] In one embodiment, before determining the second fitted circle as the iterative fitted circle in response to the second fitted circle meeting the obtained current iteration conditions, the method further includes: randomly selecting the edge detection points for circular fitting processing to obtain an initial fitted circle; and determining the current iteration conditions based on the coordinate information of each edge detection point and the circular parameters of the initial fitted circle.

[0009] In one embodiment, the current iteration condition includes an iteration fitting error and a first iteration number threshold. The step of determining the second fitted circle as the iteration fitted circle in response to the obtained current iteration condition includes: obtaining the fitting error of the second fitted circle and the iteration fitting number corresponding to the second fitted circle; and determining the second fitted circle as the iteration fitted circle in response to the second fitted circle's fitting error being less than the iteration fitting error and the iteration fitting number being equal to the first iteration number threshold.

[0010] In one embodiment, before determining that the second fitted circle meets the obtained current iteration conditions in response to the fitting error of the second fitted circle being less than the iterative fitting error and the number of iterative fittings being equal to the first iteration number threshold, the method further includes: performing circular simulation fitting according to preset simulation fitting conditions to obtain an effective sampling probability; and determining the first iteration number threshold according to preset target confidence, inlier rate, and the effective sampling probability.

[0011] In one embodiment, determining the fitting weight corresponding to each target detection point based on the fitting matching degree between the iterative fitting circle and each target detection point includes: calculating the residual based on the circular parameters of the iterative fitting circle and the coordinate information of each target detection point to obtain the fitting matching degree between the iterative fitting circle and each target detection point; and determining the fitting weight corresponding to each target detection point based on the preset wave reduction factor and the fitting matching degree of each target detection point.

[0012] In one embodiment, the step of performing weighted iterative fitting based on the fitting weights and each target detection point to obtain the target circular parameters of the circular target to be fitted includes: performing weighted fitting on each target detection point according to the fitting weights corresponding to each target detection point to obtain weighted detection points; and performing iterative fitting based on the weighted detection points to obtain the target circular parameters of the circular target to be fitted.

[0013] In one embodiment, the step of performing iterative fitting processing based on the weighted detection points to obtain the target circular parameters of the circular target to be fitted includes: obtaining a first candidate circular parameter and a second candidate circular parameter obtained from two adjacent iterative fitting processes, wherein the acquisition time of the first candidate circular parameter is earlier than that of the second candidate circular parameter; in response to the parameter change value between the first candidate circular parameter and the second candidate circular parameter being less than a preset change value, or the iterative fitting number corresponding to the second candidate circular parameter being equal to a second iteration number threshold, determining the second candidate circular parameter as the target circular parameter.

[0014] A second aspect of this application provides a circular fitting device, comprising: a detection module for performing edge detection processing on a circular target to be fitted in an acquired target image to obtain edge detection points; a first fitting module for selecting target detection points among the edge detection points for iterative fitting processing to obtain an iteratively fitted circle; a weight determination module for determining the fitting weight corresponding to each target detection point based on the fitting matching degree between the iteratively fitted circle and each target detection point; and a second fitting module for performing weighted iterative fitting processing based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted.

[0015] A third aspect of this application provides an electronic device, including a memory and a processor, wherein the processor is configured to execute program instructions stored in the memory to implement the aforementioned circular fitting method.

[0016] The fourth aspect of this application provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a processor, implement the above-described circular fitting method.

[0017] The above scheme obtains edge detection points by performing edge detection processing on the circular target to be fitted in the acquired target image. After excluding outliers from the edge detection points, the target detection points among the edge detection points are selected for iterative fitting processing to obtain an iteratively fitted circle. This avoids interference from outliers and distortion of the fitting results. However, the selected target detection points may still have some errors. Therefore, the fitting weights corresponding to each target detection point can be determined based on the degree of fitting match between the iteratively fitted circle and each target detection point to further optimize the fitting accuracy of the point set. Then, a weighted iterative fitting process is performed based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted, which can significantly improve the circle fitting accuracy.

[0018] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.

[0020] Figure 1 This is a schematic diagram of an exemplary practical application scenario of the circular fitting method in this application; Figure 2 This is a flowchart illustrating an exemplary embodiment of the circular fitting method of this application; Figure 3 This is a block diagram illustrating a circular fitting device in an exemplary embodiment of this application; Figure 4 This is a schematic diagram of the structure of an embodiment of the electronic device of this application; Figure 5 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. Detailed Implementation

[0021] The solution of this embodiment will now be described in detail with reference to the accompanying drawings.

[0022] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.

[0023] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0024] For ease of understanding, one of the applicable scenarios of this application is illustrated by example.

[0025] In the field of machine vision technology, target detection using machine vision often requires identifying the shape of the target object. For example, in industrial vision positioning scenarios, it is often necessary to accurately identify and locate circular workpieces (such as bearings, wafers, silicon wafers, etc.). This process is a key step in enabling robots to grasp, assemble, and measure dimensions.

[0026] However, traditional methods often involve detecting the target object in an image using object detection algorithms, obtaining the object's edge points, and then fitting the data. However, the actual edge point data obtained is often affected by factors such as uneven lighting, occlusion, and imaging noise, resulting in a large number of outliers and inaccurate interior points.

[0027] For example, you can refer to... Figure 1 As shown, Figure 1 This is a schematic diagram of an exemplary practical application scenario of the circular fitting method of this application. The edge detection points in the practical application scenario include outliers and noisy inliers.

[0028] In this diagram, the blue circle represents the ideal circle, and the red dots represent outliers. Outliers deviate significantly from the circumference of the circle and are usually caused by interference from the surrounding environment of the circular target. These are points that need to be removed when fitting the circle, otherwise the result will be significantly biased. The green dots are noisy interior points that fluctuate around the circumference and are the edge points of the circle. However, they may have slight errors due to lighting, imaging blur, etc. This slight sub-pixel error also has a negative impact on the positioning accuracy of the circle in high-precision scenarios.

[0029] Traditional circle fitting algorithms estimate the best-fitting circle parameters (including the center and radius) from a set of edge points that may contain noise and outliers. The presence of outliers can lead to significant deviations in the fitting results.

[0030] Although the RANSAC algorithm can eliminate some outliers through random sampling and consensus mechanisms, its classic implementation assumes that interior points (points that meet the circular fitting conditions) are completely error-free. This assumption does not hold true in real-world applications (such as uneven lighting or blurred images). Therefore, in some application scenarios with strong interference, the fitting results of this method are not entirely reliable.

[0031] Please see Figure 2 , Figure 2 This is a flowchart illustrating an exemplary embodiment of the circular fitting method of this application. Specifically, it may include the following steps: Step S110: Perform edge detection processing on the circular target to be fitted in the acquired target image to obtain edge detection points.

[0032] The target image can be a binary image, RGB image, infrared image, laser image, etc., and there is no limitation here. The target image may contain one or more circular targets to be fitted, and there is no limitation here.

[0033] For ease of understanding and explanation, this application primarily uses an industrial application scenario as an example, but it does not limit the circular fitting method of this application to other scenarios that require the identification of circular target objects. In industrial application scenarios, the circular target to be fitted may include, but is not limited to, bearings, wafers, silicon wafers, nuts, etc.

[0034] For example, edge detection methods can refer to relevant techniques in the art (e.g., Sobel, Canny, Laplacian, and Prewitt), and are not limited here. Thus, the edge detection points (referred to as edge points) of the circular target to be fitted can be obtained, resulting in an edge point set P, for example:

[0035] in, For the first An edge point, The x-coordinate of the edge point The ordinate of the edge point This represents the total number of edge points in the edge point set.

[0036] Step S120: Select the target detection points among the edge detection points and perform iterative fitting to obtain the iterative fitting circle.

[0037] It is understandable that the edge point set may include noise points, outliers, and interior points of the circular target to be fitted. Therefore, this application selects target detection points (interior points) from the edge detection points for circular fitting, which can improve the accuracy of circular fitting.

[0038] For example, the method of this step may include, but is not limited to: using the RANSAC algorithm to directly select at least 3 edge detection points (as target detection points) from the edge detection points for iterative fitting processing until the number of iterations reaches the required number, and obtain the iterative fitting circle.

[0039] As another example, the method of this step may also include, but is not limited to: We choose to perform initialization first, starting with the point set. Three initial edge detection points are randomly selected, and the preset standard least squares method (minimizing the objective function) is applied to these three initial edge detection points. Perform circular fitting to obtain the initial fitted circle. ;in, The x-coordinate of the circle's center is... The ordinate of the circle's center is y. Let be the radius of the circle.

[0040] Furthermore, this can be used to determine the residuals between each edge detection point in the edge point set and the initial fitted circle. The mathematical expression for the degree of fit between each edge detection point and the initial fitted circle can be:

[0041] This also allows us to determine the root mean square error (fitting error) of the initial fitted circle, and then initialize the optimal root mean square error. Its mathematical expression can be:

[0042] After initialization, iterative fitting can begin using the RANSAC algorithm. Alternatively, the above initialization steps can be skipped, and iterative fitting can proceed directly.

[0043] Specifically, the method for iterative fitting based on the RANSAC algorithm can be similarly referenced to the aforementioned example methods, including but not limited to: For the preset number of RANSAC iterations n ( arrive (times), in each iteration from the point set Three points are randomly selected from the data. The standard least squares method (minimizing the objective function) is applied to these three points. Perform circular fitting to obtain the first fitted circle. Its mathematical expression can be:

[0044] And calculate the point set All edge detection points in the circle The residual;

[0045] Furthermore, based on the residuals The edge detection points are sorted in ascending order, and then the inlier rate is preset according to the current application scenario. Select the first sorted items The set of edge detection points is used as the target detection points for this iterative fitting process. (Also known as the interior point set).

[0046] Alternatively, the residuals are negatively correlated with the degree of fit (the smaller the residuals, the better the fit). Therefore, the residuals can also be used as a basis for determining the fit. The edge detection points are sorted from largest to smallest, and then combined with the inlier rate. Select the sorted last The edge detection points are used as target detection points, and no restrictions are imposed here.

[0047] Similarly, based on the circular fitting method in the previous example, at least three target detection points are selected from the set of target detection points, and the objective function is minimized. By performing least-squares fitting, the second fitted circle can be obtained. And calculate the circle corresponding to RMS error .

[0048] Based on the iterative principle, if the fitting error obtained in the current iteration is... Meets the current iteration conditions (e.g.) If the currently fitted circle is better than the best circle found in previous iterations, then iterative replacement can be performed, including at least: updating the best circle model: let , Simultaneously update the inner point set. .

[0049] This process is repeated iteratively until the upper limit of the iteration count threshold (e.g., n iterations) is reached. This allows us to obtain the current result after n iterations. This serves as the final determined iterative fitting circle.

[0050] Step S130: Determine the fitting weights corresponding to each target detection point based on the fitting degree between the iterative fitting circle and each target detection point.

[0051] Based on the steps outlined above, the example described above yields an iteratively fitted circle derived from the target detection points after n iterations. The target detection points are interior points obtained from the edge detection points through a certain selection process; therefore, this iteratively fitted circle is a relatively reliable and robust circle model.

[0052] However, it should be noted that in practical applications, even if the interior point of the circular target to be fitted is determined, there may still be a certain measurement error at that interior point.

[0053] Therefore, this application proposes a method that considers iteratively fitting the set of interior points corresponding to the circle. Potential measurement errors can be mitigated by calculating the fitting weights for each interior point (target detection point) in the set of interior points after determining the iterative fitting circle. Using these fitting weights, the interior points are weighted and iteratively fitted, significantly reducing the interference of erroneous interior points on the circle fitting result.

[0054] Step S140: Perform weighted iterative fitting based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted.

[0055] Weighted iterative fitting processing includes at least weighted processing and iterative fitting processing.

[0056] The steps described above can be similarly explained by referring to the circular iterative fitting process in the previous example, to obtain the set of interior points. Based on this, the fitting weights corresponding to each interior point are used for weighted processing, and then the weighted interior points are used for iterative fitting processing again to finally obtain the target fitting circle (i.e. the target circle parameters of the circular target to be fitted, including at least the center coordinates and radius of the circular target to be fitted).

[0057] Therefore, compared with the traditional circular fitting method that directly uses the least squares method for circular fitting, this application effectively removes interference points such as outliers and noise points through the improved RANSAC stage, and optimizes the interior point error through the iterative weighted least squares stage. Thus, under strong noise and outlier interference, it achieves a robustness and circular fitting accuracy far superior to the simple least squares method.

[0058] As can be seen, this application obtains edge detection points by performing edge detection processing on the circular target to be fitted in the acquired target image. After excluding outliers from the edge detection points, target detection points among the edge detection points are selected for iterative fitting processing to obtain an iterative fitting circle. This avoids interference from outliers and distortion of the fitting results. However, the selected target detection points may still have some errors. Therefore, the fitting weights corresponding to each target detection point can be determined based on the fitting matching degree between the iterative fitting circle and each target detection point to further optimize the fitting accuracy of the point set. Thus, a weighted iterative fitting process is performed based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted, thereby significantly improving the circle fitting accuracy.

[0059] Based on the above embodiments, this embodiment describes the method in step S120.

[0060] Specifically, in this embodiment, the method of selecting target detection points among edge detection points for iterative fitting processing to obtain an iteratively fitted circle includes at least the following steps S210 to S240: Step S210: Perform circular fitting processing based on the edge detection points to obtain the first fitted circle.

[0061] Step S220: Determine the target detection point among each edge detection point based on the fitting degree between each edge detection point and the first fitted circle and the preset inlier rate.

[0062] Step S230: Perform circular fitting on the target detection points to obtain the second fitted circle.

[0063] In step S240, in response to the second fitted circle meeting the obtained current iteration conditions, the second fitted circle is determined as the iterative fitted circle.

[0064] Referring to the foregoing embodiments, this application improves upon the traditional RANSAC stage by designing a method to robustly generate a high-quality set of interior points and an initial circle model under extreme conditions. This circle model can serve as the initial value for subsequent iterative weighted least squares calculations, effectively preventing the latter from getting trapped in local optima or diverging, thus ensuring the effectiveness of the fine-tuning stage.

[0065] Specifically, the RANSAC algorithm can be used similarly to first start from the set of identified edge detection points. Three points are randomly selected from the data, and a circular fitting process based on the standard least squares method is performed to obtain the first fitted circle. Similarly, obtain the point set. All edge detection points in the middle are connected to the corresponding first fitted circle. The residuals are used as the degree of fit between each edge detection point and the first fitted circle.

[0066] Therefore, based on the degree of fitting between each edge detection point and the first fitted circle, the edge detection points (M points) can be sorted according to their degree of fitting, and then, combined with the preset inlier rate w, selected sequentially from the edge detection points. Each edge detection point is used as the target detection point (i.e., interior point).

[0067] Furthermore, by similarly performing circular fitting on the target detection points, a second fitted circle can be obtained.

[0068] It should be noted that the first fitted circle is obtained by selecting and fitting points from the set of unfiltered edge detection points; the second fitted circle is obtained by selecting and fitting points from the set of filtered edge detection points (i.e., target detection points, or interior points). The terms "first" and "second" in "first fitted circle" and "second fitted circle" only specify that they are obtained from different fitting stages (which can be simply referred to as the first fitting stage and the second fitting stage), and do not impose restrictions on other attributes of the two (e.g., the circle parameters of the two can be the same or different, the fitting methods used can be the same or different, etc.).

[0069] In each iteration of the fitting process, after obtaining the second fitted circle, it is determined whether the second fitted circle meets the obtained current iteration conditions.

[0070] For example, the iteration conditions may include conditions set for the fitting error and conditions set for the number of iterations.

[0071] If the second fitted circle meets the current iteration conditions, then the second fitted circle is determined as the iterative fitted circle. If the second fitted circle does not meet the current iteration conditions, then the aforementioned example process is repeated to continue the iterative fitting process (which may include the first fitting stage and the second fitting stage), which will not be elaborated here.

[0072] Specifically, for iterative scenarios, the fitting error of the second fitted circle can be... Iterative fitting error in the current iteration conditions A comparison is made. Specifically, in the first iteration, the iterative fitting error... It can be obtained through initialization processing as described in the foregoing embodiments, or it can be preset; there is no limitation here.

[0073] if, Then, update the optimal circular model to achieve the iterative effect, including: Let , Simultaneously update the interior point set. .if If so, then iterative update processing is not required.

[0074] In addition, it is necessary to determine whether the current iteration fitting number is equal to the threshold number n of the first iteration.

[0075] If yes, it indicates that the current iterative fitting process has reached the iteration count condition, and the current best circular model can be determined as the iteratively fitted circle. If no, it indicates that the current iterative fitting process has not reached the iteration count condition, and iterative fitting needs to continue. Referring to the aforementioned example method, based on the comparison between the specific fitting error and the iterative fitting error, it is decided whether to perform iterative updates, and then continue iterative fitting until the iteration count condition (e.g., n times) is reached, then... The corresponding fitted circle is determined as the iterative fitted circle.

[0076] Based on the above embodiments, this embodiment describes the method prior to step S240.

[0077] Specifically, in this embodiment, the method for determining the second fitted circle as the iterative fitted circle in response to the second fitted circle meeting the obtained current iteration conditions includes at least the following steps S310 to S320: Step S310: Randomly select edge detection points for circular fitting to obtain an initial fitted circle.

[0078] Step S320: Determine the current iteration conditions based on the coordinate information of each edge detection point and the circular parameters of the initial fitted circle.

[0079] In conjunction with the foregoing embodiments, the current iteration conditions may include the iteration fitting error and the iteration number threshold, which may be preset and / or can be flexibly set according to the actual application scenario, without limitation here.

[0080] For example, this embodiment will use the scenario of the first iteration of the fitting process as an example for explanation. Since the current fitting process is the first iteration, the iteration conditions need to be initialized. Referring to the previous embodiment, at least three edge detection points are randomly selected from the edge detection points for circular fitting to obtain an initial fitted circle. .

[0081] Then, based on the circular parameters of the initial fitted circle and the coordinate information of each edge detection point, the residual between each edge detection point and the initial fitted circle can be calculated. The root mean square error (RMSE) of the initial fitted circle is then determined based on the residuals corresponding to the M edge detection points, and the optimal RMS error is initialized accordingly. This allows us to initialize the iterative fitting error.

[0082] It is understandable that if the current fitting process is not the first iteration, the iterative fitting error may be updated (depending on whether the fitting error from previous iterations exists). (This will not be elaborated upon here.)

[0083] Based on the above embodiments, this embodiment describes the method in step S240.

[0084] Specifically, in this embodiment, the method for determining the second fitted circle as the iterative fitted circle in response to the second fitted circle meeting the obtained current iteration conditions includes at least the following steps S410 to S420: Step S410: Obtain the fitting error of the second fitted circle and the number of iterations for fitting the second fitted circle.

[0085] In step S420, in response to the fact that the fitting error of the second fitted circle is less than the iterative fitting error and the number of iterative fittings is equal to the first iteration number threshold, the second fitted circle is determined to meet the obtained current iteration conditions, and the second fitted circle is determined as the iterative fitting circle.

[0086] In conjunction with the foregoing embodiments, the current iteration conditions may include at least the iteration fitting error and a first iteration number threshold N. The iteration fitting error and the first iteration number threshold may be preset and / or dynamically determined based on the actual application scenario.

[0087] For example, when determining whether the second fitted circle can be identified as the iterative fitted circle, it is necessary to first obtain the fitting error corresponding to the second fitted circle and the number of iterative fitting cycles corresponding to the second fitted circle.

[0088] Then determine whether the fitting error corresponding to the second fitting circle is less than the current iterative fitting error, and whether the number of iterative fittings corresponding to the second fitting circle is equal to the first iteration number threshold N.

[0089] The order in which the fitting error corresponding to the second fitting circle and the number of iterations corresponding to the second fitting circle are obtained is not limited; the order in which the fitting error and the iteration fitting error of the second fitting circle are compared and the number of iterations of the second fitting circle and the threshold of the first iteration are also not limited; it is also possible to obtain the fitting error first for comparison and then obtain the number of iterations for comparison; or it is possible to obtain the number of iterations for comparison first and then obtain the fitting error for comparison.

[0090] If both conditions are met, then the second fitted circle is considered to meet the current iteration conditions, and the second fitted circle can be determined as the iterative fitted circle.

[0091] If the fitting error of the second fitted circle is greater than or equal to the iterative fitting error, and the number of iterative fitting iterations equals the threshold of the first iteration number, then the current second fitted circle error is considered large and the number of iterative fitting iterations has reached its upper limit. Therefore, the current... The corresponding fitted circle is determined as the iterative fitted circle.

[0092] If the fitting error of the second fitted circle is less than the iterative fitting error, and the number of iterative fitting iterations is less than the threshold for the number of iterations in the first iteration, then the current second fitted circle error is considered small and the number of iterative fitting iterations has not reached the upper limit. Therefore, based on the current fitting error of the second fitted circle... ,right The process involves updating and replacing the parts, followed by another iteration of the fitting process.

[0093] Based on the above embodiments, this embodiment describes the method prior to step S420.

[0094] Specifically, in this embodiment, the method before determining that the second fitted circle meets the obtained current iteration conditions in response to the second fitted circle having a fitting error less than the iterative fitting error and the number of iterative fittings equal to the first iteration threshold includes at least the following steps S510 to S520: Step S510: Perform circular simulation fitting according to the preset simulation fitting conditions to obtain the effective sampling probability.

[0095] Step S520: Determine the threshold for the first iteration number based on the preset target confidence level, inlier rate, and effective sampling probability.

[0096] Among them, circular simulation fitting can be achieved using methods such as Monte Carlo simulation or quasi-Monte Carlo simulation.

[0097] Taking Monte Carlo simulation as an example, the preset simulation fitting conditions can include at least the standard deviation of Gaussian noise at interior points. (e.g., 0.5), outlier distribution model (e.g., normal distribution), number of simulations (e.g., 10,000 times) etc.

[0098] For example, the simulation points used in the circular simulation fitting process can be selected from the edge detection points obtained in step S110, or selected from a preset set of simulation points, without limitation here.

[0099] Furthermore, during the circular simulation fitting process, This is a randomized trial. During each trial: 1) On a predefined ideal circle, three simulated points from a randomly sampled set are used for circular simulation fitting, and a standard deviation of is added to these simulated points. Gaussian noise is used to simulate interior points with errors in real-world application scenarios.

[0100] 2) Use these 3 simulated points with added noise to perform a circular simulation fitting to obtain the fitted circle.

[0101] 3) Use noise-free simulated points on the ideal circle as test points to evaluate the fitted circle and determine whether the fitting is successful.

[0102] The methods for determining whether the fitting is successful may include, but are not limited to, the following: the difference between the distance from the center of the fitted circle to a test point representing a preset percentage (such as 90% or other values) and the radius of the fitted circle is less than a threshold. (threshold) The settings can be adjusted according to the actual application scenario; no specific limitations are set here. Considering subpixel noise, the threshold... It can be set to 1).

[0103] After K simulations, the proportion of successful fits in each of the K simulations is calculated (this is the success rate), and this success rate can be defined as the effective sampling probability. (This reflects the probability that the circle parameters can be effectively fitted when three interior points are sampled under noise conditions.)

[0104] Furthermore, based on the preset target confidence level (Can be set as needed, such as 0.9999 or other values), Internal Point Ratio The effective sampling probability determines the threshold N for the first iteration, which can be mathematically expressed as:

[0105] The interior point rate may be the same as or different from the interior point rate in the aforementioned embodiments (it may be preset according to actual needs), and no limitation is made here.

[0106] Based on the above embodiments, this embodiment describes the method in step S130.

[0107] Specifically, in this embodiment, the method for determining the fitting weight corresponding to each target detection point based on the degree of fitting between the iterative fitting circle and each target detection point includes at least the following steps S610 to S620: Step S610: Calculate the residual based on the circular parameters of the iterative fitting circle and the coordinate information of each target detection point to obtain the fitting degree between the iterative fitting circle and each target detection point.

[0108] Step S620: Determine the fitting weight corresponding to each target detection point based on the preset wave-damping factor and the fitting matching degree of each target detection point.

[0109] Referring to the aforementioned embodiments, the residual between the iteratively fitted circle and each target detection point can be obtained by calculating the residual based on the circle parameters (center coordinates and circle radius) of the iteratively fitted circle and the coordinate information of each target detection point. This residual is then used as the degree of fitting.

[0110] Furthermore, in each iteration, the fitting weights corresponding to each target detection point can be determined based on the preset regression loss function, the preset wave reduction factor, and the fitting matching degree of each target detection point.

[0111] The regression loss function can include, but is not limited to, the Huber function, the Tukey function, etc., and is not limited here.

[0112] For example, this embodiment mainly uses the Huber function as an example for illustration, which is more stable and less prone to change compared to the Tukey function. Its mathematical expression can be:

[0113] Wherein, the fitting weight corresponding to the i-th point is . For the preset wave-damping factor (e.g.) (1.48 times the median).

[0114] Based on the above embodiments, this embodiment describes the method in step S140.

[0115] Specifically, in this embodiment, the method for obtaining the target circle parameters of the circular target to be fitted by performing weighted iterative fitting based on fitting weights and each target detection point includes at least the following steps S710 to S720: Step S710: Weight each target detection point according to the fitting weight corresponding to each target detection point to obtain weighted detection points.

[0116] Step S720: Perform iterative fitting based on the weighted detection points to obtain the target circle parameters of the circular target to be fitted.

[0117] The robust circular model is explained in conjunction with the foregoing embodiments. corresponding After determining the fitting weights for each target detection point, the target detection points can be weighted separately to obtain weighted detection points; then, using... The circle parameter is used as the initial value for... All target detection points use the minimize objective function This enables iterative weighted least squares fitting based on the Huber function using weighted detection points.

[0118] For example, its mathematical expression can be:

[0119] in, The calculation method can be referred to in the aforementioned embodiments, and will not be repeated here.

[0120] Furthermore, the iterative fitting method described in the foregoing embodiments can be similarly referenced, but the circle is refitted using a weighted set of interior points, and the circle parameters are updated according to the actual situation, with weighted iteration. The circle parameter of this order is .

[0121] The above example method can be repeated in each iteration until the preset target iteration condition is reached (the target iteration condition at this stage may be the same as or different from the iteration condition in the previous embodiment, which is not limited here), thereby obtaining the target circular parameters of the circular target to be fitted.

[0122] Based on the above embodiments, this embodiment describes the method in step S720.

[0123] Specifically, the method in this embodiment for obtaining the target circle parameters of the circular target to be fitted by iterative fitting based on weighted detection points includes at least the following steps S810 to S820: Step S810: Obtain the first candidate circle parameter and the second candidate circle parameter obtained from two adjacent iterations of fitting processing. The acquisition time of the first candidate circle parameter is earlier than that of the second candidate circle parameter.

[0124] In step S820, in response to the parameter change value between the first candidate circle parameter and the second candidate circle parameter being less than a preset change value, or the iteration fitting number corresponding to the second candidate circle parameter being equal to the second iteration number threshold, the second candidate circle parameter is determined as the target circle parameter.

[0125] Based on the foregoing embodiments, after obtaining the fitting weights corresponding to each target detection point, a weighted iterative fitting process can be performed.

[0126] For example, the circular fitting process can be repeated using the aforementioned example method to obtain the first candidate circle parameter and the second candidate circle parameter obtained in every two adjacent iterations of the weighted iterative fitting process. The first candidate circle parameter is obtained earlier than the second candidate circle parameter. and .

[0127] Then, the parameter variation between the first candidate circle parameter and the second candidate circle parameter can be calculated. And compared with the preset change value T, its mathematical expression can be:

[0128] The preset change value T can be set as needed (e.g., 1e-6 or other values), and there is no limitation here.

[0129] The second iteration threshold in this embodiment may be the same as or different from the first iteration threshold in the aforementioned embodiment; this is not limited here. For example, the second iteration threshold may be set to 50 iterations.

[0130] Therefore, if the parameter of the circle changes by a certain value Less than the preset change value If the number of iterations corresponding to the second candidate circle parameter reaches the maximum number of iterations (the second iteration threshold), then the second candidate circle parameter can be determined as the target circle parameter, and the final optimized circle center can be output. and radius (That is, the circle parameter of the second candidate circle parameter).

[0131] Based on the above embodiments, this embodiment should further explain that, after obtaining the target circle parameters, its circle parameters can be... The final high-precision and robust circle fitting result for the target to be fitted is used in subsequent visual guidance, measurement or control processes, which will not be elaborated here.

[0132] In summary, the method described in this application can determine, through Monte Carlo simulation, the probability that randomly sampling three points and performing circle fitting can produce an effective model under the current noise model. Based on probability Target confidence level and interior point ratio Dynamically calculate the number of iterations required for the improved RANSAC algorithm. An improved RANSAC iteration is performed, in which candidate inlier sets are selected based on the ranking residuals and the estimated number of inliers in each iteration, and the best circle model is updated according to the fitting quality of the inlier set. Then, using the best circle model as the initial value, iterative weighted least squares fitting is performed on its corresponding inlier set to obtain the final target circle parameters.

[0133] Therefore, the method in this application effectively eliminates outliers, and then optimizes the interior point error through an iterative weighted least squares stage, thus achieving robustness and accuracy far superior to the simple least squares method under strong noise and outlier interference. The RANSAC stage is improved and specifically designed to robustly generate a high-quality interior point set and an initial circular model in extreme environments. This initial circular model can serve as the initial value for subsequent iterative weighted least squares, effectively preventing the latter from getting trapped in local optima or diverging, ensuring the effectiveness of the fine-tuning stage. Furthermore, the effective sampling probability q obtained from Monte Carlo simulation is actually integrated into the iteration count calculation formula, enabling the algorithm to adapt to noise levels and dynamically provide sufficient iterations. This ensures that the correct model can still be found with high confidence even in complex noisy environments, improving the algorithm's reliability and success rate.

[0134] It should be further noted that the execution entity of the circular fitting method can be a circular fitting device. For example, the circular fitting method can be executed by a terminal device, a server, or other processing devices. The terminal device can be a user equipment (UE), computer, mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. In some possible implementations, the circular fitting method can be implemented by the processor calling computer-readable instructions stored in memory.

[0135] Figure 3 This is a block diagram illustrating a circular fitting device in an exemplary embodiment of this application. Figure 3 As shown, the exemplary circular fitting device 300 includes: a detection module 310, a first fitting module 320, a weight determination module 330, and a second fitting module 340. Specifically: The detection module 310 is used to perform edge detection processing on the circular target to be fitted in the acquired target image to obtain edge detection points.

[0136] The first fitting module 320 is used to select target detection points among edge detection points for iterative fitting processing to obtain an iterative fitting circle.

[0137] The weight determination module 330 is used to determine the fitting weight corresponding to each target detection point based on the degree of fitting match between the iterative fitting circle and each target detection point.

[0138] The second fitting module 340 is used to perform weighted iterative fitting based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted.

[0139] In this exemplary circular fitting device, edge detection points are obtained by performing edge detection processing on the circular target to be fitted in the acquired target image. After excluding outliers from the edge detection points, target detection points among the edge detection points are selected for iterative fitting processing to obtain an iteratively fitted circle. This avoids interference from outliers that could distort the fitting results. However, the selected target detection points may still have some errors. Therefore, the fitting weights corresponding to each target detection point can be determined based on the degree of matching between the iteratively fitted circle and each target detection point to further optimize the fitting accuracy of the point set. Then, a weighted iterative fitting process is performed based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted, thereby significantly improving the circular fitting accuracy.

[0140] It should be noted that the apparatus and method provided in the above embodiments belong to the same concept, and the specific ways in which each module and unit performs operations have been described in detail in the method embodiments, and will not be repeated here. In practical applications, the apparatus provided in the above embodiments can be assigned to different functional modules as needed, that is, the internal structure of the apparatus can be divided into different functional modules to complete all or part of the functions described above, and this is not a limitation.

[0141] The functions of each module can be found in the implementation examples of the circular fitting method, and will not be repeated here.

[0142] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of an embodiment of the electronic device of this application. The electronic device 100 includes a memory 101 and a processor 102. The processor 102 is used to execute program instructions stored in the memory 101 to implement the steps in any of the above-described circular fitting method embodiments. In a specific implementation scenario, the electronic device 100 may include, but is not limited to, a microcomputer or a server. In addition, the electronic device 100 may also include mobile devices such as laptops and tablets, which are not limited here.

[0143] Specifically, processor 102 controls itself and memory 101 to implement the steps in any of the above-described circular fitting method embodiments. Processor 102 can also be referred to as a CPU (Central Processing Unit). Processor 102 may be an integrated circuit chip with signal processing capabilities. Processor 102 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 102 can be implemented using integrated circuit chips.

[0144] In this exemplary electronic device, edge detection points are obtained by performing edge detection processing on the circular target to be fitted in the acquired target image. After excluding outliers from the edge detection points, the target detection points among the edge detection points are selected for iterative fitting processing to obtain an iterative fitting circle. This avoids interference from outliers and distortion of the fitting results. However, the selected target detection points may still have some errors. Therefore, the fitting weights corresponding to each target detection point can be determined based on the degree of fitting match between the iterative fitting circle and each target detection point to further optimize the fitting accuracy of the point set. Thus, a weighted iterative fitting process is performed based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted, thereby significantly improving the circle fitting accuracy.

[0145] Please see Figure 5 , Figure 5 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 110 stores program instructions 111 that can be executed by a processor. The program instructions 111 are used to implement the steps in any of the above-described circular fitting method embodiments.

[0146] In this exemplary storage medium, by running program instructions within the storage medium, edge detection processing is performed on the circular target to be fitted in the acquired target image, obtaining edge detection points. After excluding outliers from the edge detection points, target detection points among the edge detection points are selected for iterative fitting processing to obtain an iteratively fitted circle. This avoids interference from outliers that could distort the fitting results. However, the selected target detection points may still have some errors. Therefore, the fitting weights corresponding to each target detection point can be determined based on the degree of matching between the iteratively fitted circle and each target detection point, further optimizing the fitting accuracy of the point set. Then, weighted iterative fitting processing is performed based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted, thereby significantly improving the circle fitting accuracy.

[0147] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0148] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.

[0149] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0150] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A circle fitting method characterized by, The method includes: Edge detection processing is performed on the circular target to be fitted in the acquired target image to obtain edge detection points; Select the target detection points from the edge detection points and perform iterative fitting to obtain the iterative fitting circle; Based on the degree of fitting between the iterative fitting circle and each target detection point, the fitting weight corresponding to each target detection point is determined; Based on the fitting weights and each target detection point, a weighted iterative fitting process is performed to obtain the target circle parameters of the circular target to be fitted.

2. The method of claim 1, wherein, The step of selecting target detection points from the edge detection points and performing iterative fitting processing to obtain an iteratively fitted circle includes: A first fitted circle is obtained by performing circular fitting processing based on the edge detection points; The target detection point in each edge detection point is determined based on the degree of fitting between each edge detection point and the first fitted circle and the preset inlier rate. Perform circular fitting on the target detection points to obtain a second fitted circle; If the second fitted circle meets the obtained current iteration conditions, then the second fitted circle is determined as the iterative fitted circle.

3. The method of claim 2, wherein, Before determining the second fitted circle as the iterative fitted circle in response to the second fitted circle meeting the obtained current iteration condition, the method further includes: Randomly select the edge detection points and perform circular fitting to obtain an initial fitted circle; The current iteration conditions are determined based on the coordinate information of each edge detection point and the circularity parameter of the initial fitted circle.

4. The method of claim 2, wherein, The current iteration conditions include the iteration fitting error and a first iteration number threshold. The step of determining the second fitted circle as the iteration fitting circle in response to the second fitted circle meeting the obtained current iteration conditions includes: Obtain the fitting error of the second fitted circle and the number of iterations for fitting the second fitted circle; In response to the fact that the fitting error of the second fitted circle is less than the iterative fitting error and the number of iterative fittings is equal to the first iteration number threshold, the second fitted circle is determined to meet the obtained current iteration conditions, and the second fitted circle is determined as the iterative fitting circle.

5. The method of claim 4, wherein, Before determining that the second fitted circle meets the obtained current iteration condition when the fitting error in response to the second fitted circle is less than the iterative fitting error and the number of iterative fittings is equal to the first iteration number threshold, the method further includes: Perform circular simulation fitting based on preset simulation fitting conditions to obtain the effective sampling probability; The threshold for the first iteration number is determined based on the preset target confidence level, the inlier rate, and the effective sampling probability.

6. The method of claim 1, wherein, The step of determining the fitting weight corresponding to each target detection point based on the fitting degree between the iterative fitting circle and each target detection point includes: The residual is calculated based on the circular parameters of the iterative fitting circle and the coordinate information of each target detection point to obtain the fitting degree between the iterative fitting circle and each target detection point; Based on the preset wave-damping factor and the degree of fitting of each target detection point, the fitting weight corresponding to each target detection point is determined.

7. The method according to claim 1, characterized in that, The step of performing weighted iterative fitting based on the fitting weights and each target detection point to obtain the target circle parameters of the circular target to be fitted includes: Each target detection point is weighted according to its corresponding fitting weight to obtain weighted detection points. The target circular parameters of the circular target to be fitted are obtained by iterative fitting based on the weighted detection points.

8. The method according to claim 7, characterized in that, The step of iteratively fitting the weighted detection points to obtain the target circular parameters of the circular target to be fitted includes: The first candidate circle parameter and the second candidate circle parameter obtained from two consecutive iterations of fitting are obtained, and the acquisition time of the first candidate circle parameter is earlier than that of the second candidate circle parameter. In response to the parameter change value between the first candidate circle parameter and the second candidate circle parameter being less than a preset change value, or the iteration fitting number corresponding to the second candidate circle parameter being equal to a second iteration number threshold, the second candidate circle parameter is determined as the target circle parameter.

9. An electronic device, characterized in that, The method includes a memory and a processor, the processor being configured to execute program instructions stored in the memory to implement the method according to any one of claims 1 to 8.

10. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the method described in any one of claims 1 to 8.