Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How would I do Face Alignment on JPEG face images in OpenCv while using Java?

I want to align several faces I have at my disposal here using openCv. 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 openCv
    //This is where I am stuck on doing face alignment. I want to do Affine alignment on face images as  follows
    //I want to be able to use e.g. an opencv Affine alignement function assuming that function is AffineAlignment()
    //I want to achieve the following assuming there is such a function for affine alignment in OpenCv with Java
    AffineAlignment imgAlign = new AffineAlignment();
    //but I do not seem to 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 outPutFile = new File("D:\\face_aligned.jpg");
    ImageIO.write(imgAligned, "JPEG", outPutFile );

}

}

Please I need your help on how to implement this in Java. Someone please show me how to do this?