Mercurial Hosting > traffic-intelligence
diff 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 |
line wrap: on
line diff
--- a/trafficintelligence/moving.py Thu Sep 07 16:20:28 2023 -0400 +++ b/trafficintelligence/moving.py Fri Sep 08 17:09:12 2023 -0400 @@ -817,6 +817,34 @@ t.addPosition(p) return t + @staticmethod + def fromPointDict(points): + '''Points is a dict of points where keys are time instants + and there are (probably) missing positions''' + instants = sorted(list(points)) + # find all gaps + t1 = instants[0] + gap = False + gaps = [] + for t in range(instants[0], instants[-1]+1): + if t in instants: + if gap: + t2 = t + # store gap + gaps.append([t1, t2]) + gap = False + t1 = t + else: + t1 = t + else: + gap = True + # interpolate for gaps + for gap in gaps: + v = (points[gap[1]]-points[gap[0]]).divide(gap[1]-gap[0]) + for t in range(gap[0]+1, gap[1]): + points[t]=points[t-1]+v + return Trajectory.fromPointList([points[t] for t in range(instants[0], instants[-1]+1)]) + def __len__(self): return len(self.positions[0]) @@ -1376,13 +1404,13 @@ 'truck', 'automated'] -coco2Types = {0: 2, 1: 4, 2: 1, 5: 5, 7: 6} +coco2Types = {0: 2, 1: 4, 2: 1, 3: 3, 5: 5, 7: 6} cocoTypeNames = {0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 5: 'bus', - 6: 'train', + #6: 'train', 7: 'truck'} userType2Num = utils.inverseEnumeration(userTypeNames)