how can i classifying vehicle on road using svm

2 views (last 30 days)
hi..im new in matlab my title is classifying vehicle using svm. anyone help for the script and send the code to me
  3 Comments
valli g
valli g on 5 Jul 2018
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=k/1200.33;
totalTRUCKS =round(r);
end
title('Detected TRUCKS');
msgbox(sprintf('totalTRUCKS = %2.3g\n',totalTRUCKS));
end
for i=0:length(Zb)
r=k/k*ZC-totalTRUCKS;
totalCARS =round(r);
end
msgbox(sprintf('totalCARS = %2.3g\n',totalCARS));
the above code is used to counting the car & truck on video.. bt the differentiate image is placed for croping.. how can i remove and get the output...
valli g
valli g on 6 Jul 2018
the truck vehicle does not count correctly plz anyone modify my code

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!