One of the fundamental requirements for successful face recognition is to reduce the environmental noise from the pictures.
Scaling and aligning pictures before it is send for training and recognition using any of the Open CV’s recognition classes will
improve the overall accuracy .
I found a very nice example online that is written in C++ for aligning the faces
The basic theory is that using flandmark the position of the eyes is calculated . Next the angle of rotation has to be calculated from the desired final alignment .
This is done by using linear regression , then the image is rotated and saved.
I wanted to try this in android and found that Java CV has made the Java bindings for Flandmark (for Java CV and Open CV own’s Java bindings check here). It was just the matter of
converting the c++ code to java and trying it out in android. The result is pretty decent , some tweaking of size and parameters could be required.
You can download the code here.
To build the code you will have to download open CV for android from here.