forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointcloud_example.m
56 lines (41 loc) · 1.39 KB
/
pointcloud_example.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
48
49
50
51
52
53
54
55
56
function pointcloud_example()
% Make Pipeline object to manage streaming
pipe = realsense.pipeline();
pointcloud = realsense.pointcloud();
% Start streaming on an arbitrary camera with default settings
profile = pipe.start();
figure('visible','on'); hold on;
figure('units','normalized','outerposition',[0 0 1 1])
% Main loop
for i = 1:10000
% Obtain frames from a streaming device
fs = pipe.wait_for_frames();
% Select depth frame
depth = fs.get_depth_frame();
%color = fs.get_color_frame();
% Produce pointcloud
if (depth.logical())% && color.logical())
%pointcloud.map_to(color);
points = pointcloud.calculate(depth);
% Adjust frame CS to matlab CS
vertices = points.get_vertices();
X = vertices(:,1,1);
Y = vertices(:,2,1);
Z = vertices(:,3,1);
plot3(X,Z,-Y,'.');
grid on
hold off;
view([45 30]);
xlim([-0.5 0.5])
ylim([0.3 1])
zlim([-0.5 0.5])
xlabel('X');
ylabel('Z');
zlabel('Y');
pause(0.01);
end
% pcshow(vertices); Toolbox required
end
% Stop streaming
pipe.stop();
end