def filter_BF_matches(matches: list, threshold=45) -> list:
    """
    filter matches list and keep the best matches according to threshold
    :param matches: a list of matches
    :param threshold: threshold filtering
    :return: matches_tmp: list of the best matches
    """
    matches_tmp = []
    sorted_matches = sorted(matches, key=lambda x: x.distance)
    threshold_percent = int(len(sorted_matches) * threshold / 100)
    for match_index in range(threshold_percent):
        matches_tmp.append([sorted_matches[match_index].queryIdx, sorted_matches[match_index].trainIdx])

    return matches_tmp