-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsvm_train.m
63 lines (51 loc) · 1.46 KB
/
svm_train.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
% This is used for training the dataset and constructing a SVM.
clc;
clear;
%load('clustering_information.mat');
class = 'holly_hand_';
points = [];
group = [];
points2 = [];
% This part is used to extract the histogram for each of the video of class
% "handshake" for training
for i=1:20
str = [['HIST/',class],num2str(i)];
fprintf('total out of %d\n',i);
str = [str,'.mat'];
load(str);
points = [points;hist'];
group = [group;1];
end
% This part is used to extract the histogram for each of the video of class
% "handshake" for testing
for i=21:28
str = [['HIST/',class],num2str(i)];
fprintf('total out of %d\n',i);
str = [str,'.mat'];
load(str);
points2 = [points2;hist'];
end
class = 'holly_phone_';
% This part is used to extract the histogram for each of the video of class
% "Talking on a phone" for training
for i=1:20
str = [['HIST/',class],num2str(i)];
fprintf('total out of %d\n',i);
str = [str,'.mat'];
load(str);
points = [points;hist'];
group = [group;2];
end
% This part is used to extract the histogram for each of the video of class
% "talking on a phone" for testing
for i=21:28
str = [['HIST/',class],num2str(i)];
fprintf('total out of %d\n',i);
str = [str,'.mat'];
load(str);
points2 = [points2;hist'];
end
% Final Training Process and constructing a SVM
svm_var = svmtrain(points,group);
% Checking for the classes of the test videos
var_ans = svmclassify(svm_var,points2);