A method for fitting a cylinder in a point cloud and a computer readable storage medium

CN117557719BActive Publication Date: 2026-09-29SHENZHEN HUAHAN WEIYE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311407347.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-27
Publication Date
2026-09-29
Estimated Expiration
2043-10-27

AI Technical Summary

Technical Problem

然而,对深度图像中待检测物体的全部轮廓或部分轮廓的像素点进行拟合时,若参与拟合的像素点中包括有局外点,则拟合获取的拟合图像会存在较大误差,进而会导致后续对待检测物体的高度及体积等的测量或检测不准确

Benefits of technology

[0078]本申请所提供的点云中圆柱体的拟合方法,包括:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117557719B_ABST
    Figure CN117557719B_ABST
Patent Text Reader

Abstract

The application provides a fitting method of a cylinder in a point cloud, which comprises: obtaining an original point cloud; selecting a plurality of point clouds from the original point cloud and fitting the point clouds to obtain a cylinder; determining whether the number of inliers is greater than a number threshold; when it is determined that the cylinder is an initial fitting cylinder, selecting a plurality of point clouds within a preset distance threshold range from the surface of the initial fitting cylinder as a to-be-fitted point cloud data set; estimating the point clouds in the to-be-fitted point cloud data set to obtain an initial value of a parameter of the fitting cylinder; iteratively updating the parameter according to the initial value and an iterative equation until an iterative update stop condition is reached to obtain a final fitting value of the parameter. The method can effectively remove the influence of abnormal points (such as point clouds belonging to outliers) on the final fitting value of the parameter used for fitting the three-dimensional shape of the to-be-detected workpiece, thereby improving the accuracy and efficiency of subsequent volume detection of the to-be-detected workpiece.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of visual recognition technology, specifically to a method for fitting cylinders in point clouds and a computer-readable storage medium. Background Technology

[0002] In the field of machine vision, depth images, or point cloud data that can reflect the three-dimensional shape information of an object, are needed for industrial quality inspection or non-contact measurement. This is to acquire the three-dimensional shape information of objects (such as planes, spheres, cylinders, etc.) and then use it for non-contact measurement of geometric tolerances such as cylindricity, perpendicularity, and roundness. For example, firstly, the pixels of the entire or part of the contour of the object (such as the object to be inspected) are fitted to obtain a corresponding fitted image. Then, based on this fitted image, industrial inspection of the object to be inspected is performed, such as height measurement, volume measurement, and other related inspection operations.

[0003] In the aforementioned fitting process, the fitting accuracy of the image is low due to factors such as environmental conditions, defects in the object being detected, and outliers, making it impossible to accurately measure geometric tolerances. In the captured data, inliers are pixels whose distance from the surface of the object being detected is less than or equal to the error distance (a preset distance threshold), while outliers are pixels whose distance from the surface of the object being detected is greater than the error distance. However, when fitting the entire or part of the contour of the object being detected in the depth image, if outliers are included in the fitting, the resulting image will have significant errors, leading to inaccurate measurements or detections of the object's height and volume. Therefore, it is necessary to remove outliers during the fitting process.

[0004] Therefore, it is necessary to improve the aforementioned existing technologies. Summary of the Invention

[0005] The main technical problem solved by this invention is to provide a method for fitting cylinders in point clouds, so as to effectively remove the influence of outliers (such as point clouds that belong to outliers) on the final fitting values ​​of the parameters of the fitted cylinder used to fit the three-dimensional shape of the workpiece to be inspected, thereby improving the accuracy and efficiency of subsequent measurement or inspection of the height and volume of the workpiece to be inspected.

[0006] According to a first aspect, one embodiment provides a method for fitting a cylinder in a point cloud. The fitting method includes:

[0007] Obtain the original point cloud; randomly select multiple point clouds from the original point cloud and fit the multiple point clouds to obtain a cylinder; determine whether to use the cylinder as the initial fitting cylinder based on whether the number of interior points corresponding to the cylinder is greater than a preset number threshold; when it is determined to use the cylinder as the initial fitting cylinder, select the multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range as the point cloud dataset to be fitted.

[0008] The original point cloud includes a point cloud used to characterize the workpiece to be inspected;

[0009] The fitting cylinder is used to fit the three-dimensional shape of the workpiece to be inspected.

[0010] The point cloud in the dataset to be fitted is estimated to obtain the initial values ​​of the parameters of the fitted cylinder;

[0011] The parameters of the fitted cylinder include the direction vector of the central axis of the fitted cylinder, the coordinates of any point on the central axis, and the radius of the fitted cylinder.

[0012] The parameters of the fitted cylinder are iteratively updated based on the initial values ​​of the parameters and the pre-constructed iterative equation of the fitted cylinder until a preset iterative update stop condition is reached, thereby obtaining the final fitted values ​​of the parameters of the fitted cylinder; wherein, the iterative equation is used to characterize the iterative update relationship between the parameters of the fitted cylinder after the (i+1)th iteration update and the parameters of the fitted cylinder after the ith iteration update.

[0013] In one embodiment, the step of randomly selecting multiple point clouds from the original point cloud and fitting the multiple point clouds to obtain a cylinder, and determining whether to use the cylinder as the initial fitting cylinder based on whether the number of interior points corresponding to the cylinder is greater than a preset threshold, and when it is determined that the cylinder is to be used as the initial fitting cylinder, the multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted, including:

[0014] The steps for selecting a point cloud are as follows: randomly select a set of point clouds from the original point cloud;

[0015] The steps for generating the cylinder are as follows: fit the set of point clouds to obtain a cylinder, and calculate the distance from each point cloud in the set of point clouds to the surface of the cylinder;

[0016] The steps for determining interior points are as follows: Based on the preset distance threshold and the distance from each point cloud in the point cloud group to the corresponding surface of the cylinder, determine the number of interior points in the point cloud group; wherein, the interior point refers to the point cloud in the point cloud group whose distance to the surface of the cylinder is less than the distance threshold.

[0017] The steps to determine the point cloud dataset to be fitted are as follows:

[0018] If the number of interior points in the point cloud is greater than a preset threshold, then the cylinder is used as the initial fitting cylinder, and the multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted, and the point cloud is deleted from the original point cloud.

[0019] If the number of interior points in the point cloud is less than the preset threshold, the above steps of selecting the point cloud, generating the cylinder, and determining the interior points are iterated until the number of interior points in the point cloud is greater than the preset threshold or the fitting error between the cylinder generated after the continued iteration and the cylinder generated before the continued iteration is less than the preset error threshold. The latest cylinder is then used as the initial fitted cylinder, and the multiple point clouds in the original point cloud whose distance from the surface of the initial fitted cylinder is within the preset distance threshold range are used as the point cloud dataset to be fitted.

[0020] In one embodiment, estimating the point cloud in the point cloud dataset to be fitted that corresponds to the initial fitted cylinder to obtain initial values ​​for the parameters of the fitted cylinder includes:

[0021] The coordinates of the centroid of the point cloud corresponding to one of the fitted cylinders are used as the initial values ​​of the coordinates of any point on the central axis corresponding to the fitted cylinder.

[0022] The initial value of the direction vector of the central axis of the fitted cylinder is determined based on the covariance matrix of the point cloud corresponding to the fitted cylinder in the point cloud dataset to be fitted; wherein, the initial value of the direction vector of the central axis of the fitted cylinder is the eigenvector corresponding to the largest eigenvalue of the covariance matrix.

[0023] The radii of multiple initial fitting cylinders are calculated by substituting the initial values ​​of the point cloud to be fitted, the coordinates of any point on the central axis, and the direction vector of the central axis into the parametric equation of the fitting cylinder.

