在ubuntu下配置好dlib,运行人脸检测例子时,遇到错误

错误如下:
Traceback (most recent call last):
File "fr.py", line 10, in <module>
win = dlib.image_window()
AttributeError: 'module' object has no attribute 'image_window'

代码如下:
import sys

import dlib
from skimage import io

detector = dlib.get_frontal_face_detector()
win = dlib.image_window()

for f in sys.argv[1:]:

print("Processing file: {}".format(f))  
img = io.imread(f)  
# The 1 in the second argument indicates that we should upsample the image  
# 1 time.  This will make everything bigger and allow us to detect more  
# faces.  
dets = detector(img, 1)  
print("Number of faces detected: {}".format(len(dets)))  
for i, d in enumerate(dets):  
    print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(  
        i, d.left(), d.top(), d.right(), d.bottom()))  

win.clear_overlay()  
win.set_image(img)  
win.add_overlay(dets)  
dlib.hit_enter_to_continue()  

if (len(sys.argv[1:]) > 0):

img = io.imread(sys.argv[1])  
dets, scores, idx = detector.run(img, 1, -1)  
for i, d in enumerate(dets):  
    print("Detection {}, score: {}, face_type:{}".format(  
        d, scores[i], idx[i]))  
阅读 9.8k
3 个回答

请描述你的安装环境

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题