dlib: Boost.Python.ArgumentError in shape_landmark_detection.py
Hello,
I have a problem using shape_predictor for face landmarks detection using python 2.7 in anaconda.
I compiled dlib and verified boost lib path according to these issues:
I also tried to rebuild Boost from source, but still having the same error:
Traceback (most recent call last):
File "face_landmark_detection.py", line 66, in <module>
predictor = dlib.shape_predictor(predictor_path)
Boost.Python.ArgumentError: Python argument types in
shape_predictor.__init__(shape_predictor, str)
did not match C++ signature:
__init__(boost::python::api::object, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
__init__(_object*)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (6 by maintainers)
Yeah, boost.python has an awful build process. I’ll switch to pybind11 instead of boost.python at some point in the future (https://github.com/davisking/dlib/issues/293). That should make building the python extensions pretty trivial.
Sorry to necro this, but maybe my note will help someone.
I had similar error message on Debian with self-compiled Python, Boost, and dlib:
Based on above discussion I figured I also had compilation issue between different versions of Boost and Python. And I did have those previously due to apt-get giving different libboost version.
After fighting for hours I realized that that error is telling me that the
shape_predictormethod expects astring, and I’m feeding it apathlib.Pathobject. Code for clarity:Lesson: Learn to read Boost.Python errors.
@davisking Yes, I commented it for someone with the same problem.
I tried all the solutions written above, but none worked on my machine. The problem was that python from anaconda kept on find the boost version installed in anaconda. After run the code blow and build dlib it worked.
I found a fix for my case (Ubuntu 16.04, python 2.7 with conda).
First, I needed to uninstall Ubuntu’s Boost:
sudo apt-get remove libboost-devas well as conda’s boost:
conda uninstall boost.After this, dlib’s
setup.pyidentified the Boost that I had manually compiled and installed:Boost version: 1.62.0. However, there were some lingering dependencies that remained in anaconda, as indicated by:USING BOOST_LIBS: /home/jrking/anaconda/lib/_libboost_python-mt.soI manually removed (after a backup)
~/anaconda/lib/libboost_python-mt.aand~/home/jrking/anaconda/lib/libboost_python-mt.soand it now seems to works.
I hope this helps others.