I am writing a Blender addon for working with 3D face scans. I want to find landmarks (the eyebrows, the corners of the eyes, the mouth line, etc.) in an image of the scanned face so I can map them to the model. The Dlib library is ideal for finding these landmarks, but I have been unable to install it in Blender's Python (so I can call it from the addon).
I had no problem installing Dlib in a standalone Python (3.6.4) version I also have installed. As a work around I am currently calling this Python from a subprocess in the addon, but this is very slow and makes the addon difficult to install on another computer.
Here is the output when I try to install Dlib with pip in Blender's Python (Blender is version 2.81 with Python 3.7.4):
C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\bin> ./python -m pip install dlib --user
Collecting dlib
Using cached dlib-19.19.0.tar.gz (3.2 MB)
Installing collected packages: dlib
Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\bin\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-x18bl7c_\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-x18bl7c_\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\David\AppData\Local\Temp\pip-record-k5d8lob9\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\David\AppData\Roaming\Python\Python37\Include\dlib'
cwd: C:\Users\David\AppData\Local\Temp\pip-install-x18bl7c_\dlib\
Complete output (66 lines):
running install
running build
running build_py
package init file 'dlib\__init__.py' not found (or not a regular file)
running build_ext
Building extension for Python 3.7.4 (default, Aug 13 2019, 14:10:15) [MSC v.1916 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\David\AppData\Local\Temp\pip-install-x18bl7c_\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\David\AppData\Local\Temp\pip-install-x18bl7c_\dlib\build\lib.win-amd64-3.7 -DPYTHON_EXECUTABLE=C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\bin\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\David\AppData\Local\Temp\pip-install-x18bl7c_\dlib\build\lib.win-amd64-3.7 -A x64'
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18362.
-- The C compiler identification is MSVC 19.16.27030.1
-- The CXX compiler identification is MSVC 19.16.27030.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: C:/Program Files/Blender Foundation/Blender 2.81/2.81/python/bin/python.exe (found version "3.7.4")
CMake Error at C:/Users/David/AppData/Local/Temp/pip-install-x18bl7c_/dlib/dlib/external/pybind11/tools/FindPythonLibsNew.cmake:158 (message):
Python libraries not found
Call Stack (most recent call first):
C:/Users/David/AppData/Local/Temp/pip-install-x18bl7c_/dlib/dlib/external/pybind11/tools/pybind11Tools.cmake:16 (find_package)
C:/Users/David/AppData/Local/Temp/pip-install-x18bl7c_/dlib/dlib/external/pybind11/CMakeLists.txt:33 (include)
-- Configuring incomplete, errors occurred!
See also "C:/Users/David/AppData/Local/Temp/pip-install-x18bl7c_/dlib/build/temp.win-amd64-3.7/Release/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\David\AppData\Local\Temp\pip-install-x18bl7c_\dlib\setup.py", line 261, in <module>
'Topic :: Software Development',
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\site-packages\setuptools\__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\site-packages\setuptools\command\install.py", line 61, in run
return orig.install.run(self)
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\David\AppData\Local\Temp\pip-install-x18bl7c_\dlib\setup.py", line 135, in run
self.build_extension(ext)
File "C:\Users\David\AppData\Local\Temp\pip-install-x18bl7c_\dlib\setup.py", line 172, in build_extension
subprocess.check_call(cmake_setup, cwd=build_folder)
File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-x18bl7c_\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-x18bl7c_\\dlib\\build\\lib.win-amd64-3.7', '-DPYTHON_EXECUTABLE=C:\\Program Files\\Blender Foundation\\Blender 2.81\\2.81\\python\\bin\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-x18bl7c_\\dlib\\build\\lib.win-amd64-3.7', '-A', 'x64']' returned non-zero exit status 1.
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\bin\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-x18bl7c_\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-x18bl7c_\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\David\AppData\Local\Temp\pip-record-k5d8lob9\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\David\AppData\Roaming\Python\Python37\Include\dlib' Check the logs for full command output.
While I would like to use Dlib in Blender, I am open to other methods of finding the facial landmarks in an image. Either way, I need another user of the addon (or the addon itself) to be able to install the required libraries without too much work.
In case it is helpful, here is a video demonstrating using Dlib in Blender.
Please let me know if I can clarify anything.
Thanks, David