How to save the figure generated by pcplayer

13 ビュー (過去 30 日間)
Daigo
Daigo 2024 年 6 月 3 日
編集済み: Adam Danz 2024 年 6 月 5 日
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

採用された回答

Adam Danz
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 件)

カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by