disuniting of structures and design principles. joint deformation
Posts: 14,118
Threads: 61
Joined: Oct 2014
This code should detect smoke in the video and the alarm will be active, but the active warning for all videos, even the videos will not smoke.
vid=uigetfile;
vid=mmreader(vid);
numFrames = vid.NumberOfFrames;
n=numFrames;
for i =1:n
frames = read(vid,i);
imwrite(frames,[int2str(i) '.jpg']);
end
frm1=rgb2gray(imread('1.jpg'));
for j=1:n
frm2=([num2str(j),'.jpg']);
p1=(imread(frm2,'jpg'));
p2=(rgb2gray(p1));
res=abs(double(p2)-double(frm1));
astn=get(handles.edt,'string');
astn=str2num(astn);
ast=res>astn;
bw=bwareaopen(ast,500);
R=p1(:,:,1);
G=p1(:,:,2);
B=p1(:,:,3);
xr=R(bw);
r=mean(xr);
xg=G(bw);
g=mean(xg);
xb=B(bw);
b=mean(xb);
avg=(r+g+b)/3;
S=(abs(r-avg)+abs(b-avg)+abs(g-avg))/3;
if (S<astn)
set(handles.text1,'visible','on');
beep
subplot(211)
h1 = image;
axis ij
imshow(p1,h1);
pause(0.5);
set(handles.text1,'visible','off');
pause(0.5);
end;
end