Mercurial > hg > nsaunier > traffic-intelligence
changeset 1283:77a310e29233
work on stationary objects
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 16 Jul 2024 12:06:34 -0400 |
| parents | 106365257da9 |
| children | 8e30c9a6ac6f 5ac26907e3c3 |
| files | trafficintelligence/moving.py |
| diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/trafficintelligence/moving.py Tue Jul 09 17:44:51 2024 -0400 +++ b/trafficintelligence/moving.py Tue Jul 16 12:06:34 2024 -0400 @@ -53,7 +53,7 @@ def equal(self, i2): return self.first==i2.first and self.last == i2.last - def getList(self): + def aslist(self): return [self.first, self.last] def contains(self, instant): @@ -1583,6 +1583,16 @@ print('The object does not exist at {}'.format(inter)) return None + def splitOverTime(self, instants, minObjectDuration = 1): + '''Returns objects for each sub-time intervals: + [first instant, t1], [t1+1, t2], [t2+1, t3], ... [tn, last instant] + if duration more than minObjectDuration''' + subObjects = [] + for t1, t2 in zip([self.getFirstInstant()-1]+instants, instants+[self.getLastInstant()]): + if t2-t1-1 >= minObjectDuration: + subObjects.append(self.getObjectInTimeInterval(TimeInterval(t1+1, t2))) + return subObjects + def getObjectsInMask(self, mask, homography = None, minLength = 1): '''Returns new objects made of the positions in the mask mask is in the destination of the homography space''' @@ -1841,8 +1851,7 @@ def isStationary(self, speedThreshold, distanceThreshold): '''Indicates if object is not moving if speed on average below threshold and final-initial position close enough - - TODO: returns time interval stationary if starts moving or stops moving''' + or the largest time interval during which the object is stationary (same condition)''' speeds = self.getSpeeds() if quantile(speeds, 0.5) <= speedThreshold and Point.distanceNorm2(self.getPositionAt(0),self.getPositionAt(-1)) <= distanceThreshold: return True, None
