comparison python/moving.py @ 595:17b02c8054d0

added tests and corrected one bug
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 07 Dec 2014 22:59:47 -0500
parents 9e39cd95e017
children 04a8304e13f0 aee4cbac9e0e
comparison
equal deleted inserted replaced
594:9e39cd95e017 595:17b02c8054d0
1313 if d < matchingDistance: 1313 if d < matchingDistance:
1314 return d 1314 return d
1315 else: 1315 else:
1316 return matchingDistance + 1 1316 return matchingDistance + 1
1317 1317
1318 def computeClearMOT(objects, annotations, matchingDistance, firstInstant, lastInstant, debug = False): 1318 def computeClearMOT(annotations, objects, matchingDistance, firstInstant, lastInstant, debug = False):
1319 '''Computes the CLEAR MOT metrics 1319 '''Computes the CLEAR MOT metrics
1320 1320
1321 Reference: 1321 Reference:
1322 Keni, Bernardin, and Stiefelhagen Rainer. "Evaluating multiple object tracking performance: the CLEAR MOT metrics." EURASIP Journal on Image and Video Processing 2008 (2008) 1322 Keni, Bernardin, and Stiefelhagen Rainer. "Evaluating multiple object tracking performance: the CLEAR MOT metrics." EURASIP Journal on Image and Video Processing 2008 (2008)
1323 1323
1366 unmatchedTOs = [o for o in objects if o.existsAtInstant(t) and o not in matchedTOs] 1366 unmatchedTOs = [o for o in objects if o.existsAtInstant(t) and o not in matchedTOs]
1367 nGTs = len(matchedGTs)+len(unmatchedGTs) 1367 nGTs = len(matchedGTs)+len(unmatchedGTs)
1368 nTOs = len(matchedTOs)+len(unmatchedTOs) 1368 nTOs = len(matchedTOs)+len(unmatchedTOs)
1369 if len(unmatchedTOs) > 0: 1369 if len(unmatchedTOs) > 0:
1370 for a in unmatchedGTs: 1370 for a in unmatchedGTs:
1371 aCosts = [a.matches(o, t, matchingDistance) for o in unmatchedTOs] 1371 costs.append([a.matches(o, t, matchingDistance) for o in unmatchedTOs])
1372 if min(aCosts) < matchingDistance:
1373 costs.append(aCosts)
1374 # print costs
1375 if len(costs) > 0: 1372 if len(costs) > 0:
1376 newMatches = munk.compute(costs) 1373 newMatches = munk.compute(costs)
1377 for k,v in newMatches: 1374 for k,v in newMatches:
1378 if costs[k][v] < matchingDistance: 1375 if costs[k][v] < matchingDistance:
1379 matches[unmatchedGTs[k]]=unmatchedTOs[v] 1376 matches[unmatchedGTs[k]]=unmatchedTOs[v]
1406 1403
1407 if ct > 0: 1404 if ct > 0:
1408 motp = dist/ct 1405 motp = dist/ct
1409 else: 1406 else:
1410 motp = None 1407 motp = None
1411 return motp, 1.-float(mt+fpt+mme)/gt, mt, mme, fpt, gt 1408 if gt > 0:
1409 mota = 1.-float(mt+fpt+mme)/gt
1410 else:
1411 mota = None
1412 return motp, mota, mt, mme, fpt, gt
1412 1413
1413 1414
1414 def plotRoadUsers(objects, colors): 1415 def plotRoadUsers(objects, colors):
1415 '''Colors is a PlottingPropertyValues instance''' 1416 '''Colors is a PlottingPropertyValues instance'''
1416 from matplotlib.pyplot import figure, axis 1417 from matplotlib.pyplot import figure, axis