Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 619:dc2d0a0d7fe1
merged code from Mohamed Gomaa Mohamed for the use of points of interests in mation pattern learning and motion prediction (TRB 2015)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 10 Dec 2014 15:27:08 -0500 |
parents | 04a8304e13f0 0791b3b55b8f |
children | 582508610572 |
comparison
equal
deleted
inserted
replaced
596:04a8304e13f0 | 619:dc2d0a0d7fe1 |
---|---|
793 if count > lengthThreshold: | 793 if count > lengthThreshold: |
794 return True | 794 return True |
795 return False | 795 return False |
796 | 796 |
797 def wiggliness(self): | 797 def wiggliness(self): |
798 return self.cumulatedDisplacement()/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1))) | 798 return self.getCumulativeDistance(self.length()-1)/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1))) |
799 | 799 |
800 def getIntersections(self, p1, p2): | 800 def getIntersections(self, p1, p2): |
801 '''Returns a list of the indices at which the trajectory | 801 '''Returns a list of the indices at which the trajectory |
802 intersects with the segment of extremities p1 and p2 | 802 intersects with the segment of extremities p1 and p2 |
803 the list is empty if there is no crossing''' | 803 the list is empty if there is no crossing''' |
1066 tMaxFeatures = t | 1066 tMaxFeatures = t |
1067 return MovingObject.maxDistance(self, self, tMaxFeatures) | 1067 return MovingObject.maxDistance(self, self, tMaxFeatures) |
1068 else: | 1068 else: |
1069 print('Load features to compute a maximum size') | 1069 print('Load features to compute a maximum size') |
1070 return None | 1070 return None |
1071 | 1071 |
1072 def setRoutes(self, startRouteID, endRouteID): | 1072 def setRoutes(self, startRouteID, endRouteID): |
1073 self.startRouteID = startRouteID | 1073 self.startRouteID = startRouteID |
1074 self.endRouteID = endRouteID | 1074 self.endRouteID = endRouteID |
1075 | 1075 |
1076 def getInstantsCrossingLane(self, p1, p2): | 1076 def getInstantsCrossingLane(self, p1, p2): |
1163 # User Type Classification | 1163 # User Type Classification |
1164 ### | 1164 ### |
1165 def classifyUserTypeSpeedMotorized(self, threshold, aggregationFunc = median, ignoreNInstantsAtEnds = 0): | 1165 def classifyUserTypeSpeedMotorized(self, threshold, aggregationFunc = median, ignoreNInstantsAtEnds = 0): |
1166 '''Classifies slow and fast road users | 1166 '''Classifies slow and fast road users |
1167 slow: non-motorized -> pedestrians | 1167 slow: non-motorized -> pedestrians |
1168 fast: motorized -> cars''' | 1168 fast: motorized -> cars |
1169 | |
1170 aggregationFunc can be any function that can be applied to a vector of speeds, including percentile: | |
1171 aggregationFunc = lambda x: percentile(x, percentileFactor) # where percentileFactor is 85 for 85th percentile''' | |
1169 if ignoreNInstantsAtEnds > 0: | 1172 if ignoreNInstantsAtEnds > 0: |
1170 speeds = self.getSpeeds()[ignoreNInstantsAtEnds:-ignoreNInstantsAtEnds] | 1173 speeds = self.getSpeeds()[ignoreNInstantsAtEnds:-ignoreNInstantsAtEnds] |
1171 else: | 1174 else: |
1172 speeds = self.getSpeeds() | 1175 speeds = self.getSpeeds() |
1173 if aggregationFunc(speeds) >= threshold: | 1176 if aggregationFunc(speeds) >= threshold: |