昨日数学实验

我们学校每年都有一个叫做“三下乡”活动,我被院系安排到教授的科研实践队,可害死我了。要从新学习数学实验,还要建立数学模型,本来上课就没有好好地听 ,感觉要从新学习matlab。直到现在还没有建立起三维图形。还没有弄到一半。我的弄的是“

视频中人体跟踪与检测算法的设计”  好难啊,

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

 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);



bw(:,:,l) = im2bw(k, .2);
   
   bw1=bwlabel(bw(:,:,l));
   imshow(bw(:,:,l))
   hold on

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); 



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;

这些代码都读不懂,好难办。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章