-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetPoses.m
41 lines (29 loc) · 1.07 KB
/
getPoses.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
function poseLines = getPoses(aPosesNet, aImg)
netInput = im2single(aImg)-0.5;
netInput = netInput(:,:,[3 2 1]);
netInput = dlarray(netInput,"SSC");
[heatmaps,pafs] = predict(aPosesNet, netInput);
heatmaps = extractdata(heatmaps);
displayHeatMap(heatmaps, aImg);
heatmaps = heatmaps(:,:,1:end-1);
pafs = extractdata(pafs);
displayPafs(pafs, aImg)
params = getBodyPoseParameters();
poses = getBodyPoses(heatmaps,pafs,params);
poseLines = renderBodyPoses(aImg,poses,size(heatmaps,1),size(heatmaps,2),params);
end
function displayHeatMap(aHeatMaps, aImg)
montage(rescale(aHeatMaps),"BackgroundColor","b","BorderSize",3);
idx = 1;
hmap = aHeatMaps(:,:,idx);
hmap = imresize(hmap,size(aImg,[1 2]));
imshowpair(hmap,aImg);
end
function displayPafs(aPafs, aImg)
montage(rescale(aPafs),"Size",[19 2],"BackgroundColor","b","BorderSize",3);
idx = 1;
impair = horzcat(aImg,aImg);
pafpair = horzcat(aPafs(:,:,2*idx-1),aPafs(:,:,2*idx));
pafpair = imresize(pafpair,size(impair,[1 2]));
imshowpair(pafpair,impair);
end