comparison python/moving.py @ 626:35155ac2a294

corrected bugs, in particular to MovingObject.play
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 14 Feb 2015 19:18:14 -0500
parents bac66bd536c5
children 82e9f78a4714
comparison
equal deleted inserted replaced
625:9202628a4130 626:35155ac2a294
791 count = 0 791 count = 0
792 lengthThreshold = float(self.length())*minProportion 792 lengthThreshold = float(self.length())*minProportion
793 for p in self: 793 for p in self:
794 if p.similarOrientation(refDirection, cosineThreshold): 794 if p.similarOrientation(refDirection, cosineThreshold):
795 count += 1 795 count += 1
796 if count > lengthThreshold: 796 if count > lengthThreshold:
797 return True 797 return True
798 return False 798 else:
799 return False
799 800
800 def wiggliness(self): 801 def wiggliness(self):
801 return self.getCumulativeDistance(self.length()-1)/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1))) 802 return self.getCumulativeDistance(self.length()-1)/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1)))
802 803
803 def getIntersections(self, p1, p2): 804 def getIntersections(self, p1, p2):
1068 self.positions.plot(options, withOrigin, timeStep, **kwargs) 1069 self.positions.plot(options, withOrigin, timeStep, **kwargs)
1069 1070
1070 def plotOnWorldImage(self, nPixelsPerUnitDistance, options = '', withOrigin = False, timeStep = 1, **kwargs): 1071 def plotOnWorldImage(self, nPixelsPerUnitDistance, options = '', withOrigin = False, timeStep = 1, **kwargs):
1071 self.positions.plotOnWorldImage(nPixelsPerUnitDistance, options, withOrigin, timeStep, **kwargs) 1072 self.positions.plotOnWorldImage(nPixelsPerUnitDistance, options, withOrigin, timeStep, **kwargs)
1072 1073
1073 def play(self, videoFilename, homography = None): 1074 def play(self, videoFilename, homography = None, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1.):
1074 cvutils.displayTrajectories(videoFilename, [self], homography, self.getFirstInstant(), self.getLastInstant()) 1075 cvutils.displayTrajectories(videoFilename, [self], homography = homography, firstFrameNum = self.getFirstInstant(), lastFrameNumArg = self.getLastInstant(), undistort = undistort, intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = distortionCoefficients, undistortedImageMultiplication = undistortedImageMultiplication)
1075 1076
1076 def speedDiagnostics(self, framerate = 1., display = False): 1077 def speedDiagnostics(self, framerate = 1., display = False):
1077 from numpy import std 1078 from numpy import std
1078 from scipy.stats import scoreatpercentile 1079 from scipy.stats import scoreatpercentile
1079 speeds = framerate*self.getSpeeds() 1080 speeds = framerate*self.getSpeeds()
1241 e.g. def indic(x): 1242 e.g. def indic(x):
1242 if abs(x-mu) < sigma: 1243 if abs(x-mu) < sigma:
1243 return 1 1244 return 1
1244 else: 1245 else:
1245 return x''' 1246 return x'''
1246 if not hasattr(self, aggregatedSpeed): 1247 if not hasattr(self, 'aggregatedSpeed'):
1247 self.aggregatedSpeed = aggregationFunc(self.getSpeeds()) 1248 self.aggregatedSpeed = aggregationFunc(self.getSpeeds())
1248 userTypeProbabilities = {} 1249 userTypeProbabilities = {}
1249 for userTypename in speedProbabilities: 1250 for userTypename in speedProbabilities:
1250 userTypeProbabilities[userType2Num[userTypename]] = speedProbabilities[userTypename](self.aggregatedSpeed) 1251 userTypeProbabilities[userType2Num[userTypename]] = speedProbabilities[userTypename](self.aggregatedSpeed)
1251 self.setUserType(utils.argmaxDict(userTypeProbabilities)) 1252 self.setUserType(utils.argmaxDict(userTypeProbabilities))