I want to align several faces I have at my disposal here using openImaj. I want to read a jpg face photo, align it and finally save it as in jpg after alignment. Here is where I am stuck. See below
public class FaceImageAlignment {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
BufferedImage img = null;
img = ImageIO.read(new File("D:/face_test.jpg"));
//How to align face image using openImaj
//This is where I am stuck on doing face alignment. I tried doing the following
AffineAligner imgAlign = new AffineAligner();
//but I could not figure out how to do face alignment with it
BufferedImage imgAligned = new BufferedImage(//I will need to put aligned Image here as a BufferedImage);
File f = new File("D:\\face_aligned.jpg");
ImageIO.write(imgAligned, "JPEG", f);
}
}
What Code do I need to have there to face align face_test.jpg to face_aligned.jpg ?
Aligners work in combination with face detectors, so you need to use a detector to find the face(s) and then pass that to the aligner. Different aligners are tied to different detector implementations as they require different information to perform the alignment; for example the affine aligner needs facial key points found by the FKEFaceDetector. Basic code looks something like this: