Skip to content

Instantly share code, notes, and snippets.

@Zerk123
Created December 1, 2016 07:57
Show Gist options
  • Save Zerk123/5b372b3f4da27be05b77b4d395de8613 to your computer and use it in GitHub Desktop.
Save Zerk123/5b372b3f4da27be05b77b4d395de8613 to your computer and use it in GitHub Desktop.
Car Detection From an Image using SURF(Speeded Up Robust Feature) Matlab
% Team Owais, Zerk, Shaleem, Faisal, Farman
% Accuracy 0.9472 (94%)
% Uses bag of features for training.
% Path to data-set folder
path = 'data-set';
imgSets = imageSet(path, 'recursive');
% Partition our data to 30/70, Where 30% data is for training and 70 for
% test set. Increasing training set will increase accuracy.
[trainingSets, testSets] = partition(imgSets, 0.3, 'randomize');
% Extract features from training set images.
bag = bagOfFeatures(trainingSets,'Verbose',false);
% Generate category classifier from training images.
categoryClassifier = trainImageCategoryClassifier(trainingSets, bag);
% Test classifier on test image.
confMatrix = evaluate(categoryClassifier, testSets)
% Show mean of diagnols, Diagnol contains success.
mean(diag(confMatrix))
% Test classifier against our random input
img = imread('nv.png');
[labelIdx, score] = predict(categoryClassifier, img);
% Result: Non Vehicle -> Success
categoryClassifier.Labels(labelIdx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment