How can I plot on top of a video, and then save the new video with the plots?
24 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2015-12-23
编辑: MathWorks Support Team
2023-4-13
I would like to read in a video file (MP4), plot some points and lines on top of every frame, and then save this to a new video file with the plotted points and lines in place. The plotted points would change position based on calculations done in every frame. How can I accomplish this?
采纳的回答
MathWorks Support Team
2023-4-10
编辑:MathWorks Support Team
2023-4-13
In short, this can be done with the following steps:
1) Create a
object for the input video file.
2) Create a VideoWriter object for the output video file, and open it for editing.
2) Loop through the video, using readFrame to get each video frame, and displaying it to an axes.
3) Plot the desired points and lines on top of the image.
4) Capture the current axes appearance with the getframe function.
5) Save each of the new frames to the VideoWriter object with the writeVideo function.
6) When finished, close the output video file.
Please see the attached file for an example of one way that this can be accomplished.
For MATLAB R2017b documentation on the same, please use the following command:
>> web(fullfile(docroot, 'matlab/ref/videowriter.html'))
>> web(fullfile(docroot, 'matlab/ref/videoreader.html'))
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!