Rotates a keypoint by 90 degrees CCW (see np.rot90)

    Args:
        keypoint (tuple): A tuple (x, y, angle, scale).
        factor (int): Number of CCW rotations. Must be in range [0;3] See np.rot90.
        rows (int): Image rows.
        cols (int): Image cols.

def keypoint_rot90(keypoint, factor, rows, cols, **params):
    """Rotates a keypoint by 90 degrees CCW (see np.rot90)

    Args:
        keypoint (tuple): A tuple (x, y, angle, scale).
        factor (int): Number of CCW rotations. Must be in range [0;3] See np.rot90.
        rows (int): Image rows.
        cols (int): Image cols.
    """
    if factor < 0 or factor > 3:
        raise ValueError('Parameter n must be in range [0;3]')
    x, y, angle, scale = keypoint
    if factor == 1:
        keypoint = [y, (cols - 1) - x, angle - math.pi / 2, scale]
    if factor == 2:
        keypoint = [(cols - 1) - x, (rows - 1) - y, angle - math.pi, scale]
    if factor == 3:
        keypoint = [(rows - 1) - y, x, angle + math.pi / 2, scale]
    return keypoint