Ellipse fitting method, device and vision inspection system for a vision inspection system

By performing initial fitting, internal and external point division, and iterative updates on the workpiece data point set, the problems of instability and insufficient accuracy of ellipse fitting in the visual inspection system were solved, and stable and high-precision ellipse fitting was achieved.

CN117291946BActive Publication Date: 2026-08-04SHENZHEN LINGYUN VISION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN LINGYUN VISION TECH CO LTD
Filing Date
2023-09-25
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

Existing ellipse fitting methods suffer from unstable results and insufficient accuracy in visual inspection systems, failing to meet industrial needs.

Method used

By initially fitting the workpiece data point set, dividing the inner and outer points based on the inner point distance threshold, iteratively updating, and optimizing using the inner point weights, the fitting accuracy is gradually improved, and finally a stable target fitting ellipse is obtained.

Benefits of technology

It achieves stable results and high fitting accuracy in ellipse fitting, which can more accurately represent the elliptical shape characteristics of the target workpiece and meet industrial needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117291946B_ABST
    Figure CN117291946B_ABST
Patent Text Reader

Abstract

The application discloses an ellipse fitting method and device for a visual detection system and a visual detection system, and belongs to the technical field of data processing. The method comprises the following steps: fitting an ellipse for a workpiece data point set to be fitted to obtain a first fitting ellipse, wherein the workpiece data point set is obtained by collecting a target workpiece by a data collection device of the visual detection system; determining inliers and outliers in the workpiece data point set based on distances from each workpiece data point in the data point set to the first fitting ellipse and an inlier distance threshold; fitting an ellipse for the inliers in the workpiece data point set to obtain a second fitting ellipse; iteratively updating the inliers and the outliers in the workpiece data point set based on the second fitting ellipse; and fitting an ellipse for the updated inliers in the workpiece data point set to obtain a target fitting ellipse on the target workpiece. The method can obtain a fitting ellipse with stable results and high fitting precision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of data processing technology, and in particular relates to an ellipse fitting method, apparatus and visual inspection system for visual inspection systems. Background Technology

[0002] Ellipse fitting is a commonly used technique in vision application projects. Stable elliptical features are often used to detect whether workpieces meet process design requirements, provide ellipse center information for line circle positioning, detect defects such as protrusions, depressions or discontinuities on the workpiece edge, or assist in laser and dispensing positioning.

[0003] Common ellipse fitting techniques include Combination, Robust Regression (Robust), Random Sample Consensus (Ransac), and RansacRobust (a combination of Ransac and Robust). Among these, the Combination method is unsuitable for time-sensitive applications; the Robust method is the most efficient, but its ellipse accuracy cannot meet industrial requirements; the Ransac method produces unstable ellipse results, and its time consumption is related to the number of iterations; the RansacRobust method provides more reliable ellipse results than Ransac, but still retains some randomness and cannot meet the high stability requirements of industrial applications. Summary of the Invention

[0004] This application aims to address at least one of the technical problems existing in the prior art. To this end, this application proposes an ellipse fitting method, apparatus, and visual inspection system for a visual inspection system, which can obtain a fitted ellipse with stable results and high fitting accuracy.

[0005] In a first aspect, this application provides an ellipse fitting method for a visual inspection system, the method comprising:

[0006] Ellipse fitting is performed on the workpiece data point set to be fitted to obtain the first fitted ellipse. The workpiece data point set is obtained by the data acquisition device of the vision inspection system acquiring the target workpiece.

[0007] Based on the distance from each data point in the workpiece data point set to the first fitted ellipse and the inner point distance threshold, the inner and outer points in the workpiece data point set are determined.

[0008] Ellipse fitting is performed on the interior points of the workpiece data point set to obtain a second fitted ellipse;

[0009] Based on the second fitted ellipse, the inner and outer points of the workpiece data point set are iteratively updated;

[0010] Ellipse fitting is performed on the updated interior points of the workpiece data point set to obtain the target fitted ellipse on the target workpiece.

[0011] According to the ellipse fitting method for visual inspection systems in this application, an initial first fitted ellipse is obtained by directly fitting the workpiece data point set. Based on the first fitted ellipse, the inner and outer points are divided according to the inner point distance threshold, and a second fitted ellipse with higher accuracy is fitted. The inner and outer points are iteratively updated based on the second fitted ellipse to find a more stable and accurate inner point, and finally a target fitted ellipse with stable results and high fitting accuracy is obtained.

[0012] According to one embodiment of this application, the iterative update of the inner and outer points in the workpiece data point set based on the second fitted ellipse includes:

[0013] The weight of each data point in the workpiece data point set is determined based on the distance from each data point in the workpiece data point set to the second fitted ellipse.

[0014] Based on the weights of each data point in the workpiece data point set, the inner and outer points of the workpiece data point set are iteratively updated, and the weights corresponding to the inner points in the workpiece data point set are greater than the weights corresponding to the outer points.

[0015] According to one embodiment of this application, the iterative update of the inner and outer points in the workpiece data point set based on the second fitted ellipse includes:

[0016] Based on the distances from each data point in the workpiece data point set to the second fitted ellipse and the prior distances to the outer points, the inner and outer points in the workpiece data point set are iteratively updated. The prior distances to the outer points are used to characterize that the distance from any outer point in the workpiece data point set to the second fitted ellipse is greater than the distance from any inner point to the second fitted ellipse.

[0017] According to one embodiment of this application, the iterative update of the inner and outer points in the workpiece data point set includes:

[0018] Each iteration determines M far points in the workpiece data point set, where M is an integer greater than 1;

[0019] The iteration terminates if the M far points of the current iteration are the same as the M far points of the previous iteration.

[0020] According to one embodiment of this application, the step of performing ellipse fitting on the interior points of the workpiece data point set to obtain a second fitted ellipse includes:

[0021] The target number of internal points in the workpiece data point set is iteratively updated.

[0022] Ellipse fitting is performed on the updated interior points of the workpiece data point set to obtain a third fitted ellipse, and the fitting error of the third fitted ellipse in each iteration is calculated.

[0023] Based on the fitting error, the second fitted ellipse is determined from the target number of the third fitted ellipses.

[0024] According to one embodiment of this application, the iterative update of the interior points in the workpiece data point set for a target number of iterations includes:

[0025] Refit the first fitted ellipse;

[0026] Based on the distances from each data point in the workpiece data point set to the new first fitted ellipse and the interior point distance threshold, the interior and exterior points in the workpiece data point set are redefined.

[0027] According to one embodiment of this application, the target number is determined based on the proportion of interior points in the workpiece data point set and the maximum number of iterations constraint.

[0028] Secondly, this application provides an ellipse fitting device for a visual inspection system, the device comprising:

[0029] The first processing module is used to perform ellipse fitting on the workpiece data point set to be fitted, and obtain the first fitted ellipse. The workpiece data point set is obtained by the data acquisition device of the vision inspection system acquiring the target workpiece.

[0030] The second processing module is used to determine the inner and outer points in the workpiece data point set based on the distance from each data point in the workpiece data point set to the first fitted ellipse and the inner point distance threshold.

[0031] The third processing module is used to perform ellipse fitting on the interior points of the workpiece data point set to obtain a second fitted ellipse.

[0032] The fourth processing module is used to iteratively update the inner and outer points of the workpiece data point set based on the second fitted ellipse.

[0033] The fifth processing module is used to perform ellipse fitting on the updated interior points of the workpiece data point set to obtain the target fitted ellipse on the target workpiece.

[0034] According to the ellipse fitting device for a visual inspection system of this application, an initial first fitting ellipse is obtained by directly fitting the workpiece data point set. Based on the first fitting ellipse, the inner and outer points are divided according to the inner point distance threshold, and a second fitting ellipse with higher accuracy is fitted. The inner and outer points are iteratively updated based on the second fitting ellipse to find a more stable and accurate inner point, and finally a target fitting ellipse with stable results and high fitting accuracy is obtained.

[0035] Thirdly, this application provides a visual inspection system, including:

[0036] A data acquisition device, which is used to acquire a set of workpiece data points to be fitted;

[0037] A controller, electrically connected to the data acquisition device, is used to execute the ellipse fitting method for a visual inspection system described in the first aspect above.

[0038] According to the visual inspection system of this application, an initial first fitting ellipse is obtained by directly fitting the workpiece data point set. Based on the first fitting ellipse, the inner and outer points are divided according to the inner point distance threshold, and a second fitting ellipse with higher accuracy is fitted. The inner and outer points are iteratively updated based on the second fitting ellipse to find a more stable and accurate inner point, and finally a target fitting ellipse with stable results and high fitting accuracy is obtained.

[0039] Fourthly, this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the ellipse fitting method for a visual inspection system as described in the first aspect above.

[0040] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0041] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:

[0042] Figure 1 This is a flowchart illustrating the ellipse fitting method for a visual inspection system provided in an embodiment of this application.

[0043] Figure 2 This is one of the schematic diagrams of the second fitted ellipse provided in the embodiments of this application;

[0044] Figure 3 This is a second schematic diagram of the second fitted ellipse provided in the embodiments of this application;

[0045] Figure 4 This is a schematic diagram of the structure of the ellipse fitting device for a visual inspection system provided in the embodiments of this application;

[0046] Figure 5 This is a schematic diagram of the structure of the visual inspection system provided in the embodiments of this application;

[0047] Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0048] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0049] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0050] The ellipse fitting method, ellipse fitting device, visual inspection system, electronic device, and readable storage medium for a visual inspection system provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.

[0051] Among them, the ellipse fitting method used in visual inspection systems can be applied to the terminal, specifically executed by the hardware or software in the terminal.

[0052] The terminal includes, but is not limited to, portable communication devices such as mobile phones or tablets with touch-sensitive surfaces (e.g., touchscreen displays and / or touchpads). It should also be understood that, in some embodiments, the terminal may not be a portable communication device, but rather a desktop computer with touch-sensitive surfaces (e.g., touchscreen displays and / or touchpads).

[0053] The following embodiments describe a terminal including a display and a touch-sensitive surface. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse, and joystick.

[0054] The ellipse fitting method for a visual inspection system provided in this application embodiment can be executed by an electronic device or a functional module or entity in an electronic device that can implement the ellipse fitting method for the visual inspection system. The electronic devices mentioned in this application embodiment include, but are not limited to, mobile phones, tablets, computers, cameras, and wearable devices. The ellipse fitting method for a visual inspection system provided in this application embodiment will be described below using an electronic device as the execution subject as an example.

[0055] The visual inspection system of this application includes a data acquisition device and a controller, and the data acquisition device and the controller are connected.

[0056] Ellipse fitting methods for visual inspection systems are used to fit an ellipse shape to match the set of workpiece data points extracted from the target workpiece, so that the ellipse shape best represents the ellipse shape features of the target workpiece.

[0057] like Figure 1 As shown, the ellipse fitting method for the visual inspection system includes steps 110 to 150.

[0058] Step 110: Perform ellipse fitting on the workpiece data point set to be fitted to obtain the first fitted ellipse. Here, the workpiece data point set is obtained by the data acquisition device of the vision inspection system from the target workpiece. The workpiece data point set is a collection of data points to be fitted within the target workpiece, and the target workpiece is a workpiece with elliptical shape characteristics. The workpiece data point set can characterize the elliptical shape characteristics of the target workpiece. For example, the target workpiece can be an elliptical gasket. The edge data points of the elliptical gasket are collected using the data acquisition device of the vision inspection system to obtain the workpiece data point set corresponding to the edge of the elliptical gasket. This workpiece data point set can characterize the elliptical edge shape of the elliptical gasket.

[0059] For example, the target workpiece can be an elliptical mounting hole for a display screen. The data acquisition device of the vision inspection system can be used to collect the contour data points of the elliptical mounting hole for the display screen, and obtain the workpiece data point set corresponding to the contour of the elliptical mounting hole for the display screen. This workpiece data point set can characterize the elliptical contour shape of the elliptical mounting hole for the display screen.

[0060] It is understandable that all data points in the workpiece data point set lie in a plane, and the workpiece data point set is a finite set.

[0061] In this step, an ellipse fitting is performed on the workpiece data point set to be fitted. Data points are randomly selected from the workpiece data point set, and an initial ellipse, namely the first fitted ellipse, is obtained based on the selected data points. At the same time, the mathematical expression corresponding to the first fitted ellipse is obtained.

[0062] In practice, at least 5 data points need to be selected for ellipse fitting.

[0063] It should be noted that determining the ellipse based on the selected data points involves substituting the selected data points into the ellipse equation and performing a least-squares solution to obtain the coefficients of the ellipse equation. This process then fits the first fitted ellipse and its corresponding mathematical expression.

[0064] For example, five data points can be randomly selected from the set of workpiece data points to be fitted, and these five points can be substituted into the ellipse equation to perform least squares solution to determine the first fitted ellipse and its corresponding mathematical expression.

[0065] Step 120: Based on the distance from each data point in the workpiece data point set to the first fitted ellipse and the inner point distance threshold, determine the inner and outer points in the workpiece data point set.

[0066] In this set of workpiece data points, the inner points are those that are close to the first fitted ellipse and can be used for ellipse fitting. The outer points are those that are far from the first fitted ellipse. The ellipse obtained by fitting the outer points may not be able to characterize the elliptical shape features of the target workpiece, thus affecting subsequent detection steps.

[0067] In this embodiment, the interior point distance threshold is a preset distance critical value. If the first fitted distance of a data point to the ellipse is less than the interior point distance threshold, the data point is determined to be an interior point. If the distance of a data point to the first fitted ellipse is greater than the interior point distance threshold, the data point is determined to be an exterior point.

[0068] For example, if the threshold for the distance between interior points is 5cm, the distance from point a to the first fitted ellipse is 4cm, and the distance from point b to the first fitted ellipse is 6cm, then a is an interior point and b is an exterior point.

[0069] Step 130: Perform ellipse fitting on the interior points of the workpiece data point set to obtain the second fitted ellipse.

[0070] The second fitted ellipse is the fitted ellipse obtained by fitting the interior points of the workpiece data point set with an ellipse.

[0071] In this step, five data points can be randomly selected from the interior points, and these five data points can be substituted into the ellipse equation to perform a least-squares solution, thereby determining the second fitted ellipse and its corresponding mathematical expression.

[0072] In this embodiment, external points that may affect the fitting of the elliptical shape of the target workpiece are removed, and elliptical fitting is performed on the internal points, which can provide a second fitted ellipse with higher accuracy.

[0073] Step 140: Based on the second fitted ellipse, iteratively update the inner and outer points in the workpiece data point set.

