基于图像的人脸识别 [英] Image based face recognition

查看:77
本文介绍了基于图像的人脸识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了以下代码,用于从文件夹中读取两个图像,并在其上应用fisherface训练算法,有两个人的图像,我已阅读....谁能告诉我如何进行代码如何识别人之间这两张图片???



我的尝试:



I have write the below code for reading two images from folder and apply fisherface training algorithm on them there are two person images that i have read....can anyone tell me how to proceed the code for how to recognised person between these two images???

What I have tried:

#include 
#include 
#include <iostream>
#include <stdio.h>
#include 
#include 
using namespace cv;
using namespace std;
const char *facerecAlgorithm = "FaceRecognizer.Fisherfaces";
int main()
{
string facerecAlgorithm = "FaceRecognizer.Fisherfaces";
Ptr<facerecognizer> model;

// Make sure the "contrib" module is dynamically loaded at runtime.
// Requires OpenCV v2.4.1 or later (from June 2012), otherwise the FaceRecognizer will not compile or run!
bool haveContribModule = initModule_contrib();
if (!haveContribModule) 
{
cerr << "ERROR: The 'contrib' module is needed for FaceRecognizer but has not been loaded into OpenCV!" << endl;
exit(1);
}
else
{
cout << "\ncontrib module is successfully loaded" << std::endl;	
}


model = Algorithm::create<facerecognizer>(facerecAlgorithm);

if (model.empty()) 
{
cerr << "ERROR: The FaceRecognizer [" << facerecAlgorithm;
cerr << "] is not available in your version of OpenCV. ";
cerr << "Please update to OpenCV v2.4.1 or newer." << endl;
exit(1);
}
else
{
cout << "\nFisherFaceRecognizer is successfully loaded" << std::endl;	
}

cout << "\nFisherFaceRecognizer training starting......" << std::endl;

// holds images and labels
vector<mat> images;
vector<int> labels;

// images for first person
images.push_back(imread("1.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
images.push_back(imread("3.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
images.push_back(imread("5.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);

// images for second person
images.push_back(imread("2.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(1);
images.push_back(imread("4.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(1);

// This is the common interface to train all of the available cv::FaceRecognizer
// implementations
model->train(various_images, labels);

cout << "\nFisherFaceRecognizer training finished......" << std::endl;
return 0;
}</int></mat></facerecognizer></facerecognizer></stdio.h></iostream>

推荐答案

codeproject searchbox 提供最佳结果,您可以在此处找到。看看并询问一些作者。



如果你需要帮助和一些解决方案,你最好看看OpenCV论坛
The codeproject searchbox is delivering best results, what you can find here. Check it out and ask some of the authors.

If you need mor help and some solution you better look in the OpenCV forums.


这篇关于基于图像的人脸识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