Ask Your Question
0

Trying to use face recognition, the facerecognizer

asked 2013-09-14 09:36:33 -0600

lovelf gravatar image

updated 2013-09-16 13:15:11 -0600

berak gravatar image

So I copied from http://docs.opencv.org/trunk/modules/contrib/doc/facerec/facerec_api.html

 // Let's say we want to keep 10 Eigenfaces and have a threshold value of 10.0
 int num_components = 10;
 double threshold = 10.0;
 // Then if you want to have a cv::FaceRecognizer with a confidence threshold,
 // create the concrete implementation with the appropiate parameters:
 Ptr<FaceRecognizer> model = createEigenFaceRecognizer(num_components, threshold);

 // The following line reads the threshold from the Eigenfaces model:
 double current_threshold = model->getDouble("threshold");
 // And this line sets the threshold to 0.0:
 model->set("threshold", 0.0);

 // Create a FaceRecognizer:
 Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
 // And here's how to get its name:
 String name = model->name();

 // holds images and labels
 vector<Mat> images;
 vector<int> labels;
 // images for first person
 images.push_back(imread("/var/www/html/photos/1.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/2.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/3.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/4.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/5.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/6.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/7.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/8.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/9.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/10.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/11.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/12.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/13.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/14.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/15.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/16.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/17.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/19.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/20.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/21.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/22.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/23.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/24.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/25.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/26.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/27.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/28.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/29.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
 images.push_back(imread("/var/www/html/photos/30 ...
(more)
edit retag flag offensive close merge delete

Comments

1

try to rename facerecog.c to facerecog.cpp, or use g++

and you probably need to :

 #include "opencv2/contrib/contrib.hpp"
 #include "opencv2/highgui/highgui.hpp"
berak gravatar imageberak ( 2013-09-14 12:09:53 -0600 )edit

hey, with this edit you're creating 2 "model" . wont compile.

berak gravatar imageberak ( 2013-09-14 13:54:07 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-09-15 06:10:37 -0600

updated 2013-09-15 06:12:11 -0600


FaceRecognizer::save("/var/www/html/photos/saved.txt");

What is this?

You have to call the save method on an instance of a FaceRecognizer, so in your example it would be:


model->save("/var/www/html/photos/saved.txt");

And the problems should be gone.

edit flag offensive delete link more

Comments

ok, awesome, I am still getting expecting constructor, destructor or type conversion before < and before . , etc, as on the code output of the question, thanks so much really, I would love to implement face recognizer on my website

lovelf gravatar imagelovelf ( 2013-09-22 07:43:59 -0600 )edit

Question Tools

Stats

Asked: 2013-09-14 09:36:33 -0600

Seen: 487 times

Last updated: Sep 15 '13