t2botond
t2botond

Reputation: 31

Why dlib facial landmark detector throws RuntimeError?

I am quite new at python programming. I am trying to run the sample code for dlib facial landmark detector. Unfortunately I got the following error:

Traceback (most recent call last):
  File "facial_landmarks.py", line 109, in <module>
    predictor = dlib.shape_predictor(predictor_path)
RuntimeError: Error deserializing object of type long
   while deserializing a dlib::matrix

Does anyone have an idea how to solve it?

Upvotes: 2

Views: 2913

Answers (2)

stekhn
stekhn

Reputation: 2087

The shape predictor for dlib is missing:

  1. Download and extract the model for shape predicting (about 60 MB):

    wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
    bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2
    
  2. The pass the the predictor file path as first argument to your Python script:

    python facial_landmarks.py shape_predictor_68_face_landmarks.dat faces/*.jpg
    

A great walkthrough, on how to use dlib for facial landmark detection can be found here: http://www.learnopencv.com/facial-landmark-detection/

Upvotes: 2

QA Collective
QA Collective

Reputation: 2419

This message will be caused by one of the following:

  • The file pointed to by predictor_path is corrupt or missing
  • You've forgotten to unzip the file pointed to by predictor_path
  • Some other issue with the underlying file system not delivering the data correctly to dlib.shape_predictor (e.g. disk corruption, file permissions, symbolic link problem)

Take a more detailed look at the dlib example itself: http://dlib.net/face_landmark_detection.py.html

Upvotes: 1

Related Questions