process_images.py 文件源码

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

项目:Emotion-Recognition 作者: HashCode55 项目源码 文件源码
def process_image(img = list()):
    """
    Extracts faces from the image using haar cascade, resizes and applies filters. 
    :param img: image matrix. Must be grayscale
    ::returns faces:: list contatining the cropped face images
    """
    face_cascade = cv2.CascadeClassifier('/Users/mehul/opencv-3.0.0/build/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml')   

    faces_location = face_cascade.detectMultiScale(img, 1.3, 5)
    faces = []

    for (x,y,w,h) in faces_location:
        img = img[y:(y+h), x:(x+w)]
        try:
            img = cv2.resize(img, (256, 256))
        except:
            exit(1)
        img = cv2.bilateralFilter(img,15,10,10)
        img = cv2.fastNlMeansDenoising(img,None,4,7,21)
        faces.append(img)

    return faces
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号