def normalize_rect(rect):
    """
    Make rectangle a rotated tall rectangle, which means y-size > x-size
    and the angle indicates the "tilt": rotation of the longer axis from vertical
    :param rect: OpenCV's rectangle object
    :return: OpenCV's rectangle object normalized as described
    rect[0] is the coordinates of the center of the rectangle
    rect[1] is tuple of the sizes (x, y)
    rect[2] is the tilt angle
    if width > height, in rect's internal means, then we turn it 90 degrees
    which means swap the sizes and turn cw or ccw depending on the previous value
    """
    if rect[1][0] > rect[1][1]:
        # incoming rect can be a tuple so if swapping reassign the whole thing
        rect = (
            rect[0],                   # same center coordinates
            (rect[1][1], rect[1][0]),  # swap height with width
            rect[2] + 90.0 if rect[2] < 0.0 else -90.0
        )
    return rect