필터 지우기
필터 지우기

How to save the figure generated by pcplayer

조회 수: 5 (최근 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 CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by