Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 590:0fa73cbe9fdb
annotation centroid are computed explicitly and projected at that step if required
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 05 Dec 2014 16:41:11 -0500 |
parents | 5800a87f11ae |
children | 985a3021cff2 |
comparison
equal
deleted
inserted
replaced
589:5800a87f11ae | 590:0fa73cbe9fdb |
---|---|
724 return None | 724 return None |
725 else: | 725 else: |
726 return Trajectory([[a-b for a,b in zip(self.getXCoordinates(),traj2.getXCoordinates())], | 726 return Trajectory([[a-b for a,b in zip(self.getXCoordinates(),traj2.getXCoordinates())], |
727 [a-b for a,b in zip(self.getYCoordinates(),traj2.getYCoordinates())]]) | 727 [a-b for a,b in zip(self.getYCoordinates(),traj2.getYCoordinates())]]) |
728 | 728 |
729 def multiply(self, alpha): | |
730 '''Returns a new trajectory of the same length''' | |
731 return Trajectory([[alpha*x for x in self.getXCoordinates()], | |
732 [alpha*y for y in self.getYCoordinates()]]) | |
733 | |
729 def differentiate(self, doubleLastPosition = False): | 734 def differentiate(self, doubleLastPosition = False): |
730 diff = Trajectory() | 735 diff = Trajectory() |
731 for i in xrange(1, self.length()): | 736 for i in xrange(1, self.length()): |
732 diff.addPosition(self[i]-self[i-1]) | 737 diff.addPosition(self[i]-self[i-1]) |
733 if doubleLastPosition: | 738 if doubleLastPosition: |
1281 ################## | 1286 ################## |
1282 # Annotations | 1287 # Annotations |
1283 ################## | 1288 ################## |
1284 | 1289 |
1285 class BBAnnotation(MovingObject): | 1290 class BBAnnotation(MovingObject): |
1286 '''Class for : a series of ground truth annotations using bounding boxes | 1291 '''Class for a series of ground truth annotations using bounding boxes |
1287 Its center is the center of the containing shape | 1292 Its center is the center of the containing shape |
1293 | |
1294 By default in image space | |
1288 ''' | 1295 ''' |
1289 | 1296 |
1290 def __init__(self, num = None, timeInterval = None, topLeftPositions = None, bottomRightPositions = None, userType = userType2Num['unknown']): | 1297 def __init__(self, num = None, timeInterval = None, topLeftPositions = None, bottomRightPositions = None, userType = userType2Num['unknown']): |
1291 super(BBAnnotation, self).__init__(num, timeInterval, Trajectory(), userType = userType) | 1298 super(BBAnnotation, self).__init__(num, timeInterval, userType = userType) |
1292 self.topLeftPositions = topLeftPositions.getPositions() | 1299 self.topLeftPositions = topLeftPositions.getPositions() |
1293 self.bottomRightPositions = bottomRightPositions.getPositions() | 1300 self.bottomRightPositions = bottomRightPositions.getPositions() |
1294 for i in xrange(int(topLeftPositions.length())): | 1301 |
1295 self.positions.addPosition((topLeftPositions.getPositionAt(i) + bottomRightPositions.getPositionAt(i)).multiply(0.5)) | 1302 def computeCentroidTrajectory(self, homography = None): |
1296 | 1303 self.positions = self.topLeftPositions.add(self.bottomRightPositions).multiply(0.5) |
1304 if homography != None: | |
1305 self.positions = self.positions.project(homography) | |
1306 | |
1307 def matches(self, obj, instant, matchingDistance): | |
1308 '''Indicates if the annotation matches obj (MovingObject) | |
1309 with threshold matchingDistance''' | |
1310 return True | |
1311 | |
1312 def matchingGroundTruthToTracker(objects, annotations, matchingDistance): | |
1313 '''Returns a matching of tracker output (objects) to ground truth (annnotations) | |
1314 | |
1315 objects and annotations are supposed to in the same space | |
1316 current implementation is BBAnnotations (bounding boxes) | |
1317 mathingDistance is threshold on matching between annotation and object''' | |
1297 | 1318 |
1298 def plotRoadUsers(objects, colors): | 1319 def plotRoadUsers(objects, colors): |
1299 '''Colors is a PlottingPropertyValues instance''' | 1320 '''Colors is a PlottingPropertyValues instance''' |
1300 from matplotlib.pyplot import figure, axis | 1321 from matplotlib.pyplot import figure, axis |
1301 figure() | 1322 figure() |