4

I'm using a c++ version of dlib to extract positions of the facial landmarks in an image. I would like to reduce the execution time. Now it takes around 2.5 seconds to run a complied file and detect landmark on a single image.

After an analysis, I found that the main bottleneck is the deserialize function which takes a path to a shape predictor and loads this file to a shape predictor object. This function takes 1.5 seconds.

The code snippet is below.

shape_predictor sp;
deserialize("shape_predictor_68_face_landmarks.dat") >> sp; 

I wonder if there could be a way to speed up the deserialize function.

ivan.koval
  • 119
  • 2
  • 8
  • 2
    The bottleneck comes from reading off the harddrive. Once you deserialize are you caching the data, or are you deserializing in every iteration of the loop? Make sure you cache your results. If this is the case, there might be some multi-threaded option in DLIB for this. Something else you can do is get a faster harddrive or get a solid state drive. One last thing you can do is store the data from the *.dat file in either an in-memory database such as memcached, or a web service based database such as dynamodb and write your own custom logic to always pull from that database. – rossb83 Apr 12 '17 at 15:47

0 Answers0