new InfoDialog(null, "<html>Not enough training images availble for EigenfaceRecognition.<br>Please classify the first faces manually!</html>");
return new HashMap<String, Integer>();
}
}
FaceDatabase db = MainController.getInstance().getFaceDB();
String[] names = db.getExistingAnnotations();
BufferedImage unknownFaceImage = region.toThumbnail(Constants.FACE_THUMBNAIL_SIZE);
byte[] unknownFace = Utilities.bufferedImageToIntensityArray(unknownFaceImage);
double[] unknownFaceWeight = this.getWeightForImage(unknownFace);
// Mirrored region may increase recognition performance
double[] unknownMirroredFaceWeight = null;
if (this.mirrorFaces){
byte[] mirroredFace = new byte[unknownFace.length];
for (int i = 0; i < Constants.FACE_THUMBNAIL_SIZE.height; i++){
for (int j = 0; j < Constants.FACE_THUMBNAIL_SIZE.width; j++){
int elem = i * Constants.FACE_THUMBNAIL_SIZE.width + j;
mirroredFace[elem] = unknownFace[(i+1) * Constants.FACE_THUMBNAIL_SIZE.width - j - 1];
}
}
unknownMirroredFaceWeight = this.getWeightForImage(mirroredFace);
}
HashMap<String, Integer> result = new HashMap<String, Integer>( names.length);
ArrayList<SortableContainer<Region>> bestHits = new ArrayList<SortableContainer<Region>>();
for (String name : names) {
Region image = null;
Region[] regionsForName = db.getRegionsForFace(name);
if (regionsForName != null) {
double minDist = Double.MAX_VALUE;
for (int i = 0; i < regionsForName.length; i++) {