eos 1.4.0
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
eos::core Namespace Reference

Essential functions and classes to work with 3D face models, meshes and landmarks. More...

Classes

class  Image
 Class to represent images. More...
 
struct  Landmark
 Representation of a landmark, consisting of a landmark name and coordinates of the given type. Usually, the type would be Eigen::Vector2f. More...
 
class  LandmarkMapper
 Represents a mapping from one kind of landmarks to a different format (e.g. model vertices). More...
 
struct  Mesh
 This class represents a 3D mesh consisting of vertices, vertex colour information and texture coordinates. More...
 
class  Pixel
 Represents a pixel with given type and number of channels. More...
 
struct  PixelTraits
 Todo. More...
 
struct  PixelTraits< Pixel< ElementType, NumChannels > >
 Todo. More...
 
struct  Rect
 A simple type representing a rectangle. More...
 

Typedefs

using Image1u = Image< std::uint8_t >
 
using Image3u = Image< Pixel< std::uint8_t, 3 > >
 
using Image4u = Image< Pixel< std::uint8_t, 4 > >
 
using Image1f = Image< float >
 
using Image3f = Image< Pixel< float, 3 > >
 
using Image1d = Image< double >
 
template<class LandmarkType >
using LandmarkCollection = std::vector< Landmark< LandmarkType > >
 A trivial collection of landmarks that belong together.
 

Functions

cv::Mat to_mat (const Image4u &image)
 
cv::Mat to_mat (const Image1d &image)
 
Image3u from_mat (const cv::Mat &image)
 
Image4u from_mat_with_alpha (const cv::Mat &image)
 
template<typename ElementType , int NumChannels>
constexpr bool operator== (const Pixel< ElementType, NumChannels > &lhs, const Pixel< ElementType, NumChannels > &rhs) noexcept
 
template<class T >
LandmarkCollection< T > filter (const LandmarkCollection< T > &landmarks, const std::vector< std::string > &filter)
 Shorthand for a 2D floating point landmark type.
 
template<typename T >
radians (T degrees)
 Convert given degrees to radians.
 
template<typename T >
degrees (T radians)
 Convert given radians to degree.
 
template<typename T >
std::enable_if< std::is_unsigned< T >::value, int >::type constexpr sign (T const x)
 Returns the sign of the given number (-1, 0 or +1).
 
template<typename T >
std::enable_if< std::is_signed< T >::value, int >::type constexpr sign (T const x)
 Returns the sign of the given number (-1, 0 or +1).
 
Mesh read_obj (std::string filename)
 Reads the given Wavefront .obj file into a Mesh.
 
LandmarkCollection< Eigen::Vector2f > read_pts_landmarks (std::string filename)
 
void write_obj (const Mesh &mesh, std::string filename)
 Writes the given Mesh to an obj file that for example can be read by MeshLab.
 
void write_textured_obj (const Mesh &mesh, std::string filename)
 Writes an obj file of the given Mesh, including texture coordinates, and an mtl file containing a reference to the texture map.
 

Variables

template<class T >
constexpr T pi = T(3.1415926535897932385L)
 Compile-time constant for pi (19 digits).
 

Detailed Description

Essential functions and classes to work with 3D face models, meshes and landmarks.

Function Documentation

◆ filter()

template<class T >
LandmarkCollection< T > eos::core::filter ( const LandmarkCollection< T > &  landmarks,
const std::vector< std::string > &  filter 
)

Shorthand for a 2D floating point landmark type.

Alias for the 2D landmark point type.

Filters the given LandmarkCollection and returns a new LandmarkCollection containing all landmarks whose name matches the one given by filter.

Parameters
[in]landmarksThe input LandmarkCollection to be filtered.
[in]filterA list of landmark names (identifiers) by which the given LandmarkCollection is filtered.
Returns
A new, filtered LandmarkCollection.

◆ from_mat()

Image3u eos::core::from_mat ( const cv::Mat &  image)
inline

Returns an Image3u from a given cv::Mat with type CV_8UC3. The channel order is not changed, i.e. if the cv::Mat is BGR, the output Image3u will have BGR channel ordering too.

◆ from_mat_with_alpha()

Image4u eos::core::from_mat_with_alpha ( const cv::Mat &  image)
inline

Supports both CV_8UC3 and CV_8UC4 cv::Mat as input images. If a CV_8UC3 images is given, then all pixels of the alpha channel of the returned image are set to 255.

◆ read_obj()

Mesh eos::core::read_obj ( std::string  filename)
inline

Reads the given Wavefront .obj file into a Mesh.

https://en.wikipedia.org/wiki/Wavefront_.obj_file as of 22 August 2017.

Parameters
[in]filenameInput filename (ending in ".obj").
Returns
A Mesh with the data read from the obj file.

◆ read_pts_landmarks()

LandmarkCollection< Eigen::Vector2f > eos::core::read_pts_landmarks ( std::string  filename)
inline

Reads an ibug .pts landmark file and returns an ordered vector with the 68 2D landmark coordinates.

Parameters
[in]filenamePath to a .pts file.
Returns
An ordered vector with the 68 ibug landmarks.

◆ sign() [1/2]

template<typename T >
std::enable_if< std::is_unsigned< T >::value, int >::type constexpr eos::core::sign ( T const  x)
inlineconstexpr

Returns the sign of the given number (-1, 0 or +1).

According to StackOverflow, the < 0 part of the check triggers GCC's -Wtype-limits warning when instantiated for an unsigned type. Thus we use two overloads, for signed and unsigned types.

◆ sign() [2/2]

template<typename T >
std::enable_if< std::is_signed< T >::value, int >::type constexpr eos::core::sign ( T const  x)
inlineconstexpr

Returns the sign of the given number (-1, 0 or +1).

According to StackOverflow, the < 0 part of the check triggers GCC's -Wtype-limits warning when instantiated for an unsigned type. Thus we use two overloads, for signed and unsigned types.

◆ write_obj()

void eos::core::write_obj ( const Mesh mesh,
std::string  filename 
)
inline

Writes the given Mesh to an obj file that for example can be read by MeshLab.

If the mesh contains vertex colour information, it will be written to the obj as well.

Parameters
[in]meshThe mesh to save as obj.
[in]filenameOutput filename (including ".obj").

◆ write_textured_obj()

void eos::core::write_textured_obj ( const Mesh mesh,
std::string  filename 
)
inline

Writes an obj file of the given Mesh, including texture coordinates, and an mtl file containing a reference to the texture map.

The obj will contain texture coordinates for the mesh, and the mtl file will link to a file named <filename>.texture.png. Note that the texture (i.e. the <filename>.texture.png file) has to be saved separately.

Parameters
[in]meshThe mesh to save as obj.
[in]filenameOutput filename, including .obj.