Mercurial Hosting > traffic-intelligence
comparison trafficintelligence/moving.py @ 1125:b358bed29ab4
updates and bugs
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 30 Jan 2020 10:17:07 -0500 |
parents | bb58506c1bfd |
children | 2682b4696cdf |
comparison
equal
deleted
inserted
replaced
1118:234e2228fd30 | 1125:b358bed29ab4 |
---|---|
736 result = result and (p == po) | 736 result = result and (p == po) |
737 return result | 737 return result |
738 else: | 738 else: |
739 return False | 739 return False |
740 | 740 |
741 def append(self,other): | |
742 '''adds positions of other to the trajectory (in-place modification)''' | |
743 for p in other: | |
744 self.addPosition(p) | |
745 | |
741 def setPositionXY(self, i, x, y): | 746 def setPositionXY(self, i, x, y): |
742 if i < self.__len__(): | 747 if i < self.__len__(): |
743 self.positions[0][i] = x | 748 self.positions[0][i] = x |
744 self.positions[1][i] = y | 749 self.positions[1][i] = y |
745 | 750 |
1074 S.append(S[-1]+v) | 1079 S.append(S[-1]+v) |
1075 Y = [y]*nPoints | 1080 Y = [y]*nPoints |
1076 lanes = [lane]*nPoints | 1081 lanes = [lane]*nPoints |
1077 return CurvilinearTrajectory(S, Y, lanes) | 1082 return CurvilinearTrajectory(S, Y, lanes) |
1078 | 1083 |
1079 def append(self,other): | |
1080 '''adds positions of other to the curvilinear trajectory (in-place modification)''' | |
1081 for p in other: | |
1082 self.addPosition(p) | |
1083 | |
1084 @staticmethod | 1084 @staticmethod |
1085 def fromTrajectoryProjection(t, alignments, halfWidth = 3): | 1085 def fromTrajectoryProjection(t, alignments, halfWidth = 3): |
1086 ''' Add, for every object position, the class 'moving.CurvilinearTrajectory()' | 1086 ''' Add, for every object position, the class 'moving.CurvilinearTrajectory()' |
1087 (curvilinearPositions instance) which holds information about the | 1087 (curvilinearPositions instance) which holds information about the |
1088 curvilinear coordinates using alignment metadata. | 1088 curvilinear coordinates using alignment metadata. |
1214 'car', | 1214 'car', |
1215 'pedestrian', | 1215 'pedestrian', |
1216 'motorcycle', | 1216 'motorcycle', |
1217 'bicycle', | 1217 'bicycle', |
1218 'bus', | 1218 'bus', |
1219 'truck'] | 1219 'truck', |
1220 'automated'] | |
1220 | 1221 |
1221 userType2Num = utils.inverseEnumeration(userTypeNames) | 1222 userType2Num = utils.inverseEnumeration(userTypeNames) |
1222 | 1223 |
1223 class CarClassifier: | 1224 class CarClassifier: |
1224 def predict(self, hog): | 1225 def predict(self, hog): |
1423 if hasattr(self, 'curvilinearPositions'): | 1424 if hasattr(self, 'curvilinearPositions'): |
1424 return self.curvilinearPositions | 1425 return self.curvilinearPositions |
1425 else: | 1426 else: |
1426 return None | 1427 return None |
1427 | 1428 |
1429 def getCurvilinearVelocities(self): | |
1430 if hasattr(self, 'curvilinearVelocities'): | |
1431 return self.curvilinearVelocities | |
1432 else: | |
1433 return None | |
1434 | |
1428 def plotCurvilinearPositions(self, lane = None, options = '', withOrigin = False, **kwargs): | 1435 def plotCurvilinearPositions(self, lane = None, options = '', withOrigin = False, **kwargs): |
1429 if hasattr(self, 'curvilinearPositions'): | 1436 if hasattr(self, 'curvilinearPositions'): |
1430 if lane is None: | 1437 if lane is None: |
1431 plot(list(self.getTimeInterval()), self.curvilinearPositions.positions[0], options, **kwargs) | 1438 plot(list(self.getTimeInterval()), self.curvilinearPositions.positions[0], options, **kwargs) |
1432 if withOrigin: | 1439 if withOrigin: |