Three-dimensional point cloud data processing method and application thereof, electronic device, and storage medium

Through the processing method of 3D point cloud data, combined with the 2D image algorithm to assist the 3D image algorithm, the problem of large data volume and long processing time in 3D visual inspection is solved, and efficient 3D object measurement and arc detection are achieved.

CN114612412BActive Publication Date: 2024-08-23HANGZHOU ADAPTIVE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210215815.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-07
Publication Date
2024-08-23
Estimated Expiration
2042-03-07

AI Technical Summary

Technical Problem

When the existing three-dimensional visual inspection technology processes the height, width and arc measurement of three-dimensional objects, the amount of data is large, the processing is time-consuming, and the efficiency is low. It is also difficult to circle the area of ​​interest, resulting in low detection efficiency.

Method used

The three-dimensional point cloud data processing method is adopted, and the three-dimensional point cloud data is obtained through a line scan camera, and the straight-through filtering and two-dimensional mapping are performed. The two-dimensional image algorithm is used to assist the three-dimensional image algorithm, and the point cloud data is registered and the weld seam measurement is performed to improve the Data processing speed and efficiency.

Benefits of technology

It significantly improves the processing speed and efficiency of 3D point cloud data, improves the accuracy and efficiency of weld measurement and arc detection, and simplifies the selection process of areas of interest.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114612412B
    Figure CN114612412B
Patent Text Reader

Abstract

The present invention discloses a method for processing three-dimensional point cloud data and its application, electronic device and storage medium. The processing method comprises: S1, performing straight-through filtering on the point cloud data of a workpiece to be measured and a standard workpiece; S2, taking the distance value from a line scan camera to each point cloud as a pixel value, obtaining a first depth image corresponding to the point cloud data of the workpiece to be measured and a second depth image corresponding to the point cloud data of the standard workpiece; S3, calculating the offset and rotation angle of the first depth image and the second depth image, and aligning the point cloud data of the workpiece to be measured accordingly; the difficulty of processing three-dimensional point cloud data is reduced, and the speed and efficiency of data processing are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of automated detection technology, and in particular relates to a three-dimensional point cloud data processing method and application thereof, electronic equipment, and storage medium. Background Art

[0002] The welds of the product mainly include minimum width, maximum width, average width, minimum height, maximum height and average height, etc. By evaluating the difference between the width and height and the standard workpiece, it can be determined whether the current workpiece is qualified; the curvature of the product mainly includes upper curvature, lower curvature, etc. By evaluating the difference between the curvature and the standard curvature, it can be determined whether the current workpiece is qualified.

[0003] At present, the inspection of welds and curvature is mainly divided into manual inspection and automatic inspection. In manual inspection, workers use standard tools to measure and record, and finally make statistical comparisons on the data. The inspection efficiency is low, and the workers' work accuracy will continue to decline with the increase of work intensity and working time. Automatic inspection mainly obtains the surface data of the product through parameter measurement technology, and then performs statistics and calculations on the surface data of the product according to the corresponding algorithm to obtain the height parameters, width parameters and curvature parameters of the area of ​​interest.

[0004] Among the existing product parameter measurement technologies, there are two methods: two-dimensional visual inspection and three-dimensional visual inspection. When using traditional two-dimensional visual inspection methods to inspect three-dimensional objects, due to the complex structure and numerous parameters of three-dimensional objects, there will be great limitations, and it is difficult to measure the height, width and other information of three-dimensional objects; three-dimensional visual inspection technology uses a lot of advanced visual processing technologies and object imaging equipment, and has the characteristics of fast and accurate measurement of the height, width and curvature of three-dimensional objects. However, compared with two-dimensional image algorithms, three-dimensional image algorithms process a large amount of data, take a long time to process, have low efficiency, and it is difficult to circle the area of ​​interest in three-dimensional space. Summary of the invention

[0005] The purpose of an embodiment of the present invention is to provide a method for processing three-dimensional point cloud data and its use, which obtains three-dimensional point cloud data of a test piece through a line scan camera, performs a series of processing on the point cloud data, simplifies the three-dimensional point cloud data and performs two-dimensional mapping, thereby facilitating statistical calculations of areas of interest in the three-dimensional point cloud data, reducing the difficulty of processing three-dimensional point cloud data, and improving the speed and efficiency of data processing.

[0006] The embodiment of the present invention also aims to provide an electronic device and a storage medium.

[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is a method for processing three-dimensional point cloud data, comprising the following steps:

[0008] S1, obtaining the point cloud data of the workpiece to be tested and the point cloud data of the standard workpiece, and performing straight-through filtering on the point cloud data so that its Z-axis coordinate is 0 to 1;

[0009] S2, using the distance value from the line scan camera to each point cloud as a pixel value, to obtain a first depth image corresponding to the point cloud data of the workpiece to be tested and a second depth image corresponding to the point cloud data of the standard workpiece;

[0010] S3, calculating an offset and a rotation angle between the first depth image and the second depth image, and registering the point cloud data of the workpiece to be measured accordingly.

[0011] Further, the S3 comprises the following steps:

[0012] S31, using downsampling to respectively acquire a first image pyramid of the first depth image and a second image pyramid of the second depth image;

[0013] S32, using a rectangular frame to enclose an area with obvious texture features in the bottom layer of the first image pyramid as a region of interest ROI1, and converting the coordinates, width and height of the region of interest ROI1 layer by layer to obtain the region of interest ROI in each layer of the first image pyramid i , and ROI i The pixel value and feature vector of each pixel point in the

[0014] ROI i =(P i (x i ,y i ), W i , H i ), where i represents the number of layers of the first image pyramid and the second image pyramid, i=1,…,I, I represents the total number of layers of the first image pyramid and the second image pyramid, the Ith layer is the highest layer, P i (x i ,y i ) represents the upper left corner of the region of interest at the i-th level of the first image pyramid, W i represents the width of the region of interest at the i-th level of the first image pyramid, H i Represents the height of the region of interest at the i-th level of the first image pyramid;

[0015] S33, taking each pixel in the highest layer of the second image pyramid as the center point, and taking W I , H I Construct matching regions for width and height, obtain new matching regions for each matching region at different rotation angles, and use each matching region and its new matching region at different rotation angles as elements to form a data set;

[0016] According to the highest level region of interest ROI of the first image pyramid I The pixel values ​​and feature vectors of the inner pixels are obtained with ROI I The best matching area in the corresponding data set takes its center point as the best matching point, expands the best matching point and converts its coordinate value to obtain the best matching point set of the I-1 layer of the second image pyramid;

[0017] S34, traverse each optimal matching point in the I-1th layer of the second image pyramid, take each optimal matching point as the center, and calculate W I-1 , H I-1 Construct matching regions for width and height, and obtain new matching regions for each matching region at different rotation angles to form a matching region data set;

[0018] According to the region of interest ROI of the I-1 layer of the first image pyramid I-1 The pixel value and feature vector of the inner pixel point are obtained to obtain the region of interest ROI in the I-1 layer of the second image pyramid I-1 Corresponding to the best matching area and the best matching point, the best matching point is expanded and the coordinate value is converted to obtain the best matching point set of the I-2 layer of the second image pyramid;

[0019] Repeat S34 to obtain the coordinate value of the best matching point in the bottom layer of the second image pyramid;

[0020] S35, calculating an offset and a rotation angle of the first depth image relative to the second depth image according to the coordinate value of the center point in the region of interest ROI1 and the coordinate value of the best matching point in the bottom layer of the second image pyramid;

[0021] S36, obtaining a transformation matrix between the point cloud data of the workpiece to be measured and the point cloud data of the standard workpiece according to the offset and the rotation angle, and aligning the point cloud data of the workpiece to be measured based on the transformation matrix.

[0022] Furthermore, the process of obtaining the optimal matching area is as follows:

[0023] Traverse each optimal matching point in the i-th layer of the second image pyramid, take each optimal matching point as the center, and use W i , H i Construct matching regions for width and height, and obtain new matching regions for each matching region at different rotation angles to form a matching region data set;

[0024] Calculate the matching regions and the region of interest ROI in the matching region data set i If all matching regions are similar to ROI i If the similarity of the matching area is less than or equal to 0.9, the matching fails. iIf the similarity is greater than 0.9, the matching area is the optimal matching area, and its center point is the optimal matching point.

[0025] Furthermore, the process of expanding the optimal matching point and converting the coordinate values ​​is as follows:

[0026] The best matching point in the i-th layer of the second image pyramid is expanded to obtain right The coordinate values ​​of each matching point in the second image pyramid are converted to obtain the optimal matching point set U of the previous depth image. The elements in the set U are P i-1 (m i-1 ,n i-1 ,θ);

[0027] The coordinate value conversion formula is as follows:

[0028] P i-1 (m i-1 ,n i-1 ,θ)=k·P i (m i ,n i ,θ)

[0029] Where P i (m i ,n i ,θ) represents the optimal matching point of the i-th layer of the image pyramid, P i-1 (m i-1 ,n i-1 ,θ) represents the optimal matching point of the i-1th layer of the image pyramid, k represents the downsampling coefficient when constructing the second image pyramid, k = 2, (m i ,n i ) indicates P i (m i ,n i ,θ) coordinate value, (m i-1 ,n i-1 ) indicates P i-1 (m i-1 ,n i-1 ,θ), where θ represents the rotation angle of the matching area.

[0030] Furthermore, the similarity S is calculated as follows:

[0031]

[0032]

[0033] M i 、N i Denote the total number of rows and columns of pixels in the matching area of ​​the second image pyramid, DerXR ,DerY R Represents pixel Pixel R (x i ,y i ) vector in the X and Y directions, DerX M ,DerY M Represents pixel Pixel M (m i ,n i ) Vectors in the X and Y directions, Pixel M (m i ,n i ) represents the coordinates in the matching area (m i ,n i ) R (x i ,y i ) represents the coordinate (m i ,n i ) Corresponding ROI i Pixel point in, Sim(x i ,y i ) means Pixel M (m i ,n i ) and Pixel R (x i ,y i )The similarity between two pixels.

[0034] The purpose of the three-dimensional point cloud data processing method is to measure the weld in the workpiece to be measured, and specifically includes the following steps:

[0035] S41, generating a third depth image according to the registered point cloud data of the workpiece to be measured, wherein the region of interest in the third depth image is the weld, and the third depth image is divided into a left region and a right region with the weld as the center line;

[0036] S42, mapping the left area and the right area back to the point cloud data to obtain the point cloud data on the left side and the point cloud data on the right side of the weld;

[0037] S43, performing plane fitting on the point cloud data using a RANSAC algorithm to obtain a left fitting plane corresponding to the point cloud data on the left side of the weld and a right fitting plane corresponding to the point cloud data on the right side;

[0038] S44, obtaining the point cloud data of the weld area through a coordinate conversion algorithm, and calculating the distance d from each point cloud data in the weld area to the left fitting plane li , the distance d of the right fitting plane ri , according to the distance d liand distance d ri Filter the point cloud data to obtain the final point cloud data of the weld area;

[0039] S45, traverse each point cloud in the weld point cloud data, count the distribution of each point cloud on the X-axis, Y-axis, and Z-axis, and obtain the width, length, and height information of the weld.

[0040] The purpose of the three-dimensional point cloud data processing method is to measure the arc curvature of the workpiece to be measured, and specifically includes the following steps:

[0041] S51, filtering the Z-axis information of the point cloud data of the workpiece to be measured, and projecting it onto the XOY plane to obtain plane point cloud data;

[0042] S52, generating a fourth depth image corresponding to the plane point cloud data, performing grayscale and binarization processing on the fourth depth image to obtain a binary image of the fourth depth image, using a Canny operator to extract edge information in the binary image to obtain a set of arc pixel points;

[0043] S53, obtaining the coordinate values ​​of the arc pixel points, and performing curve fitting using the least square method to obtain a curve fitting equation;

[0044] S54, calculating the curvature of each arc pixel point to obtain the curvature information of the workpiece to be measured.

[0045] An electronic device comprises a processor, a memory and a communication bus, wherein the processor and the memory communicate with each other via the communication bus;

[0046] Memory, used to store computer programs;

[0047] The processor is used to implement the above method steps when executing the program stored in the memory.

[0048] A computer-readable storage medium stores a computer program, and the computer program implements the above method steps when executed by a processor.

[0049] The beneficial effects of the present invention are: using a three-dimensional image algorithm to solve the defects of a two-dimensional image algorithm in measuring the shape of objects in space, and using a two-dimensional image algorithm to assist a three-dimensional image algorithm to improve the efficiency of the three-dimensional image algorithm; image acquisition uses line structured light to improve stability and accuracy, and uses the positioning technology of a two-dimensional image algorithm to assist in the registration of three-dimensional point cloud data, which greatly improves the registration speed of three-dimensional point cloud data, and uses the mapping relationship between two-dimensional images and three-dimensional point cloud data to realize the selection of areas of interest, which greatly improves the efficiency of weld measurement and curvature detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0051] Figure 1 is a flow chart of an embodiment of the present invention.

[0052] Figure 2 It is the flow chart of the registration of the point cloud data to be tested.

[0053] Figure 3 The figure is a flow chart of measuring a weld according to an embodiment of the present invention.

[0054] Figure 4 It is a flow chart of measuring radian according to an embodiment of the present invention. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0056] like Figure 1 As shown, the method for processing three-dimensional point cloud data specifically includes the following steps:

[0057] Step 1: Take the platform where the bottom surface of the workpiece is located as the XOY plane and the vertical direction of the platform as the Z axis to establish a coordinate system, and use a line scan camera to scan the workpiece to be measured and the standard workpiece to obtain the point cloud data of the workpiece to be measured and the standard workpiece.

[0058] Step 2: Since the structured light of the line scan camera is linear, the distribution of the original point cloud data in the X and Y directions is within a limited range, and the distribution along the Z axis is wider. There is a lot of redundant data and noise data in the Z axis direction, which reduces the accuracy and efficiency of using the data for weld measurement and curvature detection. Therefore, pass-through filtering is used to filter and simplify the point cloud data of the workpiece to be tested and the point cloud data of the standard workpiece, respectively.

[0059] When passing through the filter, the Z-axis filter range of the point cloud data is set to 0-1, which can not only retain most of the features of the point cloud data, but also greatly simplify the original point cloud data.

[0060] Step 3: In order to speed up the selection and registration of the subsequent region of interest, the point cloud data of the workpiece to be tested is mapped to the first depth image, and the point cloud data of the standard workpiece is mapped to the second depth image. The specific process is as follows:

[0061] Set the parameters of the image collector and use the library functions in the PCL point cloud library to generate a depth image at a specific angle, that is, obtain the distance from the line scan camera to each point cloud in the point cloud data, and the sum of the squares of the specific values ​​of the point cloud in three dimensions at the default shooting angle of the camera. Use the distance value as the pixel value of each pixel in the depth image to obtain the first depth image corresponding to the point cloud data of the workpiece to be tested and the second depth image corresponding to the point cloud data of the standard workpiece.

[0062] The parameters include: 1. Select the angle of the image collector, i.e., the pose (sensor_pose), which is generally set by default to the angle taken by the line scan camera. The purpose of setting this parameter is to obtain the depth image of the workpiece at a top-down angle. If the measurement requirements change, the depth image of the workpiece at a front or side view angle can be obtained by rotating the 3D point cloud model on the preview page; 2. Set the angle resolution, which is the size of the angle corresponding to a pixel in the depth image; 3. Set the horizontal maximum sampling angle and the vertical maximum sampling angle of the depth sensor. Due to the characteristics of the line scan camera, there is no 3D point cloud data on the back side of the sensor, so the horizontal maximum sampling angle and the vertical maximum sampling angle are both set to 180°; 4. Set the default coordinate system to CAMERA_FRAME; 5. When obtaining the depth image depth, the influence level of the neighboring points on the query point distance value is set to 5, which means that the average value of all points within 5cm in the Z-axis buffer is used as the pixel value of the pixel point to ensure that data is not lost; 6. Set the minimum acquisition distance, which is generally set to 0 by default, indicating that the area smaller than the current value in the Z-axis direction is the blind area of ​​the image collector and is not processed.

[0063] In general, the depth image processing can be performed directly on the data scanned by the line scan camera. If the data collected by the line scan camera is not ideal, or if it is desired to obtain the depth image of the collected data at other angles, it can be obtained by adjusting the above parameters.

[0064] Step 4: Use a two-dimensional image algorithm to calculate the offset and rotation angle of the first depth image compared to the second depth image, such as Figure 2 The specific process of registering the point cloud data to be measured is shown below:

[0065] Step 41, by downsampling, a first image pyramid of the first depth image and a second image pyramid of the second depth image are respectively generated. The two image pyramids have the same number of layers, and the bottom layer thereof is the original depth image, i.e., the first depth image and the second depth image. The higher the number of layers of the image pyramid, the fewer the number of pixels in the depth image. The size of each layer of the depth image in the image pyramid is 1 / 2 of the lower layer of the depth image. Reducing the number of layers of the image pyramid will slow down the processing speed of the algorithm and improve the calculation accuracy. Increasing the number of layers of the image pyramid can appropriately improve the processing speed of the algorithm, but the feature information loss in the depth image is relatively large, and the processing result is poor. Considering the processing speed and effect of the algorithm comprehensively, the number of layers of the image pyramid is set within 2-6 layers.

[0066] Step 42, use a rectangular frame to enclose the area with obvious texture features in the bottom layer of the first image pyramid as the region of interest ROI1, and use formula (1) to convert the region of interest ROI1 layer by layer to obtain the region of interest ROI of each layer in the first image pyramid i :

[0067]

[0068] Region of interest ROI in the i-th level of the first image pyramid i =(P i (x i ,y i ), W i , H i ), where i represents the number of layers of the image pyramid, I represents the total number of layers of the image pyramid, i = 1, 2, ..., I, P i (x i ,y i ) represents the upper left corner of the region of interest at the i-th level of the first image pyramid, P i+1 (x i+1 ,y i+1 ) represents the upper left corner of the region of interest at the i+1th level of the first image pyramid, W i represents the width of the region of interest at the i-th level of the first image pyramid, W i+1 represents the width of the region of interest at the i+1th level of the first image pyramid, H i represents the height of the region of interest at the i-th level of the first image pyramid, H i+1 represents the height of the region of interest at the i+1th layer of the first image pyramid, k represents the downsampling coefficient when constructing the first image pyramid, and k=2.

[0069] Step 43: Obtain the region of interest ROI in each layer of the first image pyramid i The pixel value Px of each pixel in iAnd use the Sobel operator to process the depth image to obtain the feature vector Ve of each pixel i .

[0070] Step 44, construct a matching region in the highest level of the second image pyramid, according to the region of interest ROI I The pixel values ​​and feature vectors of the internal pixels are obtained to obtain the region of interest ROI I The best matching area with the highest similarity takes its center point as the best matching point.

[0071] Step 45: In order to avoid calculation errors, the obtained optimal matching points are expanded to obtain According to the best matching point matched in the highest layer, the coordinate value is converted to obtain the best matching point set U of the previous layer in the second image pyramid. The elements in the set U are P I-1 (m I-1 ,n I-1 ,θ);

[0072] Similarly, in the I-1th layer of the second image pyramid, with each pixel in the optimal matching point set U as the center, and W I-1 , H I-1 Construct matching regions for width and height, and form a new matching region set from all matching regions and their matching regions at different rotation angles.

[0073] Repeat the similarity calculation to obtain a new optimal matching point, expand the newly obtained optimal matching point and convert its coordinate value until it reaches the bottom layer of the second image pyramid, and obtain the coordinate value P of the optimal matching point in the bottom layer. res (m res , n res ,θ res ).

[0074] The coordinate value conversion formula is as follows:

[0075] P i-1 (m i-1 ,n i-1 ,θ)=k·P i (m i ,n i ,θ)

[0076] Where P i (m i ,n i ,θ) represents the optimal matching point of the i-th layer of the image pyramid, P i-1 (m i-1 ,n i-1 ,θ) represents the optimal matching point of the i-1th layer of the image pyramid, k represents the downsampling coefficient when constructing the second image pyramid, k = 2.

[0077] Step 46: according to the coordinate value P of the center point in the region of interest ROI1 roi (x roi ,y roi ,θ roi ) and the coordinate value P of the best matching point in the bottom layer of the second image pyramid res (m res ,n res ,θ res ), calculate the offset and rotation angle r of the first depth image compared to the second depth image:

[0078] offset=(m res -x roi ,n res -y roi )

[0079] r = θ res -θ roi

[0080] Since the rotation of the workpiece to be measured only occurs on the plane where the X-axis and the Y-axis are located, the offset of the first depth image compared to the second depth image can be rewritten as D(a, b, c), D(a, b, c) = (offset x ,offset y ,0), where offset x Indicates the offset of the workpiece in the X direction, offset y Indicates the offset of the workpiece in the Y direction, offset x =m res -x roi , offset y =n res -y roi .

[0081] The transformation matrix is ​​constructed according to the offset D(a, b, c) and the rotation angle of the workpiece to be measured on the Y axis as follows:

[0082]

[0083] where r x 、r y 、r z Respectively represent the rotation angles of the point cloud data of the workpiece to be measured on the X-axis, Y-axis, and Z-axis. a, b, and c represent the offsets of the point cloud data of the workpiece to be measured in the X, Y, and Z directions, respectively. a = offset x , b = offset y , c=0.

[0084] The point cloud data of the workpiece to be measured is transformed by the above-mentioned transformation matrix to obtain the aligned point cloud data of the workpiece to be measured. In this embodiment, the depth image is used to indirectly calculate the offset and rotation angle of the point cloud data of the workpiece to be measured relative to the point cloud data of the standard workpiece, which can improve the processing speed of the algorithm and facilitate the processing of three-dimensional point cloud data.

[0085] The process of constructing the matching area and obtaining the optimal matching area in step 44 is as follows:

[0086] Assign the pixel values ​​and feature vectors of the pixels beyond the edge position to 0, and traverse each pixel point P in the i-th layer depth image of the second image pyramid. i (m i ,n i ), with each pixel P i (m i ,n i ) as the center point, with W i , H i Construct matching regions for width and height, obtain new matching regions of the matching regions at different rotation angles within the preset angle range of 0-180°, and use all matching regions and their new matching regions at different rotation angles as elements to form the data set Match_Rotate of the matching regions in the i-th layer i .

[0087] The rotation formula of the matching area is as follows:

[0088]

[0089]

[0090] Among them (m i n i ) represents the coordinates of the pixel point in the i-th layer before rotation, (m i 'n i ′) represents the coordinates of the pixel point in the i-th layer after rotation, Indicates the pixel point (m i n i ) is the matching area constructed with the center point, Indicates the matching area The new matching area obtained after rotation angle θ.

[0091] Use each element in the data set Region of Interest (ROI) i Match and calculate Pixel M (m i ,n i ) and region of interest ROI IPixel R (x i ,y i )’s similarity Sim(x) i ,y i ), region of interest ROI I Same as the width and height of the matching area, pixel M (m i ,n i ) and Pixel R (x i ,y i ) has the same position in each depth image, that is, m i =x i 、n i =y i , and then obtain each matching area and region of interest ROI i The similarity S.

[0092]

[0093]

[0094] Among them, M i 、N i Denote the total number of rows and columns of pixels in the matching area of ​​the second image pyramid, DerX R ,DerY R Represents pixel Pixel R (x i ,y i ) vector in the X and Y directions, DerX M ,DerY M Represents pixel Pixel M (m i ,n i ) in the X and Y directions.

[0095] When all matching regions in the data set are i If the similarity of the two regions is less than or equal to 0.9, the match is considered to have failed. i When the similarity is higher than 0.9, the matching area is considered to be the optimal matching area, and its center point is the optimal matching point.

[0096] like Figure 3 As shown in the figure, the weld measurement is performed using the point cloud data processed by the above method. The specific process is as follows:

[0097] Step 51, generating a corresponding third depth image according to the registered point cloud data of the workpiece to be measured, the region of interest in the third depth image is the weld, and the third depth image is divided into a left region and a right region with the plane where the weld is located as the center line.

[0098] Step 52: Obtain point cloud data on the left side and point cloud data on the right side of the weld according to the position coordinates of the left side region and the right side region in the third depth image.

[0099] The coordinate conversion relationship between the third depth image position coordinates and the point cloud data is as follows:

[0100]

[0101] Where x, y, and z represent the three-dimensional coordinate data of the point cloud, x′ and y′ represent the position coordinates of the pixel point in the third depth image, and D represents the depth value. Indicates the camera internal parameters.

[0102] Step 53, according to the point cloud data on the left side of the weld and the point cloud data on the right side, plane fitting is performed according to the following process to obtain a left fitting plane and a right fitting plane:

[0103] Create a model parameter object to save the plane fitting results;

[0104] Set the plane segmentation threshold to 0.7, and judge the points whose distance from the fitting plane exceeds the threshold as invalid data;

[0105] The RANSAC algorithm is used to perform plane fitting on the point cloud data, and finally the best result of plane fitting is obtained by continuously updating the setting model.

[0106] The specific process of the RANSAC algorithm is as follows:

[0107] Specifically, an iterative method is used to estimate the parameters of the mathematical model from a set of point cloud data of the workpiece to be tested that contains outliers. The RANSAC algorithm assumes that the data contains correct data and abnormal data (or noise). The correct data is recorded as inliers and the abnormal data is recorded as outliers. At the same time, RANSAC also assumes that given a set of correct data, there is a method to calculate the model parameters that conform to these data.

[0108] The core idea of ​​the RANSAC algorithm is randomness and assumption. Randomness is to randomly select sample data based on the probability of occurrence of correct data. According to the law of large numbers, random simulation can approximately obtain the correct result. Assumption is to assume that the selected sample data are correct data, and then use these correct data to calculate other points through the model that satisfies the problem. Finally, the result is scored. If there are too few points in the game and it is not as good as the previous model, it will be discarded. If it is worse than the existing model, the current model will be selected.

[0109] The reason why the RANSAC algorithm is selected in this embodiment is as follows: the amount of data is reduced after the data is processed by straight-through filtering. The RANSAC algorithm is robust and can estimate high-precision parameters from a large number of outlier data sets. In order to more accurately count the point cloud data of the key area, the point cloud data of the non-key area needs to be sent out first. Therefore, it is necessary to perform plane fitting on the point cloud data on both sides of the key area to obtain the fitting plane of the point cloud data on the left side of the weld and the fitting plane of the point cloud data on the right side. The equation is expressed as follows: l x+B l y+C l z=D l , A r x+B r y+C r z=D r , where A l ,B l ,C l ,D l With A r ,B r ,C r ,D r The formula constants of the left fitting plane and the right fitting plane are calculated for the RANSAC algorithm respectively.

[0110] Step 54: According to the position coordinates of the weld area in the third depth image, the corresponding point cloud data is obtained using the coordinate system conversion relationship in step 52, and the distance d between each point cloud data of the weld area and the left fitting plane is calculated. li , the distance d of the right fitting plane ri , filter the point cloud data to obtain the final weld point cloud data.

[0111] Set the weld point cloud data filtering threshold to 0.1. When the distance between a point cloud and the left fitting plane or the right fitting plane is less than or equal to 0.1, it is considered a plane point, that is, the edge burr of the weld, which needs to be filtered out. When the distance between a point cloud and the left fitting plane and the right fitting plane is greater than 0.1, the point cloud is considered a non-plane point and needs to be retained. When the value of the filtering threshold is too small, the burr points on the edge of the weld will be counted, generating redundant data. When the value of the filtering threshold is too large, some weld point cloud data will be filtered out, affecting the final statistical results.

[0112] Step 55, traverse each point in the weld point cloud data, count the coordinate values ​​of each point cloud data on the X-axis, Y-axis, and Z-axis, obtain the maximum, minimum, and average distance values ​​between every two points on the X-axis and Y-axis, and the maximum, minimum, and average coordinate values ​​on the Z-axis, and obtain the height, width, and height information of the weld.

[0113] like Figure 4 As shown, the arc curvature measurement is performed using the point cloud data processed by the above method. The specific process is as follows:

[0114] Step 61 , projecting the point cloud data in the Z-axis direction, projecting the point cloud data to be measured onto the XOY plane, filtering the Z-axis information of the point cloud data to be measured, and obtaining the plane point cloud data.

[0115] Step 62, drag the 3D model through the visualization window, adjust the posture of the plane point cloud to the front view angle, under the above posture conditions, use the method in step 3 to generate the corresponding fourth depth image, grayscale and binarize the fourth depth image, and obtain a binary image of the fourth depth image.

[0116] Set the input of Canny to a binary image, the output to an arc image, the low threshold to 90, the high threshold to 110, the image channel to 1, and call the Canny interface to extract the edge information in the binary image to obtain the arc pixel point set;

[0117] Step 63: Perform curve fitting using the least square method according to the coordinate value of each pixel point in the arc pixel point set.

[0118] Specifically, assume that the fitting polynomial of the least squares method is: y = a0 + a1x + ... + a k x k , the sum of the distances from each pixel to the curve, that is, the sum of squared deviations is as follows: Finally, in a set of suitable coefficients (a0, a1, ..., a k ), the partial variance and the minimum are the best, and the fitted curve is better.

[0119] Where k represents the number of terms in the fitting polynomial, a0, a1, ak They represent the coefficients of the first, second, and kth terms of the fitting polynomial, respectively, and their values ​​are unknown. q represents the number of arc pixels, Q represents the total number of arc pixels, q = 1, 2, ..., Q, y q Represents the least squares fitting result of the qth arc pixel point.

[0120] In order to obtain the coefficients of the fitting polynomial that meet the conditions, find a on the right side of the equation q Partial derivatives, thus we get:

[0121]

[0122] ...

[0124]

[0125] The polynomial coefficients of the above equation are expressed in matrix form as follows:

[0126]

[0127] where x q Indicates the X-axis coordinate of the qth arc pixel point, It represents the performance of the kth coefficient when calculating the distance from the qth arc pixel point to the fitting curve. The coefficient matrix is ​​solved using the above formula, i.e. a0-a k , and then determine the fitting equation of the curve.

[0128] Step 64, obtain the curvature κ of each pixel on the fitting curve by the following formula: q , and obtain the curvature information of the workpiece to be measured.

[0129]

[0130] where y′ q Represents y q The first derivative of , y″ q Represents y q The second-order derivative of the curve is taken as the curvature characteristic value of the curve.

[0131] In the early stage of this embodiment, the template_alignment method and the alignment_prerejective method were tried to directly match the 3D point cloud data, and then the point cloud data was calibrated. After testing, the time for measuring the width and height of the weld each time was as long as 30 minutes. Subsequently, under the same computer configuration, a two-dimensional image algorithm was used to assist the three-dimensional point cloud calibration. The entire measurement time was reduced to about 20 seconds, greatly speeding up the processing speed of the algorithm. Comparing the processing results of different processing methods before and after, the results of the two methods all controlled the error within 1%.

[0132] Similarly, in the initial stage of this embodiment, the curvature of the surface is calculated by directly reconstructing the three-dimensional point cloud data. The kd-tree method is used to reconstruct the three-dimensional point cloud data, and the getModelCurvatures interface in PCL is used to calculate the surface curvature. The whole calculation process takes one hour. Under the same computer configuration, the 3D to 2D conversion method is used to assist in calculating the surface curvature. The whole calculation process is reduced to about 20 seconds, which greatly speeds up the processing speed of the algorithm.

[0133] The present invention also includes an electronic device, including a memory and a processor, wherein the memory is used to store various computer program instructions, and the processor is used to execute the computer program instructions to complete all or part of the above steps; the electronic device can communicate with one or more external devices, and can also communicate with one or more devices that enable users to interact with the electronic device, and / or communicate with any device that enables the electronic device to communicate with one or more other computing devices. The electronic device can also communicate with one or more networks (such as local area networks, wide area networks and / or public networks) through a network adapter.

[0134] The present invention also includes a computer-readable medium storing a computer program that can be executed by a processor. The computer-readable medium may include but is not limited to magnetic storage devices, optical disks, digital versatile disks, smart cards and flash memory devices. In addition, the readable storage medium described in the present invention can represent one or more devices and / or other machine-readable media for storing information. The term "machine-readable medium" includes but is not limited to wireless channels and various other media (and / or storage media) that can store, contain and / or carry codes and / or instructions and / or data.

[0135] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0136] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A method for processing three-dimensional point cloud data, characterized in that: The following steps are involved: S1, obtaining the point cloud data of the workpiece to be tested and the point cloud data of the standard workpiece, and performing straight-through filtering on the point cloud data so that its Z-axis coordinate is 0 to 1; S2, using the distance value from the line scan camera to each point cloud as a pixel value, to obtain a first depth image corresponding to the point cloud data of the workpiece to be tested and a second depth image corresponding to the point cloud data of the standard workpiece; S3, calculating the offset and rotation angle of the first depth image compared to the second depth image, and registering the point cloud data of the workpiece to be measured based on the offset and rotation angle of the first depth image compared to the second depth image; The S3 comprises the following steps: S31, using downsampling to respectively acquire a first image pyramid of the first depth image and a second image pyramid of the second depth image; S32, using a rectangular frame to encircle an area with obvious texture features in the bottom layer of the first image pyramid as a region of interest , for the region of interest The coordinates, width and height are converted layer by layer to obtain the region of interest in each layer of the first image pyramid ,as well as The pixel value and feature vector of each pixel point in the ,in The variable representing the number of layers of the first image pyramid and the second image pyramid, , represents the total number of layers of the first image pyramid and the second image pyramid. The highest level, Represents the first image pyramid The upper left corner of the layer's area of ​​interest, Represents the first image pyramid Layer region of interest width, Represents the first image pyramid Layer area of ​​interest height; S33, taking each pixel point in the highest layer of the second image pyramid as the center point, , Construct matching regions for width and height, obtain new matching regions for each matching region at different rotation angles, and use each matching region and its new matching region at different rotation angles as elements to form a data set; According to the highest level region of interest of the first image pyramid The pixel value and feature vector of the inner pixel are obtained The best matching area in the corresponding data set takes its center point as the best matching point, expands the best matching point and converts its coordinate value to obtain its The optimal matching point set of the layer; S34, traverse the second image pyramid Each optimal matching point in the layer is centered on each optimal matching point. Construct matching regions for width and height, and obtain new matching regions for each matching region at different rotation angles to form a matching region data set; According to the first image pyramid Layer Area of ​​Interest The pixel values ​​and feature vectors of the inner pixels are used to obtain the second image pyramid. Layer and region of interest The corresponding optimal matching area and optimal matching point are expanded and the coordinate value of the optimal matching point is converted to obtain the second image pyramid. The optimal matching point set of the layer; Repeat S34 to obtain the coordinate value of the best matching point in the bottom layer of the second image pyramid; S35, according to the region of interest The coordinate value of the inner center point and the coordinate value of the best matching point in the bottom layer of the second image pyramid are used to calculate the offset and rotation angle of the first depth image relative to the second depth image; S36, obtaining a transformation matrix between the point cloud data of the workpiece to be measured and the point cloud data of the standard workpiece according to the offset and the rotation angle, and aligning the point cloud data of the workpiece to be measured based on the transformation matrix.

