那位高人给加个注释啊,本人小白,function d = tracking(video)if ischar(video)% Load the video from an avi file.avi = aviread(video);pixels = double(cat(4,avi(1:2:end).cdata))/255;clear avielse% Compile the pixel data into a single arraypix

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 11:28:11

那位高人给加个注释啊,本人小白,function d = tracking(video)if ischar(video)% Load the video from an avi file.avi = aviread(video);pixels = double(cat(4,avi(1:2:end).cdata))/255;clear avielse% Compile the pixel data into a single arraypix
那位高人给加个注释啊,本人小白,
function d = tracking(video)
if ischar(video)
% Load the video from an avi file.
avi = aviread(video);
pixels = double(cat(4,avi(1:2:end).cdata))/255;
clear avi
else
% Compile the pixel data into a single array
pixels = double(cat(4,video{1:2:end}))/255;
clear video
end
% Convert to RGB to GRAY SCALE image.
nFrames = size(pixels,4);
for f = 1:nFrames
% F = getframe(gcf);
% [x,map]=frame2im(F);
% imwrite(x,'fln.jpg','jpg');
% end
pixel(:,:,f) = (rgb2gray(pixels(:,:,:,f)));
end
rows=240;
cols=320;
nrames=f;
for l = 2:nrames
d(:,:,l)=(abs(pixel(:,:,l)-pixel(:,:,l-1)));
k=d(:,:,l);
% imagesc(k);
% drawnow;
% himage = imshow('d(:,:,l)');
% hfigure = figure;
% impixelregionpanel(hfigure,himage);
% datar=imageinfo(imagesc(d(:,:,l)));
% disp(datar);
bw(:,:,l) = im2bw(k,.2);
bw1=bwlabel(bw(:,:,l));
imshow(bw(:,:,l))
hold on
% % for h=1:rows
% for w=1:cols
%
% if(d(:,:,l)< 0.1)
% d(h,w,l)=0;
% end
% end
%
% end
% % disp(d(:,:,l));
% % size(d(:,:,l))
cou=1;
for h=1:rows
for w=1:cols
if(bw(h,w,l)>0.5)
% disp(d(h,w,l));
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,l)>0.5)
leftsi = w;
if (coun == 1)
lftln=leftsi;
coun=coun+1;
end
break
end
end
end
disp(leftsi);
disp(lftln);
% % drawnow;
% % d = abs(pixel(:,:,l),pixel(:,:,l-1));
% % disp(d);
% s = regionprops(bw1,'BoundingBox');
% % centroids = cat(1,s.Centroid);
%
% % ang=s.Orientation;
%
% % plot(centroids(:,1),centroids(:,2),'r*')
% for r = 1 :length(s)
% rectangle('Position',s(r).BoundingBox,'EdgeColor','r');
%
% % plot('position',s(r).BoundingBox,'faceregion','r');
% end
%
% % disp(ang);
% % imaqmontage(k);
widh=leftsi-lftln;
heig=toplen-tpln;
widt=widh/2;
disp(widt);
heit=heig/2;
with=lftln+widt;
heth=tpln+heit;
wth(l)=with;
hth(l)=heth;
disp(heit);
disp(widh);
disp(heig);
rectangle('Position',[lftln tpln widh heig],'EdgeColor','r');
disp(with);
disp(heth);
plot(with,heth,'r*');
drawnow;
hold off
end;
% wh=square(abs(wth(2)-wth(nrames)));
% ht=square(abs(hth(2)-hth(nrames)));
% disp(wth(1
% distan=sqrt(wh+ht);
%
% disp(distan);

那位高人给加个注释啊,本人小白,function d = tracking(video)if ischar(video)% Load the video from an avi file.avi = aviread(video);pixels = double(cat(4,avi(1:2:end).cdata))/255;clear avielse% Compile the pixel data into a single arraypix
function d = tracking(video)
if ischar(video)

% 视频是否为字符数组
avi = aviread(video);
pixels = double(cat(4,avi(1:2:end).cdata))/255;
clear avi
else
% 否则直接读取视频中的帧,间隔取帧,得到一个四维的矩阵,里面放的是彩色图像
pixels = double(cat(4,video{1:2:end}))/255;
clear video
end
% 将每一帧的彩色图像转化为灰度图像
nFrames = size(pixels,4);
for f = 1:nFrames
% F = getframe(gcf);
% [x,map]=frame2im(F);
% imwrite(x,'fln.jpg','jpg');
% end
pixel(:,:,f) = (rgb2gray(pixels(:,:,:,f)));
end
rows=240;
cols=320;
nrames=f;
% 下面就是利用帧间做差发进行运动目标的跟踪
for l = 2:nrames
% 后一帧减去前一帧
d(:,:,l)=(abs(pixel(:,:,l)-pixel(:,:,l-1)));
k=d(:,:,l);
% imagesc(k);
% drawnow;
% himage = imshow('d(:,:,l)');
% hfigure = figure;
% impixelregionpanel(hfigure, himage);
% datar=imageinfo(imagesc(d(:,:,l)));
% disp(datar);
bw(:,:,l) = im2bw(k, .2);% 二值化

bw1=bwlabel(bw(:,:,l));% 连通标记
imshow(bw(:,:,l))%显示图像
% imshow(pixelsrgb(:,:,:,l)); % 显示彩色图像,标出运动……
hold on

% % for h=1:rows
% for w=1:cols
%
% if(d(:,:,l)< 0.1)
% d(h,w,l)=0;
% end
% end
%
% end

% % disp(d(:,:,l));
% % size(d(:,:,l))
cou=1;
% 下面的目的就是得到二值图像中目标的大小,并矩形框出来,连续显示
for h=1:rows
for w=1:cols
if(bw(h,w,l)>0.5)


% disp(d(h,w,l));
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,l)>0.5)