[0024] Calculate the average of the radii of all the initial fitted cylinders, and use the average as the initial value of the radius of the fitted cylinder.

[0025] In one embodiment, the parametric equation of the fitted cylinder is:

[0026] A 2 +B 2 +C 2 =R 2 ,

[0027] in,

[0028]

[0029]

[0030]

[0031] Where (a, b, c) represents the direction vector of the central axis of the fitted cylinder, and R represents the radius of the fitted cylinder. Let represent the coordinates of any point on the central axis, and let be the expression for the radius:

[0032]

[0033] Among them, u i =A,v i =B, w i =C.

[0034] In one embodiment, the step of iteratively updating the parameters of the fitted cylinder based on the initial values ​​of the parameters of the fitted cylinder and the pre-constructed iterative equation of the fitted cylinder until a preset iterative update stop condition is reached, thereby obtaining the final fitted values ​​of the parameters of the fitted cylinder, includes:

[0035] Based on the initial values ​​of the parameters of the fitting cylinder, the distance from each point cloud in the point cloud dataset to the corresponding surface of the fitting cylinder is calculated. Based on the distance from each point cloud in the point cloud dataset to the corresponding surface of the fitting cylinder, the weight of the loss value of each point cloud in the point cloud dataset is obtained.

[0036] A new coordinate system is established with the initial value of the coordinates of any point on the central axis as the origin and the initial value of the direction vector of the central axis as the axis. The coordinates of each point cloud in the point cloud dataset to be fitted are transformed to the new coordinate system using a preset coordinate transformation formula.

[0037] Based on the pre-constructed iterative equation of the fitted cylinder, the parameter change matrix of the fitted cylinder is calculated; wherein, the parameter change matrix includes: the change in the direction vector of the central axis of the fitted cylinder, the change in the coordinate of any point on the central axis, and the change in the radius of the fitted cylinder;

[0038] The steps for iteratively updating and calculating the overall loss value are as follows: Based on the parameter change matrix of the fitted cylinder, the parameters of the fitted cylinder are iteratively updated to obtain the updated parameters of the fitted cylinder, and the overall loss value of the fitted cylinder after iterative update and the overall loss value before iterative update are calculated.

[0039] Repeat the steps of iterative update and calculation of the overall loss value until the preset iterative update stop condition is reached. The value of the parameter of the fitted cylinder corresponding to the iterative update stop condition is taken as the final fitted value of the parameter of the fitted cylinder.

[0040] In one embodiment, the preset iterative update stopping condition is: the ratio of the difference between the total loss value after the iterative update and the total loss value before the iterative update to the total loss value before the iterative update is less than a preset ratio threshold, or the preset number of iterations threshold is reached;

[0041] The overall loss value is obtained by weighting the loss values ​​of each point cloud based on the loss value weight of each point cloud. The loss value of each point cloud is obtained based on the distance of each point cloud to the surface of the fitted cylinder. The loss value weight of each point cloud is inversely proportional to the distance of each point cloud to the corresponding surface of the fitted cylinder.

[0042] The iterative equation is obtained based on the matrix of the rate of change of the overall loss value with respect to each parameter of the fitted cylinder.

[0043] In one embodiment, the expression of the preset coordinate transformation formula is:

[0044] Among them, (x' i y' i , z' i (x) represents the coordinates of the i-th point cloud in the point cloud dataset to be fitted in the new coordinate system. i y i , z i () represents the coordinates of the i-th point in the point cloud dataset to be fitted in the original coordinate system.

[0045] Wherein, when the direction vector (a, b, c) of the central axis is (1, 0, 0), s1 = 0, c1 = 1, s2 = -1, c2 = 0;

[0046] otherwise,

[0047] In one embodiment, the expression for the iterative equation is:

[0048] (J i T J i +λdiag(J i T J i ))P i =J i T F i ,

[0049] Wherein, J i J represents the matrix representing the rate of change of the overall loss value of the fitted cylinder relative to the parameters of the fitted cylinder after the i-th iteration update. i The expression is:

[0050]

[0051] Wherein, w i The weight of the loss value for the i-th point cloud in the point cloud dataset to be fitted is N, where N is the number of point clouds in the point cloud dataset to be fitted, and P is... i The parameter change matrix generated from the i-th iteration update to the (i+1)-th iteration update, wherein P i This is the quantity to be solved in the iterative equation.

[0052] The F i This represents the estimated value r obtained after the i-th iteration update, based on the i-th point cloud, of the radius of the fitted cylinder. i The difference between the current R and the value of R.

[0053] The λ i This represents the learning rate after the i-th iteration of the iterative equation. The learning rate is used to control the step size for iteratively updating the parameters of the fitted cylinder.

[0054] The estimated value r i The expression is:

[0055]

[0056] In one embodiment, the P i The expression is:

[0057] P i = [dx, dy, da, db, dR] T ,

[0058] The F i The expression is:

[0059] F i = [R-r1, R-r2, ..., Rr] N ] T .

[0060] In one embodiment, the expressions for the updated parameters of the fitted cylinder are as follows:

[0061]

[0062]

[0063] R' = R + dR.

[0064] In one embodiment, the expression for the overall loss value is:

[0065]

[0066] Wherein, the ε i Let be the loss value of the i-th point cloud in the point cloud dataset to be fitted.

[0067] In one embodiment, the ε i The expression is:

[0068] or Wherein, the δ i τ is the distance from the i-th point cloud in the point cloud to be fitted to the surface of the fitting cylinder, and τ is the distance threshold.

[0069] In one embodiment, the expression for τ is:

[0070]

[0071] The expression for the weight of the loss value of the i-th point cloud in the point cloud to be fitted is:

[0072] or

[0073] In one embodiment, after iteratively updating the parameters of the fitted cylinder to obtain the updated parameters of the fitted cylinder, if the ratio of the total loss value of the fitted cylinder after the current iteration to the total loss value of the fitted cylinder before the current iteration is greater than a preset ratio threshold, then the learning rate is updated using the following expression:

[0074] λ new =λ old / k,

[0075] Wherein, k is a preset coefficient, and λ old The learning rate before the current iteration update, λ new The learning rate is the one updated in the current iteration.

[0076] According to a second aspect, one embodiment provides a computer-readable storage medium. The computer-readable storage medium includes a program. The program is executable by a processor to perform the methods described in any of the embodiments herein.

[0077] The beneficial effects of this application are:

[0078] The method for fitting cylinders in point clouds provided in this application includes:

[0079] Obtain the original point cloud; randomly select multiple point clouds from the original point cloud, and fit the multiple point clouds to obtain a cylinder. Determine whether to use the cylinder as the initial fitted cylinder based on whether the number of interior points corresponding to the cylinder is greater than a preset threshold. When the cylinder is determined to be the initial fitted cylinder, the multiple point clouds in the original point cloud whose distance to the surface of the initial fitted cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted. The original point cloud includes point clouds used to characterize the workpiece to be inspected; the fitted cylinder is used for... The three-dimensional shape of the workpiece to be inspected is fitted; the point cloud in the point cloud dataset to be fitted is estimated to obtain the initial values ​​of the parameters of the fitted cylinder; wherein, the parameters of the fitted cylinder include the direction vector of the central axis of the fitted cylinder, the coordinates of any point on the central axis, and the radius of the fitted cylinder; the parameters of the fitted cylinder are iteratively updated according to the initial values ​​of the parameters of the fitted cylinder and the pre-constructed iterative equation of the fitted cylinder until a preset iterative update stop condition is reached, thereby obtaining the final fitted values ​​of the parameters of the fitted cylinder. This method determines whether to use the cylinder as the initial fitting cylinder based on whether the number of interior points corresponding to the cylinder is greater than a preset threshold. When the cylinder is determined to be the initial fitting cylinder, multiple point clouds in the original point cloud whose distance to the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted. This avoids using outliers (such as point clouds belonging to outliers) for subsequent fitting of the cylinder. In other words, this method can effectively remove the adverse effects of outliers (such as point clouds belonging to outliers) on the final fitting value of the parameters of the fitting cylinder used to fit the three-dimensional shape of the workpiece to be inspected, improve the accuracy of the final fitting value, and thus improve the accuracy and efficiency of subsequent measurement or inspection of the height and volume of the workpiece to be inspected. Attached Figure Description

