Nirkin Face Swap  0.9.0
Face swap.
utilities.h
1 #ifndef FACE_SWAP_UTILITIES_H
2 #define FACE_SWAP_UTILITIES_H
3 
4 #include "face_swap/basel_3dmm.h"
5 #include <opencv2/core.hpp>
6 
7 namespace face_swap
8 {
16  cv::Mat euler2RotMat(float x, float y, float z);
17 
18  cv::Mat euler2RotMat(const cv::Mat& euler);
19 
20  cv::Mat createModelView(const cv::Mat& euler, const cv::Mat& translation);
21 
22  cv::Mat createOrthoProj4x4(const cv::Mat& euler, const cv::Mat& translation,
23  int width, int height);
24 
25  cv::Mat createOrthoProj3x4(const cv::Mat& euler, const cv::Mat& translation,
26  int width, int height);
27 
28  cv::Mat createPerspectiveProj3x4(const cv::Mat& euler,
29  const cv::Mat& translation, const cv::Mat& K);
30 
31  void renderWireframe(cv::Mat& img, const Mesh& mesh, const cv::Mat& P,
32  float scale = 1, const cv::Scalar& color = cv::Scalar(0, 255, 0));
33 
34  void renderWireframe(cv::Mat& img, const Mesh& mesh,
35  const cv::Mat& rvec, const cv::Mat& tvec, const cv::Mat& K,
36  float scale = 1, const cv::Scalar& color = cv::Scalar(0, 255, 0));
37 
38  void renderWireframeUV(cv::Mat& img, const Mesh& mesh, const cv::Mat& uv,
39  const cv::Scalar& color = cv::Scalar(0, 255, 0));
40 
41  void renderBoundary(cv::Mat& img, const Mesh& mesh,
42  const cv::Mat& rvec, const cv::Mat& tvec, const cv::Mat& K,
43  const cv::Scalar& color = cv::Scalar(255, 0, 0));
44 
45  bool is_ccw(const cv::Point2f& p1, const cv::Point2f& p2, const cv::Point2f& p3);
46 
47  inline unsigned int nextPow2(unsigned int x)
48  {
49  --x;
50  x |= x >> 1;
51  x |= x >> 2;
52  x |= x >> 4;
53  x |= x >> 8;
54  x |= x >> 16;
55  return ++x;
56  }
57 
58  cv::Mat computeFaceNormals(const Mesh& mesh);
59 
60  cv::Mat computeVertexNormals(const Mesh& mesh);
61 
62 } // namespace face_swap
63 
64 #endif // FACE_SWAP_UTILITIES_H
65 
Definition: basel_3dmm.h:9