diff trafficintelligence/moving.py @ 1081:346b41cbc81a

added code idea from Paul St Aubin
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 21 Jul 2018 22:36:47 -0400
parents 845d694af7b8
children 7853106677b7
line wrap: on
line diff
--- a/trafficintelligence/moving.py	Fri Jul 20 16:36:42 2018 -0400
+++ b/trafficintelligence/moving.py	Sat Jul 21 22:36:47 2018 -0400
@@ -1869,6 +1869,17 @@
         else:
             return matchingDistance + 1
 
+def matchObjects(obj1, obj2, instant, matchingDistance):
+    '''Indicates if obj matches obj2 with threshold matchingDistance
+        Returns distance if below matchingDistance, matchingDistance+1 otherwise
+    (returns an actual value, otherwise munkres does not terminate)'''
+    d = Point.distanceNorm2(obj1.getPositionAtInstant(instant), obj2.getPositionAtInstant(instant))
+    if d < matchingDistance:
+        return d
+    else:
+        return matchingDistance + 1
+
+# TODO class to have different matching methods, eg with something like matchObjects
 def computeClearMOT(annotations, objects, matchingDistance, firstInstant, lastInstant, returnMatches = False, debug = False):
     '''Computes the CLEAR MOT metrics