manipulating frame by frame on AVI video
Ältere Kommentare anzeigen
hi all!
first of all i will say i usually don't write scripts and MATLAB is not my cup of tea ;-)
having said that- i really need some help with basic code that i need to write.
i am reading an AVI code and i need to mark one fixed pixel so when the movie is running i will see this mark
i tried to write a code but surprisingly it does not working.
the code;
clc
clear all
x=VideoReader('focus_m1.avi');
%frame = x.read(1);
nFrames = x.NumberOfFrames;
for i=1:10
%i=1:nFrames
currFrame = x.read(i)
%fig = figure(i)
imshow(currFrame)
hold on
plot (333,397,'r-.x','MarkerSize',20)
M=getframe;
end
movie(M)
any help will be a saver
yael
Antworten (2)
yael
am 29 Feb. 2012
0 Stimmen
Walter Roberson
am 29 Feb. 2012
0 Stimmen
The data you are trying to write out is constant, and in a constant location. You can read a frame, set the specific locations in the frame array to the constant values, and then write the adjusted frame, without ever displaying the frame.
3 Kommentare
yael
am 29 Feb. 2012
Walter Roberson
am 29 Feb. 2012
x = VideoReader('focus_m1.avi');
xout = VideoWriter('focus_m1x.avi');
xout.FrameRate = x.FrameRate;
open(xout);
red3x3 = repmat(reshape([1 0 0], [1 1 3]), 2, 2, 1); %3x3 block of red
nFrames = x.NumberOfFrames;
for i = 1 : nFrames
currFrame = x.read(i);
currFrame(333:335, 396:398, :) = red3x3;
xout.write(currFrame);
end
xout.close;
clear x; %no close method for reader
yael
am 4 Mär. 2012
Kategorien
Mehr zu Descriptive Statistics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!