可以使用dlib库来检测图片中的人脸,并使用其中的函数来选择最大的人脸。接着,可以使用dlib中的预先训练的人脸关键点检测器来检测眼部区域。代码示例如下:
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include <dlib/opencv.h>
#include <opencv2/highgui/highgui.hpp>