Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 511:ad518f0c3218
merged pulling from main
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 28 May 2014 17:46:38 -0400 |
parents | c81cbd6953fb |
children | a40c75f04903 |
comparison
equal
deleted
inserted
replaced
510:b0dac840c24f | 511:ad518f0c3218 |
---|---|
803 def predictPosition(self, instant, nTimeSteps, externalAcceleration = Point(0,0)): | 803 def predictPosition(self, instant, nTimeSteps, externalAcceleration = Point(0,0)): |
804 '''Predicts the position of object at instant+deltaT, | 804 '''Predicts the position of object at instant+deltaT, |
805 at constant speed''' | 805 at constant speed''' |
806 return predictPositionNoLimit(nTimeSteps, self.getPositionAtInstant(instant), self.getVelocityAtInstant(instant), externalAcceleration) | 806 return predictPositionNoLimit(nTimeSteps, self.getPositionAtInstant(instant), self.getVelocityAtInstant(instant), externalAcceleration) |
807 | 807 |
808 def classifyUserTypeSpeed(self, threshold, statisticsFunc = median): | 808 def classifyUserTypeSpeed(self, threshold, statisticsFunc = median, ignoreNInstantsAtEnds = 0): |
809 '''Classifies slow and fast road users | 809 '''Classifies slow and fast road users |
810 slow: non-motorized -> pedestrians | 810 slow: non-motorized -> pedestrians |
811 fast: motorized -> cars''' | 811 fast: motorized -> cars''' |
812 if statisticsFunc(self.velocities.norm()) >= threshold: | 812 if ignoreNInstantsAtEnds > 0: |
813 speeds = self.velocities.norm()[ignoreNInstantsAtEnds:-ignoreNInstantsAtEnds] | |
814 else: | |
815 speeds = self.velocities.norm() | |
816 if statisticsFunc(speeds) >= threshold: | |
813 self.setUserType(userType2Num['car']) | 817 self.setUserType(userType2Num['car']) |
814 else: | 818 else: |
815 self.setUserType(userType2Num['pedestrian']) | 819 self.setUserType(userType2Num['pedestrian']) |
816 | 820 |
817 @staticmethod | 821 @staticmethod |