CN117934429A - Flatness detection method of bus side wall panel based on 3D point cloud and contour matching - Google Patents

Flatness detection method of bus side wall panel based on 3D point cloud and contour matching Download PDF

Info

Publication number
CN117934429A
CN117934429A CN202410113884.5A CN202410113884A CN117934429A CN 117934429 A CN117934429 A CN 117934429A CN 202410113884 A CN202410113884 A CN 202410113884A CN 117934429 A CN117934429 A CN 117934429A
Authority
CN
China
Prior art keywords
point
point cloud
points
side wall
passenger car
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202410113884.5A
Other languages
Chinese (zh)
Other versions
CN117934429B (en
Inventor
胡志恒
王佳怡
秦凯阳
任缪楠
王文劲
王斯冉
习爽
刘兴光
杨雨图
韩程
周海燕
刘�英
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Forestry University
Original Assignee
Nanjing Forestry University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Forestry University filed Critical Nanjing Forestry University
Priority to CN202410113884.5A priority Critical patent/CN117934429B/en
Publication of CN117934429A publication Critical patent/CN117934429A/en
Application granted granted Critical
Publication of CN117934429B publication Critical patent/CN117934429B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • G06T7/001Industrial image inspection using an image reference approach
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10028Range image; Depth image; 3D point clouds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30204Marker

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Artificial Intelligence (AREA)
  • Health & Medical Sciences (AREA)
  • Multimedia (AREA)
  • Quality & Reliability (AREA)
  • Length Measuring Devices With Unspecified Measuring Means (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a passenger car side wall board flatness detection method based on three-dimensional point cloud and contour matching, which comprises the following steps: acquiring one-frame three-dimensional point clouds of side wallboards of different types of passenger cars; preprocessing the three-dimensional point cloud to generate point cloud slice data; performing line segment fitting on the point cloud slice data, and storing a line segment function obtained by fitting, the number of acquired points and region division into a template library; performing point cloud preprocessing operation when collecting each frame of point cloud data of a measured piece, matching the point cloud preprocessing operation with point cloud slice data in a template library, setting a relevant defect threshold value, and judging whether a point is a defect point or not; unfolding the data into complete point cloud data of the side wall plate of the passenger car, and dividing out a defect area; and eliminating misjudgment points by using an abnormal point eliminating algorithm to obtain a defect area. The invention solves the problems that the detection time is too long due to the oversized side wall plate of the passenger car, and the detection is difficult due to the too small defects by adopting the contour matching method, thereby meeting the real-time and accurate defect detection on the complex curved surface of the side wall plate of the passenger car.

Description

基于三维点云和轮廓匹配的客车侧墙板平整度检测方法Flatness detection method of bus side wall panel based on 3D point cloud and contour matching

技术领域Technical Field

本发明属于机器视觉无损检测领域,具体是一种基于三维点云和轮廓匹配的客车侧墙板平整度检测方法。The invention belongs to the field of machine vision nondestructive testing, and in particular is a method for detecting the flatness of a passenger car side wall panel based on three-dimensional point cloud and contour matching.

背景技术Background technique

在大型零件生产制造过程中,难以避免地会出现制造瑕疵,如物体表面的纹理破坏、材料焊接过程中产生的焊缝、受到挤压碰撞时产生的凹陷等。如果不及时发现这些瑕疵并进行维护和修理,产品的使用寿命将会大大降低,甚至带来极大的安全风险。以客车侧墙板为例,侧墙板上存在的各种缺陷会极大地影响到侧墙板的强度与美观,较大的缺陷甚至会导致列车在运行过程中产生油漆与腻子一起脱落的风险。车身的外观多为白色原色,使用机器视觉缺陷检测技术对于存在深度信息的微小缺陷检测效果欠佳,而点云缺陷检测技术能够很好地满足侧墙板缺陷特征提取的要求。In the manufacturing process of large parts, manufacturing defects are inevitable, such as texture damage on the surface of the object, welds produced during the welding process of materials, and dents caused by extrusion and collision. If these defects are not discovered in time and maintained and repaired, the service life of the product will be greatly reduced, and even bring great safety risks. Taking the side wall panels of passenger cars as an example, the various defects on the side wall panels will greatly affect the strength and appearance of the side wall panels. Large defects may even cause the risk of paint and putty falling off during the operation of the train. The appearance of the car body is mostly white. The use of machine vision defect detection technology is not effective for detecting small defects with depth information, while point cloud defect detection technology can well meet the requirements for extracting defect features of side wall panels.

基于点云的产品表面质量检测是一个值得深入研究的领域,也是生产制造和产品使用维护中的关键步骤。3D点云缺陷检测技术可以总结为五类:1、基于轮廓点云;2、基于模板匹配;3、基于局部几何特征;4、基于多模态点云数据;5、基于深度学习。这些点云缺陷检测方法各有优势:基于轮廓点云适应性强、速度快;基于模板匹配准确、适用于标准件,但速度较慢;基于局部几何特征泛化能力高;多模态点云精确度高、泛化性强;基于深度学习可以处理不规则点云,但样本获取困难且通用性较低。客车侧墙板尺寸较大,缺陷特征较小且要求精度较高,若采用以上方法,难以检测到较小的缺陷且所检测所需时间过长。Product surface quality inspection based on point cloud is a field worthy of in-depth research, and it is also a key step in manufacturing and product use and maintenance. 3D point cloud defect detection technology can be summarized into five categories: 1. Based on contour point cloud; 2. Based on template matching; 3. Based on local geometric features; 4. Based on multimodal point cloud data; 5. Based on deep learning. These point cloud defect detection methods have their own advantages: based on contour point cloud, it has strong adaptability and fast speed; based on template matching, it is accurate and suitable for standard parts, but the speed is slow; based on local geometric features, it has high generalization ability; multimodal point cloud has high accuracy and strong generalization; based on deep learning, it can process irregular point clouds, but it is difficult to obtain samples and has low versatility. The side wall panels of buses are large in size, the defect features are small and require high precision. If the above methods are used, it is difficult to detect small defects and the detection time is too long.

发明内容Summary of the invention

本发明所要解决的技术问题是针对上述现有技术的不足提供一种基于三维点云和轮廓匹配的客车侧墙板平整度检测方法,本方法通过对点云数据切片,对切片的点云数据进行数据处理,解决了因客车侧墙板尺寸过大而导致的检测时间过长,同时采用轮廓匹配的方法,解决了因缺陷过小而难以检测的问题,可以满足在客车侧墙板这类复杂曲面上进行实时、精准地缺陷检测,为后续在客车侧墙板表面腻子喷涂提供可靠的数据支持。The technical problem to be solved by the present invention is to provide a bus side wall panel flatness detection method based on three-dimensional point cloud and contour matching in response to the above-mentioned deficiencies in the prior art. The method slices the point cloud data and processes the sliced point cloud data, thereby solving the problem of long detection time caused by the large size of the bus side wall panels. At the same time, the contour matching method is adopted to solve the problem of difficult detection due to small defects. It can meet the needs of real-time and accurate defect detection on complex curved surfaces such as bus side wall panels, and provide reliable data support for the subsequent putty spraying on the surface of the bus side wall panels.

为实现上述技术目的,本发明采取的技术方案为:In order to achieve the above technical objectives, the technical solution adopted by the present invention is:

一种基于三维点云和轮廓匹配的客车侧墙板平整度检测方法,包括以下步骤:A method for detecting the flatness of a passenger car side wall panel based on three-dimensional point cloud and contour matching comprises the following steps:

步骤1、获取不同类型标准客车侧墙板一帧三维点云数据;Step 1, obtaining a frame of 3D point cloud data of different types of standard passenger car side wall panels;

步骤2、将获取得到的三维点云数据作预处理操作,并以Y坐标作为主方向,生成一份点云切片数据;Step 2: pre-process the acquired 3D point cloud data, and use the Y coordinate as the main direction to generate a point cloud slice data;

步骤3、将点云切片数据进行线段拟合,拟合出两条直线段与两条曲线段,将拟合得出的直线段函数、曲线段函数、采集得到的点的个数及区域划分记录下来,存储至模板库中;Step 3: Fit the point cloud slice data to obtain two straight line segments and two curved line segments, record the fitted straight line segment function, curved line segment function, the number of points collected and the area division, and store them in the template library;

步骤4、在采集被测件的每一帧点云数据时作点云预处理操作,将每一帧点云数据以Y坐标为基准,从步骤3所做的模板库中提取出相应的点云切片数据与采集的被测件的第一帧点云数据匹配,计算每一帧点云中的每个点到模板库中匹配的客车类型对应的线段的最短距离,设定相关缺陷阈值,当计算出的最短距离大于相关缺陷阈值时,则认定该点为缺陷点,记录下该点的位置及参数;Step 4: perform point cloud preprocessing when collecting each frame of point cloud data of the tested object. Take the Y coordinate of each frame of point cloud data as the reference, extract the corresponding point cloud slice data from the template library made in step 3 and match it with the first frame of point cloud data collected from the tested object. Calculate the shortest distance from each point in each frame of point cloud to the line segment corresponding to the matching bus type in the template library, set the relevant defect threshold, and when the calculated shortest distance is greater than the relevant defect threshold, the point is identified as a defect point, and the position and parameters of the point are recorded;

步骤5、在采集完所有的点云切片数据后,将其按照Y坐标展开成完整的客车侧墙板点云数据,并分割出其中的缺陷区域;Step 5: After all the point cloud slice data are collected, they are expanded into complete bus side wall panel point cloud data according to the Y coordinate, and the defective area is segmented;

步骤6、利用异常点剔除算法剔除误判点,最终得到缺陷区域信息。Step 6: Use the outlier elimination algorithm to eliminate misjudged points and finally obtain the defect area information.

作为本发明进一步改进的技术方案,所述步骤1具体为:As a further improved technical solution of the present invention, the step 1 is specifically:

利用客车侧墙板扫描装置,取不同类型标准客车侧墙板一帧三维点云数据。The bus side wall panel scanning device is used to obtain a frame of three-dimensional point cloud data of different types of standard bus side wall panels.

作为本发明进一步改进的技术方案,所述步骤2具体为:As a further improved technical solution of the present invention, the step 2 is specifically as follows:

步骤2.1、对步骤1所获取得到的一帧标准点云数据进行滤波、去噪,剔除侧墙板点云中的异常点以及噪声,使用均匀下采样的方法对点云数据进行降采样处理;Step 2.1, filtering and denoising a frame of standard point cloud data obtained in step 1, removing abnormal points and noise in the side wall panel point cloud, and downsampling the point cloud data using a uniform downsampling method;

步骤2.2、调整预处理完成后的侧墙板点云数据位姿,以Y坐标轴作为其主方向,即点云数据中所有的点的Y坐标相同。Step 2.2: Adjust the pose of the side wall panel point cloud data after preprocessing, taking the Y coordinate axis as its main direction, that is, all points in the point cloud data have the same Y coordinate.

作为本发明进一步改进的技术方案,所述步骤3具体为:As a further improved technical solution of the present invention, the step 3 is specifically as follows:

步骤3.1、以步骤2中得到的点云切片数据为对象,假设切片数据P中有k个点,由于各个点的Y坐标数值均相同,因此将切片中的点看作为二维数据中的点集,即每个点由x坐标及z坐标组成,则P={(x1,z1),(x2,z2),…,(xk,zk)};Step 3.1, taking the point cloud slice data obtained in step 2 as the object, assuming that there are k points in the slice data P, since the Y coordinate values of each point are the same, the points in the slice are regarded as a point set in two-dimensional data, that is, each point consists of an x coordinate and a z coordinate, then P = {(x 1 ,z 1 ),(x 2 ,z 2 ),…,(x k ,z k )};

步骤3.2、将集合P按照x坐标进行区域划分,即分为四个部分P1、P2、P3、P4,其中P1和P3为曲线部分点集,P2和P4为直线部分点集,假设P1中有m个点,P3中有n个点,P2中有a个点,P4中有b个点,且m+n+a+b=k;Step 3.2, divide the set P into four parts according to the x-coordinate, namely P1 , P2 , P3 , P4 , where P1 and P3 are curve point sets, P2 and P4 are straight line point sets, assuming that there are m points in P1 , n points in P3 , a points in P2 , b points in P4 , and m+n+a+b=k;

步骤3.3、利用最小二乘法来对切片数据中的直线部分进行拟合:Step 3.3: Use the least squares method to fit the straight line part in the slice data:

l(x)=a0+a1x (1);l(x)=a 0 +a 1 x (1);

其中l(x)为拟合出的直线函数,将需要拟合的数据中的每个点带入最小二乘法公式(1)中计算预测值,再通过加权误差平方和来判断直线拟合是否合理,加权误差平方和的计算公式如下:Where l(x) is the fitted straight line function. Each point in the data to be fitted is substituted into the least squares formula (1) to calculate the predicted value. The weighted square error is then used to determine whether the straight line fitting is reasonable. The calculation formula is as follows:

其中ω(xi)>0是xi范围内的权函数,l(xi)为拟合出的函数值,f(xi)为原始值,xi为第i个点的坐标;当拟合出的直线段的加权误差平方和最小时,则最小二乘拟合完成;Where ω( xi )>0 is the weight function within the range of xi , l( xi ) is the fitted function value, f( xi ) is the original value, and xi is the coordinate of the i-th point; when the weighted error sum of the fitted straight line segment is When is minimum, the least square fitting is completed;

利用公式(1)和公式(2)对P2进行拟合,拟合出直线段函数l1(x),利用公式(1)和公式(2)对P4进行拟合,拟合出直线段函数l2(x);Use formula (1) and formula (2) to fit P 2 , and fit the straight line segment function l 1 (x). Use formula (1) and formula (2) to fit P 4 , and fit the straight line segment function l 2 (x).

步骤3.4、采用圆拟合方法来获得切片数据中的曲线段方程:Step 3.4: Use the circle fitting method to obtain the curve segment equation in the slice data:

(X-x)2+(Z-z)2=r2 (3);(Xx) 2 +(Zz) 2 =r 2 (3);

其中圆心坐标为(x,z),圆半径为r;拟合过程分为以下几步:The coordinates of the center of the circle are (x, z) and the radius of the circle is r. The fitting process is divided into the following steps:

步骤3.4.1、在曲线部分点集对应的曲线段中首先随机挑选出不同的三个点,利用三点定圆的原理,拟合出曲线段圆方程;Step 3.4.1, first randomly select three different points in the curve segment corresponding to the curve part point set, and use the principle of three-point circle to fit the curve segment circle equation;

步骤3.4.2、由于切片数据中的曲线段小于四分之一个圆,因此将拟合出的曲线段圆方程转变为函数z=f(x),将切片数据中曲线段的点带入拟合出的函数中,求得新的z坐标值,同时求出决定系数R2Step 3.4.2: Since the curve segment in the slice data is less than a quarter of a circle, the fitted curve segment circle equation is transformed into a function z=f(x), and the points of the curve segment in the slice data are brought into the fitted function to obtain a new z coordinate value, and at the same time, the determination coefficient R 2 is obtained:

其中,zi表示第i个点的真实z坐标值,表示第i个点的预测z坐标值,/>表示所有点的真实z坐标值的平均值;Among them, zi represents the true z coordinate value of the i-th point, Indicates the predicted z coordinate value of the i-th point, /> Represents the average value of the true z coordinates of all points;

当R2<0.95时,返回到步骤3.4.1重新随机挑选三个点进行曲线拟合,直至R2≥0.95时,曲线拟合完毕;When R 2 <0.95, return to step 3.4.1 and randomly select three points for curve fitting again until R 2 ≥0.95, and the curve fitting is completed;

利用步骤3.4.1和步骤3.4.2对P1拟合,拟合出曲线段函数f1(x),利用步骤3.3.1和步骤3.3.2对P3拟合,拟合出曲线段函数f2(x);Use steps 3.4.1 and 3.4.2 to fit P 1 and obtain the curve segment function f 1 (x). Use steps 3.3.1 and 3.3.2 to fit P 3 and obtain the curve segment function f 2 (x).

步骤3.5、重复步骤3.1到步骤3.4,获取得到所有客车类型以及其侧墙板点云切片数据中的两个直线段函数、两个曲线段函数、点云切片数据中点的个数以及区域划分,将拟合出的两个直线段函数、两个曲线段函数、点云切片数据中点的个数和区域划分以及其相对应的客车类型存入模板库中。Step 3.5, repeat steps 3.1 to 3.4 to obtain the two straight line segment functions, two curve segment functions, the number of points in the point cloud slice data and the area division of all bus types and their side wall panel point cloud slice data, and store the fitted two straight line segment functions, two curve segment functions, the number of points in the point cloud slice data and the area division and the corresponding bus types into the template library.

作为本发明进一步改进的技术方案,所述步骤4具体为:As a further improved technical solution of the present invention, the step 4 is specifically as follows:

步骤4.1、利用客车侧墙板扫描装置,采集被测件的三维点云数据,在采集到第一帧点云数据时,立马对其进行步骤2.1中的预处理方式,同时采用步骤2.2中的点云位姿调整方式,使同一帧点云数据中各个点的Y坐标相同;Step 4.1, using the bus side wall panel scanning device to collect the three-dimensional point cloud data of the measured part, when the first frame of point cloud data is collected, immediately perform the preprocessing method in step 2.1 on it, and at the same time use the point cloud posture adjustment method in step 2.2 to make the Y coordinates of each point in the same frame of point cloud data the same;

步骤4.2、计算采集到的第一帧点云切片数据中点的个数,在模板库中寻找到与计算得到的第一帧点云切片数据中点的个数最相近的客车类型,并与之匹配;Step 4.2, calculate the number of points in the first frame of point cloud slice data collected, find the bus type that is closest to the number of points in the first frame of point cloud slice data calculated in the template library, and match it;

步骤4.3、从模板库中提取出匹配的客车类型对应的两个直线段函数和两个曲线段函数,并将采集得到的被测件的点云切片数据按照模板库中的区域划分,将被测件的点云切片数据对应的集合P按照x坐标分为四个部分P1、P2、P3、P4,其中P1和P3为曲线部分点集,P2和P4为直线部分点集,计算获取到的被测件的每一帧点云切片数据中每个点分别到匹配的客车类型中的相应线段函数的最短距离;Step 4.3, extract two straight line segment functions and two curve segment functions corresponding to the matching bus type from the template library, and divide the collected point cloud slice data of the tested object according to the areas in the template library, and divide the set P corresponding to the point cloud slice data of the tested object into four parts P1 , P2 , P3 , and P4 according to the x-coordinate, where P1 and P3 are curve part point sets, and P2 and P4 are straight line part point sets, and calculate the shortest distance from each point in each frame of the acquired point cloud slice data of the tested object to the corresponding line segment function in the matching bus type;

步骤4.4、在求被测件的直线部分点集中的点到直线段函数的最短距离时,假设将直线段函数l1(x)转化成直线方程ax+bz+c=0,则点到直线段的最短距离为:Step 4.4: When calculating the shortest distance from a point in the straight line portion of the measured object to the straight line segment function, assuming that the straight line segment function l 1 (x) is transformed into a straight line equation ax+bz+c=0, the shortest distance from the point to the straight line segment is:

公式(5)中distancei为点(xi,zi)到直线段l1(x)的最短距离;In formula (5), distance i is the shortest distance from point (x i ,z i ) to line segment l 1 (x);

利用步骤4.4的方法求出被测件的P2点集中的每个点到模板库中匹配的客车类型对应的直线段函数l1(x)的最短距离,求出被测件的P4点集中的每个点到模板库中匹配的客车类型对应的直线段函数l2(x)的最短距离;Using the method in step 4.4, find the shortest distance from each point in the P2 point set of the tested object to the straight line segment function l1 (x) corresponding to the matching bus type in the template library, and find the shortest distance from each point in the P4 point set of the tested object to the straight line segment function l2 (x) corresponding to the matching bus type in the template library;

步骤4.5、在求被测件的曲线部分点集中的点到曲线段函数的最短距离时,需要寻找到点到曲线之间的垂点q0,假设在被测件的P1点集中的一点Pi(xi,zi),在曲线段函数f1(x)上任取一点qτ,求得在qτ点处的切线的方向向量Pi(xi,zi)与qτ组成线段的方向向量为/>设定相关阈值k,若/>则qτ是所求的点Pi(xi,zi)到曲线段函数f1(x)之间的垂点q0,否则,增添一个步长,搜索曲线段函数f1(x)上的下一个点,重复寻找垂点的步骤,直到满足/>的条件;在求得垂点q0=(x,z)后,可求得点Pi(xi,zi)到曲线段函数f1(x)的最短距离:Step 4.5: When finding the shortest distance from a point in the curve part point set of the measured object to the curve segment function, it is necessary to find the perpendicular point q 0 between the point and the curve. Assume that at a point P i ( xi , z i ) in the P 1 point set of the measured object, select any point q τ on the curve segment function f 1 (x), and find the direction vector of the tangent line at point q τ. The direction vector of the line segment formed by P i (x i ,z i ) and q τ is/> Set the relevant threshold k, if/> Then q τ is the perpendicular point q 0 between the desired point Pi ( xi , z1 ) and the curve segment function f1 (x). Otherwise, add a step size to search for the next point on the curve segment function f1 (x), and repeat the steps of finding the perpendicular point until it satisfies/> After obtaining the perpendicular point q 0 =(x,z), the shortest distance from point Pi ( xi , zi ) to the curve segment function f1 (x) can be obtained:

公式(6)中distancei为点Pi(xi,zi)到曲线段函数f1(x)的最短距离;In formula (6), distance i is the shortest distance from point P i (x i ,z i ) to the curve segment function f 1 (x);

利用步骤4.5的方法求出被测件的P1点集中的每个点到模板库中匹配的客车类型对应的曲线段函数f1(x)的最短距离,求出被测件的P3点集中的每个点到模板库中匹配的客车类型对应的曲线段函数f2(x)的最短距离;Using the method in step 4.5, find the shortest distance from each point in the P1 point set of the tested object to the curve segment function f1 (x) corresponding to the bus type matched in the template library, and find the shortest distance from each point in the P3 point set of the tested object to the curve segment function f2 (x) corresponding to the bus type matched in the template library;

步骤4.6、设定相关缺陷阈值ε,分别比较被测件的P2点集中的每个点到模板库中匹配的客车类型对应的直线段函数l1(x)的最短距离、被测件的P4点集中的每个点到模板库中匹配的客车类型对应的直线段函数l2(x)的最短距离、被测件的P1点集中的每个点到模板库中匹配的客车类型对应的曲线段函数f1(x)的最短距离以及被测件的P3点集中的每个点到模板库中匹配的客车类型对应的曲线段函数f2(x)的最短距离与相关缺陷阈值ε之间的大小,若某最短距离大于相关缺陷阈值ε,则该最短距离对应的被测件中的点为缺陷点,记录该缺陷点对应的最短距离以及该缺陷点的位置;Step 4.6, set the relevant defect threshold ε, and compare the shortest distance from each point in the P2 point set of the tested piece to the straight line segment function l1 (x) corresponding to the bus type matched in the template library, the shortest distance from each point in the P4 point set of the tested piece to the straight line segment function l2 (x) corresponding to the bus type matched in the template library, the shortest distance from each point in the P1 point set of the tested piece to the curve segment function f1 (x) corresponding to the bus type matched in the template library, and the shortest distance from each point in the P3 point set of the tested piece to the curve segment function f2 (x) corresponding to the bus type matched in the template library with the relevant defect threshold ε. If a shortest distance is greater than the relevant defect threshold ε, the point in the tested piece corresponding to the shortest distance is a defect point, and the shortest distance corresponding to the defect point and the position of the defect point are recorded;

步骤4.7、在进行完步骤4.1和步骤4.2后,每采集到被测件的一帧点云切片数据,即循环一次步骤4.2到步骤4.6。Step 4.7: After completing steps 4.1 and 4.2, each time a frame of point cloud slice data of the test piece is collected, steps 4.2 to 4.6 are cycled once.

作为本发明进一步改进的技术方案,所述步骤5具体为:As a further improved technical solution of the present invention, the step 5 is specifically as follows:

步骤5.1、在采集完被测件的侧墙板所有的点云切片数据时,将所采集得到的所有点云切片数据按照Y方向展开,获得一整块侧墙板点云数据,同时将缺陷点组成的缺陷区域标注出来。Step 5.1, after collecting all the point cloud slice data of the side wall panel of the test piece, all the collected point cloud slice data are expanded in the Y direction to obtain the point cloud data of a whole side wall panel, and the defect area composed of defect points is marked.

作为本发明进一步改进的技术方案,所述步骤6具体为:As a further improved technical solution of the present invention, the step 6 is specifically as follows:

步骤6.1、提取所有的缺陷区域,将提取的缺陷区域分割成缺陷区域1、缺陷区域2、…缺陷区域n;Step 6.1, extracting all defect areas, and dividing the extracted defect areas into defect area 1, defect area 2, ... defect area n;

步骤6.2、假设缺陷区域j中的点的集合为Q,j=1,2,3…n,计算出集合Q中所有点的最小包围盒,获得最小包围球的体积T,设定一个相关阈值γ,当T<γ时,则认定该缺陷区域为误判区域,将其纠正为无缺陷区域;Step 6.2, assuming that the set of points in the defect area j is Q, j = 1, 2, 3 ... n, calculate the minimum bounding box of all points in the set Q, obtain the volume T of the minimum bounding sphere, set a relevant threshold γ, when T < γ, the defect area is considered to be a misjudged area and corrected to a non-defective area;

步骤6.3、按步骤6.2检测完所有缺陷区域,剔除其中的误判区域,最终获得缺陷区域。Step 6.3: After all defective areas are detected according to step 6.2, the misjudged areas are eliminated to finally obtain the defective areas.

本发明的有益效果为:The beneficial effects of the present invention are:

(1)本发明建立客车侧墙板模板库,将不同类型的标准客车侧墙板存入模板库中,使得本算法能够自适应各种不同类型的客车侧墙板的平整度检测,即使制作出了全新的客车侧墙板,也只需将其扫描一次存入模板库中即可进行检测,解决了适应性差的问题。(1) The present invention establishes a template library for bus side wall panels and stores different types of standard bus side wall panels in the template library, so that the algorithm can adapt to the flatness detection of different types of bus side wall panels. Even if a brand new bus side wall panel is manufactured, it only needs to be scanned once and stored in the template library for detection, thus solving the problem of poor adaptability.

(2)本发明通过对每一帧点云轮廓进行处理,而非对扫描完成后的整片点云进行处理,避免了在处理整片点云数据时间过长的问题,使得能够在采集侧墙板点云数据的同时进行缺陷区域的提取,大大减少了所需运行的时间。(2) The present invention processes the outline of each frame of point cloud instead of processing the entire point cloud after scanning, thereby avoiding the problem of taking too long to process the entire point cloud data. This makes it possible to extract defective areas while collecting the side wall panel point cloud data, greatly reducing the required running time.

(3)本发明利用点云轮廓进行模板匹配,放大了检测中的缺陷特征,解决了因客车侧墙板尺寸过大而导致的缺陷检测精度较小及小缺陷无法检测的问题。(3) The present invention uses point cloud contours for template matching, which amplifies the defect features in the detection and solves the problem of low defect detection accuracy and inability to detect small defects due to the large size of the bus side wall panels.

(4)本发明将所获得的所有点云切片数据拼接成完整的侧墙板点云数据,并将缺陷区域标注出来,再利用异常区域剔除算法,将误判的缺陷区域修正为无缺陷区域,解决了由于硬件原因所产生误差的问题,同时能够获得缺陷区域的坐标及深度信息,为后续的侧墙板腻子表面喷涂提供可靠的数据来源。(4) The present invention splices all the obtained point cloud slice data into complete side wall panel point cloud data, marks the defective area, and then uses the abnormal area elimination algorithm to correct the misjudged defective area into a non-defective area, thereby solving the problem of errors caused by hardware reasons. At the same time, the coordinates and depth information of the defective area can be obtained, providing a reliable data source for the subsequent side wall panel putty surface spraying.

(5)本发明通过对点云数据切片,对切片的点云数据进行数据处理,解决了因客车侧墙板尺寸过大而导致的检测时间过长,同时采用轮廓匹配的方法,解决了因缺陷过小而难以检测的问题,可以满足在客车侧墙板这类复杂曲面上进行实时、精准地缺陷检测,为后续在客车侧墙板表面腻子喷涂提供可靠的数据支持。(5) The present invention slices the point cloud data and processes the sliced point cloud data, thereby solving the problem of long detection time caused by the large size of the bus side wall panel. At the same time, the contour matching method is adopted to solve the problem that defects are difficult to detect due to being too small. It can meet the needs of real-time and accurate defect detection on complex curved surfaces such as bus side wall panels, and provide reliable data support for the subsequent putty spraying on the surface of the bus side wall panels.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本发明客车侧墙板平整度检测方法整体流程图。FIG. 1 is an overall flow chart of a method for detecting flatness of a side wall panel of a passenger car according to the present invention.

图2为侧墙板标准点云的轮廓图。Figure 2 is a contour diagram of the standard point cloud of the side wall panel.

图3为侧墙板缺陷类点云轮廓图。Figure 3 is a point cloud contour diagram of the side wall panel defects.

图4为侧墙板完整点云图Figure 4 is the complete point cloud of the side wall panel

图5为图4中真实缺陷区域图。FIG5 is a diagram of the actual defect area in FIG4 .

图5中的a为图4中真实缺陷区域放大图。Figure 5 a is an enlarged view of the actual defect area in Figure 4.

图5中的b为单纯真实缺陷区域图。Figure 5 (b) is a pure real defect area map.

具体实施方式Detailed ways

下面根据附图对本发明的具体实施方式作出进一步说明:The specific embodiments of the present invention are further described below according to the accompanying drawings:

一种基于三维点云和轮廓匹配的客车侧墙板平整度检测方法,如图1所示,包括以下步骤:A method for detecting the flatness of a bus side wall panel based on three-dimensional point cloud and contour matching, as shown in FIG1 , comprises the following steps:

步骤1、获取不同类型标准客车侧墙板一帧三维点云数据;Step 1, obtaining a frame of 3D point cloud data of different types of standard passenger car side wall panels;

步骤2、将获取得到的三维点云数据作预处理操作,并以Y坐标作为主方向,生成一份点云切片数据;Step 2: pre-process the acquired 3D point cloud data, and use the Y coordinate as the main direction to generate a point cloud slice data;

步骤3、将点云切片数据进行线段拟合,拟合出两条直线段与两条曲线段,将拟合得出的直线段函数、曲线段函数、采集得到的点的个数及区域划分记录下来,存储至模板库中;Step 3: Fit the point cloud slice data to obtain two straight line segments and two curved line segments, record the fitted straight line segment function, curved line segment function, the number of points collected and the area division, and store them in the template library;

步骤4、在采集被测件的每一帧点云数据时作点云预处理操作,将每一帧点云数据以Y坐标为基准,从步骤3所做的模板库中提取出相应的点云切片数据与被测件的第一帧点云数据匹配,计算被测件的每一帧点云中的每个点到模板库中匹配的客车类型对应的线段的最短距离,设定相关缺陷阈值,当计算出的最短距离大于相关缺陷阈值时,则认定该点为缺陷点,记录下该点的位置及参数;Step 4: perform point cloud preprocessing when collecting each frame of point cloud data of the tested object. Take the Y coordinate of each frame of point cloud data as the reference, extract the corresponding point cloud slice data from the template library made in step 3 and match it with the first frame of point cloud data of the tested object. Calculate the shortest distance from each point in each frame of point cloud of the tested object to the line segment corresponding to the matching bus type in the template library, set the relevant defect threshold, and when the calculated shortest distance is greater than the relevant defect threshold, the point is identified as a defect point, and the position and parameters of the point are recorded;

步骤5、在采集完所有的点云切片数据后,将其按照Y坐标展开成完整的客车侧墙板点云数据,并分割出其中的缺陷区域;Step 5: After all the point cloud slice data are collected, they are expanded into complete bus side wall panel point cloud data according to the Y coordinate, and the defective area is segmented;

步骤6、利用异常点剔除算法剔除误判点,最终得到缺陷区域信息。Step 6: Use the outlier elimination algorithm to eliminate misjudged points and finally obtain the defect area information.

所述步骤1具体为:The step 1 is specifically as follows:

步骤1.1、搭建客车侧墙板扫描装置(采用现有结构),包括扫描设备(相机)、底座、支架、悬臂梁、伺服电机等。扫描设备的底座与支架结构主要由独立滑轨一、独立滑轨二、悬臂梁连接件、支撑架主体和底座等组成;独立滑轨一、独立滑轨二作用为控制相机与被测物件间距离;考虑到线激光扫描相机的分辨率和有效采集区域,在悬臂梁相机支撑架上一共设置了六个相机放置点,以确保能够一次性地采集完整个侧墙板表面数据;Step 1.1, build a passenger car side wall panel scanning device (using the existing structure), including scanning equipment (camera), base, bracket, cantilever beam, servo motor, etc. The base and bracket structure of the scanning equipment are mainly composed of independent slide rail 1, independent slide rail 2, cantilever beam connector, support frame body and base, etc. Independent slide rail 1 and independent slide rail 2 are used to control the distance between the camera and the object to be measured; considering the resolution and effective acquisition area of the line laser scanning camera, a total of six camera placement points are set on the cantilever beam camera support frame to ensure that the entire side wall panel surface data can be collected at one time;

步骤1.2、一共有四个伺服电机来控制整个装置进行扫描运动,其中两个电机放置在支撑架与悬臂梁交接处,用来控制悬臂梁前后运动与上下运动,调节线激光扫描相机与被测件之间的距离,剩余两个电机用来控制底座在滑轨上的运动,从而实现线激光扫描相机移动采集被测件的三维数据。Step 1.2: There are four servo motors in total to control the scanning movement of the entire device. Two of the motors are placed at the junction of the support frame and the cantilever beam to control the forward and backward movement and up and down movement of the cantilever beam and adjust the distance between the line laser scanning camera and the workpiece under test. The remaining two motors are used to control the movement of the base on the slide rail, thereby realizing the movement of the line laser scanning camera to collect three-dimensional data of the workpiece under test.

所述步骤2具体为:The step 2 is specifically as follows:

步骤2.1、对步骤1所获取得到的一帧标准点云数据进行滤波、去噪的预处理操作,剔除侧墙板点云中的异常点以及噪声,使用均匀下采样的方法对点云数据进行降采样处理,减少后续处理时间;Step 2.1, perform filtering and denoising preprocessing operations on a frame of standard point cloud data obtained in step 1, remove abnormal points and noise in the side wall panel point cloud, and use a uniform downsampling method to downsample the point cloud data to reduce subsequent processing time;

步骤2.2、调整预处理完成后的侧墙板点云数据位姿,以Y坐标轴作为其主方向,即点云数据中所有的点的Y坐标相同;Step 2.2, adjust the pose of the side wall panel point cloud data after preprocessing, taking the Y coordinate axis as its main direction, that is, the Y coordinates of all points in the point cloud data are the same;

所述步骤3具体为:The step 3 is specifically as follows:

步骤3.1、以步骤2中得到的点云切片数据为对象,假设切片数据P中有k个点,由于各个点的Y坐标数值均相同,因此将切片中的点看作为二维数据中的点集,即每个点由x坐标及z坐标组成,则P={(x1,z1),(x2,z2),…,(xk,zk)};Step 3.1, taking the point cloud slice data obtained in step 2 as the object, assuming that there are k points in the slice data P, since the Y coordinate values of each point are the same, the points in the slice are regarded as a point set in two-dimensional data, that is, each point consists of an x coordinate and a z coordinate, then P = {(x 1 ,z 1 ),(x 2 ,z 2 ),…,(x k ,z k )};

步骤3.2、如图2,图2为侧墙板标准点云的轮廓图,将集合P按照x坐标进行区域划分,即分为四个部分P1、P2、P3、P4,其中P1和P3为曲线部分点集,P2和P4为直线部分点集,假设P1中有m个点,P3中有n个点,P2中有a个点,P4中有b个点,且m+n+a+b=k;Step 3.2, as shown in Figure 2, which is a contour diagram of the standard point cloud of the side wall panel, the set P is divided into four parts P1 , P2 , P3 , and P4 according to the x-coordinate, where P1 and P3 are curve part point sets, and P2 and P4 are straight line part point sets. Assume that there are m points in P1 , n points in P3 , a points in P2 , and b points in P4 , and m+n+a+b=k;

步骤3.3、利用最小二乘法来对切片数据中的直线部分进行拟合:Step 3.3: Use the least squares method to fit the straight line part in the slice data:

l(x)=a0+a1x (1);l(x)=a 0 +a 1 x (1);

其中l(x)为拟合出的直线函数,由一般经验可知l(x)为一元一次函数;将需要拟合的数据中的每个点带入最小二乘法公式(1)中计算预测值,再通过加权误差平方和来判断直线拟合是否合理,加权误差平方和的计算公式如下:Where l(x) is the fitted straight line function. According to general experience, l(x) is a linear function. Each point in the data to be fitted is substituted into the least squares formula (1) to calculate the predicted value. The weighted error sum of squares is then used to determine whether the straight line fitting is reasonable. The calculation formula is as follows:

其中ω(xi)>0是xi范围内的权函数,l(xi)为拟合出的函数值,f(xi)为原始值,xi为第i个点的坐标;当拟合出的直线段的加权误差平方和最小时,则最小二乘拟合完成;Where ω( xi )>0 is the weight function within the range of xi , l( xi ) is the fitted function value, f( xi ) is the original value, and xi is the coordinate of the i-th point; when the weighted error sum of the fitted straight line segment is When is minimum, the least square fitting is completed;

利用公式(1)和公式(2)对P2进行拟合,拟合出直线段函数l1(x),利用公式(1)和公式(2)对P4进行拟合,拟合出直线段函数l2(x);Use formula (1) and formula (2) to fit P 2 , and fit the straight line segment function l 1 (x). Use formula (1) and formula (2) to fit P 4 , and fit the straight line segment function l 2 (x).

步骤3.4、由制造过程可知客车侧墙板轮廓中的曲线部分近似于圆弧,因此将采用圆拟合方法来获得切片数据中的曲线段方程:Step 3.4: It can be seen from the manufacturing process that the curve part in the contour of the bus side wall panel is similar to an arc, so the circle fitting method will be used to obtain the curve segment equation in the slice data:

(X-x)2+(Z-z)2=r2 (3);(Xx) 2 +(Zz) 2 =r 2 (3);

其中圆心坐标为(x,z),圆半径为r;拟合过程分为以下几步:The coordinates of the center of the circle are (x, z) and the radius of the circle is r. The fitting process is divided into the following steps:

步骤3.4.1、在曲线部分点集对应的曲线段中首先随机挑选出不同的三个点,利用三点定圆的原理,拟合出曲线段圆方程;Step 3.4.1, first randomly select three different points in the curve segment corresponding to the curve part point set, and use the principle of three-point circle to fit the curve segment circle equation;

步骤3.4.2、由于切片数据中的曲线段明显小于四分之一个圆,因此可以将拟合出的曲线段圆方程转变为函数z=f(x),一个x对应一个z,将切片数据中曲线段的点带入拟合出的函数中,求得新的z坐标值,同时求出决定系数R2Step 3.4.2: Since the curve segment in the slice data is obviously smaller than a quarter of a circle, the fitted curve segment circle equation can be transformed into a function z=f(x), where one x corresponds to one z. Substitute the points of the curve segment in the slice data into the fitted function to obtain the new z coordinate value and the determination coefficient R 2 :

其中,zi表示第i个点的真实z坐标值,表示第i个点的预测z坐标值,也即拟合出的函数求出的z值,/>表示所有点的真实z坐标值的平均值;Among them, zi represents the true z coordinate value of the i-th point, Represents the predicted z coordinate value of the ith point, that is, the z value obtained by the fitted function, /> Represents the average value of the true z coordinates of all points;

当R2<0.95时,返回到步骤3.4.1重新随机挑选三个点进行曲线拟合,直至R2≥0.95时,曲线拟合完毕;When R 2 <0.95, return to step 3.4.1 and randomly select three points for curve fitting again until R 2 ≥0.95, and the curve fitting is completed;

利用步骤3.4.1和步骤3.4.2对P1拟合,拟合出曲线段函数f1(x),利用步骤3.3.1和步骤3.3.2对P3拟合,拟合出曲线段函数f2(x);Use steps 3.4.1 and 3.4.2 to fit P 1 and obtain the curve segment function f 1 (x). Use steps 3.3.1 and 3.3.2 to fit P 3 and obtain the curve segment function f 2 (x).

步骤3.5、重复步骤3.1到步骤3.4,获取得到所有客车类型以及其侧墙板点云切片数据中的两个直线段函数、两个曲线段函数、点云切片数据中点的个数以及区域划分,将拟合出的两个直线段函数、两个曲线段函数、点云切片数据中点的个数和区域划分以及其相对应的客车类型存入模板库中。Step 3.5, repeat steps 3.1 to 3.4 to obtain the two straight line segment functions, two curve segment functions, the number of points in the point cloud slice data and the area division of all bus types and their side wall panel point cloud slice data, and store the fitted two straight line segment functions, two curve segment functions, the number of points in the point cloud slice data and the area division and the corresponding bus types into the template library.

所述步骤4具体为:The step 4 is specifically as follows:

步骤4.1、利用客车侧墙板扫描装置,沿着地轨采集被测件的三维点云数据,在采集到第一帧点云数据时,立马对其进行步骤2.1中的预处理方式,同时采用步骤2.2中的点云位姿调整方式,使同一帧点云数据中各个点的Y坐标相同;Step 4.1, using the bus side wall scanning device, collect the three-dimensional point cloud data of the measured object along the ground track. When the first frame of point cloud data is collected, immediately perform the preprocessing method in step 2.1 on it, and at the same time use the point cloud posture adjustment method in step 2.2 to make the Y coordinates of each point in the same frame of point cloud data the same;

步骤4.2、根据经验可知,不同类型的客车侧墙板点云切片数据中点的个数相差甚大,因此计算采集到的第一帧点云切片数据中点的个数,在模板库中寻找到与计算得到的第一帧点云切片数据中点的个数最相近的客车类型,并与之匹配;Step 4.2: According to experience, the number of points in the point cloud slice data of different types of bus side wall panels varies greatly. Therefore, the number of points in the first frame of point cloud slice data collected is calculated, and the bus type with the closest number of points to the calculated first frame of point cloud slice data is found in the template library and matched;

步骤4.3、从模板库中提取出匹配的客车类型对应的两个直线段函数和两个曲线段函数,并将采集得到的被测件的点云切片数据按照模板库中的区域划分,将被测件的点云切片数据对应的集合P按照x坐标分为四个部分P1、P2、P3、P4,其中P1和P3为曲线部分点集,P2和P4为直线部分点集,计算获取到的被测件的每一帧点云切片数据中每个点分别到匹配的客车类型对应的相应线段函数的最短距离;Step 4.3, extract two straight line segment functions and two curve segment functions corresponding to the matching bus type from the template library, and divide the collected point cloud slice data of the tested object according to the areas in the template library, and divide the set P corresponding to the point cloud slice data of the tested object into four parts P1 , P2 , P3 , and P4 according to the x-coordinate, where P1 and P3 are curve part point sets, and P2 and P4 are straight line part point sets, and calculate the shortest distance from each point in each frame of the acquired point cloud slice data of the tested object to the corresponding line segment function corresponding to the matching bus type;

如图3,被测件的点云切片数据对应的集合按照x坐标分为四个部分P1、P2、P3、P4,图3为侧墙板缺陷类点云轮廓图;As shown in Figure 3, the set corresponding to the point cloud slice data of the tested part is divided into four parts P 1 , P 2 , P 3 , and P 4 according to the x coordinate. Figure 3 is a point cloud contour diagram of the side wall panel defect;

步骤4.4、在求被测件的直线部分点集中的点到直线段函数的最短距离时,假设将直线段函数l1(x)转化成直线方程ax+bz+c=0,则点到直线段的最短距离为:Step 4.4: When calculating the shortest distance from a point in the straight line portion of the measured object to the straight line segment function, assuming that the straight line segment function l 1 (x) is transformed into a straight line equation ax+bz+c=0, the shortest distance from the point to the straight line segment is:

公式(5)中distancei为点(xi,zi)到直线段l1(x)的最短距离;In formula (5), distance i is the shortest distance from point (x i ,z i ) to line segment l 1 (x);

利用步骤4.4的方法求出被测件的P2点集中的每个点到模板库中匹配的客车类型对应的直线段函数l1(x)的最短距离,求出被测件的P4点集中的每个点到模板库中匹配的客车类型对应的直线段函数l2(x)的最短距离;Using the method in step 4.4, find the shortest distance from each point in the P2 point set of the tested object to the straight line segment function l1 (x) corresponding to the matching bus type in the template library, and find the shortest distance from each point in the P4 point set of the tested object to the straight line segment function l2 (x) corresponding to the matching bus type in the template library;

步骤4.5、在求被测件的曲线部分点集中的点到曲线段函数的最短距离时,需要寻找到点到曲线之间的垂点q0,假设在被测件的P1点集中的一点Pi(xi,zi),在曲线段函数f1(x)上任取一点qτ,qτ表示曲线段函数f1(x)上的第τ个点,求得在qτ点处的切线的方向向量Pi(xi,zi)与qτ组成线段的方向向量为/>设定相关阈值k,若/>则qτ是所求的点Pi(xi,zi)到曲线段函数f1(x)之间的垂点q0,否则,增添一个步长,搜索曲线段函数f1(x)上的下一个点,重复寻找垂点的步骤,直到满足/>的条件;在求得垂点q0=(x,z)后,可求得点Pi(xi,zi)到曲线段函数f1(x)的最短距离:Step 4.5: When finding the shortest distance from a point in the curve part point set of the measured object to the curve segment function, it is necessary to find the perpendicular point q 0 between the point and the curve. Assume that at a point P i ( xi , z i ) in the P 1 point set of the measured object, select any point q τ on the curve segment function f 1 (x), q τ represents the τth point on the curve segment function f 1 (x), and find the direction vector of the tangent at point q τ The direction vector of the line segment formed by P i (x i ,z i ) and q τ is/> Set the relevant threshold k, if/> Then q τ is the perpendicular point q 0 between the desired point Pi ( xi , z1 ) and the curve segment function f1 (x). Otherwise, add a step size to search for the next point on the curve segment function f1 (x). Repeat the steps of finding the perpendicular point until/> is satisfied. After obtaining the perpendicular point q 0 =(x,z), the shortest distance from point Pi ( xi , zi ) to the curve segment function f1 (x) can be obtained:

公式(6)中distancei为点Pi(xi,zi)到曲线段函数f1(x)的最短距离;In formula (6), distance i is the shortest distance from point P i (x i ,z i ) to the curve segment function f 1 (x);

利用步骤4.5的方法求出被测件的P1点集中的每个点到模板库中匹配的客车类型对应的曲线段函数f1(x)的最短距离,求出被测件的P3点集中的每个点到模板库中匹配的客车类型对应的曲线段函数f2(x)的最短距离;Using the method in step 4.5, find the shortest distance from each point in the P1 point set of the tested object to the curve segment function f1 (x) corresponding to the bus type matched in the template library, and find the shortest distance from each point in the P3 point set of the tested object to the curve segment function f2 (x) corresponding to the bus type matched in the template library;

步骤4.6、设定相关缺陷阈值ε,分别比较被测件的P2点集中的每个点到模板库中匹配的客车类型对应的直线段函数l1(x)的最短距离、被测件的P4点集中的每个点到模板库中匹配的客车类型对应的直线段函数l2(x)的最短距离、被测件的P1点集中的每个点到模板库中匹配的客车类型对应的曲线段函数f1(x)的最短距离以及被测件的P3点集中的每个点到模板库中匹配的客车类型对应的曲线段函数f2(x)的最短距离与相关缺陷阈值ε之间的大小,若某最短距离大于相关缺陷阈值ε,则该最短距离对应的被测件中的点为缺陷点,记录该缺陷点对应的最短距离以及该缺陷点的位置(参数);Step 4.6, set the relevant defect threshold ε, and compare the shortest distance from each point in the P2 point set of the tested piece to the straight line segment function l1 (x) corresponding to the bus type matched in the template library, the shortest distance from each point in the P4 point set of the tested piece to the straight line segment function l2 (x) corresponding to the bus type matched in the template library, the shortest distance from each point in the P1 point set of the tested piece to the curve segment function f1 (x) corresponding to the bus type matched in the template library, and the shortest distance from each point in the P3 point set of the tested piece to the curve segment function f2 (x) corresponding to the bus type matched in the template library with the relevant defect threshold ε. If a shortest distance is greater than the relevant defect threshold ε, the point in the tested piece corresponding to the shortest distance is a defect point, and the shortest distance corresponding to the defect point and the position (parameters) of the defect point are recorded;

步骤4.7、在进行完步骤4.1和步骤4.2后,每采集到被测件的一帧点云切片数据,即循环一次步骤4.2到步骤4.6。Step 4.7: After completing steps 4.1 and 4.2, each time a frame of point cloud slice data of the test piece is collected, steps 4.2 to 4.6 are cycled once.

所述步骤5具体为:The step 5 is specifically as follows:

步骤5.1、在客车侧墙板扫描装置运行完毕,即采集完被测件的侧墙板所有的点云切片数据时,将所采集得到的所有点云切片数据按照Y方向展开,获得一整块侧墙板点云数据,同时将缺陷点组成的缺陷区域标注出来。Step 5.1, when the bus side wall panel scanning device is completed, that is, when all the point cloud slice data of the side wall panel of the tested part is collected, all the collected point cloud slice data are expanded in the Y direction to obtain a whole piece of side wall panel point cloud data, and the defect area composed of defect points is marked.

所述步骤6具体为:The step 6 is specifically as follows:

步骤6.1、由于相机的偶然抖动、噪声未消除干净等原因,会不可避免地产生误判现象,因此提取所有的缺陷区域,将提取的缺陷区域分割成缺陷区域1、缺陷区域2、…缺陷区域n;Step 6.1, due to the occasional camera shake, noise not completely eliminated and other reasons, misjudgment will inevitably occur, so all defect areas are extracted, and the extracted defect areas are divided into defect area 1, defect area 2, ... defect area n;

步骤6.2、假设缺陷区域j中的点的集合为Q,j=1,2,3…n,计算出集合Q中所有点的最小包围盒,获得最小包围球的体积T,设定一个相关阈值γ,当T<γ时,则认定该缺陷区域为误判缺陷区域,将其纠正为无缺陷区域;如图4所示,包括误判缺陷区域和真实缺陷区域;图5中的a为图4中真实缺陷区域的放大图,图5中的b为提取的纯真实缺陷区域;Step 6.2, assuming that the set of points in the defect area j is Q, j = 1, 2, 3 ... n, calculate the minimum bounding box of all points in the set Q, obtain the volume T of the minimum bounding sphere, set a relevant threshold γ, when T < γ, the defect area is determined to be a misjudged defect area, and it is corrected to a non-defective area; as shown in Figure 4, including the misjudged defect area and the real defect area; a in Figure 5 is an enlarged view of the real defect area in Figure 4, and b in Figure 5 is the extracted pure real defect area;

步骤6.3、按步骤6.2检测完所有缺陷区域,剔除其中的误判区域,最终获得缺陷区域及缺陷参数。Step 6.3: After all defect areas are detected according to step 6.2, the misjudged areas are eliminated, and finally the defect areas and defect parameters are obtained.

本发明建立客车侧墙板模板库,将不同类型的客车侧墙板存入模板库中,使得本方法能够自适应各种不同类型的客车侧墙板的平整度检测,即使制作出了全新的客车侧墙板,也只需将其扫描一次存入模板库中即可进行检测,解决了适应性差的问题。The present invention establishes a coach side wall panel template library and stores different types of coach side wall panels in the template library, so that the method can adaptively detect the flatness of different types of coach side wall panels. Even if a brand new coach side wall panel is manufactured, it only needs to be scanned once and stored in the template library for detection, thus solving the problem of poor adaptability.

本发明通过对每一帧点云轮廓进行处理,而非对扫描完成后的整片点云进行处理,避免了在处理整片点云数据时间过长的问题,使得能够在采集侧墙板点云数据的同时进行缺陷区域的提取,大大减少了所需运行的时间。The present invention processes the outline of each frame of point cloud instead of processing the entire point cloud after scanning, thereby avoiding the problem of taking too long to process the entire point cloud data, making it possible to extract defective areas while collecting the side wall panel point cloud data, greatly reducing the required running time.

本发明利用点云轮廓进行模板匹配,放大了检测中的缺陷特征,解决了因客车侧墙板尺寸过大而导致的缺陷检测精度较小及小缺陷无法检测的问题。The present invention uses point cloud contours for template matching, amplifies defect features in detection, and solves the problem of low defect detection accuracy and inability to detect small defects due to the excessive size of the bus side wall panel.

本发明将所获得的所有点云切片数据拼接成完整的侧墙板点云数据,并将缺陷区域标注出来,再利用异常区域剔除算法,将误判的缺陷区域修正为无缺陷区域,解决了由于硬件原因所产生误差的问题,同时能够获得缺陷区域的坐标及深度信息,为后续的侧墙板腻子表面喷涂提供可靠的数据来源。The present invention splices all the obtained point cloud slice data into complete side wall panel point cloud data, marks the defective area, and then uses the abnormal area elimination algorithm to correct the misjudged defective area into a non-defective area, thereby solving the problem of errors caused by hardware reasons. At the same time, the coordinates and depth information of the defective area can be obtained, providing a reliable data source for subsequent side wall panel putty surface spraying.

本发明的保护范围包括但不限于以上实施方式,本发明的保护范围以权利要求书为准,任何对本技术做出的本领域的技术人员容易想到的替换、变形、改进均落入本发明的保护范围。The protection scope of the present invention includes but is not limited to the above embodiments. The protection scope of the present invention shall be based on the claims. Any replacement, deformation, and improvement of the technology that can be easily thought of by technicians in this field shall fall within the protection scope of the present invention.

Claims (7)

1. A passenger car side wall board flatness detection method based on three-dimensional point cloud and contour matching is characterized by comprising the following steps:
step 1, acquiring one-frame three-dimensional point cloud data of side wallboards of different types of standard buses;
Step 2, preprocessing the obtained three-dimensional point cloud data, and generating a part of point cloud slice data by taking a Y coordinate as a main direction;
Step 3, carrying out line segment fitting on the point cloud slice data, fitting two straight line segments and two curve segments, recording the straight line segment function and the curve segment function obtained by fitting, and the number and the area division of the acquired points, and storing the obtained points and the area division into a template library;
Step 4, performing point cloud preprocessing operation when collecting each frame of point cloud data of the measured piece, extracting corresponding point cloud slice data from the template library which is made in the step 3 by taking the Y coordinate as a reference, matching the corresponding point cloud slice data with the collected first frame of point cloud data of the measured piece, calculating the shortest distance from each point in each frame of point cloud to a line segment which corresponds to the matched bus type in the template library, setting a relevant defect threshold, and when the calculated shortest distance is larger than the relevant defect threshold, determining the point as a defect point and recording the position and parameters of the point;
Step 5, after all point cloud slice data are acquired, expanding the point cloud slice data into complete point cloud data of the side wall plate of the passenger car according to Y coordinates, and dividing a defect area in the point cloud data;
and 6, eliminating misjudgment points by using an abnormal point eliminating algorithm, and finally obtaining the defect area information.
2. The method for detecting the flatness of the side wall panel of the passenger car based on the three-dimensional point cloud and the contour matching according to claim 1, wherein the step 1 is specifically as follows:
and taking one-frame three-dimensional point cloud data of the side wallboards of different types of standard buses by using the scanning device of the side wallboards of the buses.
3. The method for detecting the flatness of the side wall panel of the passenger car based on the three-dimensional point cloud and the contour matching according to claim 1, wherein the step2 is specifically as follows:
step 2.1, filtering and denoising the frame of standard point cloud data obtained in the step 1, removing abnormal points and noise in the point cloud of the side wall plate, and performing downsampling on the point cloud data by using a uniform downsampling method;
and 2.2, adjusting the pose of the point cloud data of the side wall panel after the pretreatment is finished, and taking the Y coordinate axis as the main direction of the pose, namely, the Y coordinates of all points in the point cloud data are the same.
4. The passenger car side wall panel flatness detection method based on three-dimensional point cloud and contour matching according to claim 1, wherein the step 3 specifically comprises:
step 3.1, taking the point cloud slice data obtained in the step 2 as an object, assuming that k points exist in the slice data P, and considering the points in the slice as a point set in the two-dimensional data because the Y coordinate values of the points are the same, i.e., each point is composed of an x coordinate and a z coordinate, then p= { (x 1,z1),(x2,z2),...,(xk,zk) };
Step 3.2, dividing the set P into four parts P 1、P2、P3、P4 according to the x coordinate, wherein P 1 and P 3 are curve part point sets, P 2 and P 4 are straight part point sets, assuming that there are m points in P 1, n points in P 3, a point in P 2, b points in P 4, and m+n+a+b=k;
step 3.3, fitting the straight line part in the slice data by using a least square method:
l(x)=a0+a1x (1);
Wherein l (x) is a fitted linear function, each point in the data to be fitted is brought into a least square method formula (1) to calculate a predicted value, and whether the linear fitting is reasonable or not is judged by a weighted error square sum The calculation formula of (2) is as follows:
Wherein ω (x i) > 0 is the weight function in the range of x i, l (x i) is the fitted function value, f (x i) is the original value, and x i is the coordinate of the i-th point; when the weighted error square sum of the fitted straight line segments And if the least square is the least, the least square fitting is completed;
fitting P 2 by using a formula (1) and a formula (2) to obtain a straight-line segment function l 1 (x), and fitting P 4 by using the formula (1) and the formula (2) to obtain a straight-line segment function l 2 (x);
and 3.4, obtaining a curve segment equation in slice data by adopting a circle fitting method:
(X-x)2+(Z-z)2=r2 (3);
Wherein the center coordinates are (x, z), and the radius of the circle is r; the fitting process comprises the following steps:
Step 3.4.1, firstly randomly picking out different three points in a curve segment corresponding to a curve part point set, and fitting out a curve segment circle equation by utilizing the principle of three-point circle setting;
In step 3.4.2, since the curve segment in the slice data is smaller than one quarter circle, the fitted curve segment circle equation is converted into a function z=f (x), the points of the curve segment in the slice data are brought into the fitted function, a new z coordinate value is obtained, and a determination coefficient R 2 is obtained at the same time:
Wherein z i represents the true z-coordinate value of the ith point, Predictive z-coordinate value representing the ith point,/>Representing an average of true z coordinate values for all points;
When R 2 is less than 0.95, returning to the step 3.4.1, and randomly selecting three points again to perform curve fitting until R 2 is more than or equal to 0.95, and finishing the curve fitting;
Fitting P 1 by using the steps 3.4.1 and 3.4.2 to obtain a curve segment function f 1 (x), fitting P 3 by using the steps 3.3.1 and 3.3.2 to obtain a curve segment function f 2 (x);
And 3.5, repeating the steps 3.1 to 3.4, obtaining two straight line segment functions, two curve segment functions, the number of points in the point cloud slice data and region division in all passenger car types and the side wall plate point cloud slice data, and storing the fitted two straight line segment functions, two curve segment functions, the number of points in the point cloud slice data and region division and corresponding passenger car types into a template library.
5. The method for detecting the flatness of the side wall panel of the passenger car based on the three-dimensional point cloud and the contour matching according to claim 1, wherein the step 4 is specifically:
Step 4.1, acquiring three-dimensional point cloud data of a detected piece by utilizing a scanning device of a side wall board of the passenger car, and when the first frame of point cloud data is acquired, carrying out a preprocessing mode in the step 2.1 by a vertical horse, and simultaneously adopting a point cloud pose adjustment mode in the step 2.2 to enable Y coordinates of all points in the same frame of point cloud data to be the same;
step 4.2, calculating the number of points in the acquired first frame point cloud slice data, and finding the passenger car type closest to the calculated number of points in the first frame point cloud slice data in a template library and matching the passenger car type with the passenger car type;
Step 4.3, extracting two straight line segment functions and two curve segment functions corresponding to the matched passenger car type from a template library, dividing acquired point cloud slice data of the detected piece according to regions in the template library, dividing a set P corresponding to the point cloud slice data of the detected piece into four parts P 1、P2、P3、P4 according to x coordinates, wherein P 1 and P 3 are curve part point sets, P 2 and P 4 are straight line part point sets, and calculating the shortest distance from each point in each frame of the acquired point cloud slice data of the detected piece to the corresponding line segment function in the matched passenger car type;
Step 4.4, when obtaining the shortest distance from the point in the point set of the linear part of the measured object to the linear segment function, assuming that the linear segment function l 1 (x) is converted into a linear equation ax+bz+c=0, the shortest distance from the point to the linear segment is:
Distance i in equation (5) is the shortest distance from point (x i,zi) to straight line segment l 1 (x);
Obtaining the shortest distance from each point in the P 2 point set of the tested piece to a straight line segment function l 1 (x) corresponding to the matched passenger car type in the template library by using the method of the step 4.4, and obtaining the shortest distance from each point in the P 4 point set of the tested piece to a straight line segment function l 2 (x) corresponding to the matched passenger car type in the template library;
Step 4.5, when obtaining the shortest distance from the point concentrated on the curve part of the measured object to the curve segment function, it is necessary to find the perpendicular point q 0 between the point and the curve, assuming a point P i(xi,zi concentrated on the point P 1 of the measured object), taking a point q τ on the curve segment function f 1 (x), obtaining the direction vector of the tangent line at the point q τ P i(xi,zi) and q τ are each a segment direction vector/>Setting a correlation threshold k, if/>Q τ is the calculated point P i(xi,zi) to the perpendicular point q 0 between the curve segment functions f 1 (x), otherwise, adding a step size, searching the next point on the curve segment function f 1 (x), repeating the step of finding the perpendicular point until the point is satisfiedConditions of (2); after the perpendicular point q 0 = (x, z) is found, the shortest distance from the point P i(xi,zi to the curve segment function f 1 (x) can be found:
Distance i in equation (6) is the shortest distance from point P i(xi,zi) to curve segment function f 1 (x);
Calculating the shortest distance from each point in the P 1 point set of the tested piece to a curve segment function f 1 (x) corresponding to the matched passenger car type in the template library by using the method of the step 4.5, and calculating the shortest distance from each point in the P 3 point set of the tested piece to a curve segment function f 2 (x) corresponding to the matched passenger car type in the template library;
Step 4.6, setting a relevant defect threshold epsilon, respectively comparing the shortest distance between each point in the P 2 point set of the tested piece and a straight line segment function l 1 (x) corresponding to the matched passenger car type in the template library, the shortest distance between each point in the P 4 point set of the tested piece and a straight line segment function l 2 (x) corresponding to the matched passenger car type in the template library, the shortest distance between each point in the P 1 point set of the tested piece and a curve segment function f 1 (x) corresponding to the matched passenger car type in the template library, and the shortest distance between each point in the P 3 point set of the tested piece and a curve segment function f 2 (x) corresponding to the matched passenger car type in the template library with the relevant defect threshold epsilon, and if a certain shortest distance is larger than the relevant defect threshold epsilon, the point in the tested piece corresponding to the shortest distance is a defect point, and recording the shortest distance corresponding to the defect point and the position of the defect point;
and step 4.7, after the step 4.1 and the step 4.2 are performed, each frame of point cloud slice data of the measured piece is acquired, namely, the step 4.2 to the step 4.6 are circulated once.
6. The passenger car side wall panel flatness detection method based on three-dimensional point cloud and contour matching according to claim 1, wherein the step 5 specifically comprises:
and 5.1, when all the point cloud slice data of the side wall plate of the measured piece are acquired, expanding all the acquired point cloud slice data according to the Y direction to obtain the point cloud data of the whole side wall plate, and marking the defect area consisting of the defect points.
7. The passenger car side wall panel flatness detection method based on three-dimensional point cloud and contour matching according to claim 1, wherein the step 6 specifically comprises:
step 6.1, extracting all defect areas, and dividing the extracted defect areas into a defect area 1, a defect area 2 and a … defect area n;
step 6.2, assuming that the set of points in the defect area j is Q, j=1, 2,3 … n, calculating the minimum bounding box of all points in the set Q, obtaining the volume T of the minimum bounding sphere, setting a relevant threshold value gamma, and when T is less than gamma, recognizing the defect area as a misjudgment area and correcting the misjudgment area as a non-defect area;
And 6.3, detecting all the defect areas according to the step 6.2, removing the misjudgment areas in the defect areas, and finally obtaining the defect areas.
CN202410113884.5A 2024-01-27 2024-01-27 Bus side wall plate flatness detection method based on three-dimensional point cloud and contour matching Active CN117934429B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410113884.5A CN117934429B (en) 2024-01-27 2024-01-27 Bus side wall plate flatness detection method based on three-dimensional point cloud and contour matching

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410113884.5A CN117934429B (en) 2024-01-27 2024-01-27 Bus side wall plate flatness detection method based on three-dimensional point cloud and contour matching

Publications (2)

Publication Number Publication Date
CN117934429A true CN117934429A (en) 2024-04-26
CN117934429B CN117934429B (en) 2024-07-02

Family

ID=90768197

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410113884.5A Active CN117934429B (en) 2024-01-27 2024-01-27 Bus side wall plate flatness detection method based on three-dimensional point cloud and contour matching

Country Status (1)

Country Link
CN (1) CN117934429B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118578191A (en) * 2024-07-29 2024-09-03 温州昌信电气有限公司 A method for cutting a panel of a switch housing

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020002705A1 (en) * 2018-06-29 2020-01-02 Universiteit Antwerpen Item inspection by radiation imaging using an iterative projection-matching approach
CN111024037A (en) * 2019-09-25 2020-04-17 北京工业大学 Circular shield tunnel section fitting method based on three-dimensional laser scanning technology
CN114881955A (en) * 2022-04-28 2022-08-09 厦门微亚智能科技有限公司 Slice-based annular point cloud defect extraction method and device and equipment storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020002705A1 (en) * 2018-06-29 2020-01-02 Universiteit Antwerpen Item inspection by radiation imaging using an iterative projection-matching approach
CN111024037A (en) * 2019-09-25 2020-04-17 北京工业大学 Circular shield tunnel section fitting method based on three-dimensional laser scanning technology
CN114881955A (en) * 2022-04-28 2022-08-09 厦门微亚智能科技有限公司 Slice-based annular point cloud defect extraction method and device and equipment storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LINTAO HUO 等: "Review: Research on product surface quality inspection technology based on 3D point cloud", 《ADVANCES IN MECHANICAL ENGINEERING》, vol. 15, no. 3, 25 March 2023 (2023-03-25), pages 1 - 17 *
李威祥 等: "基于图像点云的道路缺陷检测", 《计算机系统应用》, vol. 33, no. 3, 19 January 2024 (2024-01-19), pages 220 - 225 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118578191A (en) * 2024-07-29 2024-09-03 温州昌信电气有限公司 A method for cutting a panel of a switch housing

Also Published As

Publication number Publication date
CN117934429B (en) 2024-07-02

Similar Documents

Publication Publication Date Title
CN109489580B (en) An on-machine point cloud detection and compensation method for surface machining of aero-engine blades
CN110095061B (en) Vehicle form and position detection system and method based on contour scanning
CN105354880B (en) A kind of sand blasting machine people&#39;s automatic path generation method based on line laser structured light
CN118602979B (en) Weld joint morphology and surface defect online detection and evaluation method and system
CN111738985B (en) Visual detection method and system for weld joint contour
CN117934429B (en) Bus side wall plate flatness detection method based on three-dimensional point cloud and contour matching
CN110736999B (en) Railway turnout detection method based on lidar
CN113450379B (en) Method and device for extracting and analyzing profile line of section of special-shaped workpiece
CN109653045B (en) Track gauge measuring method and device
CN109483887A (en) Shaping layer contour accuracy online test method in the fusion process of selective laser
CN117433430A (en) System and method for detecting size of steel plate cutting part
CN114119957A (en) Method and device for profile detection of high-speed railway rails
García et al. Rail surface inspection system using differential topographic images
CN114140486B (en) A point cloud depth acquisition method based on normal projection
CN111738907A (en) Train pantograph detection method based on binocular calibration and image algorithm
CN118882518B (en) A digital detection system and method for glass edge grinding based on 3D visual detection
CN119477842A (en) A method for weld size measurement and defect detection based on point cloud features
Borsu et al. Automated surface deformations detection and marking on automotive body panels
Ntoulmperis et al. 3D point cloud analysis for surface quality inspection: A steel parts use case
Zhou et al. Automated detection of surface defects on sphere parts using laser and CDD measurements
CN113947583A (en) Weld joint nondestructive testing method based on deep learning two-dimensional time sequence image
Judek et al. Analysis of measurement errors in rail vehicles’ pantograph inspection system
CN110827240B (en) Positioning method and device of rail profile
CN110021027B (en) Edge cutting point calculation method based on binocular vision
CN116363080A (en) 3D gluing abnormality detection method and device based on contour synchronization time sequence

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant