Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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???
// 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;
}
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???
Code:
#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;
}
i have read the tutorial and by using this i have capture,detect and save the image in current folder as well but i cant get it how to go for recognition process thats why i am asking....
i have read the tutorial and by using this i have capture,detect and save the image in current folder as well but i cant get it how to go for recognition process thats why i am asking....
So what ARE you getting??? We can't guess as to what you've done/tried and where you're stuck, can we? Just saying "cant get it how" tells us nothing.
// Verify whether the reconstructed face locameraNumberoks like the preprocessed face, otherwise it is probably an unknown person.
double similarity = getSimilarity(image1,image2);
string outputStr;
if (similarity < UNKNOWN_PERSON_THRESHOLD)
{
outputStr = toString(identity);
printf("\nboth image are same\n");
}
else
{
// Since the confidence is low, assume it is an unknown person.
outputStr = "\nUnknown image\n";
}
cout << "\nIdentity: " << outputStr << "\nSimilarity: " << similarity << endl;
// Verify whether the reconstructed face locameraNumberoks like the preprocessed face, otherwise it is probably an unknown person.
double similarity = getSimilarity(image1,image2);
string outputStr;
if (similarity < UNKNOWN_PERSON_THRESHOLD)
{
outputStr = toString(identity);
printf("\nboth image are same\n");
}
else
{
// Since the confidence is low, assume it is an unknown person.
outputStr = "\nUnknown image\n";
}
cout << "\nIdentity: " << outputStr << "\nSimilarity: " << similarity << endl;
// Verify whether the reconstructed face locameraNumberoks like the preprocessed face, otherwise it is probably an unknown person.
double similarity = getSimilarity(image1,image2);
string outputStr;
if (similarity < UNKNOWN_PERSON_THRESHOLD)
{
outputStr = toString(identity);
printf("\nboth image are same\n");
}
else
{
// Since the confidence is low, assume it is an unknown person.
outputStr = "\nUnknown image\n";
}
cout << "\nIdentity: " << outputStr << "\nSimilarity: " << similarity << endl;
AGAIN, as you have been asked MANY TIMES: USE CODE TAGS WHEN POSTING CODE
And AGAIN, just posting a snippet of code, when you've posted the ENTIRE PROGRAM previously (again, WITHOUT CODE TAGS), STILL tells us nothing. Unless you tell us what error(s)/message(s) you're getting, there is no point in posting this. And AGAIN, what part of the tutorial (that has WORKING CODE in it, with full, detailed explanations), are you not understanding????
Re-stating what you WANT is pointless...unless you provide details/information, there is absolutely NOTHING we can tell you.
hello,i am not getting any error for above code in my first comment i want to ask you how to proceed for compare these image that i have stored in array..do have any idea about how to go for "IMAGE RECOGNITION"??
hello,i am not getting any error for above code in my first comment i want to ask you how to proceed for compare these image that i have stored in array..do have any idea about how to go for "IMAGE RECOGNITION"??
You proceed by READING THE DOCUMENTATION AND TUTORIALS. We can help you with specific questions, but come on....you have to show SOME effort of your own. The tutorial you were spoon-fed (which you SAID you read/followed), has examples and code...how much more do you need to get started???? You've now been working with this for MONTHS....isn't it about time you were able to do SOMETHING with it?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.