Contour fitting method, contour fitting device and contour fitting system

By decentralizing the set of points to be fitted by the workpiece contour and polar coordinate transformation, combined with supplementary and fitting operations, the problem of time-consuming and robustness of contour fitting in the prior art is solved, and a more efficient and robust contour fit is achieved.

CN119850776APending Publication Date: 2025-04-18SHENZHEN LINGYUN VISION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411871157.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In the prior art, the closing curve fitting of the workpiece profile takes a long time and is poorly robust, resulting in a long contour fitting time.

Method used

By obtaining the set of points to be fitted in the Cartesian coordinate system of the test piece, performing decentralization processing and polar coordinate transformation, the set of points to be obtained under the polar coordinate system, and supplementing and fitting are performed to obtain a polar coordinate polynomial, and finally, the closed curve under the Cartesian coordinate system is determined as the fitted contour according to the polynomial.

Benefits of technology

The fitting process of the closed curve is simplified, the fitting time is reduced, and the fitting efficiency and robustness are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850776A_ABST
    Figure CN119850776A_ABST
Patent Text Reader

Abstract

The invention discloses a contour fitting method, a contour fitting device and a contour fitting system. The contour fitting method provided by the embodiment of the invention comprises the following steps: acquiring a to-be-fitted point set of a to-be-tested piece in a rectangular coordinate system; performing decentration processing on the to-be-fitted point set to obtain a decentralized point set; performing polar coordinate transformation on the decentralized point set to obtain a first point set under a polar coordinate system; supplementing the first point set to obtain a second point set under the polar coordinate system; fitting the second point set to obtain a polar coordinate polynomial; and determining a closed curve under the rectangular coordinate system according to the polar coordinate polynomial, and taking the closed curve as a fitting contour of the to-be-measured piece. Thus, the fitting process of the closed curve is simplified, the contour fitting process of the to-be-measured piece is further simplified, consumed time is short, and good robustness is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of curve fitting, and in particular to a contour fitting method, a contour fitting device and a contour fitting system. Background Art

[0002] In industrial visual inspection, the features of workpieces such as lines, surfaces, circles, and curves are the most basic inspection elements. Among them, there are very mature algorithms for fitting elements such as lines, surfaces, circles, and non-closed curves. However, the fitting of closed curves of workpiece contours is currently mainly based on the B-spline curve fitting algorithm, which is time-consuming and leads to a long time for fitting the workpiece contour. Summary of the invention

[0003] The embodiments of the present application provide a contour fitting method, a contour fitting device, a contour fitting system and a computer-readable storage medium to solve at least one of the above-mentioned technical problems.

[0004] The contour fitting method of the embodiment of the present application includes:

[0005] Obtaining a set of points to be fitted of the object to be tested in a rectangular coordinate system;

[0006] Decentralizing the point set to be fitted to obtain a decentralized point set;

[0007] Performing polar coordinate transformation on the decentralized point set to obtain a first point set in a polar coordinate system;

[0008] Supplementing the first point set to obtain a second point set in the polar coordinate system;

[0009] Fitting the second point set to obtain a polar coordinate polynomial;

[0010] A closed curve in the rectangular coordinate system is determined according to the polar coordinate polynomial as a fitting contour of the object to be tested.

[0011] In some implementations, the decentralizing the point set to be fitted to obtain a decentralized point set includes:

[0012] Calculate the coordinates of the center point of the point set to be fitted;

[0013] The coordinates of each point in the to-be-fitted point set are subtracted from the coordinates of the center point to obtain the decentralized point set.

[0014] In some embodiments, performing polar coordinate transformation on the decentralized point set to obtain a first point set in a polar coordinate system includes:

[0015] Obtaining the rectangular coordinates of each point in the decentralized point set;

[0016] The rectangular coordinates of each point are converted into polar coordinates according to a polar coordinate transformation formula to obtain the first point set.

[0017] In some embodiments, the second point set includes the first point set and supplementary points, and the first point set is supplemented to obtain the second point set in the polar coordinate system, including:

[0018] According to the polar coordinates of each point in the first point set, at least part of the points in the first point set are copied and translated to obtain the supplementary points.

[0019] In some embodiments, the supplementary point includes a first supplementary point, and the step of copying and translating at least some of the points in the first point set according to the polar coordinates of each point in the first point set to obtain the supplementary point includes:

[0020] For the polar coordinates of each point in the first point set, determining whether a polar angle corresponding to the polar coordinates is greater than a first preset value and less than a second preset value;

[0021] When the polar angle corresponding to the polar coordinates is greater than the first preset value and less than the second preset value, the point corresponding to the polar coordinates is copied and translated by a first preset distance to obtain the first supplementary point;

[0022] The first preset value is smaller than the second preset value.

[0023] In some embodiments, the supplementary points further include second supplementary points, and the obtaining of the supplementary points by copying and translating at least some of the points in the first point set according to the polar coordinates of each point in the first point set includes:

[0024] For the polar coordinates of each point in the first point set, determining whether a polar angle corresponding to the polar coordinates is greater than a third preset value and less than a fourth preset value;

[0025] When the polar angle corresponding to the polar coordinates is greater than the third preset value and less than the fourth preset value, copy and translate the point corresponding to the polar coordinates by a second preset distance to obtain the second supplementary point;

[0026] Among them, the third preset value is smaller than the fourth preset value, the third preset value is larger than the first preset value, and the fourth preset value is larger than the second preset value.

[0027] In some embodiments, fitting the second point set to obtain a polar coordinate polynomial includes:

[0028] The second point set is fitted according to a fitting algorithm to obtain the polar coordinate polynomial, wherein the fitting algorithm includes any one of a polynomial fitting algorithm, a RANSAC fitting algorithm, and a weight-based fitting algorithm.

[0029] In some embodiments, determining the closed curve in the rectangular coordinate system according to the polar coordinate polynomial as the fitting contour of the device under test includes:

[0030] Convert the polar coordinate polynomial into a rectangular coordinate polynomial according to an inverse polar coordinate transformation formula;

[0031] In the rectangular coordinate system, the closed curve is determined according to the rectangular coordinate polynomial as the fitting contour of the device under test.

[0032] The contour fitting device of the embodiment of the present application includes:

[0033] An acquisition module is used to acquire a set of points to be fitted of the object to be tested in a rectangular coordinate system;

[0034] A processing module, used for performing a decentralized processing on the point set to be fitted to obtain a decentralized point set;

[0035] A transformation module, used for performing polar coordinate transformation on the decentralized point set to obtain a first point set in a polar coordinate system;

[0036] A supplementing module, used for supplementing the first point set to obtain a second point set in the polar coordinate system;

[0037] A fitting module, used for fitting the second point set to obtain a polar coordinate polynomial;

[0038] A determination module is used to determine a closed curve in the rectangular coordinate system according to the polar coordinate polynomial as a fitting contour of the object to be tested.

[0039] The contour fitting system of the embodiment of the present application includes one or more processors and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the contour fitting method of any of the above embodiments is implemented.

[0040] The computer-readable storage medium of the embodiment of the present application stores a computer program thereon, and when the program is executed by a processor, the contour fitting method of any of the above-mentioned embodiments is implemented.

[0041] In the contour fitting method, contour fitting device, contour fitting system and computer-readable storage medium of the embodiment of the present application, the set of points to be fitted corresponding to the test piece is decentralized and then converted to the polar coordinate system, supplemented and fitted in the polar coordinate system to obtain a polar coordinate polynomial, and a closed curve in the rectangular coordinate system is determined according to the polar coordinate polynomial as the fitting contour of the test piece. In this way, the fitting process of the closed curve is simplified, and then the contour fitting process of the test piece is simplified, which is time-consuming and has good robustness.

[0042] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0044] Figure 1 is a schematic flow chart of a contour fitting method in certain embodiments of the present application;

[0045] Figure 2 is a schematic diagram of a decentralized point set in a rectangular coordinate system of certain embodiments of the present application;

[0046] Figure 3 is a schematic diagram of a first point set in a polar coordinate system of certain embodiments of the present application;

[0047] Figure 4 is a schematic diagram of a second point set in a polar coordinate system in certain embodiments of the present application;

[0048] Figure 5 is a schematic diagram of a closed curve in a rectangular coordinate system of certain embodiments of the present application;

[0049] Figure 6 is a schematic diagram of a curve in a rectangular coordinate system obtained by fitting when the first point set is not supplemented in certain embodiments of the present application;

[0050] Figure 7 is a schematic flow chart of a contour fitting method in certain embodiments of the present application;

[0051] Figure 8 is a schematic flow chart of a contour fitting method in certain embodiments of the present application;

[0052] Fig. 9 is a schematic flow chart of a contour fitting method in certain embodiments of the present application;

[0053] Fig.10is a schematic flow chart of a contour fitting method in certain embodiments of the present application;

[0054] Fig.11 is a schematic flow chart of a contour fitting method in certain embodiments of the present application;

[0055] Fig.12 is a schematic flow chart of a contour fitting method in certain embodiments of the present application;

[0056] Fig.13 is a schematic flow chart of a contour fitting method in certain embodiments of the present application;

[0057] Fig.14 is a schematic diagram of a module of a contour fitting device according to some embodiments of the present application;

[0058] Fig.15 is a schematic diagram of a module of a contour fitting system of certain embodiments of the present application;

[0059] Fig.16 It is a schematic diagram of the connection status between a computer-readable storage medium and a processor in certain embodiments of the present application. DETAILED DESCRIPTION

[0060] The following is a further description of the embodiments of the present application in conjunction with the accompanying drawings. The same or similar reference numerals in the accompanying drawings represent the same or similar elements or elements with the same or similar functions from beginning to end. In addition, the embodiments of the present application described below in conjunction with the accompanying drawings are exemplary and are only used to explain the embodiments of the present application, and cannot be understood as limiting the present application.

[0061] See also Figure 1 , the embodiment of the present application provides a contour fitting method. The contour fitting method includes:

[0062] 010: Obtain the set of points to be fitted of the object to be tested in the rectangular coordinate system;

[0063] 020: Decentralize the fitting point set to obtain a decentralized point set;

[0064] 030: Perform polar coordinate transformation on the decentralized point set to obtain the first point set in the polar coordinate system;

[0065] 040: Supplement the first point set to obtain the second point set in the polar coordinate system;

[0066] 050: Fit the second point set to obtain the polar coordinate polynomial;

[0067] 060: Determine the closed curve in the rectangular coordinate system based on the polar coordinate polynomial as the fitting contour of the test piece.

[0068] In the contour fitting method of the embodiment of the present application, the set of points to be fitted corresponding to the object to be tested is decentralized and then converted to the polar coordinate system, supplemented and fitted in the polar coordinate system to obtain a polar coordinate polynomial, and a closed curve in the rectangular coordinate system is determined according to the polar coordinate polynomial as the fitting contour of the object to be tested. In this way, the fitting process of the closed curve is simplified, and then the contour fitting process of the object to be tested is simplified, which is time-consuming and has good robustness.

[0069] Specifically, in the industrial visual inspection scenario, the part to be tested can be an industrial part on a production line, etc. In a rectangular coordinate system, a set of points to be fitted of the part to be tested is obtained, and the rectangular coordinates of each point in the set of points to be fitted are determined. The set of points to be fitted can be obtained by edge detection of the image of the part to be tested, or it can be obtained based on a three-dimensional point cloud of the part to be tested.

[0070] According to the rectangular coordinates of each point in the set of points to be fitted, the set of points to be fitted is decentralized to obtain a decentralized point set in the rectangular coordinate system, such as Figure 2 After that, the decentralized point set is transformed into polar coordinates, and the decentralized point set in the rectangular coordinate system is transformed into the polar coordinate system to obtain the first point set in the polar coordinate system, as shown in Figure 3 shown.

[0071] After obtaining the first point set, the first point set is supplemented to obtain the second point set in the polar coordinate system, and then fitting is performed based on the second point set to obtain the polar coordinate polynomial. The curve corresponding to the fitted polar coordinate polynomial is as follows: Figure 4 As shown. According to the polar coordinate polynomial, a closed curve can be determined in the rectangular coordinate system, as Figure 5 As shown in FIG. 1 , the closed curve is the closed curve corresponding to the set of points to be fitted. The closed curve corresponding to the set of points to be fitted is also the fitting contour of the object to be tested.

[0072] After obtaining the fitting contour of the test piece, the quality of the test piece can be inspected based on the fitting contour of the test piece. For example, the contour degree of the test piece can be calculated based on the fitting contour of the test piece to determine the deviation of the fitting contour from the ideal contour, thereby determining whether the test piece is qualified.

[0073] It should be noted that the polar coordinate system in the embodiment of the present application refers to a coordinate system with ρ as the ordinate and θ as the abscissa. In the polar coordinate system, the range of the θ coordinate of the first point set is (-π, π), θ = -π and θ = π correspond to the intersection of the closed curves in the rectangular coordinate system, and there may or may not be a point at θ = -π and / or θ = π. It has been found that, if Figure 6As shown, if the first point set is not supplemented, the curve obtained by direct fitting is discontinuous at the junction and cannot transition smoothly. In the implementation mode of the present application, the first point set is supplemented to obtain the second point set, and then fitting is performed based on the second point set. The closed curve finally obtained by fitting is continuous and smooth at the junction.

[0074] In the related art, a B-spline curve fitting algorithm is used for closed curve fitting. Due to the computational complexity of the B-spline curve fitting algorithm, it is time-consuming and has poor robustness, resulting in a long time for contour fitting of the test piece and poor results.

[0075] In the implementation mode of the present application, the set of points to be fitted corresponding to the test piece is converted to the polar coordinate system, and then the polynomial is fitted after supplementation, and then converted to the rectangular coordinate system to obtain the corresponding closed curve, which is also the fitting contour of the test piece. In this way, the fitting process is simple, time-consuming, and has good robustness, which improves the contour fitting efficiency of the test piece, and further improves the quality inspection efficiency of the test piece.

