How to save the figure generated by pcplayer
11 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Adam Danz
2024-6-3
编辑:Adam Danz
2024-6-5
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Point Cloud Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!