forked from spmallick/learnopencv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawLandmarks.hpp
59 lines (51 loc) · 1.67 KB
/
drawLandmarks.hpp
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
#ifndef _renderFace_H_
#define _renderFace_H_
using namespace cv;
using namespace std;
#define COLOR Scalar(255, 200,0)
// drawPolyLine draws a poly line by joining
// successive points between the start and end indices.
void drawPolyline
(
Mat &im,
const vector<Point2f> &landmarks,
const int start,
const int end,
bool isClosed = false
)
{
// Gather all points between the start and end indices
vector <Point> points;
for (int i = start; i <= end; i++)
{
points.push_back(cv::Point(landmarks[i].x, landmarks[i].y));
}
// Draw polylines.
polylines(im, points, isClosed, COLOR, 2, 16);
}
void drawLandmarks(Mat &im, vector<Point2f> &landmarks)
{
// Draw face for the 68-point model.
if (landmarks.size() == 68)
{
drawPolyline(im, landmarks, 0, 16); // Jaw line
drawPolyline(im, landmarks, 17, 21); // Left eyebrow
drawPolyline(im, landmarks, 22, 26); // Right eyebrow
drawPolyline(im, landmarks, 27, 30); // Nose bridge
drawPolyline(im, landmarks, 30, 35, true); // Lower nose
drawPolyline(im, landmarks, 36, 41, true); // Left eye
drawPolyline(im, landmarks, 42, 47, true); // Right Eye
drawPolyline(im, landmarks, 48, 59, true); // Outer lip
drawPolyline(im, landmarks, 60, 67, true); // Inner lip
}
else
{ // If the number of points is not 68, we do not know which
// points correspond to which facial features. So, we draw
// one dot per landamrk.
for(int i = 0; i < landmarks.size(); i++)
{
circle(im,landmarks[i],3, COLOR, FILLED);
}
}
}
#endif // _renderFace_H_