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
71d5dc07
Commit
71d5dc07
authored
Feb 10, 2017
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Matlab bindings for extract_texture
parent
dfde0b49
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
2 deletions
+100
-2
matlab/+eos/+render/extract_texture.m
matlab/+eos/+render/extract_texture.m
+23
-0
matlab/+eos/+render/private/render.cpp
matlab/+eos/+render/private/render.cpp
+65
-0
matlab/CMakeLists.txt
matlab/CMakeLists.txt
+12
-2
No files found.
matlab/+eos/+render/extract_texture.m
0 → 100644
View file @
71d5dc07
function
[
texturemap
]
=
extract_texture
(
mesh
,
rendering_params
,
image
,
...
compute_view_angle
,
isomap_resolution
)
% EXTRACT_TEXTURE Extracts the texture from an image and returns the texture map.
% [ texturemap ] = EXTRACT_TEXTURE(mesh, rendering_params, image, ...
% compute_view_angle, isomap_resolution)
%
% Extracts the texture of the face from the given image and stores it as
% isomap (a rectangular texture map).
%
% Default values for the parameters: compute_view_angle = false,
% isomap_resolution = 512.
%
% Please see the C++ documentation for the full description:
% http://patrikhuber.github.io/eos/doc/ (TODO: Update to v0.10.1!)
% We'll use default values to the following arguments, if they're not
% provided:
if
(
~
exist
(
'compute_view_angle'
,
'var'
)),
compute_view_angle
=
false
;
end
if
(
~
exist
(
'isomap_resolution'
,
'var'
)),
isomap_resolution
=
512
;
end
[
texturemap
]
=
render
(
mesh
,
rendering_params
,
image
,
compute_view_angle
,
isomap_resolution
);
end
matlab/+eos/+render/private/render.cpp
0 → 100644
View file @
71d5dc07
/*
* eos - A 3D Morphable Model fitting library written in modern C++11/14.
*
* File: matlab/+eos/+render/private/render.cpp
*
* Copyright 2017 Patrik Huber
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "eos/core/Mesh.hpp"
#include "eos/fitting/RenderingParameters.hpp"
#include "eos/render/texture_extraction.hpp"
#include "mexplus_opencv.hpp"
#include "mexplus_eos_types.hpp"
#include "mexplus.h"
#include "opencv2/core/core.hpp"
#include "mex.h"
using
namespace
eos
;
using
namespace
mexplus
;
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
{
// Check for proper number of input and output arguments:
if
(
nrhs
!=
5
)
{
mexErrMsgIdAndTxt
(
"eos:render:nargin"
,
"extract_texture requires 5 input arguments."
);
}
if
(
nlhs
!=
1
)
{
mexErrMsgIdAndTxt
(
"eos:render:nargout"
,
"extract_texture returns one output argument."
);
}
InputArguments
input
(
nrhs
,
prhs
,
5
);
const
auto
mesh
=
input
.
get
<
core
::
Mesh
>
(
0
);
const
auto
rendering_params
=
input
.
get
<
fitting
::
RenderingParameters
>
(
1
);
const
auto
image
=
input
.
get
<
cv
::
Mat
>
(
2
);
const
auto
compute_view_angle
=
input
.
get
<
bool
>
(
3
);
// default: false
const
auto
isomap_resolution
=
input
.
get
<
int
>
(
4
);
// default: 512
// We expect to be given a RGB image. Let's convert it to BGR for OpenCV.
// Actually, it doesn't matter at all for the texture extraction - just keep it!
//cv::Mat image_as_bgr;// = image.clone();
//cv::cvtColor(image, image_as_bgr, cv::COLOR_RGB2BGR);
// Now do the actual extraction:
const
cv
::
Mat
affine_from_ortho
=
fitting
::
get_3x4_affine_camera_matrix
(
rendering_params
,
image
.
cols
,
image
.
rows
);
const
cv
::
Mat
isomap
=
render
::
extract_texture
(
mesh
,
affine_from_ortho
,
image
,
compute_view_angle
,
render
::
TextureInterpolation
::
NearestNeighbour
,
isomap_resolution
);
// Return the extracted texture-map:
OutputArguments
output
(
nlhs
,
plhs
,
1
);
output
.
set
(
0
,
isomap
);
};
matlab/CMakeLists.txt
View file @
71d5dc07
...
@@ -25,6 +25,7 @@ find_package(Boost 1.50.0 COMPONENTS system filesystem REQUIRED) # Why do we nee
...
@@ -25,6 +25,7 @@ find_package(Boost 1.50.0 COMPONENTS system filesystem REQUIRED) # Why do we nee
# Our helper-headers, and Matlab-specific headers - to make them show up in IDEs:
# Our helper-headers, and Matlab-specific headers - to make them show up in IDEs:
set
(
EOS_MATLAB_HEADERS
set
(
EOS_MATLAB_HEADERS
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/mexplus_eigen.hpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/mexplus_eigen.hpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/mexplus_opencv.hpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/mexplus_eos_types.hpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/mexplus_eos_types.hpp
)
)
add_custom_target
(
eos-matlab-headers SOURCES
${
EOS_MATLAB_HEADERS
}
)
add_custom_target
(
eos-matlab-headers SOURCES
${
EOS_MATLAB_HEADERS
}
)
...
@@ -40,12 +41,21 @@ matlab_add_mex(
...
@@ -40,12 +41,21 @@ matlab_add_mex(
#[...]
#[...]
)
)
target_include_directories
(
eos-matlab-fitting PRIVATE
${
eos_3RDPARTY_DIR
}
/mexplus/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
matlab_add_mex
(
NAME eos-matlab-render
SRC +eos/+render/private/render.cpp
OUTPUT_NAME render
LINK_TO eos
${
OpenCV_LIBS
}
${
Boost_LIBRARIES
}
)
# Group the matlab bindings targets into one folder (in IDEs):
# Group the matlab bindings targets into one folder (in IDEs):
set_target_properties
(
eos-matlab-headers eos-matlab-fitting PROPERTIES FOLDER
"matlab-bindings"
)
set_target_properties
(
eos-matlab-headers eos-matlab-fitting
eos-matlab-render
PROPERTIES FOLDER
"matlab-bindings"
)
target_include_directories
(
eos-matlab-fitting PRIVATE
${
eos_3RDPARTY_DIR
}
/mexplus/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
# the latter one we can use the eos-matlab-headers target?
target_include_directories
(
eos-matlab-render PRIVATE
${
eos_3RDPARTY_DIR
}
/mexplus/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
install
(
FILES
${
CMAKE_CURRENT_SOURCE_DIR
}
/demo.m DESTINATION matlab
)
install
(
FILES
${
CMAKE_CURRENT_SOURCE_DIR
}
/demo.m DESTINATION matlab
)
install
(
DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/include DESTINATION matlab
)
install
(
DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/include DESTINATION matlab
)
install
(
DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/+eos DESTINATION matlab PATTERN
"*.cpp"
EXCLUDE
)
install
(
DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/+eos DESTINATION matlab PATTERN
"*.cpp"
EXCLUDE
)
install
(
TARGETS eos-matlab-fitting DESTINATION matlab/+eos/+fitting/private
)
install
(
TARGETS eos-matlab-fitting DESTINATION matlab/+eos/+fitting/private
)
install
(
TARGETS eos-matlab-render DESTINATION matlab/+eos/+render/private
)
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