Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct usage of euclidean distances in motmetrics.utils.compare_to_groundtruth() #168

Merged
merged 1 commit into from
Aug 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions motmetrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def compare_to_groundtruth(gt, dt, dist='iou', distfields=None, distth=0.5):
Kwargs
------
dist : str, optional
String identifying distance to be used. Defaults to intersection over union.
String identifying distance to be used. Defaults to intersection over union ('iou'). Euclidean
distance ('euc') and squared euclidean distance ('seuc') are also supported.
distfields: array, optional
Fields relevant for extracting distance information. Defaults to ['X', 'Y', 'Width', 'Height']
distth: float, optional
Expand All @@ -51,9 +52,19 @@ def compute_iou(a, b):
return iou_matrix(a, b, max_iou=distth)

def compute_euc(a, b):
return np.sqrt(norm2squared_matrix(a, b, max_d2=distth**2))

def compute_seuc(a, b):
return norm2squared_matrix(a, b, max_d2=distth)

compute_dist = compute_iou if dist.upper() == 'IOU' else compute_euc
if dist.upper() == 'IOU':
compute_dist = compute_iou
elif dist.upper() == 'EUC':
compute_dist = compute_euc
elif dist.upper() == 'SEUC':
compute_dist = compute_seuc
else:
raise f'Unknown distance metric {dist}. Use "IOU", "EUC" or "SEUC"'

acc = MOTAccumulator()

Expand Down