Path: blob/master/FacialLandmarkDetection/drawLandmarks.hpp
3118 views
#ifndef _renderFace_H_1#define _renderFace_H_23using namespace cv;4using namespace std;56#define COLOR Scalar(255, 200,0)78// drawPolyLine draws a poly line by joining9// successive points between the start and end indices.10void drawPolyline11(12Mat &im,13const vector<Point2f> &landmarks,14const int start,15const int end,16bool isClosed = false17)18{19// Gather all points between the start and end indices20vector <Point> points;21for (int i = start; i <= end; i++)22{23points.push_back(cv::Point(landmarks[i].x, landmarks[i].y));24}25// Draw polylines.26polylines(im, points, isClosed, COLOR, 2, 16);2728}293031void drawLandmarks(Mat &im, vector<Point2f> &landmarks)32{33// Draw face for the 68-point model.34if (landmarks.size() == 68)35{36drawPolyline(im, landmarks, 0, 16); // Jaw line37drawPolyline(im, landmarks, 17, 21); // Left eyebrow38drawPolyline(im, landmarks, 22, 26); // Right eyebrow39drawPolyline(im, landmarks, 27, 30); // Nose bridge40drawPolyline(im, landmarks, 30, 35, true); // Lower nose41drawPolyline(im, landmarks, 36, 41, true); // Left eye42drawPolyline(im, landmarks, 42, 47, true); // Right Eye43drawPolyline(im, landmarks, 48, 59, true); // Outer lip44drawPolyline(im, landmarks, 60, 67, true); // Inner lip45}46else47{ // If the number of points is not 68, we do not know which48// points correspond to which facial features. So, we draw49// one dot per landamrk.50for(int i = 0; i < landmarks.size(); i++)51{52circle(im,landmarks[i],3, COLOR, FILLED);53}54}5556}5758#endif // _renderFace_H_5960