其实文档看懂了还是相当简单,奈何本人对matlab还是相当不熟悉,于是浪费了一些时间,在这里简单的做个记录,align.m是align在matlab里的封装,可以看到它的构造函数需要一个stream对象,而stream.m里介绍了stream这个对象,里边有几个枚举值,于是我们就可以知道如何使用align函数了
这里通过修改 librealsense 里的depth_example.m来举例
% Make Pipeline object to manage streaming
pipe = realsense.pipeline();
% Start streaming on an arbitrary camera with default settings
profile = pipe.start();
% Get frames. We discard the first couple to allow
% the camera time to settle
for i = 1:5
fs = pipe.wait_for_frames();
end
% Stop streaming
pipe.stop();
% Align
to_depth = realsense.stream(1)
align = realsense.align(to_depth)
a_fs = align.process(fs)
% Select depth frame
depth = a_fs.get_depth_frame();
color = a_fs.get_color_frame();
% Get actual data and convert into a format imshow can use
% (Color data arrives as [R, G, B, R, G, B, ...] vector)
depth_data = depth.get_data();
color_data = color.get_data();
depth_img = permute(reshape(depth_data,[1,depth.get_width(),depth.get_height()]),[3,2,1]);
color_img = permute(reshape(color_data,[3,color.get_width(),color.get_height()]),[3,2,1]);
% Display image
%imshow(color_img);