Metal product flatness detection method and system based on laser three-dimensional point cloud
By constructing a topological continuity confidence score and an improved RANSAC algorithm, combined with neighborhood consistency and a weighted penalty function, the problem of noise interference in the flatness detection of metal products is solved, and high-precision flatness detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 广东玛哈特智能装备有限公司
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-17
AI Technical Summary
The existing RANSAC algorithm is susceptible to noise interference at the edges of metal products, resulting in false flatness detection results and failing to effectively distinguish between random discrete noise and continuous geometric deformation.
By constructing a topological continuity confidence score and an improved RANSAC algorithm, combined with neighborhood consistency and a weighted penalty function, the plane fitting process is optimized to distinguish high-quality planar point clouds from edge spikes or scan noise point clouds, thereby improving the robustness and accuracy of the fitting.
It significantly improves the anti-interference capability and measurement accuracy of flatness testing for metal products, ensuring that the test results truly reflect the surface quality of the product and reducing the misjudgment rate.
Smart Images

Figure CN121883384A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial precision testing technology. More specifically, this invention relates to a method and system for detecting the flatness of metal products based on laser three-dimensional point clouds. Background Technology
[0002] In the manufacturing process of metal parts (such as precision automotive structural components, power battery casings, and heat dissipation substrates), flatness is a key geometric tolerance indicator for measuring product quality. Existing automated inspection solutions typically use line laser profilometers or structured light cameras to acquire three-dimensional point cloud data of the product surface. Then, an ideal reference plane is fitted using an algorithm, and the distance deviation of each point cloud data point from the reference plane is calculated, which serves as the basis for judging flatness.
[0003] Specifically, after acquiring 3D point cloud data, the Random Sample Consensus Algorithm (RANSAC) is usually used to fit a reference plane, and then the flatness is evaluated by calculating the distance of each point cloud to the reference plane.
[0004] However, existing RANSAC algorithms have significant limitations when handling the edges of metal products. For example, the edges of metal products often generate flying point cloud noise due to laser scattering, and the products themselves may have real edge warping defects. Both of these manifest as outlier point clouds deviating from the fitted plane. Traditional RANSAC algorithms use a single Euclidean distance threshold for determining the interior point cloud, and in order to obtain the optimal mathematical fitting plane, the algorithm tends to discard all distant point clouds. This one-size-fits-all approach causes real edge warping features to be misjudged as noise and filtered out, resulting in a falsely calculated flatness that is better than the actual value, creating a serious risk of missed detections.
[0005] Therefore, there is an urgent need for a method that can effectively distinguish between random discrete noise and continuous geometric deformation during the fitting process in order to accurately detect flatness. Summary of the Invention
[0006] The purpose of this invention is to propose a method and system for flatness detection of metal products based on laser three-dimensional point clouds, in order to solve the problem in the prior art that it is impossible to effectively distinguish between random discrete noise and continuous geometric deformation during the fitting process of the reference plane, and thus cannot accurately perform flatness detection; to this end, this invention provides solutions in the following two aspects.
[0007] In a first aspect, the present invention provides a method for detecting the flatness of metal products based on laser three-dimensional point clouds, comprising: Acquire 3D point cloud data of the plane to be measured on a metal product; A topological continuity confidence score is constructed for each point cloud. The topological continuity confidence score is negatively correlated with the neighborhood consistency and average neighborhood distance of the corresponding point cloud, and positively correlated with the global average distance. The neighborhood consistency score represents the consistency of the normal vectors of each point cloud with all its neighboring point clouds. An improved RANSAC algorithm is used to fit the reference plane of the plane to be measured. The improved RANSAC algorithm uses the sum of the weighted penalty functions of all point clouds as the loss function. The weighted penalty function is obtained by the topological continuity confidence of each point cloud and the distance of each point cloud to the reference plane. The flatness is obtained by calculating the sum of the maximum positive deviation and the maximum negative deviation of the valid point cloud with a topological continuity confidence score greater than a set threshold from the reference plane.
[0008] The above scheme, by introducing neighborhood consistency and topological continuity confidence, can effectively distinguish high-quality planar point clouds on the surface of metal products from edge burrs or scanning noise point clouds. It overcomes the problem that the traditional RANSAC algorithm, which divides the local point cloud based solely on distance, is easily affected by noise interference, leading to a tilted fitting plane. By optimizing the plane fitting process through a confidence-based weighted penalty function, it significantly improves the robustness of the baseline plane fitting and the accuracy of flatness detection.
[0009] Optionally, the neighborhood consistency The specific calculation method is as follows: ; middle, Let i represent the set of point clouds within the neighborhood of k nearest neighbors of point cloud i. and Let be the unit normal vectors of point cloud i and its neighboring point cloud j, respectively, and · denote the point cloud product. Let Euclidean distance be the distance between two points in the cloud. Let be the distance decay constant, and i and j be the indexes of the point cloud, respectively.
[0010] The above scheme uses the normal vector point cloud product to determine the plane consistency and introduces a distance decay constant, which can accurately quantify the geometric smoothness of local areas of the point cloud, effectively identify the edges or drastically deformed areas with disordered normal vectors, and provide reliable geometric feature basis for subsequent confidence assessment.
[0011] Optionally, the topological continuity confidence level The specific calculation method is as follows: ; in, For adjustment coefficients, For neighborhood consistency, For point clouds The local neighborhood average point cloud spacing, The global average point cloud spacing for all point clouds.
[0012] By combining normal vector consistency and point cloud spacing distribution characteristics to construct topological continuity confidence, and using the ratio of local to global average point cloud spacing to identify sparse edges or hole regions, the reliability of point cloud data can be more comprehensively evaluated, and the weight of low-quality point clouds caused by scan gaps or edge effects can be automatically reduced.
[0013] Optionally, the weighted penalty function for: ; in, , These are the first weighting coefficient and the second weighting coefficient, respectively. For point clouds The perpendicular distance to the current iterative planar model M, For point clouds The topological continuity confidence score, where e is a natural number. For high confidence threshold, This is the low confidence threshold.
[0014] The above scheme constructs a piecewise weighted penalty function, using squared loss for high-confidence core point clouds to achieve strong constraints and accurate localization, linear loss for low-confidence edge point clouds to prevent plane skew, and exponential decay for noise points to eliminate interference. This achieves adaptive weighted fitting of point cloud data of different quality, greatly improving the stability of plane fitting in complex noise environments.
[0015] Optionally, the method further includes preprocessing the 3D point cloud data, the preprocessing including: voxelizing and downsampling the original 3D point cloud into a mesh; and establishing a KD-Tree index for the downsampled point cloud.
[0016] The above-mentioned voxelized mesh downsampling effectively suppresses minute surface roughness noise and reduces data volume while preserving the macroscopic geometric features of the metal plane. Combined with the KD-Tree index structure, the time complexity of nearest neighbor search is reduced from linear to logarithmic, which significantly improves the processing efficiency and real-time performance of large-scale point cloud data.
[0017] Optionally, the method for calculating the local neighborhood normal vector is as follows: Principal component analysis is performed on the set of points in the neighborhood of each point cloud's k nearest neighbors, and the eigenvector corresponding to the minimum eigenvalue is taken as the normal vector of that point cloud.
[0018] Optionally, the range of values for the first weighting coefficient is: The range of values for the second weighting coefficient is: .
[0019] Optionally, the range of the high confidence threshold is: The range of the low confidence threshold is as follows: .
[0020] Optionally, calculating the flatness specifically includes: Find all valid point clouds with a topological continuity confidence score greater than the low confidence threshold; Calculate the distances from all valid point clouds to the reference plane, and take the maximum positive distance as the maximum positive deviation; The absolute value of the maximum negative distance is taken as the maximum negative deviation; The flatness is obtained by adding the maximum positive deviation and the maximum negative deviation.
[0021] Before calculating the final flatness, edge burrs and scanning noise clouds are removed using a confidence threshold. The sum of the maximum positive and negative deviations is calculated based on the effective point cloud, ensuring that the output flatness can truly reflect the surface quality of the metal product and eliminating interference from defects not inherent to the product itself (such as measurement errors).
[0022] In the second aspect, the metal product flatness inspection system based on laser three-dimensional point cloud includes: processor; The memory stores computer instructions for detecting the flatness of metal products based on laser three-dimensional point clouds. When the computer instructions are executed by the processor, the system performs the aforementioned method for detecting the flatness of metal products based on laser three-dimensional point clouds.
[0023] The beneficial effects of this invention are as follows: The present invention addresses the problem of traditional methods being susceptible to noise and edge effects. By combining local normal vector consistency with point cloud spacing distribution to construct a confidence evaluation index, it effectively distinguishes between high-quality point clouds and noisy point clouds. Furthermore, a weighted penalty function is designed as a loss function to apply differentiated weights to point clouds with different confidence levels, achieving highly robust fitting of the reference plane. This significantly improves the anti-interference capability and measurement accuracy of flatness detection for metal products. Attached Figure Description
[0024] Figure 1 The flowchart illustrating the steps of the method for detecting the flatness of metal products based on laser three-dimensional point clouds in this embodiment is shown in the schematic diagram. Figure 2 This schematically illustrates the effective distance distribution from the effective point cloud to the fitted reference plane in this embodiment; Figure 3 The schematic diagram illustrates the structural block diagram of the metal product flatness detection system based on laser three-dimensional point cloud in this embodiment. Detailed Implementation
[0025] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0026] like Figure 1 As shown, the method for detecting the flatness of metal products based on laser three-dimensional point clouds in this embodiment includes the following steps: Step S1: Obtain the three-dimensional point cloud data of the surface of the metal product and preprocess the three-dimensional point cloud data.
[0027] In this embodiment, three-dimensional point cloud data of the metal product surface is first acquired using a high-precision laser scanner. The laser scanner can be a laser profile sensor or a structured light camera.
[0028] Since the acquired 3D point cloud data typically contains millions of points, direct processing involves a huge amount of computation and contains noise. To improve the efficiency of subsequent calculations and remove redundant information, this embodiment also performs voxel grid downsampling on the 3D point cloud and establishes a KD-Tree (K-Dimensional Tree) index structure for the downsampled point cloud data.
[0029] Specifically, the three-dimensional space is divided into dimensions of... For a voxel grid, calculate the centroid of all point clouds within each voxel, and use the point cloud with the centroid to represent all point clouds within that voxel.
[0030] In this embodiment, the voxel grid size Preferred setting is This range can both preserve the macroscopic geometric features of the metal plane and effectively suppress minor surface roughness noise.
[0031] KD-Tree is a data structure that partitions a k-dimensional data space, reducing the time complexity of nearest neighbor search from... Reduce to .
[0032] Step S2: Calculate the neighborhood consistency of each point cloud.
[0033] The process of obtaining neighborhood consistency in this embodiment is as follows: First, obtain the neighborhood consistency of any point cloud. The collection of point clouds within the nearest neighbor's neighborhood .
[0034] In this embodiment, for any point cloud... Search its KD-Tree Neighborhood points cluster . The preferred value is... .
[0035] Secondly, regarding point clouds and The point cloud set within the neighborhood is used to calculate the normal vector using principal component analysis (PCA).
[0036] Specifically, the process of obtaining the normal vector is as follows: first, calculate the covariance matrix of the neighborhood point cloud. For the covariance matrix Eigenvalue decomposition yields three eigenvalues. and its corresponding eigenvectors; take the minimum eigenvalue. The corresponding eigenvector is used as the unit normal vector of the point cloud. .
[0037] Normal vectors are important parameters for describing the geometric features of a surface.
[0038] Then, the neighborhood consistency of each point cloud is constructed. .
[0039] In an ideal planar region, the normal vectors of all point clouds within a neighborhood should be highly consistent, resulting in a point cloud product close to 1. However, at edges, in noisy point clouds, or in areas of severe deformation, the normal vector directions are disordered, leading to a smaller point cloud product. Furthermore, the closer a neighboring point cloud is to the center point cloud, the greater the reference value of its normal vector. Therefore, to quantize point clouds... The local geometric smoothness of the region needs to be determined by using normal vectors to build neighborhood consistency.
[0040] Specifically, neighborhood consistency The calculation formula is: ; middle, Let i represent the set of point clouds within the neighborhood of k nearest neighbors of point cloud i. and Let be the unit normal vectors of point cloud i and its neighboring point cloud j, respectively, and · denote the point cloud product. Let Euclidean distance be the distance between two points in the cloud. Let be the distance decay constant, and i and j be the indexes of the point cloud, respectively.
[0041] From the above formula, it can be seen that when the normal vector of the neighborhood point cloud... With the center point cloud normal vector When parallel, ,at this time , making A value close to 0 indicates that the plane uniformity of the region is extremely high; when the difference in normal vectors is large, Enlargement, leading to An increase in the value indicates poor flatness in the area. The exponential term... As distance weights, with distance As the distance increases, the weight decreases exponentially. This reflects the physical law that the closer the spatial distance, the stronger the correlation of geometric features.
[0042] In this embodiment, The preferred value is twice the average spacing of all point clouds.
[0043] Step S3: Construct the topological continuity confidence score.
[0044] To further distinguish between valid planar point clouds and unreliable point clouds caused by scan gaps or edge effects, this embodiment introduces point cloud spacing distribution features and combines them with neighborhood consistency to construct a topological continuity confidence score.
[0045] First, calculate the point cloud. The mean local distance to all point clouds within the local neighborhood and the mean global distance to all point clouds.
[0046] A high-quality planar point cloud should have highly consistent local normal vectors. The point cloud should be small, and its local point cloud density should be uniform, meaning the difference between the local mean distance and the global mean distance should not be significant. If the local mean distance is greater than the global mean distance, it indicates that the point cloud is located near a sparse edge or hole, and the reliability should be reduced.
[0047] Specifically, topological continuity confidence The calculation formula is: ; in, For point clouds Neighborhood consistency For point clouds The mean local distance to all point clouds within the local neighborhood. The mean global distance across all point clouds. This is an adjustment coefficient used to balance the effects of neighborhood consistency and point cloud density distribution (the ratio of the local distance mean to the global distance mean).
[0048] In this embodiment, the value range of the adjustment coefficient can preferably be 5-10.
[0049] In the above formula, the greater the neighborhood consistency, the larger the denominator, and the lower the confidence level of topological continuity; the sparser the local point cloud, i.e., the larger the mean local distance, the larger the denominator, and the lower the confidence level of topological continuity. The range is normalized to Within the range, it is convenient to set thresholds for subsequent hierarchical processing.
[0050] Step S4: Fit the reference plane using the improved RANSAC algorithm and obtain the flatness.
[0051] Traditional RANSAC algorithms, when fitting a plane, only distinguish between inner and outer point clouds based on a distance threshold, making them susceptible to noise interference and causing slight tilting of the fitted plane. This embodiment proposes an improved RANSAC algorithm based on loss function optimization. This improved RANSAC algorithm fits an initial plane model by randomly selecting a subset. Subsequently, instead of simply counting the number of point clouds within a single point cloud, a weighted penalty function is calculated for all point clouds. The sum of these values is used as the loss function, i.e. The best baseline fitting plane is determined by minimizing this loss function.
[0052] Among them, the weighted penalty function for: ; in, , These are the first weighting coefficient and the second weighting coefficient, respectively. For point clouds The perpendicular distance to the current iterative planar model M, For point clouds The topological continuity confidence score, where e is a natural number. For high confidence threshold, This is the low confidence threshold.
[0053] In the above formula, when When the point cloud is considered as a core plane point cloud, the loss function is... That is, the loss function uses squared loss, which is sensitive to distance.
[0054] In this embodiment, the high confidence threshold The range of values is Among them, the first weighting coefficient The value is relatively small, and the preferred value range is: The role of the first weighting coefficient is to use these high-quality point clouds to fine-tune and accurately locate the plane.
[0055] when When the point cloud is considered as a secondary effective point cloud, the loss function is a linear distance weighted loss function. The value is relatively large, and it introduces... The term indicates that for point clouds of medium quality, while their existence is allowed, their bias is penalized by a large coefficient, while utilizing... Dynamic adjustment prevents individual outlier point clouds from exerting excessive "pulling" force on the plane.
[0056] In this embodiment, the low confidence threshold The range of values The range of values for the second weighting coefficient is: .
[0057] when When the corresponding point cloud is considered as noise or invalid point cloud, it is treated as an exponential decay form to minimize its impact on plane fitting.
[0058] Since point clouds with different confidence levels contribute differently to plane fitting, high-confidence point clouds should dominate the determination of the plane and adopt strong constraints similar to least squares; low-confidence point clouds (such as edge point clouds) should have their weights reduced to prevent them from skewing the plane.
[0059] In this embodiment, after obtaining the best-fit reference plane, in order to obtain the flatness that truly reflects the surface quality of the metal product, it is necessary to eliminate interfering point clouds (such as edge burrs and scanning noise point clouds) to remove them. Specifically, the flatness acquisition process is as follows: Find all points in the 3D point cloud data that satisfy the following conditions: For each valid point cloud, calculate the directed distance from all valid point clouds to the reference plane, determine the maximum positive deviation, and take the absolute value of the maximum negative distance as the maximum negative deviation. The sum of the maximum positive deviation and the maximum negative deviation is taken as the flatness.
[0060] The maximum positive deviation described above represents the deviation of the point cloud furthest above the best-fit reference plane from the best-fit reference plane, while the maximum negative deviation represents the deviation of the point cloud furthest below the best-fit reference plane from the best-fit reference plane.
[0061] For example, such as Figure 2 As shown, the maximum positive deviation measured is The maximum negative deviation is The flatness of the metal product is then... .
[0062] In this embodiment, the flatness is compared with a threshold range. If the flatness is within the threshold range, the metal product is deemed qualified. In one embodiment, the threshold range is obtained by first performing flatness testing on multiple standard metal products, then obtaining the mean and standard deviation of all flatness values, and finally using the 3-sigma principle to determine the threshold range.
[0063] The solution of this invention achieves highly robust fitting of the reference plane, thereby significantly improving the anti-interference capability and measurement accuracy of flatness detection of metal products.
[0064] This invention also provides a planarity inspection system for metal products based on laser three-dimensional point clouds. For example... Figure 3As shown, the system includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the above-described method for detecting the flatness of metal products based on laser three-dimensional point clouds according to the present invention.
[0065] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and therefore will not be described in detail here.
[0066] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device. Any application or module described in this invention can be implemented by computer-readable / executable instructions stored or otherwise maintained on such a computer-readable medium.
[0067] In the description of this specification, "multiple" means at least two, such as two, three or more, etc., unless otherwise expressly and specifically defined.
[0068] While various embodiments of the invention have been shown and described in this specification, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention.
Claims
1. A method for detecting the flatness of metal products based on laser three-dimensional point clouds, characterized in that, include: Acquire 3D point cloud data of the plane to be measured on a metal product; A topological continuity confidence score is constructed for each point cloud. The topological continuity confidence score is negatively correlated with the neighborhood consistency and average neighborhood distance of the corresponding point cloud, and positively correlated with the global average distance. The neighborhood consistency score represents the consistency of the normal vectors of each point cloud with all its neighboring point clouds. An improved RANSAC algorithm is used to fit the reference plane of the plane to be measured. The improved RANSAC algorithm uses the sum of the weighted penalty functions of all point clouds as the loss function. The weighted penalty function is obtained by the topological continuity confidence of each point cloud and the distance of each point cloud to the reference plane. The flatness is obtained by calculating the sum of the maximum positive deviation and the maximum negative deviation of the valid point cloud with a topological continuity confidence score greater than a set threshold from the reference plane.
2. The method for detecting the flatness of metal products based on laser three-dimensional point clouds according to claim 1, characterized in that, Neighborhood Consistency The specific calculation method is as follows: ; middle, Let i represent the set of point clouds within the neighborhood of k nearest neighbors of point cloud i. and Let be the unit normal vectors of point cloud i and its neighboring point cloud j, respectively, and · denote the point cloud product. Let Euclidean distance be the distance between two points in the cloud. Let be the distance decay constant, and i and j be the indexes of the point cloud, respectively.
3. The method for detecting the flatness of metal products based on laser three-dimensional point clouds according to claim 1, characterized in that, The topological continuity confidence level The specific calculation method is as follows: ; in, For adjustment coefficients, For neighborhood consistency, For point clouds The local neighborhood average spacing, The global average spacing for all point clouds.
4. The method for detecting the flatness of metal products based on laser three-dimensional point clouds according to claim 1, characterized in that, The weighted penalty function for: ; in, , These are the first weighting coefficient and the second weighting coefficient, respectively. For point clouds The perpendicular distance to the current iterative planar model M, For point clouds The topological continuity confidence score, where e is a natural number. For high confidence threshold, This is the low confidence threshold.
5. The method for detecting the flatness of metal products based on laser three-dimensional point clouds according to claim 1, characterized in that, It also includes preprocessing the 3D point cloud data, which includes: voxelizing and downsampling the original 3D point cloud into a mesh; and establishing a KD-Tree index for the downsampled point cloud.
6. The method for detecting the flatness of metal products based on laser three-dimensional point clouds according to claim 1, characterized in that, The method for calculating the local neighborhood normal vector is as follows: Principal component analysis is performed on the set of points in the neighborhood of each point cloud's k nearest neighbors, and the eigenvector corresponding to the minimum eigenvalue is taken as the normal vector of that point cloud.
7. The method for detecting the flatness of metal products based on laser three-dimensional point clouds according to claim 4, characterized in that, The range of values for the first weighting coefficient is: The range of values for the second weighting coefficient is: .
8. The method for detecting the flatness of metal products based on laser three-dimensional point clouds according to claim 4, characterized in that, The range of the high confidence threshold is as follows: The range of the low confidence threshold is as follows: .
9. The method for detecting the flatness of metal products based on laser three-dimensional point clouds according to claim 1 or 4, characterized in that, The calculation of the flatness specifically includes: Find all valid point clouds with a topological continuity confidence score greater than the low confidence threshold; Calculate the distances from all valid point clouds to the reference plane, and take the maximum positive distance as the maximum positive deviation; take the absolute value of the maximum negative distance as the maximum negative deviation; The flatness is obtained by adding the maximum positive deviation and the maximum negative deviation.
10. A metal product flatness inspection system based on laser three-dimensional point cloud, characterized in that, include: processor; A memory storing computer instructions for flatness inspection of metal products based on laser three-dimensional point clouds, wherein when the computer instructions are executed by the processor, the system performs the flatness inspection method for metal products based on laser three-dimensional point clouds according to any one of claims 1-9.