Mercurial Hosting > traffic-intelligence
comparison python/events.py @ 664:455f9b93819c
added capability to set a videofilename to movingobject and interaction, renames interactiontype to collision in interaction
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 20 May 2015 12:04:22 +0200 |
parents | 72174e66aba5 |
children | 15e244d2a1b5 |
comparison
equal
deleted
inserted
replaced
663:65a867942eee | 664:455f9b93819c |
---|---|
7 | 7 |
8 import multiprocessing | 8 import multiprocessing |
9 import itertools | 9 import itertools |
10 | 10 |
11 import moving, prediction, indicators, utils, cvutils | 11 import moving, prediction, indicators, utils, cvutils |
12 from storage import VideoFilenameAddable | |
12 __metaclass__ = type | 13 __metaclass__ = type |
13 | 14 |
14 def findRoute(prototypes,objects,i,j,noiseEntryNums,noiseExitNums,minSimilarity= 0.3, spatialThreshold=1.0, delta=180): | 15 def findRoute(prototypes,objects,i,j,noiseEntryNums,noiseExitNums,minSimilarity= 0.3, spatialThreshold=1.0, delta=180): |
15 if i[0] not in noiseEntryNums: | 16 if i[0] not in noiseEntryNums: |
16 prototypesRoutes= [ x for x in sorted(prototypes.keys()) if i[0]==x[0]] | 17 prototypesRoutes= [ x for x in sorted(prototypes.keys()) if i[0]==x[0]] |
39 if useDestination: | 40 if useDestination: |
40 if route not in prototypes.keys(): | 41 if route not in prototypes.keys(): |
41 route= findRoute(prototypes,objects,route,obj.getNum(),noiseEntryNums,noiseExitNums) | 42 route= findRoute(prototypes,objects,route,obj.getNum(),noiseEntryNums,noiseExitNums) |
42 return route | 43 return route |
43 | 44 |
44 class Interaction(moving.STObject): | 45 class Interaction(moving.STObject, VideoFilenameAddable): |
45 '''Class for an interaction between two road users | 46 '''Class for an interaction between two road users |
46 or a road user and an obstacle | 47 or a road user and an obstacle |
47 | 48 |
48 link to the moving objects | 49 link to the moving objects |
49 contains the indicators in a dictionary with the names as keys | 50 contains the indicators in a dictionary with the names as keys |
229 | 230 |
230 def computePET(self, collisionDistanceThreshold): | 231 def computePET(self, collisionDistanceThreshold): |
231 # TODO add crossing zone | 232 # TODO add crossing zone |
232 self.pet = moving.MovingObject.computePET(self.roadUser1, self.roadUser2, collisionDistanceThreshold) | 233 self.pet = moving.MovingObject.computePET(self.roadUser1, self.roadUser2, collisionDistanceThreshold) |
233 | 234 |
234 def addVideoFilename(self,videoFilename): | 235 def setCollision(self, collision): |
235 self.videoFilename = videoFilename | 236 '''indicates if it is a collision: argument should be boolean''' |
236 | 237 self.collision = collision |
237 def addInteractionType(self,interactionType): | 238 |
238 ''' interaction types: conflict or collision if they are known''' | 239 def isCollision(self): |
239 self.interactionType = interactionType | 240 if hasattr(self, 'collision'): |
241 return self.collision | |
242 else: | |
243 return None | |
240 | 244 |
241 def getCrossingZones(self, predictionMethodName): | 245 def getCrossingZones(self, predictionMethodName): |
242 if self.crossingZones is not None: | 246 if self.crossingZones is not None: |
243 return self.crossingZones[predictionMethodName] | 247 return self.crossingZones[predictionMethodName] |
244 else: | 248 else: |