Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

FaceRecognizer stuck in the same label

I am having problems using opencv's face recognitzer algorithm. I am training my model using images of 5 different persons. In predict process I am always receiving as predicted label the same label 1. The images I am using for training are cropped and aligned(black n white) of the persons.

My code for training: (V channel from hsv colormap)

images = dbreading.trainImages; //2d Mat vector with 
labels = dbreading.trainLabels; // vector with labels

Ptr<FaceRecognizer> model =  createEigenFaceRecognizer();

model->train(images, labels);
model->save("eigenfaces.yml");

My code for predict:

// Detections tested image cropped aligned (V channel from hsv colormap) 
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
model->load("eigenfaces.yml");
cout << "The size of the detected image is width: " << detections.cols << "height: " << detections.rows << endl;

// And get a Prediction from the cv::FaceRecognizer:
int predicted_label;
predicted_label= model->predict(detections);

I am guessing that I am missing a classic mistake here. What is the usual reasons when recognizer stuck in the same label? I push_back images in vector images with their initial size. Do I have to reshape them as vectors before the training process???

FaceRecognizer stuck in returns always the same label

I am having problems using opencv's face recognitzer algorithm. I am training my model using images of 5 different persons. In predict process I am always receiving as predicted label the same label 1. The images I am using for training are cropped and aligned(black n white) of the persons.

My code for training: (V channel from hsv colormap)

images = dbreading.trainImages; //2d Mat vector with 
labels = dbreading.trainLabels; // vector with labels

Ptr<FaceRecognizer> model =  createEigenFaceRecognizer();

model->train(images, labels);
model->save("eigenfaces.yml");

My code for predict:

// Detections tested image cropped aligned (V channel from hsv colormap) 
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
model->load("eigenfaces.yml");
cout << "The size of the detected image is width: " << detections.cols << "height: " << detections.rows << endl;

// And get a Prediction from the cv::FaceRecognizer:
int predicted_label;
predicted_label= model->predict(detections);

I am guessing that I am missing a classic mistake here. What is the usual reasons when recognizer stuck in the same label? I push_back images in vector images with their initial size. Do I have to reshape them as vectors before the training process???process??? Do I have to randomize the order of the train images? Does it have some meaning for the training process??

FaceRecognizer returns always the same label

I am having problems using opencv's face recognitzer algorithm. I am training my model using images of 5 different persons. In predict process I am always receiving as predicted label the same label 1. The images I am using for training are cropped and aligned(black n white) of the persons.

My code for training: (V channel from hsv colormap)

images = dbreading.trainImages; //2d Mat vector with 
labels = dbreading.trainLabels; // vector with labels

Ptr<FaceRecognizer> model =  createEigenFaceRecognizer();

model->train(images, labels);
model->save("eigenfaces.yml");

My code for predict:

// Detections tested image cropped aligned (V channel from hsv colormap) 
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
model->load("eigenfaces.yml");
cout << "The size of the detected image is width: " << detections.cols << "height: " << detections.rows << endl;

// And get a Prediction from the cv::FaceRecognizer:
int predicted_label;
predicted_label= model->predict(detections);

I am guessing that I am missing a classic mistake here. What is the usual reasons when recognizer stuck in the same label? I push_back images in vector images with their initial size. Do I have to reshape them as vectors before the training process??? Do I have to randomize the order of the train images? Does it have some meaning for the training process??

EDIT: I ve discovered that .yml file contains zeros inside. So the train process is totally wrong.

FaceRecognizer returns always the same label

I am having problems using opencv's face recognitzer algorithm. I am training my model using images of 5 different persons. In predict process I am always receiving as predicted label the same label 1. The images I am using for training are cropped and aligned(black n white) of the persons.

My code for training: (V channel from hsv colormap)

images = dbreading.trainImages; //2d Mat vector with 
labels = dbreading.trainLabels; // vector with labels

Ptr<FaceRecognizer> model =  createEigenFaceRecognizer();

model->train(images, labels);
model->save("eigenfaces.yml");

My code for predict:

// Detections tested image cropped aligned (V channel from hsv colormap) 
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
model->load("eigenfaces.yml");
cout << "The size of the detected image is width: " << detections.cols << "height: " << detections.rows << endl;

// And get a Prediction from the cv::FaceRecognizer:
int predicted_label;
predicted_label= model->predict(detections);

I am guessing that I am missing a classic mistake here. What is the usual reasons when recognizer stuck in the same label? I push_back images in vector images with their initial size. Do I have to reshape them as vectors before the training process??? Do I have to randomize the order of the train images? Does it have some meaning for the training process??

EDIT: I ve discovered that .yml file contains zeros inside. So the train process is totally wrong.wrong. Is it necessary to normalize the values of the pixel? Is it possible that the arising problems is due to lack of normalization??

FaceRecognizer returns always the same label

I am having problems using opencv's face recognitzer algorithm. I am training my model using images of 5 different persons. In predict process I am always receiving as predicted label the same label 1. The images I am using for training are cropped and aligned(black n white) of the persons.

My code for training: (V channel from hsv colormap)

images = dbreading.trainImages; //2d Mat vector with 
labels = dbreading.trainLabels; // vector with labels

Ptr<FaceRecognizer> model =  createEigenFaceRecognizer();

model->train(images, labels);
model->save("eigenfaces.yml");

My code for predict:

// Detections tested image cropped aligned (V channel from hsv colormap) 
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
model->load("eigenfaces.yml");
cout << "The size of the detected image is width: " << detections.cols << "height: " << detections.rows << endl;

// And get a Prediction from the cv::FaceRecognizer:
int predicted_label;
predicted_label= model->predict(detections);

I am guessing that I am missing a classic mistake here. What is the usual reasons when recognizer stuck in the same label? I push_back images in vector images with their initial size. Do I have to reshape them as vectors before the training process??? Do I have to randomize the order of the train images? Does it have some meaning for the training process??

EDIT: I ve discovered that .yml file contains zeros inside. So the train process is totally wrong. Is it necessary to normalize the values of the pixel? Is it possible that the arising problems is due to lack of normalization??