Nirkin Face Swap  0.9.0
Face swap.
face_swap::CNN3DMM Class Reference

This class provided face shape and texture estimation using Caffe with a convolutional neural network. More...

#include <cnn_3dmm.h>

Inheritance diagram for face_swap::CNN3DMM:

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 ()
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

Detailed Description

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:

  1. Regressing Robust and Discriminative 3D Morphable Models with a very Deep Neural Network, Anh Tuan Tran, Tal Hassner, Iacopo Masi and Gerard Medioni.
  2. A 3D Face Model for Pose and Illumination Invariant Face Recognition, P. Paysan and R. Knothe and B. Amberg and S. Romdhani and T. Vetter.

Constructor & Destructor Documentation

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_filePath to 3DMM regression CNN deploy file (.prototxt).
caffe_model_filePath to 3DMM regression CNN model file (.caffemodel).
mean_filePath to 3DMM regression CNN mean file (.binaryproto).
init_cnnif true the CNN will be initialized.
with_gpuToggle GPU execution.
gpu_device_idSet the GPU's device id.

Member Function Documentation

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]imgThe image to process.
[out]shape_coefficientsPCA shape coefficients.
[out]tex_coefficientsPCA texture coefficients.

The documentation for this class was generated from the following file: