sanJo
sanJo

Reputation: 21

opencv fisherface recognizer

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:

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

      model = cv2.face.createFisherFaceRecognizer()
      model.load('foo_model.xml')

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()
        model.read('foo_model.xml')

The error message I've got when I try to use read():

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

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

Upvotes: 2

Views: 691

Answers (2)

GAD
GAD

Reputation: 11

The problem is with the xml file format. if you open the XML file you will not find "my_object" tag. I will not go to the details of this but, every time I face this problem, it works when I modify the xml file as follows.

     <?xml version="1.0"?>
         <opencv_storage>
             <my_object> //add this 
                  .........
                  .........
                  .........
             </my_object> //and this
        </opencv_storage>

Upvotes: 1

sanJo
sanJo

Reputation: 21

The problem seems to be that the xml format in which the models are saved had been changed. This seems to be a known issue. I am using OpenCV 3.3.0 and want to load a model from an older OpenCV version which results in the mentioned error from the read-function. In the OpenCV Q&A forum a solution was suggested to me, but in my case it did not work. Nonetheless I will drop the link to my post at OpenCV Q&A here. Maybe someone else with the same problem can benefit from it.

Upvotes: 0

Related Questions