Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- srcFiles = dir('E:\traffic\ftl\al--3---round about\New folder\*.jpg'); % the folder in which ur images exists
- classifier=[];hog1=[];
- 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];
- %trainingLabels=trainingLabels';
- for i = 1 : length(srcFiles)
- filename = strcat('E:\traffic\ftl\al--3---round about\New folder\',srcFiles(i).name);
- I = imread(filename);
- %figure, imshow(I);
- hog1(i,:)=extractHOGFeatures(I);
- end
- t = templateSVM('KernelFunction','linear'); %gaussian
- classifier = fitcecoc(hog1,trainingLabels,'Learners',t);
- %classifier = fitcecoc(hog1,trainingLabels,'Learners','naivebayes');
- srcFiles = dir('E:\traffic\ta\*.jpg'); % the folder in which ur images exists
- hog2=[];
- for i = 1 : length(srcFiles)
- filename = strcat('E:\traffic\ta\',srcFiles(i).name);
- I2 = imread(filename);
- %figure, imshow(I);
- hog2(i,:)=extractHOGFeatures(I2);
- end
- %testFeatures = extractHOGFeatures(hog2);
- testLabels=[1,2,2,2,2,1,1,1,1,2];
- % Make class predictions using the test features.
- predictedLabels = predict(classifier, hog2);
- % Tabulate the results using a confusion matrix.
- confMat = confusionmat(testLabels, predictedLabels)
- helperDisplayConfusionMatrix(confMat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement