[英]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.