FaceRecognizer doubts

asked 2016-10-25 14:20:06 -0500

marcosbontempo gravatar image

updated 2016-10-25 14:21:26 -0500


I'm developing an application that uses the OpenCV FaceRecognizer Java class to verify if a face is in a database of images. It works if I run my code only one time, but I want to update the database and remake the training multiple times. I'm having some doubts about doing this:

  • If I need to repeat the training, do I have to create the object again like the code below? How can I reset the FaceReconizer object?

        faceRecognizer = new FaceRecognizer();
        faceRecognizer = createEigenFaceRecognizer();
        faceRecognizer.train(images, labels);
  • I have a database with images of 5 different people. How do I have to pass these images to faceRecognizer.train? What do I have to insert in the labels variable?

  • I'm having doubts about how to read the result of faceRecognizer.predict. In my case I only want to check if a face is in the database. How can I read the returned variables (label and confidence) to determine it?

Sorry for the newbie questions but I'm really stuck and I cannot find any documentation about it :(

Any tip will be very helpful,


edit retag flag offensive close merge delete


which opencv version is it ? (are you even able to create an instance ?)

berak gravatar imageberak ( 2016-10-25 23:56:11 -0500 )edit

I'm using version 2.4.9 and yes, I can create the instance.

marcosbontempo gravatar imagemarcosbontempo ( 2016-10-26 07:47:56 -0500 )edit

there is also a (unsupported, 3rdparty) wrapper called javaCV, are you using that ? (we probably can't help much with api details, then).

berak gravatar imageberak ( 2016-10-26 07:59:29 -0500 )edit