人脸的生物学特征
两个眼睛之间的宽度大致等于一个眼睛的距离
左右对称
眼睛到嘴巴之间的距离大致等于两个眼睛的宽度
鼻子到嘴唇距离,大致等于两个嘴唇的厚度
代码:
#include <opencv2/opencv.hpp>
#include <opencv2/xfeatures2d.hpp>
#include<opencv2/face.hpp>
#include<iostream>
#include<math.h>
#include <string>
#include<fstream>
using namespace cv::face;
using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;
Rect leftEye, rightEye;
void trackEye(Mat& im, Mat& tpl, Rect& rect){
if (im.empty() || tpl.empty() || rect.empty()) return;
Mat result;
int result_cols = im.cols - tpl.cols + 1;
int result_rows = im.rows - tpl.rows + 1;
//模板匹配
result.create(result_rows,result_cols, CV_32FC1);
matchTemplate(im, tpl, result, CV_TM_CCOEFF_NORMED);//计算归一化相关性,计算值越接近于1越相关
//寻找位置
double