ITCoders / Human-detection-and-Tracking

Human-detection-and-Tracking
Apache License 2.0
850 stars 307 forks source link

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

Closed punnu97 closed 6 years ago

punnu97 commented 6 years ago

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 commented 6 years ago

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

punnu97 commented 6 years ago

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

prsntmaurya commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Hi Prashant,

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

prsntmaurya commented 6 years ago

I am closing the issue.