2022-05-19

2022-05-19

学习汇报2022-05-19

1 点云数据处理

1.1 预处理

  • 原始pcap数据

clcclearclosefilename= 'D:\leidashuji\LIDAR_0515\01.pcap'; %文件位置    veloReader = velodyneFileReader(filename,"VLP16"); % 读取.pcap文件ptCloud_original=cell(1,veloReader.NumberOfFrames); % 定义储存原始点云数据的元组num=60;%过多的点云帧的累积误差有点大,这里设置为60帧for i=1:num%veloReader.NumberOfFramesptCloud_original{1,i}=readFrame(veloReader,i); % 依次读取每次采样周期的数据,将其保存为pointCloud格式
  • 点云累积
roi = [-20 20 -20 40 -4 1]; % roi区域筛选k=1;indices_1{1,i} = findPointsInROI(ptCloud_original{1,i},roi);ptCloud_interest{1,i}=select(ptCloud_original{1,i},indices_1{1,i});endptCloudRef = ptCloud_interest{1}; % 将第1帧点云定义为参考点云ptCloudCurrent = ptCloud_interest{2}; % 将第2帧定义为待处理点云%% 下采样gridSize = 0.5; %定义下采样网格大小percentage=0.5;fixed = pcdownsample(ptCloudRef, 'random', percentage);moving = pcdownsample(ptCloudCurrent, 'random', percentage); % 下采样tform = pcregistericp(moving, fixed, 'Metric','pointToPlane','Extrapolate', true); % matlab自带ICP算法,得到moving点云至fixed点云之间的坐标转换矩阵tformptCloudAligned = pctransform(ptCloudCurrent,tform); % 将第2帧点云通过求得的坐标转换矩阵进行转换mergeSize = 0.025;ptCloudScene = pcmerge(ptCloudRef, ptCloudAligned, mergeSize);accumTform = tform; mergeSize = 0.025;ptCloudScene = pcmerge(ptCloudRef, ptCloudAligned, mergeSize);figurehAxes = pcshow(ptCloudScene);title('Updated world scene')%% 设置轴属性以更快地渲染hAxes.CameraViewAngleMode = 'auto';hScatter = hAxes.Children;     for i = 3:num%length(ptCloud_original) % 依次检索没帧点云        ptCloudCurrent = ptCloud_interest{i};% 将第i帧数据赋值给待处理点云 ptCloudCurrent        fixed = moving; % 将前一帧的移动点云作为后一帧点云的参考点云        moving = pcdownsample(ptCloudCurrent, 'gridAverage', gridSize);% 将待处理点云作为移动点云        % 应用CIP算法得到moving到fixed的坐标转换矩阵        tform = pcregistericp(moving, fixed, 'Metric','pointToPlane','Extrapolate', true);        % 通过当前转换矩阵乘以前面累积的转换矩阵,得到当前帧转换至第一帧的坐标转换矩阵        accumTform = affine3d(tform.T * accumTform.T);        ptCloudAligned = pctransform(ptCloudCurrent, accumTform);        % 更新全局累积的点云数据        ptCloudScene = pcmerge(ptCloudScene, ptCloudAligned, mergeSize);        hScatter.XData = ptCloudScene.Location(:,1);        hScatter.YData = ptCloudScene.Location(:,2);        hScatter.ZData = ptCloudScene.Location(:,3);    endfigurepcshow(ptCloudScene) 
  • 坐标转换
%% 坐标转换thetax = 23.46*pi/180;%thetay =0*pi/180;thetaz = 0;rotx = [1 0 0; ...      0 cos(thetax) -sin(thetax); ...      0 sin(thetax)  cos(thetax)];rotz=[cos(thetaz)  sin(thetaz) 0; ...      -sin(thetaz) cos(thetaz) 0; ...               0          0  1];roty=[cos(thetay) 0 sin(thetay);          0      1     0;    -sin(thetay) 0 cos(thetay)];trans = [0, 0, 0];tform = rigid3d(roty*rotx*rotz,trans);ptcloud_zuobiao=pctransform(ptCloudScene,tform);figurepcshow(ptcloud_zuobiao) 
  • 路面范围提取,保存为.csv文件
%% 路面范围提取roi = [-1 1 2 4 -2 -0.5]; % roi区域筛选indices_2 = findPointsInROI(ptcloud_zuobiao,roi);ptCloud_road=select(ptcloud_zuobiao,indices_2);figurepcshow(ptCloud_road)csvwrite('lidar_01.csv',ptCloud_road.Location )%将预处理提取的路面点云保存为CSV格式%注:lidar_01.csv的名称需根据前面导入pcap文件进行更改,如lidar_02,lidar_03...

1.2 通过CloudCompare打标签流程

CloudCompare下载地址:https://www.cloudcompare.org/

  • 导入csv点云文件

  • 直接apply

  1. 点击lidar_01-cloud

  1. 点击Edit>Mesh>Delaunay2.5D(best fitting plane)

  1. 默认0

  1. 平滑:点击Edit>Mesh>smooth

  1. 迭代次数:20,平滑因子:0.2

  1. 添加Z坐标参考,以高程图渲染点云

  1. 将.mmesh网格转换为点云格式,采样点数量设置为100000

  1. 点击生成的.sampled数据

  1. 点击分割按钮

  1. 鼠标左键连续点击框选凹坑或凸起区域,注:鼠标左键点击间距应尽可能小,完成框选后鼠标右键确定。再按图中第2步,第3步操作。如果点云中有多个凹坑和凸起,重复第10步

  1. 对分割后的点云添加标签:将lidar_01-cloud删除,方便后续保存

  1. 依次选择分割后点云,如选择第2个为凸起点云,第1个可看作是正常路面点云

  1. 添加分类标签,注:统一将正常路面设为1,凸起设为2,凹坑设为3

  1. 标签全部设置完后,合并点云,首先全选点云(记得在第11步删除lidar_01-cloud),点击合并按钮

  1. 合并后选择Classification可查看分割状态

  1. 导出为.csv格式,点击保存按钮,保存为csv格式

  1. 导出设置,精度选择8和6,分隔符选择comma,header全选

  1. 导出数据如图所示

2 基于pointnet的点云语义分割

2.1 pointnet介绍

  • PointNet 架构。 分类网络将 n 个点作为输入,应用输入和特征变换,然后通过最大池来聚合点要素。 输出是 k 类的分类分数。 分段网络是分类网络的扩展。 它将每个点的全局和局部特征和输出连接在一起。 “mlp” 代表多层感知器,括号中的数字是层大小。 Batchnorm 用于 ReLU 的所有层。Dropout 图层用于分类网中的最后一个 mlp。

  • 由于点云旋转的不变性,Pointnet的解决方法是学习一个变换矩阵T ,即T − N e t 结构。由于loss的约束,使得T 矩阵训练会学习到最有利于最终分类的变换,如把点云旋转到正面。论文的架构中,分别在输入数据后和第一层特征中使用了T 矩阵,大小为3x3和64x64。其中第二个T矩阵由于参数过多,考虑添加正则项,使其接近于正交矩阵,减少点云的信息丢失

  • 其中最典型的MLP包括包括三层:输入层、隐层和输出层,MLP神经网络不同层之间是全连接的(全连接的意思就是:上一层的任何一个神经元与下一层的所有神经元都有连接)。

2.2 python复现

  • modelnet40_normal_resampled数据集下载
  • 该数据集针对室内场景的分割,实现的是对室内各个物体的分类
  • 目前仅实现对物体分类的实现,未能实现对场景语义分割的实现

2.2 matlab实现

  • csv数据处理
 filename_train=dir('D:\leidashuji\lidar_label\code\train_data\*.csv');filename_test=dir('D:\leidashuji\lidar_label\code\test_data\*.csv'); for i=1:length(filename_train)csvname_trian=[filename_train(i,1).folder '\' filename_train(i,1).name];csvdata_trian{i} = readmatrix(csvname_trian);data_orgin_trian{i} =csvdata_trian{i}(:,1:4);numPoint_trian(i)=length(data_orgin_trian{i});pointcloud_trian{i}=pointCloud(data_orgin_trian{i}(:,1:3));endfor i=1:length(filename_test)csvname_test=[filename_test(i,1).folder '\' filename_test(i,1).name];csvdata_test{i} = readmatrix(csvname_test);data_orgin_test{i} =csvdata_test{i}(:,1:4);numPoint_test(i)=length(data_orgin_test{i});pointcloud_test{i}=pointCloud(data_orgin_test{i}(:,1:3));end%% 预览数据classNames = [ "ground" ;"humps" ;"pothloes"];for i=1:9subplot(3,3,i)labels=data_orgin_trian{i}(:,4);ax = pcshow(pointcloud_trian{i}.Location,labels);helperLabelColorbar(ax,classNames);end
  • 数据预览

免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部