smoke detection, fix problem
古いコメントを表示
hi, this code must detect smoke in the video and alarm will active, but the warning active for all videos, even the videos do not smoke. how do i fix it?
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
1 件のコメント
aisha khan
2019 年 6 月 25 日
hello sir, did you correct the code?
回答 (1 件)
Tawakal
2013 年 10 月 13 日
0 投票
Dear Ehsan I think it will be good if you post the videos that has been used in the code as well along with the complete code (means GUI).Only after that anyone will be able to help you.
カテゴリ
ヘルプ センター および File Exchange で Video Formats and Interfaces についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!