Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

there's the FaceRecognizer api in c++, and it's even already wrapped into java(sorry, can't find the docs now) but a small problem will stop you from using it in java as of now - the code's all there, but the creation functions for any of the FaceRecognizer classes did not make it there.

so, actually nice, if you're good at c++ / jni

but the general usage pattern would be like this:

  • use the face-detection to locate the face, crop img to that region.

  • take your train-images, grayscale, resize(to say 90x90) & flatten them to a row, then assemble a N(numImages) x M(numpixels_per_image) (float) Mat from that. you also need a N x 1 Mat with the person ids ( one per picture in the trainmat ), the labels

  • now you can call reco.train(trainmat,labels) on that, and later save the trained state to a xml/yml file, that you can reload later instead of repeating the training over and over.

  • after that, for each prediction, process the image in the same way ( grayscale, resize, flatten ), and call reco.predict(), which will return to you the label/person_id of the best match, and the distance between the test img and the match.

and please, look around on this site for more info, bytefish(who wrote that stuff) put a lot of work into explaining it.