manipulating frame by frame on AVI video
Afficher commentaires plus anciens
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
Réponses (2)
yael
le 29 Fév 2012
0 votes
Walter Roberson
le 29 Fév 2012
0 votes
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 commentaires
yael
le 29 Fév 2012
Walter Roberson
le 29 Fév 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
le 4 Mar 2012
Catégories
En savoir plus sur Descriptive Statistics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!