How do I record a .bag file using the MATLAB RealSense wrapper?
I have tried creating a recorder object and using the cfg.enable_record_to_file() function but neither seem to work. When troubleshooting, I keep getting various errors that are coming from the recorder class.
Here's the script I've been trying to run.
% Make Config object to manage pipeline settings
cfg = realsense.config();
% Tell pipeline to record to the given rosbag file
cfg.enable_record_to_file('test.bag');
% Make Pipeline object to manage streaming
pipe = realsense.pipeline();
pointcloud = realsense.pointcloud();
% Start streaming from the rosbag with default settings
profile = pipe.start();
% Get streaming device's name
dev = profile.get_device();
name = dev.get_info(realsense.camera_info.name);
recorder = realsense.recorder(dev,'test.bag');
figure('visible','on'); hold on;
figure('units','normalized','outerposition',[0 0 1 1])
% Main loop
for i = 1:100
% 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();
-
Hi Yalwis Discussions in the links below about recording a bag file in the RealSense MATLAB wrapper recommend using cfg.enable_record_to_file('FILEPATH'); which your script already basically does.
https://github.com/IntelRealSense/librealsense/issues/6057
https://github.com/IntelRealSense/librealsense/issues/9773#issuecomment-922283007
I note that in your pipe.start line, you have not placed cfg in the brackets. Doing so is usually necessary to inform the script that it should use the cfg instructions provided in the lines above the pipe.start instruction, otherwise the cfg instructions will be ignored by the script and it would not use cfg.enable_record_to_file. So please try changing the pipe.start line to the one below.
profile = pipe.start(cfg);
Please sign in to leave a comment.
Comments
2 comments