[0080] Figure 1 This is a flowchart illustrating a method for fitting cylinders in a point cloud according to one embodiment.

[0081] Figure 2 This is a schematic diagram illustrating the process of using multiple point clouds in the original point cloud that are within a preset distance threshold range from the surface of the initial fitting cylinder as a point cloud dataset to be fitted, as an embodiment of the process.

[0082] Figure 3 This is a schematic diagram of the initial fitted cylinder in one embodiment;

[0083] Figure 4 This is a schematic diagram illustrating the process of obtaining initial values ​​of parameters for a fitted cylinder according to one embodiment.

[0084] Figure 5 This is a schematic diagram illustrating the process of obtaining the final fitted values ​​of the parameters of a fitted cylinder according to one embodiment. Detailed Implementation

[0085] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings. Similar elements in different embodiments are referred to by associated similar element reference numerals. In the following embodiments, many details are described to facilitate a better understanding of this application. However, those skilled in the art will readily recognize that some features may be omitted in different situations, or may be replaced by other elements, materials, or methods. In some cases, certain operations related to this application are not shown or described in the specification. This is to avoid obscuring the core parts of this application with excessive description. For those skilled in the art, detailed description of these related operations is not necessary; they can fully understand the related operations based on the description in the specification and general technical knowledge in the art.

[0086] Furthermore, the features, operations, or characteristics described in the specification can be combined in any suitable manner to form various embodiments. At the same time, the steps or actions in the method description can be rearranged or adjusted in a manner obvious to those skilled in the art. Therefore, the various orders in the specification and drawings are only for the clear description of a particular embodiment and do not imply a necessary order, unless otherwise stated that a particular order must be followed.

[0087] The serial numbers assigned to components in this document, such as "first" and "second," are used only to distinguish the described objects and have no sequential or technical meaning. The terms "connection" and "linkage" used in this application, unless otherwise specified, include both direct and indirect connections (linkages).

[0088] Currently, the main method for obtaining the 3D shape information of objects is based on fitting methods; however, this method has poor noise resistance. This application proposes a fitting method for cylinders in point clouds, which is a fitting method for geometric primitives with better noise resistance. Geometric primitives are a general term for geometric elements, such as lines, circles, spheres, cylinders, and cones. Cylindrical blanks are a typical type of workpiece, which can be processed by machine tools to produce various shaft parts. Current 3D visual recognition methods for cylindrical workpieces include the following parts: 1) acquiring the 3D point cloud of the original workpiece; 2) filtering the original point cloud and calculating its normal; 3) segmenting the cylinders in the point cloud using traditional cylinder fitting tools; 4) outputting the recognition results of the cylinders. However, in practical engineering, the presence of noise points in the original 3D point cloud leads to large fitting deviations and high computational costs for cylinders. Furthermore, since most objects to be detected are composed of quadratic surfaces such as spheres, cylinders, or cones, different object shapes will yield different depth images. For each different depth image, a method corresponding to the object's shape is needed to remove outliers. For example, when the object is cylindrical, existing techniques use methods specifically for cylinders to remove outliers, such as coordinate transformation or projection. These methods convert 3D computation into 2D computation, reducing the accuracy of the estimation.

[0089] The technical approach of the point cloud fitting method for cylinders provided in this application is as follows:

[0090] An initial fitting of all point cloud data related to the workpiece to be inspected is performed to obtain a cylinder. Whether to use the cylinder as the initial fitting cylinder is determined by whether the number of interior points corresponding to the cylinder exceeds a preset threshold. When the cylinder is selected as the initial fitting cylinder, multiple point clouds in the original point cloud whose distance to the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted. Then, the point clouds in the dataset to be fitted are estimated to obtain initial values ​​for the parameters of the fitting cylinder. Finally, the fitting cylinder is fitted based on the initial values ​​of the fitting cylinder parameters and the pre-constructed iterative equation for the fitting cylinder. The parameters of the fitted cylinder are iteratively updated until a preset iteration stop condition is met, resulting in the final fitted values ​​of the cylinder's parameters. During this iterative update process, the distance from the point cloud in the dataset to be fitted to the initial surface of the fitted cylinder needs to be calculated. Points farther from the surface of the fitted cylinder have smaller weights corresponding to their loss values, while points closer to the surface have larger weights. This effectively reduces the influence of outliers on the final fitted values ​​of the cylinder's parameters. In other words, the cylinder fitting method in point clouds provided in this application estimates and iteratively optimizes parameters based on the geometric features of the object.

[0091] The fitting method provided in this application processes the three-dimensional point cloud data of the input workpiece to be inspected to obtain the final fitting value of the fitting cylinder used to fit the three-dimensional shape of the workpiece to be inspected, thereby calculating the three-dimensional shape information of the workpiece to be inspected. The calculated three-dimensional shape information of the workpiece to be inspected can then be used in the fields of measuring form and position tolerances in three-dimensional space, estimating disordered state posture, and robot grasping.

[0092] The technical solution of this application will be described in detail below with reference to the embodiments.

[0093] Please refer to Figure 1 This application provides a method for fitting cylinders in point clouds, the method comprising:

[0094] Step S100: Obtain the original point cloud; randomly select multiple point clouds from the original point cloud and fit the multiple point clouds to obtain a cylinder. Determine whether to use the cylinder as the initial fitting cylinder based on whether the number of interior points corresponding to the cylinder is greater than a preset number threshold. When it is determined to use the cylinder as the initial fitting cylinder, multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted.

[0095] Step S200: Estimate the point cloud in the point cloud dataset to be fitted to obtain the initial values ​​of the parameters of the fitted cylinder;

[0096] Step S300: Based on the initial values ​​of the parameters of the fitted cylinder and the pre-constructed iterative equation of the fitted cylinder, the parameters of the fitted cylinder are iteratively updated until the preset iterative update stop condition is reached, thereby obtaining the final fitted values ​​of the parameters of the fitted cylinder.

[0097] It should be noted that the above-mentioned fitting method provided in this application is applicable not only to workpieces that are cylindrical, but also to workpieces that are similar in shape to a cylinder (such as elliptical cylinders, simple circles, etc.).

[0098] In step S100 above, the original point cloud includes a point cloud used to characterize the workpiece to be inspected. The fitted cylinder is used to fit the three-dimensional shape of the workpiece to be inspected.

[0099] In some embodiments, in step S100 above, three-dimensional point cloud data related to the workpiece to be inspected can be directly acquired, and the three-dimensional point cloud data can be used as the original point cloud.

[0100] In some embodiments, step S100 above may involve first acquiring a depth image related to the workpiece to be inspected, then converting the depth image into three-dimensional point cloud data according to the pixel resolution, and then using the three-dimensional point cloud data obtained after the above conversion as the original point cloud.

