how to detect and count vehicle patterns in a image ?

6 views (last 30 days)
hello everyone,
i am new to matlab and image processing. I am working on a traffic emulation project in witch i need to detect and count the number of vehicles in an images. the images are from traffic cameras.. you can find examples of these images on this link:
i will be thankful if anyone could advise on a robust way to detect and count vehicles in images of this type.
Regards,
Salim

Accepted Answer

Image Analyst
Image Analyst on 20 Aug 2013
There is a demo of that on this page for the Computer Vision System Toolbox: http://www.mathworks.com/products/computer-vision/description4.html
  4 Comments
valli g
valli g on 9 Jul 2018
hi sir, im new in matlab. how can classifying vehicle type on a road using svm.
clc clear all close all t=dir('D:\project\frame'); t1=struct2cell(t); t2=t1(1,3:end); p2 = [150,640]; p3= [150,1]; q3 = [200,640]; q2 = [200,1]; thcar=7; %figure('name','Vehicle Image','numbertitle','off') %% image read & rgb to gray conversion for i=1:85 im{i}=imread(strcat('D:\project\frame\',t2{i})) ; if size(im{i},3)>1 im{i}=rgb2gray(im{i}); end imshow(im{i}); hold on plot([p2(2),p3(2)],[p2(1),p3(1)],'Color','r','LineWidth',2) plot([q2(2),q3(2)],[q2(1),q3(1)],'Color','b','LineWidth',2) pause(0.1) end %% line drawing on images %figure('name','Vehicle crop Image','numbertitle','off') for i=1:length(im) im1{i}=imcrop(im{i},[p3(2) p2(1) q3(2) q3(1)-p2(1)]) ; imshow(im1{i}) %pause(0.1) end %% diffrentiated images figure('name','diffretiated Image','numbertitle','off') ZC=0; for i=1:length(im1)-1
% d{i}=im1{i}-im1{i+1};
diff_im = imabsdiff(im1{i},im1{i+1});
temp= im2bw(diff_im,0.15);
[x,y]=find(temp);
I=zeros(size(temp));
Ix=im1{i+1};
for i=1:length(x)
I(x(i),y(i))=Ix(x(i),y(i));
end
% d{i}=I;
imshow(I)
%imtool(d{i});
% pause(0.2)
hold on
blobAnalysis = vision.BlobAnalysis('BoundingBoxOutputPort', true, ...
'AreaOutputPort', false, 'CentroidOutputPort', false, ...
'MinimumBlobArea', 500);
bbox = step(blobAnalysis, temp);000
result = insertShape(Ix ,'Rectangle', bbox, 'Color', 'green');
ZC=ZC+(size(bbox,5)/thcar);
Zb=ZC;
resultt= insertText(result,[10 10],round(Zb(:)),'BoxOpacity', 1, ...
'FontSize', 15);
YO=imshow(resultt);
dd=size(resultt);
title('Detected Cars');
k=msgbox('cars');
close(k);
end if ZC>=3.0
for i=0:length(ZC)
r=i/1200.33;
totalTRUCKS =round(r);
end
title('Detected TRUCKS');
msgbox(sprintf('totalTRUCKS = %2.3g\n',totalTRUCKS));
end
for i=0:length(Zb)
r=i/i*ZC-totalTRUCKS;
totalCARS =round(r);
end
msgbox(sprintf('totalCARS = %2.3g\n',totalCARS));
here is the code for count the car and truck on road..in result the car is correctly classify bt the truck is not classified so plz help for this code.. tq

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!