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???