A method for fitting a rounded rectangle based on a three-dimensional point cloud
Patent Information
- Application Number
- CN202611087700.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-10-16
AI Technical Summary
本发明旨在解决圆角矩形中直线段与圆弧段平滑连接导致的混合点云难以区分、圆角区域划分不稳定、半径估算受噪声和毛刺影响大的问题,提高圆角矩形特征参数提取的完整性、准确性和鲁棒性
[0048] 1. Based on the original boundary extraction and planar projection process, this invention adds an ordered contour construction and line-arc separation step. It can first automatically divide the boundary points of rounded rectangles into candidate points of straight line segments, candidate points of circular arc segments, and transitional overlapping points, and then further refine and filter out the straight line segment points and circular arc segment points; thus solving the problem of difficulty in distinguishing mixed point clouds caused by smooth connection between straight line segments and circular arc segments.
Smart Images

Figure CN122929080A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of three-dimensional point cloud processing and geometric feature extraction technology, specifically relating to a method for fitting rounded rectangles based on three-dimensional point clouds. Background Technology
[0002] In the field of industrial inspection, rounded rectangle features are widely used in rectangular slots, mounting holes, positioning windows, structural openings, mold cavities, and transition chamfer areas of mechanical parts. Compared to ordinary rectangular features, rounded rectangles are composed of four straight line segments and four circular arc segments smoothly connected. Their geometric parameters include not only the center position, length and width dimensions, and spatial orientation, but also parameters such as the four rounded corner radii, the center of the arc, and the tangent point of the straight line and the arc.
[0003] Traditional methods for measuring rounded rectangles in 3D point clouds typically involve first extracting boundary points, then determining the overall orientation and dimensions using principal component analysis or bounding box methods, and finally estimating the rounded radius near the corner points. While this approach is simple, it suffers from the following drawbacks: First, a 2D bounding box can only describe the overall envelope of the rounded rectangle, making it difficult to distinguish between straight line segments and arc segments. Second, rounded corner regions are usually smoothly connected to adjacent straight line segments, and point clouds at the line-arc junctions are prone to overlap. If a fixed threshold is used to directly divide the rounded corner region, it's easy to mistakenly include end points, burrs, or noise points of straight line segments into the arc segment point set. Third, if the average distance from the arc segment point to the theoretical sharp corner point is directly used as the rounded radius, this distance is not equivalent to the true radius of the arc, easily leading to systematic errors. Fourth, existing methods often involve step-by-step calculations, lacking overall constraints between straight line segments, arc segments, tangent points, and parallel orthogonal relationships, resulting in insufficient consistency among the fitted parameters.
[0004] Therefore, there is an urgent need for a method that, based on the existing point cloud preprocessing, mesh reconstruction, boundary extraction, and planar projection process, further addresses the mixed geometric features of rounded rectangles by performing line-arc separation, adaptive determination of rounded regions, and fitting of circular arc tangent constraints, in order to improve the completeness, accuracy, and robustness of rounded rectangle parameter extraction. Summary of the Invention
[0005] To address the problems existing in the prior art, this invention proposes a rounded rectangle fitting method based on 3D point clouds. This method improves upon the traditional rounded rectangle fitting process by explicitly modeling the rounded rectangle as a combination of "four supporting straight lines + four circular arcs + eight tangent points," instead of simply treating it as a two-dimensional bounding box with four rounded corner regions. Through ordered contour construction and local curvature and tangential continuity analysis, the boundary points are automatically separated into straight line segment point sets, circular arc segment point sets, and line-arc transition overlap points. Then, adjacent supporting straight lines are used to apply tangent constraints to the center and radius of the circular arcs, avoiding radius errors caused by directly calculating the average distance between rounded corner region points. This further filters out straight line segment points and circular arc segment points from the candidate points. Finally, through overall parameter joint optimization, the straight line segments, circular arc segments, tangent points, parallel constraints, and orthogonal constraints are kept consistent. This invention aims to solve the problems of difficult-to-distinguish mixed point clouds caused by the smooth connection of straight line segments and arc segments in rounded rectangles, unstable division of rounded corner regions, and large influence of noise and burrs on radius estimation, thereby improving the completeness, accuracy and robustness of feature parameter extraction of rounded rectangles.
[0006] To achieve the above-mentioned technical objectives, the present invention provides the following technical solution:
[0007] A method for fitting rounded rectangles based on 3D point clouds, specifically including:
[0008] Obtain point cloud data containing the target rounded rectangle; preprocess and triangulate the point cloud data to obtain a triangular mesh model;
[0009] The number of times a mesh edge is shared by triangles in a triangular mesh model is counted to identify the boundary edges; a depth-first search algorithm is used to connect the boundary edges to form a closed boundary loop; the outer and inner boundaries are distinguished based on the length, area, or number of vertices of the boundary loop, and the inner boundary point cloud of the target rounded rectangle is extracted.
[0010] The inner boundary point cloud is projected onto the fitting plane to obtain a two-dimensional projected boundary point set; according to the topological order of the boundary ring, the discrete two-dimensional boundary projection points are organized into a two-dimensional ordered contour point sequence, and the geometric features of each ordered contour point are calculated.
[0011] Based on geometric features, the two-dimensional ordered contour point sequence is initially divided into candidate points for line segments, candidate points for arc segments, and overlapping points for line-arc transitions; overlapping points for line-arc transitions are removed or assigned low fitting weights.
[0012] Robust fitting of supporting straight lines is performed on the candidate point set of straight line segments. Based on the intersection points, side directions, and candidate points of arc segments of adjacent supporting straight lines, the rounded corner region of the target rounded rectangle is determined.
[0013] For each rounded corner region, establish an arc fitting model under the constraint of the tangent of the adjacent supporting straight line, and calculate the center of the rounded corner, the radius of the rounded corner, and the tangent point respectively; determine the position and size of the arc based on the center of the rounded corner and the radius of the rounded corner, and determine the direction and angle range of the arc based on the topological order of the tangent point and the two-dimensional ordered contour point sequence.
[0014] Subsequently, candidate points are screened based on the robust fitting residuals of the supporting straight lines and the consistency of the arcs, resulting in a set of point segments for straight lines and a set of point segments for arcs. Then, based on the supporting straight lines, arcs, set of point segments for straight lines, set of point segments for arcs, parallel orthogonal constraints, and tangent constraints, the overall parameters of the rounded rectangle are jointly optimized.
[0015] The optimized rounded rectangle's overall parameters are back-projected into three-dimensional space, outputting the center point coordinates, length and width dimensions, spatial normal vector, corner radius, arc center, tangent point, and fitting residual, thus completing the fitting of the target rounded rectangle.
[0016] Furthermore, the preprocessing and triangulation of the point cloud data to obtain the triangular mesh model specifically involves:
[0017] The point cloud data is sequentially denoised, downsampled, and normal estimated to obtain point cloud data containing normal vectors. The point cloud data containing normal vectors is then used to generate triangular meshes using a greedy projection triangulation method. Mesh parameter constraints are set, including search radius, number of nearest neighbors, triangular facet angle, and smoothing coefficient.
[0018] Furthermore, the step of projecting the inner boundary point cloud onto the fitting plane to obtain a two-dimensional projected boundary point set specifically involves:
[0019] Random sampling and consistency plane fitting are performed on the inner boundary point cloud to obtain the fitted plane. ; Calculate the distance from each inner boundary point to the fitting plane, and take the inner boundary points whose distance is less than the preset threshold as points in the plane. Project them onto the fitting plane along the normal vector direction of the fitting plane to obtain the three-dimensional projection points.
[0020] A two-dimensional local coordinate system is established in the fitting plane, and principal component analysis is used to obtain the principal and secondary directions. Based on the two-dimensional local coordinate system, the three-dimensional projection points are transformed to two dimensions to obtain the two-dimensional projection boundary points. All three-dimensional projection points are traversed and transformed to obtain the set of two-dimensional projection boundary points.
[0021] Furthermore, the geometric features of the ordered contour points specifically include: local tangent vector, local curvature, linearity, and arc consistency.
[0022] Furthermore, the specific steps of dividing the two-dimensional ordered contour point sequence into a set of straight line segments, a set of circular arc segments, and overlapping points where lines and arcs connect, based on geometric features, are as follows:
[0023] For any ordered contour point :
[0024] If its local curvature Below the first threshold, and its linearity If it exceeds the second threshold, then It was determined to be a candidate point for the line segment;
[0025] If its local curvature Located within the curvature range of the circular arc, the local tangent vector direction changes continuously, and its circular arc consistency is consistent. If it exceeds the third threshold, then It was determined to be a candidate point for the arc segment;
[0026] like If it is a point of abrupt change in curvature, a point of abrupt change in direction, or a point of residual instability, then... It was determined to be a point of overlap between line and arc transitions.
[0027] Furthermore, the robust fitting of the support lines to the candidate point set of line segments, and the determination of the rounded corner region of the target rounded rectangle based on the intersection points, side directions, and candidate points of the arc segments of adjacent support lines, specifically involves:
[0028] The candidate points of the line segments are divided into four groups according to the main direction and the secondary direction, corresponding to the top, bottom, left and right line segments of the rounded rectangle. For each group of candidate points of the line segments, the random sampling consensus algorithm or the weighted least squares method is used to fit the supporting line. The distance residual from each candidate point of the line segment to the supporting line is calculated. Parallel constraints are applied to the top and bottom supporting lines and the left and right supporting lines respectively.
[0029] After obtaining four supporting lines, the intersection of two adjacent supporting lines is calculated to obtain four theoretical sharp corner points. Four local coordinate systems for rounded corners are established with the theoretical sharp corner points as the origin and the directions of the two adjacent supporting lines as the local coordinate axes. In each local coordinate system for rounded corners, the distance from the candidate point of the arc segment to the two adjacent supporting lines, the projection range to the theoretical sharp corner point, the local curvature response, and the consistency of the arc are comprehensively considered to adaptively select points in the rounded corner region.
[0030] Furthermore, the adaptive selection of rounded corner points by comprehensively considering the distance from the candidate point of the arc segment to the two adjacent supporting lines, the projection range to the theoretical sharp corner point, the local curvature response, and the consistency of the arc is specifically as follows:
[0031] For each candidate point of the arc segment, calculate its distance to the two adjacent supporting lines, its projected coordinates in the local coordinate system of the fillet, its local curvature response, and its arc consistency;
[0032] The projection range between the candidate arc point and the theoretical sharp corner point is calculated based on the projection coordinates, and points exceeding the projection range threshold are eliminated; points whose distance to two adjacent support lines is within the distance threshold are retained, and burr points and noise points are eliminated based on the local curvature response and arc consistency to obtain the rounded corner area points; the projection range threshold and distance threshold are dynamically determined based on the average spacing of boundary points, the spacing of support lines and the initial value of the candidate arc radius.
[0033] Furthermore, the step of establishing an arc fitting model under the constraint of adjacent supporting straight line tangents for each rounded corner region, and calculating the center of the rounded corner, the radius of the rounded corner, and the tangent point respectively, specifically involves:
[0034] Let the two adjacent supporting lines corresponding to a certain rounded corner region be... and The center of the rounded corner is The radius of the fillet is ;
[0035] Calculate the center of the fillet to the first support line distance Rounded corners and center To the second support line distance , rounded corner area To the center of the rounded corner Radial residuals and tangential continuous residuals of the circular arc ;
[0036] Construct robust loss including radial residuals of circular arcs and, and The squared error and Robust objective function for squared error and continuous residuals; minimizing the robust objective function to determine the center of the fillet. and fillet radius Then, determine the point of tangency between the line and the arc based on the foot of the perpendicular from the center of the fillet to the adjacent supporting line, thus obtaining the center of the fillet, the radius of the fillet, and the point of tangency.
[0037] Furthermore, the joint optimization of the overall parameters of the rounded rectangle based on the supporting straight line, arc, point set of straight line segments, point set of arc segments, parallel orthogonal constraints, and tangency constraints specifically involves:
[0038] Based on the supporting lines, the center of the rounded corners, the radius of the rounded corners, and the tangent points, construct a parametric model of a rounded rectangle consisting of four supporting lines, four arcs, four center of the rounded corners, four radii of the rounded corners, and eight tangent points.
[0039] Minimize the distance residual from the point on the straight line segment to the corresponding supporting straight line. Radial residual of the arc segment from the corresponding arc point Tangential residuals between adjacent support lines and circular arcs Parallel residuals of top and bottom edges Parallel residuals on both sides and orthogonal residuals in length and width directions To optimize the objective, weighted least squares or robust nonlinear optimization methods are used to solve for the coordinates of the center point, length and width of the rounded rectangle, the principal direction, secondary direction, normal vector, and radius of the fitted plane.
[0040] Furthermore, this application also discloses a rounded rectangle fitting method system based on 3D point clouds, which is used to perform the method described above, and specifically includes:
[0041] The point cloud input module is used for reading, storing, and inputting target areas of 3D point cloud data.
[0042] The mesh generation module is used for point cloud normal estimation and triangulation.
[0043] The boundary extraction module is used for boundary edge identification, boundary loop construction, and inner and outer boundary classification.
[0044] The plane fitting module is used for plane fitting, 2D projection, and local coordinate system establishment of the inner boundary point cloud;
[0045] The line-arc separation module is used to classify boundary points into candidate points for straight line segments, candidate points for circular arc segments, and transition overlap points based on local curvature, tangential direction change, linearity, and circular arc consistency.
[0046] The parameter calculation module supports line fitting, adaptive division of rounded corner regions, tangent-constrained arc fitting, arc interval determination, overall parameter joint optimization, and three-dimensional parameter output.
[0047] Based on the above technical solution, the present invention has at least the following beneficial effects:
[0048] 1. Based on the original boundary extraction and planar projection process, this invention adds an ordered contour construction and line-arc separation step. It can first automatically divide the boundary points of rounded rectangles into candidate points of straight line segments, candidate points of circular arc segments, and transitional overlapping points, and then further refine and filter out the straight line segment points and circular arc segment points; thus solving the problem of difficulty in distinguishing mixed point clouds caused by smooth connection between straight line segments and circular arc segments.
[0049] 2. This invention adopts an adaptive method for dividing the rounded corner region based on adjacent supporting straight lines, rather than using a fixed threshold to extract the rounded corner region, which can effectively avoid the mistaken participation of the end points, noise points, and burr points of straight line segments in the rounded corner radius calculation;
[0050] 3. This invention uses the adjacent straight line tangent constraint arc fitting method to calculate the fillet radius, so that the distance from the center of the circle to the two adjacent supporting straight lines is equal to the fillet radius. At the same time, it constrains the arc radial residual from the arc segment point to the center of the circle, thus geometrically ensuring the correctness of the radius calculation.
[0051] 4. This invention reduces the impact of outliers, missing point clouds, and non-uniform sampling on the radius of rounded corners by using a robust loss function and a transition aliasing point weighting mechanism, thereby improving detection accuracy and stability;
[0052] 5. This invention optimizes overall parameters and simultaneously outputs the center point, length and width dimensions, spatial orientation, four corner radii, center point, tangent point, and fitting residual. The parameter output is more complete and suitable for industrial inspection, reverse modeling, and automated quality evaluation. Attached Figure Description
[0053] Figure 1 This is a flowchart of a rounded rectangle fitting method based on three-dimensional point clouds proposed in this invention;
[0054] Figure 2 This is a schematic diagram of the module composition of an application system for a rounded rectangle fitting method based on three-dimensional point clouds proposed in this invention. Detailed Implementation
[0055] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. This will allow for a full understanding of how technical means are applied to solve technical problems and achieve technical effects, and to facilitate implementation of the present application.
[0056] Those skilled in the art will understand that all or part of the steps in the methods of the following embodiments can be implemented by a program instructing related hardware. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0057] This application discloses a rounded rectangle fitting method system based on 3D point clouds. This system is used to execute the method described above, and specifically includes:
[0058] The point cloud input module is used for reading, storing, and inputting target areas of 3D point cloud data.
[0059] The mesh generation module is used for point cloud normal estimation and triangulation.
[0060] The boundary extraction module is used for boundary edge identification, boundary loop construction, and inner and outer boundary classification.
[0061] The plane fitting module is used for plane fitting, 2D projection, and local coordinate system establishment of the inner boundary point cloud;
[0062] The line-arc separation module is used to classify boundary points into candidate points for straight line segments, candidate points for circular arc segments, and transition overlap points based on local curvature, tangential direction change, linearity, and circular arc consistency.
[0063] The parameter calculation module supports line fitting, adaptive division of rounded corner regions, tangent-constrained arc fitting, arc interval determination, overall parameter joint optimization, and three-dimensional parameter output.
[0064] The specific process of the method proposed in this invention is as follows: Figure 1 As shown, it specifically includes:
[0065] S1. Obtain point cloud data containing the target rounded rectangle; preprocess and triangulate the point cloud data to obtain a triangular mesh model;
[0066] In a preferred embodiment, step S1 specifically comprises:
[0067] The region containing the rounded rectangle of the target is manually extracted from the point cloud to obtain point cloud data containing the rounded rectangle of the target. The point cloud input module reads the 3D point cloud file in PCD, PLY or other formats to obtain the 3D point coordinate information of the target object surface. Then, in order to reduce the impact of noise and redundant points on subsequent processing, the point cloud data is denoised and downsampled in sequence.
[0068] Next, normal estimation is performed, searching for the normal vector for each point in the point cloud. Given a neighborhood of points, calculate the centroid and local covariance matrix of those neighborhood points; let the points be... The neighborhood of The centroid of the neighborhood point is Then the local covariance matrix can be expressed as:
[0069] ;
[0070] in, for , neighborhood points;
[0071] The eigenvector corresponding to the smallest eigenvalue of the local covariance matrix is taken as the local normal vector of that point, i.e.:
[0072] ;
[0073] in, This represents the operation of taking the eigenvector corresponding to the minimum eigenvalue; thus, point cloud data containing normal vectors is obtained. In order to ensure the stability of triangular mesh reconstruction, viewpoint consistency or adjacency propagation can be used to unify the direction of normal vectors.
[0074] A greedy projection triangulation method is used to generate triangular meshes from point cloud data containing normal vectors. This algorithm transforms disordered point clouds into triangular mesh models with topological relationships through local projection and neighborhood connectivity. Mesh parameter constraints, including search radius, number of nearest neighbors, triangular facet angles, and smoothing coefficients, are set to avoid boundary errors caused by over-connection or under-connection.
[0075] S2. Count the number of times the mesh edge is shared by triangles in the triangular mesh model to identify the boundary edge; use the depth-first search algorithm to connect the boundary edge to form a closed boundary loop; distinguish the outer boundary and the inner boundary according to the length, area or number of vertices of the boundary loop (in this embodiment, the boundary loop with the largest length or area is the outer boundary loop, and the rest are the inner boundary loops), and extract the inner boundary point cloud of the target rounded rectangle as the subsequent fitting object.
[0076] S3. Project the inner boundary point cloud onto the fitting plane to obtain a two-dimensional projected boundary point set;
[0077] In this preferred embodiment, the specific process for obtaining the two-dimensional projected boundary point set is as follows:
[0078] Random sampling and consistency plane fitting are performed on the inner boundary point cloud to obtain the fitted plane. Fitting plane Satisfies the plane equation:
[0079] ;
[0080] Where n=(a,b,c) represents the normal vector of the fitted plane, d is the bias term of the plane equation, and p is any point on the plane.
[0081] Calculate each inner boundary point (The inner boundary points are essentially points in the point cloud, so they are also used here.) Distance to the fitted plane The formula is expressed as:
[0082] ;
[0083] Points on the inner boundary that are less than a preset threshold are taken as points in the plane and projected onto the fitting plane along the normal vector direction of the fitting plane to obtain the three-dimensional projection points. It is represented as:
[0084] ;
[0085] Establish a two-dimensional local coordinate system within the fitting plane and take the centroid of the three-dimensional projection point. Using the origin as the coordinate system, principal component analysis is used to obtain the principal directions. and secondary direction Based on the two-dimensional local coordinate system, the three-dimensional projection points are transformed into two dimensions to obtain the two-dimensional projection boundary points. x-axis y-axis The process involves iterating through all three-dimensional projection points and transforming them to obtain a set of two-dimensional projection boundary points. This transforms the problem of fitting rounded rectangles in three-dimensional space into a parametric modeling problem in a two-dimensional plane.
[0086] Based on the topological order of the boundary ring, the discrete two-dimensional boundary projection points are organized into a two-dimensional ordered contour point sequence, and the geometric features of each ordered contour point are calculated.
[0087] In a preferred embodiment, the geometric features of the ordered contour points specifically include: local tangent vector, local curvature, linearity, and arc consistency. The specific calculation process is as follows:
[0088] Let ordered contour points be Its neighboring points are and Where s is the length of the local neighborhood half-window, indicating that when calculating the tangent vector, s ordered contour points are selected forward and backward respectively, so that the local tangent vector can be calculated. for:
[0089] ;
[0090] Calculate local curvature based on the change in the direction of adjacent tangent vectors. :
[0091] ;
[0092] Simultaneously, linearity is calculated within the local neighborhood. Consistency with arcs This embodiment uses neighborhood covariance eigenvalues. and Linearity is defined by the formula:
[0093] ;
[0094] Arc consistency can be defined based on the radius fluctuation from neighboring points to the locally fitted circle:
[0095] ;
[0096] in, The standard deviation of the distance from the local neighborhood points to the center of the fitted circle is given. The average radius, To prevent the use of tiny constants with a denominator of zero, in this embodiment, linearity is used to determine whether neighboring points are close to a straight line distribution, and arc consistency is used to determine whether neighboring points are close to the same arc.
[0097] S4. Based on geometric features, the two-dimensional ordered contour point sequence is initially divided into candidate points for line segments, candidate points for arc segments, and overlapping points for line-arc transitions; overlapping points for line-arc transitions are removed or given low fitting weights.
[0098] In a preferred embodiment, step S4 specifically comprises:
[0099] The specific steps for dividing the two-dimensional ordered contour point sequence into a set of straight line segments, a set of circular arc segments, and overlapping points where lines and arcs connect are as follows:
[0100] For any ordered contour point :
[0101] If its local curvature Below the first threshold, and its linearity If it exceeds the second threshold, then It was determined to be a candidate point for the line segment;
[0102] If its local curvature Located within the curvature range of the circular arc, the local tangent vector direction changes continuously, and its circular arc consistency is consistent. If it exceeds the third threshold, then It was determined to be a candidate point for the arc segment;
[0103] like If it is a point of abrupt change in curvature, a point of abrupt change in direction, or a point of residual instability, then... Points identified as overlapping transitions between lines and arcs are removed or have their weights reduced in subsequent fitting processes.
[0104] S5. Perform robust fitting of the supporting straight lines on the candidate point set of the straight line segment. Based on the intersection of adjacent supporting straight lines, the side direction, and the candidate points of the arc segment, determine the rounded corner area of the target rounded rectangle.
[0105] In a preferred embodiment, step S5 specifically comprises:
[0106] The candidate points of the line segments are divided into four groups according to the main and secondary directions, corresponding to the top, bottom, left, and right line segments of the rounded rectangle, respectively. For each group of candidate points, a random sampling consensus algorithm or weighted least squares method is used to fit a supporting line. Let the supporting line... The general form of the equation is:
[0107] ;
[0108] in, , , Provide parameters for the general equation; calculate candidate points for each line segment. Distance residual to the support line The formula is expressed as:
[0109] ;
[0110] Parallel constraints are applied to the upper and lower support lines, as well as the left and right support lines, thereby improving the consistency of the support line fitting.
[0111] After obtaining four supporting straight lines, the intersection points of two adjacent supporting straight lines are calculated to obtain four theoretical sharp corner points. Using the theoretical sharp corner points as the origin and the directions of the two adjacent supporting straight lines as local coordinate axes, four local coordinate systems for rounded corners are established. In each local coordinate system for rounded corners, the distance from the candidate point of the arc segment to the two adjacent supporting straight lines, the projection range to the theoretical sharp corner point, the local curvature response, and the consistency of the arc are comprehensively considered to adaptively select rounded corner region points. As a preferred embodiment, in this example, the specific process of adaptively selecting rounded corner region points is as follows:
[0112] The adaptive selection of rounded corner points, taking into account the distance from the candidate point of the arc segment to the two adjacent supporting lines, the projection range to the theoretical sharp corner point, the local curvature response, and the consistency of the arc, is specifically as follows:
[0113] For each candidate point of the arc segment, calculate its distance to the two adjacent supporting lines, its projected coordinates in the local coordinate system of the fillet, its local curvature response, and its arc consistency;
[0114] The projection range between the candidate arc point and the theoretical sharp corner point is calculated based on the projection coordinates, and points exceeding the projection range threshold are eliminated; points whose distance to two adjacent support lines is within the distance threshold are retained, and burr points and noise points are eliminated based on local curvature response and arc consistency to obtain rounded corner area points; the projection range threshold and distance threshold are dynamically determined based on the average spacing of boundary points, the spacing of support lines and the radius of candidate arcs, thereby achieving adaptive filtering relative to a fixed length threshold.
[0115] Unlike using a fixed threshold to extract a set of corner points, this method utilizes the geometric relationship and curvature characteristics of the supporting straight lines to determine the rounded corner region. This avoids mistakenly including the end points of straight line segments, burr points, or overlapping points of line-arc connections in the radius calculation.
[0116] S6. Establish an arc fitting model under the constraint of adjacent supporting straight line tangent for each rounded corner region, and calculate the center of the rounded corner, the radius of the rounded corner, and the tangent point respectively; determine the position and size of the arc according to the center of the rounded corner and the radius of the rounded corner, and determine the arc direction and arc angle range according to the topological order of the tangent point and the two-dimensional ordered contour point sequence.
[0117] As a preferred embodiment, the specific process for obtaining the center of the fillet, the radius of the fillet, and the point of tangency is as follows:
[0118] Let the two adjacent supporting lines corresponding to a certain rounded corner region be... and The center of the rounded corner is The radius of the fillet is ;
[0119] Calculate the center of the fillet to the first support line distance Rounded corners and center To the second support line distance , rounded corner area To the center of the rounded corner Radial residuals and tangential continuous residuals of the circular arc ;
[0120] Construct robust loss including radial residuals of circular arcs and, and The squared error and The robust objective function for the squared error and continuous residuals; the robust objective function, on the one hand, constrains the arc segment points within the rounded corner region. To the center of the rounded corner The distance should be close to the radius of the fillet. On the other hand, it constrains the center of the rounded corner. to the first support line Second support line The distances are equal and close to the radius of the rounded corners. Its formula is expressed as:
[0121] ;
[0122] in, For the first The set of arc segment points in each rounded corner region For robust loss function, , , The weighting coefficients are used to constrain the center position and radius of the circle by using two adjacent supporting straight lines, thus avoiding the geometric deviation caused by directly calculating the average distance from the arc segment point to the theoretical sharp corner point.
[0123] Minimize the robust objective function to determine the center of the rounded corner. and fillet radius Then, determine the point of tangency between the line and the arc based on the foot of the perpendicular from the center of the fillet to the adjacent supporting line, thus obtaining the center of the fillet, the radius of the fillet, and the point of tangency.
[0124] S7. Subsequently, candidate points are screened based on the robust fitting residuals of the supporting straight lines and the consistency of the arcs to obtain the set of straight line segments and the set of arc segments (i.e., after the robust fitting of the supporting straight lines in step S5 and the arc fitting in step S6, the candidate points are finely screened based on the fitted supporting straight lines and arcs to obtain the straight line segments and arc segments used for the final joint optimization); then, the overall parameters of the rounded rectangle are jointly optimized based on the supporting straight lines, arcs, the set of straight line segments, the set of arc segments, parallel orthogonal constraints, and tangent constraints.
[0125] As a preferred embodiment, the specific process of joint optimization of the overall parameters of the rounded rectangle in this embodiment is as follows:
[0126] Based on the supporting lines, the center of the rounded corners, the radius of the rounded corners, and the tangent points, construct a parametric model of a rounded rectangle consisting of four supporting lines, four arcs, four center of the rounded corners, four radii of the rounded corners, and eight tangent points.
[0127] Minimize the distance residual from the point on the straight line segment to the corresponding supporting straight line. Radial residual of the arc segment from the corresponding arc point Tangential residuals between adjacent support lines and circular arcs Parallel residuals of top and bottom edges Parallel residuals on both sides and orthogonal residuals in length and width directions To optimize the objective, the formula for optimizing the objective is expressed as:
[0128] ;
[0129] in, Here is the set of parameters for the rounded rectangle to be optimized. , , , and Weights for each item;
[0130] Weighted least squares or robust nonlinear optimization methods are used to improve the consistency between different geometric elements, and finally the center point of the rounded rectangle is solved. Length and width dimensions Optimize the principal directions of the fitting plane Secondary direction Normal vector And the radius of the rounded corners.
[0131] S8. Backproject the overall parameters of the optimized rounded rectangle to three-dimensional space, and output the coordinates of the center point, length and width, spatial normal vector, rounded corner radius, arc center, tangent point and fitting residual of the rounded rectangle to complete the fitting of the target rounded rectangle.
[0132] In summary, this invention proposes a method for fitting rounded rectangles based on 3D point clouds. This method is applicable to applications requiring parameterized extraction of rounded rectangle features, such as industrial part inspection, reverse engineering, hole and groove feature measurement, assembly surface recognition, and automated quality inspection. The proposed method effectively solves the problems of indistinguishable mixed point clouds caused by smooth connections between straight and curved segments in rounded rectangles, unstable rounded corner region segmentation, and radius estimation significantly affected by noise and burrs, thus improving the completeness, accuracy, and robustness of rounded rectangle feature parameter extraction.
[0133] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0134] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A method for fitting rounded rectangles based on 3D point clouds, characterized in that, Specifically, the following steps are included: Obtain point cloud data containing the target rounded rectangle; preprocess and triangulate the point cloud data to obtain a triangular mesh model; The number of times a mesh edge is shared by triangles in a triangular mesh model is counted to identify boundary edges; a depth-first search algorithm is used to connect the boundary edges to form a closed boundary loop; the outer and inner boundaries are distinguished based on the length, area, or number of vertices of the boundary loop, and the inner boundary point cloud of the target rounded rectangle is extracted. The inner boundary point cloud is projected onto the fitting plane to obtain a two-dimensional projected boundary point set; according to the topological order of the boundary ring, the discrete two-dimensional boundary projection points are organized into a two-dimensional ordered contour point sequence, and the geometric features of each ordered contour point are calculated. Based on geometric features, the two-dimensional ordered contour point sequence is initially divided into candidate points for line segments, candidate points for arc segments, and overlapping points for line-arc transitions; overlapping points for line-arc transitions are removed or assigned low fitting weights. Robust fitting of supporting straight lines is performed on the candidate point set of straight line segments. Based on the intersection points, side directions, and candidate points of arc segments of adjacent supporting straight lines, the rounded corner region of the target rounded rectangle is determined. For each rounded corner region, establish an arc fitting model under the constraint of the tangent of the adjacent supporting straight line, and calculate the center of the rounded corner, the radius of the rounded corner, and the tangent point respectively; determine the position and size of the arc based on the center of the rounded corner and the radius of the rounded corner, and determine the direction and angle range of the arc based on the topological order of the tangent point and the two-dimensional ordered contour point sequence. Subsequently, candidate points are screened based on the robust fitting residuals of the supporting straight lines and the consistency of the arcs, resulting in a set of point segments for straight lines and a set of point segments for arcs. Then, based on the supporting straight lines, arcs, set of point segments for straight lines, set of point segments for arcs, parallel orthogonal constraints, and tangent constraints, the overall parameters of the rounded rectangle are jointly optimized. The optimized rounded rectangle's overall parameters are back-projected into three-dimensional space, outputting the center point coordinates, length and width dimensions, spatial normal vector, corner radius, arc center, tangent point, and fitting residual, thus completing the fitting of the target rounded rectangle.
2. The rounded rectangle fitting method based on three-dimensional point clouds according to claim 1, characterized in that, The preprocessing and triangulation of the point cloud data to obtain the triangular mesh model are specifically as follows: The point cloud data is sequentially denoised, downsampled, and normal estimated to obtain point cloud data containing normal vectors. The point cloud data containing normal vectors is then used to generate triangular meshes using a greedy projection triangulation method. Mesh parameter constraints are set, including search radius, number of nearest neighbors, triangular facet angle, and smoothing coefficient.
3. The rounded rectangle fitting method based on three-dimensional point clouds according to claim 1, characterized in that, The specific steps of projecting the inner boundary point cloud onto the fitting plane to obtain the two-dimensional projected boundary point set are as follows: Random sampling and consistency plane fitting are performed on the inner boundary point cloud to obtain the fitted plane. ; Calculate the distance from each inner boundary point to the fitting plane, and take the inner boundary points whose distance is less than a preset threshold as points in the plane. Project them onto the fitting plane along the normal vector direction of the fitting plane to obtain the three-dimensional projection points. A two-dimensional local coordinate system is established in the fitting plane, and principal component analysis is used to obtain the principal and secondary directions. Based on the two-dimensional local coordinate system, the three-dimensional projection points are transformed to two dimensions to obtain the two-dimensional projection boundary points. All three-dimensional projection points are traversed and transformed to obtain the set of two-dimensional projection boundary points.
4. The rounded rectangle fitting method based on three-dimensional point clouds according to claim 1, characterized in that, The geometric features of the ordered contour points specifically include: local tangent vector, local curvature, linearity, and arc consistency.
5. The rounded rectangle fitting method based on three-dimensional point clouds according to claim 4, characterized in that, The preliminary division of the two-dimensional ordered contour point sequence into candidate points for straight line segments, candidate points for circular arc segments, and overlapping points for line-arc transitions based on geometric features is as follows: For any ordered contour point : If its local curvature Below the first threshold, and its linearity If it exceeds the second threshold, then It was determined to be a candidate point for the line segment; If its local curvature Located within the curvature range of the circular arc, the local tangent vector direction changes continuously, and its circular arc consistency is consistent. If it exceeds the third threshold, then It was determined to be a candidate point for the arc segment; like If it is a point of abrupt change in curvature, a point of abrupt change in direction, or a point of residual instability, then... It was determined to be a point of overlap between line and arc transitions.
6. The rounded rectangle fitting method based on three-dimensional point clouds according to claim 1, characterized in that, The process of robustly fitting the candidate point set of line segments to support the lines, and determining the rounded corner region of the target rounded rectangle based on the intersection points, side directions, and candidate points of the arc segments of adjacent supporting lines, specifically involves: The candidate points of the line segments are divided into four groups according to the main direction and the secondary direction, corresponding to the top, bottom, left and right line segments of the rounded rectangle. For each group of candidate points of the line segments, the random sampling consensus algorithm or the weighted least squares method is used to fit the supporting line. The distance residual from each candidate point of the line segment to the supporting line is calculated. Parallel constraints are applied to the top and bottom supporting lines and the left and right supporting lines respectively. After obtaining four supporting lines, the intersection of two adjacent supporting lines is calculated to obtain four theoretical sharp corner points. Four local coordinate systems for rounded corners are established with the theoretical sharp corner points as the origin and the directions of the two adjacent supporting lines as the local coordinate axes. In each local coordinate system for rounded corners, the distance from the candidate point of the arc segment to the two adjacent supporting lines, the projection range to the theoretical sharp corner point, the local curvature response, and the consistency of the arc are comprehensively considered to adaptively select points in the rounded corner region.
7. The rounded rectangle fitting method based on three-dimensional point clouds according to claim 6, characterized in that, The adaptive selection of rounded corner points, taking into account the distance from the candidate point of the arc segment to the two adjacent supporting lines, the projection range to the theoretical sharp corner point, the local curvature response, and the consistency of the arc, is specifically as follows: For each candidate point of the arc segment, calculate its distance to the two adjacent supporting lines, its projected coordinates in the local coordinate system of the fillet, its local curvature response, and its arc consistency; The projection range between the candidate arc point and the theoretical sharp corner point is calculated based on the projection coordinates, and points exceeding the projection range threshold are eliminated; points whose distance to two adjacent support lines is within the distance threshold are retained, and burr points and noise points are eliminated based on local curvature response and arc consistency to obtain rounded corner area points; the projection range threshold and distance threshold are dynamically determined based on the average spacing of boundary points, the spacing of support lines and the radius of the candidate arc.
8. The rounded rectangle fitting method based on three-dimensional point clouds according to claim 1, characterized in that, The step of establishing an arc fitting model for each rounded corner region under the constraint of adjacent supporting straight line tangents, and calculating the center of the rounded corner, the radius of the rounded corner, and the tangent point are as follows: Let the two adjacent supporting lines corresponding to a certain rounded corner region be... and The center of the rounded corner is The radius of the fillet is ; Calculate the center of the fillet to the first support line distance Rounded corners and center To the second support line distance , rounded corner area To the center of the rounded corner The radial residual of the circular arc and the tangential residual between the circular arcs ; Construct robust loss including radial residuals of circular arcs and, and The squared error and Robust objective functions for squared error and tangent residual; minimizing the robust objective function to determine the center of the fillet. and fillet radius Then, determine the tangent point of the line-circle arc based on the foot of the perpendicular from the center of the fillet to the adjacent supporting line, thereby obtaining the center of the fillet, the radius of the fillet, and the tangent point.
9. The rounded rectangle fitting method based on three-dimensional point clouds according to claim 1, characterized in that, The joint optimization of the overall parameters of the rounded rectangle based on the supporting straight line, arc, point set of straight line segment, point set of arc segment, parallel orthogonal constraint, and tangency constraint is specifically as follows: Based on the supporting lines, the center of the rounded corners, the radius of the rounded corners, and the tangent points, construct a parametric model of a rounded rectangle consisting of four supporting lines, four arcs, four center of the rounded corners, four radii of the rounded corners, and eight tangent points. Minimize the distance residual from the point on the straight line segment to the corresponding supporting straight line. Radial residual of the arc segment from the corresponding arc point Tangential residuals between adjacent supporting straight lines and circular arcs Parallel residuals of top and bottom edges Parallel residuals on both sides and orthogonal residuals in length and width directions To optimize the objective, weighted least squares or robust nonlinear optimization methods are used to solve for the coordinates of the center point, length and width of the rounded rectangle, the principal direction, secondary direction, normal vector, and radius of the fitted plane.
10. A system for fitting rounded rectangles based on 3D point clouds, the system being used to execute the method as described in any one of claims 1-9, characterized in that, Specifically, it includes: The point cloud input module is used for reading, storing, and inputting target areas of 3D point cloud data. The mesh generation module is used for point cloud normal estimation and triangulation. The boundary extraction module is used for boundary edge identification, boundary loop construction, and inner and outer boundary classification. The plane fitting module is used for plane fitting, 2D projection, and local coordinate system establishment of the inner boundary point cloud; The line-arc separation module is used to classify boundary points into candidate points for straight line segments, candidate points for circular arc segments, and transition overlap points based on local curvature, tangential direction change, linearity, and circular arc consistency. The parameter calculation module supports line fitting, adaptive division of rounded corner regions, tangent-constrained arc fitting, arc interval determination, overall parameter joint optimization, and three-dimensional parameter output.