1

ここで 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 に揃えるには、どのコードが必要ですか?

4

1 に答える 1

2

アライナーは顔検出器と組み合わせて機能するため、検出器を使用して顔を検出し、それをアライナーに渡す必要があります。異なるアライナーは、アライメントを実行するために異なる情報を必要とするため、異なる検出器の実装に関連付けられています。たとえば、アフィン アライナーには、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"));
于 2015-06-27T07:50:16.140 に答える