[0101] It should be noted that the above-mentioned "converting the depth image into three-dimensional point cloud data according to pixel resolution" is existing technology in this field, and therefore will not be described in detail.

[0102] In step S200 above, the parameters of the fitted cylinder include the direction vector of the central axis of the fitted cylinder, the coordinates of any point on the central axis, and the radius of the fitted cylinder.

[0103] In step S300 above, the iterative equation is used to characterize the iterative update relationship between the parameters of the fitted cylinder after the (i+1)th iteration update and the parameters of the fitted cylinder after the ith iteration update.

[0104] In some embodiments, please refer to Figure 2 In step S100, multiple point clouds are randomly selected from the original point cloud, and a cylinder is obtained by fitting these multiple point clouds. Whether to use the cylinder as the initial fitting cylinder is determined based on whether the number of interior points corresponding to the cylinder is greater than a preset threshold. When it is determined that the cylinder will be used as the initial fitting cylinder, multiple point clouds in the original point cloud whose distance to the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted, including:

[0105] Step S110 for selecting point clouds: Randomly select a set of point clouds from the original point cloud;

[0106] Step S120 for generating the cylinder: Fit the point cloud to obtain a cylinder, and calculate the distance from each point cloud in the point cloud to the surface of the cylinder.

[0107] Step S130 for determining interior points: Based on the preset distance threshold and the distance from each point cloud in the point cloud to the corresponding cylindrical surface, determine the number of interior points in the point cloud.

[0108] Step S140 for determining the point cloud dataset to be fitted: If the number of interior points in the point cloud is greater than a preset threshold, then the cylinder is used as the initial fitting cylinder, and multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted, and the point cloud is deleted from the original point cloud; if the number of interior points in the point cloud is less than a preset threshold, then the above steps of selecting point clouds, generating cylinders, and determining interior points are iterated until the number of interior points in the point cloud is greater than the preset threshold or the fitting error between the cylinder generated after the iteration and the cylinder generated before the iteration is less than a preset error threshold, then the newly obtained cylinder is used as the initial fitting cylinder, and multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted.

[0109] In some embodiments, in step S110 of selecting point clouds described above, a certain number of point clouds (e.g., 5 point clouds) can be randomly selected from the original point cloud.

[0110] In some embodiments, a cylinder can be directly fitted using the aforementioned certain number of point clouds, and the distance from each point cloud in the set of point clouds (i.e., the aforementioned certain number of point clouds) to the surface of the cylinder can be calculated. It is understood that in other embodiments, the distance from each point cloud in the original point cloud to the surface of the cylinder can also be directly calculated, and the calculated distance can be used for subsequent calculations.

[0111] It should be noted that the calculation of the distances from each point cloud to the surface of the cylinder is common knowledge in this field, so it will not be elaborated here.

[0112] It should be noted that the purpose of "calculating the distance from the point cloud (such as the point cloud in the dataset to be fitted) to the surface of the fitted cylinder" is to give a smaller weight to the loss value of the point cloud that is far from the fitted cylinder, and a larger weight to the loss value of the point cloud that is close to the fitted cylinder. This is to remove outlier data (such as point cloud data that belongs to outside points) from the data (such as the original point cloud data), thereby improving the accuracy and stability of the final fitted value of the parameters of the fitted cylinder.

[0113] It should be noted that step S100 can effectively remove point cloud data of non-cylindrical objects (i.e., point clouds that do not belong to the workpiece to be inspected), thereby improving the accuracy of the final fitted values ​​of the parameters obtained by fitting the fitted cylinder.

[0114] It should be noted that the specific process of "fitting the point cloud to obtain a cylinder" can be referred to step S200 below. For example, the process of "fitting the point cloud to obtain a cylinder" can be as follows: 1) Use the coordinates of the centroid of the point cloud as the initial value of the coordinates of any point on the central axis corresponding to the fitted cylinder; determine the direction vector of the central axis of the cylinder based on the covariance matrix of the point cloud; wherein, the direction vector of the central axis of the cylinder is the eigenvector corresponding to the largest eigenvalue of the covariance matrix; 2) Substitute the coordinates of the point cloud, any point on the central axis, and the direction vector of the central axis into the parametric equation of the fitted cylinder to calculate the radius of the cylinder, and thus obtain the cylinder.

[0115] In some embodiments, in step S130 of determining interior points, after the distances from each point cloud to the surface of the cylinder have been calculated, the number of interior points in the group of point clouds can be determined based on a preset distance threshold and the distances from each point cloud in the group to the corresponding surface of the cylinder. An interior point refers to a point cloud in the group of point clouds or the original point cloud whose distance to the surface of the cylinder is less than the distance threshold; an exterior point (i.e., an outlier) refers to a point cloud in the group of point clouds or the original point cloud whose distance to the initial fitted cylinder surface is less than the distance threshold.

[0116] It should be noted that the specific settings of the above-mentioned "preset distance threshold", "preset quantity threshold" and "preset error threshold" are common knowledge in the field, and those skilled in the art can set them specifically according to actual needs, so they will not be elaborated further.

[0117] In some embodiments, in step S140 above, if the distance from the point cloud to the surface of the cylinder is less than a preset distance threshold, the vote count can be incremented by 1. When the number of inliers (i.e., the final result of the vote count) is greater than a preset number threshold, the cylinder can be used as the initial fitting cylinder. Multiple point clouds in the original point cloud whose distance to the surface of the initial fitting cylinder is within the preset distance threshold range are used as the point cloud dataset to be fitted, and this set of point clouds is deleted from the original point cloud.

[0118] It should be noted that there is only one "initial fitted cylinder" determined in step S140 that corresponds to the original point cloud. For example, the "initial fitted cylinder" determined in step S140 may be the cylinder corresponding to the condition "the number of interior points in this set of point clouds is greater than a preset number threshold", or the cylinder corresponding to the condition "the fitting error between the cylinder generated after further iteration and the cylinder generated before further iteration is less than a preset error threshold" (i.e., the latest cylinder obtained above).

[0119] It should be noted that the purpose of step S100 is to segment the point cloud belonging to the workpiece to be detected from the original point cloud, that is, to remove abnormal point clouds (i.e., point clouds belonging to the aforementioned external points in the original point cloud), and to use the point cloud belonging to the workpiece to be detected (i.e., the point cloud in the aforementioned point cloud dataset to be fitted) to fit the aforementioned fitted cylinder, thereby enabling the final fitted value of the parameters of the subsequently obtained fitted cylinder to have higher fitting accuracy. Please refer to... Figure 3 , Figure 3 A set of point clouds roughly cylindrical in shape belongs to the workpiece to be inspected or the initial fitted cylinder, while the point clouds located in... Figure 3 The point cloud that is planar directly below the roughly cylindrical shape is a planar point cloud. This is because if a planar point cloud is used to fit the above-mentioned fitted cylinder, it is likely that the final fitting value of the parameters of the above-mentioned fitted cylinder will have poor fitting accuracy.

[0120] In some embodiments, please refer to Figure 4 In step S200 above, the point cloud corresponding to the initial fitted cylinder in the point cloud dataset to be fitted is estimated to obtain the initial values ​​of the parameters of the fitted cylinder, including:

[0121] Step S210: Use the coordinates of the centroid of the point cloud corresponding to a fitted cylinder as the initial value of the coordinates of any point on the central axis corresponding to the fitted cylinder; determine the initial value of the direction vector of the central axis of the fitted cylinder based on the covariance matrix of the point cloud corresponding to the fitted cylinder in the dataset of the point cloud to be fitted; wherein, the initial value of the direction vector of the central axis of the fitted cylinder is the eigenvector corresponding to the largest eigenvalue of the covariance matrix.

