OpenCV3.4.1 实现人脸识别

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_24815615/article/details/80766956

参考链接:

https://docs.opencv.org/3.4.1/dd/d65/classcv_1_1face_1_1FaceRecognizer.html#ac8680c2aa9649ad3f55e27761165c0d6

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;
}

猜你喜欢

转载自blog.csdn.net/qq_24815615/article/details/80766956