How to save the figure generated by pcplayer
13 views (last 30 days)
Show older comments
Hi, I visualize map points estimated by SLAM as a point cloud using the pcplayer. I am wondering if there is a programatic way to save the plot as a video or a figure file. I tried using saveas() function but the object created by pcplayer is different from the figure handle.
For example, suppose I have a steam of 3D point cloud data like below. What would be the best way to save the stream as a video?
player = pcplayer([0 1],[0 1],[0 1]);
while isOpen(player)
ptCloud = pointCloud(rand(1000,3,"single"));
view(player,ptCloud);
end
0 Comments
Accepted Answer
Adam Danz
on 3 Jun 2024
Edited: Adam Danz
on 5 Jun 2024
Get the figure handle from the player object produced by pcplayer.
Use VideoWriter to create a VideoWriter object and use getframe to write the figure frame on each iteration to the video.
v = VideoWriter("myvideo.avi");
cleanupVideo = @()close(v);
open(v)
player = pcplayer([0 1],[0 1],[0 1]);
fig = ancestor(player.Axes,'figure');
for i = 1:100 % <-------------here's your update loop
if ~isOpen(player)
continue
end
ptCloud = pointCloud(rand(1000,3,"single"));
view(player,ptCloud);
frame = getframe(fig);
writeVideo(v,frame)
end
clear('cleanupVideo') % not needed if this is in a function
0 Comments
More Answers (0)
See Also
Categories
Find more on Point Cloud Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!