[0122] Step S220: Substitute the initial values ​​of the coordinates of a set of point clouds to be fitted, any point on the central axis, and the direction vector of the central axis corresponding to the initial fitted cylinder into the parametric equation of the fitted cylinder to calculate the radii of multiple initial fitted cylinders.

[0123] Step S230: Calculate the average value of the radii of all initial fitted cylinders, and use the average value as the initial value of the radius of the fitted cylinder.

[0124] It should be noted that the purpose of obtaining the initial values ​​of the parameters of the fitted cylinder in step S200 is to obtain the initial values ​​of the parameters of the fitted cylinder, and then use the above initial values ​​to preliminarily characterize the geometric features and other three-dimensional morphological information of the workpiece to be inspected or the fitted cylinder.

[0125] In some embodiments, in step S210, the coordinates (d, e, f) of the centroid of the point cloud corresponding to a fitted cylinder are calculated using the following expression:

[0126]

[0127] Where n represents the number of point clouds in the point cloud dataset to be fitted that correspond to a fitted cylinder, and x i y i and z i Let d, e, and f represent the coordinates of the i-th point cloud in the point cloud dataset corresponding to the aforementioned fitting cylinder along the x-axis, y-axis, and z-axis, respectively; where the coordinates (d, e, f) (i.e., the coordinates of the centroids of each point cloud in the point cloud dataset) are the coordinates of any point on the central axis corresponding to the fitting cylinder. The initial value.

[0128] The expression for the covariance matrix of the point cloud dataset to be fitted in step S210 above can be:

[0129]

[0130] At this time It also represents the coordinates of the centroids of each point cloud in the point cloud dataset to be fitted. That is, at this time, the coordinates of the centroids of each point cloud in the point cloud dataset to be fitted are used as the initial values ​​of the coordinates of any point on the central axis corresponding to the fitted cylinder.

[0131] It should be noted that the coordinates of the centroid of the point cloud corresponding to the fitted cylinder can also be obtained directly through other existing calculation methods. Here, we do not restrict the specific method of obtaining the coordinates of the centroid.

[0132] The parametric equations for fitting the cylinder in step S220 above are as follows:

[0133] A 2 +B 2 +C 2 =R 2 ,

[0134] in,

[0135]

[0136] Where (a, b, c) represents the direction vector of the central axis of the fitted cylinder, and R represents the radius of the fitted cylinder, which is expressed as:

[0137]

[0138] Among them, u i =A,v i =B, w i =C. Wherein, a, b, c, and R are the parameters to be fitted corresponding to the fitted cylinder mentioned above. Let be the coordinates of any point on the central axis corresponding to the fitted cylinder.

[0139] It should be noted that the above u i v i w i This is an intermediate variable for calculating the radius R.

[0140] It should be noted that, given that the initial values ​​of the coordinates of any point on the central axis corresponding to the fitted cylinder and the initial values ​​of the direction vector of the central axis of the fitted cylinder have been obtained in step S210 above, a set of point clouds to be fitted corresponding to the initial fitted cylinder and the coordinates of any point on the central axis (i.e., ...) can be respectively... The initial values ​​of the initial values ​​of the central axis and the direction vector of the central axis (i.e., (a, b, c)) are substituted into the parametric equation of the fitted cylinder in step S220 above to calculate the radii R of multiple initial fitted cylinders.

[0141] It should be noted that the step S230, "calculating the average value of the radii of all initial fitted cylinders and using the average value as the initial value of the radius of the fitted cylinder," is common knowledge in the field, so it will not be elaborated further.

[0142] In some embodiments, please refer to Figure 5 In step S300, the parameters of the fitted cylinder are iteratively updated based on the initial values ​​of the parameters and the pre-constructed iterative equation of the fitted cylinder until a preset iterative update stop condition is reached, thereby obtaining the final fitted values ​​of the parameters of the fitted cylinder, including:

[0143] Step S310: Based on the initial values ​​of the parameters of the fitting cylinder, calculate the distance from each point cloud in the point cloud dataset to the corresponding surface of the fitting cylinder, and obtain the loss weight of each point cloud in the point cloud dataset based on the distance from each point cloud in the point cloud dataset to the corresponding surface of the fitting cylinder.

[0144] Step S320: Establish a new coordinate system with the initial value of the coordinates of any point on the central axis as the origin and the initial value of the direction vector of the central axis as the axis. Use the preset coordinate transformation formula to transform the coordinates of each point cloud in the point cloud dataset to be fitted to the new coordinate system.

[0145] Step S330: Calculate the parameter change matrix of the fitted cylinder according to the pre-constructed iterative equation of the fitted cylinder; wherein, the parameter change matrix includes: the change of the direction vector of the central axis of the fitted cylinder, the change of the coordinate of any point on the central axis, and the change of the radius of the fitted cylinder;

[0146] Step S340 of iterative update and calculation of total loss value: Based on the parameter change matrix of the fitted cylinder, iteratively update the parameters of the fitted cylinder to obtain the updated parameters of the fitted cylinder, and calculate the total loss value of the fitted cylinder after iterative update and the total loss value before iterative update.

[0147] Step S350: Repeat the iterative update and calculation of the overall loss value until the preset iterative update stop condition is reached. The value of the parameters of the fitted cylinder corresponding to the iterative update stop condition is taken as the final fitted value of the parameters of the fitted cylinder.

[0148] It should be noted that the purpose of "iteratively updating the parameters of the fitted cylinder" in step S300 is to remove outlier data (such as point cloud data belonging to external points), thereby improving the accuracy and precision of the final fitted values ​​of the parameters of the fitted cylinder.

[0149] It should be noted that in step S300, during the iterative update of the parameters of the fitted cylinder, the shape of the fitted cylinder is also constantly being iteratively updated. That is, it gradually iterates from the initial fitted cylinder to a fitted cylinder that is basically or completely consistent with the shape of the workpiece to be detected (such as a cylinder).

[0150] It should be noted that the purpose of step S300 is to estimate the final fitting value of the parameters of the fitted cylinder. This application adopts a step-by-step iterative update method (i.e., the iterative equation mentioned above) to gradually approach the optimal value (i.e., the final fitting value of the parameters of the fitted cylinder) starting from the initial value of the parameters of the fitted cylinder. That is, based on the iterative equation mentioned above, the initial fitted cylinder is iterated step by step to a fitted cylinder that is basically or completely consistent with the shape of the workpiece to be detected (such as a cylinder).

[0151] It should be noted that the step S310 above, "calculating the distance from each point cloud in the point cloud dataset to the corresponding fitting cylinder surface", is common knowledge in the field, so it will not be elaborated further.

[0152] In some embodiments, the expression of the preset coordinate transformation formula in step S320 above is:

[0153]

