Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C++
#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>
Posted
Updated 22-May-16 20:50pm
v3

1 solution

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.
 
Share this answer
 
Comments
Member 12453056 23-May-16 4:11am    
@KarstenK thanks for your reply...i have ask in that forum but many question related to real time video capture only..and i want on images based

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900