forked from MasteringOpenCV/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPAW.h
More file actions
executable file
·79 lines (61 loc) · 1.74 KB
/
Copy pathPAW.h
File metadata and controls
executable file
·79 lines (61 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
#include <map>
#include <opencv2/opencv.hpp>
#include <opencv2/legacy/legacy.hpp>
using namespace std;
using namespace cv;
class PAW
{
public:
PAW(Mat srcLandmarks, Mat dstLandmarks,int width, int height);
vector<CvPoint> getPointsInsideHull();
Mat getTriangles();
Mat getWarp();
int getNLandmarks();
int getBaseImageWidth();
int getBaseImageHeight();
Mat getSourceLandmarks();
Mat getDestLandmarks();
map<int,int>& getMapPointTriangle();
~PAW(void);
private:
int nLandmarks;
int nPixels;
int nTriangles;
//width and height of base image to be swept
//this image contains the base mesh
int baseImageWidth, baseImageHeight;
map<int,int> mapPointTriangle;
//src and dst landmark matrix follow the format
// [x0 y0
// x1 y1
// x2 y2
// x3 y3]]
Mat srcLandmarks;
Mat dstLandmarks;
// nx3 integer matrix with triangle indexes
// 0 1 2
// 0 2 3
// ...
Mat triangles;
// warp matrix is in the following format
// a10 a20 a30 a40 a50 a60
// a11 a21 a31 a41 a51 a61
// a12 a22 a32 a42 a52 a62
Mat warp;
// alphas
// [alpha0
// alpha1
// ...
// alphaTriangleN]
Mat alphas, betas;
vector<CvPoint> pointsInsideHull;
//calculates convexHull, nPixels and triangles
void init();
void populatePointsInsideHull();
void triangulate();
void calculateWarpMatrix();
bool isPointInsideTriangleIndex(int px, int py, int triangleIndex);
bool isPointInsideTriangle(int px, int py, int t0x, int t0y, int t1x, int t1y, int t2x, int t2y);
void populatePointTriangleMap();
};