写一个测试脚本:
import cv2import sysimport dlib
detector = dlib.get_frontal_face_detector() # init detectorimg_file...) # right x value
print(x1, x2, y1, y2) # add detect box in image
cv2.rectangle(img,(int(...x1),int(y1)),(int(x2),int(y2)),(0,255,0),3)
cv2.imshow('new.jpg', img)
cv2.waitKey(0)
python test.py...detector = dlib.get_frontal_face_detector()
win = dlib.image_window()for f in sys.argv[1:]:
print...:{}".format(
d, scores[i], idx[i]))
重点说明第二个参数,设置为1表示一次上采样,对原图进行上采样放大,能够使得检测器检测出更多的人脸。