picCarver.py 文件源码

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

项目:PyHack 作者: lanxia 项目源码 文件源码
def faceDetect(path, fileName):
    img = cv2.read(path)
    cascade = cv2.CascadeClassifier("haarcascade_frontalface_alt.xml")
    rects = cascade.detectMultiScale(img, 1.3, 4, cv2.cv.CV_HAAR, SCALE_IMAGE, (20, 20))

    if len(rects) == 0:
        return False

    rects[:, 2:] += rects[:, :2]

    for x1, y1, x2, y2 in rects:
        cv2.rectangle(img, (x1, y1), (x2, y2), (127, 255, 0), 2)

    cv2.imwrite("%s/%s-%s" % (facesDirectory, pcapFile, fileName), img)

    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号