diff python/cvutils.py @ 218:b5772df11b37

corrected bugs to load objects and display trajectories over videos
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 21 Jun 2012 18:04:11 -0400
parents 51acf43e421a
children c31722fcc9de
line wrap: on
line diff
--- a/python/cvutils.py	Thu Jun 21 15:18:41 2012 -0400
+++ b/python/cvutils.py	Thu Jun 21 18:04:11 2012 -0400
@@ -129,16 +129,18 @@
         capture = cv2.VideoCapture(videoFilename)
         if capture.isOpened():
             key = -1
-            frameNum = 1
+            frameNum = 0
             while key!= 113: # 'q'
                 ret, img = capture.read()
                 if ret:
                     print(frameNum)
                     for obj in objects:
                         if obj.existsAtInstant(frameNum):
-                            #obj.getTimeInterval()
-                            if homography != None and obj.getFirstInstant() == frameNum:
-                                obj.projectedPositions = obj.positions.project(homography)
+                            if obj.getFirstInstant() == frameNum:
+                                if homography != None:
+                                    obj.projectedPositions = obj.positions.project(homography)
+                                else:
+                                    obj.projectedPositions = obj.positions
                             draw(img, obj.projectedPositions, cvRed, frameNum-obj.getFirstInstant())
                             cv2.putText(img, '{0}'.format(obj.num), obj.projectedPositions[frameNum-obj.getFirstInstant()].astuple(), cv2.FONT_HERSHEY_PLAIN, 1, cvRed)
                     cv2.imshow('frame', img)