-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathdemo.m
65 lines (53 loc) · 1.68 KB
/
demo.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
clear; clc; close all;
%% Load: rgb, segm, joints2D, joints3D, voxels
fn = 'sample_data/up/input.png';
load([fn '.mat']);
%%
vix = [3 1 2];
jix = [7, 3, 4, 2, 5, 1, 6, 9, 10, 13, 14, 12, 15, 11, 16];
addpath('matlab_utils');
% From mathworks.com/matlabcentral/fileexchange/26710-smooth-triangulated-mesh
addpath('smoothpatch_version1b');
%addpath('export_fig'); % if you don't have this replace with saveas func
figure(1); set(gcf, 'Position', [1023 523 442 347]);
figure(2); set(gcf, 'Position', [132 95 820 805]);
vws = [0 0]; %; 45 ,20];
%% 2D figs
figure(1);
% (1) RGB
rgb = uint8(255*permute(rgb, [2 3 1]));
imshow(rgb);
imwrite(rgb, [fn '_rgb.png']);
% (2) 2D Pose + Segm
swap_segm = [1 2 3 7 8 9 4 5 6 13 14 15 10 11 12];
swapped_segm = segm;
for p = 1:15
swapped_segm(segm == swap_segm(p)) = p;
end
segm = swapped_segm;
fig_2D(joints2D(jix, :)', segm, fn);
%% 3D figs
figure(2);
% (3) 3D Pose
joints3D(:, [1 2]) = -joints3D(:, [1 2]);
joints3D = joints3D(:, vix);
fig_joints3D(joints3D(jix, :)', fn, vws);
% (4) Voxels
voxels = permute(voxels, vix);
voxels = voxels(:, end:-1:1, end:-1:1);
fig_mesh(voxels, true, double(imresize(rgb, [128 128]))./255, fn, vws);
% (5) Part voxels
logm = 1 ./ (1 + exp(-partvoxels));
softm = bsxfun(@rdivide, logm, sum(logm, 1));
[partprob, partclass] = max(softm, [], 1);
partprob = squeeze(partprob);
partclass = squeeze(partclass);
partclass = permute(partclass, vix);
partclass = partclass(:, end:-1:1, end:-1:1);
fig_parts(partclass, fn, vws);
if false
% (6) SMPL
fig_smpl(smpl.gt_vertices, [fn 'gt_'], vws, obj.f.v);
fig_smpl(smpl.initial_vertices, [fn 'pred1_'], vws, obj.f.v);
fig_smpl(smpl.final_vertices, [fn 'pred2_'], vws, obj.f.v);
end