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

Public Member Functions

 FaceSwap (const std::string &landmarks_path, const std::string &model_3dmm_h5_path, const std::string &model_3dmm_dat_path, const std::string &reg_model_path, const std::string &reg_deploy_path, const std::string &reg_mean_path, bool generic=false, bool with_expr=true, bool with_gpu=true, int gpu_device_id=0)
 Construct FaceSwap instance. More...
 
void setSegmentationModel (const std::string &seg_model_path, const std::string &seg_deploy_path)
 Set segmentation model. More...
 
void clearSegmentationModel ()
 Clear previously set segmentation model. More...
 
bool isSegmentationModelInit ()
 Check whether the segmentation model is initialized.
 
bool setSource (const cv::Mat &img, const cv::Mat &seg=cv::Mat())
 Set source image and segmentation.
 
bool setTarget (const cv::Mat &img, const cv::Mat &seg=cv::Mat())
 Set target image and segmentation.
 
cv::Mat swap ()
 Transfer the face from the source image onto the face in the target image.
 
const MeshgetSourceMesh () const
 Get the 3D reconstruced mesh of the source face. More...
 
const MeshgetTargetMesh () const
 Get the 3D reconstruced mesh of the target face. More...
 
cv::Mat debugSource ()
 
cv::Mat debugTarget ()
 
cv::Mat debug ()
 
cv::Mat debugSourceMesh ()
 
cv::Mat debugTargetMesh ()
 
cv::Mat debugMesh (const cv::Mat &img, const cv::Mat &seg, const cv::Mat &uv, const Mesh &mesh, const cv::Mat &vecR, const cv::Mat &vecT, const cv::Mat &K)
 
cv::Mat debugSourceLandmarks ()
 
cv::Mat debugTargetLandmarks ()
 
cv::Mat debugRender ()
 

Constructor & Destructor Documentation

face_swap::FaceSwap::FaceSwap ( const std::string &  landmarks_path,
const std::string &  model_3dmm_h5_path,
const std::string &  model_3dmm_dat_path,
const std::string &  reg_model_path,
const std::string &  reg_deploy_path,
const std::string &  reg_mean_path,
bool  generic = false,
bool  with_expr = true,
bool  with_gpu = true,
int  gpu_device_id = 0 
)

Construct FaceSwap instance.

Parameters
landmarks_pathPath to the landmarks model file.
model_3dmm_h5_pathPath to 3DMM file (.h5).
model_3dmm_dat_pathPath to 3DMM file (.dat).
reg_model_pathPath to 3DMM regression CNN model file (.caffemodel).
reg_deploy_pathPath to 3DMM regression CNN deploy file (.prototxt).
reg_mean_pathPath to 3DMM regression CNN mean file (.binaryproto).
genericUse generic model without shape regression.
with_exprToggle fitting face expressions.
with_gpuToggle GPU execution.
gpu_device_idSet the GPU's device id.

Member Function Documentation

void face_swap::FaceSwap::clearSegmentationModel ( )

Clear previously set segmentation model.

Source and Target segmentation will not longer be calculated if not specified.

const Mesh& face_swap::FaceSwap::getSourceMesh ( ) const

Get the 3D reconstruced mesh of the source face.

If the "generic" option is enabled than this will return the generic shape.

const Mesh& face_swap::FaceSwap::getTargetMesh ( ) const

Get the 3D reconstruced mesh of the target face.

If the "generic" option is enabled than this will return the generic shape.

void face_swap::FaceSwap::setSegmentationModel ( const std::string &  seg_model_path,
const std::string &  seg_deploy_path 
)

Set segmentation model.

Source and Target segmentations will be calculated using this model if not specified. GPU execution and the GPU's device id are determined in the constructor.

Parameters
seg_model_pathPath to face segmentation CNN model file (.caffemodel).
seg_deploy_pathPath to face segmentation CNN deploy file (.prototxt).

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