-
Notifications
You must be signed in to change notification settings - Fork 0
/
carla_dicp.m
47 lines (36 loc) · 1.15 KB
/
carla_dicp.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
42
43
44
45
46
47
saveAsFileName = 'carla2';
num_frames = 465;
fig = figure;
set(fig, 'Position', [ 100, 100, 560, 420 ]);
title('Velocity Color-coded Point Cloud Animation');
xlabel('X');
ylabel('Y');
zlabel('Z');
cd
myWriter = VideoWriter(strcat(Aeva_dataset, '/', datapath, saveAsFileName), 'Motion JPEG AVI');
myWriter.Quality = 100;
myWriter.FrameRate = 10;
open(myWriter);
for fileIter = 1:num_frames
fileName = strcat(datapath, sprintf('%0.5d', fileIter), '.bin');
data = fread(fopen(fileName, "rb"), [4, inf], 'float32')';
pc = pointCloud(data(:, 1:3), 'Intensity', data(:, 4)); %doppler
pcPlot = pcshow(pc, "ColorSource","Intensity");
xlim([0 300]);
ylim([-20 20]);
zlim([0 30]);
xlabel('X'); ylabel('Y'); zlabel('Z');
axis on;
c = colorbar;
c.Color = [1 1 1];
c.Label.String = 'velocity (m/s)';
c.Label.FontSize = 12;
c.Label.Color = [1 1 1];
% caxis([min(data(:,4)) max(data(:,4))]);
drawnow;
frame_data = getframe(fig);
frame_data.cdata = imresize(frame_data.cdata, [420, 560]);
writeVideo(myWriter, frame_data);
clf; % Clear figure for the next iteration
end
close(myWriter);