-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathmain.m
41 lines (27 loc) · 933 Bytes
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function main()
% specify training data directory path
root_dir = './data_object_velodyne/training/velodyne/';
% specify training label directory path
label_dir = './training/label_2/';
% specify output directory path
out_dir = './grid_files/';
% specify resolution of grid
res = 10;
for frame = 1:1500
% load velodyne points
fid = fopen(sprintf('%s%06d.bin',root_dir,frame),'rb');
velo = fread(fid,[4 inf],'single')';
% remove every 5th point for display speed
%velo = velo(1:5:end,:);
fclose(fid);
% remove all points behind image plane (approximation
idx = velo(:,1)<5;
velo(idx,:) = [];
% convert pcl to grid file with the specified resolution
grid = pcltogrid(velo, res);
filename = sprintf('%s%06d.csv',out_dir,frame);
csvwrite(filename, grid);
train_label = sprintf('%s%06d.txt',label_dir,frame);
copyfile(train_label, out_dir);
end
end