changeset 1132:09ef0dc994a0

modification for performance computation
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 26 Feb 2020 22:32:39 -0500
parents 3972d85e3b6c
children c4d9c270f999
files trafficintelligence/moving.py
diffstat 1 files changed, 7 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/trafficintelligence/moving.py	Thu Feb 20 23:56:56 2020 -0500
+++ b/trafficintelligence/moving.py	Wed Feb 26 22:32:39 2020 -0500
@@ -1757,6 +1757,11 @@
             print('Object {} has no features'.format(self.getNum()))
             return None
 
+    def motDistanceAtInstant(self, obj, instant):
+        '''Returns distance for computing CLEAR MOT metrics
+        (returns an actual value, otherwise munkres does not terminate)'''
+        return Point.distanceNorm2(self.getPositionAtInstant(instant), obj.getPositionAtInstant(instant))
+
     ###
     # User Type Classification
     ###
@@ -1939,7 +1944,7 @@
     (computed after projecting if homography available)
     '''
 
-    def __init__(self, num = None, timeInterval = None, topLeftPositions = None, bottomRightPositions = None, userType = userType2Num['unknown']):
+    def __init__(self, topLeftPositions, bottomRightPositions, num = None, timeInterval = None, userType = userType2Num['unknown']):
         super(BBMovingObject, self).__init__(num, timeInterval, userType = userType)
         self.topLeftPositions = topLeftPositions.getPositions()
         self.bottomRightPositions = bottomRightPositions.getPositions()
@@ -1949,17 +1954,6 @@
         if homography is not None:
             self.positions = self.positions.homographyProject(homography)
 
-    def matches(self, obj, instant, matchingDistance):
-        '''Indicates if the annotation matches obj (MovingObject)
-        with threshold matchingDistance
-        Returns distance if below matchingDistance, matchingDistance+1 otherwise
-        (returns an actual value, otherwise munkres does not terminate)'''
-        d = Point.distanceNorm2(self.getPositionAtInstant(instant), obj.getPositionAtInstant(instant))
-        if d < matchingDistance:
-            return d
-        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
@@ -2020,7 +2014,7 @@
         toDelete = []
         for a in matches:
             if a.existsAtInstant(t) and matches[a].existsAtInstant(t):
-                d = a.matches(matches[a], t, matchingDistance)
+                d = a.motDistanceAtInstant(matches[a], t)
                 if d < matchingDistance:
                     dist += d
                 else: