contextnet/utils/utils.py
def find_matching_box(points, new_point, similarity, match_sim):
    """
    Compute similarity score between new points and all points to find most similar.

    Parameters
    ----------
    points: list
        The list of points for measering similarity.
    new_point: np.array
        The point which is wanted to match with one from points.
    similarity: func
        Similarity function.
    match_sim: float 
        threshold for similarity.
    Returns
    -------
    best_index: int
        index of most similar point in points to new_point.
    best_sim: float
        value of similarity between best similar point and new_point.
    """
    best_sim = match_sim
    best_index = -1
    for i in range(len(points)):
        box = points[i]
        sim = float(similarity.measure(
            box[:2], new_point[:2]))
        if sim > best_sim:
            best_index = i
            best_sim = sim
    return best_index, best_sim

    Compute similarity score between new points and all points to find most similar.

    Parameters
    ----------
    points: list
        The list of points for measering similarity.
    new_point: np.array
        The point which is wanted to match with one from points.
    similarity: func
        Similarity function.
    match_sim: float 
        threshold for similarity.
    Returns
    -------
    best_index: int
        index of most similar point in points to new_point.
    best_sim: float
        value of similarity between best similar point and new_point.
    
Compute similarity score between new points and all points to find most similar.
Parameters

list
The list of points for measering similarity.
new_point: np.array
The point which is wanted to match with one from points.
similarity: func
Similarity function.
match_sim: float
threshold for similarity.
Returns

int
index of most similar point in points to new_point.
best_sim: float
value of similarity between best similar point and new_point.
Compute similarity score between new points and all points to find most similar . Parameters list The list of points for measering similarity . new_point : np . array The point which is wanted to match with one from points . similarity : func Similarity function . match_sim : float threshold for similarity . Returns int index of most similar point in points to new_point . best_sim : float value of similarity between best similar point and new_point .
def find_matching_box(points, new_point, similarity, match_sim):
    best_sim = match_sim
    best_index = -1
    for i in range(len(points)):
        box = points[i]
        sim = float(similarity.measure(
            box[:2], new_point[:2]))
        if sim > best_sim:
            best_index = i
            best_sim = sim
    return best_index, best_sim
def find_matching_box ( points , new_point , similarity , match_sim ) : best_sim = match_sim best_index = - 1 for i in range ( len ( points ) ) : box = points [ i ] sim = float ( similarity . measure ( box [ : 2 ] , new_point [ : 2 ] ) ) if sim > best_sim : best_index = i best_sim = sim return best_index , best_sim
Compute similarity score between new points and all points to find most similar.
Compute similarity score between new points and all points to find most similar .
"""
    Compute similarity score between new points and all points to find most similar.

    Parameters
    ----------
    points: list
        The list of points for measering similarity.
    new_point: np.array
        The point which is wanted to match with one from points.
    similarity: func
        Similarity function.
    match_sim: float 
        threshold for similarity.
    Returns
    -------
    best_index: int
        index of most similar point in points to new_point.
    best_sim: float
        value of similarity between best similar point and new_point.
    """
points
new_point
similarity
match_sim