我正在学习在线课程,但是遇到了问题。 错误消息:
self.ldmark_detector = dlib.shape_predictor('./dlib_model/shape_predictor_68_face_landmarks.dat')
RuntimeError: Unable to open ./dlib_model/shape_predictor_68_face_landmarks.dat
代码:
class Face_detector(QtCore.QThread):
def __init__(self, textBrowser):
super(Face_detector, self).__init__()
self.face_detector = dlib.get_frontal_face_detector()
self.ldmark_detector = dlib.shape_predictor('./dlib_model/shape_predictor_68_face_landmarks.dat')
self.face_info = {}
self.textBrowser = textBrowser
self.detecting = True # flag of if detect face
self.ldmarking = False # flag of if detect landmark
self.total = 0
我真的不知道发生了什么。我安装了dlib,但在我的机器中搜索了文件,既没有名为"dlib_model"
的文件夹,也没有名为"shape_predictor_68_face_landmarks.dat"
的文件,但是代码应该正确。
顺便说一句,我使用pip install dlib
安装了dlib。看来它存储在一个奇怪的位置,但是我的程序可以成功导入dlib。我目前的翻译是user/bin/python2.7
Collecting dlib
Using cached https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz
Building wheels for collected packages: dlib
Running setup.py bdist_wheel for dlib ... done
Stored in directory: /home/huiting/.cache/pip/wheels/50/b6/b5/5f46aacfd18028ff57591cfb53fcc7554362977c15e9060e67
Successfully built dlib
Installing collected packages: dlib
Successfully installed dlib-19.17.0
答案 0 :(得分:-1)
您需要下载此文件“ shape_predictor_68_face_landmarks.dat”。