functions.py 文件源码

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

项目:cvloop 作者: shoeffner 项目源码 文件源码
def find_faces(self, image, draw_box=False):
        """Uses a haarcascade to detect faces inside an image.

        Args:
            image: The image.
            draw_box: If True, the image will be marked with a rectangle.

        Return:
            The faces as returned by OpenCV's detectMultiScale method for
            cascades.
        """
        frame_gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
        faces = self.cascade.detectMultiScale(
            frame_gray,
            scaleFactor=1.3,
            minNeighbors=5,
            minSize=(50, 50),
            flags=0)

        if draw_box:
            for x, y, w, h in faces:
                cv2.rectangle(image, (x, y),
                              (x + w, y + h), (0, 255, 0), 2)
        return faces
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号