Mercurial Hosting > traffic-intelligence
changeset 515:727e3c529519
renamed all draw functions to plot for consistency
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 06 Jun 2014 14:10:42 -0400 |
parents | 1ba618fb0f70 |
children | bce1fe45d1b2 |
files | python/cvutils.py python/ml.py python/moving.py python/prediction.py |
diffstat | 4 files changed, 35 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/python/cvutils.py Thu Jun 05 17:50:42 2014 -0400 +++ b/python/cvutils.py Fri Jun 06 14:10:42 2014 -0400 @@ -36,7 +36,7 @@ def saveKey(key): return chr(key&255) == 's' -def drawLines(filename, origins, destinations, w = 1, resultFilename='image.png'): +def plotLines(filename, origins, destinations, w = 1, resultFilename='image.png'): '''Draws lines over the image ''' import Image, ImageDraw # PIL @@ -48,7 +48,7 @@ for p1, p2 in zip(origins, destinations): draw.line([p1.x, p1.y, p2.x, p2.y], width = w, fill = (256,0,0)) #draw.line([p1.x, p1.y, p2.x, p2.y], pen) - del draw + del draw #out = utils.openCheck(resultFilename) img.save(resultFilename) @@ -93,7 +93,7 @@ cvmat[i,j] = a[i,j] return cvmat - def draw(img, positions, color, lastCoordinate = None): + def cvPlot(img, positions, color, lastCoordinate = None): last = lastCoordinate+1 if lastCoordinate != None and lastCoordinate >=0: last = min(positions.length()-1, lastCoordinate) @@ -247,7 +247,7 @@ obj.projectedPositions = obj.positions.project(homography) else: obj.projectedPositions = obj.positions - draw(img, obj.projectedPositions, cvRed, frameNum-obj.getFirstInstant()) + cvPlot(img, obj.projectedPositions, cvRed, frameNum-obj.getFirstInstant()) if frameNum in boundingBoxes.keys(): for rect in boundingBoxes[frameNum]: cv2.rectangle(img, rect[0].asint().astuple(), rect[1].asint().astuple(), cvRed)
--- a/python/ml.py Thu Jun 05 17:50:42 2014 -0400 +++ b/python/ml.py Fri Jun 06 14:10:42 2014 -0400 @@ -48,9 +48,9 @@ inst.multiply(1/(self.nInstances+instance.nInstances)) return Centroid(inst, self.nInstances+instance.nInstances) - def draw(self, options = ''): + def plot(self, options = ''): from matplotlib.pylab import text - self.instance.draw(options) + self.instance.plot(options) text(self.instance.position.x+1, self.instance.position.y+1, str(self.nInstances)) def kMedoids(similarityMatrix, initialCentroids = None, k = None):
--- a/python/moving.py Thu Jun 05 17:50:42 2014 -0400 +++ b/python/moving.py Fri Jun 06 14:10:42 2014 -0400 @@ -179,7 +179,7 @@ def multiply(self, alpha): return Point(self.x*alpha, self.y*alpha) - def draw(self, options = 'o', **kwargs): + def plot(self, options = 'o', **kwargs): from matplotlib.pylab import plot plot([self.x], [self.y], options, **kwargs) @@ -360,10 +360,10 @@ def multiply(self, alpha): return FlowVector(self.position.multiply(alpha), self.velocity.multiply(alpha)) - def draw(self, options = '', **kwargs): + def plot(self, options = '', **kwargs): from matplotlib.pylab import plot plot([self.position.x, self.position.x+self.velocity.x], [self.position.y, self.position.y+self.velocity.y], options, **kwargs) - self.position.draw(options+'x', **kwargs) + self.position.plot(options+'x', **kwargs) @staticmethod def similar(f1, f2, maxDistance2, maxDeltavelocity2): @@ -474,7 +474,7 @@ self.positions[1].append(self.positions[1][-1]) @staticmethod - def _draw(positions, options = '', withOrigin = False, lastCoordinate = None, timeStep = 1, **kwargs): + def _plot(positions, options = '', withOrigin = False, lastCoordinate = None, timeStep = 1, **kwargs): from matplotlib.pylab import plot if lastCoordinate == None: plot(positions[0][::timeStep], positions[1][::timeStep], options, **kwargs) @@ -486,17 +486,17 @@ def project(self, homography): return Trajectory(cvutils.projectTrajectory(homography, self.positions)) - def draw(self, options = '', withOrigin = False, timeStep = 1, **kwargs): - Trajectory._draw(self.positions, options, withOrigin, None, timeStep, **kwargs) + def plot(self, options = '', withOrigin = False, timeStep = 1, **kwargs): + Trajectory._plot(self.positions, options, withOrigin, None, timeStep, **kwargs) - def drawAt(self, lastCoordinate, options = '', withOrigin = False, timeStep = 1, **kwargs): - Trajectory._draw(self.positions, options, withOrigin, lastCoordinate, timeStep, **kwargs) + def plotAt(self, lastCoordinate, options = '', withOrigin = False, timeStep = 1, **kwargs): + Trajectory._plot(self.positions, options, withOrigin, lastCoordinate, timeStep, **kwargs) - def drawOnWorldImage(self, nPixelsPerUnitDistance, imageHeight, options = '', withOrigin = False, timeStep = 1, **kwargs): + def plotOnWorldImage(self, nPixelsPerUnitDistance, imageHeight, options = '', withOrigin = False, timeStep = 1, **kwargs): from matplotlib.pylab import plot imgPositions = [[x*nPixelsPerUnitDistance for x in self.positions[0]], [-x*nPixelsPerUnitDistance+imageHeight for x in self.positions[1]]] - Trajectory._draw(imgPositions, options, withOrigin, timeStep, **kwargs) + Trajectory._plot(imgPositions, options, withOrigin, timeStep, **kwargs) def getXCoordinates(self): return self.positions[0] @@ -747,11 +747,11 @@ def getYCoordinates(self): return self.positions.getYCoordinates() - def draw(self, options = '', withOrigin = False, timeStep = 1, **kwargs): - self.positions.draw(options, withOrigin, timeStep, **kwargs) + def plot(self, options = '', withOrigin = False, timeStep = 1, **kwargs): + self.positions.plot(options, withOrigin, timeStep, **kwargs) - def drawOnWorldImage(self, nPixelsPerUnitDistance, imageHeight, options = '', withOrigin = False, timeStep = 1, **kwargs): - self.positions.drawOnWorldImage(nPixelsPerUnitDistance, imageHeight, options, withOrigin, timeStep, **kwargs) + def plotOnWorldImage(self, nPixelsPerUnitDistance, imageHeight, options = '', withOrigin = False, timeStep = 1, **kwargs): + self.positions.plotOnWorldImage(nPixelsPerUnitDistance, imageHeight, options, withOrigin, timeStep, **kwargs) def play(self, videoFilename, homography = None): cvutils.displayTrajectories(videoFilename, [self], homography, self.getFirstInstant(), self.getLastInstant()) @@ -765,7 +765,7 @@ if display: from matplotlib.pyplot import figure, plot, axis figure(1) - self.draw() + self.plot() axis('equal') figure(2) plot(list(self.getTimeInterval()), speeds) @@ -844,7 +844,7 @@ from matplotlib.pyplot import figure, axis figure() for obj in objects: - obj.draw(colors.get(obj.userType)) + obj.plot(colors.get(obj.userType)) axis('equal')
--- a/python/prediction.py Thu Jun 05 17:50:42 2014 -0400 +++ b/python/prediction.py Fri Jun 06 14:10:42 2014 -0400 @@ -30,8 +30,8 @@ def getPredictedSpeeds(self): return [so.norm for so in self.predictedSpeedOrientations.values()] - def draw(self, options = '', withOrigin = False, timeStep = 1, **kwargs): - self.getPredictedTrajectory().draw(options, withOrigin, timeStep, **kwargs) + def plot(self, options = '', withOrigin = False, timeStep = 1, **kwargs): + self.getPredictedTrajectory().plot(options, withOrigin, timeStep, **kwargs) class PredictedTrajectoryConstant(PredictedTrajectory): '''Predicted trajectory at constant speed or acceleration @@ -170,13 +170,13 @@ figure() for et in predictedTrajectories1: et.predictPosition(timeHorizon) - et.draw('rx') + et.plot('rx') for et in predictedTrajectories2: et.predictPosition(timeHorizon) - et.draw('bx') - obj1.draw('r') - obj2.draw('b') + et.plot('bx') + obj1.plot('r') + obj2.plot('b') title('instant {0}'.format(currentInstant)) axis('equal') @@ -222,13 +222,13 @@ figure() for et in predictedTrajectories1: et.predictPosition(timeHorizon) - et.draw('rx') + et.plot('rx') for et in predictedTrajectories2: et.predictPosition(timeHorizon) - et.draw('bx') - obj1.draw('r') - obj2.draw('b') + et.plot('bx') + obj1.plot('r') + obj2.plot('b') title('instant {0}'.format(i)) axis('equal') @@ -376,9 +376,9 @@ figure() plot([p1.x, intersection.x], [p1.y, intersection.y], 'r') plot([p2.x, intersection.x], [p2.y, intersection.y], 'b') - intersection.draw() - obj1.draw('r') - obj2.draw('b') + intersection.plot() + obj1.plot('r') + obj2.plot('b') title('instant {0}'.format(currentInstant)) axis('equal')