簡體   English   中英

使用openImaj API庫進行人臉對齊

[英]Face alignment using openImaj API libraries

我想使用openImaj對齊我可以使用的幾個面孔。 我想閱讀一張jpg臉部照片,將其對齊,最后在對齊后將其另存為jpg。 這就是我卡住的地方。 見下文

     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);

    }
}

我需要什么代碼才能將face_test.jpg與face_aligned.jpg對齊?

對准器與面部檢測器結合使用,因此您需要使用檢測器來找到面部,然后將其傳遞給對准器。 不同的對准器與不同的檢測器實現方式綁定在一起,因為它們需要不同的信息來執行對准。 例如,仿射對齊器需要FKEFaceDetector找到的面部關鍵點。 基本代碼如下所示:

FImage img = ImageUtilities.readF(new File("..."));
FKEFaceDetector detector = new FKEFaceDetector();
FaceAligner<KEDetectedFace> aligner = new AffineAligner();
KEDetectedFace face = detector.detectFaces(img).get(0);
FImage alignedFace = aligner.align(face);
ImageUtilities.write(alignedFace, new File("aligned.jpg"));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM