forked from kevinlisun/clothes_recognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb1_clothes_classification.m
225 lines (193 loc) · 7.12 KB
/
b1_clothes_classification.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
function [collecton_video, Label] = b1_clothes_classification(weight_feature, imginit, imgend)
% function [collecton_video, Label] = b1_clothes_classification(weight_feature)
% weight_feature
warning off
%pctRunOnAll warning('off','all')
%clear all
%close all
% clc
flag = true;
addpath('./BSplineFitting');
addpath('./Functions');
addpath('./Classification');
addpath('./libSVM');
addpath('./SurfaceFeature');
addpath('./SpatialPyramid');
addpath(genpath([pwd,'/GPML']));
addpath('./ShapeContent');
addpath('./Utilities');
addpath('./vlfeat/toolbox');
addpath(genpath('./RandomForest'));
addpath('./FINDDD');
addpath('./myGP');
addpath('./gentleboost');
addpath('./adaboost');
vl_setup
startup
%% script setting
coding_opt = 'LLC';
para.isnorm = 1;
para.local.bsp = 1;
para.local.finddd =0;
para.local.lbp = 0;
para.local.sc = 0;
para.local.dlcm = 0;
para.local.sift = 0;
para.global.si = 1;
para.global.lbp = 1;
para.global.topo = 1;
para.global.dlcm = 0;
para.global.imm = 0;
para.global.vol = 0;
para.distintic.keyparthist = 0;
para.distintic.keyparthist_onlyneck = 1;
para.distintic.keyparthist_onlywaist = 1;
para.distintic.neckshirt = 0;
para.distintic.size = 0;
current_dir='~/bags';
data_dir = '~/bags/data/';
% category = {'pant','shirt','tshirt','sweater','towel'};
category = {'pant','shirt','sweater','tshirt'};
size_class=3;
size_move=10;
%% main loop
Instance = [];
Label = [];
ClothesID = [];
collecton_video = [];
id = 1;
id_colecction = 1;
for iter_i = 1:length(category)
for iter_j = 1:size_class
for iter_k = 5:size_move
name_local_file = [current_dir,'/Features/local_descriptors_' category{iter_i} int2str(iter_j) '_move' int2str(iter_k)];
name_global_file = [current_dir,'/Features/global_descriptors_' category{iter_i} int2str(iter_j) '_move' int2str(iter_k)];
name_distintic_file = [current_dir,'/Features/distintic_descriptors_' category{iter_i} int2str(iter_j) '_move' int2str(iter_k)];
if exist([name_local_file '.mat'],'file') && exist([name_global_file '.mat'],'file')
load([name_local_file '.mat']);
load([name_global_file '.mat']);
if exist([name_distintic_file '.mat'],'file')
load([name_distintic_file '.mat']);
end
instance = [];
local_feature = [];
global_feature = [];
distintic_feature = [];
video_instance = [];
w_bsp1 = weight_feature(1); %40;
w_lbp1 = weight_feature(2)/60; %40/60;
w_si1 = weight_feature(3); %60;
w_topo1 = weight_feature(4); %10;
% w_size1 = weight_feature(5)/(640*480); %10;
w_bsp2 = w_bsp1;
w_lbp2 = w_lbp1;
w_si2 = w_lbp1;
w_topo2 = w_topo1;
% w_size2 = w_size1;
% for iter_l = 1:2
iter_l =1;
global_feature_tmp = [];
local_feature_tmp = [];
distintic_feature_tmp = [];
if para.local.bsp
vbsp = allfeatures_local(iter_l).dscr_bsp ;
local_feature_tmp = [ local_feature_tmp, vbsp*w_bsp1];
end
if para.global.lbp
vlbp=allfeatures_global(iter_l).lbp;
global_feature_tmp = [ global_feature_tmp, vlbp*w_lbp1];
end
if para.global.si
vsi=allfeatures_global(iter_l).si;
global_feature_tmp = [ global_feature_tmp, vsi*w_si1];
end
if para.global.topo
vtopo =allfeatures_global(iter_l).topo;
global_feature_tmp = [ global_feature_tmp, vtopo*w_topo1];
end
if para.distintic.size
distintic_feature_tmp = [ distintic_feature_tmp, allfeatures_distintic.size2d(iter_l)*w_size1 ]; % /(640*480)
end
local_feature = [ local_feature, local_feature_tmp ];
global_feature = [ global_feature, global_feature_tmp ];
distintic_feature = [ distintic_feature, distintic_feature_tmp ];
frame_instance = [local_feature_tmp, global_feature_tmp, distintic_feature_tmp ];
video_instance = [video_instance; frame_instance];
% end
% for iter_l = 4+imginit:imgend
% length(allfeatures_local)
% imgend
for iter_l = length(allfeatures_local)-imgend+1: length(allfeatures_local)-imginit +1 %25
% for iter_l = 4 + imginit : 4+imgend
% for iter_l = length(allfeatures_local)-25: length(allfeatures_local) %25
% for iter_l = max(5,length(allfeatures_local)-20): length(allfeatures_local)
global_feature_tmp = [];
local_feature_tmp = [];
distintic_feature_tmp = [];
if para.local.bsp
vbsp = allfeatures_local(iter_l).dscr_bsp ;
local_feature_tmp = [ local_feature_tmp, vbsp*w_bsp2];
end
if para.global.lbp
vlbp=allfeatures_global(iter_l).lbp;
global_feature_tmp = [ global_feature_tmp, vlbp*w_lbp2];
end
if para.global.si
vsi=allfeatures_global(iter_l).si;
global_feature_tmp = [ global_feature_tmp, vsi*w_si2];
end
if para.global.topo
vtopo =allfeatures_global(iter_l).topo;
global_feature_tmp = [ global_feature_tmp, vtopo*w_topo2];
end
if para.distintic.size
distintic_feature_tmp = [ distintic_feature_tmp, allfeatures_distintic.size2d(iter_l)*w_size2];
end
local_feature = [ local_feature, local_feature_tmp ];
global_feature = [ global_feature, global_feature_tmp ];
distintic_feature = [ distintic_feature, distintic_feature_tmp ];
frame_instance = [local_feature_tmp, global_feature_tmp, distintic_feature_tmp ];
video_instance = [video_instance; frame_instance];
end
% length(allfeatures_local) - max(5,length(allfeatures_local)-20)
% last_id = length(allfeatures_local)
% for iter_l = length(allfeatures_local) : (4+20)
% global_feature_tmp = [];
% local_feature_tmp = [];
% distintic_feature_tmp = [];
% if para.local.bsp
% local_feature_tmp = [ local_feature_tmp, allfeatures_local(last_id).dscr_bsp ];
% end
% if para.global.lbp
% global_feature_tmp = [ global_feature_tmp, allfeatures_global(last_id).lbp];
% end
% if para.global.si
% global_feature_tmp = [ global_feature_tmp, allfeatures_global(last_id).si ];
% end
% if para.global.topo
% global_feature_tmp = [ global_feature_tmp, allfeatures_global(last_id).topo ];
% end
% if para.distintic.size
% distintic_feature_tmp = [ distintic_feature_tmp, allfeatures_distintic.size2d(last_id) ];
% end
% local_feature = [ local_feature, local_feature_tmp ];
% global_feature = [ global_feature, global_feature_tmp ];
% distintic_feature = [ distintic_feature, distintic_feature_tmp ];
% frame_instance = [local_feature_tmp, global_feature_tmp, distintic_feature_tmp ];
% video_instance = [video_instance; frame_instance];
% end
collecton_video (id_colecction,:,:) = video_instance;
id_colecction = id_colecction+1;
instance = [ local_feature, global_feature, distintic_feature ];
% instance = [ local_feature_simple, global_feature_simple ];
Instance = [ Instance; instance ];
Label = [ Label; iter_i ];
% ClothesID = [ ClothesID; iter_i*100 + iter_j*10 + iter_k];
ClothesID = [ ClothesID; id];
else
% [name_local_file '.mat or ' name_global_file '.mat doesnt exist']
end
end
id = id+1;
end
end