Adriano Valente Adriano Valente - 9 days ago 6
Java Question

FaceRecognizer with openCV

I am using openCV 2.4.9 Java Library and I have several problems to implement some FaceRecognizer. I know that, in C++, the class

contrib.FaceRecognizer
is Abastract, but I don't know if it also happens to the Java Library (actually the Java Documentation is too much scarce!). Anyways, here are my tries to call the class:

FaceRecognizer rec = new FaceRecognizer();


or

FaceRecognizer rec = null;

or

FaceRecognizer rec;


And finally, I'm trying to call the
Train
and
Predict
methods this ways:

public static void main(String[] args) {
// TODO code application logic here
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
FaceRecognizer rec = null;
List<Mat> images;
images = new ArrayList<Mat>();
images.add(Highgui.imread("/home/adriano/Desktop/fotos/gabi/1.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/gabi/2.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/gabi/3.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/estevao/1.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/estevao/2.jpg"));
images.add(Highgui.imread("/home/adriano/Desktop/fotos/estevao/3.jpg"));

Mat labels = new Mat(1, 6, CvType.CV_8UC1, Scalar(0));
// How can I add some values different from 0 to this Mat?


rec.train(images, labels);


// Predicts the label
System.out.println(testando.predict(Highgui.imread("/home/adriano/Desktop/fotos/gabi/4.jpg"));


}


Any help is welcome (:

Answer

to make facerecognizer you can use

FaceRecognizer rec=createLBPHFaceRecognizer();

or

FaceRecognizer rec=createEigenFaceRecognizer();

or

FaceRecognizer rec=createFisherFaceRecognizer();
Comments