[0074] It should be noted that the second fitted ellipse is the candidate ellipse basis for the final fitted ellipse. Based on the second fitted ellipse, the interior and exterior points of the dataset are optimized iteratively to make the interior and exterior points in the dataset more stable and accurate.

[0075] Specifically, the internal and external points in the workpiece data point set are iteratively updated. This means that a data point that is currently an internal point may become an internal point or an external point after iteration; and a data point that is currently an external point may become an external point or an internal point after iteration.

[0076] In this step, during the iterative update process, more accurate interior points can be continuously searched in the workpiece data point set, and the accuracy of the interior points after iterative updates is higher.

[0077] It should be noted that in each iteration, an updated second fitted ellipse is generated. In the next iteration, the inner and outer points in the workpiece data point set are updated based on the updated second fitted ellipse.

[0078] Step 150: Perform ellipse fitting on the updated interior points of the workpiece data point set to obtain the target fitted ellipse on the target workpiece.

[0079] Among them, the target fitting ellipse is the fitting ellipse obtained by fitting the interior points determined in step 140. That is, the target fitting ellipse is the fitting ellipse finally determined by the ellipse fitting method used in the vision inspection system, and it is the fitting ellipse that best represents the elliptical shape characteristics of the target workpiece.

[0080] In this step, five data points can be randomly selected from the interior points determined in the last iteration update. These five data points are then substituted into the ellipse equation to perform a least-squares solution, thereby determining the target fitted ellipse and its corresponding mathematical expression.

[0081] For example, the target workpiece can be an elliptical pad. By performing ellipse fitting on the updated inner points of the workpiece data point set corresponding to the edge of the elliptical pad, the target fitted ellipse on the elliptical pad can be obtained. The obtained target fitted ellipse best represents the elliptical edge shape of the elliptical pad.

[0082] For example, the target workpiece can be an elliptical mounting hole for a display screen. By performing ellipse fitting on the inner points of the updated workpiece data point set corresponding to the outline of the elliptical mounting hole of the display screen, the target fitted ellipse on the elliptical mounting hole of the display screen can be obtained. The obtained target fitted ellipse best represents the elliptical outline shape of the elliptical mounting hole of the display screen.

[0083] In this embodiment, based on the second fitted ellipse with higher fitting accuracy obtained from two fittings, the inner and outer points of the workpiece data point set are iteratively updated. The determined inner and outer points are more accurate and stable. The inner points obtained by iteration can fit and update the second fitted ellipse with higher accuracy, thereby continuously improving the accuracy and stability of the inner points. The target fitted ellipse with high accuracy and stability is obtained by fitting the inner points obtained after the iteration terminates.

[0084] According to the ellipse fitting method for a vision inspection system provided in this application, an initial first fitting ellipse is obtained by directly fitting the workpiece data point set. Based on the first fitting ellipse, the inner and outer points are divided according to the inner point distance threshold, and a second fitting ellipse with higher accuracy is fitted. The inner and outer points are iteratively updated based on the second fitting ellipse to find a more stable and accurate inner point, and finally a target fitting ellipse with stable results and high fitting accuracy is obtained.

[0085] In some embodiments, based on a second fitted ellipse, the inner and outer points of the workpiece data point set are iteratively updated, including:

[0086] The weight of each data point in the workpiece data point set is determined based on the distance from each data point in the workpiece data point set to the second fitted ellipse.

[0087] Based on the weights of each data point in the workpiece data point set, the inner and outer points of the workpiece data point set are iteratively updated, and the weights corresponding to the inner points in the workpiece data point set are greater than the weights corresponding to the outer points.

[0088] In this process, determining the corresponding weights for each data point in the workpiece data point set allows for a more refined representation of the differences between the data points, enabling a more accurate division of these data points into inner and outer points.

[0089] In this embodiment, the weight of a data point can be the reciprocal of the distance from that data point to the second fitted ellipse.

[0090] For example, if the distance from a data point to the second fitted ellipse is 3cm, the weight of that data point can be 1 / 3; if the distance from a data point to the second fitted ellipse is 5cm, the weight of that data point can be 1 / 5.

[0091] In practice, when the weight of a data point is greater than a certain threshold, the data point is identified as an inside point; when the weight of a data point is less than the threshold, the data point is identified as an outside point.

[0092] For example, if the threshold is set to 5 and the weight of data point a is 4, then a can be determined as an outlier. If the weight of data point b is 6, then b can be determined as an inlier.

[0093] Understandably, during the iteration process, the second fitted ellipse is updated as the interior points are updated, and the distances from each data point in the workpiece data point set to the second fitted ellipse are also updated. Accordingly, the weights of each data point are updated based on the distances from each data point to the second fitted ellipse.

[0094] In this embodiment, the weight of a data point currently identified as an interior point may decrease after iteration, and if it decreases to less than a set threshold, it may be updated to an exterior point. Conversely, the weight of a data point currently identified as an exterior point may increase after iteration, and if it increases to more than a set threshold, it may be updated to an interior point.

