image based face recognition

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???

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <stdio.h>
#include <opencv2/contrib/contrib.hpp>
#include <opencv2/imgproc/imgproc.hpp>
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;
}
Last edited on
Topic archived. No new replies allowed.