I'm using OpenImaj to detect faces in an image.
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();
}
}
}
To display an image we can use DisplayUtilities class: DisplayUtilities.display(image); However the found face is in type DetectedFace.
Do you know how to display the face which is in the DetectedFace type?
Thank you.
You should be able to get an image with getFacePatch().
The documentation is here http://openimaj.org/apidocs/index.html