Mercurial Hosting > traffic-intelligence
diff python/moving.py @ 579:05c927c6d3cf
curvilinear projection seems operational
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 28 Aug 2014 23:50:30 -0400 |
parents | fe4e9d2b807d |
children | 10e8a9f2bd9f |
line wrap: on
line diff
--- a/python/moving.py Thu Aug 28 17:42:32 2014 -0400 +++ b/python/moving.py Thu Aug 28 23:50:30 2014 -0400 @@ -379,9 +379,7 @@ return Point(X,Y) def getSYfromXY(p, splines, goodEnoughSplineDistance = 0.5): - ''' Snap a point p to it's nearest subsegment of it's nearest spline (from the list splines). - - To force snapping to a single spline, pass the spline alone through splines (e.g. splines=[splines[splineNum]]). + ''' Snap a point p to it's nearest subsegment of it's nearest spline (from the list splines). A spline is a list of points (class Point), most likely a trajectory. Output: ======= @@ -1084,12 +1082,7 @@ Input: ====== alignments = a list of alignments, where each alignment is a list of - points, where each point is a list of coordinates, e.g. - alignments[alpha][1][x] is coordinate x for point number - 1 of the spline that represents alignment alpha. - alignments can also be a compatible object that mimics a - 3-dimensional list using the __getitem__() method as is - the case in the PVAT specification. + points (class Point). ln_mv_av_win = moving average window (in points) in which to smooth lane changes. As per tools_math.cat_mvgavg(), this term is a search *radius* around the center of the window. @@ -1099,12 +1092,12 @@ self.curvilinearPositions = CurvilinearTrajectory() #For each point - for p in self.getPositions():#xrange(int(self.length())): - result = getSYfromXY(p, alignments) + for i in xrange(int(self.length())): + result = getSYfromXY(self.getPositionAt(i), alignments) # Error handling if(result == None): - print('Warning: trajectory {} at point {} has alignment errors (spline snapping)\nCurvilinear trajectory could not be computed'.format(self.getNum(), p)) + print('Warning: trajectory {} at point {} {} has alignment errors (spline snapping)\nCurvilinear trajectory could not be computed'.format(self.getNum(), i, self.getPositionAt(i))) else: [align, alignPoint, snappedPoint, subsegmentDistance, S, Y] = result self.curvilinearPositions.addPositionSYL(S, Y, align) @@ -1115,7 +1108,7 @@ ## Recalculate projected point to new lane lanes = self.curvilinearPositions.getLanes() if(lanes != smoothed_lanes): - for i in range(int(self.length())): + for i in xrange(len(lanes)): if(lanes[i] != smoothed_lanes[i]): result = getSYfromXY(self.getPositionAt(i),[alignments[smoothed_lanes[i]]]) @@ -1124,19 +1117,9 @@ ## This can be triggered by tracking errors when the trajectory jumps around passed another alignment. print(' Warning: trajectory {} at point {} {} has alignment errors during trajectory smoothing and will not be corrected.'.format(self.getNum(), i, self.getPositionAt(i))) else: - [align, alignPoint, snapped_x, snapped_y, subsegmentDistance, S, Y] = result + [align, alignPoint, snappedPoint, subsegmentDistance, S, Y] = result self.curvilinearPositions.setPosition(i, S, Y, align) - #Resize objects - # if(len(dropped_traj) > 0): - # objects = filter(None, objects) - # if(verbose >= 2): print(' Filtering report: Trajectories dropped: '+str(len(dropped_traj))) - #if(verbose >= 2): print(' Filtering report: Lane observation corrections per object: '+str(lane_readjustments/original_object_length)) - - #if(reset_objects and len(objects) > 0): return objects[0], dropped_traj - #else: return objects, dropped_traj - - def computeSmoothTrajectory(self, minCommonIntervalLength): '''Computes the trajectory as the mean of all features if a feature exists, its position is