How can I plot on top of a video, and then save the new video with the plots?

23 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 10 de Abr. de 2023
Editada: MathWorks Support Team el 13 de Abr. de 2023
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'))

Más respuestas (0)

Productos


Versión

Aún no se ha introducido una versión.

Community Treasure Hunt

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

Start Hunting!

Translated by