def __init__(self, hat_path=os.path.join(os.curdir, 'hat.png'),
cascade_path=os.path.join(
OPENCV_CASCADE_PATH, 'haarcascades',
'haarcascade_frontalface_default.xml'),
w_offset=1.3, x_offset=-20, y_offset=80, draw_box=False):
# pragma pylint: disable=line-too-long
"""Initializes a `DrawHat` instance.
Args:
hat_path: The path to the hat file. Defaults to ./hat.png .
cascade_path: The path to the face cascade file.
Defaults to
`cvloop.OPENCV_CASCADE_PATH/haarcascades/haarcascade_frontalface_default.xml`
w_offset: Hat width additional scaling.
x_offset: Number of pixels right to move hat.
y_offset: Number of pixels down to move hat.
draw_box: If True, draws boxes around detected faces.
"""
# pragma pylint: enable=line-too-long
self.w_offset = w_offset
self.x_offset = x_offset
self.y_offset = y_offset
self.draw_box = draw_box
self.cascade = cv2.CascadeClassifier(cascade_path)
self.hat = self.load_hat(hat_path)
评论列表
文章目录