Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/moving.py @ 1233:d5695e0b59d9
saving results from ultralytics works
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 08 Sep 2023 17:09:12 -0400 |
| parents | 5654c9173548 |
| children | bb14f919d1cb |
comparison
equal
deleted
inserted
replaced
| 1232:83ca1493d55c | 1233:d5695e0b59d9 |
|---|---|
| 815 else: | 815 else: |
| 816 for p in points: | 816 for p in points: |
| 817 t.addPosition(p) | 817 t.addPosition(p) |
| 818 return t | 818 return t |
| 819 | 819 |
| 820 @staticmethod | |
| 821 def fromPointDict(points): | |
| 822 '''Points is a dict of points where keys are time instants | |
| 823 and there are (probably) missing positions''' | |
| 824 instants = sorted(list(points)) | |
| 825 # find all gaps | |
| 826 t1 = instants[0] | |
| 827 gap = False | |
| 828 gaps = [] | |
| 829 for t in range(instants[0], instants[-1]+1): | |
| 830 if t in instants: | |
| 831 if gap: | |
| 832 t2 = t | |
| 833 # store gap | |
| 834 gaps.append([t1, t2]) | |
| 835 gap = False | |
| 836 t1 = t | |
| 837 else: | |
| 838 t1 = t | |
| 839 else: | |
| 840 gap = True | |
| 841 # interpolate for gaps | |
| 842 for gap in gaps: | |
| 843 v = (points[gap[1]]-points[gap[0]]).divide(gap[1]-gap[0]) | |
| 844 for t in range(gap[0]+1, gap[1]): | |
| 845 points[t]=points[t-1]+v | |
| 846 return Trajectory.fromPointList([points[t] for t in range(instants[0], instants[-1]+1)]) | |
| 847 | |
| 820 def __len__(self): | 848 def __len__(self): |
| 821 return len(self.positions[0]) | 849 return len(self.positions[0]) |
| 822 | 850 |
| 823 def length(self): | 851 def length(self): |
| 824 return self.__len__() | 852 return self.__len__() |
| 1374 'bicycle', | 1402 'bicycle', |
| 1375 'bus', | 1403 'bus', |
| 1376 'truck', | 1404 'truck', |
| 1377 'automated'] | 1405 'automated'] |
| 1378 | 1406 |
| 1379 coco2Types = {0: 2, 1: 4, 2: 1, 5: 5, 7: 6} | 1407 coco2Types = {0: 2, 1: 4, 2: 1, 3: 3, 5: 5, 7: 6} |
| 1380 cocoTypeNames = {0: 'person', | 1408 cocoTypeNames = {0: 'person', |
| 1381 1: 'bicycle', | 1409 1: 'bicycle', |
| 1382 2: 'car', | 1410 2: 'car', |
| 1383 3: 'motorcycle', | 1411 3: 'motorcycle', |
| 1384 5: 'bus', | 1412 5: 'bus', |
| 1385 6: 'train', | 1413 #6: 'train', |
| 1386 7: 'truck'} | 1414 7: 'truck'} |
| 1387 | 1415 |
| 1388 userType2Num = utils.inverseEnumeration(userTypeNames) | 1416 userType2Num = utils.inverseEnumeration(userTypeNames) |
| 1389 | 1417 |
| 1390 class CarClassifier: | 1418 class CarClassifier: |
