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
50e78983
Commit
50e78983
authored
Dec 04, 2016
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Matlab demo script
parent
c4d33c49
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
matlab/CMakeLists.txt
matlab/CMakeLists.txt
+1
-0
matlab/demo.m
matlab/demo.m
+59
-0
No files found.
matlab/CMakeLists.txt
View file @
50e78983
...
...
@@ -27,6 +27,7 @@ matlab_add_mex(
target_include_directories
(
eos_fitting PRIVATE
${
CMAKE_SOURCE_DIR
}
/3rdparty/mexplus/include
${
CMAKE_SOURCE_DIR
}
/matlab/include
)
install
(
FILES
${
CMAKE_SOURCE_DIR
}
/matlab/demo.m DESTINATION matlab
)
install
(
DIRECTORY
${
CMAKE_SOURCE_DIR
}
/matlab/include DESTINATION matlab
)
install
(
DIRECTORY
${
CMAKE_SOURCE_DIR
}
/matlab/+eos DESTINATION matlab PATTERN
"*.cpp"
EXCLUDE
)
install
(
TARGETS eos_fitting DESTINATION matlab/+eos/+fitting/private
)
...
...
matlab/demo.m
0 → 100644
View file @
50e78983
%% Demo for running the eos fitting from Matlab
%
%% Set up some required paths to files:
model_file
=
'../share/sfm_shape_3448.bin'
;
blendshapes_file
=
'../share/expression_blendshapes_3448.bin'
;
%% Read some ibug landmarks for an image:
landmarks
=
read_pts_landmarks
(
'D:\Github\data\ibug\helen\testset\30427236_1.pts'
);
%% Run the fitting, get back the fitted mesh and pose:
[
mesh
,
render_params
]
=
eos
.
fitting
.
fit_shape_and_pose
(
model_file
,
blendshapes_file
,
landmarks
);
%% Visualise the fitted mesh using your favourite tool, for example...
figure
(
1
);
plot3
(
mesh
.
vertices
(:,
1
),
mesh
.
vertices
(:,
2
),
mesh
.
vertices
(:,
3
),
'.'
);
% or...
FV
.
vertices
=
mesh
.
vertices
(:,
1
:
3
);
FV
.
faces
=
mesh
.
tvi
;
figure
(
2
);
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:
% First we project all vertices to 2D:
points_2d
=
zeros
(
size
(
mesh
.
vertices
,
1
),
2
);
h
=
720
;
w
=
1280
;
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
);
imshow
(
img
);
hold
on
;
plot
(
points_2d
(:,
1
),
points_2d
(:,
2
),
'g.'
);
% We can also plot the landmarks the mesh was fitted to:
plot
(
landmarks
(:,
1
),
landmarks
(:,
2
),
'ro'
);
%% Just a helper function to read ibug .pts landmarks from a file:
function
[
landmarks
]
=
read_pts_landmarks
(
filename
)
file
=
fopen
(
filename
,
'r'
);
file_content
=
textscan
(
file
,
'%s'
);
landmarks
=
zeros
(
68
,
2
);
row_idx
=
1
;
for
i
=
6
:
2
:
141
landmarks
(
row_idx
,
1
)
=
str2double
(
file_content
{
1
}{
i
});
landmarks
(
row_idx
,
2
)
=
str2double
(
file_content
{
1
}{
i
+
1
});
row_idx
=
row_idx
+
1
;
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