-
Notifications
You must be signed in to change notification settings - Fork 11
/
demo.m
71 lines (60 loc) · 1.71 KB
/
demo.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
function demo()
startup;
fprintf('compiling the code...');
compile;
fprintf('done.\n\n');
load('VOC2007/car_final');
model.vis = @() visualizemodel(model, ...
1:2:length(model.rules{model.start}));
test('000034.jpg', model, -0.3);
load('INRIA/inriaperson_final');
model.vis = @() visualizemodel(model, ...
1:2:length(model.rules{model.start}));
test('000061.jpg', model, -0.3);
load('VOC2007/person_grammar_final');
model.class = 'person grammar';
model.vis = @() visualize_person_grammar_model(model, 6);
test('000061.jpg', model, -0.6);
load('VOC2007/bicycle_final');
model.vis = @() visualizemodel(model, ...
1:2:length(model.rules{model.start}));
test('000084.jpg', model, -0.3);
function test(imname, model, thresh)
cls = model.class;
fprintf('///// Running demo for %s /////\n\n', cls);
% load and display image
im = imread(imname);
clf;
image(im);
axis equal;
axis on;
disp('input image');
disp('press any key to continue'); pause;
disp('continuing...');
% load and display model
model.vis();
disp([cls ' model visualization']);
disp('press any key to continue'); pause;
disp('continuing...');
% detect objects
[ds, bs] = imgdetect(im, model, thresh);
top = nms(ds, 0.5);
clf;
if model.type == model_types.Grammar
bs = [ds(:,1:4) bs];
end
showboxes(im, reduceboxes(model, bs(top,:)));
disp('detections');
disp('press any key to continue'); pause;
disp('continuing...');
if model.type == model_types.MixStar
% get bounding boxes
bbox = bboxpred_get(model.bboxpred, ds, reduceboxes(model, bs));
bbox = clipboxes(im, bbox);
top = nms(bbox, 0.5);
clf;
showboxes(im, bbox(top,:));
disp('bounding boxes');
disp('press any key to continue'); pause;
end
fprintf('\n');