Ask Your Question
0

Help with createFisherFaceRecognizer();

asked 2014-09-02 14:57:27 -0600

Nicollaas94 gravatar image

updated 2014-09-02 15:00:49 -0600

Hi guys!

i'm newb on OpenCV, and i'm trying to execute the facerec_video.cpp from the sample sources...

my only change in the code is that i include the extensions needed in the source.

but i am having a problem when i try this part

// Get the height from the first image. We'll need this
// later in code to reshape the images to their original
// size AND we need to reshape incoming faces to this size:
int im_width = images[0].cols;
int im_height = images[0].rows;
// Create a FaceRecognizer and train it on the given images:
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
model->train(images, labels);
// That's it for learning the Face Recognition model. You now
// need to create the classifier for the task of Face Detection.
// We are going to use the haar cascade you have specified in the
// command line arguments:
//

more exactly on modes->rain(images,labels);

All my images test are in 325,325 pixels( 105625 pixels), i am using 4 pictures to each person, and am using 3 persons ... someone can help-me to fix please?

thx

this is the message Error

edit retag flag offensive close merge delete

Comments

1

all images must have same size and same format(grayscale, 8bit)

berak gravatar imageberak ( 2014-09-02 15:08:52 -0600 )edit

thx ... but didn't work :( img

Nicollaas94 gravatar imageNicollaas94 ( 2014-09-02 19:44:52 -0600 )edit
1

oh, sorry, did not read the error properly, it says: expected 105625 pixels, but was 0 pixels - so one of your train images was invalid / empty.

please check your csv, and the folder it refers to (are there any non images in it ?)

throw in a check for img.empty(), where you load them

berak gravatar imageberak ( 2014-09-03 00:44:32 -0600 )edit

i looked better and found a corrupted image. my fault kkkk. thanks for the help !!

Nicollaas94 gravatar imageNicollaas94 ( 2014-09-03 20:22:28 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-09-02 23:02:25 -0600

Haris gravatar image

Based on documentation you gave to pass gray scale image for train as well as predict.

But in the above screen shot it seems GRAY to BGR conversion for training images.

So just change the line

cvtColor(img,images[i],COLOR_GRAY2BGR);

to

cvtColor(img,images[i],CV_BGR2GRAY);

or load gray scale image by default like

 Mat img=imread("image.jpg", CV_LOAD_IMAGE_GRAYSCALE);

and don't forget to use gray scale image while predict.

edit flag offensive delete link more

Comments

thx ... now this 2 between this 2 colors make sense hahaha but i saw that theses images already are in gray scale ... my problem was that 1 of my images was corrupt o0

Nicollaas94 gravatar imageNicollaas94 ( 2014-09-03 20:17:05 -0600 )edit

Question Tools

Stats

Asked: 2014-09-02 14:57:27 -0600

Seen: 328 times

Last updated: Sep 02 '14