fire frames tracking
Show older comments
Hi sir, I am a beginner of matlab user, my project is vision based fire detection, there is some problems that I can't solve it, can you please help me in my code?
In the code, I get the coordinate of motion object by using "Find" function, but how am I going to get the values of the pixels? help me please....
function trackingFF
% Load the video from an avi file.
avi = aviread('barbeq');
pixels = double(cat(4,avi(1:2:end).cdata))/255;
%clear avi
% Convert to RGB to GRAY SCALE image.
nFrames = size(pixels,4);
for f = 1:nFrames
pixels(:,:,f) = (rgb2gray(pixels(:,:,:,f)));
end
width1=240;
height1=320;
nrames=f;
for b = 2:nrames
d(:,:,b)=(imabsdiff(pixels(:,:,b),pixels(:,:,b-1)));
k=d(:,:,b);
bw(:,:,b) = im2bw(k, 0.2);
kk=bw(:,:,b);
[width height]= find(kk==1);
%Convert axes coordinates to pixel coordinates
xdata = ['width'];
ydata = ['height'];
px = axes2pix('width',xdata,30);
py = axes2pix('height',ydata,30);
A=([width height]);
bw1=bwlabel(kk);
imshow( pixels(:,:,f))
or imshow(bw1)
hold on
disp(px)
disp(py)
disp(bw(:,:,b))
size(bw(:,:,b))
hold on
se = strel('diamond', 3);
dilate1 = imdilate(k, se);
edge1 = edge(dilate1, 'canny', 0.78, 0.9);
dilate2 = imdilate(edge1, se);
closedilate2 = imclose(dilate2, se);
edgeF(:,:,b) = edge(closedilate2, 'canny', 0.78, 0.9);
edgeD =L(:,:,b);
imshow(edgeF(:,:,b))
disp(d(:,:,b))size(d(:,:,b))
col = width;
row = height;
%%use the motion coordinate which is find by "find" function then use it
%%in orginal video.
count1=1;
for h=1:width1
for w=1:height1
if(edgeF(h,w,b)>0.3)
toplength = h;
if (count1 == 1)
tplen=toplength;
count1=count1+1;
end
break
end
end
end
disp(toplength);
count2=1;
for w=1:height1
for h=1:width1
if(edgeF(h,w,b)>0.3)
leftsi = w;
if (count2 == 1)
lftln=leftsi;
count2=count2+1;
end
break
end
end
end
disp(leftsi);
disp(lftln);
widh=leftsi-lftln;
%disp(widh);
heig=toplength-tplen;
%disp(heig);
widt=widh/2;
%disp(widt);
heit=heig/2;
%disp(heit);
with=lftln+widt;
%disp(with);
heth=tplen+heit;
%disp(heth);
wth(b)=with;
%disp(with);
hth(b)=heth;
%disp(heth);
rectangle('Position',[lftln tplen widh heig],'EdgeColor','r');
%plot(with,heth, 'r*');
drawnow;
hold off
end;
function trackingFF
% Load the video from an avi file.
avi = aviread('barbeq');
pixels = double(cat(4,avi(1:2:end).cdata))/255;
%clear avi
% Convert to RGB to GRAY SCALE image.
nFrames = size(pixels,4);
for f = 1:nFrames
pixels(:,:,f) = (rgb2gray(pixels(:,:,:,f)));
end
width1=240;
height1=320;
nrames=f;
for b = 2:nrames
d(:,:,b)=(imabsdiff(pixels(:,:,b),pixels(:,:,b-1)));
k=d(:,:,b);
bw(:,:,b) = im2bw(k, 0.2);
kk=bw(:,:,b);
[width height]= find(kk==1);
%Convert axes coordinates to pixel coordinates
xdata = ['width'];
ydata = ['height'];
px = axes2pix('width',xdata,30);
py = axes2pix('height',ydata,30);
A=([width height]);
bw1=bwlabel(kk);
imshow( pixels(:,:,f))
or imshow(bw1)
hold on
disp(px)
disp(py)
disp(bw(:,:,b))
size(bw(:,:,b))
hold on
se = strel('diamond', 3);
dilate1 = imdilate(k, se);
edge1 = edge(dilate1, 'canny', 0.78, 0.9);
dilate2 = imdilate(edge1, se);
closedilate2 = imclose(dilate2, se);
edgeF(:,:,b) = edge(closedilate2, 'canny', 0.78, 0.9);
edgeD =L(:,:,b);
imshow(edgeF(:,:,b))
disp(d(:,:,b))size(d(:,:,b))
col = width;
row = height;
%%use the motion coordinate which is find by "find" function then use it
%%in orginal video.
count1=1;
for h=1:width1
for w=1:height1
if(edgeF(h,w,b)>0.3)
toplength = h;
if (count1 == 1)
tplen=toplength;
count1=count1+1;
end
break
end
end
end
disp(toplength);
count2=1;
for w=1:height1
for h=1:width1
if(edgeF(h,w,b)>0.3)
leftsi = w;
if (count2 == 1)
lftln=leftsi;
count2=count2+1;
end
break
end
end
end
disp(leftsi);
disp(lftln);
widh=leftsi-lftln;
%disp(widh);
heig=toplength-tplen;
%disp(heig);
widt=widh/2;
%disp(widt);
heit=heig/2;
%disp(heit);
with=lftln+widt;
%disp(with);
heth=tplen+heit;
%disp(heth);
wth(b)=with;
%disp(with);
hth(b)=heth;
%disp(heth);
rectangle('Position',[lftln tplen widh heig],'EdgeColor','r');
%plot(with,heth, 'r*');
drawnow;
hold off
end;
2 Comments
Image Analyst
on 11 May 2012
What do you mean by "the binary of the pixels"?
Ernest
on 15 May 2012
Answers (0)
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!