[0076] See also Figure 7 In some implementations, the fitting point set is decentralized to obtain a decentralized point set (ie, 020), including:

[0077] 021: Calculate the coordinates of the center point of the point set to be fitted;

[0078] 022: Subtract the coordinates of the center point from the coordinates of each point in the point set to be fitted to obtain a decentralized point set.

[0079] Specifically, in a rectangular coordinate system, according to the rectangular coordinates of each point in the set of points to be fitted, the average value of the coordinates of all points is calculated to obtain the coordinates of the center point of the set of points to be fitted. The coordinates of each point in the set of points to be fitted are subtracted from the coordinates of the center point to achieve decentralization of the set of points to be fitted and obtain a decentralized point set.

[0080] It should be noted that the center point of the point set to be fitted can be any point in the rectangular coordinate system. If the subsequent fitting operation is performed directly based on the point set to be fitted, the polar coordinate polynomial obtained is relatively complex, which will increase unnecessary calculation amount. The center point of the decentralized point set is located at the origin of the rectangular coordinate system (such as Figure 2 As shown in Figure 2, the subsequent fitting operation is based on the decentralized point set, and the fitting process will be more direct and simple.

[0081] See also Figure 8 In some embodiments, polar coordinate transformation is performed on the decentralized point set to obtain a first point set (i.e., 030) in a polar coordinate system, including:

[0082] 031: Get the rectangular coordinates of each point in the decentralized point set;

[0083] 032: Convert the rectangular coordinates of each point into polar coordinates according to the polar coordinate transformation formula to obtain the first point set.

[0084] Specifically, the rectangular coordinates of each point in the decentralized point set are obtained, and the rectangular coordinates of each point in the decentralized point set are converted into polar coordinates according to the polar coordinate transformation formula, so as to transform the decentralized point set in the rectangular coordinate system into the polar coordinate system to obtain the first point set. The polar coordinate transformation formula is shown as follows:

[0085]

[0086]

[0087] Among them, (x, y) are rectangular coordinates and (ρ, θ) are the corresponding polar coordinates.

[0088] It can be understood that compared with the rectangular coordinate system, the closed curve can be described by a simpler mathematical expression in the polar coordinate system. Therefore, converting the decentralized point set in the rectangular coordinate system to the polar coordinate system and then performing subsequent fitting operations can effectively simplify the fitting process of the closed curve, thereby simplifying the contour fitting process of the test piece.

[0089] See also Fig. 9 In some embodiments, the second point set includes the first point set and the supplementary points. The first point set is supplemented to obtain the second point set (ie, 040) in the polar coordinate system, including:

[0090] 041: According to the polar coordinates of each point in the first point set, at least some of the points in the first point set are copied and translated to obtain supplementary points.

[0091] Specifically, the polar coordinates of each point in the first point set are obtained. Based on the polar coordinates of each point, some points in the first point set are selected as points to be translated according to preset rules for copy translation. Of course, all points in the first point set can also be used as points to be translated for copy translation. The points obtained by copy translation are supplementary points. The second point set includes the first point set and the supplementary points. Copy translation means that the points to be translated are first copied to obtain copy points. The points to be translated remain unchanged, and the corresponding copy points are translated to obtain supplementary points. Subsequent fitting operations are performed based on the supplemented second point set, so that the junction of the closed curve obtained by fitting can be smooth.

[0092] It should be noted that the translation distances of the multiple points to be translated may be the same or different. The process of obtaining the supplementary points is described in detail below.

[0093] See also Fig.10In some embodiments, the supplementary point includes a first supplementary point. According to the polar coordinates of each point in the first point set, at least some points in the first point set are copied and translated to obtain a supplementary point (ie, 041), including:

[0094] 0411: for the polar coordinates of each point in the first point set, determine whether the polar angle corresponding to the polar coordinates is greater than a first preset value and less than a second preset value;

[0095] 0412: When the polar angle corresponding to the polar coordinate is greater than the first preset value and less than the second preset value, the point corresponding to the polar coordinate is copied and translated by the first preset distance to obtain a first supplementary point;

[0096] The first preset value is smaller than the second preset value.

[0097] Specifically, the supplementary points include first supplementary points, the number of the first supplementary points is multiple, and the preset rules include first preset rules. First, according to the first preset rule, the points to be translated are selected in the first point set, and for the polar coordinates of each point in the first point set, it is determined whether the polar angle (that is, the θ coordinate) corresponding to the polar coordinates is greater than the first preset value and less than the second preset value. The first preset value is less than the second preset value. In an example, the first preset value is -π, and the second preset value is -c1·π. Among them, c1 is the first proportional coefficient, and the value range of c1 is (0,1). For example, c1 can be 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 or any other value between (0,1).

[0098] In the first point set, if the polar angle corresponding to the polar coordinates of a point is less than the first preset value, or greater than the second preset value, then the point does not need to be copied and translated. If the polar angle corresponding to the polar coordinates of a point is greater than the first preset value and less than the second preset value, then the point is selected as the point to be translated, and the point is copied and translated by the first preset distance to obtain the first supplementary point.

[0099] After the multiple points with polar angles greater than the first preset value and less than the second preset value are copied and translated by the first preset distance, multiple first supplementary points (such as Figure 4 The copy translation is a copy translation along the θ coordinate axis, and the first preset distance may be 2π.

[0100] See also Fig.11 In some embodiments, the supplementary point further includes a second supplementary point. According to the polar coordinates of each point in the first point set, at least some points in the first point set are copied and translated to obtain a supplementary point (ie, 041), including:

[0101] 0413: for the polar coordinates of each point in the first point set, determine whether the polar angle corresponding to the polar coordinates is greater than a third preset value and less than a fourth preset value;

[0102] 0414: when the polar angle corresponding to the polar coordinate is greater than the third preset value and less than the fourth preset value, copy and translate the point corresponding to the polar coordinate by a second preset distance to obtain a second supplementary point;

[0103] Among them, the third preset value is smaller than the fourth preset value, the third preset value is larger than the first preset value, and the fourth preset value is larger than the second preset value.

[0104] Specifically, the supplementary point also includes a second supplementary point, and the preset rule includes a second preset rule. First, a point to be translated is selected from the first point set according to the second preset rule, and for the polar coordinates of each point in the first point set, it is determined whether the polar angle (i.e., the θ coordinate) corresponding to the polar coordinates is greater than a third preset value and less than a fourth preset value. The third preset value is less than the fourth preset value, the third preset value is greater than the first preset value, and the fourth preset value is greater than the second preset value.

[0105] In one example, the first preset value is -π, the second preset value is -c1·π, the third preset value is c2·π, and the fourth preset value is π, c2·π>-π, π>c1·π. Wherein c2 is the second proportionality coefficient, and the value range of c2 is (0,1). For example, c2 can be 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 or any other value between (0,1).

[0106] In the first point set, if the polar angle corresponding to the polar coordinates of a point is less than the third preset value, or greater than the fourth preset value, then the point does not need to be copied and translated. If the polar angle corresponding to the polar coordinates of a point is greater than the third preset value and less than the fourth preset value, then the point is selected as the point to be translated, and the point is copied and translated by the second preset distance to obtain a second supplementary point.

[0107] After the multiple points with polar angles greater than the third preset value and less than the fourth preset value are copied and translated by the second preset distance, multiple second supplementary points (such as Figure 4 The second point set is obtained by taking the points in the rectangular frame A2 in the middle as the first point set, the first supplementary point and the second supplementary point. The copy translation is a copy translation along the θ coordinate axis, the absolute value of the second preset distance can be the same as the absolute value of the first preset distance, and the second preset distance can be -2π.

[0108] It can be understood that the purpose of supplementing the first point set to obtain the second point set is to make the junction of the closed curve obtained by subsequent fitting smooth. The positions of θ=-π and θ=π in the polar coordinate system correspond to the junction of the closed curve in the rectangular coordinate system, which is the same position in the rectangular coordinate system. Therefore, the points close to θ=-π in the first point set can be copied and translated to the right side of θ=π, and the points close to θ=π in the first point set can be copied and translated to the left side of θ=-π, so as to expand the range of the θ coordinate of the first point set and obtain the second point set. Since the distance between θ=-π and θ=π is 2π, the first preset distance is 2π and the second preset distance is -2π.

[0109] In the second point set obtained by supplementation, the points on the left and right sides close to θ=-π have the same distribution as the points on the left and right sides close to θ=π. For example, the points of θ∈(c2·π-2π,-c1·π) have the same distribution as the points of θ∈(c2·π,-c1·π+2π). Therefore, subsequent fitting operations based on the second point set can make the junction of the fitted closed curve smooth.

[0110] See also Fig.12 In some embodiments, fitting the second point set to obtain a polar coordinate polynomial (i.e., 050) includes:

[0111] 051: Fit the second point set according to a fitting algorithm to obtain a polar coordinate polynomial, wherein the fitting algorithm includes any one of a polynomial fitting algorithm, a RANSAC fitting algorithm, and a weight-based fitting algorithm.

[0112] Specifically, any fitting algorithm can be used to fit the second point set to obtain a polar coordinate polynomial. For example, a polynomial fitting algorithm can be used to fit the second point set, or a RANSAC fitting algorithm can be used to fit the second point set, or a weight-based fitting algorithm can be used to fit the second point set.

[0113] Among them, the polynomial fitting algorithm is simple and intuitive to model, highly adaptable and easy to optimize; the RANSAC fitting algorithm is robust, versatile and computationally efficient; the weight-based fitting algorithm considers the importance of data points, can adapt to unevenly distributed data and is highly flexible. In practical applications, different fitting algorithms can be selected for fitting according to the actual situation of the second point set to improve the fitting accuracy, so as to obtain the best polar coordinate polynomial and then the best closed curve. In addition, compared with the b-spline fitting algorithm, the above fitting algorithms have lower computational complexity, which is conducive to reducing the fitting time.

[0114] The fitted polar coordinate polynomial can correspond to a polar coordinate curve in the polar coordinate system. The part of the polar coordinate curve at θ∈(-π, π) is as follows: Figure 4 As shown in the middle curve S.

[0115] Taking the polynomial fitting algorithm to fit the second point set as an example, for the second point set, a polar coordinate polynomial is first assumed, and by adjusting the coefficients of the polar coordinate polynomial, a polar coordinate polynomial is found so that the polar coordinate polynomial achieves the best match with the second point set under a certain evaluation standard (such as the least squares method). The best match means that the error between the polar coordinate curve corresponding to the polar coordinate polynomial and the second point set is the smallest.

[0116] See also Fig.13 In some embodiments, a closed curve in a rectangular coordinate system is determined according to a polar coordinate polynomial as a fitting contour of the object to be tested (i.e., 060), including:

[0117] 061: Convert the polar coordinate polynomial to the rectangular coordinate polynomial according to the polar coordinate inverse transformation formula;

[0118] 062: In the rectangular coordinate system, a closed curve is determined according to the rectangular coordinate polynomial as the fitting contour of the object to be tested. Specifically, the polar coordinate inverse transformation formula is as follows:

[0119] x=ρcosθ

[0120] y=ρsinθ

[0121] The polar coordinate polynomial is converted into a rectangular coordinate polynomial according to the polar coordinate inverse transformation formula. It can be seen from the above implementation that the positions of θ=-π and θ=π in the polar coordinate system correspond to the intersection of the closed curve in the rectangular coordinate system. In the second point set, the points on the left and right sides close to θ=-π have the same distribution as the points on the left and right sides close to θ=π. After the polar coordinate polynomial obtained by fitting the second point set is converted into a rectangular coordinate polynomial, a smoothly transitioned closed curve can be obtained in the rectangular coordinate system. The closed curve is the closed curve corresponding to the point set to be fitted. In this way, based on simple polar coordinate transformation and polar coordinate inverse transformation, combined with the above-mentioned low-complexity fitting algorithm, the fitting of the closed curve can be achieved, which effectively simplifies the fitting process of the closed curve, and then simplifies the contour fitting process of the test piece.

[0122] See also Fig.14, the embodiment of the present application also provides a contour fitting device 100. The contour fitting device 100 includes an acquisition module 10, a processing module 20, a transformation module 30, a supplementation module 40, a fitting module 50 and a determination module 60. The acquisition module 10 is used to obtain a set of points to be fitted of the test piece in a rectangular coordinate system. The processing module 20 is used to perform a decentralized processing on the set of points to be fitted to obtain a decentralized point set. The transformation module 30 is used to perform a polar coordinate transformation on the decentralized point set to obtain a first point set in a polar coordinate system. The supplementation module 40 is used to supplement the first point set to obtain a second point set in a polar coordinate system. The fitting module 50 is used to fit the second point set to obtain a polar coordinate polynomial. The determination module 60 is used to determine a closed curve in a rectangular coordinate system according to the polar coordinate polynomial as the fitting contour of the test piece.

[0123] In some implementations, the processing module 20 is specifically used to calculate the coordinates of the center point of the set of points to be fitted; and to subtract the coordinates of the center point from the coordinates of each point in the set of points to be fitted to obtain a decentralized point set.

[0124] In some embodiments, the transformation module 30 is specifically used to obtain the rectangular coordinates of each point in the decentralized point set; and convert the rectangular coordinates of each point into polar coordinates according to the polar coordinate transformation formula to obtain the first point set.

[0125] In some embodiments, the second point set includes the first point set and supplementary points. The supplementary module 40 is specifically configured to copy and translate at least some of the points in the first point set according to the polar coordinates of each point in the first point set to obtain supplementary points.

[0126] In some embodiments, the supplementary point includes a first supplementary point. The supplementary module 40 is specifically used to determine, for each point in the first point set, whether the polar angle corresponding to the polar coordinate is greater than a first preset value and less than a second preset value; when the polar angle corresponding to the polar coordinate is greater than the first preset value and less than the second preset value, copy and translate the point corresponding to the polar coordinate by a first preset distance to obtain a first supplementary point; wherein the first preset value is less than the second preset value.

[0127] In some embodiments, the supplementary point further includes a second supplementary point. The supplementary module 40 is specifically configured to determine, for each point in the first point set, whether the polar angle corresponding to the polar coordinate is greater than a third preset value and less than a fourth preset value; when the polar angle corresponding to the polar coordinate is greater than the third preset value and less than the fourth preset value, copy and translate the point corresponding to the polar coordinate by a second preset distance to obtain a second supplementary point; wherein the third preset value is less than the fourth preset value, the third preset value is greater than the first preset value, and the fourth preset value is greater than the second preset value.

[0128] In some embodiments, the fitting module 50 is specifically used to fit the second point set according to a fitting algorithm to obtain a polar coordinate polynomial, wherein the fitting algorithm includes any one of a polynomial fitting algorithm, a RANSAC fitting algorithm, and a weight-based fitting algorithm.

[0129] In some embodiments, the determination module 60 is specifically used to convert the polar coordinate polynomial into a rectangular coordinate polynomial according to the polar coordinate inverse transformation formula; in the rectangular coordinate system, a closed curve is determined according to the rectangular coordinate polynomial as the fitting contour of the test piece.

[0130] It should be noted that the explanation of the contour fitting method in the aforementioned embodiment is also applicable to the contour fitting device 100 in the embodiment of the present application, and will not be elaborated here.

[0131] See also Fig.15 The embodiment of the present application also provides a contour fitting system 200, which includes one or more processors 210 and a memory 220. The memory 220 stores a computer program. When the computer program is executed by the processor 110, the contour fitting method of any of the above embodiments is implemented.

[0132] For example, when the computer program is executed by the processor 210, the following contour fitting method is implemented:

[0133] 010: Obtain the set of points to be fitted of the object to be tested in the rectangular coordinate system;

[0134] 020: Decentralize the fitting point set to obtain a decentralized point set;

[0135] 030: Perform polar coordinate transformation on the decentralized point set to obtain the first point set in the polar coordinate system;

[0136] 040: Supplement the first point set to obtain the second point set in the polar coordinate system;

[0137] 050: Fit the second point set to obtain the polar coordinate polynomial;

[0138] 060: Determine the closed curve in the rectangular coordinate system based on the polar coordinate polynomial as the fitting contour of the test piece.

[0139] For another example, when the computer program is executed by the processor 210, the following contour fitting method is implemented:

[0140] 021: Calculate the coordinates of the center point of the point set to be fitted;

[0141] 022: Subtract the coordinates of the center point from the coordinates of each point in the point set to be fitted to obtain a decentralized point set.

[0142] It should be noted that the explanations of the contour fitting method and the contour fitting device 100 in the aforementioned embodiment are also applicable to the contour fitting system 200 in the embodiment of the present application, and will not be elaborated here.

[0143] See also Fig.16 The computer-readable storage medium 300 of the embodiment of the present application stores a computer program 310 thereon, and when the program is executed by the processor 320, the contour fitting method of any of the above-mentioned embodiments is implemented.

[0144] For example, when the computer program 310 is executed by the processor 320, the following contour fitting method is implemented:

[0145] 010: Obtain the set of points to be fitted of the object to be tested in the rectangular coordinate system;

[0146] 020: Decentralize the fitting point set to obtain a decentralized point set;

[0147] 030: Perform polar coordinate transformation on the decentralized point set to obtain the first point set in the polar coordinate system;

[0148] 040: Supplement the first point set to obtain the second point set in the polar coordinate system;

[0149] 050: Fit the second point set to obtain the polar coordinate polynomial;

[0150] 060: Determine the closed curve in the rectangular coordinate system based on the polar coordinate polynomial as the fitting contour of the test piece.

[0151] For another example, when the computer program 310 is executed by the processor 320, the following contour fitting method is implemented:

[0152] 021: Calculate the coordinates of the center point of the point set to be fitted;

[0153] 022: Subtract the coordinates of the center point from the coordinates of each point in the point set to be fitted to obtain a decentralized point set.

[0154] It should be noted that the explanations of the contour fitting method and the contour fitting device 100 in the aforementioned embodiments are also applicable to the computer-readable storage medium 300 in the embodiments of the present application, and will not be elaborated here.

[0155] In summary, in the contour fitting method, contour fitting device 100, contour fitting system 200 and computer-readable storage medium 300 of the embodiment of the present application, the set of points to be fitted corresponding to the piece to be tested is decentralized and then converted to a polar coordinate system, supplemented and fitted in the polar coordinate system to obtain a polar coordinate polynomial, and a closed curve in a rectangular coordinate system is determined according to the polar coordinate polynomial as the fitting contour of the piece to be tested. In this way, the fitting process of the closed curve is simplified, and then the contour fitting process of the piece to be tested is simplified, which is time-consuming and has good robustness.

[0156] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0157] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0158] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable storage medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, a computer-readable storage medium can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable storage media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable storage medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0159] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0160] A person of ordinary skill in the art will appreciate that all or part of the steps carried by the method for implementing the above-mentioned embodiment can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment. In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically alone, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk or an optical disk, etc.

