Add a text to video
조회 수: 7 (최근 30일)
이전 댓글 표시
How can I add any text to MP4 video uploaded to Matlab?
댓글 수: 0
답변 (2개)
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()
댓글 수: 0
Aleksandra Pestka
2018년 1월 23일
댓글 수: 2
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!