필터 지우기
필터 지우기

How to save video from satelliteScenarioViewer?

조회 수: 63 (최근 30일)
Mike Powers
Mike Powers 2022년 10월 13일
답변: Saffan 2023년 9월 14일
Is there a way to save the video when using the satelliteScenarioViewer in the Satellite or Aerospace Comm Toolbox?
I can play it fine on my workstation but I'd like to present some animated results in a slide presentation.
  댓글 수: 3
Mike Powers
Mike Powers 2023년 8월 29일
Thanks Vinayak- when I run this code (in R2022b) I get an error:
"Unrecognized method, property, or field 'isOpen' for class 'matlabshared.satellitescenario.Viewer'."
Brian LaRocca
Brian LaRocca 2023년 9월 8일
I would like the same functionality. But I am getting the same results as Mike. I tried using a for loop, e.g. for n = 1:10 ... end to get around that and just see some saved results. However, that does not work since the satellitescenario object does not have a "step" method.

댓글을 달려면 로그인하십시오.

채택된 답변

Saffan
Saffan 2023년 9월 14일
Hi Mike,
Currently, there is no direct way to save a video from “satelliteScenarioViewer”, but there is a workaround using the “VideoWriter” class to combine each frame into a video. We can utilize the “screencapture” method from the File Exchange to obtain the required frames. Here is an example code snippet:
% Create a Scenario and a Viewer
sc = satelliteScenario(startTime,stopTime,sampleTime);
viewer = satelliteScenarioViewer(sc);
% Specify the name of the video file
videoFile = 'scenario_video.mp4';
% Create a VideoWriter object
videoWriter = VideoWriter(videoFile, 'MPEG-4');
% Set the frame rate of the video
videoWriter.FrameRate = 30;
% Open the video writer
open(videoWriter);
h=findall(0, 'Type', 'figure', 'Name', 'Satellite Scenario Viewer');
for time=startTime:minutes(1):stopTime
screencapture(h,'tempImg.png');
% Get the current frame as an image
frameImage = imread('tempImg.png');
% Write the frame to the video file
writeVideo(videoWriter, frameImage);
% Advance to the next frame
viewer.CurrentTime=time;
end
close(videoWriter);
You can choose the required playback speed of the simulation by setting the appropriate increment time in the ‘for’ loop.
Here is the link to “screencapture” method in File Exchange:
Please refer to the following documentation for more information on “VideoWriter” class:
Hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spacecraft에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by