Commit d822417c authored by Patrik Huber's avatar Patrik Huber

Setting up calling the C++ fitting function from Matlab

parent 0023da2e
......@@ -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
......@@ -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 != 12) {
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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment