|
Nirkin Face Swap
0.9.0
Face swap.
|
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 ®_model_path, const std::string ®_deploy_path, const std::string ®_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 Mesh & | getSourceMesh () const |
| Get the 3D reconstruced mesh of the source face. More... | |
| const Mesh & | getTargetMesh () 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 () |
| 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.
| landmarks_path | Path to the landmarks model file. |
| model_3dmm_h5_path | Path to 3DMM file (.h5). |
| model_3dmm_dat_path | Path to 3DMM file (.dat). |
| reg_model_path | Path to 3DMM regression CNN model file (.caffemodel). |
| reg_deploy_path | Path to 3DMM regression CNN deploy file (.prototxt). |
| reg_mean_path | Path to 3DMM regression CNN mean file (.binaryproto). |
| generic | Use generic model without shape regression. |
| with_expr | Toggle fitting face expressions. |
| with_gpu | Toggle GPU execution. |
| gpu_device_id | Set the GPU's device id. |
| 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.
| seg_model_path | Path to face segmentation CNN model file (.caffemodel). |
| seg_deploy_path | Path to face segmentation CNN deploy file (.prototxt). |