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
d822417c
Commit
d822417c
authored
Dec 03, 2016
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setting up calling the C++ fitting function from Matlab
parent
0023da2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
15 deletions
+37
-15
matlab/+eos/+fitting/fit_shape_and_pose.m
matlab/+eos/+fitting/fit_shape_and_pose.m
+17
-2
matlab/+eos/+fitting/private/fitting.cpp
matlab/+eos/+fitting/private/fitting.cpp
+20
-13
No files found.
matlab/+eos/+fitting/fit_shape_and_pose.m
View file @
d822417c
...
...
@@ -12,6 +12,9 @@ function [mesh, rendering_parameters] = fit_shape_and_pose(morphable_model, ...
% It fits the pose (camera), PCA shape model, and expression blendshapes
% in an iterative way.
%
% Default values: num_iterations = 5, num_shape_coefficients_to_fit = all
% (-1), and lambda = 30.0.
%
% Please see the C++ documentation for the description of the parameters:
% http://patrikhuber.github.io/eos/doc/ (TODO: Update documentation!)
%
...
...
@@ -20,7 +23,19 @@ function [mesh, rendering_parameters] = fit_shape_and_pose(morphable_model, ...
% contour_landmarks and model_contour as *filenames* to the respective
% files in the eos/share/ directory, and not the objects directly.
mesh
=
fitting
(
1
,
[
1
,
2
,
3
;
4
,
5
,
6
]);
rendering_parameters
=
[];
morphable_model
=
''
;
blendshapes
=
''
;
landmarks
=
zeros
(
68
,
2
);
% 68 x 2 vector with ibug LMs, in order! 1 to 68
landmark_mapper
=
''
;
image_width
=
1280
;
image_height
=
720
;
edge_topology
=
''
;
contour_landmarks
=
''
;
model_contour
=
''
;
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
(
'lambda'
,
'var'
)),
lambda
=
30.0
;
end
[
mesh
,
rendering_parameters
]
=
fitting
(
morphable_model
,
blendshapes
,
landmarks
,
landmark_mapper
,
image_width
,
image_height
,
edge_topology
,
contour_landmarks
,
model_contour
,
num_iterations
,
num_shape_coefficients_to_fit
,
lambda
);
end
matlab/+eos/+fitting/private/fitting.cpp
View file @
d822417c
...
...
@@ -26,24 +26,30 @@
#include "mex.h"
//#include "matrix.h"
#include <string>
using
namespace
mexplus
;
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
{
using
std
::
vector
;
using
std
::
string
;
// Check for proper number of input and output arguments:
mexPrintf
(
"nlhs: %d, nrhs: %d
\n
"
,
nlhs
,
nrhs
);
if
(
nrhs
!=
2
)
{
mexErrMsgIdAndTxt
(
"eos:example:nargin"
,
"
Example requires two
input arguments."
);
if
(
nrhs
!=
1
2
)
{
mexErrMsgIdAndTxt
(
"eos:example:nargin"
,
"
fit_shape_and_pose requires 12
input arguments."
);
}
else
if
(
nlhs
>
=
2
)
{
// 'nlhs >= 1' means no output argument apparently?
mexErrMsgIdAndTxt
(
"eos:example:nargout"
,
"
Example requires zero or one
output arguments."
);
if
(
nlhs
!
=
2
)
{
// 'nlhs >= 1' means no output argument apparently?
mexErrMsgIdAndTxt
(
"eos:example:nargout"
,
"
fit_shape_and_pose returns two
output arguments."
);
}
InputArguments
input
(
nrhs
,
prhs
,
2
);
double
vin1
=
input
.
get
<
double
>
(
0
);
InputArguments
input
(
nrhs
,
prhs
,
12
);
auto
morphablemodel_file
=
input
.
get
<
string
>
(
0
);
auto
blendshapes_file
=
input
.
get
<
string
>
(
1
);
auto
landmarks
=
input
.
get
<
Eigen
::
MatrixXd
>
(
2
);
// auto mm = input.get<string>(0);
// double vin1 = input.get<double>(0);
// Matlab stores col-wise in memory - hence the entry of the second row comes first
auto
vin2
=
input
.
get
<
vector
<
double
>>
(
1
);
//
auto vin2 = input.get<vector<double>>(1);
/* auto test = input[1];
MxArray mxa(test);
auto ndim = mxa.dimensionSize();
...
...
@@ -57,18 +63,19 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
*/
//auto x = MxArray::Numeric<double>(2, 2);
auto
asdf
=
input
.
get
<
Eigen
::
MatrixXd
>
(
1
);
/*
auto asdf = input.get<Eigen::MatrixXd>(1);
std::stringstream ss2;
ss2 << asdf;
std
::
string
msg2
=
ss2
.
str
();
std::string msg2 = ss2.str();
*/
OutputArguments
output
(
nlhs
,
plhs
,
1
);
output
.
set
(
0
,
asdf
);
OutputArguments
output
(
nlhs
,
plhs
,
2
);
output
.
set
(
0
,
landmarks
);
output
.
set
(
1
,
landmarks
);
//double *vin1, *vin2;
//vin1 = (double*)mxGetPr(prhs[0]);
//vin2 = (double*)mxGetPr(prhs[1]);
mexPrintf
(
"%f, %f
\n
"
,
vin1
,
vin2
[
0
]);
//
mexPrintf("%f, %f\n", vin1, vin2[0]);
};
void
func
()
...
...
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