-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict.m
39 lines (30 loc) · 939 Bytes
/
predict.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function res = predict(imgfile, annotation_file)
im = imread(imgfile);
load(annotation_file, 'box_coord', 'obj_contour');
obj.image = im;
obj.box(1,:) = box_coord(3:4); % x
obj.box(2,:) = box_coord(1:2); % y
obj.contour = obj_contour;
testSet = [obj];
% Import svm library
importDependencies();
% Define class labels
class_labels = { 'airplanes'; 'barrel'; 'bonsai'; 'brontosaurus'; 'camera';
'ceiling_fan'; 'anchor'; 'binocular'; 'brain'; 'butterfly';
'car_side'; 'cellphone'};
% Features to extract
request = {
@roundness 'Default';
@elongation 'Default';
@rectangularity 'Default';
@HOG 'Default';
@solidity 'Default';
%@curveness 'Default'
};
% Extract Features
testFeatures = extractFeature(request, testSet);
% Predict test
load('cache','classifier');
[predLabels, trash] = predictsvm(classifier, testFeatures, ...
{'unknown'}, class_labels);
disp(predLabels(1))