Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV Error: Unspecified error (The node is neither a map nor an empty collection) #25

Closed
punnu97 opened this issue Jan 15, 2018 · 6 comments
Labels
version_conflict Conflict due to change in library structure of new OpenCV version

Comments

@punnu97
Copy link

punnu97 commented Jan 15, 2018

OpenCV Error: Unspecified error (The node is neither a map nor an empty collection) in cvGetFileNodeByName, file C:\projects\opencv-python\opencv\modules\core\src\persistence.cpp, line 891
Traceback (most recent call last):
File "main.py", line 137, in
recognizer.read("model.yaml")
cv2.error: C:\projects\opencv-python\opencv\modules\core\src\persistence.cpp:891: error: (-2) The node is neither a map nor an empty collection in function cvGetFileNodeByName

Earlier there was ' recognizer.load("model.yaml") ' in the original code but there is no attribute 'load' attribute in new version of current opencv which has been replaced by 'read'.

@prsntmaurya
Copy link
Member

Hi Purnima,
Can you specify the OpenCV version you are using now?

@punnu97
Copy link
Author

punnu97 commented Jan 16, 2018

Hello,
Yes, it is OpenCV version 3.4.0 and Python version 3.6.4

@prsntmaurya
Copy link
Member

Hi Purnima,
Please run the following command on your python console and share the results with me.

  1. help(cv2.face.createLBPHFaceRecognizer().read)
  2. help(cv2.face.createLBPHFaceRecognizer().load)

@prsntmaurya
Copy link
Member

prsntmaurya commented Jan 16, 2018

Hi Purnima,
I got the fix for this issue. The issue is due to model.yaml file, you have to create new yaml file using the script "create_face_model.py". Please follow the steps below before running "create_face_model.py":

  1. Change line no 12: recognizer = cv2.face.createLBPHFaceRecognizer() to
    recognizer = cv2.face.LBPHFaceRecognizer_create()
  2. Change line no. 62: recognizer.save("cont.yaml") to
    recognizer.save("model.yaml")

After this run "create_face_model.py" using command: python3 create_face_model.py -i data/
please note that data/ is the directory where you have put training images. You can replace the images in that directory with new dataset following the name convention mentioned in Readme file.

After that, you can run main.py.

@punnu97
Copy link
Author

punnu97 commented Jan 16, 2018

Hi Prashant,

Thanks a lot for your help! My issue is resolved now.

@prsntmaurya
Copy link
Member

I am closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version_conflict Conflict due to change in library structure of new OpenCV version
Projects
None yet
Development

No branches or pull requests

2 participants