[0161] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application. The scope of the present application is defined by the claims and their equivalents.

Claims

1. A contour fitting method, characterized in that: include: Obtaining a set of points to be fitted of the object to be tested in a rectangular coordinate system; Decentralizing the point set to be fitted to obtain a decentralized point set; Performing polar coordinate transformation on the decentralized point set to obtain a first point set in a polar coordinate system; Supplementing the first point set to obtain a second point set in the polar coordinate system; Fitting the second point set to obtain a polar coordinate polynomial; A closed curve in the rectangular coordinate system is determined according to the polar coordinate polynomial as a fitting contour of the object to be tested.

2. The contour fitting method according to claim 1, characterized in that: The decentralizing the point set to be fitted to obtain a decentralized point set includes: Calculate the coordinates of the center point of the point set to be fitted; The coordinates of each point in the to-be-fitted point set are subtracted from the coordinates of the center point to obtain the decentralized point set.

3. The contour fitting method according to claim 1, characterized in that: The performing polar coordinate transformation on the decentralized point set to obtain a first point set in a polar coordinate system includes: Obtaining the rectangular coordinates of each point in the decentralized point set; The rectangular coordinates of each point are converted into polar coordinates according to a polar coordinate transformation formula to obtain the first point set.

4. The contour fitting method according to claim 1, characterized in that: The second point set includes the first point set and supplementary points, and the first point set is supplemented to obtain the second point set in the polar coordinate system, including: According to the polar coordinates of each point in the first point set, at least part of the points in the first point set are copied and translated to obtain the supplementary points.

