-
Notifications
You must be signed in to change notification settings - Fork 14
/
bboxpred_get.m
36 lines (34 loc) · 912 Bytes
/
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
function [bbox parts] = bboxpred_get(bboxpred, dets, boxes)
% Get predicted bounding boxes.
%
% bboxpred saved bounding box prediction coefficients
% dets source detection windows
% boxes source filter bounding boxes
bbox = [];
parts = [];
% number of components
maxc = max(boxes(:,end-1));
for c = 1:maxc
% limit boxes to just component c
cinds = find(boxes(:,end-1) == c);
b = boxes(cinds,:);
d = dets(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)];
bbox = [bbox; tmp];
parts = [parts; b];
end