def clip(img, size, rect):
    """ Clip the frame and return the face region
    Args:
        img: an instance of numpy.ndarray, the image
        size: size of the image when performing detection
        rect: an instance of dlib.rectangle, the face region
    Returns:
        numpy.ndarray, the face region
    """
    left = int(rect.left() / size[0] * img.shape[1])
    right = int(rect.right() / size[0] * img.shape[1])
    top = int(rect.top() / size[1] * img.shape[0])
    bottom = int(rect.bottom() / size[1] * img.shape[0])
    return img[top:bottom, left:right]