Loading Model for FisherFaceRecognizer
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()
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')
Does somebody can help me with loading the model files? Thank you :)
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 ?)
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
"but that results in an error." -- which is, exactly ?
"File can't be opened for reading! in function read"
Here is link:face recognition
I used python 3.5 and OpenCV 3.4.0 for raspberry pi 3. No issue problem.
please take another look at the xml files. do they look like this ? (saved from 3.3.0):
you might (or not) have to insert a
<my_object>
node manually.I looked into the xml files. They all seem to start like this:
I will try to add the <my_object> node then and see if this works.
@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.
I edited the xml files like this:
At the beginning and like this at the end :
But unfortunately I'm still getting the same error as before