changeset 982:51d8406b2489

corrected bug when not using a homography and using a mask for CLEAR MOT metrics
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 27 Feb 2018 16:45:46 -0500
parents c3e690c5536e
children 7463c9bc846b
files python/moving.py scripts/compute-clearmot.py
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/python/moving.py	Tue Feb 27 15:24:57 2018 -0500
+++ b/python/moving.py	Tue Feb 27 16:45:46 2018 -0500
@@ -1196,7 +1196,7 @@
         if not intersection.empty():
             trajectoryInterval = TimeInterval(intersection.first-self.getFirstInstant(), intersection.last-self.getFirstInstant())
             obj = MovingObject(self.num, intersection, self.positions.getTrajectoryInInterval(trajectoryInterval), self.geometry, self.userType)
-            if self.velocities:
+            if self.velocities is not None:
                 obj.velocities = self.velocities.getTrajectoryInInterval(trajectoryInterval)
             return obj
         else:
@@ -1212,7 +1212,7 @@
             self.projectedPositions = self.positions
         def inMask(positions, i, mask):
             p = positions[i]
-            return mask[p.y, p.x] != 0.
+            return mask[int(p.y), int(p.x)] != 0.
 
         #subTimeIntervals self.getFirstInstant()+i
         filteredIndices = [inMask(self.projectedPositions, i, mask) for i in range(int(self.length()))]
--- a/scripts/compute-clearmot.py	Tue Feb 27 15:24:57 2018 -0500
+++ b/scripts/compute-clearmot.py	Tue Feb 27 16:45:46 2018 -0500
@@ -33,9 +33,9 @@
 args = parser.parse_args()
 
 if args.homographyFilename is not None:
-    homography = loadtxt(args.homographyFilename)
+    invHomography = inv(loadtxt(args.homographyFilename))
 else:
-    homography = None
+    invHomography = None
 
 objects = storage.loadTrajectoriesFromSqlite(args.trackerDatabaseFilename, 'object')
 
@@ -46,12 +46,12 @@
     if len(mask) > 1:
         mask = mask[:,:,0]
     for obj in objects:
-        maskObjects += obj.getObjectsInMask(mask, inv(homography), 2) # TODO add option to keep object if at least one feature in mask
+        maskObjects += obj.getObjectsInMask(mask, invHomography, 10) # TODO add option to keep object if at least one feature in mask
     objects = maskObjects    
 
 annotations = storage.loadBBMovingObjectsFromSqlite(args.groundTruthDatabaseFilename)
 for a in annotations:
-    a.computeCentroidTrajectory(homography)
+    a.computeCentroidTrajectory(invHomography)
 
 if args.nFramesOffsetAnnotations is not None:
     for a in annotations:
@@ -81,7 +81,7 @@
         intrinsicCameraMatrix = None
     firstInstant = args.firstInstant
     lastInstant = args.lastInstant
-    cvutils.displayTrajectories(args.videoFilename, objects, {}, inv(homography), firstInstant, lastInstant, annotations = annotations, undistort = args.undistort, intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = args.distortionCoefficients, undistortedImageMultiplication = args.undistortedImageMultiplication, gtMatches = gtMatches, toMatches = toMatches)
+    cvutils.displayTrajectories(args.videoFilename, objects, {}, invHomography, firstInstant, lastInstant, annotations = annotations, undistort = args.undistort, intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = args.distortionCoefficients, undistortedImageMultiplication = args.undistortedImageMultiplication, gtMatches = gtMatches, toMatches = toMatches)
     #print('Ground truth matches')
     #print(gtMatches)
     #print('Object matches')