I am working about smart parking system with video processing I need to scan just special area for parking system.I tried to scan just special area but ı could not.When ı try that the second car's rectangular is on the first car rectangular.

1 view (last 30 days)
vid=videoinput('winvideo',1,'YUY2_320x240'); set(vid,'FramesPerTrigger',Inf); set(vid,'ReturnedColorspace','rgb') vid.FrameGrabInterval=10; start(vid); while(vid.FramesAcquired<=1000) data=getsnapshot(vid);
%%Aşağıdaki bölümde bir kaç değişiklik yapılıp 1-100 pixel arası ve 139-240 %%pixelleri arası görüntü taraması yapılmak istenmektedir.Ayrıca oto parkın %%boş kısımları boşken yeşil kutucuklar içerisine alinmak istenmektedir. Im1=data(1:160,1:60,:); r1mat=Im1(:,:,1); g1mat=Im1(:,:,2); b1mat=Im1(:,:,3); Im2=data(1:160,80:140,:); r2mat=Im2(:,:,1); g2mat=Im2(:,:,2); b2mat=Im2(:,:,3);
%%Plot the data levelr=0.5; levelg=0.5; levelb=0.5; i1_1=im2bw(r1mat,levelr); i2_1=im2bw(g1mat,levelg); i3_1=im2bw(b1mat,levelb); Isum=(i1_1&i2_1&i3_1); i1_2=im2bw(r2mat,levelr); i2_2=im2bw(g2mat,levelg); i3_2=im2bw(b2mat,levelb); Isum_2=(i1_2&i2_2&i3_2);
Icomp_1=imcomplement(i3_1); Ifilled_1=imfill(Icomp_1,'holes');
Icomp_2=imcomplement(i3_2); Ifilled_2=imfill(Icomp_2,'holes');
se_1=strel('disk',10); Iopenned_1=imopen(Ifilled_1,se_1); se_2=strel('disk',10); Iopenned_2=imopen(Ifilled_2,se_2);
Iregion_1=regionprops(Iopenned_1,'centroid'); [labeled_1,numObjects]=bwlabel(Iopenned_1,4); stats_1=regionprops(labeled_1,'Eccentricity','Area','BoundingBox'); areas_1=[stats_1.Area]; eccentricities_1=[stats_1.Eccentricity]; idxOfSkittles_1=find(eccentricities_1); statsDefects_1=stats_1(idxOfSkittles_1); Iregion_2=regionprops(Iopenned_2,'centroid'); [labeled_2,numObjects]=bwlabel(Iopenned_2,4); stats_2=regionprops(labeled_2,'Eccentricity','Area','BoundingBox'); areas_2=[stats_2.Area]; eccentricities_2=[stats_2.Eccentricity]; idxOfSkittles_2=find(eccentricities_2); statsDefects_2=stats_2(idxOfSkittles_2); imshow(data);
for idx_1=1:length(idxOfSkittles_1) h_1=rectangle('Position',statsDefects_1(idx_1).BoundingBox); set(h_1,'EdgeColor',[.75 0 0]); end
for idx_2=1:length(idxOfSkittles_2) h_2=rectangle('Position',statsDefects_2(idx_2).BoundingBox); set(h_2,'EdgeColor',[.75 0 0]);
end end
hold off; clear all;

Answers (0)

Categories

Find more on Introduction to Installation and Licensing 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!