MATLAB Answers

I am working about smart parking system with video processing and ı need to scan just special area for image processing so imagine a parking area, we need to scan just parking area.So how can we scan special area in matlab with video processing?

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); section1=data(1:100,:,:); section2=data(140:239,:,:); y=zeros(240,320,3); y(1:100,:,:)=section1; y(140:239,:,:)=section2; y=uint8(y);
%% Im=y; rmat=Im(:,:,1); gmat=Im(:,:,2); bmat=Im(:,:,3);
%%Plot the data levelr=0.5; levelg=0.5; levelb=0.5; i1=im2bw(rmat,levelr); i2=im2bw(gmat,levelg); i3=im2bw(bmat,levelb); Isum=(i1&i2&i3);
Icomp=imcomplement(i3); Ifilled=imfill(Icomp,'holes');
se=strel('disk',10); Iopenned=imopen(Ifilled,se);
Iregion=regionprops(Iopenned,'centroid'); [labeled,numObjects]=bwlabel(Iopenned,4); stats=regionprops(labeled,'Eccentricity','Area','BoundingBox'); areas=[stats.Area]; eccentricities=[stats.Eccentricity]; idxOfSkittles=find(eccentricities); statsDefects=stats(idxOfSkittles); imshow(data);
for idx=1:length(idxOfSkittles) h=rectangle('Position',statsDefects(idx).BoundingBox); set(h,'EdgeColor',[.75 0 0]);
hold off; end
if idx>10 title('there are',num2str(numObjects),'objects in'); end
hold off; clear all;

Accepted Answer

Image Analyst
Image Analyst on 20 May 2018
Also post a no-car image plus an image with cars parked some of the spaces.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by