Method for directly registering point cloud to STL (Standard Template Library) model

By constructing a KD tree and verifying projection points using the center of gravity coordinate method, combined with the weighted least squares method to calculate the affine transformation matrix, the existing point cloud registration method has solved the problems of strong dependence on initial registration, low computing efficiency and insufficient registration accuracy, and achieved efficient and accurate point cloud and STL model registration.

CN120182335APending Publication Date: 2025-06-20NANJING INST OF TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510096752.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

The existing point cloud registration methods have strong dependence on initial registration, low computing efficiency, and insufficient registration accuracy when processing large-scale point clouds or point cloud data containing noise.

Method used

A method of directly registering point clouds to STL models is adopted. By constructing a KD tree, the nearest neighbor search of the inner points of the triangle face sheet is accelerated, the projection point is checked using the center of gravity coordinate method, the projection point is recalculated to improve the accuracy, and the affine transformation matrix is ​​calculated by the weighted least squares method, and the transformation matrix is ​​iteratively optimized to improve the registration accuracy.

Benefits of technology

The registration accuracy between point cloud and STL model is significantly improved, the dependence on the initial location is reduced, the computing time is reduced, and large-scale point clouds and noisy point clouds can be effectively handled.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120182335A_ABST
    Figure CN120182335A_ABST
Patent Text Reader

Abstract

The invention discloses a method for directly registering a point cloud to an STL (Standard Template Library) model. The method comprises the following steps: reading geometric parameters of the STL model of a casting to be registered; acquiring point cloud data of actual scanning of the casting, and performing downsampling processing on the point cloud data; a unit matrix is initialized as an initial transformation matrix for registration between the point cloud and the STL model, nearest neighbor search is accelerated by constructing a KD tree, and the transformation matrix is gradually optimized by iteratively calculating the distance between the point cloud and the STL model. Through continuous projection and matrix transformation, the algorithm finally outputs a registration matrix from a high-precision point cloud to an STL (Standard Template Library) model. The method has the advantages of being high in calculation efficiency, good in stability and wide in adaptability, a reliable registration solution can be provided in a complex industrial scene, and the method is widely applied to the fields of industrial detection, reverse engineering, 3D printing model calibration and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision and 3D computing, and particularly relates to a method for directly registering point cloud to an STL model. Background Art

[0002] In modern industrial and research fields, the technologies for processing and analyzing 3D point cloud data are becoming increasingly important. Point cloud data usually comes from technologies such as laser scanning, computed tomography (CT), and phase measurement profilometry (PMD), and is widely used in multiple fields such as reverse engineering, autonomous driving, robot navigation, and medical imaging. In these application scenarios, accurately registering the point cloud data with a pre-existing 3D model is a key step for achieving precise measurement, reconstruction, and analysis.

[0003] In existing point cloud registration methods, the most common one is the Iterative Closest Point (ICP) algorithm. The ICP algorithm realizes the registration of point cloud data by repeatedly iterating to minimize the distance between the source point cloud and the target model. However, the ICP algorithm has some inherent limitations. First, the algorithm is highly sensitive to the initial alignment position. If the position of the initial point cloud deviates too far from the target model, the algorithm may not converge to the global optimal solution. Second, the computational complexity of the ICP algorithm is relatively high. Especially when dealing with large-scale point cloud data, the computational time will increase significantly. Finally, when the ICP algorithm searches for corresponding points, it assumes that the point with the closest Euclidean distance is the corresponding point. This assumption is unreasonable and will generate a certain number of incorrect corresponding points.

[0004] In the process of 3D modeling and processing, one of the commonly used file formats is the STL format. The STL model represents complex 3D geometric shapes by approximating the object surface with countless triangular patches. The vertices and normal vectors of each triangle are stored as discrete numerical data, which makes the STL model a widely used standard format in computer graphics, manufacturing, and engineering design.

[0005] In the prior art, the published patent with the publication number CN113658184A discloses a method for segmenting point cloud surfaces guided by an IGES model, which also involves registering the STL model with the point cloud. However, in this solution, first, it is necessary to calculate the plane equation of each triangular patch, and the process is too cumbersome, increasing the computational amount. Second, if the projection point is not within the triangular patch, the invention does not recalculate the projection point, which will reduce the registration accuracy.

[0006] Therefore, it is necessary to improve the existing point cloud registration. The improved method not only needs to improve the computational efficiency, but also needs to make breakthroughs in registration accuracy, stability, and adaptability to complex models. This will provide more reliable technical support for various 3D modeling and analysis applications. Summary of the Invention

[0007] 1. Technical problems to be solved:

[0008] In view of the above technical problems, the present invention provides a method for directly registering a point cloud to an STL model. This method can solve the problems existing in the prior art, such as strong dependence on initial registration, low computational efficiency, and insufficient registration accuracy when dealing with point cloud data containing noise; especially when the point cloud data is large, the model is complex, or the point cloud data contains a lot of noise, it solves the problem that the traditional iterative closest point algorithm and other common registration methods are difficult to achieve the expected effect.

[0009] 2. Technical solutions:

[0010] A method for directly registering a point cloud to an STL model, characterized by comprising:

[0011] Step 1: Use MeshVS_Mesh to read the parameters of the STL model of the casting to be registered; the parameters of the STL model include the number of triangular facets, the number of nodes, the vertex coordinates of each triangular facet, and the edge indices of the STL model; calculate the incenter of each triangular facet and the normal vector of the incenter.

[0012] Step 2: Load the point cloud of the casting obtained by actual scanning, perform denoising and downsampling to obtain the downsampled point cloud.

[0013] Step 3: Initialize a 4×4 identity matrix as the initial transformation matrix between the point cloud and the STL model of the casting to be registered, and set the number of iterations for calculating the transformation matrix between the point cloud and the STL model.

[0014] Step 4: Construct a KD tree capable of performing nearest neighbor search on the incenter coordinates of triangular facets. According to the downsampled point cloud, find the incenter coordinates of all triangular facets in the KD tree to obtain the nearest triangular facets of different point cloud points within a preset specified range.

[0015] Step 5: Determine the projection points of each point in the point cloud to its nearest triangular facet; based on the KD tree, determine the nearest triangular facet corresponding to each point in the point cloud to obtain the preliminary projection point of the point; use the barycentric coordinate method to check whether the preliminary projection point is within its corresponding triangular facet; if the preliminary projection point is not within its corresponding triangular facet, recalculate to obtain the projection point; sort the projection points according to the indices of the downsampled point cloud to obtain a new projected point cloud.

[0016] Step 6: Use the analytical method to calculate the affine transformation matrix from the downsampled point cloud to its corresponding projected point cloud.

[0017] Step 7: Left-multiply the initial transformation matrix by the affine transformation matrix to obtain the iterative matrix. When the number of iterations is reached, the final transformation matrix is obtained, enabling the downsampled point cloud to gradually approximate the STL model and finally converge to complete the iteration.

[0018] Further, Step 1 specifically includes:

[0019] S11: Use the MeshVS_Mesh class in OpenCASCADE to read the three vertices of each triangular facet of the casting to be registered; define the three vertices of the i-th triangular facet as A i (x i1 , y i1 , z i1 ), B i (x i2 , y i2 , z i2 ), C i (x i3 , y i3 , z i3 ), and the corresponding three side lengths are a i , b i , c i ;

[0020] S12: Calculate the incenter I i (x i , y i , z i ) of each triangular facet;

[0021] First, calculate the three side lengths of each triangle as follows:

[0022]

[0023] Then, obtain the incenter I i (x i , y i , z i ) of each triangular facet, as follows:

[0024]

[0025] S13: Calculate the normal vector of each triangular facet;

[0026] First, calculate the two edge vectors of each triangular facet as follows:

[0027]

[0028] Then, the normal vector n i (x in , y in , zin ) is expressed as:

[0029]

[0030] In formula (4), the normal vector x in , y in , z in are respectively:

[0031]

[0032] S14: Normalize the normal vector; First, unitize the normal vector to obtain the modulus length of the corresponding triangular facet normal vector as ||n i ||, then:

[0033]

[0034] Then, define the normalized normal vector as n i,normalized , then the normalization formula is expressed as:

[0035]

[0036] Furthermore, the expression of the initial transformation matrix M0 in step three is:

[0037]

[0038] Furthermore, step five specifically includes:

[0039] S51: Use the KD tree created in step four to input the incenter coordinates of all triangular facets into the KD tree; For each point in the downsampled point cloud, find the incenter point of the triangular facet with the closest distance to it in the KD tree, then this triangular facet is the closest triangular facet to this point;

[0040] S52: Calculate the distance d of each point to the normal line of its closest triangular face k ;

[0041] d k = n normalized (P - I) (9)

[0042] In the above formula, P(x p , y p , z p ) is a point in the point cloud; n normalized is the normal vector of the closest triangular facet of this point cloud;

[0043] S53: Since the projection direction of each point in the casting point cloud is along the direction of the normal vector of the corresponding triangular facet, the projection point of each point in the point cloud is the position where each point in the downsampled point cloud is projected onto the triangular facet along the normal direction of its nearest triangular facet, that is, each point is moved a distance d along the normal direction of its nearest triangular facet. k The preliminary projection point is determined as follows:

[0044] O = P - d k n normalized (10)

[0045] In the above formula, O represents the projection point;

[0046] S54: Based on the preliminary projection points obtained in step S53, the barycentric coordinate method is used to determine whether the preliminary projection points are within the triangular facets; specifically:

[0047] First: The vectors between two of the sides of the triangular facet and the vector from the projection point to any vertex are obtained through the following formula:

[0048]

[0049] In the above formula, v0 represents the vector from the first vertex A to the third vertex C of the triangle; v1 represents the vector from the first vertex A to the second vertex B of the triangle; v2 represents the vector from the projection point O to the first vertex A; where (x i1 , y i1 , z i1 ), (x i2 , y i2 , z i2 ), (x i3 , y i3 , z i3 ) correspond to the coordinates of the first, second, and third vertices A, B, and C of the triangular facet respectively; (x io , y io , z io ) are the coordinates of the projection point O;

[0050] Then, the dot product calculations are performed between the three obtained vectors respectively, as follows:

[0051]

[0052] Finally, the projection position judgment parameters u and v of the preliminary projection point relative to the triangular facet are calculated using the barycentric coordinate method, as follows:

[0053]

[0054] If \(u\geq0\), \(v\geq0\), and \(u + v\lt1\) are all satisfied simultaneously, then the preliminary projection point is located inside the triangular patch, and it is determined that this preliminary projection point is the projection point of this point, and proceed to step S56; if not satisfied, then proceed to step S55 to reconfirm the projection point;

[0055] S55: Reconfirm the projection point;

[0056] Define the vector Then The squared norm \(w\) of

[0057]

[0058] Expanding the above formula gives:

[0059]

[0060] Determine the parameter \(t\), which is a proportionality coefficient and represents the relative position of the projection point to be reconfirmed along the vector direction, that is:

[0061]

[0062] When \(t\lt0\), the projection point \(O\) to be reconfirmed is the point \(A\) of its corresponding triangular patch, take \(O = A\);

[0063] When \(t\gt1\), the projection point \(O\) to be reconfirmed is the point \(B\) of its corresponding triangular patch, take \(O = B\);

[0064] When \(0\leq t\leq1\), the projection point \(O\) to be reconfirmed is on the side \(AB\) of its corresponding triangular patch, take

[0065] S56: Reorder the projection points according to the indices of the downsampled point cloud to obtain the final projected point cloud.

[0066] Furthermore, in step six, the weighted least squares method is used to calculate the affine transformation matrix trans for registering the point cloud to the STL model; specifically, it includes the following steps:

[0067] S61: Preset the weights \(w\) of the downsampled point cloud \(P\); the centroid \(P\) of the downsampled point cloud \(P\) bar is as follows:

[0068]

[0069] In the above formula, \(i\) represents the index of each point cloud and its weight from 1 to \(m\), and \(m\) represents the total number of points in the point cloud set;

[0070] Similarly, for the projected point cloud \(Q\), the centroid \(Q\) of the point cloud \(Q\) bar The calculation formula is:

[0071]

[0072] In the above formula, i represents the index of each point cloud and its weight from 1 to n; n represents the total number of points in the point cloud set;

[0073] S62: Solve the optimal rotation matrix R for registering the point cloud to the STL model;

[0074] First, construct the covariance matrix N between the two;

[0075]

[0076] where P mark = p i - P bar , Q mark = q i - Q bar ; p i represents the i-th point in the downsampled point cloud P, and q i is the i-th point in the target point cloud Q;

[0077] Then, perform the following singular value decomposition on the covariance matrix N:

[0078]

[0079] In the above formula, U represents a 3×3 orthogonal matrix containing the left singular vectors of the covariance matrix; Σ represents a 3×3 diagonal matrix containing the singular values; is a 3×3 orthogonal matrix containing the right singular vectors of the covariance matrix;

[0080] Therefore, the optimal rotation matrix R is as follows:

[0081]

[0082] In the above formula, D is a diagonal matrix whose diagonal elements are The role of this diagonal matrix is to ensure that the determinant of the rotation matrix is positive, that is, to ensure the right-hand rule;

[0083] S63: Determine the translation matrix T of the affine transformation matrix trans as implemented by the following formula:

[0084] T = Q bar - R·P bar (22);

[0085] S64: Further obtain the affine transformation matrix trans between the two as follows:

[0086]

[0087] Further, step seven specifically includes:

[0088] S71: The loop iteration ends, and the final rigid transformation matrix trans is obtained final , as shown in the following formula:

[0089] trans final = M k+1 = L k+1 ·M k (24)

[0090] In the above formula, M k represents the transformation matrix after the Kth iteration, where M0 is a 4*4 identity matrix; L k+1 is the affine transformation matrix obtained in the (k + 1)th iteration.

[0091] Further, in step two, the voxel filtering downsampling method is used to downsample the actually scanned casting point cloud.

