我正在使用OpenImaj来检测图像中的面孔。
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import org.openimaj.image.FImage;
import org.openimaj.image.ImageUtilities;
import org.openimaj.image.MBFImage;
import org.openimaj.image.colour.Transforms;
import org.openimaj.image.processing.face.detection.DetectedFace;
import org.openimaj.image.processing.face.detection.FaceDetector;
import org.openimaj.image.processing.face.detection.HaarCascadeDetector;
public class FaceDetection {
public static void main(String[] args) {
MBFImage image;
try {
image = ImageUtilities.readMBF(new FileInputStream("image.jpg"));
FaceDetector<DetectedFace,FImage> fd = new HaarCascadeDetector(80);
List<DetectedFace> faces = fd. detectFaces (Transforms.calculateIntensity(image));
System.out.println(faces.size());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}要显示图像,我们可以使用DisplayUtilities类:DisplayUtilities.display(图像);但是,找到的脸是DetectedFace类型的。
你知道如何显示DetectedFace类型的脸吗?
谢谢。
发布于 2016-03-09 19:18:48
您应该能够使用getFacePatch()获得一个图像。
文档在这里,http://openimaj.org/apidocs/index.html
发布于 2017-08-31 08:26:02
除先前的答复外:
getFacePatch()中,您可以看到FImage的面孔:
final FImage faceFImage = face.getFacePatch();BufferedImage:
最终ImageUtilities.createBufferedImage(faceFImage);BufferedImage bufferedFaceImage =https://stackoverflow.com/questions/35899362
复制相似问题