[0154] Among them, (x' i y' i , z' i (x) represents the coordinates of the i-th point in the point cloud dataset to be fitted in the new coordinate system. i y i , z i () represents the coordinates of the i-th point in the point cloud dataset to be fitted in the original coordinate system.

[0155]

[0156] Wherein, when the direction vector (a, b, c) of the central axis is (1, 0, 0), s1 = 0, c1 = 1, s2 = -1, c2 = 0; otherwise,

[0157] It should be noted that those skilled in the art can select the original coordinate system (such as a rectangular coordinate system) according to actual needs, and there is no restriction on the "original coordinate system" here.

[0158] In some embodiments, the expression for the iterative equation in step S330 above is:

[0159] (J i T J i +λdiag(J i T J i ))P i =J i T F i ,

[0160] Among them, J i This represents the overall loss value of the fitted cylinder after the i-th iteration update relative to the parameters of the fitted cylinder (e.g., ...). A matrix of the rates of change of (a, b, and c, etc.).

[0161] J i The expression is:

[0162]

[0163] Among them, w i J represents the weight of the loss value for the i-th point cloud in the dataset to be fitted, N is the number of point clouds in the dataset to be fitted, and J is the weight of the loss value for the i-th point cloud. i x in the expression i y i z i This refers to the coordinates of the point cloud obtained by transforming it using the coordinate transformation formula described above. P i Let P be the parameter change matrix generated from the i-th iteration update to the (i+1)-th iteration update. i As the variable to be solved in the iterative equation, F i This represents the estimated value r obtained after the i-th iteration update, based on the i-th point cloud, of the radius of the fitted cylinder. i The difference between R and the current R, λ i The learning rate represents the learning rate after the i-th iteration of the iterative equation. The learning rate is used to control the step size for iterative updates of the parameters of the fitted cylinder.

[0164] The above estimated value r i The expression is:

[0165]

[0166] It should be noted that in step S330 above, the gradient can be obtained by calculating the partial derivative of the set objective function. The opposite direction of the gradient corresponds to the direction of the largest rate of change of each parameter in the parameter change matrix. Therefore, when the above iterative equation is updated, the opposite direction of the gradient can be used as the direction of the iterative equation, which can make the iterative equation approach the optimal value of each parameter of the fitted cylinder (i.e., the final fitted value of each parameter of the fitted cylinder) more quickly.

[0167] It should be noted that the overall loss value of the fitted cylinder mentioned above is the "defined objective function". The objective function refers to the weighted sum of squares of the errors between the estimated value and the true value, or it can be expressed as the weighted sum of squares of the errors of the geometric distances obtained by substituting all the points in the point cloud dataset to be fitted into the above cylinder parametric equation.

[0168] In some embodiments, in step S330 above, the parameter change matrix P i The expression is:

[0169] P i = [dx, dy, da, db, dR] T ,

[0170] F i The expression is:

[0171] F i = [R-r1, R-r2, ..., Rr] N ] T ,

[0172] Where da and db represent the change in the direction vector of the central axis of the fitted cylinder, dx and dy represent the change in the coordinates of any point on the central axis, and dR represents the change in the radius R of the fitted cylinder.

[0173] Among them, P i This represents the matrix of parameter changes obtained from the solution, that is, it can be represented relative to the values ​​before the current iteration update. The changes in a, b, and R.

[0174] In some embodiments, the expressions for the updated parameters of the fitted cylinder in step S340 above are as follows:

[0175]

[0176]

[0177] R' = R + dR.

[0178] In some embodiments, the expression for the above-mentioned total loss value is:

[0179]

[0180] Where, ε i Let be the loss value of the i-th point cloud in the point cloud dataset to be fitted.

[0181] In some embodiments, the above ε i The expression is:

[0182]

[0183] or

[0184]

[0185] Where, δ iLet be the distance from the i-th point in the point cloud to the surface of the fitting cylinder, and τ be the distance threshold. Those skilled in the art can flexibly set the above distance threshold according to actual needs.

[0186] In some embodiments, the expression for τ above is:

[0187]

[0188] The expression for the weight of the loss value of the i-th point in the point cloud to be fitted is:

[0189]

[0190] or

[0191]

[0192] It should be noted that the expression for the weights of the loss values ​​mentioned above... The loss value weight of point clouds whose distance to the surface of the fitted cylinder is less than the distance threshold can be set to 1, while the loss value weight of point clouds whose distance to the surface of the fitted cylinder is greater than the distance threshold can be set to 1. As the distance to the surface of the fitted cylinder increases, the loss value weight of the corresponding point cloud decreases.

[0193] It should be noted that the expression for the weights of the loss values ​​mentioned above... The loss weights of point clouds whose distance to the surface of the fitted cylinder is less than a distance threshold can be increased, while the loss weights of point clouds whose distance to the surface of the fitted cylinder is greater than a distance threshold can be zero.

[0194] In some embodiments, in step S340 above, after iteratively updating the parameters of the fitted cylinder to obtain the updated parameters of the fitted cylinder, if the ratio of the total loss value of the fitted cylinder after the current iteration update to the total loss value of the fitted cylinder before the current iteration update is greater than a preset ratio threshold, then the learning rate is updated using the following expression:

[0195] λ new =λ old / k,

[0196] Where k is a preset coefficient, λ old λ represents the learning rate before the current iteration update. new This represents the learning rate updated in the current iteration.

[0197] In some embodiments, k can be 20. Those skilled in the art can select the specific value of k according to actual needs, and there is no limitation on the value of k here.

[0198] It should be noted that the reason for updating the learning rate during the iterative update of the parameters of the fitted cylinder is as follows: the iterative update of the parameters of the fitted cylinder starts from the initial value of the parameters of the fitted cylinder and gradually approaches the optimal value (i.e., the final fitted value of the parameters of the fitted cylinder). That is, based on the above iterative equation, it iterates from the initial fitted cylinder to a fitted cylinder that is basically or completely consistent with the shape of the workpiece to be detected (such as a cylinder). At the beginning of the above iterative update, the fitted value of the parameters of the fitted cylinder is far from the optimal value, so it is desirable to have a larger step size for the iterative update to quickly approach the optimal value. When the fitted value of the parameters of the fitted cylinder is close to the optimal value, it is desirable to have a smaller step size for the iterative update to avoid skipping the optimal value.

[0199] In some embodiments, the preset iterative update stopping condition in step S350 is: the ratio of the difference between the total loss value after iterative update and the total loss value before iterative update to the total loss value before iterative update is less than a preset ratio threshold, or the preset number of iterations threshold is reached; the total loss value is obtained by weighting the loss values ​​of each point cloud based on the loss value weight of each point cloud, the loss value of each point cloud is obtained based on the distance of each point cloud to the surface of the fitting cylinder, and the loss value weight of each point cloud is inversely proportional to the distance of each point cloud to the corresponding surface of the fitting cylinder; the iterative equation is obtained based on the matrix of the rate of change of the total loss value relative to each parameter of the fitting cylinder.

[0200] It should be noted that the loss values ​​for each point cloud mentioned above refer to the weighted sum of squared errors of the geometric distance (i.e., the distance from each point cloud to the surface of the fitted cylinder). That is, the weighted sum of squared errors reflects a piecewise representation of the weighted distance, which is equivalent to integrating the aforementioned loss value weights and the aforementioned geometric distances.

[0201] Compared with existing technologies, the advantages of the cylinder fitting method in point clouds provided in this application are:

[0202] 1) The fitting method of this application has good noise resistance;

[0203] 2) The learning rate update and calculation described above can be completed through the iterative process of this application;

[0204] 3) The fitting method of this application can effectively eliminate the influence of outliers (such as point clouds belonging to outliers) on the final fitting values ​​of the parameters of the fitting cylinder used to fit the three-dimensional shape of the workpiece to be inspected, thereby improving the accuracy and efficiency of subsequent measurement or inspection of the height and volume of the workpiece to be inspected.

[0205] It should be noted that the statement "the fitting method of this application has good noise resistance" is reflected in the overall loss value obtained by weighting the loss values ​​of each point cloud based on the loss value weight of each point cloud, as well as the specific process of "iteratively updating the parameters of the fitted cylinder" mentioned above.

