Mercurial Hosting > traffic-intelligence
diff python/moving.py @ 377:2aed569f39e7
added utils
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 18 Jul 2013 02:08:51 -0400 |
parents | 349eb1e09f45 |
children | 3805b9639647 |
line wrap: on
line diff
--- a/python/moving.py Wed Jul 17 18:19:08 2013 -0400 +++ b/python/moving.py Thu Jul 18 02:08:51 2013 -0400 @@ -687,6 +687,18 @@ def play(self, videoFilename, homography = None): cvutils.displayTrajectories(videoFilename, [self], homography, self.getFirstInstant(), self.getLastInstant()) + def speedDiagnostics(self, display = False): + from numpy import std + speeds = self.getSpeeds() + coef = utils.linearRegression(range(len(speeds)), speeds) + print(speeds[-2]-speeds[1], std(speeds), coef[0]) + if display: + from matplotlib.pyplot import figure, plot + figure(1) + self.draw() + figure(2) + plot(list(self.getTimeInterval()), speeds) + def getInstantsCrossingLane(self, p1, p2): '''Returns the instant(s) at which the object passes from one side of the segment to the other