forked from phg1024/FaceShapeFromShading-MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_SFS_cli_noskin_nocloud.m
60 lines (45 loc) · 1.71 KB
/
run_SFS_cli_noskin_nocloud.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
tic;
sfs_pipe = fopen('sfs_pipe', 'r');
path = fscanf(sfs_pipe, '%s');
fclose(sfs_pipe);
close all;
fprintf('The path of images is %s\n', path);
% create the parallel workers pool
poolobj = gcp('nocreate');
delete(poolobj);
parpool('8workers', 8);
% perform face segmentation first
face_seg_dummy(path);
all_images = read_settings(fullfile(path, 'settings.txt'));
in_img_for_size = imread(fullfile(path, all_images{1}));
[img_w, img_h, ~] = size(in_img_for_size)
% LoG kernel and LoG matrix
[LoG, mat_LoG] = LoGMatrix(2, img_w, img_h, 1.0);
[albedo_LoG, albedo_mat_LoG] = LoGMatrix(2, img_w, img_h, 0.5);
options.LoG = LoG;
options.mat_LoG = mat_LoG;
options.albedo_LoG = albedo_LoG;
options.albedo_mat_LoG = albedo_mat_LoG;
options.path = path;
options.silent = true;
parfor i=1:length(all_images)
input_image = fullfile(path, all_images{i})
[~, basename, ~] = fileparts(all_images{i});
image_index = str2num(basename);
albedo_image = fullfile(path, 'SFS', sprintf('albedo_transferred_%d.png', image_index))
normal_image = fullfile(path, 'SFS', sprintf('normal%d.png', image_index))
mask_image = fullfile(path, 'masked', sprintf('mask%d.png', image_index))
depth_map = fullfile(path, 'SFS', sprintf('depth_map%d.bin', image_index))
options_i = options;
options_i.idx = image_index;
%[h, w, ~] = size(imread(albedo_image));
%[LoG, mat_LoG] = LoGMatrix(2, h, w, 1.0);
tic;
refined_normal_map = SFS(input_image, albedo_image, normal_image, depth_map, mask_image, options_i);
fprintf('image %d finished in %.3fs\n', i, toc);
end
% create masks based on the refined point clouds
create_masked_point_clouds_dummy(path);
% select point clouds
select_point_clouds_dummy(path);
toc;