5. The contour fitting method according to claim 4, characterized in that: The supplementary points include a first supplementary point, and the step of copying and translating at least some of the points in the first point set according to the polar coordinates of each point in the first point set to obtain the supplementary points includes: For the polar coordinates of each point in the first point set, determining whether a polar angle corresponding to the polar coordinates is greater than a first preset value and less than a second preset value; When the polar angle corresponding to the polar coordinates is greater than the first preset value and less than the second preset value, the point corresponding to the polar coordinates is copied and translated by a first preset distance to obtain the first supplementary point; The first preset value is smaller than the second preset value.

6. The contour fitting method according to claim 5, characterized in that: The supplementary points also include second supplementary points, and the method of obtaining the supplementary points by copying and translating at least some of the points in the first point set according to the polar coordinates of each point in the first point set includes: For the polar coordinates of each point in the first point set, determining whether a polar angle corresponding to the polar coordinates is greater than a third preset value and less than a fourth preset value; When the polar angle corresponding to the polar coordinates is greater than the third preset value and less than the fourth preset value, copy and translate the point corresponding to the polar coordinates by a second preset distance to obtain the second supplementary point; Among them, the third preset value is smaller than the fourth preset value, the third preset value is larger than the first preset value, and the fourth preset value is larger than the second preset value.

7. The contour fitting method according to claim 1, characterized in that: The step of fitting the second point set to obtain a polar coordinate polynomial includes: The second point set is fitted according to a fitting algorithm to obtain the polar coordinate polynomial, wherein the fitting algorithm includes any one of a polynomial fitting algorithm, a RANSAC fitting algorithm, and a weight-based fitting algorithm.

8. The contour fitting method according to claim 1, characterized in that: The step of determining a closed curve in the rectangular coordinate system according to the polar coordinate polynomial as a fitting contour of the object to be tested includes: Convert the polar coordinate polynomial into a rectangular coordinate polynomial according to an inverse polar coordinate transformation formula; In the rectangular coordinate system, the closed curve is determined according to the rectangular coordinate polynomial as the fitting contour of the device under test.

9. A contour fitting device, characterized in that: include: An acquisition module is used to acquire a set of points to be fitted of the object to be tested in a rectangular coordinate system; A processing module, used for performing a decentralized processing on the point set to be fitted to obtain a decentralized point set; A transformation module, used for performing polar coordinate transformation on the decentralized point set to obtain a first point set in a polar coordinate system; A supplementing module, used for supplementing the first point set to obtain a second point set in the polar coordinate system; A fitting module, used for fitting the second point set to obtain a polar coordinate polynomial; A determination module is used to determine a closed curve in the rectangular coordinate system according to the polar coordinate polynomial as a fitting contour of the object to be tested.

10. A contour fitting system, characterized in that: The contour fitting system includes one or more processors and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the contour fitting method according to any one of claims 1 to 8 is implemented.