Workpiece ruling depth detection method and device based on point cloud data
By downsampling point cloud data, applying Gaussian filtering and statistical filtering using a scalar domain self-attention mechanism, and combining scribe line region fitting and reference plane calculation, the problem of balancing point cloud data processing efficiency and accuracy was solved, achieving efficient and accurate detection of micro- and nano-scale scribe line depths.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-03-27
AI Technical Summary
Existing point cloud processing methods cannot simultaneously balance point cloud data processing efficiency and measurement accuracy when handling depth detection of micro- and nano-scale workpieces with scribed lines.
The depth of the scribing is extracted by downsampling point cloud data, Gaussian filtering based on scalar domain self-attention mechanism, statistical filtering, scalar domain thresholding, scribing region fitting, and reference plane calculation.
It significantly improves the efficiency and accuracy of depth measurement of workpieces with engraved lines, meeting the detection requirements of micro- and nano-level precision.
Smart Images

Figure CN121329972B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of workpiece model construction technology, and in particular to a method and apparatus for detecting the depth of workpiece scribing based on point cloud data. Background Technology
[0002] As industrial manufacturing continues to advance towards micro- and nano-level precision, the demand for non-contact, high-precision inspection of workpiece geometry is becoming increasingly urgent. Among these, the measurement of etched standard depths is an indispensable part of metrology and verification, currently mostly conducted at the micrometer scale. Linear spectral confocal detection technology based on three-dimensional point clouds shows great potential in this field due to its ability to acquire complete three-dimensional information of object surfaces.
[0003] In traditional technologies, point cloud detection algorithms face the following main problems: First, current point cloud algorithms for workpiece size measurement process relatively small point clouds, ranging from tens of thousands to hundreds of thousands of points, which cannot effectively represent the minute size data of the workpiece itself; second, for dense 3D point clouds applied to large scenes such as streets and buildings, the focus is on the reconstruction of macroscopic contours, and the accuracy of the processing results is low, which cannot meet the accuracy requirements at this scale; and automatic calculation processing of point clouds with standard depth and scribing lines is still lacking.
[0004] In summary, current point cloud processing methods have a technical problem in dealing with depth detection of micro- and nano-scale workpieces with etched lines: they cannot simultaneously achieve both point cloud data processing efficiency and measurement accuracy. Summary of the Invention
[0005] Therefore, it is necessary to provide a workpiece scribing depth detection method and device based on point cloud data that can efficiently and accurately extract scribing depth automatically, addressing the aforementioned technical problems.
[0006] Firstly, this application provides a method for detecting the depth of scribing lines on a workpiece based on point cloud data, including:
[0007] Acquire point cloud data of the workpiece under test, and downsample the point cloud data;
[0008] Gaussian filtering based on a scalar domain self-attention mechanism is applied to the downsampled point cloud data to obtain scalar domain enhanced point cloud data;
[0009] Statistical filtering is performed on the scalar domain-enhanced point cloud data to remove outliers;
[0010] The statistically filtered point cloud data is subjected to scalar domain threshold filtering to obtain the scribed region.
[0011] Within the etched area, a straight line model of the etched line is fitted, and a point cloud at the position of the straight line model is obtained;
[0012] A reference plane is fitted to the neighborhood of the point cloud at the location of the straight line model.
[0013] The distance from the point cloud at the location of the straight line model to the reference plane is calculated to obtain the scribing depth.
[0014] In one embodiment, Gaussian filtering based on a scalar-domain self-attention mechanism includes:
[0015] The k-nearest neighbor search algorithm is used to determine each point in the point cloud data. Neighboring points;
[0016] Calculation points With each neighboring point Differences in scalar domains;
[0017] Based on the differences in the scalar domain, calculate the value of each neighbor point. Adaptive attention weights;
[0018] Use the adaptive attention weights for each neighbor point We obtain the point by performing a weighted average over the scalar domain. The filtering results.
[0019] In one embodiment, downsampling the point cloud data includes:
[0020] Determine the smallest 3D grid that surrounds all points in the point cloud data, and use it as the root grid;
[0021] Define the hierarchy of the octree, and based on the hierarchy, calculate the size of the voxel corresponding to each leaf node of the octree, where the voxel is the three-dimensional mesh corresponding to the leaf node;
[0022] Traverse the leaf nodes and replace all points within the voxel with the center of the voxel.
[0023] In one embodiment, fitting a straight line model of the etched line within the etched line region includes:
[0024] Calculate the centroid of the point cloud within the scribed area, and translate the coordinates of all the point clouds to a coordinate system with the centroid as the origin to obtain a centered point cloud;
[0025] The covariance matrix of the centered point cloud is calculated and eigenvalue decomposition is performed using the principal component analysis algorithm to obtain eigenvalues and eigenvectors.
[0026] The eigenvector corresponding to the maximum eigenvalue is selected as the direction vector of the etch line to obtain the straight line model of the etch line.
[0027] In one embodiment, the statistical filtering of the scalar-domain-enhanced point cloud data to remove outliers includes:
[0028] Calculate the average distance and standard deviation between each point in the point cloud data and all points within its neighborhood;
[0029] Calculate the outlier degree of each point in the point cloud data based on the average distance and the standard deviation;
[0030] Points whose outlier degree exceeds a preset threshold are identified as outliers and removed.
[0031] In one embodiment, the outlier is the ratio of the average distance to the standard deviation of all points in the neighborhood.
[0032] In one embodiment, fitting a reference plane model to the neighborhood of the point cloud data at the location of the straight line model includes:
[0033] From the point cloud data of the neighboring region, three non-collinear points are randomly selected to fit a candidate plane;
[0034] Points in the point cloud data of non-neighboring regions whose distance to the candidate plane is less than a preset threshold are designated as interior points of the candidate plane, and the number of interior points is counted.
[0035] The fitting candidate plane operation is iterated, and the candidate plane with the most interior points is selected as the reference plane model.
[0036] In one embodiment, the step of performing scalar domain threshold filtering on the statistically filtered point cloud data to obtain the etched region includes:
[0037] Set a threshold in the scalar domain for the filtered point cloud data;
[0038] Point clouds with scalar domain values below the threshold are selected to obtain the point cloud set of the scribed region.
[0039] Secondly, this application also provides a workpiece scribing depth detection device based on point cloud data, comprising:
[0040] The downsampling module is used to acquire point cloud data of the workpiece under test and to downsample the point cloud data.
[0041] The scalar domain enhancement module is used to perform Gaussian filtering on the downsampled point cloud data based on the scalar domain self-attention mechanism to obtain scalar domain enhanced point cloud data.
[0042] The outlier removal module is used to perform statistical filtering on the scalar domain-enhanced point cloud data to remove outliers.
[0043] The scribing region localization module is used to perform scalar domain threshold filtering on the statistically filtered point cloud data to obtain the scribing region;
[0044] The scribing direction fitting module is used to fit a straight line model of the scribing within the scribing area and obtain a point cloud at the position of the straight line model.
[0045] A reference plane fitting module is used to fit a reference plane to the neighborhood of the point cloud at the location of the straight line model.
[0046] The scribing depth calculation module is used to calculate the distance from the point cloud at the position of the straight line model to the reference plane, and obtain the scribing depth.
[0047] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described in any one of the first aspects above.
[0048] The aforementioned workpiece engraving depth detection method and apparatus based on point cloud data reduces the size of the point cloud data and improves processing efficiency by downsampling the point cloud data; by introducing Gaussian filtering with a fusion self-attention mechanism, it achieves smoothing of the point cloud in the scalar domain, solving the problem of unclear representation and difficulty in precise segmentation of fine features in the scalar domain; by fitting a linear model of the scale lines, it accurately extracts the aggregate features and spatial position of the engraving lines; and by fitting a reference plane, it calculates the perpendicular distance from the engraving line position point to the reference plane, significantly improving the efficiency and accuracy of depth measurement of workpieces with engraving lines. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 This is an application environment diagram of a workpiece scribing depth detection method based on point cloud data in one embodiment;
[0051] Figure 2 This is a flowchart illustrating a workpiece scribing depth detection method based on point cloud data in one embodiment;
[0052] Figure 3 This is a point cloud downsampling processing result based on an octree in one embodiment;
[0053] Figure 4This is a schematic diagram of the scalar domain distribution in one embodiment;
[0054] Figure 5 This is a preliminary screening result achieved by setting a threshold in one embodiment;
[0055] Figure 6 This is a schematic diagram of the Gaussian filtering result fused with the self-attention mechanism in one embodiment;
[0056] Figure 7 This is a filtered 3D coordinate map of the scribed point cloud in one embodiment;
[0057] Figure 8 This is a three-dimensional schematic diagram of the PCA scale line fitting result in one embodiment;
[0058] Figure 9 This is a standard depth variation curve of a workpiece scribing line in one embodiment;
[0059] Figure 10 This is a structural block diagram of a workpiece scribing depth detection device based on point cloud data in one embodiment;
[0060] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0061] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0062] The workpiece scribing depth detection method based on point cloud data provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. The data storage system stores the data that server 104 needs to process. Terminal 102 controls precision measuring equipment such as a line-scan spectral confocal sensor to acquire high-precision, three-dimensional dense point cloud data of the workpiece being measured, and sends the raw data or pre-processed data to server 104. After receiving the data, server 104 executes algorithms such as point cloud downsampling, scalar domain enhancement filtering, outlier removal, scribing positioning and fitting, reference plane fitting, and depth calculation, ultimately outputting the scribing depth measurement result of the workpiece. The data storage system stores the point cloud data, algorithm parameters, and calculation results that server 104 needs to process. This data storage system can be integrated on server 104 or located in the cloud or on other network servers.
[0063] The terminal 102 can be, but is not limited to, various industrial computers, embedded systems, industrial control computers, or special measuring instruments that integrate precision sensor control units. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0064] In one exemplary embodiment, such as Figure 2 As shown, a method for detecting the depth of workpiece scribing lines based on point cloud data is provided, which is then applied to... Figure 1 Taking the server in the example, the explanation includes the following steps S201 to S206. Wherein:
[0065] Step S201: Obtain point cloud data of the workpiece under test and downsample the point cloud data.
[0066] For example, a detection system can be built using a line-scan spectral confocal sensor to acquire point cloud data of the workpiece being tested.
[0067] Because measurements at the micro- and nanoscale require high density of point cloud data, the original point cloud typically contains hundreds of thousands or even hundreds of millions of points. This often leads to high computational complexity and significant memory consumption for data storage and transmission. Therefore, after obtaining the point cloud data of the workpiece under test, the data is downsampled.
[0068] Downsampling is a method to reduce the sampling rate, which can improve processing efficiency while preserving key geometric features by reducing the number of sampling points. Specifically, downsampling can use techniques such as voxel downsampling, random downsampling, and uniform sampling.
[0069] Step S202: Perform Gaussian filtering on the downsampled point cloud data based on the scalar domain self-attention mechanism to obtain scalar domain enhanced point cloud data.
[0070] In this context, the scalar domain refers to the scalar value added to each point in the point cloud data in addition to its spatial coordinates (X, Y, Z), representing the optical information related to color or reflectivity acquired by the spectral confocal sensor. For example, in this embodiment, the point cloud color is obtained by mapping scalar domain information. It can be understood that the differences in material or morphology between the etched and non-etched areas of a workpiece theoretically manifest as differences in the scalar domain. However, in actual measurements, the distribution of this scalar domain is easily affected by environmental noise and appears disordered. Therefore, this method smooths the scalar domain of the point cloud data to enhance the color representation of the etched line positions.
[0071] Since the distribution of point clouds in the scalar domain largely conforms to a normal distribution, Gaussian filtering, as a typical linear smoothing filtering method, can determine the weights through the shape of the Gaussian function and has a good suppression effect on noise that follows a normal distribution. In traditional Gaussian filtering, the Gaussian filter weights only depend on the Mahalanobis distance. Although it can smooth noise, it cannot distinguish points belonging to different regions in the scalar domain, resulting in the inability to distinguish the edges of the scribe lines.
[0072] Therefore, this scheme improves upon Gaussian filtering by incorporating a self-attention mechanism to dynamically adjust the weights of each point on its neighbors. Specifically, for each point in the point cloud data... The difference between the scalar field values of the point and its neighbors is calculated, and attention weights are calculated based on this difference, ensuring that the sum of the weights is 1. A weighted average of the scalar field values of the neighbors is then performed using these weights to obtain the point. The filtering results.
[0073] Set a scalar domain threshold for the smoothed point cloud data, and filter out the point cloud data in the scale line region for further processing.
[0074] Step S203: Perform statistical filtering on the scalar domain enhanced point cloud data to remove outliers.
[0075] Outliers are noise points that deviate significantly from their neighboring point sets in spatial distribution. Even for scalar information-filtered point clouds, outliers may still occur due to uncertainties in manually set thresholds, thus necessitating further outlier removal.
[0076] Since outliers typically exhibit characteristics of being far from dense point cloud clusters and sparsely distributed in space, statistical filters are effective at removing outliers with obvious distributional features. Statistical filters achieve filtering by analyzing the local density of the point cloud: when the local density of the point cloud in a certain region is lower than a set threshold, the points in that region are identified as outliers and removed.
[0077] Step S204: Perform scalar domain threshold filtering on the statistically filtered point cloud data to obtain the scribed region.
[0078] Since the scalar threshold value of the etched area is significantly distinguished from other areas after enhancement, the etched area to be measured can be filtered out by setting a threshold and extracting all points whose scalar threshold value is lower or higher than the threshold.
[0079] Step S205: Within the scribing area, fit a straight line model of the scribing and obtain the point cloud at the position of the straight line model.
[0080] After statistical filtering, the point cloud distribution in the scribed area becomes more regular. To further extract the geometric features of the scribed area, we can perform line fitting by determining the main direction of the point cloud in the scribed area.
[0081] Optionally, Principal Component Analysis (PCA) is used for line fitting. PCA analyzes the spatial distribution of the point cloud in the scribe line region and finds the direction with the largest variance as the first principal component, which is the main direction of the scribe line. Using this method, each scribe line can be fitted to a straight line model with a clear direction. Point cloud data within a certain range near this straight line model is extracted as the precise location point set representing the scribe line, used for subsequent depth calculations.
[0082] Step S206: Fit a reference plane to the neighborhood of the point cloud at the location of the straight line model.
[0083] During point cloud data acquisition, slight etching may occur at the scale line positions due to factors such as processing technology, resulting in a lower Z-coordinate value for the point cloud in that area. Therefore, to reduce the impact of such errors, adjacent areas need to be delineated on both sides of the scale line for fitting and correction to the reference plane.
[0084] For example, the Random Sample Consensus (RANSAC) algorithm is used for plane fitting. RANSAC is an iterative algorithm that can estimate mathematical model parameters from a sample set containing outlier data. Specifically, a neighborhood is defined on both sides of the scribe line determined in step S205, and the RANSAC algorithm is used to fit a model representing the workpiece reference plane in the point cloud of this neighborhood.
[0085] Step S207: Calculate the distance from the point cloud at the position of the straight line model to the reference plane to obtain the scribing depth.
[0086] After determining the reference plane, and combining the position of the straight line model, capture all point clouds at the current scale line position, calculate the corresponding depth value according to the calculation formula from point to plane, and record it.
[0087] In the above method, the point cloud data is simplified by downsampling, which reduces the data size and improves the processing efficiency; by introducing Gaussian filtering with a fusion self-attention mechanism, the scalar domain of the point cloud is smoothed, which solves the problem that fine features are not clearly represented in the scalar domain and are difficult to segment accurately; by fitting the scale line and the reference plane, the vertical distance from the scale line position point to the reference plane is calculated, thereby improving the efficiency and accuracy of depth measurement of workpieces with scale lines.
[0088] In one embodiment, a voxel downsampling implementation based on an octree is provided, specifically including the following steps:
[0089] Step S301: Determine the smallest 3D grid that surrounds all points in the point cloud data, and use it as the root grid.
[0090] Understandably, an octree, as a typical hierarchical spatial partitioning data structure, recursively divides the bounding volume of a scene into eight uniform sub-regions until the number of elements in each sub-node meets a preset threshold or other termination conditions, thereby achieving the orderly organization and management of point clouds. In this structure, each octree node can be regarded as a voxel, realizing spatial compression and structured representation of point cloud data.
[0091] In establishing the octree topology, we first traverse all points and record the extreme values in the X, Y, and Z directions to determine a minimum 3D grid that can enclose all points. The grid size is:
[0092] ;
[0093] Step S302: Set the level of the octree. Based on the level, calculate the size of the voxel corresponding to each leaf node of the octree. The voxel is the three-dimensional mesh corresponding to the leaf node.
[0094] Given an octree with a level d, the voxel mesh size of each leaf node is calculated as follows:
[0095] ;
[0096] Step S303: Traverse the leaf nodes and replace all points within the voxel with the center of the voxel.
[0097] Traverse each leaf node, calculate the voxel center, and replace all points within the entire voxel with the voxel center of the current node to complete voxel downsampling.
[0098] This embodiment reduces the total amount of point cloud data by using voxel downsampling based on octrees, thereby improving the overall processing efficiency. Furthermore, since the algorithm performs uniform sampling of the space, it avoids feature loss that may be caused by random downsampling.
[0099] In an exemplary embodiment, Gaussian filtering based on a scalar domain self-attention mechanism specifically includes the following steps:
[0100] Step S401: Use the k-nearest neighbor search algorithm to determine each point in the point cloud data. The neighboring point.
[0101] In traditional Gaussian filtering, for a given sampling point pi, the filtering result is determined by the weighted average of its neighborhood points:
[0102] ;
[0103] in It is a point The set of neighbors; It is a Gaussian weight function, and its specific expression is:
[0104] ;
[0105] in, denoted as the standard deviation of the Gaussian kernel.
[0106] It can be seen that traditional Gaussian filtering weights rely solely on Mahalanobis distance and cannot distinguish the correlation of other features. Therefore, this scheme improves Gaussian filtering by incorporating a self-attention mechanism to dynamically adjust the weights of each point on its neighbors. This allows the filter to adaptively learn the relationships between points based on their scalar thresholds, resulting in more flexible and structure-sensitive filtering.
[0107] Specifically, the k-nearest neighbor search method is used to find the k neighbors of each point. For each point... Calculate its relationship with each of its neighboring points. Calculate the distance and obtain the adjacency relationship.
[0108] Step S402, calculate points With each neighboring point The difference in scalar domains. Wherein, the difference in scalar domains is... .
[0109] Step S403: Calculate the difference between each neighbor point based on the scalar domain. Adaptive attention weights.
[0110] Attention weights are calculated based on the aforementioned scalar domain differences, and softmax normalization is used to ensure that the sum of the weights is 1. The weight calculation formula is as follows:
[0111] ;
[0112] in, This indicates that the target point is obtained through the k-nearest neighbor search algorithm. The set of points found in the surrounding space that are the k nearest neighbors.
[0113] Step S404, apply adaptive attention weights to each neighbor point We obtain the point by performing a weighted average over the scalar domain. The filtering result is expressed as:
[0114] ;
[0115] In the above embodiments, energy weights are introduced by scalar domain differences, which can enhance the representation of the scribing region in the scalar domain while suppressing random noise, so as to better distinguish the scribing region.
[0116] Even for scalar-domain-enhanced point cloud data, outliers may still occur due to uncertainties in manually set thresholds. Therefore, further outlier removal is necessary. In some embodiments, statistical filtering is performed on the scalar-domain-enhanced point cloud data to remove outliers, specifically including the following steps:
[0117] Step S501: Calculate the average distance and standard deviation between each point in the point cloud data and all points within its neighborhood.
[0118] For each point in the point cloud First, its neighborhood range needs to be determined. There are usually two ways: one is a fixed radius neighborhood: for a given radius r, select all neighborhoods that are adjacent to the given radius r. One approach is to select points whose Euclidean distance is no more than r as the neighborhood; another approach is to select a fixed number of neighborhoods: points with a distance of r from the Euclidean distance of r. The k nearest points form a neighborhood. Let... The neighborhood of a contains k points, and the points The Euclidean distance to the j-th neighboring point is denoted as . Then its average distance It can be represented as:
[0119] ;
[0120] Then, calculate the points. The standard deviation of the distances between points within a neighborhood. It indicates the degree of distance variation between neighboring points, reflecting the smoothness of the point cloud in a local region.
[0121] ;
[0122] in, For point The distance to the j-th point in the neighborhood. It is the average distance of the neighborhood. (Using the average distance of the neighborhood) and standard deviation To determine whether point Pi is an outlier.
[0123] Step S502: Calculate the outlier degree of each point in the point cloud data based on the mean distance and standard deviation.
[0124] In the process of outlier identification, the degree of anomalousness of each point is measured by calculating its outlier degree. It is understandable that there can be various designs for calculating the outlier degree. For example, the outlier degree is defined as the ratio of the average distance to the standard deviation within the point's neighborhood.
[0125] Step S503: Points with outlier scores exceeding a preset threshold are identified as outliers and removed.
[0126] The outlier score of each point is calculated and compared with a preset threshold T. If the outlier score of a point exceeds the threshold, the point is identified as an outlier and removed from the point cloud data; otherwise, it is retained as a normal point.
[0127] The statistical filtering in the above embodiments can effectively remove noise points in point cloud data that exhibit abnormal spatial distribution, thereby significantly improving the accuracy of scale line positioning and reference plane fitting.
[0128] After statistical filtering, the point cloud distribution in the scribed area becomes more regular. To further extract its geometric features and fit a straight line model, the PCA algorithm is used to determine the main direction of the point cloud and perform straight line fitting.
[0129] In an exemplary embodiment, a PCA-based method for fitting a scribed line model is provided, specifically including the following steps:
[0130] Step S601: Calculate the centroid of the point cloud within the scribing area, and translate the coordinates of all point clouds to a coordinate system with the centroid as the origin to obtain a centered point cloud.
[0131] Translate all point cloud coordinates to a coordinate system with the centroid as the origin to eliminate the effect of the overall offset, and obtain the centered points:
[0132] ;
[0133] Step S602: Using the principal component analysis algorithm, calculate the covariance matrix of the centered point cloud and perform eigenvalue decomposition to obtain eigenvalues and eigenvectors.
[0134] ;
[0135] ;
[0136] in, Represents the j-th eigenvalue. This represents the corresponding feature vector.
[0137] Step S603: Select the eigenvector corresponding to the maximum eigenvalue as the direction vector of the scribing line to obtain the straight line model of the scribing line.
[0138] It is understandable that the eigenvector represents the main direction of the point cloud distribution, while the eigenvalue reflects the variance in that direction, i.e., the degree of dispersion of the data in that direction. By selecting the eigenvector corresponding to the largest eigenvalue as the direction vector of the tick mark, a straight-line fit of the tick mark can be achieved.
[0139] In an exemplary embodiment, to reduce the low z-value of the point cloud caused by slight etching at the scale line position, a neighborhood region with a step size m is defined on both sides of the scale line, and the reference plane is fitted and corrected based on the RANSAC algorithm. Specifically, the following steps are included:
[0140] Step S701: Randomly select three non-collinear points from the point cloud data of the neighboring region to fit a candidate plane.
[0141] RANSAC is a typical robust estimation algorithm that can effectively extract the best model that conforms to the distribution of most data by performing random sampling and model estimation on datasets containing noise and outliers.
[0142] First, randomly select three non-collinear points from the point cloud data, denoted as _____. , , Using the selected sample n, a planar model S is fitted, and the equation of the plane S is Ax + By + Cz + D = 0.
[0143] Where (A, B, C) are the normal vectors of the plane. Normal vectors can be obtained through the cross product of vectors:
[0144] ;
[0145] ;
[0146] ;
[0147] The equation of the plane is:
[0148] ;
[0149] For all other points in the point cloud, calculate their distance to the current plane. The distance di from point Pi(xi,yi,zi) to the plane Ax+By+Cz+D=0 can be calculated using the following formula:
[0150] .
[0151] Step S702: Points in the point cloud data of non-neighboring areas whose distance to the candidate plane is less than a preset threshold are taken as interior points of the candidate plane, and the number of interior points is counted.
[0152] If the distance is less than the preset threshold ε, then the point is considered to be an interior point of the current plane.
[0153] Step S703: Iterate the fitting candidate plane operation and select the candidate plane with the most interior points as the reference plane model.
[0154] By counting the number of interior points in the current model and comparing it with the optimal model obtained in previous iterations, the model with the most interior points is retained as the new optimal model. This iteration is repeated until the set number of iterations is reached, thus obtaining the final optimal planar model.
[0155] After determining the optimal plane, all point clouds are projected onto this plane. During projection, the x and y coordinates of a point are taken as the planar coordinates of the projected point, while its z coordinate represents the Euclidean distance from the point to the plane. This method not only accurately fits the reference plane but also provides a unified reference benchmark for subsequent scale line depth calculations.
[0156] In a preferred embodiment, the method of the present invention is described in detail using the detection of the scribing depth of a micro / nano-scale scraper fineness gauge as a specific application scenario.
[0157] Specifically, in this embodiment, a single-slot scraper fineness gauge with a range of 0-25μm is used as the workpiece to be calibrated. The data acquisition platform is a FocalSpec LCI401 line scan spectral confocal sensor with an acquisition interval of 0.002mm in the X-axis direction and an exposure parameter of 200.
[0158] Step S1: Obtain point cloud data of the workpiece under test, and perform voxel downsampling on the point cloud data based on octree.
[0159] The visualization results of the original point cloud data are as follows Figure 3 As shown in (a) above, the result after octree downsampling is as follows: Figure 3 As shown in (b) of the diagram, the original point cloud contained 210,272,271 points. After downsampling, the number of points was reduced to 25,550,440. Furthermore, magnifying the visualization 50 times reveals a significant reduction in data size, while the downsampled point cloud still retains its main structure and geometric features. This achieves the goal of effectively reducing data volume while preserving key morphological information. This not only improves the computational efficiency of subsequent processing but also provides a feasibility guarantee for the application of the algorithm in large-scale point cloud scenarios.
[0160] Step S2: Perform Gaussian filtering on the downsampled point cloud data based on the scalar domain self-attention mechanism to obtain scalar domain enhanced point cloud data.
[0161] Depend on Figure 4It can be seen that the point cloud of the tick mark region is assigned blue based on the scalar domain information using the built-in Jet mapping function of the Open3D library. Opening the point cloud file in CloudCompare software reveals that the tick mark region exhibits values below 50 in the scalar domain. Preliminary filtering of results by setting a threshold is shown below. Figure 5 As shown, the scale line area and the surrounding area have limited distinguishability in the scalar domain. The non-scale line area still has a lot of noise and is close to the scale line area in the scalar domain. Therefore, in the process of scale line positioning, it is necessary to enhance the difference between this part of the area and other areas as much as possible.
[0162] A Gaussian filter incorporating a self-attention mechanism is introduced to filter the scalar domain of the point cloud. The resulting scalar domain distribution histogram is shown below. Figure 6 As shown. Among them, Figure 6 (a) in the figure is the scalar domain distribution histogram of the original point cloud; Figure 6 (b) in the figure is the scalar domain distribution histogram of the point cloud after traditional Gaussian filtering; Figure 6 (c) in the figure is the scalar domain distribution histogram of the point cloud after bilateral filtering; Figure 6 (d) in the figure is the scalar domain distribution histogram of the point cloud after traditional Gaussian filtering + bilateral filtering; Figure 6 In the figure (e), the scalar domain distribution histogram of the point cloud after Gaussian filtering by the fusion self-attention mechanism in this invention is shown.
[0163] Depend on Figure 6 As can be seen, when comparing the results of the above methods with those of traditional methods, Gaussian filtering with self-attention mechanism is superior in scalar domain discrimination in the scale line region. It can more effectively amplify the ratio of the scalar domain of the point cloud in the scale line region and highlight the scalar characteristics of the scale line position.
[0164] Step S3: Perform statistical filtering on the scalar domain-enhanced point cloud data to remove outliers.
[0165] Based on this, point clouds at the scale line positions are filtered out by setting a scalar domain threshold, and statistical filtering is further used to remove outliers, thus obtaining cleaner scale line point cloud data. The filtered scale line point cloud is as follows: Figure 7 As shown, it can clearly characterize the geometric features of the scale lines, providing a data foundation for subsequent scale line fitting and reference plane calculation.
[0166] Step S4: Perform scalar domain threshold filtering on the statistically filtered point cloud data to obtain the scribed region.
[0167] Step S5: Within the scribing area, use the PCA algorithm to fit a straight line model of the scribing and obtain the point cloud at the location of the straight line model.
[0168] Using the PCA line fitting algorithm, multiple scale lines are obtained by fitting the filtered scribe point cloud. The fitting results are as follows: Figure 8 As shown.
[0169] Step S6: Use the RANSAC algorithm to fit a reference plane to the neighborhood of the point cloud at the location of the straight line model.
[0170] Step S7: Calculate the distance from the point cloud at the position of the straight line model to the reference plane to obtain the scribing depth.
[0171] After fitting the reference plane for the tick mark position using the RANSAC plane fitting algorithm, and combining it with the x-value of the tick mark fitted by the PCA algorithm in the previous step, all point clouds at the current tick mark position are captured. Based on the formula for calculating the point-to-plane distance, the corresponding depth value is calculated and recorded. All recorded depth values for each tick mark position are then plotted as a depth variation curve, as shown in the image. Figure 9 As shown.
[0172] The point cloud processing method described in the above embodiments was used to process the scanned 0~25μm scraper fineness gauge point cloud data. The corresponding values for each scale line position are shown in Table 1.
[0173] Table 1
[0174]
[0175] According to the relevant provisions of the national standard JJG905-2010, the indication error of a scraper fineness gauge with a single-slot range of 0~25μm should not exceed ±1.5μm. As can be seen from the data in the table, the detection accuracy of this method can meet the relevant provisions of the national standard.
[0176] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0177] Based on the same inventive concept, this application also provides a workpiece scribing depth detection device based on point cloud data for implementing the method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more device embodiments provided below can be found in the limitations of the workpiece scribing depth detection method based on point cloud data described above, and will not be repeated here.
[0178] In one exemplary embodiment, such as Figure 10 As shown, a workpiece scribing depth detection device 800 based on point cloud data is provided, including: a downsampling module 801, a scalar domain enhancement module 802, an outlier removal module 803, a scribing region positioning module 804, a scribing direction fitting module 805, a reference plane fitting module 806, and a scribing depth calculation module 807, wherein:
[0179] The downsampling module 801 is used to acquire point cloud data of the workpiece under test and downsample the point cloud data.
[0180] The scalar domain enhancement module 802 is used to perform Gaussian filtering on the downsampled point cloud data based on the scalar domain self-attention mechanism to obtain scalar domain enhanced point cloud data.
[0181] The outlier removal module 803 is used to perform statistical filtering on the scalar domain enhanced point cloud data to remove outliers.
[0182] The scribing region localization module 804 is used to perform scalar domain threshold filtering on the statistically filtered point cloud data to obtain the scribing region.
[0183] The scribing direction fitting module 805 is used to fit a straight line model of the scribing within the scribing area and obtain a point cloud at the position of the straight line model.
[0184] The reference plane fitting module 806 is used to fit a reference plane to the neighborhood of the point cloud at the position of the straight line model.
[0185] The scribing depth calculation module 807 is used to calculate the distance from the point cloud at the position of the straight line model to the reference plane to obtain the scribing depth.
[0186] Each module in the aforementioned workpiece scribing depth detection device based on point cloud data can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.
[0187] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores point cloud data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network. When the computer program is executed by the processor, it implements a workpiece scribing depth detection method based on point cloud data.
[0188] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0189] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0190] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0191] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0192] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for detecting the depth of scribing lines on a workpiece based on point cloud data, characterized in that, The method includes: Acquire point cloud data of the workpiece under test, and downsample the point cloud data; Using the k-nearest neighbor search algorithm, determine each point in the downsampled point cloud data. Neighboring points; Calculation points With each neighboring point The difference in scalar domains, among which, , for The set of points consisting of the k neighboring points; Based on the differences in the scalar domain, calculate the value of each neighbor point. Adaptive attention weights; Use the adaptive attention weights for each neighbor point We obtain the point by performing a weighted average over the scalar domain. The filtered result is used as scalar domain augmented point cloud data; Statistical filtering is performed on the scalar domain-enhanced point cloud data to remove outliers; The statistically filtered point cloud data is subjected to scalar domain threshold filtering to obtain the scribed region. Within the etched area, a straight line model of the etched line is fitted, and a point cloud at the position of the straight line model is obtained; A reference plane is fitted to the neighborhood of the point cloud at the location of the straight line model. The distance from the point cloud at the location of the straight line model to the reference plane is calculated to obtain the scribing depth.
2. The method according to claim 1, characterized in that, The downsampling of the point cloud data includes: Determine the smallest 3D grid that surrounds all points in the point cloud data, and use it as the root grid; Define the hierarchy of the octree, and based on the hierarchy, calculate the size of the voxel corresponding to each leaf node of the octree, where the voxel is the three-dimensional mesh corresponding to the leaf node; Traverse the leaf nodes and replace all points within the voxel with the center of the voxel.
3. The method according to claim 1, characterized in that, The method of fitting a straight line model for the etched line within the etched line area includes: Calculate the centroid of the point cloud within the scribed area, and translate the coordinates of all the point clouds to a coordinate system with the centroid as the origin to obtain a centered point cloud; The covariance matrix of the centered point cloud is calculated and eigenvalue decomposition is performed using the principal component analysis algorithm to obtain eigenvalues and eigenvectors. The eigenvector corresponding to the maximum eigenvalue is selected as the direction vector of the etch line to obtain the straight line model of the etch line.
4. The method according to claim 1, characterized in that, The statistical filtering of the scalar-domain enhanced point cloud data to remove outliers includes: Calculate the average distance and standard deviation of each point in the scalar domain-enhanced point cloud data and all points within its neighborhood; The outlier degree of each point in the scalar domain augmented point cloud data is calculated based on the average distance and the standard deviation. Points whose outlier degree exceeds a preset threshold are identified as outliers and removed.
5. The method according to claim 4, characterized in that, The outlier is the ratio of the average distance to the standard deviation of all points in the neighborhood.
6. The method according to claim 1, characterized in that, Fitting a reference plane model to the neighborhood of the point cloud data at the location of the straight line model includes: From the point cloud data of the neighboring region, three non-collinear points are randomly selected to fit a candidate plane; Points in the point cloud data of non-neighboring regions whose distance to the candidate plane is less than a preset threshold are designated as interior points of the candidate plane, and the number of interior points is counted. The fitting candidate plane operation is iterated, and the candidate plane with the most interior points is selected as the reference plane model.
7. The method according to claim 1, characterized in that, The scalar domain threshold filtering of the statistically filtered point cloud data to obtain the scribed region includes: Set a threshold for the scalar domain for the statistically filtered point cloud data; Point clouds with scalar domain values below the threshold are selected to obtain the point cloud set of the scribed region.
8. A workpiece scribing depth detection device based on point cloud data, characterized in that, The device includes: The downsampling module is used to acquire point cloud data of the workpiece under test and to downsample the point cloud data. The scalar domain augmentation module is used to determine each point in the downsampled point cloud data using the k-nearest neighbor search algorithm. Neighboring points; Calculation points With each neighboring point The difference in scalar domains, among which, , for The set of points consisting of k neighboring points; based on the difference in the scalar domain, calculate the value of each neighboring point. Adaptive attention weights; using the adaptive attention weights for each neighbor point We obtain the point by performing a weighted average over the scalar domain. The filtered result is used as scalar domain augmented point cloud data; The outlier removal module is used to perform statistical filtering on the scalar domain-enhanced point cloud data to remove outliers. The scribing region localization module is used to perform scalar domain threshold filtering on the statistically filtered point cloud data to obtain the scribing region; The scribing direction fitting module is used to fit a straight line model of the scribing within the scribing area and obtain a point cloud at the position of the straight line model. A reference plane fitting module is used to fit a reference plane to the neighborhood of the point cloud at the location of the straight line model. The scribing depth calculation module is used to calculate the distance from the point cloud at the position of the straight line model to the reference plane, and obtain the scribing depth.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Plate surface defect detection method and system based on image and point cloud data fusion
CN115496746A
Scribing groove detection method and device
CN118781111A