forked from kevinlisun/clothes_recognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
c1_online_classification.m
54 lines (41 loc) · 1.56 KB
/
c1_online_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
function testresp = c1_online_classification(~,req,resp)
% global weight_feature
global collecton_video
global Label
weight_feature= [40 40 60 10];
data_client = rossvcclient('/merge_data/get_sequence_data');
testreq = rosmessage(data_client);
testresp = call(data_client,testreq,'Timeout',10);
disp('Get sequence data ... OK');
tic
video_features = c2_extract_features(testresp);
disp( [ 'Extract features ... OK (' int2str(toc) 'sec)']);
tic
video_features = c3_local_features_llc(video_features);
disp( [ 'Apply LLC ... OK (' int2str(toc) 'sec)']);
%crear collection
test_video = c4_features_integration(video_features, weight_feature);
tic
ST = LGSR(test_video, collecton_video, 'euclidean');
disp( [ 'Apply LGSR ... OK (' int2str(toc) 'sec)']);
tic
[nC, collection_frames, feats] = size(collecton_video);
Lc = zeros(nC, 1);
% Qc = zeros(nC, 1);
for c=1:nC
X = reshape(collecton_video(c,:,:),[collection_frames feats]);
STtmp = reshape(ST(c,:,:),[collection_frames collection_frames]);
% STtmp
xst = (X'*STtmp)';
Lc(c,1) = 0.5*norm( (test_video - xst ) ,'inf'); % max(svd((Y - xst ) ) ) ;
% Qc(c,1) = norm( STtmp,'inf') / norm( (Y - xst ) ,'inf'); %max(svd(STtmp) ) /max(svd( (Y - xst )) );
end
[a,idmin]= min(Lc);
disp(['Classifcation ... OK (' int2str(toc) 'sec)']);
category = {'pant','shirt','sweater','tshirt'};
disp(['Class : ' int2str(Label(idmin)) category{Label(idmin)} ]);
resp.ID = Label(idmin);
data_client = rossvcclient('/merge_data/set_result');
req = rosmessage(data_client);
req.ID = Label(idmin);
testresp = call(data_client,req,'Timeout',10);