2. The method for processing three-dimensional point cloud data according to claim 1, characterized in that: The process of obtaining the optimal matching area is as follows: Calculate the matching areas and the areas of interest in the matching area data set Similarity , if all matching regions are If the similarity of is less than or equal to 0.9, the match fails. If the similarity is greater than 0.9, the matching area is the optimal matching area, and its center point is the optimal matching point.

3. The method for processing three-dimensional point cloud data according to claim 1, characterized in that: The process of expanding the optimal matching point and converting the coordinate values ​​is as follows: For the second image pyramid The best matching point in the layer is expanded to obtain ,right The coordinate values ​​of each matching point in the image pyramid are converted to obtain the optimal matching point set of the previous depth image in the second image pyramid. ,gather The elements in are ; The coordinate value conversion formula is as follows: ; in Represents the second image pyramid The best matching point of the layer, Represents the second image pyramid The best matching point of the layer, represents the downsampling coefficient when constructing the second image pyramid, , express The coordinate value of express The coordinate value of Indicates the rotation angle of the matching area.

4. The method for processing three-dimensional point cloud data according to claim 2, characterized in that: The similarity The calculation of is as follows: ; ; They represent the second image pyramid The total number of rows and columns of pixels in the matching area in the layer, Represents pixel points Vectors in the X and Y directions, , Represents pixel points Vectors in the X and Y directions, Represents the coordinates in the matching area The pixels on Representation and coordinates Corresponding The pixels in express and The similarity between two pixels.

5. Use of the method for processing three-dimensional point cloud data according to any one of claims 1 to 4, characterized in that: It is used to measure the weld in the workpiece to be measured, and specifically includes the following steps: S41, generating a third depth image according to the registered point cloud data of the workpiece to be measured, wherein the region of interest in the third depth image is the weld, and the third depth image is divided into a left region and a right region with the weld as the center line; S42, mapping the left area and the right area back to the point cloud data to obtain the point cloud data on the left side and the point cloud data on the right side of the weld; S43, performing plane fitting on the point cloud data using a RANSAC algorithm to obtain a left fitting plane corresponding to the point cloud data on the left side of the weld and a right fitting plane corresponding to the point cloud data on the right side; S44, obtaining the point cloud data of the weld area through a coordinate conversion algorithm, and calculating the distance from each point cloud data in the weld area to the left fitting plane , the distance of the right fitting plane , according to the distance and distance Filter the point cloud data to obtain the final point cloud data of the weld area; S45, traverse each point cloud in the weld point cloud data, count the distribution of each point cloud on the X-axis, Y-axis, and Z-axis, and obtain the width, length, and height information of the weld.

6. Use of the method for processing three-dimensional point cloud data according to any one of claims 1 to 4, characterized in that: It is used to measure the arc curvature of the workpiece to be measured, and specifically includes the following steps: S51, filtering the Z-axis information of the point cloud data of the workpiece to be measured, and projecting it onto the XOY plane to obtain plane point cloud data; S52, generating a fourth depth image corresponding to the plane point cloud data, performing grayscale and binarization processing on the fourth depth image to obtain a binary image of the fourth depth image, using a Canny operator to extract edge information in the binary image to obtain a set of arc pixel points; S53, obtaining the coordinate values ​​of the arc pixel points, and performing curve fitting using the least square method to obtain a curve fitting equation; S54, calculating the curvature of each arc pixel point to obtain the curvature information of the workpiece to be measured.

7. An electronic device, characterized in that: It includes a processor, a memory and a communication bus, wherein the processor and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 6 when executing a program stored in a memory.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Three-dimensional modeling method and device, electronic equipment and storage medium

    CN112894832A

  • Plant point cloud acquisition, registration and optimization method based on TOF camera

    US20200388044A1