Antal.Ai - Virtual Makeup
FaceDrawer.h
Go to the documentation of this file.
1 #pragma once
2 #include <vector>
3 
4 #include <opencv2/core/mat.hpp>
5 #include <opencv2/core/types.hpp>
6 
7 
8 
17 namespace visualization {
24  class Triangle
25  {
26  public:
27  Triangle(int a, int b, int c) : A(a), B(b), C(c) {}
28  int A;
29  int B;
30  int C;
31  };
32 
40  class FaceDrawer
41  {
42  public:
43  FaceDrawer();
44 
45  ~FaceDrawer() = default;
46 
56  void loadTriangles(const std::string path);
57 
67  void loadTriangles(const std::vector<uchar>& faceVerticesFileContent);
68 
78  void draw(cv::Mat& image, const std::vector<cv::Point>& facialPoints);
79 
80  void drawMakeupMask(cv::Mat& referenceFace, const std::vector<cv::Point>& referenceFaceLandmark,
81  cv::Mat& currentFace, const std::vector<cv::Point>& currentFaceLandmark);
82 
83  private:
84  std::vector<Triangle> mTriangles;
85 
86  std::vector<int> lipsOuter{
87  61, 185, 40, 39, 37, 0, 267, 269, 270, 409, 291,
88  375, 321, 405, 314, 17, 84, 181, 91, 146
89  };
90 
91 
92  std::vector<int> lipsInner{
93  78, 191, 80, 81, 82, 13, 312, 311, 310, 415, 308,
94  324, 318, 402, 317, 14, 87, 178, 88, 95
95  };
96 
97  };
98 }//namespace visualization
Draws triangulation on faces based on facial points.
Definition: FaceDrawer.h:41
void loadTriangles(const std::string path)
Loads triangles from a file.
Definition: FaceDrawer.cpp:93
void draw(cv::Mat &image, const std::vector< cv::Point > &facialPoints)
Draws triangulation on the given image using facial points.
Definition: FaceDrawer.cpp:116
Represents a triangle with vertex indices.
Definition: FaceDrawer.h:25
int C
Index of the third vertex of the triangle.
Definition: FaceDrawer.h:30
int A
Index of the first vertex of the triangle.
Definition: FaceDrawer.h:28
int B
Index of the second vertex of the triangle.
Definition: FaceDrawer.h:29