Advertisement
backlog

cla.s.m

Apr 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.23 KB | None | 0 0
  1. clc
  2. srcFiles = dir('E:\traffic\ftl\al--3---round about\New folder\*.jpg');  % the folder in which ur images exists
  3. classifier=[];hog1=[];
  4. trainingLabels=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2];
  5. %trainingLabels=trainingLabels';
  6. for i = 1 : length(srcFiles)
  7.     filename = strcat('E:\traffic\ftl\al--3---round about\New folder\',srcFiles(i).name);
  8.     I = imread(filename);
  9.     %figure, imshow(I);
  10.     hog1(i,:)=extractHOGFeatures(I);
  11.    
  12. end
  13. t = templateSVM('KernelFunction','linear'); %gaussian
  14. classifier = fitcecoc(hog1,trainingLabels,'Learners',t);
  15.  
  16. %classifier = fitcecoc(hog1,trainingLabels,'Learners','naivebayes');
  17.  
  18.  
  19. srcFiles = dir('E:\traffic\ta\*.jpg');  % the folder in which ur images exists
  20. hog2=[];
  21. for i = 1 : length(srcFiles)
  22.     filename = strcat('E:\traffic\ta\',srcFiles(i).name);
  23.     I2 = imread(filename);
  24.     %figure, imshow(I);
  25.     hog2(i,:)=extractHOGFeatures(I2);
  26.    
  27. end
  28.  
  29.  
  30. %testFeatures = extractHOGFeatures(hog2);
  31.  testLabels=[1,2,2,2,2,1,1,1,1,2];
  32.  
  33. % Make class predictions using the test features.
  34. predictedLabels = predict(classifier, hog2);
  35.  
  36. % Tabulate the results using a confusion matrix.
  37. confMat = confusionmat(testLabels, predictedLabels)
  38.  
  39. helperDisplayConfusionMatrix(confMat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement