Nirkin Face Swap  0.9.0
Face swap.
cnn_3dmm.h
1 #ifndef FACE_SWAP_CNN_3DMM_H
2 #define FACE_SWAP_CNN_3DMM_H
3 
4 // Includes
5 #include <opencv2/core.hpp>
6 
7 // Caffe
8 #include <caffe/caffe.hpp>
9 
10 #include <string>
11 
12 namespace face_swap
13 {
24  class CNN3DMM
25  {
26  public:
27 
36  CNN3DMM(const std::string& deploy_file, const std::string& caffe_model_file,
37  const std::string& mean_file, bool init_cnn = true,
38  bool with_gpu = true, int gpu_device_id = 0);
39 
42  ~CNN3DMM();
43 
49  void process(const cv::Mat& img,
50  cv::Mat& shape_coefficients, cv::Mat& tex_coefficients);
51 
52  private:
53  void wrapInputLayer(std::vector<cv::Mat>& input_channels);
54 
55  cv::Mat readMean(const std::string& mean_file) const;
56 
57  cv::Mat preprocess(const cv::Mat& img);
58 
59  void copyInputData(cv::Mat& img);
60 
61  protected:
62  std::shared_ptr<caffe::Net<float> > m_net;
63  int m_num_channels;
64  cv::Size m_input_size;
65  cv::Mat m_mean;
66  bool m_with_gpu;
67  };
68 
69 } // namespace face_swap
70 
71 #endif // FACE_SWAP_CNN_3DMM_H
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.
~CNN3DMM()
Destructor.
void process(const cv::Mat &img, cv::Mat &shape_coefficients, cv::Mat &tex_coefficients)
Estimate face shape and texture from image.
This class provided face shape and texture estimation using Caffe with a convolutional neural network...
Definition: cnn_3dmm.h:24
Definition: basel_3dmm.h:9