关键思想是《Image Deformation Using Moving Least Squares》这篇论文中提到的方法。
实现:
1>实现人脸关键点定位
2>实现论文中像素点的坐标变换
坐标变换源码:
void face_lift(Mat &src,const vector<Point2f>& landmarks,int change,const Rect &face)
{
vector<Point2f> control_p = {landmarks[0],
landmarks[5], Point2f(face.x,face.y+face.height),
Point2f(face.x+face.width,face.y+face.height),
landmarks[11],
landmarks[16],
landmarks[33],
landmarks[62]
};
vector<Point2f> control_q = { landmarks[0],
landmarks[5], Point2f(landmarks[5].x + change,landmarks[5].y), Point2f(face.x,face.y + face.height),
Point2f(face.x + face.width,face.y + face.height),