Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
eos
Commits
dbf6d153
Commit
dbf6d153
authored
Dec 04, 2016
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Matlab demo code
parent
7aa30194
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
32 deletions
+24
-32
matlab/+eos/+fitting/fit_shape_and_pose.m
matlab/+eos/+fitting/fit_shape_and_pose.m
+5
-9
matlab/demo.m
matlab/demo.m
+19
-23
No files found.
matlab/+eos/+fitting/fit_shape_and_pose.m
View file @
dbf6d153
...
@@ -26,15 +26,11 @@ function [mesh, rendering_parameters] = fit_shape_and_pose(morphable_model, ...
...
@@ -26,15 +26,11 @@ function [mesh, rendering_parameters] = fit_shape_and_pose(morphable_model, ...
% contour_landmarks and model_contour as *filenames* to the respective
% contour_landmarks and model_contour as *filenames* to the respective
% files in the eos/share/ directory, and not the objects directly.
% files in the eos/share/ directory, and not the objects directly.
morphable_model
=
'../share/sfm_shape_3448.bin'
;
% We'll use default values to the following arguments, if they're not
blendshapes
=
'../share/expression_blendshapes_3448.bin'
;
% provided:
landmarks
=
zeros
(
68
,
2
);
if
(
~
exist
(
'edge_topology'
,
'var'
)),
edge_topology
=
'../share/sfm_3448_edge_topology.json'
;
end
landmark_mapper
=
'../share/ibug2did.txt'
;
if
(
~
exist
(
'contour_landmarks'
,
'var'
)),
contour_landmarks
=
'../share/ibug2did.txt'
;
end
image_width
=
1280
;
if
(
~
exist
(
'model_contour'
,
'var'
)),
model_contour
=
'../share/model_contours.json'
;
end
image_height
=
720
;
edge_topology
=
'../share/sfm_3448_edge_topology.json'
;
contour_landmarks
=
'../share/ibug2did.txt'
;
model_contour
=
'../share/model_contours.json'
;
if
(
~
exist
(
'num_iterations'
,
'var'
)),
num_iterations
=
5
;
end
if
(
~
exist
(
'num_iterations'
,
'var'
)),
num_iterations
=
5
;
end
if
(
~
exist
(
'num_shape_coefficients_to_fit'
,
'var'
)),
num_shape_coefficients_to_fit
=
-
1
;
end
if
(
~
exist
(
'num_shape_coefficients_to_fit'
,
'var'
)),
num_shape_coefficients_to_fit
=
-
1
;
end
if
(
~
exist
(
'lambda'
,
'var'
)),
lambda
=
30.0
;
end
if
(
~
exist
(
'lambda'
,
'var'
)),
lambda
=
30.0
;
end
...
...
matlab/demo.m
View file @
dbf6d153
...
@@ -3,42 +3,38 @@
...
@@ -3,42 +3,38 @@
%% Set up some required paths to files:
%% Set up some required paths to files:
model_file
=
'../share/sfm_shape_3448.bin'
;
model_file
=
'../share/sfm_shape_3448.bin'
;
blendshapes_file
=
'../share/expression_blendshapes_3448.bin'
;
blendshapes_file
=
'../share/expression_blendshapes_3448.bin'
;
landmark_mappings
=
'../share/ibug2did.txt'
;
%% Read some ibug landmarks for an image:
%% Load an image and its landmarks in ibug format:
landmarks
=
read_pts_landmarks
(
'D:\Github\data\ibug\helen\testset\30427236_1.pts'
);
image
=
imread
(
'../bin/data/image_0010.png'
);
landmarks
=
read_pts_landmarks
(
'../bin/data/image_0010.pts'
);
image_width
=
size
(
image
,
2
);
image_height
=
size
(
image
,
1
);
%% Run the fitting, get back the fitted mesh and pose:
%% Run the fitting, get back the fitted mesh and pose:
[
mesh
,
render_params
]
=
eos
.
fitting
.
fit_shape_and_pose
(
model_file
,
blendshapes_file
,
landmarks
);
[
mesh
,
render_params
]
=
eos
.
fitting
.
fit_shape_and_pose
(
model_file
,
blendshapes_file
,
landmarks
,
landmark_mappings
,
image_width
,
image_height
);
% Note: The function actually has a few more arguments to files it
% needs. If you're not running it from within eos/matlab/, you need to
% provide them. See its documentation and .m file.
%% Visualise the fitted mesh using your favourite
tool
, for example...
%% Visualise the fitted mesh using your favourite
plot
, for example...
figure
(
1
);
figure
(
1
);
plot3
(
mesh
.
vertices
(:,
1
),
mesh
.
vertices
(:,
2
),
mesh
.
vertices
(:,
3
),
'.'
);
plot3
(
mesh
.
vertices
(:,
1
),
mesh
.
vertices
(:,
2
),
mesh
.
vertices
(:,
3
),
'.'
);
% or...
% or...
FV
.
vertices
=
mesh
.
vertices
(:,
1
:
3
);
FV
.
vertices
=
mesh
.
vertices
(:,
1
:
3
);
FV
.
faces
=
mesh
.
tvi
;
FV
.
faces
=
mesh
.
tvi
;
figure
(
2
);
figure
(
2
);
patch
(
FV
,
'FaceColor'
,
[
1
1
1
],
'EdgeColor'
,
'none'
,
'FaceLighting'
,
'phong'
);
light
;
axis
equal
;
axis
off
;
patch
(
FV
,
'FaceColor'
,
[
1
1
1
],
'EdgeColor'
,
'none'
,
'FaceLighting'
,
'phong'
);
light
;
axis
equal
;
axis
off
;
%% Visualise the fitting in 2D, on top of the input image:
%% Visualise the fitting in 2D, on top of the input image:
% First we project all vertices to 2D:
% Project all vertices to 2D:
points_2d
=
zeros
(
size
(
mesh
.
vertices
,
1
),
2
);
points_2d
=
mesh
.
vertices
*
(
render_params
.
viewport
*
render_params
.
projection
*
render_params
.
modelview
)
'
;
h
=
720
;
w
=
1280
;
% Display the image and plot the projected mesh points on top of it:
viewport
=
[
0
,
h
,
w
,
-
h
];
for
i
=
1
:
size
(
mesh
.
vertices
,
1
)
tmp
=
render_params
.
projection
*
render_params
.
modelview
*
mesh
.
vertices
(
i
,
:)
'
;
tmp
=
tmp
.*
0.5
+
0.5
;
tmp
(
1
)
=
tmp
(
1
)
*
viewport
(
3
)
+
viewport
(
1
);
tmp
(
2
)
=
tmp
(
2
)
*
viewport
(
4
)
+
viewport
(
2
);
points_2d
(
i
,
:)
=
tmp
(
1
:
2
);
end
% Load the image, plot the projected mesh points on top of it:
img
=
imread
(
'D:\Github\data\ibug\helen\testset\30427236_1.jpg'
);
figure
(
3
);
figure
(
3
);
imshow
(
im
g
);
imshow
(
im
age
);
hold
on
;
hold
on
;
plot
(
points_2d
(:,
1
),
points_2d
(:,
2
),
'g.'
);
plot
(
points_2d
(:,
1
),
points_2d
(:,
2
),
'g.'
);
% We can also plot the landmarks the mesh was fitted to:
% We can also plot the landmarks the mesh was fitted to:
plot
(
landmarks
(:,
1
),
landmarks
(:,
2
),
'ro'
);
plot
(
landmarks
(:,
1
),
landmarks
(:,
2
),
'ro'
);
%% Just a helper function to read ibug .pts landmarks from a file:
%% Just a helper function to read ibug .pts landmarks from a file:
...
@@ -56,4 +52,4 @@ for i=6:2:141
...
@@ -56,4 +52,4 @@ for i=6:2:141
row_idx
=
row_idx
+
1
;
row_idx
=
row_idx
+
1
;
end
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment