Loading Model for FisherFaceRecognizer

asked 2018-01-05 06:04:33 -0500

sanJo gravatar image

Hi there,

I'm trying to load model files for a FisherFaceRecognizer. The initial problem is that the program was written for an older OpenCV version and it seems some interfaces were changed.

Info about my project:

  • programming language: Python 3.5
  • OpenCV Version: 3.3.0

These are the two lines were I had a problem with:

      model = cv2.face.createFisherFaceRecognizer()

In the OpenCV documentation I found out that there is a new way to call the create functions and it seems to work. But I could not find the right call for the load function. I have tried to use the read function of the recognizer, but that results in an error.

        model = cv2.face.FisherFaceRecognizer_create()

Does somebody can help me with loading the model files? Thank you :)

edit retag flag offensive close merge delete


yes, unfortunately, those interfaces are in perpetual motion, and 3.4 will also differ from 3.3.0.

can you add the 1st few lines of your xml to the question ? (and maybe find out the version, from which it was saved ?)

berak gravatar imageberak ( 2018-01-05 06:25:40 -0500 )edit

Thanks for your help. The code can be found on the following repo( click) . The model files can be found in the fish_models folder. I'm not quite sure about the OpenCV version, but in the corresponding blog post here it is mentioned that OpenCV 3 was used. I'm not sure if this helps since you mentioned that these interfaces can be changed from version to version. Thanks again

sanJo gravatar imagesanJo ( 2018-01-05 06:37:10 -0500 )edit

"but that results in an error." -- which is, exactly ?

berak gravatar imageberak ( 2018-01-05 07:07:43 -0500 )edit

"File can't be opened for reading! in function read"

sanJo gravatar imagesanJo ( 2018-01-05 07:13:02 -0500 )edit

Here is link:face recognition

supra56 gravatar imagesupra56 ( 2018-01-05 07:26:44 -0500 )edit

I used python 3.5 and OpenCV 3.4.0 for raspberry pi 3. No issue problem.

supra56 gravatar imagesupra56 ( 2018-01-05 07:27:56 -0500 )edit

please take another look at the xml files. do they look like this ? (saved from 3.3.0):

<?xml version="1.0"?>

you might (or not) have to insert a <my_object> node manually.

berak gravatar imageberak ( 2018-01-05 07:32:57 -0500 )edit

I looked into the xml files. They all seem to start like this:

<?xml version="1.0"?>
<mean type_id="opencv-matrix">

I will try to add the <my_object> node then and see if this works.

sanJo gravatar imagesanJo ( 2018-01-05 07:44:40 -0500 )edit

@supra56, the file format as well as the commands to read/write it changed a lot, so folks have problems reading models saved from an older version. it's a known issue.

berak gravatar imageberak ( 2018-01-05 07:56:53 -0500 )edit

I edited the xml files like this:

<?xml version="1.0"?>
<mean type_id="opencv-matrix">

At the beginning and like this at the end :


But unfortunately I'm still getting the same error as before

sanJo gravatar imagesanJo ( 2018-01-05 08:09:34 -0500 )edit