Skeletal Animation Multithread Face
|
This class runs the client that handles the vertices coming from the python server face_mesh_server.py to render the face landmarking. More...
#include <face.h>
Public Member Functions | |
Face () | |
Constructor. More... | |
void | update (void) |
Eigen::MatrixXd | get_vertices (void) |
Get face vertices. More... | |
Eigen::MatrixXi | get_surface_indices (void) |
Get the surface indices of the face mesh. More... | |
Eigen::MatrixXd | translation_matrix (const Eigen::Vector3d &offset, size_t vert_num) |
This function offset a set of vertices by a given offset. More... | |
Private Member Functions | |
void | setup_tcp_communication (void) |
Setup communication with python server. More... | |
Eigen::MatrixXd | incoming_data_callback (void) |
Read incoming data. More... | |
Private Attributes | |
std::filesystem::path | m_vertices_connections_abs_path |
Absolute name of vertices connection files. More... | |
std::string | m_vertices_connections_rel_filename |
Relative name of vertices connection files. More... | |
Eigen::MatrixXi | m_faces |
Face landmarking indices matrix. More... | |
std::string | m_local_ip_address = "127.0.1.1" |
Start tcp client at this ip adress (localhost). More... | |
const int | m_tcp_port = 5052 |
int | m_socket = 0 |
Socket handle. More... | |
const int | m_buffer_size = 40000 |
const int | m_vertices_num = 468 |
Number of vertices provided by the mediapipe. This is constant. More... | |
Eigen::MatrixXi | m_surf_indices |
The surface element indices of the incoming mesh. More... | |
std::future< Eigen::MatrixXd > | m_future_fun |
Future function handle. More... | |
bool | m_return_value = 0 |
Termination flag for callback function. More... | |
Eigen::MatrixXd | m_vol_mesh_vertices |
Volume mesh data. More... | |
Eigen::Matrix3d | m_rot_mat = Eigen::Matrix3d::Identity() |
Face rotation matrix. More... | |
double | m_face_mesh_scale = 6.0 |
Face scale matrix. More... | |
Eigen::Vector3d | m_face_offset = Eigen::Vector3d({0.0, -2.0, 0.0}) |
Eigen::Matrix3d | m_scale_mat |
This class runs the client that handles the vertices coming from the python server face_mesh_server.py to render the face landmarking.
Face::Face | ( | ) |
Constructor.
Construct a new Face:: Face object It initializes the tcp communcations and the asychronous functionalities. The indices of the face mesh are stored in the "vertices_connections.csv" and they are converted to an Eigen::MatrixXi.
Definition at line 9 of file face.cpp.
|
inline |
Eigen::MatrixXd Face::get_vertices | ( | void | ) |
Get face vertices.
It is the point of entry that feeds the animation loop with the face vertices data. It also manages the asynchronous threading.
Definition at line 41 of file face.cpp.
|
private |
Read incoming data.
This is the callback function for reading asynchronously the incoming data (vertices) from the server. The data is sent as a json file, so a parser is also used for reading the x, y and z coordinates of each vertex of the face mesh.
Definition at line 63 of file face.cpp.
|
private |
Setup communication with python server.
Since the libraries for face landmarking are all written in Python, we establish an Inter-process communication (IPC), to get all the data in our C++ program. In this case the IPC is implemented with the help of sockets. The python side sets up a server and it transmits all the data to our C++ client. This method sets the tcp communication and initializes the socket and the client that listens to incoming data.
Definition at line 143 of file face.cpp.
Eigen::MatrixXd Face::translation_matrix | ( | const Eigen::Vector3d & | offset, |
size_t | vert_num | ||
) |
This function offset a set of vertices by a given offset.
This is not a homogenous transformation matrix. Instead it is used for shifting a matrix of vertices (as defined by libigl) by a given offset.
offset | The offset to shift the matrix of vertices. |
vert_num | The number of matrices. |
Definition at line 176 of file face.cpp.
void Face::update | ( | void | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |