mmod_human_face_detector.dat是训练好的模型,可以从这里下载:
http://dlib.net/files/mmod_human_face_detector.dat.bz2
输入参数:
1. 模型dat文件
2.要检测的人脸图片
import sys
import dlib
if len(sys.argv) < 3:
print(
"Call this program like this:\n"
" ./cnn_face_detector.py mmod_human_face_detector.dat ../examples/faces/*.jpg\n"
"You can get the mmod_human_face_detector.dat file from:\n"
" http://dlib.net/files/mmod_human_face_detector.dat.bz2")
exit()
cnn_face_detector = dlib.cnn_face_detection_model_v1(sys.argv[1])
win = dlib.image_window()
for f in sys.argv[2:]:
print("Processing file: {}".format(f))
img = dlib.load_rgb_image(f)
# The 1 in the second argument indicates that we should upsample the image
# 1 time.