function d = tracking(video)
%功能:跟踪视频中的运动目标并显示
%输入:video-待跟踪的视频 输出:d-差值图像序列
%读入视频图像
if ischar (video) %将相邻两帧图像进行做差,并将差值图像转换为二值图像
for 1 = 2:nrames
a(:,:,1)=(abc(pixel(:,:,1)-pixel(:,:,1-1)));
k=d(:,:,1);
bw(:.:,1) = im2bw(k,2);
bw1 = bwlabel()(bw(:,:,1));
inshow(bw(:,:,1))
hold on %标记运动物体的位置并显示
cou =1;
for h=1:rows
for w =1:cols
if(bw(h,w,1)>0.5)
toplen = h;
if(cou = =1)
tpln =toplen;
end
cou= cou+ 1;
break
end
end
end
disp(toplen);
coun = 1;
for w =1:cols
for h = 1:rows
if(bw(h,w,1)>0.5)
leftsi = w;
if(coun = =1)
lftln = leftsi;
coun = coun +1;
end
break
end
end
end
disp(leftsi);
disp(lftln);
widh = leftsi - lftiln;
heig = toplen - tpln;
widt = widh/2;
disp(widt);
heit = heig/2;
with = lftln + widt;
heth = tpln +heit;
wth(1) = with;
hth(1) = heth;
dis(heit);
disp(widt);
disp(heig);
rectangle('Position',[lftln tpln widh heig],'EdgeColor','r');
disp(with);
disp(heth);
plot(with,heth,'r');
drawnow;
hold off
end
vehicle-frame.zip_帧差_车辆 检测_车辆检测_车辆运动检测_运动车辆检测
版权申诉
197 浏览量
2022-07-15
04:44:44
上传
评论
收藏 810B ZIP 举报
小贝德罗
- 粉丝: 71
- 资源: 1万+