Routines.py 文件源码

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

项目:structured-output-ae 作者: sbelharbi 项目源码 文件源码
def face_detect(self, img):
        """ Detect the face location of the image img, using Haar cascaded face detector of OpenCV.

        return : x,y w, h of the bouning box.
        """
        face_cascade = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml')
        faces = face_cascade.detectMultiScale(img, 1.3, 5)
        x = -1
        y = -1
        w = -1
        h = -1
        if len(faces) == 1: # we take only when we have 1 face, else, we return nothing.
            x,y,w,h = faces[0]
        else:
##            for (x_,y_,w_,h_) in faces:
##                x = x_
##                y = y_
##                w = w_
##                h = h_
##                break # we take only the first face,
            print "More than one face!!!!!!!!!"


        return x,y,w,h
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号