Main Menu

Menu

Wednesday 25 May 2011

Video Edge Detection In Matlab

This is the code (c+p in the matlab command line):

vid = videoinput('winvideo')
set(vid,'TriggerRepeat',Inf);
vid.FrameGrabInterval = 5;
vid_src = getselectedsource(vid);
set(vid_src,'Tag','motion detection setup');
figure;
start(vid)
while(vid.FramesAcquired<=inf)
data = getdata(vid,2);
diff_im = imadd(data(:,:,:,1),-data(:,:,:,2));
diff_im = edge(rgb2gray(diff_im),'sobel');
imshow(diff_im);
end
stop(vid)

No comments:

Post a Comment