[0092] Further, in step seven, at the beginning of the iteration, the number of iterations is preset to 50 times, and the point cloud can be converged to the model to achieve the effect of fine registration in about 50 times.

[0093] 3. Beneficial effects:

[0094] (1) A method for directly registering a point cloud to an STL model disclosed by this method breaks through the harsh requirements of traditional point cloud registration methods for the initial registration accuracy, allows the rough registration stage to effectively tolerate large errors, reduces the dependence on the initial position during registration, and avoids the risk that traditional algorithms are prone to falling into local optimal solutions, thereby significantly improving the registration accuracy between the point cloud and the STL model.

[0095] (2) A method for directly registering a point cloud to an STL model disclosed by this method uses a KD-tree structure to accelerate the nearest neighbor search of the point cloud for triangular patches when calculating projection points, greatly reducing the calculation time, enabling the algorithm to quickly process large-scale point cloud data, and meeting the requirements of real-time applications.

[0096] (3) A method for directly registering a point cloud to an STL model disclosed by this method can effectively cope with noise interference through weighted processing and outlier rejection techniques when calculating the affine transformation matrix trans between the point cloud and the STL model. Therefore, when registering point cloud data with more noise to the STL model, it can still maintain a high registration accuracy. Description of the Drawings

[0097] Figure 1 is the overall flowchart of a method for directly registering a point cloud to an STL model of the present invention;

[0098] Figure 2 The matching effect diagrams of the point cloud and the model at different iteration times during the registration process of the casting to be registered in Specific Embodiment 1;

[0099] Figure 3 The schematic diagram of the STL model of the casting to be registered in Specific Embodiment 2;

[0100] Figure 4 The registration effect diagram of the point cloud and the model realized by using this registration method in Specific Embodiment 2. Specific Embodiments

[0101] The present invention will be specifically described below with reference to the accompanying drawings.

[0102] As shown in the attached Figure 1 figures, a method for directly registering a point cloud to an STL model, characterized by comprising:

[0103] Step 1: Use MeshVS_Mesh to read the parameters of the STL model of the casting to be registered; the parameters of the STL model include the number of triangular patches, the number of nodes, the vertex coordinates of each triangular patch, and the edge index of the STL model; calculate the incenter of each triangular patch and the normal vector of the incenter.

[0104] The STL model is a mesh model composed of multiple triangular patches; each calculated incenter of the triangular patch has its own index, and in the model, according to the index of each point, the position of the triangular patch closest to the actual scanned point cloud after downsampling can be determined; in this method, the final projected point cloud is obtained by reordering the projected points.

[0105] Step 2: Load the point cloud of the actually scanned casting, perform denoising and downsampling to obtain the downsampled point cloud;

[0106] Step 3: Initialize a 4×4 identity matrix as the initial transformation matrix between the point cloud and the STL model of the casting to be registered, and set the number of iterations for calculating the transformation matrix between the point cloud and the STL model.

[0107] Step 4: Construct a KD tree capable of performing nearest neighbor search on the incenter point coordinates of the triangular patches, and according to the sampled point cloud, search for the incenter point coordinates of all triangular patches in the KD tree to obtain the nearest triangular patch of different point cloud points within a preset specified range.

[0108] The KD tree is an efficient spatial data structure suitable for point queries in multi-dimensional spaces. In this solution, it is used to determine the position of the face closest to each point;

[0109] Step 5: Determine the projection points of each point in the point cloud onto its nearest triangular facet; Based on the KD tree, determine the nearest triangular facet for each point in the point cloud to obtain the preliminary projection points of the points; Use the barycentric coordinate method to check whether the preliminary projection points are within their corresponding triangular facets; If the preliminary projection points are not within their corresponding triangular facets, recalculate to obtain the projection points; Sort the projection points according to the indices of the downsampled point cloud to obtain a new projected point cloud.

[0110] Step 6: Use the analytical method to calculate the affine transformation matrix from the downsampled point cloud to its corresponding projected point cloud;

[0111] Step 7: Left-multiply the initial transformation matrix by the affine transformation matrix for iterative matrix. When the number of iterations is reached, obtain the final transformation matrix, making the downsampled point cloud gradually approach the STL model and finally converge to complete the iteration.

[0112] Further, Step 1 specifically includes:

[0113] S11: Use the MeshVS_Mesh class in OpenCASCADE to read the three vertices of each triangular facet of the casting to be registered; Define the three vertices of the i-th triangular facet as A i (x i1 , y i1 , z i1 ), B i (x i2 , y i2 , z i2 ), C i (x i3 , y i3 , z i3 ). The corresponding three side lengths are a i , b i , c i ;

[0114] S12: Calculate the incenter I i (x i , y i , z i ) of each triangular facet;

[0115] First, calculate the three side lengths of each triangle as follows:

[0116]

[0117] Then obtain the incenter I i (x i , y i , z i ) of each triangular facet, as follows:

[0118]

[0119] S13: Calculate the normal vector of each triangular patch;

[0120] First, calculate two edge vectors of each triangular patch As follows:

[0121]

[0122] Then, the normal vector n of each triangular patch i (x in , y in , z in ) is expressed as:

[0123]

[0124] In equation (4), the normal vector x in , y in , z in are respectively:

[0125]

[0126] S14: Normalize the normal vector; First, unitize the normal vector to obtain the modulus length of the normal vector corresponding to the triangular patch as ||n i ||, then:

[0127]

[0128] Then, define the normalized normal vector as n i,normalized , then the normalization formula is expressed as:

[0129]

[0130] Furthermore, the expression of the initial transformation matrix M0 in step three is:

[0131]

[0132] Furthermore, step five specifically includes:

[0133] S51: Use the KD tree created in step four to input the incenter coordinates of all triangular patches into the KD tree; For each point in the downsampled point cloud, find the incenter point of the triangular patch with the closest distance to it in the KD tree, then this triangular patch is the closest triangular patch to this point;

[0134] S52: Calculate the distance d from each point to the normal line of its closest triangular face k ;

[0135] d k = n normalized(P-I) (9)

[0136] In the above formula, P(x p , y p , z p ) is a point in the point cloud; n normalized is the normal vector of the nearest triangular facet of the point cloud;

[0137] S53: Since the projection direction of each point in the casting point cloud is along the direction of the normal vector of the corresponding triangular facet, the projection point of each point in the point cloud is the position where each point in the downsampled point cloud is projected onto the triangular facet along the normal direction of its nearest triangular facet, that is, each point moves a distance of d k along the normal direction of its nearest triangular facet. Then the determination of the preliminary projection point is as follows:

[0138] O = P - d k n normalized (10)

[0139] In the above formula, O represents the projection point;

[0140] S54: Based on the preliminary projection points obtained in step S53, the barycentric coordinate method is used to determine whether the preliminary projection points are within the triangular facets; specifically:

[0141] First: The vectors between two of the sides of the triangular facet and the vector from the projection point to any vertex are obtained through the following formula:

[0142]

[0143] In the above formula, v0 represents the vector from the first vertex A to the third vertex C of the triangle; v1 represents the vector from the first vertex A to the second vertex B of the triangle; v2 represents the vector from the projection point O to the first vertex A; where (x i1 , y i1 , z i1 ), (x i2 , y i2 , z i2 ), (x i3 , y i3 , z i3 ) correspond to the coordinates of the first, second, and third vertices A, B, and C of the triangular facet respectively; (x io , y io , z io ) are the coordinates of the projection point O;

[0144] Then, the dot product calculations are performed respectively between the three obtained vectors, as follows:

[0145]

[0146] Finally, the barycentric coordinate method is used to calculate the projection position judgment parameters u and v of the preliminary projection point relative to the triangular patch, as shown in the following formula:

[0147]

[0148] If u≥0, v≥0, and u + v < 1 are satisfied simultaneously, then the preliminary projection point is located inside the triangular patch, and it is determined that the preliminary projection point is the projection point of this point, and step S56 is entered; if not satisfied, step S55 is entered to reconfirm the projection point;

[0149] S55: Reconfirm the projection point;

[0150] Define the vector Then The square modulus w of, as shown in the following formula:

[0151]

[0152] Expanding the above formula gives:

[0153]

[0154] Determine the parameter t, which is a proportionality coefficient and represents the relative position of the projection point to be reconfirmed along the vector Direction, that is:

[0155]

[0156] When t < 0, the projection point O to be reconfirmed is the A point of its corresponding triangular patch, and take O = A;

[0157] When t > 1, the projection point O to be reconfirmed is the B point of its corresponding triangular patch, and take O = B;

[0158] When 0 ≤ t ≤ 1, the projection point O to be reconfirmed is on the side AB of its corresponding triangular patch, and take

[0159] S56: According to the index of the downsampled point cloud, the projection points are reordered to obtain the final projected point cloud.

[0160] Furthermore, in step six, the weighted least squares method is used to calculate the affine transformation matrix trans for registering the point cloud to the STL model; specifically, it includes the following steps:

[0161] S61: Preset the weight w of the downsampled point cloud P; the centroid P of the downsampled point cloud P bar As shown in the following formula:

[0162]

[0163] In the above formula, \(i\) represents the index of each point cloud and its weight from \(1\) to \(m\), and \(m\) represents the total number of points in the point cloud set;

[0164] Similarly, for the projected point cloud \(Q\), the centroid \(\overline{Q}\) of the point cloud \(Q\) bar The calculation formula is:

[0165]

[0166] In the above formula, \(i\) represents the index of each point cloud and its weight from \(1\) to \(n\); \(n\) represents the total number of points in the point cloud set;

[0167] S62: Solve the optimal rotation matrix \(R\) for registering the point cloud to the STL model;

[0168] First, construct the covariance matrix \(N\) between the two;

[0169]

[0170] where \(P\) mark \(=\mathbf{p}\) i -\(\overline{P}\) bar , \(Q\) mark \(=\mathbf{q}\) i -\(\overline{Q}\) bar ; \(\mathbf{p}\) i represents the \(i\)-th point in the downsampled point cloud \(P\), and \(\mathbf{q}\) i is the \(i\)-th point in the target point cloud \(Q\);

[0171] Then, perform the singular value decomposition of the covariance matrix \(N\) as follows:

[0172]

[0173] In the above formula, \(U\) represents a \(3\times3\) orthogonal matrix containing the left singular vectors of the covariance matrix; \(\Sigma\) represents a \(3\times3\) diagonal matrix containing the singular values; is a \(3\times3\) orthogonal matrix containing the right singular vectors of the covariance matrix;

[0174] Therefore, the optimal rotation matrix \(R\) is as follows:

[0175]

[0176] In the above formula, \(D\) is a diagonal matrix, and its diagonal elements are The role of this diagonal matrix is to ensure that the determinant of the rotation matrix is positive, that is, to ensure the right-hand rule;

[0177] S63: Determine the affine transformation matrix \(trans\) and the translation matrix \(T\), which is implemented by the following formula:

[0178] \(T = \overline{Q}\) bar - \(R\cdot\overline{P}\)bar (22);

[0179] S64: Further obtain the affine transformation matrix trans between the two as follows:

[0180]

[0181] Furthermore, step seven specifically includes:

[0182] S71: The loop iteration ends, and the final rigid transformation matrix trans final , is as follows:

[0183] trans final = M k+1 = L k+1 · M k (24)

[0184] In the above formula, M k represents the transformation matrix after the Kth iteration, where M0 is a 4*4 identity matrix; L k+1 is the affine transformation matrix obtained in the (k + 1)th iteration.

[0185] Furthermore, in step two, the voxel filtering downsampling method is used to downsample the actually scanned casting point cloud.

[0186] Furthermore, in step seven, at the beginning of the iteration, the number of iterations is preset to 50 times, and after about 50 times, the point cloud can be converged to the model to achieve the effect of precise registration.

[0187] Verification Example 1:

[0188] This verification example takes a simple STL model drawn by CATIA by itself as an example, and uses this method for registration. As shown in the appendix Figure 2 , the figure includes the positional relationship between the point cloud and the model at the initial iteration position, after 5 iterations, after 10 iterations, and after 15 iterations. Since the STL model used in this verification example is relatively simple, the matching degree between the point cloud and the STL model is already relatively consistent after 15 iterations. In the figure, the blue represents the point cloud data to be projected, and the red part is the STL model. During the projection process, the shortest distance from each point of the point cloud to the model surface is calculated as the correct projection point to obtain the accurate position of the point cloud projection. Based on the projected point cloud data and the target model, registration calculation is performed. This algorithm uses the weighted least squares method to calculate the rotation matrix R and the translation vector T to obtain the affine transformation matrix trans between the point cloud data and the target model. After iterative optimization, the final registration result of the point cloud and the STL model is obtained, and the point cloud data is precisely aligned with the target model, which can accurately reflect the shape and structure of the measurement object.

[0189] Verification Example 2:

[0190] This verification example is for the attached Figure 3 The specific operation flow diagram of the actual registration of the casting of the rear floor of the automobile in the actual production operation shown in the figure. The purple part in the figure is the line structured light emitted by the surface structured light camera when taking pictures, which is used to collect the surface point cloud of the casting. In this embodiment, due to the limited field of view of the surface structured light camera, multiple shots are required to cover the entire casting. The figure shows a schematic diagram of dividing this accessory into 5 parts for scanning point cloud registration. The 5 parts correspond to the 5 small pictures in the figure.

[0191] In this verification example, in order to compare the time consumption, accuracy and other specific data with the existing commonly used registration methods, the casting in the lower right corner is selected to perform registration between the actual point cloud collected and the STL model.

[0192] The following table compares the effects of the classic ICP algorithm and the point cloud registration to STL model method (this method) in this verification example.

[0193]

[0194]

[0195] From the data in the table above, it can be seen that the point cloud registration to STL model algorithm has higher computational efficiency and more stable computational speed than the classic ICP algorithm when processing point clouds of different scales. Especially when the number of point clouds is large, although the number of calculations and the calculation time increase, the increase in error is relatively small, indicating that the algorithm can maintain good accuracy and stability when processing large-scale point clouds. Compared with the classic ICP algorithm, the point cloud registration to STL model algorithm has advantages in error control, especially when processing 500,000 point clouds, its root mean square error (RMSE) is 0.40mm, while the ICP algorithm is 1.10mm, which clearly shows an improvement in accuracy.

[0196] As attached Figure 4 The figure shows the casting in the lower right corner. First, the model is partially cut using CATIA, and then imported into the developed visualization software. The figure uses Qt as the visualization platform and combines the C++ programming language to implement the algorithm, which can give full play to the advantages of Qt in graphical interface and interactive operation, and at the same time use the characteristics of C++ in performance and computing efficiency to ensure the efficiency and real-time performance of the system.

[0197] Although the present invention has been disclosed as above in terms of preferred embodiments, they are not intended to limit the present invention. Anyone skilled in the art can make various changes or modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection defined by the claims of this application.

Claims

1. A method for directly registering a point cloud to an STL model, characterized in that: include: Step 1: Use MeshVS_Mesh to read the parameters of the STL model of the casting to be registered; the parameters of the STL model include the number of triangles, the number of nodes, the vertex coordinates of each triangle and the index of the edge of the STL model; calculate the incenter of each triangle and the normal vector of the incenter; Step 2: Load the casting point cloud obtained by actual scanning, perform denoising and downsampling, and obtain the downsampled point cloud; Step 3: Initialize a 4*4 unit matrix as the initial transformation matrix between the point cloud and the STL model of the casting to be registered, and set the number of iterations for calculating the transformation matrix between the point cloud and the STL model; Step 4: Construct a KD tree that can perform nearest neighbor search on the coordinates of the inner point of the triangle. According to the sampled point cloud, find the coordinates of the inner point of all triangles in the KD tree to obtain the nearest triangles of different point cloud points within the preset specified range. Step 5: Determine the projection point of each point in the point cloud to its nearest triangular facet; determine the nearest triangular facet corresponding to each point in the point cloud based on the KD tree to obtain the preliminary projection point of the point; use the barycentric coordinate method to check whether the preliminary projection point is within its corresponding triangular facet; if the preliminary projection point is not within its corresponding triangular facet, recalculate the projection point; sort the projection points according to the index of the downsampled point cloud to obtain a new projection point cloud; Step 6: Use analytical method to calculate the affine transformation matrix from the downsampled point cloud to its corresponding projection point cloud; Step 7: Multiply the initial transformation matrix by the affine transformation matrix on the left to iterate the matrix. When the number of iterations is reached, the final transformation matrix is ​​obtained, so that the downsampled point cloud gradually approaches the STL model and finally converges to complete the iteration.

2. A method for directly registering a point cloud to an STL model according to claim 1, characterized in that: Step 1 specifically includes: S11: Use the MeshVS_Mesh class in OpenCASCADE to read the three vertices of each triangular facet of the casting to be registered; define the three vertices of the i-th triangular facet as A i (x i1 ,y i1 、z i1 ), B i (x i2 ,y i2 、z i2 ), C i (x i3 ,y i3 、z i3 ) The lengths of the three sides corresponding to i , b i , c i ; S12: Calculate the inner center I of each triangle i (x i ,y i 、z i ); First, calculate the lengths of the three sides of each triangle as follows: Then we get the center I of each triangle i (x i ,y i 、z i ), as follows: S13: Calculate the normal vector of each triangle; First, calculate the two edge vectors of each triangle As follows: Then the normal vector n of each triangle is i (x in ,y in 、z in ) is expressed as: (4) In the formula, the normal vector x in ,y in 、z in They are: S14: Normalize the normal vector; first normalize the normal vector to get the modulus length of the corresponding triangle patch normal vector || n i ||, then: Then, define the normalized normal vector as n i,normalized , then the normalized formula is expressed as:

3. The method for directly registering a point cloud to an STL model according to claim 1, characterized in that: The expression of the initial transformation matrix M0 in step 3 is:

