diff python/moving.py @ 928:063d1267585d

work in progress
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 12 Jul 2017 01:24:31 -0400
parents 630934595871
children be28a3538dc9
line wrap: on
line diff
--- a/python/moving.py	Tue Jul 11 17:56:23 2017 -0400
+++ b/python/moving.py	Wed Jul 12 01:24:31 2017 -0400
@@ -551,7 +551,7 @@
     speedOrientation is the other encoding of velocity, (speed, orientation)
     speedOrientation and control are NormAngle'''
     predictedSpeedTheta = speedOrientation+control
-    if maxSpeed:
+    if maxSpeed is not None:
          predictedSpeedTheta.norm = min(predictedSpeedTheta.norm, maxSpeed)
     predictedPosition = position+predictedSpeedTheta.getPoint()
     return predictedPosition, predictedSpeedTheta
@@ -1561,7 +1561,7 @@
         self.setUserType(utils.argmaxDict(userTypeProbabilities))
         return userTypeProbabilities
 
-    def initClassifyUserTypeHoGSVM(self, aggregationFunc, pedBikeCarSVM, bikeCarSVM = None, pedBikeSpeedTreshold = float('Inf'), bikeCarSpeedThreshold = float('Inf'), nInstantsIgnoredAtEnds = 0):
+    def initClassifyUserTypeHoGSVM(self, aggregationFunc, pedBikeCarSVM, bikeCarSVM = None, pedBikeSpeedTreshold = float('Inf'), bikeCarSpeedThreshold = float('Inf'), nInstantsIgnoredAtEnds = 0, homography = None, intrinsicCameraMatrix = None, distortionCoefficients = None):
         '''Initializes the data structures for classification
 
         TODO? compute speed for longest feature?'''
@@ -1575,7 +1575,10 @@
                 def predict(self, hog):
                     return userType2Num['car']
             self.appearanceClassifier = CarClassifier()
-        
+        # project feature positions
+        if self.hasFeatures():
+            for f in self.getFeatures():
+                f.projectedPositions = cvutils.projectArray(homography, f.getPositions().asArray(), intrinsicCameraMatrix, distortionCoefficients)
         self.userTypes = {}
 
     def classifyUserTypeHoGSVMAtInstant(self, img, instant, homography, width, height, px, py, minNPixels, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, blockNorm):