版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_24815615/article/details/80766956
参考链接:
https://blog.csdn.net/xingchenbingbuyu/article/details/51472330
测试代码
#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
using namespace std;
using namespace cv;
using namespace cv::face;
int main()
{
// Create a FaceRecognizer:
Ptr<FaceRecognizer> model = EigenFaceRecognizer::create();
model->read("D:\\OpenCV\\MyFacePCAModel.xml");
cout << "read model ok!" << endl;
// Do your initialization here (create the cv::FaceRecognizer model) ...
// ...
// Read in a sample image:
Mat img = imread("D:\\datasets\\att_faces\\s2\\1.pgm", CV_LOAD_IMAGE_GRAYSCALE);
// And get a prediction from the cv::FaceRecognizer:
int predicted = model->predict(img);
cout << "predicted result is : "<< predicted << endl;
waitKey(0);
system("pause");
return 0;
}