Modules.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:apparent-age-gender-classification 作者: danielyou0230 项目源码 文件源码
def facial_landmark_detection(image, detector, predictor, file):
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    img_size = gray.shape
    landmark_faces = detector(gray, 1)

    faces = list()
    area = 0
    face_idx = 0
    bItr = False
    for (idx, landmark_faces) in enumerate(landmark_faces):
        shape = predictor(gray, landmark_faces)
        shape = shape_to_np(shape)
        (x, y, w, h) = rect_to_bb(landmark_faces, img_size, file)

        if (w * h) > area:
            area = w * h
            faces = [x, y, w, h]
            bItr = True
        #cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
        #cv2.putText(image, "Face #{}".format(idx + 1), (x - 10, y - 10), \
        #           cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
        #for (x, y) in shape:
        #   cv2.circle(image, (x, y), 1, (0, 0, 255), -1)

    return bItr, faces
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号