-
Notifications
You must be signed in to change notification settings - Fork 124
/
inferenceReg.m
executable file
·41 lines (34 loc) · 1.45 KB
/
inferenceReg.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
% Codes for CVPR-15 work `Face Alignment by Coarse-to-Fine Shape Searching'
% Any question please contact Shizhan Zhu: zhshzhutah2@gmail.com
% Released on July 25, 2015
function currentPose = inferenceReg(images,model,Pr,level,regsInfo)
m = length(images);
n_pts = size(model{level}.tpt,2) / 2;
tpt = model{max(1,level-1)}.tpt;
mt = size(tpt,1);
% 61. Sampling
index_inference = zeros(m,regsInfo.samplingTot(level));
currentPose_inference = zeros(m,2*n_pts,regsInfo.samplingTot(level));
for i = 1:m
if level > 1
[~,tmp] = sort(Pr(i,:),'descend');
index_inference(i,:) = tmp(1:regsInfo.samplingTot(level));
else
index_inference(i,:) = randSampleNoReplace(mt, regsInfo.samplingTot(level), Pr(i,:));
end;
for j = 1:regsInfo.samplingTot(level)
currentPose_inference(i,:,j) = tpt(index_inference(i,j),:);
end;
end;
% 62. Inference Iteration
featInfo.scale = regsInfo.SIFTscale;
for iter = 1:regsInfo.iterTot(level)
featOri_batch = extractSIFTs_toosimple_samples(images,currentPose_inference,iter,featInfo);
for j = 1:regsInfo.samplingTot(level)
currentPose_inference(:,:,j) = currentPose_inference(:,:,j) + ...
(featOri_batch(:,:,j) - repmat(model{level}.reg{iter}.mu,m,1)) * model{level}.reg{iter}.A ...
+ repmat(model{level}.reg{iter}.b,m,1);
end;
end;
currentPose = poseVoting(currentPose_inference,regsInfo.dominantIterTot(level));
end