# HG changeset patch # User MohamedGomaa # Date 1418239110 18000 # Node ID 0791b3b55b8ff56a1bb8538cb024f9b6d1c18083 # Parent 0954aaf282313ec35b2dc1e57940423db1380402# Parent 34111db7cecbf4550fa613f5c3df25e360f7efee Merge diff -r 0954aaf28231 -r 0791b3b55b8f c/Makefile --- a/c/Makefile Wed Dec 10 14:12:06 2014 -0500 +++ b/c/Makefile Wed Dec 10 14:18:30 2014 -0500 @@ -1,6 +1,6 @@ EXE_DIR=../bin SCRIPTS_DIR=../scripts -TRAJECTORYMANAGEMENT_DIR=D:/00-trackingSoftware/trajectories-trajectorymanagementandanalysis/trunk/src/TrajectoryManagementAndAnalysis +TRAJECTORYMANAGEMENT_DIR=$(HOME)/Research/Code/trajectorymanagementandanalysis/trunk/src/TrajectoryManagementAndAnalysis CXX = g++ diff -r 0954aaf28231 -r 0791b3b55b8f python/moving.py --- a/python/moving.py Wed Dec 10 14:12:06 2014 -0500 +++ b/python/moving.py Wed Dec 10 14:18:30 2014 -0500 @@ -5,7 +5,7 @@ import cvutils from math import sqrt -from numpy import median,percentile +from numpy import median try: from shapely.geometry import Polygon, Point as shapelyPoint @@ -790,7 +790,7 @@ return False def wiggliness(self): - return self.computeCumulativeDistances()/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1))) + return self.getCumulativeDistance(self.length()-1)/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1))) def getIntersections(self, p1, p2): '''Returns a list of the indices at which the trajectory @@ -1157,16 +1157,18 @@ ### # User Type Classification ### - def classifyUserTypeSpeedMotorized(self, threshold, percentileFactor=95, ignoreNInstantsAtEnds = 0): + def classifyUserTypeSpeedMotorized(self, threshold, aggregationFunc = median, ignoreNInstantsAtEnds = 0): '''Classifies slow and fast road users slow: non-motorized -> pedestrians fast: motorized -> cars - The percentile function is the same as the median if percentileFactor=50, the same as the minimum if percentileFactor=0 and the same as the maximum if percentileFactor=100.''' + + aggregationFunc can be any function that can be applied to a vector of speeds, including percentile: + aggregationFunc = lambda x: percentile(x, percentileFactor) # where percentileFactor is 85 for 85th percentile''' if ignoreNInstantsAtEnds > 0: speeds = self.getSpeeds()[ignoreNInstantsAtEnds:-ignoreNInstantsAtEnds] else: speeds = self.getSpeeds() - if percentile(speeds,percentileFactor) >= threshold: + if aggregationFunc(speeds) >= threshold: self.setUserType(userType2Num['car']) else: self.setUserType(userType2Num['pedestrian'])