1 | initial version |
the haarcascades are used for face detection, the eigen/fisher/lbp methods for face recognition
but a typical program will need both, a haar-detection first, to restrict the processing to the face area, and a face-recognizer after that.
let's think for now, that you got pre-cropped images of the persons (say, 90x90).
you create a facerecogizer:
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
then it needs to get trained. for every person you need some images(say 10), load them (grayscale), and put them into a vector<mat>. also you need to track which person it was, so it needs another vector<int> with person-ids, one for each image. now we can train it:
model->train(images, labels);
after that is done, you can test if it regognizes persons, you give it a grayscale image ( same size ) and call:
int predictedLabel = model->predict(testSample);
you'll get back the id of the person it was most similar to.
2 | No.2 Revision |
the haarcascades are used for face detection, the eigen/fisher/lbp methods for face recognition
but a typical program will need both, a haar-detection first, to restrict the processing to the face area, and a face-recognizer after that.
let's think for now, that you got pre-cropped images of the persons (say, 90x90).
you create a facerecogizer:
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
then it needs to get trained. for every person you need some images(say 10), load them (grayscale), and put them into a vector<mat>. also you need to track which person it was, so it needs another vector<int> with person-ids, one for each image. now we can train it:
model->train(images, labels);
after that is done, you can test if it regognizes persons, you give it a grayscale image ( same size ) and call:
int predictedLabel = model->predict(testSample);
you'll get back the id of the person it was most similar to.
again, look here for the recognition example, and here for the detection