[0095] For example, if the threshold is set to 5, in this iteration, the weight of data point a is 6 and it is determined to be an interior point, and the weight of point b is 4 and it is determined to be an exterior point. In the next iteration, the weight of point a can be 4 and it is determined to be an exterior point, and the weight of point b can be 6 and it is determined to be an interior point.

[0096] In some embodiments, based on a second fitted ellipse, the inner and outer points of the workpiece data point set are iteratively updated, including:

[0097] Based on the distances from each data point in the workpiece data point set to the second fitted ellipse and the prior distances to the outer points, the inner and outer points in the workpiece data point set are iteratively updated.

[0098] Among them, the prior distance of the outer point is used to characterize that the distance from any outer point of the workpiece data point set to the second fitted ellipse is greater than the distance from any inner point to the second fitted ellipse.

[0099] In this embodiment, based on the prior distance of the outer points, data points that are far from the second fitted ellipse are determined as outer points, which can prevent data points that are far from the second fitted ellipse from participating in the fitting process of the second fitted ellipse and affecting the fitting result.

[0100] Understandably, by introducing prior knowledge of the outlier distance, the speed of iterative updates of inlier and outlier points in the dataset can be effectively improved, resulting in a faster ellipse fitting speed.

[0101] In some embodiments, iteratively updating the inner and outer points in the workpiece data point set includes:

[0102] Each iteration determines M far points in the workpiece data point set, where M is an integer greater than 1;

[0103] The iteration terminates if the M far points of the current iteration are the same as the M far points of the previous iteration.

[0104] Among them, the M far points in the workpiece data point set are the first M points selected by arranging the data points in the workpiece data point set from farthest to closest according to their distance from the second fitted ellipse, where M is a preset value.

[0105] In this embodiment, the M far points in the workpiece data point set are determined as outer points, and the remaining points after removing the M far points from the workpiece data point set are determined as inner points.

[0106] In this embodiment, when the M far points of the current iteration are the same as the M far points of the previous iteration, it is considered that the ellipse that best represents the elliptical shape characteristics of the target workpiece has been obtained.

[0107] It should be noted that the determination of iteration termination is based on the premise that "the outlier points removed by the optimal fitting result must be the data points farthest from the ellipse".

[0108] The following proof by contradiction will demonstrate that "the outlier points removed by the optimal fitting result must be the data points farthest from the ellipse".

[0109] Assuming the globally optimal fitted ellipse is not a stable fit, the removed outliers are not necessarily the data points closest to the farthest point. Therefore, among the removed outliers, there must exist points closer to the ellipse than some of the farthest data points. For example... Figure 2 As shown in the figure, the ellipse is the globally optimal fitted ellipse, P1 and P2 are the data points farthest from the ellipse, and P2 and P3 are the outliers that were removed. Data point P3 is closer to the ellipse than data point P1. Figure 3 As shown, if data point P1 is taken as the exterior point and data point P3 as the interior point, the root mean square (RMS) error of the new ellipse will obviously decrease. If the exterior point is removed and the ellipse is refitted, Figure 3 The RMS error of the ellipse will be greater than Figure 2 The RMS error of the ellipse is small. Therefore, we can obtain a value that is greater than... Figure 1 The ellipse with the smaller RMS error among the globally optimal fitted ellipses, i.e. Figure 2 The ellipse in the middle. Then " Figure 1 "The RMS error of the ellipse is not the minimum", which is related to Figure 1 The ellipse in the equation represents a global optimal contradiction. Therefore, the original conclusion holds.

[0110] In some embodiments, ellipse fitting is performed on the interior points of the workpiece data point set to obtain a second fitted ellipse, including:

[0111] The target number of internal points in the workpiece data point set is iteratively updated.

[0112] Ellipse fitting is performed on the updated interior points of the workpiece data point set to obtain the third fitted ellipse, and the fitting error of the third fitted ellipse in each iteration is calculated.

[0113] Based on the fitting error, a second fitted ellipse is determined from the target number of third fitted ellipses.

[0114] The target number is a preset value used to determine the number of times the interior points in the workpiece data point set need to be iterated and updated before obtaining the second fitted ellipse.

[0115] The third fitted ellipse is the fitted ellipse obtained by fitting the updated interior points in each iteration to an ellipse. A third fitted ellipse will be obtained in each iteration.

[0116] In this embodiment, the fitting error is used to measure the fitting accuracy of the fitted ellipse, that is, the degree of similarity between the fitted ellipse and the elliptical shape of the target workpiece. The smaller the fitting error, the greater the similarity between the fitted ellipse and the elliptical shape of the target workpiece. The larger the fitting error, the smaller the similarity between the fitted ellipse and the elliptical shape of the target workpiece.

[0117] In this embodiment, the fitting error can be the RMS error.

[0118] In practice, the fitting error of the fitted ellipse can be determined based on the average distance from the interior point to the fitted ellipse. The larger the average distance, the larger the fitting error, and the smaller the average distance, the smaller the fitting error.

