简体   繁体   中英

How to get the coordinates of bounding box for dets in dlib?

I am trying to get the coordinates of dets in order to write name above the detected face using dlib library.

import dlib

detector = dlib.get_frontal_face_detector()

dets = detector(img, 1)

You can refer to the below source code

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)

use imutils.face_utils rect_to_bb to declare the coordinates

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM