__init__.py 文件源码

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

项目:python-smart-crop 作者: epixelic 项目源码 文件源码
def center_from_faces(matrix):
    face_cascade = cv2.CascadeClassifier(cascade_path)
    faces = face_cascade.detectMultiScale(matrix, FACE_DETECT_REJECT_LEVELS, FACE_DETECT_LEVEL_WEIGHTS)

    x, y = (0, 0)
    weight = 0

    # iterate over our faces array
    for (x, y, w, h) in faces:
        print('Face detected at ', x, y, w, h)
        weight += w * h
        x += (x + w / 2) * w * h
        y += (y + h / 2) * w * h

    if len(faces) == 0:
        return False

    return {
        'x': x / weight,
        'y': y / weight,
        'count': len(faces)
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号