[0119] For example, in the first iteration, the third fitted ellipse a is determined. The average distance from each interior point to the third fitted ellipse a is 4cm, so the fitting error of the third fitted ellipse a is determined to be 1. In the second iteration, the third fitted ellipse b is determined. The average distance from each interior point to the third fitted ellipse b is 5cm, so the fitting error of the third fitted ellipse b is determined to be 2. The fitting error 1 of the third fitted ellipse a is less than the fitting error 2 of the third fitted ellipse b. Therefore, the third fitted ellipse a is more similar to the elliptical shape of the target workpiece than the third fitted ellipse b.

[0120] In this embodiment, the third fitted ellipse with the smallest fitting error is determined as the second fitted ellipse.

[0121] For example, if the target number is set to 3, the internal points of the workpiece data point set are updated 3 times in an iterative manner. The fitting error of the third fitted ellipse a determined by the first iteration update is a1, the fitting error of the third fitted ellipse b determined by the second iteration update is a2, and the fitting error of the third fitted ellipse c determined by the third iteration update is a3. The fitting error of the third fitted ellipse a is the smallest, so the third fitted ellipse a is determined as the second fitted ellipse.

[0122] In this embodiment, selecting the third fitted ellipse with the highest accuracy as the second fitted ellipse can improve the accuracy of the second fitted ellipse and provide a candidate ellipse with higher accuracy for further iterative optimization.

[0123] In some embodiments, iteratively updating the interior points of the workpiece data point set for a target number of iterations includes:

[0124] Refit the first fitted ellipse;

[0125] Based on the distances from each data point in the workpiece data point set to the new first fitted ellipse and the interior point distance thresholds, the interior and exterior points in the workpiece data point set are redefined.

[0126] In this embodiment, refitting the first fitted ellipse can avoid the influence of the randomness of performing only one fitting and reduce the error caused by the process of randomly selecting data points to determine the ellipse.

[0127] In some embodiments, the target number is determined based on the proportion of interior points in the workpiece data point set and the maximum number of iterations constraint.

[0128] Among them, the in-point ratio is the proportion of in-points in the workpiece data point set to all data points, and the maximum iteration number constraint is used to constrain the number of iterations to prevent the number of iterations from being too large.

[0129] For example, if the confidence level is p, the proportion of interior points to all data points in the workpiece data point set is w, the minimum number of data points the fitting model needs to select from the workpiece data point set is n, and the number of non-repeating combinations selected from the workpiece data point set is k (i.e., the theoretical maximum number of iterations required for curve fitting), then the following formula holds:

[0130]

[0131] Taking the logarithm of both sides, we have:

[0132]

[0133] For ellipse fitting, there are 5 parameters, and a minimum of 5 points are required for fitting, that is:

[0134]

[0135] The confidence level p is taken as an empirical value of 0.99. The proportion of in-points w can be calculated by setting the initial number of out-points m and the total number of data points N in the workpiece data point set: w = 1 - m / N. Considering that when the proportion of out-points (m / N) is close to 1 and the confidence level is also close to 1, the value of k may be very large, resulting in an excessively long fitting time. Therefore, a maximum iteration number constraint L is introduced (usually taken as 1000 or 2000). The final maximum number of iterations (target number) is: Nmax = min(k,L).

[0136] The following is a specific embodiment of an ellipse fitting method for a visual inspection system.

[0137] Step 1: Use the data acquisition device of the vision inspection system to acquire the target workpiece with elliptical shape features to obtain the workpiece data point set.

[0138] Step 2: Initialize the iteration count Iter to 0, set the initial number of outliers to m, and calculate the final maximum iteration count Nmax based on the confidence level and the maximum iteration count constraint.

[0139] Step 3: Randomly select 5 points from the obtained workpiece data point set (total number N) and perform ellipse fitting (i.e., substitute into the ellipse equation and perform least squares solution) to obtain the initial ellipse (first fitted ellipse) Ellipse_Iter.

[0140] Step 4: Calculate the distance from all data points in the workpiece data point set to the initial ellipse Ellipse_Iter. Obtain the inner points based on the inner point distance threshold, perform ellipse fitting on the inner points to obtain the current circle (the third fitted ellipse) Ellipse_cur, and calculate the RMS error.

[0141] Step 5: Iteration count Iter = Iter + 1.

[0142] Step 6: Repeat steps 2 to 4 above until the number of iterations Iter reaches the final maximum number of iterations Nmax, and take the result with the smallest RMS error in the current ellipse fitting as the final candidate ellipse result (the second fitted ellipse).

[0143] It should be noted that, in order to address the issue that randomness may cause variations in the fitting results, a fixed random seed must be used in the above randomization process.

[0144] Step 7: Combining the idea of ​​rapid iterative optimization, iteratively correct the outliers in the candidate ellipse fitting results to make the candidate ellipse fitting results more stable and further reduce the RMS error.

[0145] In practice, candidate ellipses can be obtained based on Ransac. The main approach is to randomly select 5 points from the fitted points to fit an initial ellipse. Then, the distances from all fitted points to the initial ellipse are calculated. Based on whether the distances exceed a threshold, outliers and inliers are identified. The inliers are then used to fit the ellipse, and the RMS error is calculated. Finally, the above process is repeated within the maximum number of iterations to obtain the ellipse fitting result with the smallest RMS error as the candidate ellipse.

[0146] Stable ellipse fitting utilizes the weighted iteration concept in the Robust method. It calculates weights based on the distance from each point to the ellipse, excludes points with low weights, updates the ellipse result, and repeats the above process multiple times until the result is stable.

[0147] The ellipse fitting method for a visual inspection system provided in this application can be executed by an ellipse fitting device for a visual inspection system. This application uses an ellipse fitting device for a visual inspection system executing the ellipse fitting method as an example to illustrate the ellipse fitting device for a visual inspection system provided in this application.

[0148] This application also provides an ellipse fitting device for a visual inspection system.

[0149] like Figure 4 As shown, the ellipse fitting device for the visual inspection system includes:

[0150] The first processing module 410 is used to perform ellipse fitting on the workpiece data point set to be fitted, and obtain the first fitted ellipse. The workpiece data point set is obtained by the data acquisition device of the vision inspection system acquiring the target workpiece.

[0151] The second processing module 420 is used to determine the inner and outer points in the workpiece data point set based on the distance from each data point in the workpiece data point set to the first fitted ellipse and the inner point distance threshold.

[0152] The third processing module 430 is used to perform ellipse fitting on the interior points of the workpiece data point set to obtain a second fitted ellipse.

[0153] The fourth processing module 440 is used to iteratively update the inner and outer points of the workpiece data point set based on the second fitted ellipse.

[0154] The fifth processing module 450 is used to perform ellipse fitting on the inner points of the updated workpiece data point set to obtain the target fitted ellipse on the target workpiece.

[0155] According to the ellipse fitting device for a visual inspection system provided in the embodiments of this application, an initial first fitting ellipse is obtained by directly fitting the workpiece data point set. Based on the first fitting ellipse, the inner and outer points are divided according to the inner point distance threshold, and a second fitting ellipse with higher accuracy is fitted. The inner and outer points are iteratively updated according to the second fitting ellipse to find a more stable and accurate inner point, and finally a target fitting ellipse with stable results and high fitting accuracy is obtained.

[0156] In some embodiments, the fourth processing module 440 is used to determine the weight of each data point in the workpiece data point set based on the distance from each data point in the workpiece data point set to the second fitted ellipse.

[0157] Based on the weights of each data point in the workpiece data point set, the inner and outer points of the workpiece data point set are iteratively updated, and the weights corresponding to the inner points in the workpiece data point set are greater than the weights corresponding to the outer points.

[0158] In some embodiments, the fourth processing module 440 is used to iteratively update the interior and exterior points in the workpiece data point set based on the distance from each data point in the workpiece data point set to the second fitted ellipse and the prior distance of the exterior points. The prior distance of the exterior points is used to characterize that the distance from any exterior point in the workpiece data point set to the second fitted ellipse is greater than the distance from any interior point to the second fitted ellipse.

[0159] In some embodiments, the fourth processing module 440 is used to determine M far points in the workpiece data point set in each iteration, where M is an integer greater than 1;

[0160] The iteration terminates if the M far points of the current iteration are the same as the M far points of the previous iteration.

[0161] In some embodiments, the third processing module 430 is used to iteratively update the internal points of the workpiece data point set by a target number of times.

[0162] Ellipse fitting is performed on the updated interior points of the workpiece data point set to obtain the third fitted ellipse, and the fitting error of the third fitted ellipse in each iteration is calculated.

[0163] Based on the fitting error, a second fitted ellipse is determined from the target number of third fitted ellipses.

[0164] In some embodiments, the third processing module is used to refit the first fitted ellipse;

[0165] Based on the distances from each data point in the workpiece data point set to the new first fitted ellipse and the interior point distance thresholds, the interior and exterior points in the workpiece data point set are redefined.

[0166] In some embodiments, the target number is determined based on the proportion of interior points in the workpiece data point set and the maximum number of iterations constraint.

[0167] The ellipse fitting device for the visual inspection system in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the specific device.

[0168] The ellipse fitting device for a visual inspection system in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.

[0169] The ellipse fitting device for a visual inspection system provided in this application embodiment can achieve… Figures 1 to 3 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.

[0170] This application also provides a visual inspection system.

[0171] like Figure 5 As shown, the visual inspection system includes:

[0172] Data acquisition device 510, the data acquisition device is used to acquire the set of workpiece data points to be fitted;

[0173] The controller 520 is electrically connected to the data acquisition device and is used to execute the ellipse fitting method described above for a visual inspection system.

