def adjust_boundingbox(face, width, height, size):
    """
    :param face: dlib face class
    :param width: frame width
    :param height: frame height
    :param size: set bounding box size
    :return: x, y, bounding_box_size in opencv form
    """
    x1 = face[0]
    y1 = face[1]
    x2 = face[2]
    y2 = face[3]
    center_x, center_y = (x1 + x2) // 2, (y1 + y2) // 2

    # Check for out of bounds, x-y top left corner
    x1 = min(max(int(center_x - size // 2), 0), width - size)
    y1 = min(max(int(center_y - size // 2), 0), height - size)

    return [x1, y1, size]