leftsi = w;


if (coun == 1)
lftln=leftsi;
coun=coun+1;
end
break
end

end
end
disp(leftsi);
disp(lftln);
% % drawnow;
% % d = abs(pixel(:, :, l), pixel(:, :, l-1));
% % disp(d);

% s = regionprops(bw1, 'BoundingBox');
% % centroids = cat(1, s.Centroid);
%
% % ang=s.Orientation;
%
% % plot(centroids(:,1), centroids(:,2), 'r*')
% for r = 1 : length(s)
% rectangle('Position',s(r).BoundingBox,'EdgeColor','r');
%
% % plot('position',s(r).BoundingBox,'faceregion','r');
% end
%
% % disp(ang);
% % imaqmontage(k);
widh=leftsi-lftln;
heig=toplen-tpln;
widt=widh/2;
disp(widt);
heit=heig/2;
with=lftln+widt;
heth=tpln+heit;
wth(l)=with;
hth(l)=heth;
disp(heit);
disp(widh);
disp(heig);
rectangle('Position',[lftln tpln widh heig],'EdgeColor','r');
disp(with);
disp(heth);
plot(with,heth, 'r*');
drawnow;
hold off
end;
% wh=square(abs(wth(2)-wth(nrames)));
% ht=square(abs(hth(2)-hth(nrames)));
% disp(wth(1
% distan=sqrt(wh+ht);
%
% disp(distan);

那位高人给加个注释啊,本人小白,function d = tracking(video)if ischar(video)% Load the video from an avi file.avi = aviread(video);pixels = double(cat(4,avi(1:2:end).cdata))/255;clear avielse% Compile the pixel data into a single arraypix 那位英语高人给本人介绍一下 英语四级复习应该用那本英语书 是新概念的那册书 高中物理怎么学啊?我就是学不懂.那位高人给我点拨一下啊~ 那位英语高人给我翻译一下 有个数学符号不认识这个是在高等数学长提到的符号 那位高人给解答下 如何养壁虎?我想养 只 但是不知道怎么养 那位高人给个 明确的 养 法``````` 三星neto2 7100怎么把程序安装到sd卡,上本人小白,请给位大神给个明细的说明谢谢! 那位高人能说下镗床平旋盘怎么做吗,做好能给个简单的图纸,或者做个简易的镗床刀杆能镗槽就行 中国银行的不可撤销的跟单信用证中文翻译本人英文太差;那位仁兄能给我发一份中文的不可撤销的跟单信用证,我将不胜感激!再加一些注释.(中国银行的) 那位高人可以帮我解这个几何题啊?求阴影部分面积.这是小学题,尽量用小学的知识本人比较愚钝 高人能给点雅思口语话题吗?我想练习,那位高人能给我点雅思口语话题? “荏苒”是什么意思啊?那位高人解释一下.谢了啊 word2007中如何加注释符号不是脚注和尾注,就是给文字后面的右上脚标记个括号1或圈1的注释符号就行.还有啊,word2007在哪里给文字注音啊?那,我再申明一遍,我不要中学语文课本里的那种脚注!我 怎么解方程啊 请给位高人教教我 还可以举个例子来说明一下 Miracles happen every day 为什么happen 不加S 我英语比较烂 那位高人能帮我看看 为什么 Miracle要加S啊 唉,在这公司两年了,一直也没涨工资,那位大神给编个要求涨薪的英文邮件啊(老板一直在国外).本人英文文盲,涨了工资请你吃饭哈!单位是一个小外企,我2011年7月份入职到现在两年了,工资你 please help me translate the following setence into english! 麻烦那位高人给翻译 只有年年春草生 御爱黄花晚节清 遥知雨后山光好 沛然甘泽以时行 那位高人给解释一下