-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbla.m
43 lines (42 loc) · 1.37 KB
/
bla.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
%MOVEMENT DETECTOR
%Get video from webcam and detect the movement.
%Author: Diego Orlando Barragán Guerrero
%For more information, visit: www.matpic.com
%Loja (ECUADOR)
%Electronics & Telecommunications
%*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
clc
vid = videoinput('winvideo', 1);
set(vid,'TriggerRepeat',Inf);
vid.FrameGrabInterval = 5;
start(vid);
try
% media=[];
while(vid.FramesAcquired<=110) % Stop after 110 frames
IM = getdata(vid,2);
IMGray = rgb2gray(IM(:,:,1:3));
IMbw=im2bw(IMGray,0.5);
IMneg=imadjust(IMGray,[0 1],[1 0]);
subplot(2,3,1);imshow(IM(:,:,:,1));title('Input Video-Image')
subplot(2,3,2);imshow(IMbw);title('Black & White Video')
subplot(2,3,3);imshow(IMGray);title('Gray Scale Video')
subplot(2,3,4);imshow(IMneg);title('Negative Image Video')
%*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
i1=IM(:,:,:,1);
i2=IM(:,:,:,2);
i1=rgb2gray(i1(:,:,1:3));
i2=rgb2gray(i2(:,:,1:3));
m=abs(double(i1)-double(i2))/256;
subplot(2,3,5);imshow(m);title('Movement')
% sum(sum(m))
% media=[media sum(sum(m))];
if sum(sum(m))>850
disp('Movement');beep
end
%*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
end
stop(vid);
catch
stop(vid);
end