forked from rbgirshick/voc-dpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.m
95 lines (82 loc) · 2.4 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function demo(no_compile)
% AUTORIGHTS
% -------------------------------------------------------
% Copyright (C) 2011-2012 Ross Girshick
% Copyright (C) 2008, 2009, 2010 Pedro Felzenszwalb, Ross Girshick
%
% This file is part of the voc-releaseX code
% (http://people.cs.uchicago.edu/~rbg/latent/)
% and is available under the terms of an MIT-like license
% provided in COPYING. Please retain this notice and
% COPYING if you use this file (or a portion of it) in
% your project.
% -------------------------------------------------------
startup;
if ~exist('no_compile', 'var')
fprintf('compiling the code...');
compile;
fprintf('done.\n\n');
end
load('VOC2007/car_final');
model.vis = @() visualizemodel(model, ...
1:2:length(model.rules{model.start}));
test('000034.jpg', model, 1);
load('INRIA/inriaperson_final');
model.vis = @() visualizemodel(model, ...
1:2:length(model.rules{model.start}));
test('000061.jpg', model, 2);
load('VOC2007/person_grammar_final');
model.class = 'person grammar';
model.vis = @() visualize_person_grammar_model(model, 6);
test('000061.jpg', model, 2);
load('VOC2007/bicycle_final');
model.vis = @() visualizemodel(model, ...
1:2:length(model.rules{model.start}));
test('000084.jpg', model, 1);
function test(imname, model, num_dets)
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;
title('input image');
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
tic;
[ds, bs] = imgdetect(im, model, -1);
toc;
top = nms(ds, 0.5);
top = top(1:min(length(top), num_dets));
ds = ds(top, :);
bs = bs(top, :);
clf;
if model.type == model_types.Grammar
bs = [ds(:,1:4) bs];
end
showboxes(im, reduceboxes(model, bs));
title('detections');
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,:));
title('predicted bounding boxes');
disp('bounding boxes');
disp('press any key to continue'); pause;
end
fprintf('\n');