How to save the figure generated by pcplayer
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Adam Danz
am 3 Jun. 2024
Bearbeitet: Adam Danz
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Point Cloud Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!