Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 182:d3f6de6c3918
added drawing functialities, in particular on aerial image
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 24 Nov 2011 19:00:04 -0500 |
parents | 74b1fc68d4df |
children | d70e9b36889c |
comparison
equal
deleted
inserted
replaced
181:42142c5223ce | 182:d3f6de6c3918 |
---|---|
265 self.positions[0].append(x) | 265 self.positions[0].append(x) |
266 self.positions[1].append(y) | 266 self.positions[1].append(y) |
267 | 267 |
268 def addPosition(self, p): | 268 def addPosition(self, p): |
269 self.addPositionXY(p.x, p.y) | 269 self.addPositionXY(p.x, p.y) |
270 | 270 |
271 def draw(self, options = ''): | 271 @staticmethod |
272 def _draw(positions, options = '', withOrigin = False): | |
272 from matplotlib.pylab import plot | 273 from matplotlib.pylab import plot |
273 plot(self.positions[0], self.positions[1], options) | 274 plot(positions[0], positions[1], options) |
275 if withOrigin: | |
276 plot([positions[0][0]], [positions[1][0]], 'ro') | |
277 | |
278 def draw(self, options = '', withOrigin = False): | |
279 Trajectory._draw(self.positions, options, withOrigin) | |
280 | |
281 def drawOnImage(self, nPixelsPerUnitDistance, imageHeight, options = '', withOrigin = False): | |
282 from matplotlib.pylab import plot | |
283 imgPositions = [[x*nPixelsPerUnitDistance for x in self.positions[0]], | |
284 [-x*nPixelsPerUnitDistance+imageHeight for x in self.positions[1]]] | |
285 Trajectory._draw(imgPositions, options, withOrigin) | |
274 | 286 |
275 def length(self): | 287 def length(self): |
276 return len(self.positions[0]) | 288 return len(self.positions[0]) |
277 | 289 |
278 def getXCoordinates(self): | 290 def getXCoordinates(self): |
433 return self.positions.getXCoordinates() | 445 return self.positions.getXCoordinates() |
434 | 446 |
435 def getYCoordinates(self): | 447 def getYCoordinates(self): |
436 return self.positions.getYCoordinates() | 448 return self.positions.getYCoordinates() |
437 | 449 |
438 def draw(self, options = ''): | 450 def draw(self, options = '', withOrigin = False): |
439 self.positions.draw(options) | 451 self.positions.draw(options, withOrigin) |
452 | |
453 def drawOnImage(self, nPixelsPerUnitDistance, imageHeight, options = '', withOrigin = False): | |
454 self.positions.drawOnImage(nPixelsPerUnitDistance, imageHeight, options, withOrigin) | |
440 | 455 |
441 def getInstantsCrossingLane(self, p1, p2): | 456 def getInstantsCrossingLane(self, p1, p2): |
442 '''Returns the instant(s) | 457 '''Returns the instant(s) |
443 at which the object passes from one side of the segment to the other | 458 at which the object passes from one side of the segment to the other |
444 empty list if there is no crossing''' | 459 empty list if there is no crossing''' |