Mercurial > hg > nsaunier > traffic-intelligence
comparison python/moving.py @ 615:0954aaf28231
Merge
| author | MohamedGomaa |
|---|---|
| date | Wed, 10 Dec 2014 14:12:06 -0500 |
| parents | 84690dfe5560 c5406edbcf12 |
| children | 0791b3b55b8f |
comparison
equal
deleted
inserted
replaced
| 613:306db0f3c7a2 | 615:0954aaf28231 |
|---|---|
| 922 | 922 |
| 923 userType2Num = utils.inverseEnumeration(userTypeNames) | 923 userType2Num = utils.inverseEnumeration(userTypeNames) |
| 924 | 924 |
| 925 class MovingObject(STObject): | 925 class MovingObject(STObject): |
| 926 '''Class for moving objects: a spatio-temporal object | 926 '''Class for moving objects: a spatio-temporal object |
| 927 with a trajectory and a geometry (constant volume over time) and a usertype (e.g. road user) coded as a number (see | 927 with a trajectory and a geometry (constant volume over time) |
| 928 and a usertype (e.g. road user) coded as a number (see userTypeNames) | |
| 928 ''' | 929 ''' |
| 929 | 930 |
| 930 def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown']): | 931 def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown']): |
| 931 super(MovingObject, self).__init__(num, timeInterval) | 932 super(MovingObject, self).__init__(num, timeInterval) |
| 932 self.positions = positions | 933 self.positions = positions |
| 1275 def collisionCourseCosine(movingObject1, movingObject2, instant): | 1276 def collisionCourseCosine(movingObject1, movingObject2, instant): |
| 1276 'A positive result indicates that the road users are getting closer' | 1277 'A positive result indicates that the road users are getting closer' |
| 1277 return Point.cosine(movingObject1.getPositionAtInstant(instant)-movingObject2.getPositionAtInstant(instant), #deltap | 1278 return Point.cosine(movingObject1.getPositionAtInstant(instant)-movingObject2.getPositionAtInstant(instant), #deltap |
| 1278 movingObject2.getVelocityAtInstant(instant)-movingObject1.getVelocityAtInstant(instant)) #deltav | 1279 movingObject2.getVelocityAtInstant(instant)-movingObject1.getVelocityAtInstant(instant)) #deltav |
| 1279 | 1280 |
| 1281 | |
| 1282 ################## | |
| 1283 # Annotations | |
| 1284 ################## | |
| 1285 | |
| 1286 class BBAnnotation(MovingObject): | |
| 1287 '''Class for : a series of ground truth annotations using bounding boxes | |
| 1288 Its center is the center of the containing shape | |
| 1289 ''' | |
| 1290 | |
| 1291 def __init__(self, num = None, timeInterval = None, topPositions = None, bottomPositions = None, userType = userType2Num['unknown']): | |
| 1292 super(BBAnnotation, self).__init__(num, timeInterval, Trajectory(), userType = userType) | |
| 1293 self.topPositions = topPositions.getPositions() | |
| 1294 self.bottomPositions = bottomPositions.getPositions() | |
| 1295 for i in xrange(int(topPositions.length())): | |
| 1296 self.positions.addPosition((topPositions.getPositionAt(i) + bottomPositions.getPositionAt(i)).multiply(0.5)) | |
| 1297 | |
| 1298 | |
| 1280 def plotRoadUsers(objects, colors): | 1299 def plotRoadUsers(objects, colors): |
| 1281 '''Colors is a PlottingPropertyValues instance''' | 1300 '''Colors is a PlottingPropertyValues instance''' |
| 1282 from matplotlib.pyplot import figure, axis | 1301 from matplotlib.pyplot import figure, axis |
| 1283 figure() | 1302 figure() |
| 1284 for obj in objects: | 1303 for obj in objects: |
