forked from rbgirshick/voc-dpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbboxpred_get.m
55 lines (52 loc) · 1.58 KB
/
bboxpred_get.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
function [ds_pred, bs_pred] = bboxpred_get(bboxpred, ds, bs)
% Get predicted bounding boxes.
% [bbox, bs_out] = bboxpred_get(bboxpred, ds, bs)
%
% Return values
% ds_pred Output detection windows
% bs_pred Output filter bounding boxes
%
% Arguments
% bboxpred Bounding box prediction coefficients (see bboxpred_train.m)
% ds Source detection windows
% bs Source filter bounding boxes
% 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.
% -------------------------------------------------------
ds_pred = [];
bs_pred = [];
% number of components
maxc = max(bs(:,end-1));
for c = 1:maxc
% limit boxes to just component c
cinds = find(bs(:,end-1) == c);
b = bs(cinds,:);
d = ds(cinds,:);
if isempty(b)
continue;
end
% build test data
[A x1 y1 x2 y2 w h] = bboxpred_input(d, b(:,1:end-2));
% predict displacements
dx1 = A*bboxpred{c}.x1;
dy1 = A*bboxpred{c}.y1;
dx2 = A*bboxpred{c}.x2;
dy2 = A*bboxpred{c}.y2;
% compute object location from predicted displacements
tmp = [x1 + (w.*dx1) ...
y1 + (h.*dy1) ...
x2 + (w.*dx2) ...
y2 + (h.*dy2) ...
b(:, end)];
ds_pred = [ds_pred; tmp];
bs_pred = [bs_pred; b];
end