【问题标题】:How to get the coordinates of bounding box for dets in dlib?如何获取dlib中dets的边界框坐标?
【发布时间】:2020-03-03 18:15:54
【问题描述】:

我正在尝试获取 dets 的坐标,以便使用 dlib 库在检测到的面部上方写入名称。

import dlib

detector = dlib.get_frontal_face_detector()

dets = detector(img, 1)

【问题讨论】:

    标签: python python-3.x dlib


    【解决方案1】:

    你可以参考下面的源码

    detector = dlib.get_frontal_face_detector()
    dets = detector(img, 1)
    
    for (i, det) in enumerate(dets):
        #you can draw name based on faceRect
        #to get top left point 
        top_left_point= det.tl_corner
        print (top_left_point.x, top_left_point.y)
    

    【讨论】:

    • 我得到了这个错误作为回报:faceRect = det.rect AttributeError: 'dlib.rectangle' object has no attribute 'rect'
    • 所以 det 已经是一个矩形了。编辑了我的答案。你可以在这里参考更多dlib.net/python/index.html#dlib.rectangle
    • 感谢您的帮助,我发现使用 imutils 面部实用程序对我有用
    【解决方案2】:

    使用 imutils.face_utils rect_to_bb 声明坐标

    for det in dets:
        (x, y, w, h) = rect_to_bb(det)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-18
      • 2021-04-04
      • 2021-01-05
      • 1970-01-01
      • 2017-11-16
      • 1970-01-01
      • 2021-07-18
      • 2019-09-18
      相关资源
      最近更新 更多