[0206] It should be noted that the reason for "updating and calculating the learning rate through an iterative process" is that this application aims to increase the learning rate as the distance from the optimal value increases, and decrease the learning rate as the distance from the optimal value decreases. The technical purpose of "updating and calculating the learning rate" is to approximate the optimal solution with high precision, avoiding oscillations and excessive time consumption.

[0207] It should be noted that the aforementioned "adverse effects of effectively removing outliers (such as point clouds belonging to outliers) on the final fitted values ​​of the parameters of the fitted cylinder used to fit the 3D shape of the workpiece to be inspected" are mainly reflected in the following two aspects:

[0208] First, by determining whether to use the cylinder as the initial fitting cylinder based on whether the number of interior points corresponding to the cylinder is greater than a preset threshold, when it is determined that the cylinder is the initial fitting cylinder, the multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted, thereby avoiding the use of outliers (such as point clouds belonging to outliers) for fitting the subsequent fitting cylinder, and removing the adverse effects of outliers (such as point clouds belonging to outliers) on the final fitting values ​​of the parameters of the fitting cylinder used to fit the three-dimensional shape of the workpiece to be inspected.

[0209] Second, the overall loss value obtained by weighting the loss values ​​of each point cloud based on the loss value weight of each point cloud, the loss value of each point cloud obtained based on the distance of each point cloud to the surface of the fitting cylinder, and the relationship between the loss value weight of each point cloud and the distance of each point cloud to the corresponding surface of the fitting cylinder are used to further remove the adverse effects of outliers (such as point clouds belonging to outliers) on the final fitting value of the parameters of the fitting cylinder used to fit the three-dimensional shape of the workpiece to be inspected. In the iterative update process, the fitted cylinder is constantly approaching the true shape of the workpiece to be inspected, and the distance of each corresponding point cloud to the corresponding surface of the fitting cylinder is constantly changing, and thus the loss value weight of each point cloud is also changing synchronously.

[0210] The above describes some methods for fitting cylinders in point clouds. Some embodiments of this application also disclose a computer-readable storage medium including a program that can be executed by a processor to implement the methods described in any of the embodiments herein.

[0211] This document describes various exemplary embodiments with reference to them. However, those skilled in the art will recognize that changes and modifications can be made to the exemplary embodiments without departing from the scope of this document. For example, various operational steps and components for performing operational steps can be implemented in different ways depending on the specific application or considering any number of cost functions associated with the operation of the system (e.g., one or more steps can be deleted, modified, or combined with other steps).

[0212] In the above embodiments, implementation can be achieved, in whole or in part, by software, hardware, firmware, or any combination thereof. Furthermore, as those skilled in the art will understand, the principles herein can be reflected in a computer program product on a computer-readable storage medium pre-loaded with computer-readable program code. Any tangible, non-transitory computer-readable storage medium may be used, including magnetic storage devices (hard disks, floppy disks, etc.), optical storage devices (CD-ROMs, DVDs, Blu-ray discs, etc.), flash memory, and / or the like. These computer program instructions can be loaded onto a general-purpose computer, special-purpose computer, or other programmable data processing apparatus to form a machine, such that instructions executing on the computer or other programmable data processing apparatus can generate means for implementing a specified function. These computer program instructions can also be stored in a computer-readable storage medium that can instruct the computer or other programmable data processing apparatus to operate in a particular manner, such that instructions stored in the computer-readable storage medium can form an article of manufacture including means for implementing the specified function. The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to perform a series of operational steps on the computer or other programmable apparatus to produce a computer-implemented process, such that instructions executing on the computer or other programmable apparatus can provide steps for implementing the specified function.

[0213] While the principles herein have been illustrated in various embodiments, numerous modifications to the structures, arrangements, proportions, elements, materials, and components, particularly suited to specific environments and operational requirements, may be used without departing from the principles and scope of this disclosure. These modifications and other alterations or alterations will be included within the scope of this document.

[0214] The foregoing specific descriptions have been described with reference to various embodiments. However, those skilled in the art will recognize that various modifications and changes can be made without departing from the scope of this disclosure. Therefore, considerations for this disclosure are to be illustrative rather than restrictive, and all such modifications are to be included within its scope. Similarly, advantages, other advantages, and solutions to problems with respect to various embodiments have been described above. However, benefits, advantages, solutions to problems, and any elements that produce these, or make them more explicit, should not be construed as critical, essential, or necessary. The term “comprising” and any other variations thereof as used herein are non-exclusive inclusion, meaning that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not expressly listed or not part of the process, method, system, article, or apparatus. Furthermore, the term “coupled” and any other variations thereof as used herein refer to physical connections, electrical connections, magnetic connections, optical connections, communication connections, functional connections, and / or any other connections.

[0215] Those skilled in the art will recognize that many changes can be made to the details of the above embodiments without departing from the basic principles of the invention. Therefore, the scope of the invention should be determined only by the claims.

Claims

1. A method for fitting cylinders in point clouds, characterized in that, include: Obtain the original point cloud; randomly select multiple point clouds from the original point cloud and fit the multiple point clouds to obtain a cylinder; determine whether to use the cylinder as the initial fitting cylinder based on whether the number of interior points corresponding to the cylinder is greater than a preset number threshold; when it is determined to use the cylinder as the initial fitting cylinder, select the multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range as the point cloud dataset to be fitted. The original point cloud includes a point cloud used to characterize the workpiece to be inspected; The fitting cylinder is used to fit the three-dimensional shape of the workpiece to be inspected. The point cloud in the dataset to be fitted is estimated to obtain the initial values ​​of the parameters of the fitted cylinder; The parameters of the fitted cylinder include the direction vector of the central axis of the fitted cylinder, the coordinates of any point on the central axis, and the radius of the fitted cylinder. The parameters of the fitted cylinder are iteratively updated based on the initial values ​​of the parameters and the pre-constructed iterative equation of the fitted cylinder until a preset iterative update stop condition is reached, thereby obtaining the final fitted values ​​of the parameters of the fitted cylinder; wherein, the iterative equation is used to characterize the iterative update relationship between the parameters of the fitted cylinder after the (i+1)th iteration update and the parameters of the fitted cylinder after the ith iteration update.

2. The fitting method as described in claim 1, characterized in that, The process involves randomly selecting multiple point clouds from the original point cloud and fitting them to obtain a cylinder. The method determines whether to use this cylinder as the initial fitted cylinder based on whether the number of interior points corresponding to the cylinder is greater than a preset threshold. When the cylinder is determined to be the initial fitted cylinder, the multiple point clouds in the original point cloud whose distance to the surface of the initial fitted cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted, including: The steps for selecting a point cloud are as follows: randomly select a set of point clouds from the original point cloud; The steps for generating the cylinder are as follows: fit the set of point clouds to obtain a cylinder, and calculate the distance from each point cloud in the set of point clouds to the surface of the cylinder; The steps for determining interior points are as follows: Based on the preset distance threshold and the distance from each point cloud in the point cloud group to the corresponding surface of the cylinder, determine the number of interior points in the point cloud group; wherein, the interior point refers to the point cloud in the point cloud group whose distance to the surface of the cylinder is less than the distance threshold. The steps to determine the point cloud dataset to be fitted are as follows: If the number of interior points in the point cloud is greater than a preset threshold, then the cylinder is used as the initial fitting cylinder, and the multiple point clouds in the original point cloud whose distance from the surface of the initial fitting cylinder is within a preset distance threshold range are used as the point cloud dataset to be fitted, and the point cloud is deleted from the original point cloud. If the number of interior points in the point cloud is less than the preset threshold, the above steps of selecting the point cloud, generating the cylinder, and determining the interior points are iterated until the number of interior points in the point cloud is greater than the preset threshold or the fitting error between the cylinder generated after the continued iteration and the cylinder generated before the continued iteration is less than the preset error threshold. The latest cylinder is then used as the initial fitted cylinder, and the multiple point clouds in the original point cloud whose distance from the surface of the initial fitted cylinder is within the preset distance threshold range are used as the point cloud dataset to be fitted.

