Add a text to video

8 ビュー (過去 30 日間)
Aleksandra Pestka
Aleksandra Pestka 2018 年 1 月 20 日
コメント済み: Aleksandra Pestka 2018 年 1 月 24 日
How can I add any text to MP4 video uploaded to Matlab?

回答 (2 件)

Walter Roberson
Walter Roberson 2018 年 1 月 20 日
Read frames and use computer vision insertText() and write the frame out.
With older MATLAB it would be vision.textInserter instead of insertText()

Aleksandra Pestka
Aleksandra Pestka 2018 年 1 月 23 日
I've read frames from my video. The code looks like:
v= VideoReader('My_movie.mp4');
currAxes = axes;
while hasFrame(v)
vidFrame = readFrame(v);
image(vidFrame, 'Parent', currAxes);
currAxes.Visible = 'off';
pause(1/v.FrameRate);
end
Now I want to use:
RGB = insertText(I,position,text)
However, I don't know what is I i this case. Can anyone suggest me what to do?
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 1 月 23 日
v = VideoReader('My_movie.mp4');
currAxes = axes;
while hasFrame(v)
vidFrame = readFrame(v);
I = vidFrame;
RGB = insertText(I,position,text);
vidFrame = RGB;
image(vidFrame, 'Parent', currAxes);
currAxes.Visible = 'off';
pause(1/v.FrameRate);
end
... which can of course be made shorter.
v = VideoReader('My_movie.mp4');
currAxes = axes;
while hasFrame(v)
image( insertText(readFrame(v)), position, text);
currAxes.Visible = 'off';
pause(1/v.FrameRate);
end
But you are better off using the more efficient:
v = VideoReader('My_movie.mp4');
currAxes = axes;
first = true;
while hasFrame(v)
RGB = insertText(readFrame(v)), position, text);
if first
h = image(RGB);
currAxes.Visible = 'off';
first = false;
else
h.CData = RGB;
end
pause(1/v.FrameRate);
end
Aleksandra Pestka
Aleksandra Pestka 2018 年 1 月 24 日
Thank you so much!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by