[0174] According to the vision inspection system provided in the embodiments of this application, an initial first fitting ellipse is obtained by directly fitting the workpiece data point set. Based on the first fitting ellipse, the inner and outer points are divided according to the inner point distance threshold, and a second fitting ellipse with higher accuracy is fitted. The inner and outer points are iteratively updated according to the second fitting ellipse to find a more stable and accurate inner point, and finally a target fitting ellipse with stable results and high fitting accuracy is obtained.

[0175] In some embodiments, such as Figure 6 As shown, this application embodiment also provides an electronic device 600, including a processor 601, a memory 602, and a computer program stored in the memory 602 and executable on the processor 601. When the program is executed by the processor 601, it implements the various processes of the above-described ellipse fitting method embodiment for a visual inspection system and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0176] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.

[0177] This application also provides a non-transitory computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described ellipse fitting method embodiment for a visual inspection system and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0178] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0179] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described ellipse fitting method for a visual inspection system.

[0180] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0181] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0182] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0183] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

[0184] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0185] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.

Claims

1. An ellipse fitting method for a vision inspection system, characterized by, include: Ellipse fitting is performed on the workpiece data point set to be fitted to obtain the first fitted ellipse. The workpiece data point set is obtained by the data acquisition device of the vision inspection system acquiring the target workpiece. Based on the distance from each data point in the workpiece data point set to the first fitted ellipse and the inner point distance threshold, the inner and outer points in the workpiece data point set are determined. Ellipse fitting is performed on the interior points of the workpiece data point set to obtain a second fitted ellipse; Based on the second fitted ellipse, the inner and outer points of the workpiece data point set are iteratively updated; Ellipse fitting is performed on the updated interior points of the workpiece data point set to obtain the target fitted ellipse on the target workpiece. The step of performing ellipse fitting on the interior points of the workpiece data point set to obtain a second fitted ellipse includes: iterating and updating the interior points of the workpiece data point set for a target number of times; performing ellipse fitting on the updated interior points of the workpiece data point set to obtain a third fitted ellipse, and calculating the fitting error of the third fitted ellipse in each iteration; and determining the second fitted ellipse from the target number of third fitted ellipses based on the fitting error. The iterative update of the inner points of the workpiece data point set for a target number of times includes: refitting the first fitted ellipse; and redetermining the inner and outer points of the workpiece data point set based on the distance from each data point in the workpiece data point set to the new first fitted ellipse and the inner point distance threshold.

2. The ellipse fitting method for vision inspection system according to claim 1, wherein, The iterative update of the inner and outer points in the workpiece data point set based on the second fitted ellipse includes: The weight of each data point in the workpiece data point set is determined based on the distance from each data point in the workpiece data point set to the second fitted ellipse. Based on the weights of each data point in the workpiece data point set, the inner and outer points of the workpiece data point set are iteratively updated, and the weights corresponding to the inner points in the workpiece data point set are greater than the weights corresponding to the outer points.

3. The ellipse fitting method for vision inspection system of claim 1, wherein, The iterative update of the inner and outer points in the workpiece data point set based on the second fitted ellipse includes: Based on the distances from each data point in the workpiece data point set to the second fitted ellipse and the prior distances to the outer points, the inner and outer points in the workpiece data point set are iteratively updated. The prior distances to the outer points are used to characterize that the distance from any outer point in the workpiece data point set to the second fitted ellipse is greater than the distance from any inner point to the second fitted ellipse.

4. The ellipse fitting method for vision inspection system according to claim 3, wherein, The iterative update of the inner and outer points in the workpiece data point set includes: Each iteration determines M far points in the workpiece data point set, where M is an integer greater than 1; The iteration terminates if the M far points of the current iteration are the same as the M far points of the previous iteration.

5. The ellipse fitting method for vision inspection system according to claim 1, wherein, The target number is determined based on the proportion of interior points in the workpiece data point set and the maximum number of iterations constraint.

6. An ellipse fitting device for a vision inspection system, adapted to implement the ellipse fitting method for a vision inspection system according to any one of claims 1-5, characterized in that, include: The first processing module is used to perform ellipse fitting on the workpiece data point set to be fitted, and obtain the first fitted ellipse. The workpiece data point set is obtained by the data acquisition device of the vision inspection system acquiring the target workpiece. The second processing module is used to determine the inner and outer points in the workpiece data point set based on the distance from each data point in the workpiece data point set to the first fitted ellipse and the inner point distance threshold. The third processing module is used to perform ellipse fitting on the interior points of the workpiece data point set to obtain a second fitted ellipse. The fourth processing module is used to iteratively update the inner and outer points of the workpiece data point set based on the second fitted ellipse. The fifth processing module is used to perform ellipse fitting on the updated interior points of the workpiece data point set to obtain the target fitted ellipse on the target workpiece.

7. A vision inspection system characterized by, include: A data acquisition device, which is used to acquire a set of workpiece data points to be fitted; A controller, electrically connected to the data acquisition device, is used to execute the ellipse fitting method for a visual inspection system according to any one of claims 1-5.

8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the ellipse fitting method for a visual inspection system as described in any one of claims 1-5.