-
Notifications
You must be signed in to change notification settings - Fork 7
/
batpose_gentor.m
95 lines (75 loc) · 2.57 KB
/
batpose_gentor.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
classdef batpose_gentor
%BATPOSE_GENTOR Summary of this class goes here
% Detailed explanation goes here
properties
N; % number of original #instances
i_bat; % current batch count
num_bat; %
end
properties
h1;
h2;
end
methods
function ob = batpose_gentor()
ob = reset(ob, 888, 16888, 168); % Why the numbers?? -_-
end
function ob = reset(ob, N, Nstar, bat_sz)
ob.h1 = bat_gentor();
ob.h1 = reset(ob.h1, Nstar, bat_sz);
ob.h2 = bat_gentor();
ob.h2 = reset(ob.h2, Nstar, bat_sz);
ob.N = N;
ob.i_bat = 1;
assert( ob.h1.num_bat == ob.h2.num_bat );
ob.num_bat = ob.h1.num_bat;
end % reset
function [idx1,idx2] = get_idx (ob, ib)
% the index in {1,...,Nstar}
idx1 = get_idx(ob.h1, ib);
idx2 = get_idx(ob.h2, ib);
% the index in {1,...,N}
idx1 = 1 + mod(idx1-1, ob.N);
idx2 = 1 + mod(idx2-1, ob.N);
end % get_idx
function [idx1,idx2] = get_idx_orig (ob, ib)
% the index in {1,...,Nstar}
idx1 = get_idx_orig(ob.h1, ib);
idx2 = get_idx_orig(ob.h2, ib);
% the index in {1,...,N}
idx1 = 1 + mod(idx1-1, ob.N);
idx2 = 1 + mod(idx2-1, ob.N);
end % get_idx_orig
function [bat_I,bat_pGT,bat_pInit] = get_data (ob, I, pGT, ib)
[ix1,ix2] = get_idx(ob, ib);
bat_pGT = pGT(:,:,ix1);
bat_I = I(:,:,:,ix1);
% transform the mean shape as the initial pose
bat_pInit = zeros( size(bat_pGT) );
pMean = mean(pGT,3); % [2,L]
pGTix2 = pGT(:,:,ix2);
parfor i = 1 : numel(ix2)
p_moving = pGTix2(:,:,i); % [2,L]
z = fitgeotrans(p_moving', pMean', 'nonreflectivesimilarity');
p_moved = transformPointsForward(...
z, [p_moving(1,:)', p_moving(2,:)'] );
bat_pInit(:,:,i) = p_moved';
end
end % get_data
function [bat_I,bat_pGT,bat_pInit] = get_data_orig (ob, I, pGT, ib)
[ix1,ix2] = get_idx_orig(ob, ib);
bat_pGT = pGT(:,:,ix1);
bat_I = I(:,:,:,ix1);
% transform the mean shape as the initial pose
bat_pInit = zeros( size(bat_pGT) );
pMean = mean(pGT,3); % [2,L]
for i = 1 : numel(ix2)
ix = ix2(i);
p_moving = pGT(:,:,ix); % [2,L]
z = cp2tform(p_moving', pMean', 'nonreflective similarity');
p_moved = tformfwd(z, p_moving(1,:)', p_moving(2,:)');
bat_pInit(:,:,i) = p_moved';
end
end % get_data_orig
end % methods
end % batpose_gentor