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
7ac1b4a8
Commit
7ac1b4a8
authored
Jul 09, 2015
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added cereal serialisation to the PCA and Morphable Model classes
Added cereal include directory to CMake
parent
9547afe3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
0 deletions
+72
-0
CMakeLists.txt
CMakeLists.txt
+4
-0
include/eos/morphablemodel/MorphableModel.hpp
include/eos/morphablemodel/MorphableModel.hpp
+49
-0
include/eos/morphablemodel/PcaModel.hpp
include/eos/morphablemodel/PcaModel.hpp
+19
-0
No files found.
CMakeLists.txt
View file @
7ac1b4a8
...
@@ -42,6 +42,8 @@ else(Boost_FOUND)
...
@@ -42,6 +42,8 @@ else(Boost_FOUND)
endif
()
endif
()
set
(
CEREAL_INCLUDE_DIR
"
${
CMAKE_SOURCE_DIR
}
/3rdparty/cereal-1.1.1/include"
)
# Header files:
# Header files:
set
(
HEADERS
set
(
HEADERS
include/eos/core/LandmarkMapper.hpp
include/eos/core/LandmarkMapper.hpp
...
@@ -57,6 +59,7 @@ set(HEADERS
...
@@ -57,6 +59,7 @@ set(HEADERS
# Add header includes:
# Add header includes:
include_directories
(
"include"
)
include_directories
(
"include"
)
include_directories
(
${
CEREAL_INCLUDE_DIR
}
)
include_directories
(
${
Boost_INCLUDE_DIRS
}
)
include_directories
(
${
Boost_INCLUDE_DIRS
}
)
include_directories
(
${
OpenCV_INCLUDE_DIRS
}
)
include_directories
(
${
OpenCV_INCLUDE_DIRS
}
)
...
@@ -73,6 +76,7 @@ source_group(render\\detail include/eos/render/detail/*)
...
@@ -73,6 +76,7 @@ source_group(render\\detail include/eos/render/detail/*)
# The install target:
# The install target:
install
(
DIRECTORY
${
CMAKE_SOURCE_DIR
}
/include/ DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/include
)
install
(
DIRECTORY
${
CMAKE_SOURCE_DIR
}
/include/ DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/include
)
install
(
DIRECTORY
${
CMAKE_SOURCE_DIR
}
/share/ DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/share
)
install
(
DIRECTORY
${
CMAKE_SOURCE_DIR
}
/share/ DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/share
)
install
(
DIRECTORY
${
CMAKE_SOURCE_DIR
}
/3rdparty/cereal-1.1.1/include/ DESTINATION 3rdparty/cereal-1.1.1/include
)
# cereal headers
if
(
BUILD_EXAMPLES
)
if
(
BUILD_EXAMPLES
)
add_subdirectory
(
examples
)
add_subdirectory
(
examples
)
...
...
include/eos/morphablemodel/MorphableModel.hpp
View file @
7ac1b4a8
...
@@ -26,6 +26,11 @@
...
@@ -26,6 +26,11 @@
#include "eos/render/Mesh.hpp"
#include "eos/render/Mesh.hpp"
#include "eos/morphablemodel/io/mat_cerealisation.hpp"
#include "cereal/access.hpp"
#include "cereal/types/vector.hpp"
#include "cereal/archives/binary.hpp"
#include <vector>
#include <vector>
#include <array>
#include <array>
...
@@ -49,6 +54,7 @@ namespace eos {
...
@@ -49,6 +54,7 @@ namespace eos {
class
MorphableModel
class
MorphableModel
{
{
public:
public:
MorphableModel
()
=
default
;
/**
/**
* Create a Morphable Model from a shape and a color PCA model, and optional
* Create a Morphable Model from a shape and a color PCA model, and optional
...
@@ -187,6 +193,49 @@ private:
...
@@ -187,6 +193,49 @@ private:
return
texture_coordinates
.
size
()
>
0
?
true
:
false
;
return
texture_coordinates
.
size
()
>
0
?
true
:
false
;
};
};
friend
class
cereal
::
access
;
/**
* Serialises this class using cereal.
*
* @param[in] ar The archive to serialise to (or to serialise from).
*/
template
<
class
Archive
>
void
serialize
(
Archive
&
archive
)
{
archive
(
shape_model
,
color_model
,
texture_coordinates
);
};
};
/**
* Helper method to load a Morphable Model from
* a cereal::BinaryInputArchive from the harddisk.
*
* @param[in] filename Filename to a model.
* @return The loaded Morphable Model.
*/
MorphableModel
load_model
(
std
::
string
filename
)
{
MorphableModel
model
;
std
::
ifstream
file
(
filename
,
std
::
ios
::
binary
);
cereal
::
BinaryInputArchive
input_archive
(
file
);
input_archive
(
model
);
return
model
;
};
/**
* Helper method to save a Morphable Model to the
* harddrive as cereal::BinaryInputArchive.
*
* @param[in] model The model to be saved.
* @param[in] filename Filename for the model.
*/
void
save_model
(
MorphableModel
model
,
std
::
string
filename
)
{
std
::
ofstream
file
(
filename
,
std
::
ios
::
binary
);
cereal
::
BinaryOutputArchive
output_archive
(
file
);
output_archive
(
model
);
};
};
namespace
detail
{
/* eos::morphablemodel::detail */
namespace
detail
{
/* eos::morphablemodel::detail */
...
...
include/eos/morphablemodel/PcaModel.hpp
View file @
7ac1b4a8
...
@@ -22,6 +22,11 @@
...
@@ -22,6 +22,11 @@
#ifndef PCAMODEL_HPP_
#ifndef PCAMODEL_HPP_
#define PCAMODEL_HPP_
#define PCAMODEL_HPP_
#include "eos/morphablemodel/io/mat_cerealisation.hpp"
#include "cereal/access.hpp"
#include "cereal/types/array.hpp"
#include "cereal/types/vector.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/core/core.hpp"
#include <string>
#include <string>
...
@@ -251,6 +256,20 @@ private:
...
@@ -251,6 +256,20 @@ private:
cv
::
Mat
eigenvalues
;
///< A col-vector of the eigenvalues (variances in the PCA space).
cv
::
Mat
eigenvalues
;
///< A col-vector of the eigenvalues (variances in the PCA space).
std
::
vector
<
std
::
array
<
int
,
3
>>
triangle_list
;
///< List of triangles that make up the mesh of the model.
std
::
vector
<
std
::
array
<
int
,
3
>>
triangle_list
;
///< List of triangles that make up the mesh of the model.
friend
class
cereal
::
access
;
/**
* Serialises this class using cereal.
*
* @param[in] ar The archive to serialise to (or to serialise from).
*/
template
<
class
Archive
>
void
serialize
(
Archive
&
archive
)
{
archive
(
mean
,
normalised_pca_basis
,
unnormalised_pca_basis
,
eigenvalues
,
triangle_list
);
// Note: If the files are too big, We could split this in save/load, only
// store one of the bases, and calculate the other one when loading.
};
};
};
...
...
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