Skip to content

Commit 008f45c

Browse files
authored
Corrected motmetrics.utils.compare_to_groundtruth(,,dist='euc') to use euclidean distances. (#168)
The squared distance can still be used with dist='seuc'. Co-authored-by: Angel Carro-Lagoa <[email protected]>
1 parent 1ad168c commit 008f45c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

motmetrics/utils.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def compare_to_groundtruth(gt, dt, dist='iou', distfields=None, distth=0.5):
3737
Kwargs
3838
------
3939
dist : str, optional
40-
String identifying distance to be used. Defaults to intersection over union.
40+
String identifying distance to be used. Defaults to intersection over union ('iou'). Euclidean
41+
distance ('euc') and squared euclidean distance ('seuc') are also supported.
4142
distfields: array, optional
4243
Fields relevant for extracting distance information. Defaults to ['X', 'Y', 'Width', 'Height']
4344
distth: float, optional
@@ -51,9 +52,19 @@ def compute_iou(a, b):
5152
return iou_matrix(a, b, max_iou=distth)
5253

5354
def compute_euc(a, b):
55+
return np.sqrt(norm2squared_matrix(a, b, max_d2=distth**2))
56+
57+
def compute_seuc(a, b):
5458
return norm2squared_matrix(a, b, max_d2=distth)
5559

56-
compute_dist = compute_iou if dist.upper() == 'IOU' else compute_euc
60+
if dist.upper() == 'IOU':
61+
compute_dist = compute_iou
62+
elif dist.upper() == 'EUC':
63+
compute_dist = compute_euc
64+
elif dist.upper() == 'SEUC':
65+
compute_dist = compute_seuc
66+
else:
67+
raise f'Unknown distance metric {dist}. Use "IOU", "EUC" or "SEUC"'
5768

5869
acc = MOTAccumulator()
5970

0 commit comments

Comments
 (0)