comparison python/moving.py @ 622:dc8490726d06

corrected issues created with homography projection in Trajectory
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 22 Dec 2014 16:29:34 -0500
parents 582508610572
children ce7133cbcdf3
comparison
equal deleted inserted replaced
621:582508610572 622:dc8490726d06
674 plot(positions[0][:lastCoordinate:timeStep], positions[1][:lastCoordinate:timeStep], options, **kwargs) 674 plot(positions[0][:lastCoordinate:timeStep], positions[1][:lastCoordinate:timeStep], options, **kwargs)
675 if withOrigin: 675 if withOrigin:
676 plot([positions[0][0]], [positions[1][0]], 'ro', **kwargs) 676 plot([positions[0][0]], [positions[1][0]], 'ro', **kwargs)
677 677
678 def project(self, homography): 678 def project(self, homography):
679 return Trajectory(cvutils.projectTrajectory(homography, self.positions)) 679 return Trajectory(cvutils.projectTrajectory(homography, self.positions).tolist())
680 680
681 def plot(self, options = '', withOrigin = False, timeStep = 1, **kwargs): 681 def plot(self, options = '', withOrigin = False, timeStep = 1, **kwargs):
682 Trajectory._plot(self.positions, options, withOrigin, None, timeStep, **kwargs) 682 Trajectory._plot(self.positions, options, withOrigin, None, timeStep, **kwargs)
683 683
684 def plotAt(self, lastCoordinate, options = '', withOrigin = False, timeStep = 1, **kwargs): 684 def plotAt(self, lastCoordinate, options = '', withOrigin = False, timeStep = 1, **kwargs):
815 ratio = 0 815 ratio = 0
816 indices.append(i+ratio) 816 indices.append(i+ratio)
817 return indices 817 return indices
818 818
819 def getTrajectoryInInterval(self, inter): 819 def getTrajectoryInInterval(self, inter):
820 'Returns all position between index inter.first and index.last (included)'
820 if inter.first >=0 and inter.last<= self.length(): 821 if inter.first >=0 and inter.last<= self.length():
821 return Trajectory([self.positions[0][inter.first:inter.last], 822 return Trajectory([self.positions[0][inter.first:inter.last+1],
822 self.positions[1][inter.first:inter.last]]) 823 self.positions[1][inter.first:inter.last+1]])
823 else: 824 else:
824 return None 825 return None
825 826
826 def getTrajectoryInPolygonNoShapely(self, polygon): 827 def getTrajectoryInPolygonNoShapely(self, polygon):
827 '''Returns the trajectory built with the set of points inside the polygon 828 '''Returns the trajectory built with the set of points inside the polygon
943 944
944 @staticmethod 945 @staticmethod
945 def generate(p, v, timeInterval): 946 def generate(p, v, timeInterval):
946 positions, velocities = Trajectory.generate(p, v, int(timeInterval.length())) 947 positions, velocities = Trajectory.generate(p, v, int(timeInterval.length()))
947 return MovingObject(timeInterval = timeInterval, positions = positions, velocities = velocities) 948 return MovingObject(timeInterval = timeInterval, positions = positions, velocities = velocities)
949
950 @staticmethod
951 def concatenate(obj1, obj2):
952 ''' '''
953 pass
948 954
949 def getObjectInTimeInterval(self, inter): 955 def getObjectInTimeInterval(self, inter):
950 '''Returns a new object extracted from self, 956 '''Returns a new object extracted from self,
951 restricted to time interval inter''' 957 restricted to time interval inter'''
952 intersection = TimeInterval.intersection(inter, self.getTimeInterval()) 958 intersection = TimeInterval.intersection(inter, self.getTimeInterval())