Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/moving.py @ 1253:ef68d4ba7dae
added loading ego vehicle in kitti 2D format and method to plot outline
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 25 Mar 2024 17:05:20 -0400 |
| parents | fe35473acee3 |
| children | 20a5e1292321 |
comparison
equal
deleted
inserted
replaced
| 1252:fe35473acee3 | 1253:ef68d4ba7dae |
|---|---|
| 1412 2: 'car', | 1412 2: 'car', |
| 1413 3: 'motorcycle', | 1413 3: 'motorcycle', |
| 1414 5: 'bus', | 1414 5: 'bus', |
| 1415 #6: 'train', | 1415 #6: 'train', |
| 1416 7: 'truck'} | 1416 7: 'truck'} |
| 1417 kitti2Types = {'Car': 1, 'Cyclist': 4, 'Pedestrian': 2, 'Van': 1} | |
| 1417 | 1418 |
| 1418 userType2Num = utils.inverseEnumeration(userTypeNames) | 1419 userType2Num = utils.inverseEnumeration(userTypeNames) |
| 1419 | 1420 |
| 1420 class CarClassifier: | 1421 class CarClassifier: |
| 1421 def predict(self, hog): | 1422 def predict(self, hog): |
| 1438 self.velocities = velocities | 1439 self.velocities = velocities |
| 1439 self.geometry = geometry | 1440 self.geometry = geometry |
| 1440 self.userType = userType | 1441 self.userType = userType |
| 1441 self.setNObjects(nObjects) # a feature has None for nObjects | 1442 self.setNObjects(nObjects) # a feature has None for nObjects |
| 1442 self.features = features | 1443 self.features = features |
| 1444 if features is not None and len(features) > 1: | |
| 1445 self.featureNumbers = [f.getNum() for f in features] | |
| 1443 # compute bounding polygon from trajectory | 1446 # compute bounding polygon from trajectory |
| 1444 | 1447 |
| 1445 @staticmethod | 1448 @staticmethod |
| 1446 def croppedTimeInterval(obj, value, after = True): | 1449 def croppedTimeInterval(obj, value, after = True): |
| 1447 newTimeInterval = TimeInterval(obj.getFirstInstant(), min(value, obj.getLastInstant())) if after else TimeInterval(max(obj.getFirstInstant(), value), obj.getLastInstant()) | 1450 newTimeInterval = TimeInterval(obj.getFirstInstant(), min(value, obj.getLastInstant())) if after else TimeInterval(max(obj.getFirstInstant(), value), obj.getLastInstant()) |
| 1817 self.velocities.reset(0,0) | 1820 self.velocities.reset(0,0) |
| 1818 if self.hasFeatures(): | 1821 if self.hasFeatures(): |
| 1819 for f in self.getFeatures(): | 1822 for f in self.getFeatures(): |
| 1820 f.setStationary() | 1823 f.setStationary() |
| 1821 | 1824 |
| 1822 def plot(self, options = '', withOrigin = False, timeStep = 1, withFeatures = False, withIds = False, **kwargs): | 1825 def plot(self, options = '', withOrigin = False, timeStep = 1, withFeatures = False, withOutline = False, withIds = False, **kwargs): |
| 1823 if withIds: | 1826 if withIds: |
| 1824 objNum = self.getNum() | 1827 objNum = self.getNum() |
| 1825 else: | 1828 else: |
| 1826 objNum = None | 1829 objNum = None |
| 1827 if withFeatures and self.hasFeatures(): | 1830 if (withFeatures or withOutline) and self.hasFeatures(): |
| 1828 for f in self.getFeatures(): | 1831 if withOutline: |
| 1829 f.positions.plot('r', True, timeStep, **kwargs) | 1832 for t in self.getTimeInterval(): |
| 1830 self.positions.plot('bx-', True, timeStep, objNum, **kwargs) | 1833 if t%timeStep == 0: |
| 1834 self.plotOutlineAtInstant(t, cvutils.colors[self.getNum()%len(cvutils.colors)]+'-') | |
| 1835 self.positions.plot(cvutils.colors[self.getNum()%len(cvutils.colors)]+'-', withOrigin, timeStep, objNum, **kwargs) | |
| 1836 else: | |
| 1837 for f in self.getFeatures(): | |
| 1838 f.positions.plot('r', True, timeStep, **kwargs) | |
| 1839 self.positions.plot('bx-', True, timeStep, objNum, **kwargs) | |
| 1831 else: | 1840 else: |
| 1832 self.positions.plot(options, withOrigin, timeStep, objNum, **kwargs) | 1841 self.positions.plot(options, withOrigin, timeStep, objNum, **kwargs) |
| 1833 | 1842 |
| 1834 def plotOnWorldImage(self, nPixelsPerUnitDistance, options = '', withOrigin = False, timeStep = 1, withIds = False, **kwargs): | 1843 def plotOnWorldImage(self, nPixelsPerUnitDistance, options = '', withOrigin = False, timeStep = 1, withIds = False, **kwargs): |
| 1835 if withIds: | 1844 if withIds: |