3. The fitting method as described in claim 1, characterized in that, The step of estimating the point cloud in the point cloud dataset to be fitted, corresponding to the initial fitted cylinder, to obtain initial values ​​for the parameters of the fitted cylinder, includes: The coordinates of the centroid of the point cloud corresponding to one of the fitted cylinders are used as the initial values ​​of the coordinates of any point on the central axis corresponding to the fitted cylinder. The initial value of the direction vector of the central axis of the fitted cylinder is determined based on the covariance matrix of the point cloud corresponding to the fitted cylinder in the point cloud dataset to be fitted; wherein, the initial value of the direction vector of the central axis of the fitted cylinder is the eigenvector corresponding to the largest eigenvalue of the covariance matrix. The radii of multiple initial fitting cylinders are calculated by substituting the initial values ​​of the point cloud to be fitted, the coordinates of any point on the central axis, and the direction vector of the central axis into the parametric equation of the fitting cylinder. Calculate the average of the radii of all the initial fitted cylinders, and use the average as the initial value of the radius of the fitted cylinder.

4. The fitting method as described in claim 3, characterized in that, The parametric equation of the fitted cylinder is: A 2 +B 2 +C 2 =R 2 , in, Where (a, b, c) represents the direction vector of the central axis of the fitted cylinder, and R represents the radius of the fitted cylinder. Let represent the coordinates of any point on the central axis, and let be the expression for the radius: Among them, u i = A, v i = B, w i = C.

5. The fitting method as described in claim 1, characterized in that, The step of iteratively updating the parameters of the fitted cylinder based on the initial values ​​of the parameters and the pre-constructed iterative equation of the fitted cylinder until a preset iterative update stop condition is met, thereby obtaining the final fitted values ​​of the parameters of the fitted cylinder, includes: Based on the initial values ​​of the parameters of the fitting cylinder, the distance from each point cloud in the point cloud dataset to the corresponding surface of the fitting cylinder is calculated. Based on the distance from each point cloud in the point cloud dataset to the corresponding surface of the fitting cylinder, the weight of the loss value of each point cloud in the point cloud dataset is obtained. A new coordinate system is established with the initial value of the coordinates of any point on the central axis as the origin and the initial value of the direction vector of the central axis as the axis. The coordinates of each point cloud in the point cloud dataset to be fitted are transformed to the new coordinate system using a preset coordinate transformation formula. Based on the pre-constructed iterative equation of the fitted cylinder, the parameter change matrix of the fitted cylinder is calculated; wherein, the parameter change matrix includes: the change in the direction vector of the central axis of the fitted cylinder, the change in the coordinate of any point on the central axis, and the change in the radius of the fitted cylinder; The steps for iteratively updating and calculating the overall loss value are as follows: Based on the parameter change matrix of the fitted cylinder, the parameters of the fitted cylinder are iteratively updated to obtain the updated parameters of the fitted cylinder, and the overall loss value of the fitted cylinder after iterative update and the overall loss value before iterative update are calculated. Repeat the steps of iterative update and calculation of the overall loss value until the preset iterative update stop condition is reached. The value of the parameter of the fitted cylinder corresponding to the iterative update stop condition is taken as the final fitted value of the parameter of the fitted cylinder.

6. The fitting method as described in claim 5, characterized in that, The preset iterative update stopping condition is: the ratio of the difference between the total loss value after the iterative update and the total loss value before the iterative update to the total loss value before the iterative update is less than a preset ratio threshold, or the preset number of iterations threshold is reached. The overall loss value is obtained by weighting the loss values ​​of each point cloud based on the loss value weight of each point cloud. The loss value of each point cloud is obtained based on the distance of each point cloud to the surface of the fitted cylinder. The loss value weight of each point cloud is inversely proportional to the distance of each point cloud to the corresponding surface of the fitted cylinder. The iterative equation is obtained based on the matrix of the rate of change of the overall loss value with respect to each parameter of the fitted cylinder.

7. The fitting method as described in claim 5, characterized in that, The expression for the preset coordinate transformation formula is: Among them, (x' i y' i , z' i (x) represents the coordinates of the i-th point cloud in the point cloud dataset to be fitted in the new coordinate system. i y i , z i () represents the coordinates of the i-th point in the point cloud dataset to be fitted in the original coordinate system. Wherein, when the direction vector (a, b, c) of the central axis is (1, 0, 0), s1 = 0, c1 = 1, s2 = -1, c2 = 0; otherwise, 8. The fitting method as described in claim 5, characterized in that, The expression for the iterative equation is: (J i T J i +λdiag(J i T J i ))P i =J i T F i , Wherein, J i J represents the matrix representing the rate of change of the overall loss value of the fitted cylinder relative to the parameters of the fitted cylinder after the i-th iteration update. i The expression is: Wherein, w i The weight of the loss value for the i-th point cloud in the point cloud dataset to be fitted is N, where N is the number of point clouds in the point cloud dataset to be fitted, and P is... i The parameter change matrix generated from the i-th iteration update to the (i+1)-th iteration update, wherein P i This is the quantity to be solved in the iterative equation. The F i This represents the estimated value r obtained after the i-th iteration update, based on the i-th point cloud, of the radius of the fitted cylinder. i The difference between the current R and the value of R. The λ i This represents the learning rate after the i-th iteration of the iterative equation. The learning rate is used to control the step size for iteratively updating the parameters of the fitted cylinder. The estimated value r i The expression is:

9. The fitting method as described in claim 8, characterized in that, The P i The expression is: P i =[dx, dy, da, db, dR] T , The F i The expression is: F i =[R-r1,R-r2,…,R-r N ] T 。 10. The fitting method as described in claim 9, characterized in that, The expressions for the updated parameters of the fitted cylinder are as follows: R′=R+dR.

11. The fitting method as described in claim 10, characterized in that, The expression for the total loss value is: Wherein, the ε i Let be the loss value of the i-th point cloud in the point cloud dataset to be fitted.

12. The fitting method as described in claim 11, characterized in that, The ε i The expression is: or Wherein, the δ i τ is the distance from the i-th point cloud in the point cloud to be fitted to the surface of the fitting cylinder, and τ is the distance threshold.

13. The fitting method as described in claim 12, characterized in that, The expression for τ is: The expression for the weight of the loss value of the i-th point cloud in the point cloud to be fitted is: or 14. The fitting method as described in claim 5, characterized in that, After iteratively updating the parameters of the fitted cylinder to obtain the updated parameters, if the ratio of the total loss value of the fitted cylinder after the current iteration to the total loss value of the fitted cylinder before the current iteration is greater than a preset ratio threshold, then the learning rate is updated using the following expression: l new =λ old / k, Wherein, k is a preset coefficient, and λ old The learning rate before the current iteration update, λ new The learning rate is the one updated in the current iteration.

15. A computer-readable storage medium, characterized in that, Includes a program that can be executed by a processor to implement the method as described in any one of claims 1 to 14.

Citation Information

Patent Citations

  • Rendering method and device of three-dimensional scene model file

    CN103838851A

  • System and method for mesh and body hybrid modeling using 3D scan data

    US20070265727A1