matlab 交通流中机动车辆的检测


交通流中机动车辆的轮廓提取与标识 附带视频
资源截图
代码片段和文件信息
clc;clear all
mov=mmreader(‘Noname.avi‘);
nframe=get(mov‘NumberOfframes‘);
I=read(mov1);%读取第一帧
  %批量读图并处理
  
for k = 1:3:nframe-180
Im{k} =read(movk);

Imgray{k}=rgb2gray(Im{k});
gray{k}=Imgray{k};
[Imgray{k}t]=edge(Imgray{k}‘canny‘);%canny边缘检测
   i = k ;
  if (i==1);
   sub{1}=Imgray{1i};%把元素从cell中提取出来
   n=i;
   else
    sub{i}=Imgray{1i}-Imgray{1n};%帧差法提取轮廓
    n=i;
    H = fspecial(‘unsharp‘);
    sub{i}=imfilter(sub{i}H‘replicate‘);
   sub{i}=bwperim(sub{i}4);
   %figure imshow(sub{i} )
   se90=strel(‘line‘390);%增强
   se0=strel(‘line‘30);
   sub{i}=imdilate(sub{i}[se90 se0]);
   %figure imshow(sub{i} )
   sub{i}=imfill(sub{i}‘holes‘);%填充
   seD=strel(‘rectangle‘[33]);
    sub{i}=imerode(sub{i}seD);
    sub{i}=imopen(sub{i}seD);
    sub{i}=imclose(sub{i}seD);
    % figure imshow(sub{i} )
     
     
     [Lnum] = bwlabel(sub{i}8) ;%L==sub{i}是与图像相同大小的矩阵,num是图像中连通区域的个数;
     stats = regionprops(L‘boundingbox‘‘filledArea‘‘centroid‘);
     taggedCars( :: )=gray{k};
     if any( L(:) )
      for i=1:length(stats)
           if ((stats(i).FilledArea > 350 &&stats(i).FilledArea<6000));
              centroid=stats(i).Centroid;
               box =stats(i).BoundingBox;
               area=stats(i).FilledArea;
               left=round(box(1));
                top=round(box(2));
                right=round(box(1)+box(3)-1);
                bottom=round(box(2)+box(4)-1);
                if( abs(top - bottom)/abs(right - left) > 3 || abs(right - left)/abs(top - bottom) > 3 )
                   continue;
                end 
                taggedCars(topleft:right)=255;                                    %画矩形框%
                taggedCars(bottomleft:right)=255;
                taggedCars(top:bottomleft)=255;
                taggedCars(top:bottomright)=255;
           end
        end
     end
      %figureimshow(taggedCars);
   
    
  end
end
frameRate=get(mov‘frameRate‘);
implay(taggedCarsframeRate);


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2030  2011-04-30 01:45  cheliangjiancegrowcut.m

     文件    1977716  2011-04-28 09:30  cheliangjianceNoname.avi

     目录          0  2011-04-30 14:27  cheliangjiance

----------- ---------  ---------- -----  ----

              1979746                    3


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)