dlib.get_frontal_face_detector()及detector()返回值

目录

1.结论

2.验证过程

2.1代码

2.2数据:传入图片(必应搜索获取)

2.3输出结果

3.参考致谢


1.结论

detector=dlib.get_frontal_face_detector() 获得脸部位置检测器

dets = detector(gray, 0) 返回值是,即一个矩形,表示为能够唯一表示这个人脸矩形框两个点坐标:左上角(x1,y1)、右下角(x2,y2)。

2.验证过程

2.1代码

import cv2
import dlib

img = cv2.imread(r'D:\i\1.jpg') #这里我用本地图片绝对路径
detector = dlib.get_frontal_face_detector()
#cv2.cvtColor(p1,p2) 是颜色空间转换函数,p1是需要转换的图片,p2是转换成何种格式
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)#将img转换为灰度图

dets = detector(gray, 0)
for i, d in enumerate(dets):
    print(type(d))
    y1 = d.top()
    y2 = d.bottom()
    x1 = d.left()
    x2 = d.right()
    print("i=" , i , "point of left_top (", x1 , ",", y1 ,") ",
                    " point of right_bottom (", x2 , ",", y2 ,")")

2.2数据:传入图片(必应搜索获取)

dlib.get_frontal_face_detector()及detector()返回值_第1张图片

2.3输出结果

结果为图片的25张人脸

i : [ 0 , 24 ]

point of left_top为返回矩形 i 左上角顶点

point of right_bottom为返回矩形 i 右下角顶点


i= 0 point of left_top ( 205 , 349 )   point of right_bottom ( 277 , 421 )

i= 1 point of left_top ( 517 , 525 )   point of right_bottom ( 589 , 597 )

i= 2 point of left_top ( 365 , 61 )   point of right_bottom ( 437 , 133 )

i= 3 point of left_top ( 205 , 45 )   point of right_bottom ( 277 , 117 )

i= 4 point of left_top ( 677 , 365 )   point of right_bottom ( 749 , 437 )

i= 5 point of left_top ( 525 , 221 )   point of right_bottom ( 597 , 293 )

i= 6 point of left_top ( 669 , 669 )   point of right_bottom ( 741 , 741 )

i= 7 point of left_top ( 517 , 661 )   point of right_bottom ( 589 , 733 )

i= 8 point of left_top ( 213 , 661 )   point of right_bottom ( 285 , 733 )

i= 9 point of left_top ( 213 , 517 )   point of right_bottom ( 285 , 589 )

i= 10 point of left_top ( 53 , 381 )   point of right_bottom ( 125 , 453 )

i= 11 point of left_top ( 365 , 517 )   point of right_bottom ( 437 , 589 )

i= 12 point of left_top ( 677 , 525 )   point of right_bottom ( 749 , 597 )

i= 13 point of left_top ( 61 , 53 )   point of right_bottom ( 133 , 125 )

i= 14 point of left_top ( 53 , 669 )   point of right_bottom ( 125 , 741 )

i= 15 point of left_top ( 677 , 205 )   point of right_bottom ( 749 , 277 )

i= 16 point of left_top ( 53 , 517 )   point of right_bottom ( 125 , 589 )

i= 17 point of left_top ( 381 , 205 )   point of right_bottom ( 453 , 277 )

i= 18 point of left_top ( 53 , 213 )   point of right_bottom ( 125 , 285 )

i= 19 point of left_top ( 669 , 53 )   point of right_bottom ( 741 , 125 )

i= 20 point of left_top ( 525 , 365 )   point of right_bottom ( 597 , 437 )

i= 21 point of left_top ( 373 , 685 )   point of right_bottom ( 445 , 757 )

i= 22 point of left_top ( 371 , 362 )   point of right_bottom ( 458 , 448 )

i= 23 point of left_top ( 218 , 189 )   point of right_bottom ( 304 , 275 )

i= 24 point of left_top ( 517 , 61 )   point of right_bottom ( 589 , 133 )

3.参考致谢

dlib.get_frontal_face_detector()函数返回值_南阜止鸟的博客-CSDN博客_dlib.get_frontal_face_detector detector = dlib.get_frontal_face_detector()获取人脸框的用法_夏华东的博客的博客-CSDN博客_dlib.get_frontal_face_detector

 小白学习ing...

你可能感兴趣的:(计算机视觉,opencv,python)