Golang WEB开发:初识Gin框架
308 2023-04-03 05:03:53
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)
%% 路面范围提取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...
PointNet 架构。 分类网络将 n 个点作为输入,应用输入和特征变换,然后通过最大池来聚合点要素。 输出是 k 类的分类分数。 分段网络是分类网络的扩展。 它将每个点的全局和局部特征和输出连接在一起。 “mlp” 代表多层感知器,括号中的数字是层大小。 Batchnorm 用于 ReLU 的所有层。Dropout 图层用于分类网中的最后一个 mlp。
由于点云旋转的不变性,Pointnet的解决方法是学习一个变换矩阵T ,即T − N e t 结构。由于loss的约束,使得T 矩阵训练会学习到最有利于最终分类的变换,如把点云旋转到正面。论文的架构中,分别在输入数据后和第一层特征中使用了T 矩阵,大小为3x3和64x64。其中第二个T矩阵由于参数过多,考虑添加正则项,使其接近于正交矩阵,减少点云的信息丢失
其中最典型的MLP包括包括三层:输入层、隐层和输出层,MLP神经网络不同层之间是全连接的(全连接的意思就是:上一层的任何一个神经元与下一层的所有神经元都有连接)。
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