4. The method for directly registering a point cloud to an STL model according to claim 1, characterized in that: Step 5 specifically includes: S51: using the KD tree created in step 4, input the inner coordinates of all triangles into the KD tree; for each point in the downsampled point cloud, search the inner point of the triangle closest to it in the KD tree, and the triangle is the nearest triangle to the point; S52: Calculate the distance d from each point to the normal of its nearest triangle face k ; d k =n normalized (P-I) (9) In the above formula, P(x p ,y p 、z p ) is a point in the point cloud; n normalized is the normal vector of the nearest triangle of the point cloud; S53: Since the projection direction of each point in the casting point cloud is along the direction of the normal vector of the corresponding triangle, the projection point of each point in the point cloud is the position of each point in the downsampled point cloud projected onto the triangle along the normal direction of its nearest triangle, that is, each point moves d along the normal direction of its nearest triangle. k The initial projection point is determined as follows: O=P-d k n normalized (10) In the above formula, O represents the projection point; S54: Based on the preliminary projection point obtained in step S53, the barycentric coordinate method is used to determine whether the preliminary projection point is within the triangular facet; specifically: First: the vector between two edges of the triangle patch and the vector between the projection point and any vertex are obtained by the following formula: In the above formula, v0 represents the vector from the first vertex A to the third vertex C of the triangle; v1 represents the vector from the first vertex A to the second vertex B of the triangle; v2 represents the vector from the projection point O to the first vertex A; where (x i1 ,y i1 ,z i1 )、(x i2 ,y i2 ,z i2 )、(x i3 ,y i3 ,z i3 ) correspond to the coordinates of the first, second, and third vertex A, B, and C of the triangle respectively; (x io ,y io ,z io ) are the coordinates of the projection point O; Then the dot product is calculated between the three vectors obtained, as shown below: Finally, the barycentric coordinate method is used to calculate the projection position judgment parameters u and v of the preliminary projection point relative to the triangle patch, as follows: If u≥0, v≥0, and u+v<1 are satisfied at the same time, the preliminary projection point is located in the triangle patch, and the preliminary projection point is determined to be the projection point of the point, and the process proceeds to step S56; if not satisfied, the process proceeds to step S55 to reconfirm the projection point; S55: reconfirm the projection point; Defining vectors but The square modulus w is as follows: Expand the above formula to get: Determine the parameter t, which is the proportional coefficient, which represents the projection point to be reconfirmed along the vector Relative position in direction, that is: When t<0, the projection point O to be reconfirmed is the point A of the corresponding triangle patch, and O=A; When t>1, the projection point O to be reconfirmed is the point B of the corresponding triangle patch, and O=B; When 0≤t≤1, the projection point O to be reconfirmed is on the edge AB of its corresponding triangle patch. S56: reorder the projection points according to the index of the downsampled point cloud to obtain the final projection point cloud.

5. The method for directly registering a point cloud to an STL model according to claim 1, characterized in that: In step 6, the weighted least squares method is used to calculate the affine transformation matrix trans of the point cloud registration to the STL model; specifically, the following steps are included: S61: preset the weight w of the downsampled point cloud P; the centroid P of the downsampled point cloud P bar As follows: In the above formula, i represents the index of each point cloud and its weight from 1 to m, and m represents the total number of points in the point cloud set; similarly, for the projected point cloud Q, the centroid Q of the point cloud Q bar The calculation formula is: In the above formula, i represents the index of each point cloud and its weight from 1 to n; n represents the total number of points in the point cloud set; S62: solve the optimal rotation matrix R for point cloud registration to STL model; First, construct the covariance matrix N between the two; Where P mark =p i -P bar , Q mark =q i -Q bar ;p i represents the i-th point in the downsampled point cloud P, q i is the i-th point in the target point cloud Q; Then perform the singular value decomposition of the covariance matrix N as follows: In the above formula, U represents a 3×3 orthogonal matrix containing the left singular vectors of the covariance matrix; Σ represents a 3×3 diagonal matrix containing singular values; is a 3×3 orthogonal matrix containing the right singular vectors of the covariance matrix; Therefore, the optimal rotation matrix R is as follows: In the above formula, D is a diagonal matrix whose diagonal elements are The role of this diagonal matrix is ​​to ensure that the determinant of the rotation matrix is ​​positive, that is, to ensure the right-hand rule; S63: Determine the affine transformation matrix trans and the translation matrix T, which can be implemented as follows: T=Q bar -R·P bar (22) S64: Then the affine transformation matrix trans between the two is obtained as follows:

6. The method for directly registering a point cloud to an STL model according to claim 1, characterized in that: Step 7 specifically includes: S71: The loop iteration ends and the final rigid transformation matrix trans is obtained final , as follows: trans final =M k+1 =L k+1 ·M k (24) In the above formula, M k represents the transformation matrix after the Kth iteration, where M0 is a 4*4 unit matrix; L k+1 is the affine transformation matrix obtained at the k+1th iteration.

7. The method for directly registering a point cloud to an STL model according to claim 1, characterized in that: In step 2, the actual casting point cloud acquired by scanning is downsampled using a voxel filtering downsampling method.

8. The method for directly registering a point cloud to an STL model according to claim 1, characterized in that: In step seven, at the beginning of the iteration, the number of iterations is preset to 50 times. After about 50 times, the point cloud can be converged to the model to achieve the effect of precise registration.

Citation Information

Patent Citations

  • Point cloud curved surface segmentation method based on IGES model guidance

    CN113658184A