Nirkin Face Swap
0.9.0
Face swap.
|
This class provided face shape and texture estimation using Caffe with a convolutional neural network. More...
#include <cnn_3dmm.h>
Public Member Functions | |
CNN3DMM (const std::string &deploy_file, const std::string &caffe_model_file, const std::string &mean_file, bool init_cnn=true, bool with_gpu=true, int gpu_device_id=0) | |
Creates an instance of CNN3DMM. More... | |
~CNN3DMM () | |
Destructor. | |
void | process (const cv::Mat &img, cv::Mat &shape_coefficients, cv::Mat &tex_coefficients) |
Estimate face shape and texture from image. More... | |
Protected Attributes | |
std::shared_ptr< caffe::Net< float > > | m_net |
int | m_num_channels |
cv::Size | m_input_size |
cv::Mat | m_mean |
bool | m_with_gpu |
This class provided face shape and texture estimation using Caffe with a convolutional neural network.
The CNN estimates shape and texture coefficients for a PCA model that is based on Basel's 3D Morphable Model. This is an implementation of the following papers:
face_swap::CNN3DMM::CNN3DMM | ( | const std::string & | deploy_file, |
const std::string & | caffe_model_file, | ||
const std::string & | mean_file, | ||
bool | init_cnn = true , |
||
bool | with_gpu = true , |
||
int | gpu_device_id = 0 |
||
) |
Creates an instance of CNN3DMM.
deploy_file | Path to 3DMM regression CNN deploy file (.prototxt). |
caffe_model_file | Path to 3DMM regression CNN model file (.caffemodel). |
mean_file | Path to 3DMM regression CNN mean file (.binaryproto). |
init_cnn | if true the CNN will be initialized. |
with_gpu | Toggle GPU execution. |
gpu_device_id | Set the GPU's device id. |
void face_swap::CNN3DMM::process | ( | const cv::Mat & | img, |
cv::Mat & | shape_coefficients, | ||
cv::Mat & | tex_coefficients | ||
) |
Estimate face shape and texture from image.
[in] | img | The image to process. |
[out] | shape_coefficients | PCA shape coefficients. |
[out] | tex_coefficients | PCA texture coefficients. |