dlib 的 frontal_face_detector 检测器来检测人脸的代码示例

淡淡的烟草味﹌ 2023-10-08 20:14 56阅读 0赞

非常好的问题。下面是使用 dlib 的 frontal_face_detector 检测器来检测人脸的代码示例:

  1. import dlib
  2. # 使用 dlib 的预训练的人脸检测器模型
  3. detector = dlib.get_frontal_face_detector()
  4. # 加载图像
  5. image = dlib.load_rgb_image(image_file)
  6. # 检测人脸
  7. faces = detector(image)
  8. # 打印检测到的人脸数量
  9. print(f'Number of faces detected: {
  10. len(faces)}')
  11. # 遍历检测到的人脸
  12. for

发表评论

表情:
评论列表 (有 0 条评论,56人围观)

还没有评论,来说两句吧...

相关阅读